Showing results for 
Search instead for 
Did you mean: 

Setting up the PHP code

New Community Member

Setting up the PHP code



Im developing a site where users can make a simple purchase of an item. I would like to get a conformation of the order sent to my server, so i can log it.

The front-end buttons code is:

    createOrder: function(data, actions) {
      return actions.order.create({
        purchase_units: [
            amount: {
              currency_code : 'EUR',[Removed. Phone #s not permitted]p;       }
    onApprove: function(data, actions) {

        return actions.order.capture().then(function(details) {
          alert('Transaction completed by ' +;
          // Call your server to save the transaction
          return fetch('pp_trans_comp.php', {
            method: 'post',
            headers: {
            'content-type': 'application/json'
          body: JSON.stringify({
          orderID: data.orderID

    onCancel: function (data) {
      // Show a cancel page, or return to cart


I already installed the SDK with the composer, but don't know how to proceed. I've been trying the examples from the documentation but it never seems to work. Any help will be appreciated.