Skip to content

Commit 02dfa63

Browse files
fix(checkout): properly update order amount if extra value is added (#26)
1 parent 93b6029 commit 02dfa63

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

routes/#checkout.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,6 @@ module.exports = (checkoutBody, checkoutRespond, storeId) => {
335335
}
336336
})
337337

338-
if (transaction.amount > amount.total) {
339-
amount.extra += (transaction.amount - amount.total)
340-
fixAmount()
341-
}
342-
343338
// setup transaction app object
344339
if (!transaction.app) {
345340
transaction.app = { _id: result._id }
@@ -430,6 +425,17 @@ module.exports = (checkoutBody, checkoutRespond, storeId) => {
430425
if (countDone === transactions.length) {
431426
if (amount.total / paymentsAmount > 1.01) {
432427
cancelOrder('Transaction amounts doesn\'t match (is lower) order total value')
428+
} else {
429+
amount.extra = (paymentsAmount - amount.total)
430+
if (amount.extra > 0) {
431+
fixAmount()
432+
setTimeout(() => {
433+
const body = {
434+
amount
435+
}
436+
Api('orders/' + orderId + '.json', 'PATCH', body, storeId)
437+
}, 400)
438+
}
433439
}
434440
}
435441
return

0 commit comments

Comments
 (0)