From 68053409efd39255e984c0b9bf873d29fab849db Mon Sep 17 00:00:00 2001 From: "Antoine Vandevenne (anv)" Date: Fri, 23 Feb 2024 11:36:34 +0100 Subject: [PATCH] [FIX] payment_stripe: always create a customer for one-shot payments Following commit ac90aa07, the Customer object was no longer created on Stripe for one-shot (non-recurring) payments made with Stripe. This prevented Radar (Stripe's fraud detection tool) to work effectively as it could not rely on the customer's name and addresses anymore (see https://docs.stripe.com/radar/integration#recommendations). This commit forces the creation of a Customer object even for one-shot payments. opw-3694379 closes odoo/odoo#155276 X-original-commit: 20efda51fefcc50861d9c73a483b4291e5b7e85d Signed-off-by: Antoine Vandevenne (anv) --- addons/payment_stripe/models/payment_transaction.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/payment_stripe/models/payment_transaction.py b/addons/payment_stripe/models/payment_transaction.py index a31822c0503..67a5dcab7f2 100644 --- a/addons/payment_stripe/models/payment_transaction.py +++ b/addons/payment_stripe/models/payment_transaction.py @@ -164,10 +164,10 @@ class PaymentTransaction(models.Model): 'mandate': self.token_id.stripe_mandate or None, }) else: + customer = self._stripe_create_customer() + payment_intent_payload['customer'] = customer['id'] if self.tokenize: - customer = self._stripe_create_customer() payment_intent_payload.update( - customer=customer['id'], setup_future_usage='off_session', **self._stripe_prepare_mandate_options(), )