From 4f0ffbdc2e31138dc2d4cbf708d2746e835e4c93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 1 Nov 2019 22:54:50 +0100 Subject: [PATCH] Do not create payment intent if it already exists issue8778 review268281002 --- payment.py | 1 + tests/scenario_account_payment_stripe.rst | 2 ++ tests/scenario_account_payment_stripe_dispute.rst | 3 +++ 3 files changed, 6 insertions(+) diff --git a/payment.py b/payment.py index 41b45e4529..7dc3ce3099 100644 --- a/payment.py +++ b/payment.py @@ -571,6 +571,7 @@ class Payment(CheckoutMixin, metaclass=PoolMeta): # Use clear cache after a commit payment = cls(payment.id) if (payment.stripe_charge_id + or payment.stripe_payment_intent_id or payment.journal.process_method != 'stripe' or payment.state != 'processing'): continue diff --git a/tests/scenario_account_payment_stripe.rst b/tests/scenario_account_payment_stripe.rst index 0db21cc4cc..63d202568c 100644 --- a/tests/scenario_account_payment_stripe.rst +++ b/tests/scenario_account_payment_stripe.rst @@ -106,6 +106,7 @@ Checkout the payment:: >>> Payment.write([payment.id], { ... 'stripe_token': token.id, ... 'stripe_chargeable': True, + ... 'stripe_payment_intent_id': None, # Remove intent from checkout ... }, config.context) Process the payment:: @@ -145,6 +146,7 @@ Create failing payment:: ... ) >>> Payment.write([payment.id], { ... 'stripe_token': token.id, + ... 'stripe_payment_intent_id': None, # Remove intent from checkout ... }, config.context) >>> process_payment = Wizard('account.payment.process', [payment]) >>> process_payment.execute('process') diff --git a/tests/scenario_account_payment_stripe_dispute.rst b/tests/scenario_account_payment_stripe_dispute.rst index ad4fcbd6c8..fa9fe7ee53 100644 --- a/tests/scenario_account_payment_stripe_dispute.rst +++ b/tests/scenario_account_payment_stripe_dispute.rst @@ -93,6 +93,7 @@ Create fully disputed payment:: >>> Payment.write([payment.id], { ... 'stripe_token': token.id, ... 'stripe_chargeable': True, + ... 'stripe_payment_intent_id': None, # Remove intent from checkout ... }, config.context) >>> process_payment = Wizard('account.payment.process', [payment]) @@ -184,6 +185,7 @@ Create partial disputed payment:: >>> Payment.write([payment.id], { ... 'stripe_token': token.id, ... 'stripe_chargeable': True, + ... 'stripe_payment_intent_id': None, # Remove intent from checkout ... }, config.context) >>> process_payment = Wizard('account.payment.process', [payment]) @@ -253,6 +255,7 @@ Create won disputed payment:: >>> Payment.write([payment.id], { ... 'stripe_token': token.id, ... 'stripe_chargeable': True, + ... 'stripe_payment_intent_id': None, # Remove intent from checkout ... }, config.context) >>> process_payment = Wizard('account.payment.process', [payment])