Use appropriate stripe_coupon_id
This commit is contained in:
		
					parent
					
						
							
								3ca1a45217
							
						
					
				
			
			
				commit
				
					
						e322e58246
					
				
			
		
					 3 changed files with 14 additions and 8 deletions
				
			
		|  | @ -933,11 +933,11 @@ class OrderConfirmationView(DetailView, FormView): | ||||||
|             subscription_result = stripe_utils.subscribe_customer_to_plan( |             subscription_result = stripe_utils.subscribe_customer_to_plan( | ||||||
|                 stripe_api_cus_id, |                 stripe_api_cus_id, | ||||||
|                 [{"plan": stripe_plan.get('response_object').stripe_plan_id}], |                 [{"plan": stripe_plan.get('response_object').stripe_plan_id}], | ||||||
|                 coupon='ipv6-discount-8chf' if ( |                 coupon=(discount['stripe_coupon_id'] | ||||||
|                     'name' in discount and |                     if 'name' in discount and | ||||||
|                     discount['name'] is not None and |                        'ipv6' in discount['name'].lower() and | ||||||
|                     'ipv6' in discount['name'].lower() |                        discount['stripe_coupon_id'] | ||||||
|                 ) else "", |                     else ""), | ||||||
|                 tax_rates=[stripe_tax_rate.tax_rate_id] if stripe_tax_rate else [], |                 tax_rates=[stripe_tax_rate.tax_rate_id] if stripe_tax_rate else [], | ||||||
|             ) |             ) | ||||||
|             stripe_subscription_obj = subscription_result.get('response_object') |             stripe_subscription_obj = subscription_result.get('response_object') | ||||||
|  |  | ||||||
|  | @ -1185,7 +1185,11 @@ class OrdersHostingDetailView(LoginRequiredMixin, DetailView, FormView): | ||||||
|         subscription_result = stripe_utils.subscribe_customer_to_plan( |         subscription_result = stripe_utils.subscribe_customer_to_plan( | ||||||
|             stripe_api_cus_id, |             stripe_api_cus_id, | ||||||
|             [{"plan": stripe_plan.get('response_object').stripe_plan_id}], |             [{"plan": stripe_plan.get('response_object').stripe_plan_id}], | ||||||
|             coupon='ipv6-discount-8chf' if 'name' in discount and 'ipv6' in discount['name'].lower() else "", |             coupon=(discount['stripe_coupon_id'] | ||||||
|  |                     if 'name' in discount and | ||||||
|  |                        'ipv6' in discount['name'].lower() and | ||||||
|  |                        discount['stripe_coupon_id'] | ||||||
|  |                     else ""), | ||||||
|             tax_rates=[stripe_tax_rate.tax_rate_id] if stripe_tax_rate else [], |             tax_rates=[stripe_tax_rate.tax_rate_id] if stripe_tax_rate else [], | ||||||
|         ) |         ) | ||||||
|         stripe_subscription_obj = subscription_result.get('response_object') |         stripe_subscription_obj = subscription_result.get('response_object') | ||||||
|  |  | ||||||
|  | @ -122,7 +122,8 @@ def get_vm_price_for_given_vat(cpu, memory, ssd_size, hdd_size=0, | ||||||
|     discount = { |     discount = { | ||||||
|         'name': discount_name, |         'name': discount_name, | ||||||
|         'amount': discount_amount, |         'amount': discount_amount, | ||||||
|         'amount_with_vat': round(float(discount_amount_with_vat), 2) |         'amount_with_vat': round(float(discount_amount_with_vat), 2), | ||||||
|  |         'stripe_coupon_id': pricing.stripe_coupon_id | ||||||
|     } |     } | ||||||
|     return (round(float(price), 2), round(float(vat), 2), |     return (round(float(price), 2), round(float(vat), 2), | ||||||
|             round(float(vat_percent), 2), discount) |             round(float(vat_percent), 2), discount) | ||||||
|  | @ -173,7 +174,8 @@ def get_vm_price_with_vat(cpu, memory, ssd_size, hdd_size=0, | ||||||
|     vat = vat.quantize(cents, decimal.ROUND_HALF_UP) |     vat = vat.quantize(cents, decimal.ROUND_HALF_UP) | ||||||
|     discount = { |     discount = { | ||||||
|         'name': pricing.discount_name, |         'name': pricing.discount_name, | ||||||
|         'amount': round(float(pricing.discount_amount), 2) |         'amount': round(float(pricing.discount_amount), 2), | ||||||
|  |         'stripe_coupon_id': pricing.stripe_coupon_id | ||||||
|     } |     } | ||||||
|     return (round(float(price), 2), round(float(vat), 2), |     return (round(float(price), 2), round(float(vat), 2), | ||||||
|             round(float(vat_percent), 2), discount) |             round(float(vat_percent), 2), discount) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue