Test Full cycle and fix some issues

This commit is contained in:
amalelshihaby 2021-08-16 10:46:59 +02:00
commit 2e05ebbf67
19 changed files with 131 additions and 98 deletions

View file

@ -1,5 +1,6 @@
import json
from uncloud_pay.models import Product, Order, ProductToRecurringPeriod
from uncloud_pay.models import Product, Order, ProductToRecurringPeriod, Bill, Payment
from .models import VMInstance
def finalize_order(request, customer, billing_address,
@ -17,4 +18,12 @@ def finalize_order(request, customer, billing_address,
product = product,
config=json.dumps(specs)
)
return order
if order:
bill = Bill.create_next_bill_for_order(order, ending_date=order.next_cancel_or_downgrade_date(order.starting_date))
payment= Payment.withdraw(owner=request.user, amount=one_time_price, notes=f"BILL #{bill.id}")
if payment:
#Close the bill as the payment has been added
VMInstance.create_instance(order)
bill.close()
return order, bill