Handle no payments in gocardless response

This commit is contained in:
Oly 2018-10-11 14:15:30 +01:00
parent 090b91b4d6
commit fb661f32d1
1 changed files with 5 additions and 1 deletions

View File

@ -54,13 +54,17 @@ class gocardless_provider:
customer = self.client.customers.get(mandate.links.customer)
# TODO get the last couple of months not all time payments
payments = self.client.payments.list(params={"customer": customer.id}).records
last_payments = None
if len(payments):
last_payment = payments[0].charge_date
# gocardless does not have a reference so we use the id instead
yield {
'status': paying_member.status,
'email': customer.email,
'start_date': paying_member.created_at,
'reference': paying_member.id,
'last_payment': payments[0].charge_date,
'last_payment': last_payment,
'amount': paying_member.amount * 0.01}
def get_redirect_url(self):