AuthorizationCapture Class
The AuthorizationCapture class handles the IPCAuthorizationCapture method. It allows you to capture funds that were previously authorized using a direct card authorization (Authorization class).
This is the final step in a two-phase transaction. You authorize first to hold funds, and then capture when you're ready to complete the charge.
Class Overview
- Namespace:
Mypos\IPC - Located at:
AuthorizationCapture.php - Extends:
Mypos\IPC\Base - Purpose: Finalize and capture funds from a prior authorization
Method Summary
| Method | Return Type | Description |
|---|---|---|
__construct(Config $cnf) | - | Initializes the capture object with IPC configuration. |
setOrderID(string $orderID) | AuthorizationCapture | Sets the same order ID used during authorization. |
getOrderID() | string | Returns the authorization order ID. |
setAmount(mixed $amount) | AuthorizationCapture | The amount to capture (must be ≤ authorized amount). |
getAmount() | mixed | Returns the capture amount. |
setCurrency(string $currency) | AuthorizationCapture | Currency of the transaction (e.g., EUR). |
getCurrency() | string | Returns the set currency. |
validate() | bool | Ensures required fields are set correctly. |
process() | Response | Sends the request to capture the funds and returns the IPC response object. |
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\AuthorizationCapture;
$config = new Config();
// Setup SID, Wallet number, API keys, etc.
$capture = new AuthorizationCapture($config);
$capture->setOrderID('AUTH-20250410-XYZ')
->setCurrency('EUR')
->setAmount(100.00); // Must be less than or equal to originally authorized amount
if ($capture->validate()) {
$response = $capture->process();
echo "Funds captured successfully!";
} else {
echo "Validation failed. Check Order ID, amount, or currency.";
}
Use cases
Use the AuthorizationCapture class when:
- You’ve already authorized a payment using the
Authorizationclass - You want to capture the funds after a successful delivery, booking, or confirmation
- You support delayed charges or staged payments
- You want to finalize only part of the amount originally authorized