Uncaught DOMException error

YCA2020
Contributor
Contributor

I am getting errors like this

Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.

 

when using

<script src="https://www.paypal.com/sdk/js?components=hosted-fields,buttons&client-id=<clinet-id>" data-client-token="<token>"></script>

with the code example for advanced credit and debit card payments

 

Login to Me Too
6 REPLIES 6

Steepe
New Community Member

Any solution yet?

Login to Me Too

Joestack01
New Community Member

Any solution yet? I'm having the same error

Login to Me Too

AECAST
Contributor
Contributor

Hi Comunity,

 

any one found an answer to this problem with the the Javacript SDK not working for the data-client-token, whihc as per the Javascript SDK says you can add as in paypal example below...

 

<script src="https://www.paypal.com/sdk/js?components=hosted-fields,buttons&client-id=<clinet-id>" data-client-token="<token>"></script>

Need to have this working so I can send a Client token to the IPN page to then link to clients buying services.

 

PAYPAL - Please reply to this as this has been on your comunity bord since 2020 1 and half years and you have not replied or helped!!!!!!!

Login to Me Too

dunp
New Community Member

Mabe it can help.

I've had the same problem.
I've change the POST cURL to obtain the Access Token putting the "grant_type":"client_credentials" in the post body instead of query parameter and now it works fine.

 

 

Login to Me Too

Philsims
Contributor
Contributor

I have had the same problem, and been trying to figure it out all day...

In my case I rushing through the docs and mistakenly populating <YOUR-CLIENT-TOKEN> with <ACCESS-TOKEN>

 

<script src="https://www.paypal.com/sdk/js?components=buttons,hosted-fields&client-id=<YOUR-CLIENT-ID>" data-client-token="<YOUR-CLIENT-TOKEN>"></script>

 

so I need to make 2 curl requests 1 to make an <ACCESS-TOKEN> then use the <ACCESS-TOKEN> to make a second curl request

to generate a <YOUR-CLIENT-TOKEN>

 

Hope this helps any future devs that find this post

 

Login to Me Too

ohmniox
Contributor
Contributor

I too was struggling like hell to solve this, but finally after reading the documentation 1000 times I got to know where I was facing the issue.

In order to get the  data-client-token value, we need to invoke 2 APIs:

1. https://api-m.sandbox.paypal.com/v1/oauth2/token  : This retrieves the access token
(Refer this for more information: Get Access Token

2. Then using the access token, we can retrieve the client token using the following API

https://api-m.sandbox.paypal.com/v1/identity/generate-token 

(Refer this for more information: Generate Client Token )

Now the use the client token in the script 
<script src="https://www.paypal.com/sdk/js?components=buttons,hosted-fields&client-id=<Client ID>" data-client-token="<Client Token from Step 2>"></script>

Paypal documentation surely needs to be improved!!!


 

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.