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() | ||||
|         charge_response = stripe_utils.make_charge(amount=final_price, | ||||
|                                                    customer=customer.stripe_id) | ||||
|         charge = charge_response.get('response_object') | ||||
| 
 | ||||
|         # Check if the payment was approved | ||||
|         if not charge: | ||||
|             context = {} | ||||
|             context.update({ | ||||
|                 'paymentError': charge_response.get('error') | ||||
|             }) | ||||
|             return render(request, self.payment_template_name, context) | ||||
|         if not charge_response.get('response_object') and not charge_response.get('paid'): | ||||
|             msg = charge_response.get('error') | ||||
|             messages.add_message(self.request, messages.ERROR, msg, extra_tags='make_charge_error') | ||||
|             return HttpResponseRedirect(reverse('datacenterlight:payment')) | ||||
| 
 | ||||
|         charge = charge_response.get('response_object') | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue