Don't handle generic exception for the moment
This commit is contained in:
parent
981e68aa4f
commit
259c509113
1 changed files with 70 additions and 70 deletions
140
webhook/views.py
140
webhook/views.py
|
@ -136,84 +136,84 @@ def handle_webhook(request):
|
||||||
if (invoice_obj.paid and
|
if (invoice_obj.paid and
|
||||||
invoice_obj.billing_reason == "subscription_update"):
|
invoice_obj.billing_reason == "subscription_update"):
|
||||||
logger.debug("Start provisioning")
|
logger.debug("Start provisioning")
|
||||||
|
# try:
|
||||||
|
stripe_subscription_obj = stripe.Subscription.retrieve(
|
||||||
|
invoice_obj.subscription)
|
||||||
try:
|
try:
|
||||||
stripe_subscription_obj = stripe.Subscription.retrieve(
|
incomplete_sub = IncompleteSubscriptions.objects.get(
|
||||||
invoice_obj.subscription)
|
subscription_id=invoice_obj.subscription)
|
||||||
try:
|
request = ""
|
||||||
incomplete_sub = IncompleteSubscriptions.objects.get(
|
soc = ""
|
||||||
subscription_id=invoice_obj.subscription)
|
card_details_response = ""
|
||||||
request = ""
|
gp_details = ""
|
||||||
soc = ""
|
template = ""
|
||||||
card_details_response = ""
|
specs = ""
|
||||||
gp_details = ""
|
billing_address_data = ""
|
||||||
template = ""
|
if incomplete_sub.request:
|
||||||
specs = ""
|
request = json.loads(incomplete_sub.request)
|
||||||
billing_address_data = ""
|
if incomplete_sub.specs:
|
||||||
if incomplete_sub.request:
|
specs = json.loads(incomplete_sub.specs)
|
||||||
request = json.loads(incomplete_sub.request)
|
if incomplete_sub.stripe_onetime_charge:
|
||||||
if incomplete_sub.specs:
|
soc = json.loads(incomplete_sub.stripe_onetime_charge)
|
||||||
specs = json.loads(incomplete_sub.specs)
|
if incomplete_sub.gp_details:
|
||||||
if incomplete_sub.stripe_onetime_charge:
|
gp_details = json.loads(incomplete_sub.gp_details)
|
||||||
soc = json.loads(incomplete_sub.stripe_onetime_charge)
|
if incomplete_sub.card_details_response:
|
||||||
if incomplete_sub.gp_details:
|
card_details_response = json.loads(
|
||||||
gp_details = json.loads(incomplete_sub.gp_details)
|
incomplete_sub.card_details_response)
|
||||||
if incomplete_sub.card_details_response:
|
if incomplete_sub.template:
|
||||||
card_details_response = json.loads(
|
template = json.loads(
|
||||||
incomplete_sub.card_details_response)
|
incomplete_sub.template)
|
||||||
if incomplete_sub.template:
|
if incomplete_sub.billing_address_data:
|
||||||
template = json.loads(
|
billing_address_data = json.loads(
|
||||||
incomplete_sub.template)
|
incomplete_sub.billing_address_data)
|
||||||
if incomplete_sub.billing_address_data:
|
logger.debug("*******")
|
||||||
billing_address_data = json.loads(
|
logger.debug(str(incomplete_sub))
|
||||||
incomplete_sub.billing_address_data)
|
logger.debug("*******")
|
||||||
logger.debug("*******")
|
logger.debug("1*******")
|
||||||
logger.debug(str(incomplete_sub))
|
logger.debug(request)
|
||||||
logger.debug("*******")
|
logger.debug("2*******")
|
||||||
logger.debug("1*******")
|
logger.debug(card_details_response)
|
||||||
logger.debug(request)
|
logger.debug("3*******")
|
||||||
logger.debug("2*******")
|
logger.debug(soc)
|
||||||
logger.debug(card_details_response)
|
logger.debug("4*******")
|
||||||
logger.debug("3*******")
|
logger.debug(gp_details)
|
||||||
logger.debug(soc)
|
logger.debug("5*******")
|
||||||
logger.debug("4*******")
|
logger.debug(template)
|
||||||
logger.debug(gp_details)
|
logger.debug("6*******")
|
||||||
logger.debug("5*******")
|
do_create_vm(
|
||||||
logger.debug(template)
|
request=request,
|
||||||
logger.debug("6*******")
|
user={'name': incomplete_sub.name,
|
||||||
do_create_vm(
|
'email': incomplete_sub.email},
|
||||||
request=request,
|
stripe_api_cus_id=incomplete_sub.stripe_api_cus_id,
|
||||||
user={'name': incomplete_sub.name,
|
card_details_response=card_details_response,
|
||||||
'email': incomplete_sub.email},
|
stripe_subscription_obj=stripe_subscription_obj,
|
||||||
stripe_api_cus_id=incomplete_sub.stripe_api_cus_id,
|
stripe_onetime_charge=soc,
|
||||||
card_details_response=card_details_response,
|
gp_details=gp_details,
|
||||||
stripe_subscription_obj=stripe_subscription_obj,
|
specs=specs,
|
||||||
stripe_onetime_charge=soc,
|
vm_template_id=incomplete_sub.vm_template_id,
|
||||||
gp_details=gp_details,
|
template=template,
|
||||||
specs=specs,
|
billing_address_data=billing_address_data
|
||||||
vm_template_id=incomplete_sub.vm_template_id,
|
)
|
||||||
template=template,
|
except (IncompleteSubscriptions.DoesNotExist,
|
||||||
billing_address_data=billing_address_data
|
IncompleteSubscriptions.MultipleObjectsReturned) as ex:
|
||||||
)
|
|
||||||
except (IncompleteSubscriptions.DoesNotExist,
|
|
||||||
IncompleteSubscriptions.MultipleObjectsReturned) as ex:
|
|
||||||
logger.error(str(ex))
|
|
||||||
# TODO Inform admin
|
|
||||||
email_data = {
|
|
||||||
'subject': "IncompleteSubscriptions error",
|
|
||||||
'from_email': settings.DCL_SUPPORT_FROM_ADDRESS,
|
|
||||||
'to': settings.DCL_ERROR_EMAILS_TO_LIST,
|
|
||||||
'body': "Response = %s" % str(ex),
|
|
||||||
}
|
|
||||||
send_plain_email_task.delay(email_data)
|
|
||||||
except Exception as ex:
|
|
||||||
logger.error(str(ex))
|
logger.error(str(ex))
|
||||||
|
# TODO Inform admin
|
||||||
email_data = {
|
email_data = {
|
||||||
'subject': "invoice.paid Webhook error",
|
'subject': "IncompleteSubscriptions error",
|
||||||
'from_email': settings.DCL_SUPPORT_FROM_ADDRESS,
|
'from_email': settings.DCL_SUPPORT_FROM_ADDRESS,
|
||||||
'to': settings.DCL_ERROR_EMAILS_TO_LIST,
|
'to': settings.DCL_ERROR_EMAILS_TO_LIST,
|
||||||
'body': "Response = %s" % str(ex),
|
'body': "Response = %s" % str(ex),
|
||||||
}
|
}
|
||||||
send_plain_email_task.delay(email_data)
|
send_plain_email_task.delay(email_data)
|
||||||
|
# except Exception as ex:
|
||||||
|
# logger.error(str(ex))
|
||||||
|
# email_data = {
|
||||||
|
# 'subject': "invoice.paid Webhook error",
|
||||||
|
# 'from_email': settings.DCL_SUPPORT_FROM_ADDRESS,
|
||||||
|
# 'to': settings.DCL_ERROR_EMAILS_TO_LIST,
|
||||||
|
# 'body': "Response = %s" % str(ex),
|
||||||
|
# }
|
||||||
|
# send_plain_email_task.delay(email_data)
|
||||||
else:
|
else:
|
||||||
logger.error("Unhandled event : " + event.type)
|
logger.error("Unhandled event : " + event.type)
|
||||||
return HttpResponse(status=200)
|
return HttpResponse(status=200)
|
||||||
|
|
Loading…
Reference in a new issue