Redirect URLs
Send users to a specific website after a successful or cancelled purchase.
The <CrossmintPayButton>
component offers two optional properties which can be used to redirect users to a website after a purchase:
successCallbackURL
redirects users to a given url after a successful transaction.failureCallbackURL
redirects users to a given url after a failed transaction.
Whitelisting Domains
For security reasons, you must whitelist the URLs from the Domains
tab on the console (staging, production).
Whitelisted domains must be https
. This means you will not be able to whitelist localhost
since it’s http
Payloads
The redirect URL will contain a query parameter with format ?p=payload
which contains an object with information about the outcome of the transaction. The payload
will be a URL encoded JSON string. If you pass https://www.example.xyz/success
as the successCallbackURL
then you will be redirected to URL like the following:
You can then extract and parse the payload from the redirect URL like so:
The exact structure of the payload can vary depending on the specific implementation and the transaction details. See below for details about the expected properties.
type
: Payload type (purchase.succeeded
).status
: Transaction status ("success"
).walletAddress
: Address to which the minting is done.passThroughArgs
: Additional arguments passed through the transaction.clientId
: The client identifier.collectionId
: The collection identifier, same asclientId
.txId
: The transaction identifier.orderId
: The order identifier associated with the transaction.projectId
: The project identifier (if available).contractAddress
: The contract address of the token contract (EVM only)mintHash
: The mint hash of the token (Solana only)tokenId
: The tokenId of the the transaction. (EVM only)tokenIds
: An array of tokenIds to support transactions where multiple are purchased. (EVM only)
Testing the Failure Condition
It’s rather difficult to test the failure condition for two reasons. Firstly, Crossmint simulates the transaction before presenting the checkout to the user and if the simulation fails they will not be able to proceed with payment. If simulation is successful and payment proceeds, Crossmint will automatically retry until successful.
Any issues with credit card processing will be handled directly in the checkout form and will not result in creating the failure condition as the order is not actually submitted without a successful payment.
For primary sales, where the buyer is minting an NFT into existence, the only plausible failure conditions are:
- the contract sells out between simulation and payment completion
- some other contract error that couldn’t be detected in simulation (allowlist is updated between simulation and payment for example)
For secondary sales, it’s possible that another user buys the NFT for sale before the purchase completes.
If you really must test the failure condition you could open a checkout and allow simulation to complete. Then make a change in the contract such as pausing the sale. Then, after the contract sale is paused, you could submit payment. This should create the failure condition.