PreAuthorization Class

The PreAuthorization class processes the IPCPreAuthorization method. It allows merchants to authorize a payment amount on a customer’s card without immediately capturing the funds.

This is useful for hotel bookings, rental services, or security deposits, where the final charge might vary or occur later.

Class Overview

  • Namespace: Mypos\IPC
  • Located at: PreAuthorization.php
  • Extends: Mypos\IPC\Base
  • Purpose: Initiates a pre-authorization transaction, holds funds on the customer’s card, and allows later capture or cancellation.

Method Summary

MethodReturn TypeDescription
__construct(Config $cnf)-Initializes the object with IPC configuration.
setOrderID(string $orderID)PreAuthorizationSets a unique order ID for this pre-auth.
getOrderID()stringRetrieves the order ID.
setItemName(string $itemName)PreAuthorizationOptional: name of the item/service.
getItemName()stringReturns the item name.
setAmount(float $amount)PreAuthorizationTotal amount to be authorized (not captured).
getAmount()floatRetrieves the amount.
setCurrency(string $currency)PreAuthorizationSets ISO 4217 currency code (e.g., EUR).
getCurrency()stringGets the currency used.
setNote(string $note)PreAuthorizationOptional note or description for the transaction.
getNote()stringReturns the note.
setUrlOk(string $url)PreAuthorizationURL to redirect after successful authorization.
getUrlOk()stringGets success redirect URL.
setUrlCancel(string $url)PreAuthorizationURL to redirect if customer cancels or fails authorization.
getUrlCancel()stringGets cancellation URL.
setUrlNotify(string $url)PreAuthorizationWebhook for server-to-server notifications.
getUrlNotify()stringGets notify URL.
validate()boolValidates that all required parameters are set.
process()boolSends the API request and initiates the pre-auth.

Inherited from Base

Includes all core communication tools:

  • _addPostParam() * _processPost(), _processHtmlPost()
  • getCnf(), setCnf()
  • getOutputFormat(), setOutputFormat()
  • isValidSignature()

Example Usage

use Mypos\IPC\Config;
use Mypos\IPC\PreAuthorization;

$config = new Config();
// Set SID, wallet, API keys, etc.

$preAuth = new PreAuthorization($config);
$preAuth->setOrderID('AUTH-20250410-XYZ')
        ->setAmount(150.00)
        ->setCurrency('EUR')
        ->setItemName('Hotel Booking')
        ->setNote('Reservation for April 20-22')
        ->setUrlOk('https://merchant.com/success')
        ->setUrlCancel('https://merchant.com/cancel')
        ->setUrlNotify('https://merchant.com/notify');

if ($preAuth->validate()) {
    $preAuth->process(); // Customer redirected to myPOS pre-auth page
} else {
    echo "Validation failed. Please check required fields.";
}

Use Cases

Use the PreAuthorization class when you:

  • Need to reserve funds without charging the customer immediately
  • Want to capture payment later after service is confirmed
  • Provide physical goods, bookings, rentals, or event holds
  • Require PCI-DSS compliant handling via redirect-based flow