diff --git a/myproject/myapp/UserTokenModel.py b/myproject/myapp/UserTokenModel.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/myproject/myapp/payments.py b/myproject/myapp/payments.py new file mode 100644 index 0000000000000000000000000000000000000000..b103fa59dfa3c8b737d37a947fe3ea9fa958463d --- /dev/null +++ b/myproject/myapp/payments.py @@ -0,0 +1,167 @@ +import paypalrestsdk +from django.conf import settings +from django.http import JsonResponse +from django.shortcuts import redirect, render +from django.urls import reverse +from django.shortcuts import redirect, render +from django.urls import reverse + +# Create a payment that can be made via the PayPal API +# Create a payment that can be made via the PayPal API +def create_payment(request): + + + # Configure PayPal SDK + paypalrestsdk.configure({ + "mode": settings.PAYPAL_MODE, + "client_id": settings.PAYPAL_CLIENT_ID, + "client_secret": settings.PAYPAL_CLIENT_SECRET + }) + + # Create payment object + payment = paypalrestsdk.Payment({ + "intent": "sale", + "payer": { + "payment_method": "paypal", + }, + "redirect_urls": { + "return_url": request.build_absolute_uri(reverse('execute_payment')), + "cancel_url": request.build_absolute_uri(reverse('payment_cancelled')), + "return_url": request.build_absolute_uri(reverse('execute_payment')), + "cancel_url": request.build_absolute_uri(reverse('payment_cancelled')), + }, + "transactions" : [{ + "item_list" : { + "items" : [{ + "name": "Test item", + "sku": "test item", + "price": "9.99", + "currency": "GBP", + "quantity": 1, + }] + }, + "amount" : { + "total": "9.99", + "currency": "GBP" + }, + "description": "Test payment description" + }] + }) + +<<<<<<< HEAD + # Successfully communicated with API + if payment.create(): + print("Payment created successfully!") + # get url for payment approval + for link in payment.links: + if link.rel == "approval_url": + # turn link into text + approval_url = str(link.href) + # send on merry way + return redirect(approval_url) + else: + print(payment.error) + + +# Execute a successful payment +def execute_payment(request): + # Get payment id and payer id + payment_id = request.GET.get('paymentId') + payer_id = request.GET.get('PayerID') + + #If neither ID, error, restart + if not payment_id or not payer_id: + print("no payment") + #TODO: Change this to a more appropriate path, maybe a generic error page that takes a string:Error to display in a template + return redirect('handler404') + + # configure API + paypalrestsdk.configure({ + "mode": settings.PAYPAL_MODE, + "client_id": settings.PAYPAL_CLIENT_ID, + "client_secret": settings.PAYPAL_CLIENT_SECRET + }) + + # Check we've got a successful payment + payment = paypalrestsdk.Payment.find(payment_id) + + # If it we do an the payer IDs match + if payment.execute({"payer_id": payer_id}): + print("Payment executed successfully!") + + # Allocate some tokens + user = request.user + tokens_purchased = 1 + + # increment user_tokens + # commit changes + + return redirect('success') + else: + #TODO: Change this to a more appropriate error message + print("exiting at the end of execute_payment()") + return redirect('handler404') + +def payment_cancelled(request): + return render(request, 'payment_cancelled.html') + +def payment_success(request): + return render(request,'payment_success.html') +======= + if payment.create(): + print("Payment created successfully!") + # get url for payment approval + for link in payment.links: + if link.rel == "approval_url": + # turn link into text + approval_url = str(link.href) + # send on merry way + return redirect(approval_url) + else: + print(payment.error) + + +# Execute a successful payment +def execute_payment(request): + # Get payment id and payer id + payment_id = request.GET.get('paymentId') + payer_id = request.GET.get('PayerID') + + #If neither ID, error, restart + if not payment_id or not payer_id: + print("no payment") + #TODO: Change this to a more appropriate path, maybe a generic error page that takes a string:Error to display in a template + return redirect('handler404') + + # configure API + paypalrestsdk.configure({ + "mode": settings.PAYPAL_MODE, + "client_id": settings.PAYPAL_CLIENT_ID, + "client_secret": settings.PAYPAL_CLIENT_SECRET + }) + + # Check we've got a successful payment + payment = paypalrestsdk.Payment.find(payment_id) + + # If it we do an the payer IDs match + if payment.execute({"payer_id": payer_id}): + print("Payment executed successfully!") + + # Allocate some tokens + user = request.user + tokens_purchased = 1 + + # increment user_tokens + # commit changes + + return redirect('success') + else: + #TODO: Change this to a more appropriate error message + print("exiting at the end of execute_payment()") + return redirect('handler404') + +def payment_cancelled(request): + return render(request, 'payment_cancelled.html') + +def payment_success(request): + return render(request,'payment_success.html') \ No newline at end of file diff --git a/myproject/myapp/templates/payment_cancelled.html b/myproject/myapp/templates/payment_cancelled.html new file mode 100644 index 0000000000000000000000000000000000000000..e5240f5c7d78f8ee68bd51d9b23e29bdf8823973 --- /dev/null +++ b/myproject/myapp/templates/payment_cancelled.html @@ -0,0 +1,10 @@ +{% extends "_base.html" %}{% block content %} +<div class="grid grid-cols-1 gap-16 items-center py-8 px-4 mx-auto w-70 lg:grid"> + <div class="font-light text-gray-500 sm:text-lg dark:text-gray-400"> + <h2 class="mb-4 text-4xl tracking-tight font-extrabold text-gray-900 dark:text-white">Payment Cancelled</h2> + <p class="mb-4">Your payment has been cancelled.</p> + </div> +</div> + +<button class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-200 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-900 font-medium rounded-lg text-sm px-5 py-2.5 inline-flex justify-center text-center"><a href="{% url 'pricing' %}">Return</a></button> +{% endblock content%} diff --git a/myproject/myapp/templates/payment_success.html b/myproject/myapp/templates/payment_success.html new file mode 100644 index 0000000000000000000000000000000000000000..8496abe27218036de5f59812760e16c1b43ba7c9 --- /dev/null +++ b/myproject/myapp/templates/payment_success.html @@ -0,0 +1,10 @@ +{% extends "_base.html" %}{% block content %} +<div class="grid grid-cols-1 gap-16 items-center py-8 px-4 mx-auto w-70 lg:grid"> + <div class="font-light text-gray-500 sm:text-lg dark:text-gray-400"> + <h2 class="mb-4 text-4xl tracking-tight font-extrabold text-gray-900 dark:text-white">Success!</h2> + <p class="mb-4">Your payment was successful and you have been credited with 1 token.</p> + </div> +</div> + +<button class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-200 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-900 font-medium rounded-lg text-sm px-5 py-2.5 inline-flex justify-center text-center"><a href="{% url 'users' %}">Return</a></button> +{% endblock content%} diff --git a/myproject/myapp/templates/pricing.html b/myproject/myapp/templates/pricing.html index 42ff5a92c6da60fb20f22eac6dae6ee0b5765998..45b0ad300e57ab36520ab611260c5bb4e23c0c6a 100644 --- a/myproject/myapp/templates/pricing.html +++ b/myproject/myapp/templates/pricing.html @@ -1,64 +1,44 @@ {% extends "_base.html" %}{% block content %} -<div class="grid content-start"> - <div class="my-5"> - <h1>Purchase Tokens</h1> - <p>We operate through a token model. To use our service, you must purchase tokens that can be redeemed for model runs.</p> +<div class="grid grid-cols-1 gap-16 items-center py-8 px-4 mx-auto w-70 lg:grid"> + <div class="font-light text-gray-500 sm:text-lg dark:text-gray-400"> + <h2 class="mb-4 text-4xl tracking-tight font-extrabold text-gray-900 dark:text-white">An Intelligent System for Instrument Detection</h2> + <p class="mb-4">*placeholder input* We present to you a intelligent system for instrument detection. Using audio processing techinques and a convolutionsal + neural network we are able to classify instruments used in a song. other exciting words that might catch peoples attention and make them use our product. + To use our service upload an mp3 file below. + *placeholder input* + </p> </div> + </div> <div class="grid grid-cols-2 content-start"> - <div class="w-full mx-auto max-w-sm p-4 bg-white border border-gray-200 rounded-lg shadow sm:p-8 dark:bg-gray-800 dark:border-gray-700"> - <h5 class="mb-4 text-xl font-medium text-gray-500 dark:text-gray-400">Trial plan</h5> + <div class="w-full h-80 mx-auto max-w-sm p-4 bg-white border border-gray-200 rounded-lg shadow sm:p-8 dark:bg-gray-800 dark:border-gray-700"> + <h5 class="mb-4 text-xl font-medium text-gray-500 dark:text-gray-400">Single Purchase</h5> <div class="flex items-baseline text-gray-900 dark:text-white"> - <span class="text-5xl font-extrabold tracking-tight">Free</span> + <span class="text-5xl font-extrabold tracking-tight">£9.99</span> </div> <ul role="list" class="space-y-5 my-7"> <li class="flex items-center"> <svg class="flex-shrink-0 w-4 h-4 text-blue-700 dark:text-blue-500" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20"> <path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5Zm3.707 8.207-4 4a1 1 0 0 1-1.414 0l-2-2a1 1 0 0 1 1.414-1.414L9 10.586l3.293-3.293a1 1 0 0 1 1.414 1.414Z"/> </svg> - <span class="text-base font-normal leading-tight text-gray-500 dark:text-gray-400 ms-3">1 team member</span> - </li> - <li class="flex"> - <svg class="flex-shrink-0 w-4 h-4 text-blue-700 dark:text-blue-500" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20"> - <path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5Zm3.707 8.207-4 4a1 1 0 0 1-1.414 0l-2-2a1 1 0 0 1 1.414-1.414L9 10.586l3.293-3.293a1 1 0 0 1 1.414 1.414Z"/> - </svg> - <span class="text-base font-normal leading-tight text-gray-500 dark:text-gray-400 ms-3">0GB Cloud storage</span> - </li> - <li class="flex decoration-gray-500"> - <svg class="flex-shrink-0 w-4 h-4 text-blue-700 dark:text-gray-500" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20"> - <path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5Zm3.707 8.207-4 4a1 1 0 0 1-1.414 0l-2-2a1 1 0 0 1 1.414-1.414L9 10.586l3.293-3.293a1 1 0 0 1 1.414 1.414Z"/> - </svg> - <span class="text-base font-normal leading-tight text-gray-500 ms-3">1 File upload</span> - <span class="ms-1 text-sm font-normal text-gray-500 dark:text-gray-400">/month</span> - </li> - <li class="flex line-through decoration-gray-500"> - <svg class="flex-shrink-0 w-4 h-4 text-gray-400 dark:text-blue-500" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20"> - <path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5Zm3.707 8.207-4 4a1 1 0 0 1-1.414 0l-2-2a1 1 0 0 1 1.414-1.414L9 10.586l3.293-3.293a1 1 0 0 1 1.414 1.414Z"/> - </svg> - <span class="text-base font-normal leading-tight text-gray-500 dark:text-gray-400 ms-3">Integration help</span> + <span class="text-base font-normal leading-tight text-gray-500 dark:text-gray-400 ms-3">1 token</span> </li> - <li class="flex line-through decoration-gray-500"> + <li class="flex decoration-gray-500"> <svg class="flex-shrink-0 w-4 h-4 text-gray-400 dark:text-gray-500" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20"> <path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5Zm3.707 8.207-4 4a1 1 0 0 1-1.414 0l-2-2a1 1 0 0 1 1.414-1.414L9 10.586l3.293-3.293a1 1 0 0 1 1.414 1.414Z"/> </svg> <span class="text-base font-normal leading-tight text-gray-500 ms-3">API Access</span> </li> - <li class="flex line-through decoration-gray-500"> + <li class="flex decoration-gray-500"> <svg class="flex-shrink-0 w-4 h-4 text-gray-400 dark:text-gray-500" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20"> <path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5Zm3.707 8.207-4 4a1 1 0 0 1-1.414 0l-2-2a1 1 0 0 1 1.414-1.414L9 10.586l3.293-3.293a1 1 0 0 1 1.414 1.414Z"/> </svg> - <span class="text-base font-normal leading-tight text-gray-500 ms-3">Complete documentation</span> - </li> - <li class="flex line-through decoration-gray-500"> - <svg class="flex-shrink-0 w-4 h-4 text-gray-400 dark:text-gray-500" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20"> - <path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5Zm3.707 8.207-4 4a1 1 0 0 1-1.414 0l-2-2a1 1 0 0 1 1.414-1.414L9 10.586l3.293-3.293a1 1 0 0 1 1.414 1.414Z"/> - </svg> - <span class="text-base font-normal leading-tight text-gray-500 ms-3">24×7 phone & email support</span> + <span class="text-base font-normal leading-tight text-gray-500 ms-3">Email support</span> </li> </ul> - <button type="button" class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-200 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-900 font-medium rounded-lg text-sm px-5 py-2.5 inline-flex justify-center w-full text-center">Choose plan</button> + <button type="button" class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-200 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-900 font-medium rounded-lg text-sm px-5 py-2.5 inline-flex justify-center w-full text-center"><a href="{% url 'create_payment' %}">Purchase via PayPal</a></button> </div> <div class="w-full mx-auto max-w-sm p-4 bg-white border border-gray-200 rounded-lg shadow sm:p-8 dark:bg-gray-800 dark:border-gray-700"> diff --git a/myproject/myapp/templates/user_page.html b/myproject/myapp/templates/user_page.html index 3999efc3ab6b9d657c20f4c5a83be8d2f9edca28..1cd0f06ce218418b051251efaa37eb531eb4d0bd 100644 --- a/myproject/myapp/templates/user_page.html +++ b/myproject/myapp/templates/user_page.html @@ -3,152 +3,21 @@ class="grid grid-cols-1 px-4 pt-6 xl:grid-cols-3 xl:gap-4 dark:bg-grey-300" > <div class="mb-4 col-span-full xl:mb-2"> - <h1 class="text-xl font-semibold text-gray-800 sm:text-2xl dark:text-white"> + <h1 class="mb-4 text-4xl tracking-tight font-extrabold text-gray-900 dark:text-white"> User settings </h1> </div> <!-- Right Content --> <div class="col-span-full xl:col-auto"> + <div class="p-4 mb-4 bg-white border boder-gray-200 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 sm:p-6 dark:bg-gray-800"> + <h3 class="mb-4 text-xl font-semibold dark:text-white">Tokens:</h3> + <p class="mb-4 text-xl font-semibold dark:text-white">Token Count</p> + </div> <div class="p-4 mb-4 bg-white border boder-gray-200 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 sm:p-6 dark:bg-gray-800"> <h3 class="mb-4 text-xl font-semibold dark:text-white">Change your password</h3> <a href="{% url 'password_change' %}" class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">Change Password</a> </div> - <!-- <div - class="p-4 mb-4 bg-white border border-gray-200 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 sm:p-6 dark:bg-gray-800" - > - <h3 class="mb-4 text-xl font-semibold dark:text-white"> - Password information - </h3> - <form action="#"> - <div class="grid grid-cols-6 gap-6"> - <div class="col-span-6 sm:col-span-3"> - <label - for="current-password" - class="block mb-2 text-sm font-medium text-gray-900 dark:text-white" - >Current password</label - > - <input - type="text" - name="current-password" - id="current-password" - class="shadow-sm bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" - placeholder="••••••••" - required - /> - </div> - <div class="col-span-6 sm:col-span-3"> - <label - for="password" - class="block mb-2 text-sm font-medium text-gray-900 dark:text-white" - >New password</label - > - <input - data-popover-target="popover-password" - data-popover-placement="bottom" - type="password" - id="password" - class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" - placeholder="••••••••" - required - /> - <div - data-popover - id="popover-password" - role="tooltip" - class="absolute z-10 invisible inline-block text-sm font-light text-gray-500 transition-opacity duration-300 bg-white border border-gray-200 rounded-lg shadow-sm opacity-0 w-72 dark:bg-gray-800 dark:border-gray-600 dark:text-gray-400" - > - <div class="p-3 space-y-2"> - <h3 class="font-semibold text-gray-900 dark:text-white"> - Must have at least 6 characters - </h3> - <div class="grid grid-cols-4 gap-2"> - <div class="h-1 bg-orange-300 dark:bg-orange-400"></div> - <div class="h-1 bg-orange-300 dark:bg-orange-400"></div> - <div class="h-1 bg-gray-200 dark:bg-gray-600"></div> - <div class="h-1 bg-gray-200 dark:bg-gray-600"></div> - </div> - <p>It’s better to have:</p> - <ul> - <li class="flex items-center mb-1"> - <svg - class="w-4 h-4 mr-2 text-green-400 dark:text-green-500" - aria-hidden="true" - fill="currentColor" - viewBox="0 0 20 20" - xmlns="http://www.w3.org/2000/svg" - > - <path - fill-rule="evenodd" - d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" - clip-rule="evenodd" - ></path> - </svg> - Upper & lower case letters - </li> - <li class="flex items-center mb-1"> - <svg - class="w-4 h-4 mr-2 text-gray-300 dark:text-gray-400" - aria-hidden="true" - fill="currentColor" - viewBox="0 0 20 20" - xmlns="http://www.w3.org/2000/svg" - > - <path - fill-rule="evenodd" - d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" - clip-rule="evenodd" - ></path> - </svg> - A symbol (#$&) - </li> - <li class="flex items-center"> - <svg - class="w-4 h-4 mr-2 text-gray-300 dark:text-gray-400" - aria-hidden="true" - fill="currentColor" - viewBox="0 0 20 20" - xmlns="http://www.w3.org/2000/svg" - > - <path - fill-rule="evenodd" - d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" - clip-rule="evenodd" - ></path> - </svg> - A longer password (min. 12 chars.) - </li> - </ul> - </div> - <div data-popper-arrow></div> - </div> - </div> - <div class="col-span-6 sm:col-span-3"> - <label - for="confirm-password" - class="block mb-2 text-sm font-medium text-gray-900 dark:text-white" - >Confirm password</label - > - <input - type="text" - name="confirm-password" - id="confirm-password" - class="shadow-sm bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" - placeholder="••••••••" - required - /> - </div> - <div class="col-span-6 sm:col-full"> - <button - class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800" - type="submit" - > - Save all - </button> - </div> - </div> - </form> - {% comment %} REPLACE WITH LOGIC TO CHECK PROPER USER {% endcomment %} - </div> --> + {% if 1 %} <div class="p-4 mb-4 bg-white border border-gray-200 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 sm:p-6 dark:bg-gray-800" diff --git a/myproject/myapp/urls.py b/myproject/myapp/urls.py index 8e0269800f768e72ec60ddb8174e9262a0095816..9e02e7020377f1738a53840a86e3b00692240a26 100644 --- a/myproject/myapp/urls.py +++ b/myproject/myapp/urls.py @@ -1,6 +1,10 @@ from django.urls import path +<<<<<<< HEAD from .views import InstrumentDetectionView, index, users, maintenance, handler404, handler500, terms_conditions, privacy_policy, handling_music_file, pricing, generate_pdf, admin_table +======= +from .views import InstrumentDetectionView, index, users, maintenance, handler404, handler500, register, user_login, terms_conditions, privacy_policy, handling_music_file, pricing, generate_pdf, admin_table +from .payments import create_payment, execute_payment, payment_cancelled, payment_success from django.contrib.auth import views as auth_views # Authentication @@ -10,7 +14,7 @@ from django.contrib.auth.views import LoginView, LogoutView urlpatterns = [ path('', index, name='index'), path('user/', users, name='users'), - path('404/', handler404), + path('404/', handler404, name='handler404'), path('500/', handler500), path('maintenance/', maintenance), # path('register/', register, name='register'), @@ -26,10 +30,19 @@ urlpatterns = [ path('instrument_detection/', InstrumentDetectionView.as_view(), name='instrument_detection'), path('password_change/', auth_views.PasswordChangeView.as_view(template_name='password_change_form.html'), name='password_change'), path('password_change/done/', auth_views.PasswordChangeDoneView.as_view(template_name='password_change_done.html'), name='password_change_done'), - # path('user_logout/', auth_views.LogoutView.as_view(next_page='index'), name='user_logout') + # path('user_logout/', auth_views.LogoutView.as_view(next_page='index'), name='user_logout'), + path('payment/create/', create_payment, name='create_payment'), + path('payment/execute/', execute_payment, name='execute_payment'), + path('payment/cancel/', payment_cancelled, name='payment_cancelled'), + path('payment_success/', payment_success, name='success') # Authentication path('login/', CustomLoginView.as_view(), name='login'), path('logout/', LogoutView.as_view(), name='logout'), path('register/', RegisterView.as_view(), name='register'), + path('user_logout/', auth_views.LogoutView.as_view(next_page='index'), name='user_logout'), + path('payment/create/', create_payment, name='create_payment'), + path('payment/execute/', execute_payment, name='execute_payment'), + path('payment/cancel/', payment_cancelled, name='payment_cancelled'), + path('payment_success/', payment_success, name='success') ] diff --git a/myproject/myproject/settings.py b/myproject/myproject/settings.py index f4f4170d35aea11fc55f2c37a39cc94fb5e10b4c..5bb1e5500b386eb2343bb0efe23931a689bb39ce 100644 --- a/myproject/myproject/settings.py +++ b/myproject/myproject/settings.py @@ -173,4 +173,10 @@ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' IMAGE_URL = 'static/src/images/' LOGIN_REDIRECT_URL = '/' -LOGOUT_REDIRECT_URL = '/' + + +#PayPal API settings +PAYPAL_MODE = 'sandbox' +PAYPAL_CLIENT_ID = 'AYpHxonrFMrgnqmjii46SeNsQidn2PjJtEoIgVK0Nrda1iQFUbX28zyuMvUiJk67o_cHII3c8vCMWY-y' +PAYPAL_CLIENT_SECRET = 'EPXXK3Z7xDr4Gy_kt4OkPLbJRXd9tP62q1Dpbmj5QiwaFh7twcSUalHDRBbFRwxdX_rmHk_F6YStXa95' + diff --git a/myproject/requirements.txt b/myproject/requirements.txt index 287a93c4c764530b81983644f4a67744f38e5009..488687a1d85db374593a186e1c96f96cc4fe3e7c 100644 --- a/myproject/requirements.txt +++ b/myproject/requirements.txt @@ -37,4 +37,5 @@ urllib3==2.2.1 reportlab==4.1.0 chardet==5.2.0 charset-normalizer==3.3.2 -pillow==10.2.0 \ No newline at end of file +pillow==10.2.0 +paypalrestsdk==1.13.3 \ No newline at end of file