Is there a log of all the API calls triggered?

Hello,
I’m going through the quick start program here:

Is there anywhere in the developer dashboard where I can check a log of which API calls were triggered with my program?

Yes, you can view API Logs of all API calls your application makes. :slightly_smiling_face:

Hi I’m getting this response: {
“errors”: [
{
“category”: “INVALID_REQUEST_ERROR”,
“code”: “INVALID_VALUE”,
“detail”: “This merchant can only process payments in GBP, but amount was provided in USD.”,
“field”: “amount_money.currency”
}
]
}

using:
async function createPayment(token) {
const body = JSON.stringify({
locationId,
sourceId: token,
amount: 200,
currencyCode: ‘GBP’,
});

        const paymentResponse = await fetch('/payment', {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
            },
            body,
        });

        if (paymentResponse.ok) {
            return paymentResponse.json();
        }

        const errorBody = await paymentResponse.text();
        throw new Error(errorBody);
    }

Could you guide me in the right direction. Many thanks.

@JD.net, The function /payment is in the server.js file of our Quickstart. In that file you’ll need to change the currency from USD to GBP. :slightly_smiling_face:

Thanks, this works great. by the way how can I add cents as is only accepting integer value.

  "errors": [
    {
      "code": "EXPECTED_INTEGER",
      "detail": "Expected an integer value (line 1, character 117)",
      "field": "amount_money.amount",
      "category": "INVALID_REQUEST_ERROR"
    }

When working with the Money object, applications might get an EXPECTED_INTEGER error code because the specified amount value is invalid. It indicates that Square was expecting information as an integer but was sent something else (for example, a string or a float). To resolve this error:

  • Make sure the amount value is specified in the smallest denomination of the currency used. For example, the smallest currency denomination for USD is cents.
  • Make sure the amount value is specified as a positive integer.
  • Make sure the amount value is greater than, or equal to, the valid minimum amount. Valid minimums are determined by the Location.country associated with the account:
    • The United States and Canada. amount values must be integers greater than or equal to 1.
    • Australia, Japan, and the United Kingdom. amount values must be integers greater than or equal to 100.
      :slightly_smiling_face:

Thank you for this information, so if someone adds to my shopping car 2 products one costing: 7,20 GBP and the other one costing 8 GBP, the total for the client to pay would be: 15,20 so to charge 15,20 GBP its not possible, therefore I have to charge only 15 GBP?. Thanks.

You can charge £15.20. You’ll just pass the amount 152000 when you call CreatePayment. :slightly_smiling_face:

Thanks for your support, could you guide me further as this is not giving me the correct response.
server.js:
amountMoney: {
// the expected amount is in cents, meaning this is $1.00.
amount: ‘152000’,
// If you are a non-US account, you must change the currency to match the country in which
// you are accepting the payment.
currency: ‘GBP’,
},
};

card.html:
async function createPayment(token) {
const body = JSON.stringify({
locationId,
sourceId: token,
amount: ‘152000’,
});
my response:

  "payment": {
    "id": "TP15ECTb4aXEvmtvz26K5iS0X1XZY",
    "created_at": "2023-03-17T16:34:07.624Z",
    "updated_at": "2023-03-17T16:34:07.855Z",
    "amount_money": {
      "amount": 152000,
      "currency": "GBP"
    },
    "total_money": {
      "amount": 152000,
      "currency": "GBP"
    },
    "approved_money": {
      "amount": 152000,
      "currency": "GBP"
    },

With Square the amount will always be shown in cents with the responses from our APIs. So 152000 is £15.20. :slightly_smiling_face:

Hi,
Thanks for letting me know! It’s good to be aware that with Square’s APIs, the amounts are always shown in cents. I appreciate you clarifying that 152000 would represent £15.20.
Thank you once again for all your support. :slightly_smiling_face: