From 25745d8515212b37c4eaeaf091ef9addf232f1cc Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Wed, 19 Jun 2019 12:53:54 +0000 Subject: [PATCH] [FIX] payment_stripe: save token - Configure Stripe with 'Save Cards' set to 'Let the customer decide' or 'Always'. - Go to the eCommerce, buy an item - Use Stripe to pay, make sure to check 'Save my payment data' No payment token is saved. It occurs because 2 calls are performed to `/shop/payment/transaction`. The second call, which is used to record the transaction, doesn't contain the `save_token` parameter is not sent. Ideally, we should only make a single call, but since Stripe works a bit differently, we can't prevent it (in stable, at least). Therefore, we work around it by searching the checkbox value. opw-2008275 closes odoo/odoo#34242 Signed-off-by: Nicolas Martinelli (nim) --- addons/payment_stripe/static/src/js/stripe.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/addons/payment_stripe/static/src/js/stripe.js b/addons/payment_stripe/static/src/js/stripe.js index 7d8d20a0590..ec60ec4fbc5 100644 --- a/addons/payment_stripe/static/src/js/stripe.js +++ b/addons/payment_stripe/static/src/js/stripe.js @@ -105,9 +105,17 @@ odoo.define('payment_stripe.stripe', function(require) { var invoice_num = get_input_value("invoice_num"); var merchant = get_input_value("merchant"); + // Search if the user wants to save the credit card information + var form_save_token = false; + var acquirer_form = $('#o_payment_form_acq_' + acquirer_id); + if (acquirer_form.length) { + form_save_token = acquirer_form.find('input[name="o_payment_form_save_token"]').prop('checked'); + } + ajax.jsonRpc(payment_tx_url, 'call', { acquirer_id: acquirer_id, access_token: access_token, + save_token: form_save_token, }).then(function(data) { var $pay_stripe = $('#pay_stripe').detach(); try { provider_form[0].innerHTML = data; } catch (e) {}