- [HTTP request](https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/cancelReferenceNumber#body.HTTP_TEMPLATE)
- [Request body](https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/cancelReferenceNumber#body.request_body)
  - [JSON representation](https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/cancelReferenceNumber#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/cancelReferenceNumber#body.response_body)
- [CancelReferenceNumberResponse](https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/cancelReferenceNumber#CancelReferenceNumberResponse)
  - [JSON representation](https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/cancelReferenceNumber#CancelReferenceNumberResponse.SCHEMA_REPRESENTATION)
- [CancelReferenceNumberResult](https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/cancelReferenceNumber#CancelReferenceNumberResult)
  - [JSON representation](https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/cancelReferenceNumber#CancelReferenceNumberResult.SCHEMA_REPRESENTATION)

Cancels a reference number by invalidating it in the integrators system and preventing future payments.

Only a reference number that was previously created by calling [generateReferenceNumber](https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/generateReferenceNumber) is subject to cancellation.

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 requests looks like:


    {
      "requestHeader": {
        "protocolVersion": {
          "major": 2
        },
        "requestId": "cmVxdWVzdDE",
        "requestTimestamp": {
          "epochMillis": "1481899949606"
        },
        "paymentIntegratorAccountId": "InvisiCashUSA_USD"
      },
      "generateReferenceNumberRequestId": "aW50ZWdyYXRvciB0cmFuc2FjdGlvbiBpZA"
    }

An example response looks like:


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

### HTTP request

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

### 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`) }, "generateReferenceNumberRequestId": string } ``` |

| 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. |
| `generateReferenceNumberRequestId` | `string` **REQUIRED** : `requestId` of the `generateReferenceNumber` which generated the number to be cancelled. |

### 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/cancelReferenceNumber#CancelReferenceNumberResponse`)`` |
| 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. ||

## CancelReferenceNumberResponse

Response object for the `cancelReferenceNumber` 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/cancelReferenceNumber#CancelReferenceNumberResult`) } } ``` |

| 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/cancelReferenceNumber#CancelReferenceNumberResult`)`` **REQUIRED** : The result of this `cancelReferenceNumber` call. |

## CancelReferenceNumberResult

Result of this `cancelReferenceNumber` call.

| 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`) }, "referenceNumberAlreadyPaid": { object (`https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/Empty`) } // End of mutually exclusive fields. } ``` |

| Fields ||
|---|---|
| **REQUIRED** : Result of this `cancelReferenceNumber` call. 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`)`` Reference number successfully cancelled. |
| `referenceNumberAlreadyPaid` | ``object (`https://developers.google.com/pay/refundable-one-time-payment-code-v2/payment-integrator-refundable-one-time-payment-code-api/Empty`)`` Reference number has already been paid. Google should expect a call to `referenceNumberPaidNotification` for this reference number soon. |
| End of mutually exclusive fields. ||