TBC Payment System for Laravel 5.*
Inspired from tbcpay-php, created by Sandro Dzneladze
Modified ZGabievi/laravel-tbcpay for new TBC Payment system by Vati
Run composer command in your terminal.
composer require vati/tbc
Open config/app.php
and find the providers
key. Add TBCServiceProvider
to the array.
Gabievi\TBC\TBCServiceProvider::class
Find the aliases
key and add Facade
to the array.
'TBC' => Gabievi\TBC\TBCFacade::class
There are two types of transaction within this system:
- SMS is direct payment, where money is charged in 1 event.
- DMS is delayed payment, requires 2 events:
- First event blocks money on the card
- Second event takes money (It can be carried out when product is shipped to the customer, for example)
In every 24 hour the merchant must send the close the business day request to bank server
There are several methods you need to know:
SMSTransaction($amount, $currency = 981, $description = '', $language = 'GE')
DMSAuthorization($amount, $currency = 981, $description = '', $language = 'GE')
DMSTransaction($txn_id, $amount, $currency = 981, $description = '', $language = 'GE')
GetTransactionResult($txn_id)
ReverseTransaction($txn_id, $amount = '', $suspected_fraud = '')
RefundTransaction($txn_id)
CreditTransaction($txn_id, $amount = '')
CloseDay()
In your routes.php
create route:
Route::get('payment/{status}', function($status) {
if ($status == 'success') {
return TBC::GetTransactionResult(request('trans_id'));
}
return 'FAIL!';
})->where('status', 'success|fail');
Route::get('pay', function() {
return view('payment.tbc', [
'start' => TBC::SMSTransaction(1)
]);
});
Create payment/tbc.blade.php
. It should look like:
<!doctype html>
<html>
<head>
<title>TBC</title>
</head>
<body>
@if(isset($start['error']))
<h2>Error:</h2>
<h1>{{ $start['error'] }}</h1>
@elseif(isset($start['TRANSACTION_ID']))
<form name="returnform" id="Pay" action="{{config('tbc.client_handler')}}" method="POST">
<input type="hidden" name="trans_id" value="{{ $start['TRANSACTION_ID'] }}">
<noscript>
<center>Please click the submit button below.<br>
<input type="submit" name="submit" value="Submit"></center>
</noscript>
</form>
<script>
window.onload = document.forms.Pay.submit;
</script>
@endif
</body>
</html>
Publish TBC config file using command:
php artisan vendor:publish
Created file config\tbc.php
. Inside you can change configuration as you wish.
TBC is an open-sourced laravel package licensed under the MIT license
- Create tests