changeset b0f95fa90859 in modules/account_payment_stripe:6.0
details:
https://hg.tryton.org/modules/account_payment_stripe?cmd=changeset&node=b0f95fa90859
description:
Backed out changeset 8cb4fe63452a
diffstat:
payment.py | 41 ++++++++++++-----------------------------
view/account_form.xml | 3 ---
2 files changed, 12 insertions(+), 32 deletions(-)
diffs (85 lines):
diff -r 65058a9cd9aa -r b0f95fa90859 payment.py
--- a/payment.py Tue Mar 01 19:47:38 2022 +0100
+++ b/payment.py Wed Mar 02 19:34:41 2022 +0100
@@ -1,6 +1,5 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
-import datetime as dt
import uuid
import logging
import urllib.parse
@@ -975,9 +974,6 @@
depends=['webhook_identifier'],
help="The Stripe's signing secret of the webhook.")
last_event = fields.Char("Last Event", readonly=True)
- setup_intent_delay = fields.TimeDelta(
- "Setup Intent Delay", required=True,
- help="The delay before cancelling setup intent not succeeded.")
@classmethod
def __setup__(cls):
@@ -1007,10 +1003,6 @@
% url_part))
@classmethod
- def default_setup_intent_delay(cls):
- return dt.timedelta(days=30)
-
- @classmethod
def fetch_events(cls):
"""Fetch last events of each account without webhook and process them
@@ -1723,30 +1715,21 @@
# Use clear cache after commit
customer = cls(customer.id)
setup_intent = customer.stripe_setup_intent
- if not setup_intent:
- continue
- if setup_intent.status not in {'succeeded', 'canceled'}:
- delay = customer.stripe_account.setup_intent_delay
- expiration = dt.datetime.now() - delay
- if dt.datetime.fromtimstamp(setup_intent.created) < expiration:
- stripe.SetupIntent.cancel(
- customer.stripe_customer_id,
- api_key=customer.stripe_account.secret_key)
+ if not setup_intent or setup_intent.status != 'succeeded':
continue
customer.lock()
try:
- if setup_intent.status == 'succeeded':
- if customer.stripe_customer_id:
- stripe.PaymentMethod.attach(
- setup_intent.payment_method,
- customer=customer.stripe_customer_id,
- api_key=customer.stripe_account.secret_key)
- else:
- cu = stripe.Customer.create(
- api_key=customer.stripe_account.secret_key,
- payment_method=setup_intent.payment_method,
- **customer._customer_parameters())
- customer.stripe_customer_id = cu.id
+ if customer.stripe_customer_id:
+ stripe.PaymentMethod.attach(
+ setup_intent.payment_method,
+ customer=customer.stripe_customer_id,
+ api_key=customer.stripe_account.secret_key)
+ else:
+ cu = stripe.Customer.create(
+ api_key=customer.stripe_account.secret_key,
+ payment_method=setup_intent.payment_method,
+ **customer._customer_parameters())
+ customer.stripe_customer_id = cu.id
except (stripe.error.RateLimitError,
stripe.error.APIConnectionError) as e:
logger.warning(str(e))
diff -r 65058a9cd9aa -r b0f95fa90859 view/account_form.xml
--- a/view/account_form.xml Tue Mar 01 19:47:38 2022 +0100
+++ b/view/account_form.xml Wed Mar 02 19:34:41 2022 +0100
@@ -13,7 +13,4 @@
<button name="new_identifier"/>
<label name="webhook_signing_secret"/>
<field name="webhook_signing_secret" colspan="3"/>
-
- <label name="setup_intent_delay"/>
- <field name="setup_intent_delay" colspan="3"/>
</form>