Telebirr-Php is a php library for telebirr.
Telebirr is a mobile money service developed by Huawei that is owned and was launched by Ethio telecom.
This library will help you by providing an easy integration method so you can focus on your main task
composer require melaku/telebirr
you will receive the required information from Tele with information which looks like theis ⬇️
merchant name | short code | APP ID | APP KEY | Public ID | H5 | InApp Payment |
---|---|---|---|---|---|---|
owner name | 6-digit code | 32-character Id | 32-character key | 392-character public key | web payment url | mobile payment url |
you should store those information in your development environment like .env
file
you should always require the composer autoload
require 'vendor/autoload.php';
-
step 1 Initialize the information from Telebirr in variable
-
$PUBLICKEY = "YOUR PUBLIC KEY"; $APPKEY = "YOUR APP KEY"; $APPID = "YOUR APP ID"; $SHORTCODE = "YOUR SHORT CODE"; $API = "YOUR WEBPAY URL";
-
-
step 2 Initialize information from your side in a variable
-
$NOTIFYURL = "http://YOUR/NOTIFY/URL"; $RETURNURL = "http://YOUR/RERURN/URL"; $TIMEOUT = '30'; $RECIVER = "COMPANY NAME"; $totalAmount = 3; $subject = "REASON FOR PAYMENT";
- explanation
NOTIFYURL
- is the URL that will receive the payment status from telebirr and is responsible for updating your DatabaseRETURNURL
- the URL that will be returned after payment usually it is the checkout screenTIMEOUT
- payment timeout, it is set 30 seconds by defaultRECIVER
- the company that will receive the paymenttotalAmount
- is the amount that should be paid, this information usually comes from POST so assign the value accordinglysubject
- it is the reason for payment, eg. book purchase
-
-
step 3 Create a new object of Telebirr class with all informations
-
$pay1 = new Melaku\Telebirr\Telebirr( $PUBLICKEY, $APPKEY, $APPID, $API, $SHORTCODE, $NOTIFYURL, $RETURNURL, $TIMEOUT, $RECIVER, $totalAmount, $subject, );
-
-
step 4 get the payment url
-
var_dump($pay1->getPyamentUrl());
-
this will return payment url like
http://196.188.120.3:11443/ammwebpay/#/?transactionNo=123456789
the transaction number123456789
is used for example yours will be different -
after this you are required to redirect your header to the payurl
-
header("Location:" . $pay1->getPyamentUrl());
- this will forward you to the payment screen
-
-
-
step 1 define public key and data received form telebirr
-
$PUBLICKEY = "YOUR PUBLIC KEY"; $data = "DATA RECIVED FROM TEELEBIRR VIA NOTIFY URL";
- explanation
-
PUBLICKEY
- is the same as the public key defined during payment initialization -
data
- is the data received from telebirr from the notify URL, your notify URL should accept plain text not JSON, you can get incoming data by using ⬇️-
$data = file_get_contents('php://input');
-
-
- explanation
-
-
step 2 Create a new object of Notify class with
$PUBLICKEY
and$data
-
$result = new \Melaku\Telebirr\Notify($PUBLICKEY,$data);
-
to get the payment result call
getPaymentInfo()
-
var_dump($result->getPaymentInfo());
-
-
The
getPaymentInfo()
will return a json data like ⬇️-
{ "msisdn":"251900000032", "outTradeNo":"15380eaea1405302ee0821b62546682c", "totalAmount":"10", "tradeDate":1670051315108, "tradeNo":"202212031008041598937091913756674", "tradeStatus":2, "transactionNo":"9L360NSV4U" }
-
-