PreAuthorizationCompletion Class
The PreAuthorizationCompletion class processes the IPCPreAuthorizationCompletion method. It is used to capture (finalize) funds that were previously held via a pre-authorization transaction.
This step moves the funds from the customer’s account into the merchant’s account, completing the payment.
Class Overview
- Namespace:
Mypos\IPC - Located at:
PreAuthorizationCompletion.php - Extends:
Mypos\IPC\Base - Purpose: Capture all or part of the previously authorized amount
Method Summary
| Method | Return Type | Description |
|---|---|---|
__construct(Config $cnf) | - | Initializes the completion object using your IPC config. |
setOrderID(string $orderID) | PreAuthorizationCompletion | Sets the original order ID of the pre-auth transaction. |
getOrderID() | string | Retrieves the pre-auth order ID. |
setCurrency(string $currency) | PreAuthorizationCompletion | Sets the ISO-4217 currency code (e.g., EUR). |
getCurrency() | string | Returns the currency for the transaction. |
setAmount(mixed $amount) | PreAuthorizationCompletion | Amount to capture from the original pre-authorization. |
getAmount() | mixed | Returns the amount to be captured. |
validate() | bool | Checks if all necessary data is correctly set. |
process() | Response | Sends the API request and returns the IPC response object. |
Inherited from Base
Includes common IPC methods:
_addPostParam()_processPost(), _processHtmlPost()getCnf(), setCnf()getOutputFormat(), setOutputFormat()isValidSignature()
Example Usage
use Mypos\IPC\Config;
use Mypos\IPC\PreAuthorizationCompletion;
$config = new Config();
// Set your credentials, SID, wallet number, keys, etc.
$completion = new PreAuthorizationCompletion($config);
$completion->setOrderID('AUTH-20250410-XYZ')
->setCurrency('EUR')
->setAmount(100.00); // Must be ≤ pre-auth amount
if ($completion->validate()) {
$response = $completion->process();
echo "Pre-authorization completed successfully!";
} else {
echo "Missing or invalid completion parameters.";
}
Use cases
Use the PreAuthorizationCompletion class when:
- You want to capture payment after a customer has used a product or service
- You’ve previously authorized funds and now want to collect them
- You support delayed capture workflows, such as hotels, car rentals, or event services
- You want to partially capture funds (less than the pre-authorized amount)