Toni
Toni

Reputation: 1852

How to send custom data for customer via javascript

I'm trying to integrate Paddle.com as a payment solution for my application. Therefore I'm starting with the sandbox integration.

My aim is to send the crmId (some kind of customer id) of my application to Paddle on checkout in order to 'link' the customer in my database with the paddle customer object.

According to the paddle docs it's possible to send custom data which I want to use to send the customerId. The docs show to send custom data as follows via JS:

Paddle.Checkout.open({
  customData: {
    "crmId": 1234,
  },    
});

My implementation looks like this:

function openCheckout(items){
    Paddle.Checkout.open({
        items: items,
        customer: {
            customData: {
                "crmId": "test123"
            },
        },
        customData: {
            "crmId": "test456"
        }
    });
}

As you can see I'm also trying to set the customerId on the customer object directly which is also a possible way according to the docs.

After generating my html markup I can see that the parameters are set in the code. Having a look at the console I see that paddle JS doesn't load a customData attribute at all:

enter image description here

The Paddle.checkout.open functions gets executed correctly as I see updated price on my pricing page.

Another thing is that I can't find a place on Paddle's sandbox administation web frontend (the UI where you can see all transaction, customers, etc.) where custom data would be displayed.

Any help would be appreciated.

Upvotes: 0

Views: 68

Answers (1)

Michael McGovern
Michael McGovern

Reputation: 21

Looks like there's a couple of separate issues here:

1. customer.customData isn't a valid parameter for Paddle.Checkout.open()

You can supply custom data at the top-level when opening a checkout, and the custom data is created against the related transaction. You can pass a customer name and email, along with business and address information, but not custom data.

2. The screenshot you included shows a response to a call to the Paddle.PricePreivew() method, rather than a checkout event.

On a pricing page, you typically call Paddle.PricePreview() first to present localized prices, then call Paddle.Checkout.open() when a customer chooses to sign up.

Your implementation shows a call to open a checkout, but you also can't pass custom data when previewing prices. No data is created in Paddle until a checkout is opened, when a transaction and any related data is created.

Some helpful links:

Upvotes: 1

Related Questions