summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornie <nie@odoo.com>2021-04-22 13:33:30 +0000
committernie <nie@odoo.com>2021-04-23 15:20:02 +0000
commit45c839deaa45225b3613805aebf88e167535bc71 (patch)
treefa20192d790ec4555382d66e4acfb308528e9ed2
parent1d680f488f68be4e6157ffd5d8d9dcbb86915ab8 (diff)
[FIX] payment_stripe_sca, *: use setup_future_usage when saving card
*: account_payment, payment, sale Steps: - Install eCommerce - Go to Website / Configuration / eCommerce / Payment Acquirers - Configure Stripe: - Save Cards: Always - Payment Flow: Redirection to the acquirer website - Go to /shop - Add a product to the cart - Process Checkout - Select Stripe - Pay Now - Enter test data in Stripe Checkout form (https://stripe.com/docs/testing#cards) - Pay - Go to /shop - Add a product to the cart - Process Checkout - Select your saved card - Pay Now Bug: Stripe Error: The provided PaymentMethod was previously used with a PaymentIntent without Customer attachment, shared with a connected account without Customer attachment, or was detached from a Customer. It may not be used again. To use a PaymentMethod multiple times, you must attach it to a Customer first. Explanation: https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-payment_intent_data-setup_future_usage > Indicates that you intend to make future payments with the payment > method collected by this Checkout Session. According to this doc, `setup_future_usage` must be set in order to use the saved card afterwards. opw:2452452 opw:2498571 opw:2509897 closes odoo/odoo#69772 X-original-commit: 43e666f21f488067cf09a994fba7782271446b84 Signed-off-by: backspac <backspac@users.noreply.github.com>
-rw-r--r--addons/account_payment/models/payment.py1
-rw-r--r--addons/payment/controllers/portal.py1
-rw-r--r--addons/payment_stripe/models/payment.py2
3 files changed, 4 insertions, 0 deletions
diff --git a/addons/account_payment/models/payment.py b/addons/account_payment/models/payment.py
index decad0d034a..202afcaf9c7 100644
--- a/addons/account_payment/models/payment.py
+++ b/addons/account_payment/models/payment.py
@@ -15,6 +15,7 @@ class PaymentTransaction(models.Model):
def render_invoice_button(self, invoice, submit_txt=None, render_values=None):
values = {
'partner_id': invoice.partner_id.id,
+ 'type': self.type,
}
if render_values:
values.update(render_values)
diff --git a/addons/payment/controllers/portal.py b/addons/payment/controllers/portal.py
index 5fcc0147ab7..906424265cd 100644
--- a/addons/payment/controllers/portal.py
+++ b/addons/payment/controllers/portal.py
@@ -306,6 +306,7 @@ class WebsitePayment(http.Controller):
render_values = {
'partner_id': partner_id,
+ 'type': tx.type,
}
return acquirer.sudo().render(tx.reference, float(amount), int(currency_id), values=render_values)
diff --git a/addons/payment_stripe/models/payment.py b/addons/payment_stripe/models/payment.py
index d09a6977c1c..84ad304d543 100644
--- a/addons/payment_stripe/models/payment.py
+++ b/addons/payment_stripe/models/payment.py
@@ -63,6 +63,8 @@ class PaymentAcquirerStripe(models.Model):
'payment_intent_data[description]': tx_values['reference'],
'customer_email': tx_values.get('partner_email') or tx_values.get('billing_partner_email'),
}
+ if tx_values['type'] == 'form_save':
+ stripe_session_data['payment_intent_data[setup_future_usage]'] = 'off_session'
self._add_available_payment_method_types(stripe_session_data, tx_values)