/cancel

Cancel pending orders before they are captured by FlexFactor.




Merchant Initiated Transactions (MIT) are sent to FlexFactor for an asynchronous evaluation.

If the customers cancel their subscriptions while they are pending over at FlexFactor, you can cancel them by using the /cancel endpoint.

/cancel behaves like a VOID: it stops a rescue that has not yet been captured, rather than reversing a settled charge. You can cancel:

  • MIT orders in draft, onhold, processing, or capturerequired status — any status that is not completed or cancelled
  • CIT orders in capturerequired or onhold status

To reverse a charge that has already been captured, use /refund instead.

A cancel always applies to the full order amount. There is no partial cancel: the request body carries no amount or currency field, and the only accepted body field is the optional idempotencyKey. To return part of a charge after capture, use /refund with a partial amount.

📌

Void part of an order with /void

To release part of an order before capture, or to void with an explicit amount, use /void.

Cancel names the order in the URL. This differs from /void and /refund, which name the order in the request body. Two endpoints are available, depending on whether you have already received the FlexFactor order ID (orderId, returned by /evaluate alongside orderSessionKey):

  • POST /v1/orders/{id}/cancel — the standard cancellation, used once the FlexFactor orderId is known.
  • POST /v1/orders/{external-order-id}/external-cancel — a standard alternative that identifies the order by your own external order ID, usable at any time. It is especially useful when the FlexFactor order ID was never received (for example, the /evaluate response timed out). See external-cancel below.


❗️

Prerequisites to invoke this API:

📘

Idempotency

Neither /cancel nor /external-cancel requires an idempotencyKey — idempotency is enforced server-side via the order ID, so repeated cancel calls for the same order are safe.

You can include an optional idempotencyKey (a GUID, in the JSON body). When present, a retry within the 24-hour replay window replays the original response, and a reused key with a different payload is rejected as a 409 conflict. Because /external-cancel is keyed by the same underlying order as /cancel, issuing both for one order collapses into a single operation. See the Idempotency reference (§3.4) for the full behavior.



Request

Details

HTTP MethodPOST
Endpoint - Sandboxhttps://api-sandbox.flexfactor.io/v1/orders/{id}/cancel
Endpoint - Productionhttps://api.flexfactor.io/v1/orders/{id}/cancel
{id}FlexFactor unique transaction identifier.\ This is the FlexFactor orderId returned by /evaluate and/or GET /v1/orders/{id} and/or webhook and/or batch response file.
AuthenticationBearer Token

Body

This API doesn't require body parameters. A POST with an empty body ({}) is valid. You can optionally include an idempotencyKey (GUID) to make retries safe — see Idempotency. No other body fields are accepted; there is no amount or currency.



Response

A cancel returns HTTP 200 with a body of two fields. Read success to decide whether the request was processed; a 200 does not by itself prove that the order was cancelled.

successbooleantrue when FlexFactor processed the cancel. It is also true when the order was not in a cancellable status and nothing changed.
responseMessagestringnull on success. Failed to cancel order when the cancel failed.

The cancel response does not use the common FlexFactor envelope: it carries no status, result, statusCode, errors, or customProperties.

❗️

A 200 is returned even when nothing was cancelled

A cancel against an order that is not in a cancellable status (for example completed) also returns HTTP 200 with success: true, and the order is unchanged. Confirm the result with GET /v1/orders/{id} (status cancelled) or the order.cancelled webhook before you treat the order as cancelled.

OutcomeHTTP statusBody
The order is cancelled200success: true
The order was already cancelled, or is not in a cancellable status — nothing changes200Same body
idempotencyKey is not a GUID400Problem details
Invalid or expired bearer token401—
No order matches {id}, or it belongs to another merchant404Problem details
{id} on /cancel is not a GUID404Empty
An idempotent request is still in progress, or the idempotencyKey was reused for a different order409Problem details — see Idempotency §3.4
The cancel failed, for example because the authorization could not be released500success: false and responseMessage Failed to cancel order
An internal error occurred. On /external-cancel, this is also returned when several of your orders share the external order ID500The text Failed to cancel order
Idempotency store temporarily unavailable — honor Retry-After and retry503Problem details

Within 24 hours, a repeat cancel for the same order replays the stored 200 response and does not run the cancel again. This also applies when the first cancel changed nothing. To run a cancel again within the 24 hours, send a new idempotencyKey. A cancel that returned 500 is not stored, so you can repeat it as it is. No webhook fires for a cancel that changed nothing. After a successful cancel, GET /v1/orders/{id} returns status cancelled, and order.cancelled fires when the order status changed and you subscribe to the event. The full transaction state model is in Workflows §3.5.

For the error key and the message of each 400 on /cancel and /external-cancel, see Error Messages: /cancel.



❕

Updating the status order

After receiving a successful response from /cancel, you need to update this order in your CRM with the corresponding status.



Payload examples

Request


curl --request POST \
     --url https://api-sandbox.flexfactor.io/v1/orders/{id}/cancel \
	 	 --header 'Authorization: Bearer {the token returned by /oauth2}' \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{}
'


Response


HTTP/1.1 200 OK
Content-Type: application/json

{
   "success": true,
   "responseMessage": null
}


Cancel by external order ID

external-cancel identifies the order by your own external order ID (the orderId you sent to /evaluate) instead of the FlexFactor order ID returned in the response. It is a routine cancel path you can use at any time an order is cancellable — and it is especially useful when the FlexFactor order ID was never received, for example when the /evaluate response timed out.

Request

Details

HTTP MethodPOST
Endpoint - Sandboxhttps://api-sandbox.flexfactor.io/v1/orders/{external-order-id}/external-cancel
Endpoint - Productionhttps://api.flexfactor.io/v1/orders/{external-order-id}/external-cancel
{external-order-id}Your own external order ID — the orderId you sent in the original /evaluate request.
AuthenticationBearer Token

Body

This API doesn't require body parameters.

Response

Same as /cancel: HTTP 200 with the same body, including when nothing was cancelled — see Response above. If several of your orders share the external order ID, the call returns 500; cancel by the FlexFactor orderId instead.

Payload examples

Request

curl --request POST \
     --url https://api-sandbox.flexfactor.io/v1/orders/{external-order-id}/external-cancel  //insert the orderId you sent to /evaluate
     --header 'Authorization: Bearer {the token returned by /oauth2}' \
     --header 'accept: application/json'

The request body is empty.

Response

HTTP/1.1 200 OK
Content-Type: application/json

{
   "success": true,
   "responseMessage": null
}

Did this page help you?