From 66e76d681d41b6c007a0394b078ddbe872989985 Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Wed, 7 Feb 2018 12:50:12 +0100 Subject: [PATCH] [FIX] payment_stripe: integer currencies (portal payment) Before this commit: On portal (My Account > Invoices > Pay Now), a stripe payment in a normal currency (eg: a non integer currency) would debit the amount *100. This comes from b335ae0348ac74b2edb6d5ea56cc230e276ef283 which added a workflow to handle integer currencies but it also sent the *100 amount to /website_payment/transaction that would create a TX with that amount instead of the normal amount. Now, the normal amount is correctly sent to the backend, the multiplied amount is just sent to StripeCheckout handler to correctly display the amount on the popup after clicking on "Pay Now". Note: the amount will be multiplied on the backend independently ecda057e1166ea1fa9afa4e5b954e5c99aa80232 --- addons/payment_stripe/static/src/js/stripe.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/addons/payment_stripe/static/src/js/stripe.js b/addons/payment_stripe/static/src/js/stripe.js index 9db27aea858..a5dec077e7d 100644 --- a/addons/payment_stripe/static/src/js/stripe.js +++ b/addons/payment_stripe/static/src/js/stripe.js @@ -70,9 +70,6 @@ odoo.define('payment_stripe.stripe', function(require) { var currency = $("input[name='currency']").val(); var currency_id = $("input[name='currency_id']").val(); var amount = parseFloat($("input[name='amount']").val() || '0.0'); - if (!_.contains(int_currencies, currency)) { - amount = amount*100; - } ajax.jsonRpc('/website_payment/transaction', 'call', { reference: $("input[name='invoice_num']").val(), @@ -84,14 +81,11 @@ odoo.define('payment_stripe.stripe', function(require) { name: $("input[name='merchant']").val(), description: $("input[name='invoice_num']").val(), currency: currency, - amount: amount, + amount: _.contains(int_currencies, currency) ? amount : amount * 100, }); } else { var currency = $("input[name='currency']").val(); var amount = parseFloat($("input[name='amount']").val() || '0.0'); - if (!_.contains(int_currencies, currency)) { - amount = amount*100; - } ajax.jsonRpc('/shop/payment/transaction/' + acquirer_id, 'call', { so_id: so_id, @@ -102,7 +96,7 @@ odoo.define('payment_stripe.stripe', function(require) { name: $("input[name='merchant']").val(), description: $("input[name='invoice_num']").val(), currency: currency, - amount: amount, + amount: _.contains(int_currencies, currency) ? amount : amount * 100, }); }); }