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

MethodReturn TypeDescription
__construct(Config $cnf)-Initializes the cancellation request with IPC config.
setOrderID(string $orderID)PreAuthorizationCancellationSets the original pre-auth order ID (must match the one used during authorization).
getOrderID()stringRetrieves the order ID.
setCurrency(string $currency)PreAuthorizationCancellationSets the 3-letter ISO currency code (e.g., EUR).
getCurrency()stringReturns the currency code.
setAmount(mixed $amount)PreAuthorizationCancellationOptionally specify the amount to cancel (can be partial).
getAmount()mixedReturns the cancellation amount.
validate()boolValidates that all required properties are present.
process()ResponseExecutes 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