PreAuthorizationCancellation Class
The PreAuthorizationCancellation class handles the IPCPreAuthorizationCancellation method. It allows merchants to cancel a previously initiated pre-authorization, releasing any held funds back to the customer’s account.
Useful when the reserved amount is no longer needed—e.g., for cancellations, failed bookings, or unused services.
Class Overview
- Namespace:
Mypos\IPC - Located at:
PreAuthorizationCancellation.php - Extends:
Mypos\IPC\Base - Purpose: Cancel or void an active pre-authorization before the funds are captured
Method Summary
| Method | Return Type | Description |
|---|---|---|
__construct(Config $cnf) | - | Initializes the cancellation request with IPC config. |
setOrderID(string $orderID) | PreAuthorizationCancellation | Sets the original pre-auth order ID (must match the one used during authorization). |
getOrderID() | string | Retrieves the order ID. |
setCurrency(string $currency) | PreAuthorizationCancellation | Sets the 3-letter ISO currency code (e.g., EUR). |
getCurrency() | string | Returns the currency code. |
setAmount(mixed $amount) | PreAuthorizationCancellation | Optionally specify the amount to cancel (can be partial). |
getAmount() | mixed | Returns the cancellation amount. |
validate() | bool | Validates that all required properties are present. |
process() | Response | Executes the cancellation API call and returns a response object. |
Example Usage
use Mypos\IPC\Config;
use Mypos\IPC\PreAuthorizationCancellation;
$config = new Config();
// Set credentials, SID, wallet, API keys...
$cancellation = new PreAuthorizationCancellation($config);
$cancellation->setOrderID('AUTH-20250410-XYZ')
->setCurrency('EUR')
->setAmount(100.00); // Optional: can cancel full or partial
if ($cancellation->validate()) {
$response = $cancellation->process();
echo "Pre-authorization canceled successfully!";
} else {
echo "Validation failed. Check Order ID and amount.";
}
Inherited from Base
Includes access to utility methods:
_addPostParam()_processPost(), _processHtmlPost()getCnf(), setCnf()getOutputFormat(), setOutputFormat()isValidSignature()
Use cases
Use the PreAuthorizationCancellation class when:
- You need to void a pending pre-authorization
- The customer canceled their reservation or booking
- The reserved amount is no longer needed and should be released
- You want to ensure better user experience by not holding funds longer than necessary