Sandbox payment not working - undocumented error code

Hi folks,

I’m new to square payments, so hopefully this is an easy/obvious one. I’m working on the back end code, making a call to createPayment in the sandbox:

const client = new Client({
environment: Environment.Sandbox,
accessToken: “obscured

const params = {
sourceId: “cnon:card-nonce-ok”,
idempotencyKey: uuid(),
amountMoney: {
amount: 100,
currency: “USD”

try {
const response = await client.paymentsApi.createPayment(params);
} catch (err) {
console.log(“err”, err);

The response I get is a 400, along with an INVALID_REQUEST_ERROR code I couldn’t find in the API documentation. Here is the request and response. If anyone could tell me what I’m messing up I would greatly appreciate it!

request: {
method: ‘POST’,
url: ‘’,
headers: {
‘user-agent’: ‘Square-TypeScript-SDK/13.1.0’,
‘content-type’: ‘application/json’,
authorization: ‘Bearer obscured’,
‘Square-Version’: ‘2021-08-18’,
accept: ‘application/json’
body: {
type: ‘text’,
content: ‘{“source_id”:“ccof:customer-card-id-requires-verification”,“idempotency_key”:“cd4047eb-fbe2-4648-b4f6-d4289280d2f1”,“amount_money”:{}}’
statusCode: 400,
headers: {
date: ‘Mon, 06 Sep 2021 11:53:32 GMT’,
‘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’
body: ‘{“errors”: [{“code”: “BAD_REQUEST”,“detail”: “Expected \”{\" (line 1, character 1)",“category”: “INVALID_REQUEST_ERROR”}]}\n’,
result: [Object: null prototype] { errors: [ [Object: null prototype] ] },
errors: [
[Object: null prototype] {
code: ‘BAD_REQUEST’,
detail: ‘Expected “{” (line 1, character 1)’,

Hi @warrenspencer1977 welcome to the Square developer community :).

The issue seems to be that null is provided for amount_money. Can you retry the sandbox API request with values for currency and amount within the amount_money object. Here’s an example:

"amount_money": {
      "currency": "USD",
      "amount": 1000

Here’s a link to the Payment API documentation with more information on fields required in the request: POST /v2/payments - Square API Reference, hope this helps!