Better logging for broken paypal ipns.

This commit is contained in:
Samuel Clay 2021-01-05 14:55:53 -05:00
parent 00269d94b9
commit 8c3fe964f2

View file

@ -1091,6 +1091,12 @@ def paypal_signup(sender, **kwargs):
user = User.objects.get(username__iexact=ipn_obj.custom)
except User.DoesNotExist:
user = User.objects.get(email__iexact=ipn_obj.payer_email)
except User.DoesNotExist:
logging.debug(" ---> Paypal subscription not found during flagging: %s/%s" % (
ipn_obj.payer_email,
ipn_obj.custom)) logging.user(user, "~BC~SB~FBPaypal subscription payment")
return {"code": -1, "message": "User doesn't exist."}
logging.user(user, "~BC~SB~FBPaypal subscription signup")
try:
if not user.email:
@ -1109,7 +1115,12 @@ def paypal_payment_history_sync(sender, **kwargs):
user = User.objects.get(username__iexact=ipn_obj.custom)
except User.DoesNotExist:
user = User.objects.get(email__iexact=ipn_obj.payer_email)
logging.user(user, "~BC~SB~FBPaypal subscription payment")
except User.DoesNotExist:
logging.debug(" ---> Paypal subscription not found during flagging: %s/%s" % (
ipn_obj.payer_email,
ipn_obj.custom)) logging.user(user, "~BC~SB~FBPaypal subscription payment")
return {"code": -1, "message": "User doesn't exist."}
try:
user.profile.setup_premium_history()
except:
@ -1123,6 +1134,12 @@ def paypal_payment_was_flagged(sender, **kwargs):
except User.DoesNotExist:
if ipn_obj.payer_email:
user = User.objects.get(email__iexact=ipn_obj.payer_email)
except User.DoesNotExist:
logging.debug(" ---> Paypal subscription not found during flagging: %s/%s" % (
ipn_obj.payer_email,
ipn_obj.custom))
return {"code": -1, "message": "User doesn't exist."}
try:
user.profile.setup_premium_history()
logging.user(user, "~BC~SB~FBPaypal subscription payment flagged")
@ -1130,19 +1147,6 @@ def paypal_payment_was_flagged(sender, **kwargs):
return {"code": -1, "message": "User doesn't exist."}
invalid_ipn_received.connect(paypal_payment_was_flagged)
def paypal_recurring_payment_history_sync(sender, **kwargs):
ipn_obj = sender
try:
user = User.objects.get(username__iexact=ipn_obj.custom)
except User.DoesNotExist:
user = User.objects.get(email__iexact=ipn_obj.payer_email)
logging.user(user, "~BC~SB~FBPaypal subscription recurring payment")
try:
user.profile.setup_premium_history()
except:
return {"code": -1, "message": "User doesn't exist."}
valid_ipn_received.connect(paypal_recurring_payment_history_sync)
def stripe_signup(sender, full_json, **kwargs):
stripe_id = full_json['data']['object']['customer']
try: