Charges
Last updated
Last updated
Charges represent a payment by your users, and have a wealth of data associated with it. Each charge has an associated checkout, which is a hosted page where a user can perform the payment. You'll need to redirect your users there so they can pay the charge. Note that charges (and it's associated checkouts) expire after a determined amount of time. Any payment done after the expiry of the charge will be refused.
To request a cryptocurrency payment, you create a charge. Since cryptocurrency payments are push payments, a charge will expire after a waiting period (payment window) if no payment has been detected. Charges are identified by a unique code.
TIP
Your metadata object has to be stringifable. If it is not, charge creation will fail.
If you don't want to use the provided payment page, you can use the data received from charge creation to generate a QR code and address for payment. The procedure depends on each coin, but for BTC (the only accepted coin at this time) you can use the following with any QR code generator:
You don't need to include sending fees: they are automatically included when the user scans the wallet, which allows the wallet to generate the fees dynamically.
WARNING
If you alter the amount field from the response when you generate the payment, the system will either register the charge as underpaid (if lowering the amount) or the amount overpaid (if making the amount bigger) will be lost!
Note that if you aren't careful, the amounts can cause rounding errors in certain programming languages.