If you have tried to use Paypal’s API to create payments for your website, you know how painful the experience can be. For some reason, there is no code snippet on how to implement adaptive payments (parallel and chain) in Python. Note that for some reason their REST API does not support this particular type of payment, so you can’t use paypalrestsdk. You are stuck with the older NVP API for this.
Below I provide code snippets to help you get started with your own Django/Flask application.
Then, initialize your credentials and the API endpoint as follows:
After, define the dict that specifies all the payment information:
We can now submit our request to create the new payment using requests:
Once the transaction is complete, r will contain all the confirmation values. You should then verify that the payment was succesfully created (r.json()['responseEnvelope']['ack'] == 'Success' and r.json()['paymentExecStatus'] == 'CREATED'), and then redirect your user to their page for the payment: