Question:
I’m encountering an error with WixPayBackend.createPayment
when trying to pass an amount to create a payment. The error message indicates that the amount
cannot be interpreted as a BigDecimal
, and I’m not sure of the exact format expected for this field.
The full error message is:
WixPayBackend.createPayment: Could not decode [{ “currency” : “EUR”, “amount” : 5.75 }] at [.amount] as [BigDecimal].
Product:
Wix Editor with the Wix Pay API in Velo (Backend).
What are you trying to achieve:
I’m trying to create a payment from the backend using a specific amount retrieved from a database (Wix collection). The goal is to generate a payment link that I can send to users.
What have you already tried:
Here are the different approaches I’ve tried so far for the amount
field in the paymentInfo
object:
- Passing the amount as a decimal number (
float
) with a value like5.75
. This gives theBigDecimal
error. - Passing the amount as a string with two decimal places (
"5.75"
) to ensure the format is correct. The error persists. - Converting the amount to cents (an integer) by passing a value like
575
to represent 5.75 €. Still, the same error. - Using
toFixed(2)
to ensure the amount has exactly two decimal places.
Additional information:
- The
amount
field in my database is set as a number. - This issue is being tested in production mode, with the currency set to
EUR
. - I’ve consulted the
wix-pay-backend
documentation and tried formatting the amount in various ways.