Start a new topic

product.setCustomData fails with # character

For example, if I do the following:

  

const url = 'https://google.com/#helloWorld';
product.setCustomData({
  cf_site_url: url,
  cf_site_id: id,
  cf_site_secret: secret
});

 Then `cf_site_url` will be added as a custom field but everything after the # character will be deleted. In the case above it would become 'https://google.com/'. Also, the other custom fields after `cf_site_url` will be broken and will not be stored in chargebee.


The workaround is to encode the field as a URI component. This should happen by default in the chargebee library to avoid confusion. This issue caused me a few hours of head scratching.


const url = 'https://google.com/#helloWorld';
product.setCustomData({
  cf_site_url: encodeURIComponent(url),
  cf_site_id: id,
  cf_site_secret: secret
});

 

Login or Signup to post a comment