Search code examples
paypalpaypal-sandboxpaypal-rest-sdkexpress-checkout

Create a payment on Client and execute it on Server


I have a website where I want to offer 2 ways to checkout. One with a plain credit card using Stripe (Stripe Checkout) and the other with Paypal.

The way Stripe Checkout works is that when the user clicks a button on my web page, I trigger the checkout request which pops a modal and lets the user enter his credentials. Then it sends the data over to their servers to validate the card and returns a unique token which can is used to identify the card. I send the token via an AJAX request to my server and charge that token using my secret key. So the basic flow is:

  1. Generate a token in the client side
  2. Send that token to the server
  3. Charge the token

I was looking for a similar workflow with Paypal Express Checkout but it seems like the only options are:

  1. Generate a token and execute the payment in the Client side
  2. Generate a token and execute the payment in the Server side

There seems to be no combination of both of them. I want to charge my client from my server as there are several things that take place when I charge the client.

Is it possible, with Paypal Express Checkout, to generate a token in the client and charge it on the server?


Solution

  • Yes, you can create on the client and execute on the server. Take a look at this doc, hopefully it'll help: https://github.com/paypal/paypal-checkout/blob/master/docs/hybrid.md