Quotes provide real-time prices and fees for transactions. Present detailed quotes in your UI using data from the SDK or API.Only executable quotes can be used for transactions. In some cases, quotes require a challenge before you can execute a transaction. See handling challenges for details.
Copy
Ask AI
const quoteResult = await client.getQuote({ source: "USD", // The fiat currency for payment destination: "ETH", // The crypto the customer will receive sourceAmount: "100.00", // The amount to purchase walletAddress: "0x1234...", // The destination wallet address paymentMethod: "apple_pay", // The payment method type});if (!quoteResult.ok) { // Handle error}console.log(quoteResult.value);
To execute a transaction, set up the payment flow based on the quote. Different payment methods have different requirements—you can configure each as needed to control your experience. For the frame URL, size, permissions, and events, see the Apple Pay frame reference.
In some cases, transactions require a challenge. See handling
challenges for details.
Apple Pay
Copy
Ask AI
import type { ApplePayEvent } from "@moonpay/platform";// Render the Apple Pay frame into your UI and handle callbacksconst applePayResult = await client.setupApplePay({ quote: quoteResult.value.signature, // The quote signature from getQuote container: document.querySelector("#applePayContainer"), // DOM element to render the button onEvent: (event: ApplePayEvent) => { switch (event.kind) { case "ready": // The frame is ready. Use this event to reveal the button if needed. break; case "complete": // The transaction is executing. Track the final status via polling and/or webhooks. console.log(event.payload.transaction); // { id: "txn_01", status: "pending" } break; case "quoteExpired": // Fetch a new quote, then pass its signature into the frame // const newQuote = await client.getQuote({...}); // event.payload.setQuote(newQuote.value.signature); break; case "error": // Depending on the error, you can have the customer pick a different payment method or retry. console.error(event.payload.message); break; case "unsupported": // Apple Pay isn't supported in the current environment. break; } },});if (!applePayResult.ok) { // Handle error setting up Apple Pay}// You can update the quote or dispose the frame later// applePayResult.value.setQuote(newQuoteSignature);// applePayResult.value.dispose();