- [JSON representation](https://developers.google.com/pay/client-side-push-provisioning-v1/google-client-side-push-provisioning-api/GoogleOpaquePaymentCard#SCHEMA_REPRESENTATION)
- [ProtocolHeader](https://developers.google.com/pay/client-side-push-provisioning-v1/google-client-side-push-provisioning-api/GoogleOpaquePaymentCard#ProtocolHeader)
  - [JSON representation](https://developers.google.com/pay/client-side-push-provisioning-v1/google-client-side-push-provisioning-api/GoogleOpaquePaymentCard#ProtocolHeader.SCHEMA_REPRESENTATION)
- [ValidationContext](https://developers.google.com/pay/client-side-push-provisioning-v1/google-client-side-push-provisioning-api/GoogleOpaquePaymentCard#ValidationContext)
  - [JSON representation](https://developers.google.com/pay/client-side-push-provisioning-v1/google-client-side-push-provisioning-api/GoogleOpaquePaymentCard#ValidationContext.SCHEMA_REPRESENTATION)
- [PaymentCard](https://developers.google.com/pay/client-side-push-provisioning-v1/google-client-side-push-provisioning-api/GoogleOpaquePaymentCard#PaymentCard)
  - [JSON representation](https://developers.google.com/pay/client-side-push-provisioning-v1/google-client-side-push-provisioning-api/GoogleOpaquePaymentCard#PaymentCard.SCHEMA_REPRESENTATION)

Opaque (i.e., encrypted) payment card sent via client-side push provisioning. It is deliberately named to be similar to the Opaque Payment Card that is already passed through client-side push provisioning to Token Service Providers for the purpose of tokenization.

Here's an example of a clear text JSON request:


    {
      "protocolHeader": {
        "version": 1
      },
      "validationContext": {
        "serverSessionId": "GoogleSession123"
      },
      "paymentCard": {
        "accountNumber": "4321123412341234",
        "expiryMonth": "12",
        "expiryYear": "29"
      }
    }

<br />

> [!IMPORTANT]
> **Important:** The signing and encryption of the Google OPC must be done **on your server** to avoid exposing your PGP keys. We also strongly recommend applying the Base64 encoding on your server, so that the encoding logic can be shared between your Android and Web integrations.

The underlying JSON representation of the `GoogleOpaquePaymentCard` is encrypted and signed in accordance with the OpenPGP specification defined in [RFC 4880](https://datatracker.ietf.org/doc/html/rfc4880), and then a non-URL-safe Base64 encoding is applied to the encrypted bytes, in accordance with [RFC 4648, section 4](https://datatracker.ietf.org/doc/html/rfc4648#section-4), with the encoded output being represented as a byte array.

Below is sample Java server code for generating a Google OPC, starting from a`String` that contains the underlying JSON representation. Here, the [java.util.Base64](https://docs.oracle.com/javase/9/docs/api/java/util/Base64.html) class is used to accomplish the Base64 encoding.

<br />


      String googleOpcJson =
          "{"
              + "  \"protocolHeader\": {"
              + "    \"version\": 1"
              + "  },"
              + "  \"validationContext\": {"
              + "    \"serverSessionId\": \"GoogleSession123\""
              + "  },"
              + "  \"paymentCard\": {"
              + "    \"accountNumber\": \"4321123412341234\","
              + "    \"expiryMonth\": \"12\","
              + "    \"expiryYear\": \"29\""
              + "  }"
              + "}";
      byte[] googleOpcSignedAndEncryptedBytes =
          openPgpSignAndEncrypt(
              googleOpcJson, issuerPrivateSigningKey,
              googlePublicEncryptionKey);
      // This Base64 encoded byte array is the final representation of the
      // Google OPC that should be
      // returned to the Android or Web client.
      byte[] googleOpcBase64Bytes =
          Base64.https://docs.oracle.com/javase/9/docs/api/java/util/Base64.html#getEncoder--()
                .https://docs.oracle.com/javase/9/docs/api/java/util/Base64.Encoder.html#encode-byte:A-(googleOpcSignedAndEncryptedBytes);

| JSON representation |
|---|
| ``` { "protocolHeader": { object (`https://developers.google.com/pay/client-side-push-provisioning-v1/google-client-side-push-provisioning-api/GoogleOpaquePaymentCard#ProtocolHeader`) }, "validationContext": { object (`https://developers.google.com/pay/client-side-push-provisioning-v1/google-client-side-push-provisioning-api/GoogleOpaquePaymentCard#ValidationContext`) }, "paymentCard": { object (`https://developers.google.com/pay/client-side-push-provisioning-v1/google-client-side-push-provisioning-api/GoogleOpaquePaymentCard#PaymentCard`) } } ``` |

| Fields ||
|---|---|
| `protocolHeader` | ``object (`https://developers.google.com/pay/client-side-push-provisioning-v1/google-client-side-push-provisioning-api/GoogleOpaquePaymentCard#ProtocolHeader`)`` **REQUIRED**: A header for this message. |
| `validationContext` | ``object (`https://developers.google.com/pay/client-side-push-provisioning-v1/google-client-side-push-provisioning-api/GoogleOpaquePaymentCard#ValidationContext`)`` **REQUIRED**: Context for the push that can be verified. |
| `paymentCard` | ``object (`https://developers.google.com/pay/client-side-push-provisioning-v1/google-client-side-push-provisioning-api/GoogleOpaquePaymentCard#PaymentCard`)`` **REQUIRED**: Payment card details. |

## ProtocolHeader

Header object that includes protocol layer fields.

| JSON representation |
|---|
| ``` { "version": string } ``` |

| Fields ||
|---|---|
| `version` | `string (https://developers.google.com/discovery/v1/type-format format)` **REQUIRED**: The version of the JSON API spec used to construct this Google Opaque Payment Card object. The current version will be provided by Google and will change at Google's discretion, but generally only for major (i.e., breaking) changes. |

## ValidationContext

Fields that allow Google to validate the push is valid in the given context, for example the expected destination. This information will be compared to other unsigned information for consistency.

| JSON representation |
|---|
| ``` { // The following is a list of mutually exclusive fields. At most one of the // fields will be set in a response: "serverSessionId": string // End of mutually exclusive fields. } ``` |

| Fields ||
|---|---|
| **REQUIRED**: The intended "destination" of the push, for validation purposes. Only one destination should be supplied. The following is a list of mutually exclusive fields. At most one of the fields will be set in a response: ||
| `serverSessionId` | `string` A push provisioning session ID in the form of a UUID generated by a Google server. The destination user is implied by the session. |
| End of mutually exclusive fields. ||

## PaymentCard

Description of a payment card account (i.e., credit card, debit card, charge card).

| JSON representation |
|---|
| ``` { "accountNumber": string, "expiryMonth": string, "expiryYear": string } ``` |

| Fields ||
|---|---|
| `accountNumber` | `string` **REQUIRED**: The account number itself (i.e., the FPAN). |
| `expiryMonth` | `string` **REQUIRED** : Expiration month, formatted `MM`. |
| `expiryYear` | `string` **REQUIRED** : Expiration year, formatted `YY`. |