Skip to content

Commit

Permalink
fix(locksmith): fixed cents calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
julien51 committed Oct 2, 2024
1 parent 6946c37 commit 49e5dde
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions locksmith/src/payment/paymentProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class PaymentProcessor {
throw new Error('We could not compute the pricing.')
}

if (Math.abs(pricing.total - maxPrice) > 0.03 * maxPrice) {
if (Math.abs(pricing.total * 100 - maxPrice) > 0.03 * maxPrice) {
// if price diverged by more than 3%, we fail!
throw new Error('Price diverged by more than 3%. Aborting')
}
Expand Down Expand Up @@ -133,7 +133,7 @@ export class PaymentProcessor {
clientSecret: stripeIntent.client_secret,
stripeAccount,
pricing,
totalPriceInCents: pricing.total,
totalPriceInCents: pricing.total * 100,
}
}
}
Expand Down Expand Up @@ -200,7 +200,7 @@ export class PaymentProcessor {
})

const paymentIntentParams: any = {
amount: pricing.total,
amount: pricing.total * 100,
currency: creditCardCurrency,
customer: connectedCustomer.id,
payment_method: method.id,
Expand Down Expand Up @@ -250,7 +250,7 @@ export class PaymentProcessor {
return {
clientSecret: intent.client_secret,
stripeAccount,
totalPriceInCents: pricing.total,
totalPriceInCents: pricing.total * 100,
pricing,
}
}
Expand Down Expand Up @@ -301,7 +301,7 @@ export class PaymentProcessor {
throw new Error('Could not compute the pricing.')
}

const totalPriceInCents = pricing.total
const totalPriceInCents = pricing.total * 100

const paymentIntentRecord = await PaymentIntent.findOne({
where: { intentId: paymentIntentId },
Expand Down

0 comments on commit 49e5dde

Please sign in to comment.