# Web-payment-sdk got error when creating a payment

**URL:** <https://developer.squareup.com/forums/t/web-payment-sdk-got-error-when-creating-a-payment/23549>\
**Category:** Questions\
**Tags:** web-payments-sdk\
**Created:** [August 7, 2025, 7:15am UTC](https://developer.squareup.com/forums/t/web-payment-sdk-got-error-when-creating-a-payment/23549 "2025-08-07T07:15:53Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![louis\_le](https://avatars.discourse-cdn.com/v4/letter/l/ac8455/32.png) [@louis\_le](https://developer.squareup.com/forums/u/louis_le)\
**Post date:** [August 7, 2025, 1:39pm UTC](https://developer.squareup.com/forums/t/web-payment-sdk-got-error-when-creating-a-payment/23549/3 "2025-08-07T13:39:59Z")

</div>

I tried to use a workaround I saw in this conversation [Passing a variable as BigInt to create a new order - #3 by josh-square](https://developer.squareup.com/forums/t/passing-a-variable-as-bigint-to-create-a-new-order/20896/3)

```auto
BigInt.prototype.toJSON = function() {
  return this.toString(); 
};

...
try {
        const response = await squareClient.payments.create({
        idempotencyKey: randomUUID(),
        sourceId: appointmentId,
        name: appointmentId,
        amountMoney: {
            currency: "CAD",
            amount: BigInt(3000),
        },
        });
        console.log('result:::', response)
        return response;
    } catch (error) {
        console.log(error);
    }
...

```

but still got another error as below

> statusCode: 400,  
> body: { errors: [[Object] ] },  
> errors: [  
> {  
> code: ‘EXPECTED\_INTEGER’,  
> detail: ‘Expected an integer value (line 1, character 140)’,  
> field: ‘amount\_money.amount’,  
> category: ‘INVALID\_REQUEST\_ERROR’  
> }  
> ]  
> }

My version “square”: “^43.0.1”,

Appreciate if someone can help. Thanks!

---

_[View the full topic](https://developer.squareup.com/forums/t/web-payment-sdk-got-error-when-creating-a-payment/23549)._
