Fetch Quote
The fetchQuote method retrieves a quote for the specified amount in USD. The quote is used to calculate the corresponding token amount required for the card purchase. It expires in about 30 seconds.
Last updated
const participantId = "JohnChamling";
const firstName = "John";
const lastName = "Chamling";
const emailAddress = "user@example.com";
const mobilePhone = "+91 012345678";
const language = "en-US";
const city = "Bharatpur";
const state = "Bagmati";
const postalCode = "44200";
const countryCode: CountryCode = "NPL";
const address1 = "Shittal street, Bharatpur - 10, Chitwan";
const recipient = Recipient.create(
participantId,
firstName,
lastName,
emailAddress,
mobilePhone,
language,
city,
state,
postalCode,
countryCode,
address1,
);
const amount = "150.55";
const quote = await service.fetchQuote(amount);
const [depositResponse, buyCardResponse, apiResponse] = await service.purchaseCard({
amount,
recipient,
quote,
});
console.log("Deposit Transaction Hash:", depositResponse.hash);
console.log("Purchase Transaction Hash:", buyCardResponse.hash);
console.log("Zebec Server Response:", apiResponse.data);const participantId = "JohnChamling";
const firstName = "John";
const lastName = "Chamling";
const emailAddress = "user@example.com";
const mobilePhone = "+91 012345678";
const language = "en-US";
const city = "Bharatpur";
const state = "Bagmati";
const postalCode = "44200";
const countryCode: CountryCode = "NPL";
const address1 = "Shittal street, Bharatpur - 10, Chitwan";
const recipient = Recipient.create(
participantId,
firstName,
lastName,
emailAddress,
mobilePhone,
language,
city,
state,
postalCode,
countryCode,
address1,
);
const amount = "150.55"; // Amount in USD
const quote = await service.fetchQuote(amount);
const [depositResponse, apiResponse] = await service.purchaseCard({
walletAddress: signer.address || "<wallet_address>",
amount,
recipient,
quote,
});
console.log(
`Deposit response: \n BlockHash: ${depositResponse.blockHash} \n TransactionHash: ${depositResponse.txHash}`,
);
console.log("Zebec Server Response:", apiResponse.data);