[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/<id> needs to be called manually.
This commit is contained in:
Martin Trigaux
2016-06-20 12:31:06 +02:00
parent c8a94fda19
commit da82a6b705
+18 -2
View File
@@ -39,7 +39,23 @@ odoo.define('payment_stripe.stripe', function(require) {
if(!$(this).find('i').length)
$(this).append('<i class="fa fa-spinner fa-spin"/>');
$(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();
});
});
});