1
Order Creation or Update
Your user selects the chain, token, and wallet they want to pay from via your application and you create or
update an existing order with this information.
2
API Response
The API response returned from create or update order will include a
serializedTransaction
that your
application uses to request payment from the user’s wallet.3
User Confirms Transaction
After your application initiates the payment request the user must confirm the transaction.
4
Poll for Status
Your application will poll the GET order status and update the UI as the order progresses to the next phase.
During the initial
quote
phase of the order the payment status will be requires-quote
.awaiting-payment
, which indicates that the order is ready to be paid. However, it can also begin with requires-crypto-payer-address
if this information is missing.
See below the full list of possible statuses:
Payment Status | Explanation |
---|---|
requires-quote | still in the quote phase |
requires-crypto-payer-address | payment.payerAddress is missing |
requires-physical-address | shipping address is required for physical products |
crypto-payer-insufficient-funds | payerAddress cannot cover purchase for chain/currency given |
crypto-payer-insufficient-funds-for-gas | payerAddress cannot cover the blockchain fees for the transaction |
awaiting-payment | ready to submit payment |
completed | order is in the delivery or order completion phase |
completed with payment.refunded | payment was completed but has been refunded |
Setting the Payer Address
The order must know the address that will be sending the crypto payment. This enables Crossmint’s payment listeners to associate incoming transactions with the correct order. To update the order with the payer address, call the update API as demonstrated below:PATCH
/api/2022-06-09/orders/<orderId>
payerAddress
is the wallet the user will be sending the payment from. Note that you must send the entire payment object even if the currency and/or method values are not changing.
Submitting the Payment
When you’ve fully prepared the order such that the payment status isawaiting-payment
you’ll have everything necessary to request the crypto payment from your user. The details will be returned in the order.payment.preparation
property.
Example response
Example response
order.payment.preparation
property contains details about the chain that Crossmint is expecting the payment to be received on, the payer address, and a serializedTransaction
that you can use to open a payment request in the user’s wallet. See examples of how to parse the response and request transaction confirmation from the user below:
You should never alter the values in the parsed transaction object. Simply parse the transaction object as shown
in the example above. Changing any of these values may result in Crossmint not being able to validate the payment.
signAndSendTransaction
function in the code snippet(s) above will open the user’s wallet and enable them to confirm the crypto payment.
Awaiting Payment Confirmation
We recommend a polling interval of about 2500ms and never below 500ms.
You can use client-side or server-side API keys to implement headless checkout. Check the code samples for the type
of API key you’re using in your application.
Handling Refunded Payments
When polling for order status, you may encounter a situation wherepayment.status
is completed
but the order also contains a payment.refunded
property. This indicates that the payment was initially successful but has since been refunded.
payment.refunded
object includes the following fields:
amount
: The amount that was refundedcurrency
: The currency of the refundtxId
: The on-chain transaction ID the refund was sent inchain
: The blockchain where the refund transaction occurred
- Display an appropriate message to the user indicating that their payment was refunded
- Provide the transaction ID (
txId
) so users can verify the refund on-chain - Prevent any further actions related to the order (such as delivery expectations)
- Provide options for the user to place a new order if desired