fix(stripe): remove decimals on amounts (#187)

* fix: floor amounts

* fix: round instead of floor
This commit is contained in:
Sebastian Rindom
2021-02-27 10:08:05 +01:00
committed by GitHub
parent 1b7fa59bf7
commit 999e8053ea
@@ -141,7 +141,7 @@ class StripeProviderService extends PaymentService {
const amount = await this.totalsService_.getTotal(cart) const amount = await this.totalsService_.getTotal(cart)
const intentRequest = { const intentRequest = {
amount: amount, amount: Math.round(amount),
currency: currency_code, currency: currency_code,
setup_future_usage: "on_session", setup_future_usage: "on_session",
capture_method: this.options_.capture ? "automatic" : "manual", capture_method: this.options_.capture ? "automatic" : "manual",
@@ -242,12 +242,12 @@ class StripeProviderService extends PaymentService {
if (stripeId !== sessionData.customer) { if (stripeId !== sessionData.customer) {
return this.createPayment(cart) return this.createPayment(cart)
} else { } else {
if (cart.total && sessionData.amount === cart.total) { if (cart.total && sessionData.amount === Math.round(cart.total)) {
return sessionData return sessionData
} }
return this.stripe_.paymentIntents.update(sessionData.id, { return this.stripe_.paymentIntents.update(sessionData.id, {
amount: cart.total, amount: Math.round(cart.total),
}) })
} }
} catch (error) { } catch (error) {
@@ -309,7 +309,7 @@ class StripeProviderService extends PaymentService {
const { id } = payment.data const { id } = payment.data
try { try {
await this.stripe_.refunds.create({ await this.stripe_.refunds.create({
amount: amountToRefund, amount: Math.round(amountToRefund),
payment_intent: id, payment_intent: id,
}) })