Catch error from stripe call

This commit is contained in:
PCoder 2019-04-03 06:59:05 +02:00
parent 033db01810
commit c85a4f3796

View file

@ -37,8 +37,11 @@ class Command(BaseCommand):
user.stripecustomer.stripe_id, user.stripecustomer.stripe_id,
created=created_gt created=created_gt
) )
if all_invoices_response['error'] is not None:
self.stdout.write(self.style.ERROR(all_invoices_response['error']))
exit(1)
all_invoices = all_invoices_response['response_object'] all_invoices = all_invoices_response['response_object']
self.stdout.write(self.style.SUCCESS("Obtained {} invoices".format(len(all_invoices)))) self.stdout.write(self.style.SUCCESS("Obtained {} invoices".format(len(all_invoices) if all_invoices is not None else 0)))
for invoice in all_invoices: for invoice in all_invoices:
MonthlyHostingBill.create( MonthlyHostingBill.create(
invoice, stripe_customer=user.stripecustomer invoice, stripe_customer=user.stripecustomer