zgabievi / laravel-bogpayment
Bank of Georgia payment integration for Laravel
Installs: 103
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 1
Forks: 4
Open Issues: 0
Type:project
Requires
- php: ^7.2|^7.3|^7.4
- bensampo/laravel-enum: ^1.38|^2.2|^3.3
- illuminate/config: ^6.0|^7.0|^8.0
- illuminate/database: ^6.0|^7.0|^8.0
- illuminate/support: ^6.0|^7.0|^8.0
Requires (Dev)
- ext-curl: *
- ext-libxml: *
- ext-openssl: *
- ext-simplexml: *
README
Table of Contents
Installation
To get started, you need to install package:
composer require zgabievi/laravel-bogpayment
If your Laravel version is older than 5.5, then add this to your service providers in config/app.php:
'providers' => [ ... Zorb\BOGPayment\BOGPaymentServiceProvider::class, ... ];
You can publish config file using this command:
php artisan vendor:publish --provider="Zorb\BOGPayment\BOGPaymentServiceProvider"
This command will copy config file for you.
Usage
Payment
Default process has several to be completed:
- Redirect to card details page
- Bank will check payment details on your route
- Bank will register payment details on your route
Step #1
On this step you should redirect user to card details page
use Zorb\BOGPayment\Facades\BOGPayment; class PaymentController extends Controller { // public function __invoke() { return BOGPayment::redirect([ 'order_id' => 1, ], false); } }
Pass any parameter you want to recieve on check and register step as a first value. (default: []
)
Second value is boolean and defines if you want to pre-authorize payment, block amount. (default: false
)
Step #2
On this step bank will check that you are ready to accept payment.
This process is called PaymentAvail.
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'), ]); } }
Check request parameters here
Step #3
On this step bank will provide details of the payment.
This process is called RegisterPayment.
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'); } }
Check request parameters here
Recurring
Recurring process is the same as default process. Difference is that user doesn't have to fill card details again.
- Request will be sent to bank to start recurring process
- Bank will check payment details on your route
- Bank will register payment details on your route
use Zorb\BOGPayment\Facades\BOGPayment; class PaymentRecurringController extends Controller { // public function __invoke(string $trx_id) { return BOGPayment::repeat($trx_id, [ 'recurring' => true, ]); } }
In your check and register controllers you can catch BOGPayment::getParam('o.recurring')
parameter and now you will know that this process is from recurring request.
Refund
In order to refund money you need to have trx_id of payment and rrn.
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 } } }
Check result parameters here
Additional Information
Parameters of check request
Parameters of register request
Refund result
Extended result codes
Environment Variables
License
zgabievi/laravel-bogpayment is licensed under a MIT License.