Capture or Cancel a Charge

The /capture and /cancel API calls are only relevant to the Authorise and Capture flow.

Once you have determined that the customer order is ready to ship, you must capture the funds for the order. If there is an issue of any kind that prevents the order being fulfilled, the authorisation can instead be cancelled.

This flow also supports partial capture if:

  • Only a part of the order can be fulfilled
  • There are multiple items for the order that will be shipped at different times

Capture

This API call will contain:

  • The amount to be captured

This /capture API call should be made from your server and not directly from the client front end.

sequenceDiagram actor Customer Order Management->>Server: Order selected for shipping Server->>Twisto: POST<br/>/charges/{id}/capture Twisto->>Server: Return Charge<br/>with status 'captured' Server->>Order Management: Return Charge success Order Management->>Customer: Notify customer payment<br/>has been completed<br/>and goods are shipped

Request

The charge Id returned in your original /charges API call will be passed in the capture API endpoint to identify the charge being captured. For example:

https://api.twisto.cz/psp/smi/charges/chargeId/capture

Here is an example of how this information can be passed:

{ "amount": 300 }

There is no option for partial capture. If needed, use full capture and partial refund afterwards.

Cancel

If an order can not be fulfilled in its entirety, a /cancel API call should be made to free up the customer funds.

This API call will contain no request body.

This /cancel API call should be made from your server and not directly from the client front end.

sequenceDiagram actor Customer Order Management->>Server: Order selected for cancellation Server->>Twisto: POST<br/>/charges/{id}/cancel Twisto->>Server: Return Charge<br/>with status 'cancelled' Server->>Order Management: Return Cancel success Order Management->>Customer: Notify customer payment<br/>has been cancelled<br/>and funds are released

Request

The charge Id returned in your original /charges API call will be passed in the cancel API endpoint to identify the charge being captured. For example:

https://api.twisto.cz/psp/smi/charges/chargeId/cancel