Google Pay payment
Google Pay is Google's digital wallet. With it, the buyer pays with a card already saved in their Google account — on Android or in any supported browser — without entering the number, expiration date, or CVV: they select the card in Google's payment sheet and confirm. The card travels encrypted from Google directly to the acquirer; neither the store nor Appmax has access to the number, which removes the card form from the checkout and the exposure to sensitive data.
In the Appmax App Store, Google Pay is a payment method available to any app installed by a merchant. It uses the same merchant credentials, the same customer and order flow, and the same refund already used for credit card, Pix, and boleto. The only difference is the source of the card data, which now comes from Google instead of a store form.
This page covers the endpoint: what the store needs to have before starting, how to authorize the installation, how to build the payload from what Google returns, and what to do with each response.
Implementing the Google Pay button with the Appmax JS
covers the browser: where to anchor the button, how to initialize the script, and
how the onUpdate and onAuthorize callbacks behave.
If you have already integrated Apple Pay,
the path is the same and shorter: the Appmax JS init() is the same, and
there is no domain to register or .well-known file to publish.
Compatibility
The Google Pay button is displayed in Chrome, Firefox, Safari, Edge, Opera, and UC Browser, on pages served over HTTPS, on both desktop and mobile devices. The buyer must be signed in to a Google account with at least one Visa, Mastercard, or Elo card saved.
| Context | What the buyer sees |
|---|---|
| Android, Windows, or Linux on a supported browser | Google Pay button |
| iOS or macOS with Apple Pay available | Apple Pay button — the script selects it automatically |
| Browser without Google Pay API support | no button; the block stays hidden |
In sandbox, Google shows its own list of test cards as soon as the sheet opens, in any supported browser. This lets you validate the button, sheet, and callbacks without a physical device — see "Testing and Sandbox".
How it works
The integration is done through Appmax JS, the same script used for card tokenization and Apple Pay. The store anchors a button and implements two callbacks; the script performs the remaining steps.
Google's sheet opens inside an Appmax iframe, not on the store's page. Google validates the origin from which the sheet is opened against the domain approved in its console; by opening in the Appmax iframe, a single approved domain serves all integrators. That's why you don't need to create a profile in the Google Pay & Wallet Console, register a domain, or configure Google or acquirer credentials.
Difference from Apple Pay
There is no equivalent of the .well-known file or of the
domain_name installation parameter. If the app is already installed for
card, Pix, or Apple Pay, no new authorization is needed.
| What's up to you | What's up to Appmax |
|---|---|
Anchoring the button and calling init() with externalId, onUpdate, and onAuthorize |
Building Google's sheet and opening the iframe — approved domain and sheet configuration |
Returning the cart total in onUpdate |
Showing Google's official button and handling the click |
Sending the onAuthorize paymentMethodData to your backend and calling POST /v1/payments/google-pay |
Validating the token, identifying the card type, and authorizing with the acquirer |
Glossary
| Term | Description |
|---|---|
| Google Pay | Google's digital wallet. The buyer pays with a card saved in their Google account, without typing it. |
| Sheet (payment sheet) | Google interface where the buyer selects the saved card and confirms the payment. Opened in an Appmax iframe. |
paymentMethodData |
Object returned by Google after confirmation and received in onAuthorize. It is sent to Appmax in full, in payment_data.google_pay.payment_data. Generated per transaction. |
| Token | String in tokenizationData.token, inside paymentMethodData, with the card encrypted for the acquirer. Forwarded unchanged. |
onUpdate |
Callback implemented by the store: returns the cart total before the sheet opens. |
onAuthorize |
Callback implemented by the store: receives the paymentMethodData after the buyer confirms. |
external_id |
UUID that identifies the pair (installed app + store). Generated at installation and used by the Appmax JS init(). See App installation. |
pay_reference |
Charge identifier, returned in the 201. Used for reconciliation and for refunds. |
Prerequisites
On the buyer's side, for the button to appear:
- Google account with at least one Visa, Mastercard, or Elo card saved.
- Supported browser — Chrome, Firefox, Safari, Edge, Opera, or UC Browser.
- Page served over HTTPS.
On the integration side:
- App installation authorized, with the
external_idavailable (step 1). - Appmax JS included and initialized with
onUpdateandonAuthorize(step 2). - Merchant Bearer token, obtained from
POST /oauth2/tokenwith the merchant's credentials — not the app's. See Authentication.
Flow components:
- JS script:
https://scripts.appmax.com.br/appmax.min.js(production) — in sandbox, usehttps://scripts.sandboxappmax.com.br/appmax.min.js. See Environments. - Payment request to the Appmax API with a valid
paymentMethodData,order_id, andcustomer_id.
1. Authorize the app installation
The flow is the same as for any other payment method in the API: the merchant
authorizes the installation (POST /app/authorize → redirect →
POST /app/client/generate), Appmax calls the app's validation URL, and, at the end,
the merchant credentials and the external_id
for that installation are delivered. See App installation
for the full flow, with a sequence diagram of all the calls.
curl --location 'https://api.appmax.com.br/app/authorize' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer SEU_TOKEN' \
--data '{
"app_id": "APP_ID",
"external_key": "EXTERNAL_KEY",
"url_callback": "URL_CALLBACK"
}'
INFO
Unlike Apple Pay, Google Pay doesn't use the
domain_name parameter. The full installation step-by-step is in
App installation and
Test the validation URL. The external_id is
detailed in external-id.
2. Include and initialize Appmax JS
TIP
For the full step-by-step — button
selectors, SPA load order, the onUpdate contract, the
onAuthorize behavior, and troubleshooting — see
Implementing the Google Pay button with the Appmax JS.
WARNING
The externalId expected here is the same external_id you returned
with HTTP 200 in the
App installation step.
appmax.min.js does three things:
- Builds Google's sheet and opens it in an Appmax iframe — you don't configure a domain or Google credentials.
- Renders Google's official button in the
[data-appmax-google-pay]anchor and handles the click. - Fires the update (
onUpdate), authorization (onAuthorize), and error (onError) callbacks.
2.1 Initialize with externalId, onIp, onError, onUpdate, and onAuthorize
<!-- IP collection trigger: required, and must exist before init -->
<form data-appmax-customer hidden></form>
<div data-appmax-checkout data-appmax-merchant-name="Nome da loja">
<div data-appmax-google-pay-wrapper>
<button data-appmax-google-pay style="height: 48px; width: 100%"></button>
</div>
</div>
<script>
// Production: https://scripts.appmax.com.br/appmax.min.js
// Sandbox: https://scripts.sandboxappmax.com.br/appmax.min.js
const onUpdate = () => ({ total: 150.90 }); // in reais, as a number
const onAuthorize = async (paymentMethodData) => {
await processGooglePayPayment(paymentMethodData); // see step 3
};
const checkoutData = {
customer: {}
};
const onIp = ({ ip }) => {
checkoutData.customer.ip = ip;
};
const onError = ({ code, message, stage }) => console.error('Google Pay error:', code, stage, message);
window.AppmaxScripts.init({ externalId, onIp, onError, onUpdate, onAuthorize });
</script>
`onUpdate` values are provided in reais
onUpdate is an Appmax JS contract, not an API one. For that reason, the total field must be provided in reais, while the values sent to the API are provided in cents.
For example, for a charge of R$ 150.90:
- In
onUpdate:total: 150.90 - In
POST /v1/orders:15090, since the API uses integer monetary values in cents.
This difference matters because using the API format in onUpdate doesn't raise an error, but it changes the amount shown to the buyer. For example, total: 15090 will be interpreted as R$ 15,090.00.
In addition, the POST /v1/payments/google-pay request body has no field for the charge amount: the payment uses the order's total amount. As a result, an incorrect total in onUpdate can cause the buyer to see an amount on the payment sheet that differs from the amount actually charged.
For more details, see What onUpdate must return and Monetary values.
INFO
In Google Pay, the sheet is already closed when onAuthorize is
invoked and the returned value isn't used — approval or decline is
handled on your screen, based on the response from step 3. This differs from
Apple Pay; see
How onAuthorize behaves.
3. Process the payment
onAuthorize receives the paymentMethodData, which must be sent to the
store's backend. The backend runs the standard API sequence: customer,
order, and payment.
POST /v1/customers— creates or updates the customer; storedata.customer.id.POST /v1/orders— creates the order; storedata.order.id.POST /v1/payments/google-pay— makes the payment, with thecustomer_idandorder_idfrom the previous steps.
The object received in onAuthorize has this shape:
{
"type": "CARD",
"description": "Visa •••• 1234",
"info": {
"cardNetwork": "VISA",
"cardDetails": "1234",
"assuranceDetails": {
"accountVerified": true,
"cardHolderAuthenticated": true
}
},
"tokenizationData": {
"type": "PAYMENT_GATEWAY",
"token": "{\"signature\":\"MEUCIQ...\",\"protocolVersion\":\"ECv2\",\"signedMessage\":\"{...}\"}"
}
}
This object, in full and unmodified, is what goes in
payment_data.google_pay.payment_data.
The `gatewayMerchantId` is configured internally by Appmax
Don't send, replace, or try to set this identifier in the payload.
Forward the paymentMethodData received in onAuthorize in full
and unchanged, in payment_data. The public payload is the one in the example
below — no fields beyond those are needed.
async function processGooglePayPayment(paymentMethodData) {
// 1. Create customer — POST /v1/customers (see /api-reference/customers/criar-atualizar)
// 2. Create order — POST /v1/orders (see /api-reference/orders/criar-pedido)
// 3. Complete payment — POST /v1/payments/google-pay
const paymentPayload = {
order_id, // Order that already exists in Appmax
customer_id,
payment_data: {
google_pay: {
installments: 2, // 1 to 12
holder_document_number: "51425014038", // required
soft_descriptor: "MINHALOJA", // optional, max. 13 characters
payment_data: paymentMethodData // the onAuthorize object, in full
}
}
};
const resp = await fetch('https://api.appmax.com.br/v1/payments/google-pay', {
method: 'POST',
headers: { 'Content-Type': 'application/json', Authorization: `Bearer SEU_TOKEN` },
body: JSON.stringify(paymentPayload)
});
if (!resp.ok) throw new Error('Payment failed');
const { data } = await resp.json();
// Store data.payment.pay_reference in your database. To the front end,
// return only the status — never the pay_reference, the document, or the token.
return { status: 'aprovado' };
}
Warning
- Don't call
JSON.parseon thetoken. Thetokenis a string and must be sent exactly as received. Appmax does the parsing. - Don't remove fields from the object. Send the whole object, including
info. Appmax uses this data to validate the transaction and build the receipt, including the card brand and last digits. The full card number doesn't travel.
Backend integration
The request must be made exclusively from the backend. Credentials and sensitive data, such as the Bearer token, must never be exposed to the browser.
The front end must receive only the result needed for the interface: the operation status (approved or declined) and, optionally, a message. Data such as credentials, pay_reference, holder_document_number, and full API responses must stay in the backend.
INFO
-
Required fields:
order_id,customer_id,installments(1–12),holder_document_number, andpayment_data. -
soft_descriptoris optional (max. 13 characters).
The 201 response returns the payment in data.payment:
{
"data": {
"payment": {
"pay_reference": "test_localhost_1_2b5c0",
"upsell_hash": "92447142021040-1704397469-0391056001704397469",
"cashback": null
}
}
}
pay_referenceidentifies the charge and must be stored for reconciliation and refunds.upsell_hashis used for upsells.- The order status is reported through webhooks and through the order retrieval, as with any card payment.
Errors return { "errors": { "message": "..." } }, except for 403,
which uses the legacy envelope. The codes and messages are in
Responses, below. Acquirer declines arrive as
Pagamento não autorizado: <motivo>, with the status matching the
reason — show the reason to the buyer and allow another attempt.
Testing and Sandbox
In the sandbox you don't need a real card
As soon as the sheet opens, Google shows its own list of test cards, in any supported browser — including desktop. You don't need to provision a card in Google Wallet to get started.
In the sandbox, Google returns simulated card data and no charge is made. You can exercise the full flow — button, sheet, token, and payment call — without involving the buyer's card.
WARNING
The environment is defined by Appmax, according to the URL of the included script.
Use the sandbox script, API, and credentials together
(Environments); mixing different environments
results in 401.
What you can validate in the sandbox:
- Google's button and sheet, with the test cards.
- The
onUpdate,onAuthorize, andonErrorcallbacks. - The payment call contract and error handling.
- Customer and order creation.
Before going to production, do an acceptance test with a real payment on a device with a card saved in Google Wallet.
Environments
| Sandbox | Production | |
|---|---|---|
| JS script | https://scripts.sandboxappmax.com.br/appmax.min.js |
https://scripts.appmax.com.br/appmax.min.js |
| API | https://api.sandboxappmax.com.br |
https://api.appmax.com.br |
| Authentication | https://auth.sandboxappmax.com.br |
https://auth.appmax.com.br |
| Card on the sheet | Google test list | buyer's card |
| Charge | none | real |
Script and external_id must belong to the same environment — see
Environments.
Frequently asked questions (FAQ)
The sheet doesn't open and nothing appears in the console.
If the store's checkout runs inside an iframe, that iframe
needs allow="payment". Without it, the browser blocks the sheet
silently.
The buyer closed the sheet. Do I need to show an error?
No. Google returns CANCELED, which corresponds to the buyer backing out — just
allow another click. The same code is returned when Google
declines the merchant or the account and shows the error inside the sheet; from the
store page's point of view, the two cases are indistinguishable.
I got a 400 with Invalid Google Pay token. Is the problem the card?
No. In nearly all cases the paymentMethodData was altered
before sending — a JSON.parse on the token or removed fields.
Forward the object exactly as received in onAuthorize. If the error
persists, contact Appmax support.
Do I need to host any file or register a domain?
No. There is no equivalent of the
Apple Pay .well-known,
and you don't need a profile in the Google Pay & Wallet Console. The sheet opens
in an Appmax iframe, whose domain is already approved.
Can I offer installments?
Yes. Send installments from 1 to 12 in the payment body. Interest and
per-installment amounts follow what is returned by
Get installments for the store. The
onUpdate installments isn't used by Google Pay.
How is a refund made?
Through the same endpoint as the other methods:
Create a refund, with the
pay_reference returned in the 201. The transaction is a credit card
transaction for all purposes.
Which card's last four digits does the receipt show?
Those that Google returns in info.cardDetails. Since the card number
doesn't travel in this integration, it's the only source — that's why the field must
not be removed from the object.
Can I offer Apple Pay and Google Pay on the same page?
Yes. Anchor the selectors of both wallets and use the same init(). The
script shows Apple Pay where it is available and Google Pay in the
other supported browsers; onAuthorize receives the token of the
wallet used — see
Implementing the Apple Pay button with the Appmax JS.
Conclusion — checklist
- Authorize the app installation and store the
external_id— App installation. - Include the Appmax JS from the right environment (Environments) and anchor the button with
data-appmax-google-pay, inside adata-appmax-checkoutwithdata-appmax-merchant-name— see Implementing the Google Pay button. - Call
window.AppmaxScripts.init()withexternalId,onIp,onError,onUpdate, andonAuthorize. - Return the cart in
onUpdatein reais, with numeric values — not in cents, unlike the API endpoints. - In
onAuthorize, send thepaymentMethodDatato the backend, in full and without parsing thetoken. - Create the customer → create the order → process at
POST /v1/payments/google-pay, always from the backend, with the merchant token (Authentication). - Treat a closed sheet as the buyer backing out, with no error message.
- If the checkout runs in an iframe, make sure it has
allow="payment". - Validate in the sandbox and do an acceptance test with a real payment before going to production.
Authorizations
Bearer token of the merchant obtained via POST /oauth2/token using the
merchant's credentials (not the app's). See
Authentication.
Request Body
Responses
Google Pay payment approved. data.payment.pay_reference identifies the charge.