getBuyWithFiatStatus
Once you get a quote
from getBuyWithFiatQuote
and open the quote.onRampLink
in a new tab, you can start polling for the transaction status using getBuyWithFiatStatus
You should keep calling this function at regular intervals while the status is in one of the pending states such as - "PENDING_PAYMENT", "PENDING_ON_RAMP_TRANSFER", "ON_RAMP_TRANSFER_IN_PROGRESS", "CRYPTO_SWAP_IN_PROGRESS" etc..
If quote.onRampToken
is same as quote.toToken
(same chain + same token address) - This means that the token can be directly bought from the on-ramp provider.
But if they are different - On-ramp provider will send the quote.onRampToken
to the user's wallet address and a swap is required to convert it to the desired token.
You can use the isSwapRequiredPostOnramp
utility function to check if a swap is required after the on-ramp is done.
If there is no swap required - the status will become "ON_RAMP_TRANSFER_COMPLETED"
once the on-ramp provider has sent the tokens to the user's wallet address.
Once you receive this status, the process is complete.
If a swap is required - the status will become "CRYPTO_SWAP_REQUIRED"
once the on-ramp provider has sent the tokens to the user's wallet address.
Once you receive this status, you need to start the swap process.
On receiving the "CRYPTO_SWAP_REQUIRED"
status, you can use the getPostOnRampQuote
function to get the quote for the swap of type BuyWithCryptoQuote
.
Once you have this quote - You can follow the same steps as mentioned in the getBuyWithCryptoQuote
documentation to perform the swap.