How do I add custom metadata to PayPal so it can be sent with the webhook?

Tim136
Contributor
Contributor

I am trying to set up a webhook so that I can fulfill the payment on my server. The problem is I need to identify the user in the database. Usually with webhooks there is the option to send custom metadata, so I can send the user ID to PayPal and receive it with the webhook. This is very easy with Stripe, I am surprised how difficult everything is with PayPal (I have encountered so many problems already trying to set this up).

 

I am using the paypal.Buttons.render() method to generate the Smart Buttons. Is there an option to set metadata with this? I can't find it anywhere in the documentation and there are some old posts about using a hidden <input /> field, but I think this is outdated with the new payment buttons. 

Login to Me Too
2 REPLIES 2

d-squared
Contributor
Contributor

Add a custom_id in the purchase units section of create order

    createOrder: function(data, actions) {

        return actions.order.create({
            purchase_units: [{
                amount: {
                    value: document.getElementById('amount').value
                },
                description:  document.getElementById('description').value, 
                custom_id: 'my custom string',
                
            }],
            shipping_preference: 2
        });
    },

 

 

It will show in the Webhooks

Login to Me Too

Eloreden
Contributor
Contributor

I have try this method for CreateSubscription but i don't see custom_id in webhook.

 

[Solved] Sorry for posting, the method below works correctly

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.