SquareUp Payment after token nonce generation

16 views Asked by At

After generating nonce from squareup payment form to make a payment, we make a call using that token with the help of square client from node.

` const client = new Client({ environment: Environment.Sandbox, // Use Environment.Production for the production environment accessToken: accessToken, });

        if (client instanceof Client) {
          const response = await client.paymentsApi.createPayment({
            sourceId: token,
            idempotencyKey: Math.random().toString(36).substring(7),
            amountMoney: {
              amount: 100,
              currency: 'USD'
            }
          ;

`

This is how i'm doing it

[ERROR] Error processing payment: adapter is not a function

This is the error i get after running this function. What can be the reason and how can it be fixed?

1

There are 1 answers

1
Fahad Hafeez On

The error was because cloudflare workers didnt support API calls like this. So used the fetch method instead of it.