Making credit card payments work on your website is a pain!
So to make everyones' life a bit easier we are sharing the
Georgian TBC payment gateway sdk on GitHub.
Have fun :)
There are two types of transaction within this system: SMS and DMS.
SMS - is direct payment, where money is charged in 1 event.
DMS - is delayed. Requires two events: first event blocks money on the card, second event takes money (second event can be carried out when product is shipped to the customer for example).
Every 24 hours, the merchant must send the close the business day request to bank server.
It is possible to simply include the library (check examples dir), but you should use composer instead.
run in terminal:
composer require wearede/tbcpay-php:dev-master
or
Add in composer.json
"require": {
"wearede/tbcpay-php": "dev-master"
}
and run in terminal
composer update wearede/tbcpay-php
require __DIR__ . '/vendor/autoload.php';
$Payment = new TbcPayProcessor( '/cert/tbcpay.pem', '0DhJ4AdxVuPZmz3F4y', $_SERVER['REMOTE_ADDR'] );
- Certificate absolute path
- Certificate passphrase
- Client ip address
Method name | Return Value | Description |
---|---|---|
sms_start_transaction() | array( 'TRANSACTION_ID' => 'AX23x...' ) |
|
dms_start_authorization() | ||
dms_make_transaction( $trans_id ) | ||
get_transaction_result( $trans_id ) | ||
reverse_transaction( $trans_id, $amount = '', $suspected_fraud = '' ) | ||
refund_transaction( $trans_id ) | ||
credit_transaction( $trans_id, $amount = '' ) | ||
close_day() |
-
Ask bank to generate certificate
-
Tell them your server IP so they whitelist it
-
create
example.com/ok.php
andexample.com/fail.php
urls and tell them about it- ok url - is used for redirecting back user in almost all situations
- fail ulr - is used for redirecting back user when technical error occurs
-
start.example
Here we start our process. We call bank servers usingsms_start_transaction()
and get$trans_id
in return.- We use returned $trans_id to redirect user to a bank page, where credit card info can be entered.
- After user fills out card info he is thrown back to our
ok.example
url on our server.
-
Take a look at
ok.example
We get$trans_id
back from bank, and we plug that inget_transaction_result( $trans_id )
-
get_transaction_result( $trans_id )
tells us if transaction was success or not.array( 'RESULT' => 'OK' )
for example is success message, transaction went through.
Help needed with #3 !
This API besides TBCBANK should support BANK OF GEORGIA, LIBERTY BANK, and some other minor banks. But since I've only tested this with TBCBANK, I'm releasing this as such.
TBC bank provides SSL certificate in .p12 format
To Trasnform it into .pem format Run: openssl pkcs12 -in *.p12 -out tbcpay.pem
! Move cert directory somewhere non accessible to web server as a security meassure.