--- title: "Refund a transaction from the PED" url: "https://docs.adyen.com/point-of-sale/classic-library-deprecation/classic-library-integrations/c-library-integration/key-steps-c-library/cancel-or-refund-a-transaction-c-library/refund-a-transaction-from-the-ped-c" source_url: "https://docs.adyen.com/point-of-sale/classic-library-deprecation/classic-library-integrations/c-library-integration/key-steps-c-library/cancel-or-refund-a-transaction-c-library/refund-a-transaction-from-the-ped-c.md" canonical: "https://docs.adyen.com/point-of-sale/classic-library-deprecation/classic-library-integrations/c-library-integration/key-steps-c-library/cancel-or-refund-a-transaction-c-library/refund-a-transaction-from-the-ped-c" last_modified: "2026-05-25T12:55:00+02:00" language: "en" --- # Refund a transaction from the PED [View source](/point-of-sale/classic-library-deprecation/classic-library-integrations/c-library-integration/key-steps-c-library/cancel-or-refund-a-transaction-c-library/refund-a-transaction-from-the-ped-c.md) Cancel or refund a transaction from the terminal transaction list, and receive a receipt on the POS or on the PED. You can only use this cancel or refund method for transactions that: * have been completed on the PED that is receiving the cancel or refund request. * are still within the PED storage – this is currently limited to 100 tenders. ## Implement the callback Implement the callback based on the signature in the **cancel\_or\_refund\_on\_terminal\_extern.h** file and pass this as a parameter of the **cancel\_or\_refund\_on\_terminal\_allocate** call. For more information on how to do this, see [Implement callbacks](/point-of-sale/classic-library-deprecation/classic-library-integrations/c-library-integration/calls-and-callbacks-c-library/implement-callbacks). ## Allocate the request struct Allocates, initializes and returns a `cancel_or_refund_on_terminal_request` struct. Populate the request by performing string duplication. To specify where you want to receive the receipt, use the `handle_receipt` field in the `cancel_or_refund_on_terminal_request` struct:  * To handle and print the receipt on the POS, set the `handle_receipt` field to **true**.  * To have the PED print the receipt, omit the `handle_receipt` field (if the terminal has no printer, the transaction will fail). If you want the data for later use, retain it, or it will be released automatically. | Name | Description | | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `cancel_or_refund_on_terminal_allocate` | Allocates, initializes and returns a `cancel_or_refund_on_terminal_request` struct. Populate the request by performing string duplication.If you want the data for later use, retain it, or it will be released automatically. | ## Call the cancel\_or\_refund\_on\_terminal function Call the `cancel_or_refund_on_terminal` function to cancel or refund a completed transaction from the terminal transaction list. The transaction must have been completed on the PED that is receiving the cancel or refund request, and must be still within the PED storage (this is currently limited to 100 tenders.) ### Parameters | Value | Description | | --------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `cancel_or_refund_on_terminal_request` | Pointer to the `cancel_or_refund_on_terminal_request` struct, this struct contains all the input parameters for this call. | | `cancel_or_refund_on_terminal_response` | Pointer to the callback function in the POS that will be called with the results of the `cancel_or_refund_on_terminal` call | | `echo_struct` | Pointer to a POS defined struct. Returned in the callback. It can be used to share a POS data struct between the call to the library and the callback from the library in response to the call. | ## Handle the callback The `cancel_or_refund_on_terminal_CB` returns the immediate response to the call and a pointer to the POS-defined echo struct. ### Parameters | Value | Description | | --------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `cancel_or_refund_on_terminal_response` | Pointer to the callback function in the POS that will be called with the results of the `cancel_or_refund_on_terminal` call | | `echo_struct` | Pointer to a POS defined struct. Returned in the callback. It can be used to share a POS data struct between the call to the library and the callback from the library in response to the call. |