PHP SDK for the Bancard vPOS 2.0 payment gateway API
Requirements: PHP >= 8.1
composer require zrkb/bancarduse Bancard\Bancard;
$bancard = new Bancard(
publicKey: 'YOUR_PUBLIC_KEY',
privateKey: 'YOUR_PRIVATE_KEY',
staging: true, // optional, defaults to false
);All operations return typed response objects with convenience methods.
use Bancard\Util\Currency;
$response = $bancard->singleBuy([
'shop_process_id' => '7777777',
'amount' => '10000.00',
'currency' => Currency::PYG->value,
'return_url' => 'https://app.test/return',
'cancel_url' => 'https://app.test/cancel',
]);
if ($response->isSuccessful()) {
$processId = $response->getProcessId();
}$response = $bancard->singleBuyZimple([
'shop_process_id' => '7777777',
'amount' => '10000.00',
'currency' => Currency::PYG->value,
'return_url' => 'https://app.test/return',
'cancel_url' => 'https://app.test/cancel',
]);Generates the confirm token for the iframe callback (no HTTP request is made).
$response = $bancard->singleBuyConfirm([
'shop_process_id' => '7777777',
'amount' => '10000.00',
'currency' => Currency::PYG->value,
]);
$token = $response->getToken();$response = $bancard->singleBuyGetConfirmation([
'shop_process_id' => '7777777',
]);
if ($response->isApproved()) {
$code = $response->getResponseCode();
}$response = $bancard->singleBuyRollback([
'shop_process_id' => '7777777',
]);$response = $bancard->cardsNew([
'card_id' => '123',
'user_id' => '456',
'return_url' => 'https://app.test/return',
]);
$processId = $response->getProcessId();$response = $bancard->usersCards([
'user_id' => '456',
]);
foreach ($response->getCards() as $card) {
echo $card->card_masked_number;
}$response = $bancard->charge([
'shop_process_id' => '7777777',
'amount' => '10000.00',
'currency' => Currency::PYG->value,
'alias_token' => 'card_alias_token',
]);
if ($response->isApproved()) {
// Payment successful
}
if ($response->is3dsRedirect()) {
// 3DS authentication required
}$response = $bancard->deleteCard([
'user_id' => '456',
'alias_token' => 'card_alias_token',
]);$response = $bancard->preauthorizationConfirm([
'shop_process_id' => '7777777',
]);
if ($response->isApproved()) {
// Preauthorization confirmed
}$response = $bancard->billingClientInfo([
// billing client info fields
]);
$client = $response->getClient();$response = $bancard->billingCancel([
'shop_process_id' => '7777777',
]);All responses extend Bancard\Response\Response and provide:
isSuccessful(): bool-- checks ifstatus === 'success'getStatus(): ?stringgetMessage(): ?string-- first message descriptiongetErrorKey(): ?string-- error key from messagesraw(): \stdClass-- access the raw response data
Specialized responses add operation-specific methods (e.g., getProcessId(), isApproved(), getCards()).
use Bancard\Exception\ValidationException;
try {
$response = $bancard->singleBuy($payload);
} catch (ValidationException $e) {
// Missing required fields
$errors = $e->getErrors(); // ['shop_process_id', 'amount', 'currency']
}use Bancard\Util\Amount;
$formatted = Amount::format(10000); // "10000.00"See UPGRADE.md for the migration guide.
If you discover any security related issues, please use the issue tracker.
The MIT License (MIT). Please see License File for more information.