More debugging
This commit is contained in:
parent
4e978f62ea
commit
018c3b5bba
2 changed files with 8 additions and 2 deletions
|
@ -1219,6 +1219,7 @@ def get_or_create_custom_user(request, stripe_api_cus_id):
|
|||
|
||||
def set_user_card(card_id, stripe_api_cus_id, custom_user,
|
||||
card_details_response):
|
||||
logger.debug(":: set_user_card")
|
||||
if card_id:
|
||||
logger.debug("card_id %s was in request" % card_id)
|
||||
user_card_detail = UserCardDetail.get_ucd_from_card_id(card_id=card_id)
|
||||
|
@ -1233,17 +1234,18 @@ def set_user_card(card_id, stripe_api_cus_id, custom_user,
|
|||
stripe_source_id=user_card_detail.card_id
|
||||
)
|
||||
else:
|
||||
logger.debug("card_id was NOT in request, using "
|
||||
logger.debug(" card_id was NOT in request, using "
|
||||
"card_details_response")
|
||||
ucd = UserCardDetail.get_or_create_user_card_detail(
|
||||
stripe_customer=custom_user.stripecustomer,
|
||||
card_details=card_details_response
|
||||
)
|
||||
logger.debug("ucd = %s" % ucd)
|
||||
logger.debug(" ucd = %s" % ucd)
|
||||
UserCardDetail.save_default_card_local(
|
||||
custom_user.stripecustomer.stripe_id,
|
||||
ucd.card_id
|
||||
)
|
||||
logger.debug(" after save_default_card_local")
|
||||
card_details_dict = {
|
||||
'last4': ucd.last4,
|
||||
'brand': ucd.brand,
|
||||
|
|
|
@ -699,15 +699,19 @@ class UserCardDetail(AssignPermissionsMixin, models.Model):
|
|||
|
||||
@staticmethod
|
||||
def save_default_card_local(stripe_api_cus_id, card_id):
|
||||
print("save_default_card_local {}, {}".format(stripe_api_cus_id, card_id))
|
||||
stripe_cust = StripeCustomer.objects.get(stripe_id=stripe_api_cus_id)
|
||||
print(" stripe_cust={}".format(stripe_cust))
|
||||
user_card_detail = UserCardDetail.get_ucd_from_stripe_cust_n_card_id(
|
||||
stripe_customer=stripe_cust, card_id=card_id
|
||||
)
|
||||
print(" user_card_detail={}".format(user_card_detail))
|
||||
for card in stripe_cust.usercarddetail_set.all():
|
||||
card.preferred = False
|
||||
card.save()
|
||||
user_card_detail.preferred = True
|
||||
user_card_detail.save()
|
||||
print(" save_default_card_local DONE")
|
||||
|
||||
@staticmethod
|
||||
def get_ucd_from_card_id(card_id):
|
||||
|
|
Loading…
Add table
Reference in a new issue