From 1f199519ee7cb62c5d0e2be640ade142a9545086 Mon Sep 17 00:00:00 2001 From: hoangchau0909 Date: Tue, 27 Aug 2019 14:21:28 +0800 Subject: [PATCH 1/2] Charges from Checkout Session don't have Source. --- .gitignore | 2 ++ pinax/stripe/actions/charges.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 3fae6e5a9..436de4f17 100644 --- a/.gitignore +++ b/.gitignore @@ -50,3 +50,5 @@ site/ # IDEs .idea/ + +*venv diff --git a/pinax/stripe/actions/charges.py b/pinax/stripe/actions/charges.py index 375f8ffda..fdfadfa5e 100644 --- a/pinax/stripe/actions/charges.py +++ b/pinax/stripe/actions/charges.py @@ -183,7 +183,8 @@ def sync_charge_from_stripe_data(data): """ obj, _ = models.Charge.objects.get_or_create(stripe_id=data["id"]) obj.customer = models.Customer.objects.filter(stripe_id=data["customer"]).first() - obj.source = data["source"]["id"] + # obj.source = data["source"]["id"] + obj.source = data["source"].get("id") # Charges made by Checkout Session don't have Source obj.currency = data["currency"] obj.invoice = models.Invoice.objects.filter(stripe_id=data["invoice"]).first() obj.amount = utils.convert_amount_for_db(data["amount"], obj.currency) From cff1dd8753ef05b0802b9a093979658da4f59a81 Mon Sep 17 00:00:00 2001 From: hoangchau0909 Date: Tue, 27 Aug 2019 15:44:47 +0800 Subject: [PATCH 2/2] Charges from Checkout Session don't have Source. --- pinax/stripe/actions/charges.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pinax/stripe/actions/charges.py b/pinax/stripe/actions/charges.py index fdfadfa5e..74cc5d5e6 100644 --- a/pinax/stripe/actions/charges.py +++ b/pinax/stripe/actions/charges.py @@ -184,7 +184,11 @@ def sync_charge_from_stripe_data(data): obj, _ = models.Charge.objects.get_or_create(stripe_id=data["id"]) obj.customer = models.Customer.objects.filter(stripe_id=data["customer"]).first() # obj.source = data["source"]["id"] - obj.source = data["source"].get("id") # Charges made by Checkout Session don't have Source + # Charges made by Checkout Session don't have Source + if data.get('source'): + obj.source = data["source"]["id"] + else: + obj.source = '' obj.currency = data["currency"] obj.invoice = models.Invoice.objects.filter(stripe_id=data["invoice"]).first() obj.amount = utils.convert_amount_for_db(data["amount"], obj.currency)