Not persisting stripe details to db
This commit is contained in:
		
					parent
					
						
							
								66f82572f1
							
						
					
				
			
			
				commit
				
					
						bbfc7e8515
					
				
			
		
					 1 changed files with 12 additions and 10 deletions
				
			
		|  | @ -331,19 +331,22 @@ class PaymentOrderView(FormView): | ||||||
|             owner = self.request.user |             owner = self.request.user | ||||||
|          |          | ||||||
|             # Get or create stripe customer |             # Get or create stripe customer | ||||||
|             customer = StripeCustomer.get_or_create(email=user.get('email'), |             stripe_utils = StripeUtils() | ||||||
|                                                     token=token) |             stripe_data = stripe_utils.create_customer(token, user.get('email')) | ||||||
|             if not customer: |             customer_stripe_id = None | ||||||
|  |             if stripe_data.get('response_object'): | ||||||
|  |                 customer_stripe_id = stripe_data.get('response_object').get('id') | ||||||
|  | 
 | ||||||
|  |             if customer_stripe_id is None: | ||||||
|                 form.add_error("__all__", "Invalid credit card") |                 form.add_error("__all__", "Invalid credit card") | ||||||
|                 return self.render_to_response(self.get_context_data(form=form)) |                 return self.render_to_response(self.get_context_data(form=form)) | ||||||
| 
 | 
 | ||||||
|             # Create Billing Address |  | ||||||
|             billing_address = form.save() |             billing_address = form.save() | ||||||
|          |          | ||||||
|             # Make stripe charge to a customer |             # Make stripe charge to a customer | ||||||
|             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') |             charge = charge_response.get('response_object') | ||||||
|          |          | ||||||
|             # Check if the payment was approved |             # Check if the payment was approved | ||||||
|  | @ -364,7 +367,7 @@ class PaymentOrderView(FormView): | ||||||
|             vm_id = manager.create_vm( |             vm_id = manager.create_vm( | ||||||
|                 template_id=vm_template_id, |                 template_id=vm_template_id, | ||||||
|                 specs=specs, |                 specs=specs, | ||||||
|                 name="{email}-{template_name}-{date}".format( |                 vm_name="{email}-{template_name}-{date}".format( | ||||||
|                        email=user.get('email'),  |                        email=user.get('email'),  | ||||||
|                        template_name=template.get('name'), |                        template_name=template.get('name'), | ||||||
|                        date=int(datetime.now().strftime("%s"))) |                        date=int(datetime.now().strftime("%s"))) | ||||||
|  | @ -395,7 +398,7 @@ class PaymentOrderView(FormView): | ||||||
|             ## Associate an order with a stripe payment |             ## Associate an order with a stripe payment | ||||||
|             #order.set_stripe_charge(charge) |             #order.set_stripe_charge(charge) | ||||||
|          |          | ||||||
|             # If the Stripe payment was successed, set order status approved |             # If the Stripe payment is success, set order status approved | ||||||
|             #order.set_approved() |             #order.set_approved() | ||||||
| 
 | 
 | ||||||
|             vm = VirtualMachineSerializer(manager.get_vm(vm_id)).data |             vm = VirtualMachineSerializer(manager.get_vm(vm_id)).data | ||||||
|  | @ -409,8 +412,7 @@ class PaymentOrderView(FormView): | ||||||
|                 'price': specs.get('price'), |                 'price': specs.get('price'), | ||||||
|                 'template': template.get('name'), |                 'template': template.get('name'), | ||||||
|                 'vm.name': vm['name'], |                 'vm.name': vm['name'], | ||||||
|                 'vm.id': vm['vm_id'], |                 'vm.id': vm['vm_id'] | ||||||
|                 'order id': order.id  |  | ||||||
|             } |             } | ||||||
|             email_data = { |             email_data = { | ||||||
|                 'subject': "Data Center Light Order from %s" % context['email'], |                 'subject': "Data Center Light Order from %s" % context['email'], | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue