Added stripe make_charge error handler
This commit is contained in:
		
					parent
					
						
							
								4fea099b5d
							
						
					
				
			
			
				commit
				
					
						4cd3d6a4aa
					
				
			
		
					 1 changed files with 4 additions and 7 deletions
				
			
		|  | @ -467,15 +467,12 @@ class OrderConfirmationView(DetailView): | ||||||
|         stripe_utils = StripeUtils() |         stripe_utils = StripeUtils() | ||||||
|         charge_response = stripe_utils.make_charge(amount=final_price, |         charge_response = stripe_utils.make_charge(amount=final_price, | ||||||
|                                                    customer=customer.stripe_id) |                                                    customer=customer.stripe_id) | ||||||
|         charge = charge_response.get('response_object') |  | ||||||
| 
 | 
 | ||||||
|         # Check if the payment was approved |         # Check if the payment was approved | ||||||
|         if not charge: |         if not charge_response.get('response_object') and not charge_response.get('paid'): | ||||||
|             context = {} |             msg = charge_response.get('error') | ||||||
|             context.update({ |             messages.add_message(self.request, messages.ERROR, msg, extra_tags='make_charge_error') | ||||||
|                 'paymentError': charge_response.get('error') |             return HttpResponseRedirect(reverse('datacenterlight:payment')) | ||||||
|             }) |  | ||||||
|             return render(request, self.payment_template_name, context) |  | ||||||
| 
 | 
 | ||||||
|         charge = charge_response.get('response_object') |         charge = charge_response.get('response_object') | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue