Search code examples
paypalpayment

PayPal JavaScript Client SDK - Create Order - purchase units array - is there a custom parameter


There doesn't seem to be a "custom" parameter available to the PayPal JavaScript V2 Client SDK. Is there an alternative that will allow me to send a custom value?

My current set up to initialize the button is:

<script>

  function initPayPalButton() {
    paypal.Buttons({
      style: {
        shape: 'rect',
        color: 'gold',
        layout: 'vertical',
        label: 'paypal',
      },

      createOrder: function(data, actions) {
        return actions.order.create({
          purchase_units: [{"description":"Premium Service","amount":{"currency_code":"USD","value":10.99}}]
        });
      },

   . . . . Other code here

Solution

  • There is in fact, actions.order.create() is a v2/checkout/orders create, with all the same parameters including custom_id


    However if you are making use of such a parameter for anything important, it's a sign that you likely should be using the server-side pattern , with calls to "Create Order" and "Capture Order" from your back end.