From da82a6b70553e4abed4ab04c4bd884d5d5126abc Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Mon, 20 Jun 2016 12:31:06 +0200 Subject: [PATCH] [FIX] payment_stripe: correctly compute reference number As explained in 15f27b26, the transaction information should be computed when hitting the "pay now" button, not at page rendering (e.g. in case of users going back to previous page). Stripe do not work as typical providers as it does not redirect to the provider page but opens a popup. The route /shop/payment/transaction/ needs to be called manually. --- addons/payment_stripe/static/src/js/stripe.js | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/addons/payment_stripe/static/src/js/stripe.js b/addons/payment_stripe/static/src/js/stripe.js index 6c9577925e5..1630c4fba99 100644 --- a/addons/payment_stripe/static/src/js/stripe.js +++ b/addons/payment_stripe/static/src/js/stripe.js @@ -39,7 +39,23 @@ odoo.define('payment_stripe.stripe', function(require) { if(!$(this).find('i').length) $(this).append(''); $(this).attr('disabled','disabled'); - handler.open(); - e.preventDefault(); + + var $form = $(e.currentTarget).parents('form'); + var acquirer_id = $(e.currentTarget).parents('div.oe_sale_acquirer_button').first().data('id'); + if (! acquirer_id) { + return false; + } + + ajax.jsonRpc('/shop/payment/transaction/' + acquirer_id, 'call', {}).then(function (data) { + $form.html(data); + handler.open({ + name: $("input[name='merchant']").val(), + description: $("input[name='invoice_num']").val(), + currency: $("input[name='currency']").val(), + amount: $("input[name='amount']").val()*100 + }); + e.preventDefault(); + }); + }); });