|
|
|
@ -224,24 +224,25 @@ def check_order_status(request, merchant_id, order_id):
|
|
|
|
|
due_date = order_item.purchased_at + timedelta(days=recurring_cycle)
|
|
|
|
|
order_item.due_at = due_date
|
|
|
|
|
order_item.save()
|
|
|
|
|
api_url = 'https://osimenu.com/api/create-subscription/'
|
|
|
|
|
random_string = ''.join(random.choices(string.ascii_letters + string.digits, k=10))
|
|
|
|
|
api_data = {
|
|
|
|
|
'user': {
|
|
|
|
|
'username': request.user.email,
|
|
|
|
|
'email': request.user.email,
|
|
|
|
|
'password': random_string,
|
|
|
|
|
'first_name': request.user.first_name,
|
|
|
|
|
'last_name': request.user.last_name
|
|
|
|
|
},
|
|
|
|
|
'customer': {
|
|
|
|
|
'mobile_number': request.user.customerprofile.mobile_number
|
|
|
|
|
},
|
|
|
|
|
'subscription': {
|
|
|
|
|
'plan': order_item.item.title
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
response = requests.post(api_url, json=api_data)
|
|
|
|
|
if order_item.item.item_type.name == 'OSIMENU':
|
|
|
|
|
api_url = 'https://osimenu.com/api/create-subscription/'
|
|
|
|
|
random_string = ''.join(random.choices(string.ascii_letters + string.digits, k=10))
|
|
|
|
|
api_data = {
|
|
|
|
|
'user': {
|
|
|
|
|
'username': request.user.email,
|
|
|
|
|
'email': request.user.email,
|
|
|
|
|
'password': random_string,
|
|
|
|
|
'first_name': request.user.first_name,
|
|
|
|
|
'last_name': request.user.last_name
|
|
|
|
|
},
|
|
|
|
|
'customer': {
|
|
|
|
|
'mobile_number': request.user.customerprofile.mobile_number
|
|
|
|
|
},
|
|
|
|
|
'subscription': {
|
|
|
|
|
'plan': order_item.item.title
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
response = requests.post(api_url, json=api_data)
|
|
|
|
|
return redirect('orders')
|
|
|
|
|
error_message = 'Failed to retrieve order details: ' + response.text
|
|
|
|
|
return JsonResponse({'error': error_message}, status=500)
|
|
|
|
|