Use this file to discover all available pages before exploring further.
Use this guide to execute a transaction with Google Pay after you have a connected customer.See the Going Live section for details on the requirements you must meet before you can take this integration to production.
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.
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: "google_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 Google Pay frame reference.
In some cases, transactions require a challenge. See handling
challenges for details.
Google Pay
import type { GooglePayEvent } from "@moonpay/platform";// Render the Google Pay frame into your UI and handle callbacksconst googlePayResult = await client.setupGooglePay({ quote: quoteResult.value.signature, // The quote signature from getQuote container: document.querySelector("#googlePayContainer"), // DOM element to render the button onEvent: (event: GooglePayEvent) => { 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 "challenge": // Verification required. Render the challenge frame at the provided URL. // See: /platform/guides/handling-challenges console.log(event.payload.url); 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": // Google Pay isn't supported in the current environment. break; } },});if (!googlePayResult.ok) { // Handle error setting up Google Pay}// You can update the quote or dispose the frame later// googlePayResult.value.setQuote(newQuoteSignature);// googlePayResult.value.dispose();