Don't dissociate card if transaction fails

This commit is contained in:
PCoder 2018-07-07 02:03:42 +02:00
parent 0f26917f35
commit 34ed51a643
2 changed files with 8 additions and 10 deletions

View file

@ -530,11 +530,10 @@ class OrderConfirmationView(DetailView):
or stripe_subscription_obj.status != 'active'): or stripe_subscription_obj.status != 'active'):
# At this point, we have created a Stripe API card and # At this point, we have created a Stripe API card and
# associated it with the customer; but the transaction failed # associated it with the customer; but the transaction failed
# due to some reason. We may want to dissociate this card. # due to some reason. So, we would want to dissociate this card
# stripe_utils.dissociate_customer_card( # here.
# stripe_api_cus_id, # ...
# card_details_dict['card_id']
# )
msg = subscription_result.get('error') msg = subscription_result.get('error')
messages.add_message(self.request, messages.ERROR, msg, messages.add_message(self.request, messages.ERROR, msg,
extra_tags='failed_payment') extra_tags='failed_payment')

View file

@ -1054,11 +1054,10 @@ class OrdersHostingDetailView(LoginRequiredMixin, DetailView):
stripe_subscription_obj.status != 'active'): stripe_subscription_obj.status != 'active'):
# At this point, we have created a Stripe API card and # At this point, we have created a Stripe API card and
# associated it with the customer; but the transaction failed # associated it with the customer; but the transaction failed
# due to some reason. So, we dissociate this card. # due to some reason. So, we would want to dissociate this card
stripe_utils.dissociate_customer_card( # here.
request.user.stripecustomer.stripe_id, # ...
card_details_dict['card_id']
)
msg = subscription_result.get('error') msg = subscription_result.get('error')
messages.add_message(self.request, messages.ERROR, msg, messages.add_message(self.request, messages.ERROR, msg,
extra_tags='failed_payment') extra_tags='failed_payment')