/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.

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 may 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 the common FlexFactor envelope, the same shape that /void returns. Read success to decide whether the request was processed; a 200 does not by itself prove that the order was cancelled.

successbooleantrue when errors is empty.
statusstringNot meaningful on this endpoint; null in current responses. Read success.
resultstringDo not use it.
responseCodestringProcessor response code when the cancel failed. null on success. Optional
responseMessagestringProcessor response message when the cancel failed. null on success. Optional
statusCodestringIt is not the HTTP status code. Do not use it.
errorsarray of objectsError details for a failed cancel; empty on success. Each item is serialized positionally: item1 message, item2 key, item3 error code, item4 friendly flag (boolean).
customPropertiesobjectAdditional custom properties for the API request Optional
❗️

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 cancelled200Envelope with success: true
The order was already cancelled, or is not in a cancellable status — nothing changes200Same body
No order matches {id}, or it belongs to another merchant404Problem details
An idempotent request is still in progress, or the idempotencyKey was reused with a different payload409Problem details — see Idempotency §3.4
Invalid or expired bearer token401—
The cancel failed, or an internal error occurred500Envelope with success: false and responseMessage, for example 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. 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.



❕

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 \	//insert the orderId returned by the response to /evaluate
	 	 --header 'Authorization: Bearer abc123def456' \	//replace with bearer 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,
   "status": null,
   "result": null,
   "responseCode": null,
   "responseMessage": null,
   "statusCode": null,
   "errors": [],
   "customProperties": {}
}


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 envelope, including when nothing was cancelled — see Response above.

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 abc123def456' \  //replace with bearer returned by /oauth2
     --header 'accept: application/json'

The request body is empty.

Response

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

{
   "success": true,
   "status": null,
   "result": null,
   "responseCode": null,
   "responseMessage": null,
   "statusCode": null,
   "errors": [],
   "customProperties": {}
}

Did this page help you?