- [HTTP request](https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/refund#body.HTTP_TEMPLATE)
- [Request body](https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/refund#body.request_body)
  - [JSON representation](https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/refund#body.request_body.SCHEMA_REPRESENTATION)
- [Response body](https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/refund#body.response_body)
- [RefundResponse](https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/refund#RefundResponse)
  - [JSON representation](https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/refund#RefundResponse.SCHEMA_REPRESENTATION)
- [RefundResult](https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/refund#RefundResult)
  - [JSON representation](https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/refund#RefundResult.SCHEMA_REPRESENTATION)
- [AccountClosedAccountTakenOver](https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/refund#AccountClosedAccountTakenOver)
  - [JSON representation](https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/refund#AccountClosedAccountTakenOver.SCHEMA_REPRESENTATION)
- [AccountClosedFraud](https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/refund#AccountClosedFraud)
  - [JSON representation](https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/refund#AccountClosedFraud.SCHEMA_REPRESENTATION)
- [AccountOnHold](https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/refund#AccountOnHold)
  - [JSON representation](https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/refund#AccountOnHold.SCHEMA_REPRESENTATION)
- [RefundExceedsMaximumBalance](https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/refund#RefundExceedsMaximumBalance)
  - [JSON representation](https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/refund#RefundExceedsMaximumBalance.SCHEMA_REPRESENTATION)
- [RefundWindowExceeded](https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/refund#RefundWindowExceeded)
  - [JSON representation](https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/refund#RefundWindowExceeded.SCHEMA_REPRESENTATION)

Refunds a portion of or the entire transaction initiated through `capture`. The `requestId` within the header is the idempotency key, which uniquely identifies this transaction.

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/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/ErrorResponse`.

An example request looks like:


    {
      "requestHeader": {
        "protocolVersion": {
          "major": 2
        },
        "requestId": "liUrreQY233839dfFFb24gaQM",
        "requestTimestamp": {
          "epochMillis": "1502220434778"
        },
        "paymentIntegratorAccountId": "InvisiCashUSA_USD"
      },
      "transactionId": "bWVyY2hhbnQgdHJhbnNhY3Rpb24gaWQ",
      "refundAmount": {
        "amountMicros": "208000000",
        "currencyCode": "INR"
      }
    }

An example response looks like:


    {
      "responseHeader": {
        "responseTimestamp": {
          "epochMillis": "1481900013178"
        }
      },
      "result": {
        "success": {}
      }
    }

### HTTP request

`POST https://www.integratorhost.example.com/integrator-base-path/refundable-one-time-payment-code-v2/refund`

### Request body

The request body contains data with the following structure:

| JSON representation |
|---|
| ``` { "requestHeader": { object (`https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/RequestHeader`) }, "transactionId": string, "refundAmount": { object (`https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/Amount`) } } ``` |

| Fields ||
|---|---|
| `requestHeader` | ``object (`https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/RequestHeader`)`` **REQUIRED**: Common header for all requests. |
| `transactionId` | `string` **REQUIRED** : A unique identifier for this transaction. This is a `requestId` generated by Google. The call during which this `requestId` is generated will depend on the buy flow. |
| `refundAmount` | ``object (`https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/Amount`)`` **REQUIRED**: The amount of the refund. Must be a positive number. |

### 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/refundable-one-time-payment-code-v2/guides/connectivity/protocol-standards#http_status_codes).

| Possible response messages ||
|---|---|
| HTTP 200 Status | ``object (`https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/refund#RefundResponse`)`` |
| HTTP 4XX / 5XX Status | ``object (`https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/ErrorResponse`)`` |
| End of mutually exclusive fields. ||

## RefundResponse

Response object for the refund method.

| JSON representation |
|---|
| ``` { "responseHeader": { object (`https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/ResponseHeader`) }, "result": { object (`https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/refund#RefundResult`) } } ``` |

| Fields ||
|---|---|
| `responseHeader` | ``object (`https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/ResponseHeader`)`` **REQUIRED**: Common header for all responses. |
| `result` | ``object (`https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/refund#RefundResult`)`` **REQUIRED**: Result of this refund. |

## RefundResult

Result codes for refunds.

| JSON representation |
|---|
| ``` { // The following is a list of mutually exclusive fields. At most one of the // fields will be set in a response: "success": { object (`https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/Empty`) }, "accountClosed": { object (`https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/AccountClosed`) }, "accountClosedAccountTakenOver": { object (`https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/refund#AccountClosedAccountTakenOver`) }, "accountClosedFraud": { object (`https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/refund#AccountClosedFraud`) }, "accountOnHold": { object (`https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/refund#AccountOnHold`) }, "refundExceedsMaximumBalance": { object (`https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/refund#RefundExceedsMaximumBalance`) }, "refundWindowExceeded": { object (`https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/refund#RefundWindowExceeded`) } // End of mutually exclusive fields. } ``` |

| Fields ||
|---|---|
| **REQUIRED**: The result of the refund. The following is a list of mutually exclusive fields. At most one of the fields will be set in a response: ||
| `success` | ``object (`https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/Empty`)`` Successful refund. |
| `accountClosed` | ``object (`https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/AccountClosed`)`` The account held with the integrator has been closed. Returning this value will cause the user's instrument to be closed with Google. The user will be forced to add a new instrument by going through the association flow again. |
| `accountClosedAccountTakenOver` | ``object (`https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/refund#AccountClosedAccountTakenOver`)`` The user's account with the integrator has been closed, suspected account take over. Returning this value will cause the user's instrument to be closed with Google. The user will be forced to add a new instrument by going through the association flow again. |
| `accountClosedFraud` | ``object (`https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/refund#AccountClosedFraud`)`` The user's account held with the integrator has been closed because of fraud. Returning this value will cause the user's instrument to be closed with Google. The user will be forced to add a new instrument by going through the association flow again. |
| `accountOnHold` | ``object (`https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/refund#AccountOnHold`)`` The user's account is currently on hold and cannot accept the refund, but the user's account may later be able to accept the refund. Google may request another refund in the future, but will do so with a new `requestId`, so this request should be considered finished. |
| `refundExceedsMaximumBalance` | ``object (`https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/refund#RefundExceedsMaximumBalance`)`` The refund cannot be processed at the current time, because doing so would cause the user's balance to exceed the maximum allowed amount. Google may request another refund in the future, but will do so with a new `requestId`, so this request should be considered finished. |
| `refundWindowExceeded` | ``object (`https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/refund#RefundWindowExceeded`)`` The refund cannot be processed because the request is outside of the allowed refund period. |
| End of mutually exclusive fields. ||

## AccountClosedAccountTakenOver

The user's account with the integrator has been closed, suspected account take over.

| JSON representation |
|---|
| ``` { "rawResult": { object (`https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/RawResult`) } } ``` |

| Fields ||
|---|---|
| `rawResult` | ``object (`https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/RawResult`)`` **OPTIONAL** : Raw result of this event. Used to help inform Google's risk engine and analytics. In decline code--mapping situations, data is sometimes lost. The integrator can choose to give Google a raw code. For example, a credit card gateway (the integrator) may use this field to communicate to Google the exact decline code that was received from the VISA network. In that case, the `scope` would be "visa" and the `rawCode` would be whatever the VISA network returned. |

## AccountClosedFraud

The user's account held with the integrator has been closed because of fraud.

| JSON representation |
|---|
| ``` { "rawResult": { object (`https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/RawResult`) } } ``` |

| Fields ||
|---|---|
| `rawResult` | ``object (`https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/RawResult`)`` **OPTIONAL** : Raw result of this event. Used to help inform Google's risk engine and analytics. In decline code--mapping situations, data is sometimes lost. The integrator can choose to give Google a raw code. For example, a credit card gateway (the integrator) may use this field to communicate to Google the exact decline code that was received from the VISA network. In that case, the `scope` would be "visa" and the `rawCode` would be whatever the VISA network returned. |

## AccountOnHold

The account is on hold.

| JSON representation |
|---|
| ``` { "rawResult": { object (`https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/RawResult`) } } ``` |

| Fields ||
|---|---|
| `rawResult` | ``object (`https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/RawResult`)`` **OPTIONAL** : Raw result of this event. Used to help inform Google's risk engine and analytics. In decline code--mapping situations, data is sometimes lost. The integrator can choose to give Google a raw code. For example, a credit card gateway (the integrator) may use this field to communicate to Google the exact decline code that was received from the VISA network. In that case, the `scope` would be "visa" and the `rawCode` would be whatever the VISA network returned. |

## RefundExceedsMaximumBalance

The refund cannot be processed at the current time, because doing so would cause the user's balance to exceed the maximum allowed amount. Google may request another refund in the future, but will do so with a new `requestId`, so this request should be considered finished.

| JSON representation |
|---|
| ``` { "rawResult": { object (`https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/RawResult`) } } ``` |

| Fields ||
|---|---|
| `rawResult` | ``object (`https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/RawResult`)`` **OPTIONAL** : Raw result of this event. Used to help inform Google's risk engine and analytics. In decline code--mapping situations, data is sometimes lost. The integrator can choose to give Google a raw code. For example, a credit card gateway (the integrator) may use this field to communicate to Google the exact decline code that was received from the VISA network. In that case, the `scope` would be "visa" and the `rawCode` would be whatever the VISA network returned. |

## RefundWindowExceeded

The refund cannot be processed because the request is outside of the allowed refund period.

| JSON representation |
|---|
| ``` { "rawResult": { object (`https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/RawResult`) } } ``` |

| Fields ||
|---|---|
| `rawResult` | ``object (`https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/RawResult`)`` **OPTIONAL** : Raw result of this event. Used to help inform Google's risk engine and analytics. In decline code--mapping situations, data is sometimes lost. The integrator can choose to give Google a raw code. For example, a credit card gateway (the integrator) may use this field to communicate to Google the exact decline code that was received from the VISA network. In that case, the `scope` would be "visa" and the `rawCode` would be whatever the VISA network returned. |