PHP code example of fruitware / victoria-bank-gateway
1. Go to this page and download the library: Download fruitware/victoria-bank-gateway library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
fruitware / victoria-bank-gateway example snippets
use Fruitware\VictoriaBankGateway\VictoriaBankGateway;
$victoriaBankGateway = new VictoriaBankGateway();
$certDir = '/path/to/cert/dir';
$victoriaBankGateway
->configureFromEnv($certDir)
;
use Fruitware\VictoriaBankGateway\VictoriaBankGateway;
use Fruitware\VictoriaBankGateway\VictoriaBank\Exception;
use Fruitware\VictoriaBankGateway\VictoriaBank\Response;
use Fruitware\VictoriaBankGateway\VictoriaBank\AuthorizationResponse;
/** @var VictoriaBankGateway $victoriaBankGateway */
$bankResponse = $victoriaBankGateway->getResponseObject($_POST);
if (!$bankResponse->isValid()) {
throw new Exception('Invalid bank Auth response');
}
switch ($bankResponse::TRX_TYPE) {
case VictoriaBankGateway::TRX_TYPE_AUTHORIZATION:
$amount = $bankResponse->{Response::AMOUNT};
$bankOrderCode = $bankResponse->{Response::ORDER};
$rrn = $bankResponse->{Response::RRN};
$intRef = $bankResponse->{Response::INT_REF};
#
# You must save $rrn and $intRef from the response here for reversal requests
#
# Funds locked on bank side - transfer the product/service to the customer and request completion
$victoriaBankGateway->requestCompletion($bankOrderCode, $amount, $rrn, $intRef, $currency = null);
break;
case VictoriaBankGateway::TRX_TYPE_COMPLETION:
# Funds successfully transferred on bank side
break;
case VictoriaBankGateway::TRX_TYPE_REVERSAL:
# Reversal successfully applied on bank size
break;
default:
throw new Exception('Unknown bank response transaction type');
}