Expand sources from customer when needed
issue11717 review421741003 (grafted from 1ab113a47dc2f6aae828f882437ac7aa859be6e4) --HG-- branch : 6.0
This commit is contained in:
1 parent
1814b863ab
commit
893ef3ea23
2 files changed
+6
-4
No files matched your search
+4
-3
@@ -1580,13 +1580,14 @@ class Customer(CheckoutMixin, DeactivableMixin, ModelSQL, ModelView):
|
||||
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 @@ class Customer(CheckoutMixin, DeactivableMixin, ModelSQL, ModelView):
|
||||
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
|
||||
|
||||
@@ -241,7 +241,8 @@ Detach source::
|
||||
>>> 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'))
|
||||
|
||||
Reference in new issue
Block a user