executable: true.
Setup Google Pay
Parameters
| Property | Type | Required | Description |
|---|---|---|---|
quote | string | ✅ | The quote signature returned from getQuote. |
container | HTMLElement | ✅ | A DOM element to render the Google Pay frame into. |
externalTransactionId | string | Partner-assigned identifier for this transaction attempt. Useful for reconciliation. | |
onEvent | (event: GooglePayEvent) => void | Callback invoked for Google Pay flow events. See GooglePayEvent. |
GooglePayEvent
onEvent receives events as the Google Pay flow progresses. Use event.kind to decide how to handle each event.
| kind | Payload | When you receive it |
|---|---|---|
"ready" | — | The Google Pay UI is rendered and ready to be shown. |
"complete" | { transaction: FrameTransaction } | The Google Pay flow finished. Inspect the FrameTransaction for the outcome. |
"challenge" | { kind: "frame"; url: string } | Verification required. Render the challenge frame at the provided URL using setupChallenge(). |
"quoteExpired" | { setQuote: (signature: string) => void } | The quote signature expired. Fetch a new quote and call payload.setQuote(...). |
"error" | GooglePayEventError | The flow encountered an error. |
"unsupported" | — | Google Pay isn’t available in the user’s current environment. |
FrameTransaction
The transaction object returned on "complete". FrameTransaction is a discriminated union — the failure variant carries failureReason, the non-failure variant always carries id.
| Field | Type | Required | Description |
|---|---|---|---|
status | string | ✅ | The transaction status. On the failure variant, "failed". |
id | string | Required on the non-failure variant; optional when status is "failed" (a transaction may not exist yet on early failure). | |
failureReason | string | Present only on the failure variant (status === "failed"). |
GooglePayEventError
| Field | Type | Required | Description |
|---|---|---|---|
kind | "configurationError" | "invalidQuote" | "quoteExpired" | "genericError" | ✅ | The error category. |
message | string | ✅ | Developer-friendly details. |
"unsupported" event, not as an error.
Result
client.setupGooglePay() returns a Result<GooglePayFrame, SetupGooglePayError>.
Result envelope
Result<GooglePayFrame, SetupGooglePayError>
| Field | Type | Required | Description |
|---|---|---|---|
ok | boolean | ✅ | Whether the operation succeeded. |
value | GooglePayFrame | Present when ok is true. | |
error | SetupGooglePayError | Present when ok is false. |
GooglePayFrame
| Field | Type | Required | Description |
|---|---|---|---|
setQuote | (signature: string) => void | ✅ | Updates the quote signature used by the frame. Use this in response to quoteExpired. |
dispose | () => void | ✅ | Unmounts the frame. After you call this, no further events are dispatched to your onEvent callback. |
SetupGooglePayError
| Field | Type | Required | Description |
|---|---|---|---|
kind | "configurationError" | "genericError" | ✅ | The error category. |
message | string | ✅ | Developer-friendly details. |
onEvent after setup succeeds — as the "error", "quoteExpired", and
"unsupported" events respectively.
TS Definitions
TS Definitions
types.ts