PayPal Checkout pass additional data to server

daslicht
Contributor
Contributor

Hello,
the payment is working with server api.
But how to add additional POST parameters to the actions.request.post call ?
For example the Product id so that the server knows what to actually checkout ?

Cheers Marc

 

 

paypal.Button.render({
  env: 'sandbox',
  locale: 'en_US',
  style: {
    size: 'small',
    color: 'gold',
    shape: 'pill',
  },
  payment: function(data, actions) 
  {   
    return actions.request.post('/api/create-payment/')         //<------- add post parameter here ?
      .then( function( res ) {
        return res.id;
      });
  },

  onAuthorize: function (data, actions)
  {   
    return actions.request.post('/api/execute-payment/', {
      paymentID: data.paymentID,
      payerID:   data.payerID
    })
      .then( function( res ) {
        console.log('confirmation message',res);
      });

  }
}, '#paypal-button_{{@i.id}}');

 

 

Cheers Marc 

Login to Me Too
1 ACCEPTED SOLUTION

Accepted Solutions
Solved

daslicht
Contributor
Contributor

[SOLVED]

it was as easy as :

 
return actions.request.post('/api/create-payment', {
      product_id: 999,
})

View solution in original post

Login to Me Too
1 REPLY 1
Solved

daslicht
Contributor
Contributor

[SOLVED]

it was as easy as :

 
return actions.request.post('/api/create-payment', {
      product_id: 999,
})
Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.