1. Go to this page and download the library: Download zgabievi/laravel-bogpayment 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/ */
use Zorb\BOGPayment\Facades\BOGPayment;
class PaymentController extends Controller
{
//
public function __invoke()
{
return BOGPayment::redirect([
'order_id' => 1,
], false);
}
}
use Zorb\BOGPayment\Facades\BOGPayment;
class PaymentCheckController extends Controller
{
//
public function __invoke()
{
// chek that http authentication is correct
BOGPayment::checkAuth();
// check if you are getting request from allowed ip
BOGPayment::checkIpAllowed();
// check if you can find order with provided id
$order_id = BOGPayment::getParam('o.order_id');
$order = Order::find($order_id);
if (!$order) {
BOGPayment::sendError('check', 'Order couldn\'t be found with provided id');
}
$trx_id = BOGPayment::getParam('trx_id');
// send success response
BOGPayment::sendSuccess('check', [
'amount' => $order->amount,
'short_desc' => $order->short_desc,
'long_desc' => $order->long_desc,
'trx_id' => $trx_id,
'account_id' => config('bogpayment.account_id'),
'currency' => config('bogpayment.currency'),
]);
}
}
use Zorb\BOGPayment\Facades\BOGPayment;
class PaymentRegisterController extends Controller
{
//
public function __invoke()
{
// chek that http authentication is correct
BOGPayment::checkAuth();
// check if you are getting request from allowed ip
BOGPayment::checkIpAllowed();
// check if provided signature matches certificate
BOGPayment::checkSignature('register');
// check if you can find order with provided id
$order_id = BOGPayment::getParam('o.order_id');
$order = Order::find($order_id);
if (!$order) {
BOGPayment::sendError('check', 'Order couldn\'t be found with provided id');
}
$trx_id = BOGPayment::getParam('trx_id');
$result_code = BOGPayment::getParam('result_code');
if (empty($result_code)) {
BOGPayment::sendError('register', 'Result code has not been provided');
}
if ((int)$result_code === 1) {
// payment has been succeeded
} else {
// payment has been failed
}
// send success response
BOGPayment::sendSuccess('register');
}
}
use Zorb\BOGPayment\Facades\BOGPayment;
class PaymentRecurringController extends Controller
{
//
public function __invoke(string $trx_id)
{
return BOGPayment::repeat($trx_id, [
'recurring' => true,
]);
}
}
use Zorb\BOGPayment\Facades\BOGPayment;
class PaymentRefundController extends Controller
{
//
public function __invoke(string $trx_id, string $rrn)
{
$result = BOGPayment::refund($trx_id, $rrn);
if ((int)$result->code === 1) {
// refund process succeeded
} else {
// refund process failed
}
}
}