skip to Main Content

I am new to paypal php sdk and I wanted to know how to use php with javascript. Here is the frontend code I use:

paypal.Buttons({
    createOrder: function(data, actions) {
      // This function sets up the details of the transaction, including the amount and line item details.
      return actions.order.create({
        purchase_units: [{
          amount: {
            value: '0.01'
          }// I am searching for a way to get this
        }]
      });
    },
    onApprove: function(data, actions) {
     //call api to verify the order
    }
  }).render('#paypal-button-container');

It works fine but I know that using javascript is not a good idea because the user can edit the informations of the order. For the onApprove I used my php code to call the paypal api to verify that the order is payed and the informations are correct but how can I get the informations of the order ?

2

Answers


  1. I’m Guessing You want to add paypal payment to PHP Application

    https://paypal.github.io/PayPal-PHP-SDK/sample/
    You can find All info in here 🙂

    Login or Signup to reply.
  2. To use PayPal Checkout from a server, create two routes, one for ‘Create Order’ and one for ‘Capture Order’, documented here. These routes should return/output only JSON data (no other HTML or text)

    Pair your two routes with the following approval flow: https://developer.paypal.com/demo/checkout/#/pattern/server

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search