- [HTTP request](https://developers.google.com/pay/value-on-device-fop-v1/payment-integrator-value-on-device-fop-api/generateDeviceCaptureToken#body.HTTP_TEMPLATE)
- [Request body](https://developers.google.com/pay/value-on-device-fop-v1/payment-integrator-value-on-device-fop-api/generateDeviceCaptureToken#body.request_body)
  - [JSON representation](https://developers.google.com/pay/value-on-device-fop-v1/payment-integrator-value-on-device-fop-api/generateDeviceCaptureToken#body.request_body.SCHEMA_REPRESENTATION)
- [Response body](https://developers.google.com/pay/value-on-device-fop-v1/payment-integrator-value-on-device-fop-api/generateDeviceCaptureToken#body.response_body)
- [GenerateDeviceCaptureTokenResponse](https://developers.google.com/pay/value-on-device-fop-v1/payment-integrator-value-on-device-fop-api/generateDeviceCaptureToken#GenerateDeviceCaptureTokenResponse)
  - [JSON representation](https://developers.google.com/pay/value-on-device-fop-v1/payment-integrator-value-on-device-fop-api/generateDeviceCaptureToken#GenerateDeviceCaptureTokenResponse.SCHEMA_REPRESENTATION)
- [GenerateDeviceCaptureTokenResult](https://developers.google.com/pay/value-on-device-fop-v1/payment-integrator-value-on-device-fop-api/generateDeviceCaptureToken#GenerateDeviceCaptureTokenResult)
  - [JSON representation](https://developers.google.com/pay/value-on-device-fop-v1/payment-integrator-value-on-device-fop-api/generateDeviceCaptureToken#GenerateDeviceCaptureTokenResult.SCHEMA_REPRESENTATION)
- [GenerateDeviceCaptureTokenResultCode](https://developers.google.com/pay/value-on-device-fop-v1/payment-integrator-value-on-device-fop-api/generateDeviceCaptureToken#GenerateDeviceCaptureTokenResultCode)

Requests a token from the integrator that can be executed on the user's device in order to debit the device's stored value. The combination of `requestId` within the header and `paymentIntegratorAccountId` is the idempotency key and uniquely identifies this transaction. All mutations on this transaction (refunds) populate the `requestId` value in the `captureRequestId` field.

If the endpoint encounters an error while processing the request, the response body from this endpoint should be of type `https://developers.google.com/pay/value-on-device-fop-v1/payment-integrator-value-on-device-fop-api/ErrorResponse`.

An example request looks like:


    {
      "requestHeader": {
        "protocolVersion": {
          "major": 1,
          "minor": 1,
          "revision": 0
        },
        "requestId": "bWVyY2hhbnQgdHJhbnNhY3Rpb24gaWQ",
        "requestTimestamp": "1502220196077"
      },
      "paymentIntegratorAccountId": "InvisiCashUSA_USD",
      "transactionDescription": "Google - Music",
      "currencyCode": "JPY",
      "amount": "545000000",
      "deviceIdentifier": "FC199014344145",
      "instanceIdentifier": "ID15626388286838485",
      "sessionIdentifier": "5226453",
      "balance": "16000000"
    }

An example response looks like:


    {
      "responseHeader": {
        "responseTimestamp": "1481900013178"
      },
      "result": {
         "generateDeviceCaptureTokenResultCode": "SUCCESS"
      },
      "paymentIntegratorTransactionId": "aW50ZWdyYXRvciB0cmFuc2FjdGlvbiBpZA",
      "deviceCaptureToken": "WW91IHN1cmUgYXJlIGN1cmlvdXMsIGFyZW4ndCB5b3U/"
    }

### HTTP request

`POST https://www.integratorhost.example.com/integrator-base-path/value-on-device-fop-v1/generateDeviceCaptureToken`

### Request body

The request body contains data with the following structure:

| JSON representation |
|---|
| ``` { "requestHeader": { object (`https://developers.google.com/pay/value-on-device-fop-v1/payment-integrator-value-on-device-fop-api/RequestHeader`) }, "paymentIntegratorAccountId": string, "currencyCode": string, "amount": string, "transactionDescription": string, "deviceIdentifier": string, "instanceIdentifier": string, "sessionIdentifier": string, "balance": string } ``` |

| Fields ||
|---|---|
| `requestHeader` | ``object (`https://developers.google.com/pay/value-on-device-fop-v1/payment-integrator-value-on-device-fop-api/RequestHeader`)`` **REQUIRED**: Common header for all requests. |
| `paymentIntegratorAccountId` | `string` **REQUIRED**: This is the payment integrator account identifier that identifies contractual constraints around this transaction. |
| `currencyCode` | `string` **REQUIRED**: ISO 4217 3-letter currency code |
| `amount` | `string (https://developers.google.com/discovery/v1/type-format format)` **REQUIRED** : The amount of the purchase, in [micros](https://developers.google.com/pay/value-on-device-fop-v1/reference/glossary#micros "What are micros?") of the currency unit. |
| `transactionDescription` | `string` **REQUIRED** : This is the description of the transaction that can be put on the customer's statement. Localized to the userLocale found in the `requestHeader`. This format can be changed without notice and must never be parsed. |
| `deviceIdentifier` | `string` **REQUIRED**: Identifies the device this token should be built for. This is a hardware identifier. |
| `instanceIdentifier` | `string` **REQUIRED**: Identifies the eMoney card instance this token should be built for. |
| `sessionIdentifier` | `string` **OPTIONAL**: An identifier for this particular transaction or session that we are executing on the Secure Element. |
| `balance` | `string (https://developers.google.com/discovery/v1/type-format format)` **OPTIONAL** : The current balance on the Secure Element, in [micros](https://developers.google.com/pay/value-on-device-fop-v1/reference/glossary#micros "What are micros?") of the currency unit. |

### Response body

This method supports multiple return types. For additional information about what 4XX or 5XX HTTP status code to return with an `ErrorResponse`, consult the `ErrorResponse` object and [HTTP status codes documentation](https://developers.google.com/pay/value-on-device-fop-v1/guides/connectivity/protocol-standards#http_status_codes).

| Possible response messages ||
|---|---|
| HTTP 200 Status | ``object (`https://developers.google.com/pay/value-on-device-fop-v1/payment-integrator-value-on-device-fop-api/generateDeviceCaptureToken#GenerateDeviceCaptureTokenResponse`)`` |
| HTTP 4XX / 5XX Status | ``object (`https://developers.google.com/pay/value-on-device-fop-v1/payment-integrator-value-on-device-fop-api/ErrorResponse`)`` |
| End of mutually exclusive fields. ||

## GenerateDeviceCaptureTokenResponse

Response object for the generateDeviceCaptureToken method.

| JSON representation |
|---|
| ``` { "responseHeader": { object (`https://developers.google.com/pay/value-on-device-fop-v1/payment-integrator-value-on-device-fop-api/ResponseHeader`) }, "paymentIntegratorTransactionId": string, "deviceCaptureToken": string, "result": { object (`https://developers.google.com/pay/value-on-device-fop-v1/payment-integrator-value-on-device-fop-api/generateDeviceCaptureToken#GenerateDeviceCaptureTokenResult`) } } ``` |

| Fields ||
|---|---|
| `responseHeader` | ``object (`https://developers.google.com/pay/value-on-device-fop-v1/payment-integrator-value-on-device-fop-api/ResponseHeader`)`` **REQUIRED**: Common header for all responses. |
| `paymentIntegratorTransactionId` | `string` **OPTIONAL**: This identifier is specific to the integrator and is generated by the integrator. This is the identifier that the integrator knows this transaction by. For convenience, this identifier is included with in the remittance details |
| `deviceCaptureToken` | `string` **OPTIONAL**: Token to be presented to the device to trigger a capture completion. This value is **required** if the `result` is `SUCCESS` and should not be set if the result is anything other than `SUCCESS`. |
| `result` | ``object (`https://developers.google.com/pay/value-on-device-fop-v1/payment-integrator-value-on-device-fop-api/generateDeviceCaptureToken#GenerateDeviceCaptureTokenResult`)`` **REQUIRED**: The result of the generate device capture token call. The non-success result codes indicate that there is no need to attempt a device capture since it is guaranteed to be declined based on the state of the user's account and this transactions details. |

## GenerateDeviceCaptureTokenResult

Information about the result of generating a device capture token.

| JSON representation |
|---|
| ``` { "generateDeviceCaptureTokenResultCode": enum (`https://developers.google.com/pay/value-on-device-fop-v1/payment-integrator-value-on-device-fop-api/generateDeviceCaptureToken#GenerateDeviceCaptureTokenResultCode`), // The following is a list of mutually exclusive fields. At most one of the // fields will be set in a response: "transactionMaxLimit": string, "transactionMinLimit": string // End of mutually exclusive fields. } ``` |

| Fields ||
|---|---|
| `generateDeviceCaptureTokenResultCode` | ``enum (`https://developers.google.com/pay/value-on-device-fop-v1/payment-integrator-value-on-device-fop-api/generateDeviceCaptureToken#GenerateDeviceCaptureTokenResultCode`)`` **REQUIRED**: Result code of this generate device capture token call. |
| **OPTIONAL**: Additional details for a failure when generating the device capture token. The following is a list of mutually exclusive fields. At most one of the fields will be set in a response: ||
| `transactionMaxLimit` | `string (https://developers.google.com/discovery/v1/type-format format)` If `generateDeviceCaptureTokenResultCode` is `CHARGE_EXCEEDS_TRANSACTION_LIMIT` then this is the value of the maximum allowable transaction. This is used for structured, user facing messaging and decline rate analysis. This amount is micros/[micros](https://developers.google.com/pay/value-on-device-fop-v1/reference/glossary#micros "What are micros?") of the same `currencyCode` as the original `generateDeviceCaptureToken` method call. |
| `transactionMinLimit` | `string (https://developers.google.com/discovery/v1/type-format format)` If `generateDeviceCaptureTokenResultCode` is `CHARGE_UNDER_TRANSACTION_LIMIT` then this is the value of the minimum allowable transaction. This is used for structured, user facing messaging and decline rate analysis. This amount is micros/[micros](https://developers.google.com/pay/value-on-device-fop-v1/reference/glossary#micros "What are micros?") of the same `currencyCode` as the original `generateDeviceCaptureToken` method call. |
| End of mutually exclusive fields. ||

## GenerateDeviceCaptureTokenResultCode

Result codes for generating a device capture token.

| Enums ||
|---|---|
| `UNKNOWN_RESULT` | Do not ever set this default value! |
| `SUCCESS` | Device capture token generated successfully. |
| `CHARGE_UNDER_TRANSACTION_LIMIT` | Requested device capture amount does not meet the integrator's minimum per-transaction amount. If this code is used, populate the `transactionMinLimit` field with the minimum transaction amount for user messaging purposes. |
| `CHARGE_EXCEEDS_TRANSACTION_LIMIT` | Requested device capture amount exceeds the integrator's maximum per-transaction limit. If this code is used, populate the `transactionMaxLimit` field with the transaction limit for user messaging purposes. |
| `CHARGE_EXCEEDS_DAILY_LIMIT` | User's account cannot be used for purchases right now as it has exceeded its daily limit. If this code is used, do NOT set `transactionMinLimit` or `transactionMaxLimit`. Google does not look at those fields for this case. |
| `CHARGE_EXCEEDS_MONTHLY_LIMIT` | User's account cannot be used for purchases right now as it has exceeded its monthly limit. If this code is used, do NOT set `transactionMinLimit` or `transactionMaxLimit`. Google does not look at those fields for this case. |
| `ACCOUNT_CLOSED` | User's account held with the integrator has been closed. This return value will cause the user's instrument to be closed with Google. The user will be forced to add a new instrument. |
| `ACCOUNT_CLOSED_ACCOUNT_TAKEN_OVER` | User's account with the integrator has been closed, suspected account take over. This return value will cause the user's instrument to be closed with Google. The user will be forced to add a new instrument. |
| `ACCOUNT_CLOSED_FRAUD` | User's account held with the integrator has been closed because of fraud. This return value will cause the user's instrument to be closed with Google. The user will be forced to add a new instrument. |
| `ACCOUNT_ON_HOLD` | User's account is on hold. |
| `INSUFFICIENT_FUNDS` | This account does not have sufficient funds to guarantee this capture. |