# Google Wallet passes

[Google Wallet](https://wallet.google) (previously known as 'Google Pay') is a digital wallet service that can be used to
store digital artifacts (known as 'passes'), such as movie tickets.

OCAPI supports generation of Google Wallet passes for [completed orders](/digital-platform/completed-orders) that contain tickets.

Prerequisites
Ensure that the Digital Platform has been configured to enable Google Wallet. See our [help centre article](https://help.vista.co/hc/en-nz/articles/31892302130713-Allowing-patrons-to-add-living-tickets-to-a-digital-wallet) for details or talk to your local Vista representative for assistance.

## Add to Google Wallet flow

```mermaid
flowchart TB
    A(Render an 'Add to Google Wallet' button) --> B
    B(Generate a Google Wallet pass) --> C
    C(Open the Google Wallet pass)

    click A "#render-an-add-to-google-wallet-button"
    click B "#generate-a-google-wallet-pass"
    click C "#open-the-google-wallet-pass"
```

## Render an 'Add to Google Wallet' button

Google provides [brand guidelines](https://developers.google.com/wallet/tickets/events/resources/brand-guidelines) that outline
the requirements for rendering an 'Add to Google Wallet' button on various platforms. The 'Add to Google Wallet' button should
[generate a pass](#generate-a-google-wallet-pass) when pressed and [open the pass](#open-the-google-wallet-pass).

a
img
## Generate a Google Wallet pass

Use the [GetGoogleWalletPassForOrder](/openapi/digital-platform/openapi/completed-order-assets/ocapicompletedorderassets_getgooglewalletpassfororder) endpoint to generate a Google Wallet pass for a completed order.

```json
{
  "jwt": "eyJhb...",
  "url": "https://pay.google.com/gp/v/save/eyJhb..."
}
```

Points to Note
- A Google Wallet pass can only be generated for [standard orders](/digital-platform/orders/standard-orders) that contain tickets and have not [expired](/digital-platform/completed-orders/expiry).
- For orders that contain tickets to multiple showtimes, a Google Wallet pass will be generated for each showtime.
- Regardless of the number of showtimes, the endpoint will return the same JSON response.


## Open the Google Wallet pass

The [GetGoogleWalletPassForOrder](/openapi/digital-platform/openapi/completed-order-assets/ocapicompletedorderassets_getgooglewalletpassfororder)
endpoint returns the details required to open a Google Wallet pass and prompt the patron to add it to their Google Wallet.

For native Android apps, use the `jwt` property along with the Google Wallet Android SDK. See Google's [Issuing passes with the Android SDK](https://developers.google.com/wallet/generic/android) guide for more information.

For web, use the `url` property to navigate to the Google Wallet website or app (if installed), for example:

```js
/**
 * Loads a Google Wallet pass for a completed order and navigates to Google's Add Pass to Wallet UI.
 */
async function onAddToGoogleWalletButtonClick(apiUrl, gasToken, orderId) {
  // Load the Google Wallet pass
  const response = await fetch(
    `https://${apiUrl}/ocapi/v1/orders/completed/${orderId}/assets/google-wallet-pass`,
    {
      method: 'GET',
      headers: {
        Authorization: `Bearer ${gasToken}`,
      },
    },
  );

  // Parse the Google Wallet pass JSON.
  const googleWalletPass = await response.json();

  // Open the Google Wallet pass URL in the current window.
  // Note: Opening the URL in a new window may be blocked as a pop-up by the browser.
  window.open(googleWalletPass.url);
}
```