From 3e95a389bb6bf9d843cd80c5d8b2dbb9e0e24860 Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 23 Dec 2020 07:58:20 +0530 Subject: [PATCH] Preparing a fix for TODO (wip) --- webhook/views.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/webhook/views.py b/webhook/views.py index 0b05b6ac..04d19b63 100644 --- a/webhook/views.py +++ b/webhook/views.py @@ -140,14 +140,21 @@ def handle_webhook(request): logger.error(str(ex)) if ho: logger.debug("Create a VM for order %s" % str(ho)) - - # TODO: fix the error below - do_create_vm(request, user, stripe_api_cus_id, - card_details_response, stripe_subscription_obj, - stripe_onetime_charge, gp_details, specs, - vm_template_id, - template - ) + # TODO: fix the error below + try: + user = {'name': ho.customer.user.name, + 'email': ho.customer.user.email} + stripe_api_cus_id = ho.customer.stripe_id + stripe_subscription_obj = stripe.Subscription.retrieve(invoice_obj.subscription) + do_create_vm(request, user, stripe_api_cus_id, + card_details_response, + stripe_subscription_obj, + stripe_onetime_charge, gp_details, specs, + vm_template_id, + template + ) + except Exception as ex: + logger.error(str(ex)) else: logger.error("Unhandled event : " + event.type)