Search code examples
djangopaypalpaypal-sandbox

send form after paypal payement is approuve


hello I am working with django I have a form that should be posted if the paypment is done, I don't know what should I do exaclty I tried but doesn't work for me, anyways in my html page I have a form and submit button and then the paypal payment <div id="paypal-button-container"></div>


Solution

  • Gathering form information and a successful payment at the same time is tricky. One of the events has to happen first, and you need to handle the possibility of that event completing without the other completing.

    If you have a server, one of the best methods is to send all the form information in a JSON body as part of the fetch call to capture the payment. This extends the server demo pattern of https://developer.paypal.com/demo/checkout/#/pattern/server , which requires you to create two routes that in turn call the PayPal API.

    If you do client-side creates or captures (actions.order.create / actions.order.capture) , and/or if you rely on the client to do a form post after a capture, your integration will be inferior and prone to problems of desired operations not completing since they rely on the client browser.