I’m trying to create an order with the new 40.0 API and I keep getting error with the baseMoney.amount field. I am passing a number like 3500 from a cart object and it’s keeps giving me an error. I have tried passing it as a string, a number and BigInt but nothing works. I can it work to in the API explorer no problem.
Even if I hard code the amount like 3500 I get an error. If I pass BigInt(3500) it says “Expected an integer”. I even tried passing amount:3500n
I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:
If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.
Hey @brianmaggi! Can you verify if you’ve fully updated the SDK to 40.0.0? I just tested the latest Node.js SDK version with this code copied directly from API Explorer, and the request succeeded as expected:
Josh, thanks for the quick response I appreciate it. I am running 40.0.0 → in my package.json I have "square": "^40.0.0", I still have the legacy Square package installed.
import { Client } from "square/legacy";
import { SquareClient, SquareEnvironment } from "square";
I even tried hard coding data similar to what you’d submit in the API Explorer. Note amount: BigInt(3500) looks the same. So I don’t think it’s malformed.
I haven’t narrowed it down to a single problem. I think it might have something to do with my local server getting 500 errors upstream of the function to Square. So maybe it is malformed data.
Got it, yeah malformed data would fit the symptoms that we’re seeing. I’d also recommend trying to remove the legacy Square package entirely and test with only the non-legacy package imported: import { SquareClient, SquareEnvironment } from "square";
Doesn’t hurt to rule it out entirely in case there’s some wires getting crossed there accidentally!
I think 3 different things were happening which made it hard to troubleshoot. I had the legacy package still installed, there was a downstream unrelated bug 500 errors, and I had that BigInt function / workaround. All three have been removed and it works great now.
In my last reply, that was one of the 3 things I took out and now everything is working. I do have to convert the two different numbers to strings first to work. But that’s no big deal.