This GIST will help you implement PayPal v2 API with your Django app and handle payment statuses. I will use: Class-Based FormView and Django template system. To proceed you have to obtain valid PAYPAL_CLIENT_ID, PAYPAL_CLIENT_SECRET /have PayPal business account - production or sandbox/
Steps to complete:
-
Get PayPal SDK - pip install paypal-checkout-serversdk
-
Create a FormView with the payment data - amount, currency, description and cliend_id
-
Show template to the user with a dummy hidden payment form. Eventually, PayPal connect script will "hijack" that template, will process the payment and return the order_id. We will capture that order_id and submit it back to Django.
-
Handle PayPal order_id payment status. On success do stuff on your webapp - subscribe, confirm the order, send payment success mail, etc
-
Notify user about successful payment.
NOTE: Valuable information like PAYPAL_CLIENT and PAYPAL_CLIENT_SECRET should be put in your settings file like any other valuable information. Also, check official https://github.com/paypal/Checkout-Python-SDK