changeset 5429c7cfaff5 in modules/account_payment_stripe:6.0 details: https://hg.tryton.org/modules/account_payment_stripe?cmd=changeset&node=5429c7cfaff5 description: Expand sources from customer when needed
issue11717 review421741003 (grafted from 1ab113a47dc2f6aae828f882437ac7aa859be6e4) diffstat: payment.py | 7 ++++--- tests/scenario_account_payment_stripe.rst | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diffs (42 lines): diff -r 4c4f5cea5604 -r 5429c7cfaff5 payment.py --- a/payment.py Fri Apr 15 23:35:35 2022 +0200 +++ b/payment.py Sun Sep 25 20:26:21 2022 +0200 @@ -1580,13 +1580,14 @@ customer.save() Transaction().commit() - def retrieve(self): + def retrieve(self, **params): if not self.stripe_customer_id: return try: return stripe.Customer.retrieve( api_key=self.stripe_account.secret_key, - id=self.stripe_customer_id) + id=self.stripe_customer_id, + **params) except (stripe.error.RateLimitError, stripe.error.APIConnectionError) as e: logger.warning(str(e)) @@ -1596,7 +1597,7 @@ if sources is not None: return sources sources = [] - customer = self.retrieve() + customer = self.retrieve(expand=['sources']) if customer: for source in customer.sources: name = source.id diff -r 4c4f5cea5604 -r 5429c7cfaff5 tests/scenario_account_payment_stripe.rst --- a/tests/scenario_account_payment_stripe.rst Fri Apr 15 23:35:35 2022 +0200 +++ b/tests/scenario_account_payment_stripe.rst Sun Sep 25 20:26:21 2022 +0200 @@ -241,7 +241,8 @@ >>> detach.form.source = source_id >>> detach.execute('detach') - >>> cus = stripe.Customer.retrieve(stripe_customer.stripe_customer_id) + >>> cus = stripe.Customer.retrieve( + ... stripe_customer.stripe_customer_id, expand=['sources']) >>> len(cus.sources) 0 >>> len(stripe.PaymentMethod.list(customer=cus.id, type='card'))