AuthorizationReverse Class
The AuthorizationReverse class processes the IPCAuthorizationReverse method. It allows you to cancel a pre-authorized amount before the funds are captured — essentially releasing the hold on the customer’s card.
Use this when the transaction is no longer needed (e.g., canceled bookings, out-of-stock items, expired pre-auths).
Class Overview
- Namespace:
Mypos\IPC - Located at:
AuthorizationReverse.php - Extends:
Mypos\IPC\Base - Purpose: Reverse an existing authorization and release held funds back to the customer
Method Summary
| Method | Return Type | Description |
|---|---|---|
__construct(Config $cnf) | - | Initializes the object with IPC configuration. |
setOrderID(string $orderID) | AuthorizationReverse | Sets the order ID of the pre-authorization to cancel. |
getOrderID() | string | Returns the order ID. |
setCurrency(string $currency) | AuthorizationReverse | Currency used in the original authorization. |
getCurrency() | string | Returns the set currency. |
setAmount(mixed $amount) | AuthorizationReverse | Amount to reverse (can be full or partial). |
getAmount() | mixed | Returns the amount to be reversed. |
validate() | bool | Checks for missing or invalid fields. |
process() | Response | Sends the reversal request and returns the IPC response. |
Inherited from Base
Provides access to these common SDK utilities:
_addPostParam()_processPost(), _processHtmlPost()getCnf(), setCnf()getOutputFormat(), setOutputFormat()isValidSignature()
Example Usage
use Mypos\IPC\Config;
use Mypos\IPC\AuthorizationReverse;
$config = new Config();
// Set merchant credentials, SID, keys, etc.
$reverse = new AuthorizationReverse($config);
$reverse->setOrderID('AUTH-ORDER-20250410')
->setCurrency('EUR')
->setAmount(50.00); // You can reverse full or partial amount
if ($reverse->validate()) {
$response = $reverse->process();
echo "Authorization successfully reversed.";
} else {
echo "Failed to validate reversal request.";
}
Use cases
Use the AuthorizationReverse class when:
- You want to cancel a previously held amount (partial or full)
- A transaction was voided before capture
- You’re handling expired bookings, inventory issues, or customer cancellations
- You want to maintain compliance with card scheme timeframes for pre-auth reversals