From 040fc88d406d5416bb11f304504a38c057dbd481 Mon Sep 17 00:00:00 2001 From: emile Date: Tue, 23 Apr 2024 21:12:29 +0300 Subject: [PATCH] new --- .../__pycache__/views.cpython-310.pyc | Bin 6937 -> 6981 bytes osinaweb/customercore/views.py | 37 +++++++++--------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/osinaweb/customercore/__pycache__/views.cpython-310.pyc b/osinaweb/customercore/__pycache__/views.cpython-310.pyc index 7d77bfe8857afb6ceca38b94dc0e21bd76834ca9..95a08adecf08e45c7712c2c3fffcb5f8dcbf9592 100644 GIT binary patch delta 606 zcmZvYO=uHA6vyXHw!52cv)RdJvzs*Om!={@Jt#SN^WZ`7;}A<|6^byabfreaK&i}X zOZ})y&@#1}+Cu^&dK6Dy6))cOqV`hno<*c+oLN0O!~EvG|C{&0v@7o_b|aOtkX%20 z?we)fFYP*k4Z%p|;2P6H%r&l4qlF`b8(|+cFXHBNZgli6icD^HFim!WT2kEvWwSop`k-eBw%X?ClR zda+#!hvtCh;>yF)^0yLES`IkEQ#?%rHQ<$_Y?S6#pmqUO5iQ7h$9xnyY!4mej!Y@i zQVZ8)tcIwhhS=W4_kbb-=xUY@u`(ws@V^WlP05UiTqCk>d@sNP+CMD7{gj+GPFIhg zJa%eQe0IOWxOkmCmupVQ|J+W_vHJWBTfAJ~)-Ii&uM5wc6bFS3a&-SvJfM)iQ$5% za7uh?45qj%?G$S(v5%G5rL^)|L5R+*Ru0T>-g_V4%*TB09CT`Hwrw%Bx%d??02gZ;URaqTyoEQRHYD)A?wBZW<5{ujD z6gIj8Hy3F=_tJ*ie#lT@z0ZeG)FexTH2lZET~u~4dWYlKDC;Dhz60n>D{ZDNRRxD* zg`*>PYLC@>3Y~V1+F+j8(wXAuHT`wT+2%m1P>6eXhk7hKd!I&u)GKRtRAC z8`#RvNYR7R@}I+CtIAP`Euk(h&kfjM3p3<+UuonW!yFwouG3||3yVbl2(D2tI7jb- zByb%IEU1HVTx(B36RHpRNw!Cmar47T;K4*seRa00KyKvIQq&C}tLCklO=_X9@l@j( zy@}5A-;9o;i?FZ!EqG1~@s3Yg-O+fV@lxXzec>K`jBMxTjSS~Njb7{d0sV+~4gFg7 YknSZ{-926Imy(84`bNp}*oCS2KNK*Cb^rhX diff --git a/osinaweb/customercore/views.py b/osinaweb/customercore/views.py index bed1c973..79c2ea6a 100644 --- a/osinaweb/customercore/views.py +++ b/osinaweb/customercore/views.py @@ -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)