Payment API Error For excessing sandbox from HTTPS Domain

Hi All,

I am currently working with Payment api IN SandBox enviroment. when i access the createPayment from localhost It works fine.

But when i try to access createPayment sandbox enviroment from HTTPS Domain . it gave me the following error.

'frame-options': 'DENY',
'x-frame-options': 'DENY',
'x-content-type-options': 'nosniff',
'x-xss-protection': '1; mode=block',
'content-length': '123',
'strict-transport-security': 'max-age=631152000; includeSubDomains; preload',
connection: 'close' },
'{"errors": [{"code": "BAD_REQUEST","detail": "Expected \\"{\\" (line 1, character 1)","category": "INVALID_REQUEST_ERROR"}]}\n',
result: [Object: null prototype] { errors: [ [Object] ] } ,
[ [Object: null prototype] {
code: 'BAD_REQUEST',
detail: 'Expected "{" (line 1, character 1)',
category: 'INVALID_REQUEST_ERROR' } ] }

Can anyone help me to figure out what actually went wrong with my configuration?

Best Regards,

:wave: This error sometimes happens when the environment that you are testing in doesn’t see the access token. Can you confirm that the application has access to the access token and its set correctly?

Hi Bryan,

Thank you for your response. Here is the environment setup code. It is working okay on localhost.

const client = new Client({
  environment: Environment.Sandbox,
  accessToken: process.env.SQUARE_ACCESS_TOKEN,

thanks for the awesome information.

If you are intending to use sandbox as stated in the first line, then the error is happening because you are calling production Payment Api servers. Change Calling Url That’s Work.