Ad

PayPal Integration In Laravel Site

- 1 answer

I need to implement PayPal payment in my Laravel site. I was going for the server side integration, in order to save all the data, transactions and know what they actually bought. But turns out that [the older] server-side integration method [that I was looking at] is archived, and not really the preferred method anymore. Instead, they suggest using the smart buttons, with front end integration only.

Questions:

  • Is front end only safe? what prevents the user from messing with the JavaScript and editing the sum with whatever they want?
  • How do I know what they ordered if it is all front end?
  • What would I have to do if the payed sum does not correspond to the articles in the cart?
  • What should I be aware of with this system?
Ad

Answer

Smart Payment Buttons can be used with or without a server-side component.

Here is the front-end pattern that communicates with a server-side integration: https://developer.paypal.com/demo/checkout/#/pattern/server

Notice the fetches to two '/demo/...' placeholder endpoints, which need to be replaced with actual routes of yours. The first should create a v2/order via API and return the orderID. The second should capture that order after the payer approves it via Smart Payment Buttons.


The answers to your questions re: a serverless (client-side only) pattern are:

  • Nothing
  • Only what you program the JavaScript to tell you and which it actually successfully tells you, or what you read via email or in your PayPal account or app notifications
  • Refund the transaction
  • It's for people who don't want to do the work of implementing server-side routes and API calls.
Ad
source: stackoverflow.com
Ad