1

I'm using the Paypal Javascript SDK to render smart buttons and capture and authorize all client side. Everything is working great except for the occasional customer not waiting around for processing to complete on our side.

I have set up webhooks and subscribed to all events but am not able to/or not sure how to define and receive any of my custom data IDs etc.

I've attempted several different configurations to pass my data to the order from create order - mainly following this guide https://developer.paypal.com/docs/commerce-platform/v1/reference/orders-integration-guide/#create-order

Which adds custom data to purchase_units as custom and also a metadata json object with supplementary_data and postback_data

paypal.Buttons({
     createOrder: function(data, actions) {
         return actions.order.create({
             intent: 'CAPTURE',
             purchase_units : [{
                 items : ....,
                 description : ...,
                 amount : ...,
                 custom : 'purchase_units_data'
             }],
             metadata : {
                 supplementary_data : [{
                     data : 'supplementary_data'
                 }],
                 postback_data : [{
                     data : 'postback_data'
                 }]
             }
         });
     },
     onApprove: function(data, actions) {
         return actions.order.capture().then(function(details) {
             ....
         });
     }
 }).render('#paypal-button-container');

Would hope to find a way to pass a bit of custom data to a webhook payload.

user892670
  • 177
  • 4
  • 17

1 Answers1

3

The answer appears to be that I was looking at the wrong version of the API. https://developer.paypal.com/docs/api/orders/v2/#definition-purchase_unit_request

While I can't create a nicely formed metadata object I can however add data to the purchase_units object with reference_id and custom_id.

I'll just have to get a bit creative.

user892670
  • 177
  • 4
  • 17