Fix unit_amount retrieval and subtotal calculation
This commit is contained in:
parent
e9bb8714fc
commit
df1ce8d265
@ -568,7 +568,7 @@ class Subscription(models.Model):
|
|||||||
subscription = {}
|
subscription = {}
|
||||||
|
|
||||||
for x in data:
|
for x in data:
|
||||||
if 'products_and_quantities' in x['metadata']:
|
if 'Coffee' in x['description']:
|
||||||
subscription['unit_price'] = self.convert_int_to_decimal(x['price']['unit_amount'])
|
subscription['unit_price'] = self.convert_int_to_decimal(x['price']['unit_amount'])
|
||||||
|
|
||||||
if 'Shipping' in x['description']:
|
if 'Shipping' in x['description']:
|
||||||
@ -585,7 +585,8 @@ class Subscription(models.Model):
|
|||||||
customer=self.customer,
|
customer=self.customer,
|
||||||
status=OrderStatus.UNFULFILLED,
|
status=OrderStatus.UNFULFILLED,
|
||||||
shipping_address=self.shipping_address,
|
shipping_address=self.shipping_address,
|
||||||
subtotal_amount=self.convert_int_to_decimal(data_object['subtotal']),
|
subtotal_amount=self.convert_int_to_decimal(
|
||||||
|
data_object['subtotal']) - subscription['shipping_cost'],
|
||||||
shipping_total=subscription['shipping_cost'],
|
shipping_total=subscription['shipping_cost'],
|
||||||
total_amount=self.convert_int_to_decimal(data_object['total']),
|
total_amount=self.convert_int_to_decimal(data_object['total']),
|
||||||
weight=self.total_weight,
|
weight=self.total_weight,
|
||||||
|
|||||||
@ -779,10 +779,10 @@ def stripe_webhook(request):
|
|||||||
|
|
||||||
data_object = data['object']
|
data_object = data['object']
|
||||||
|
|
||||||
logger.warning('\n')
|
# logger.warning('\n')
|
||||||
logger.warning(event_type.upper() + ':\n')
|
# logger.warning(event_type.upper() + ':\n')
|
||||||
logger.warning(data)
|
# logger.warning(data)
|
||||||
logger.warning('\n')
|
# logger.warning('\n')
|
||||||
|
|
||||||
if event_type == 'checkout.session.completed':
|
if event_type == 'checkout.session.completed':
|
||||||
# Payment is successful and the subscription is created.
|
# Payment is successful and the subscription is created.
|
||||||
|
|||||||
@ -41,10 +41,6 @@
|
|||||||
<img src="{% static 'images/box.png' %}" alt="">
|
<img src="{% static 'images/box.png' %}" alt="">
|
||||||
Orders
|
Orders
|
||||||
</a>
|
</a>
|
||||||
<a href="{% url 'dashboard:subscription-list' %}">
|
|
||||||
<img src="{% static 'images/recurrent.png' %}" alt="">
|
|
||||||
Subscriptions
|
|
||||||
</a>
|
|
||||||
<a href="{% url 'dashboard:customer-list' %}">
|
<a href="{% url 'dashboard:customer-list' %}">
|
||||||
<img src="{% static 'images/customer.png' %}" alt="">
|
<img src="{% static 'images/customer.png' %}" alt="">
|
||||||
Customers
|
Customers
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user