PHP code example of melaku / telebirr

1. Go to this page and download the library: Download melaku/telebirr 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/ */

    

melaku / telebirr example snippets




      $PUBLICKEY = "YOUR PUBLIC KEY";
      $APPKEY = "YOUR APP KEY";
      $APPID = "YOUR APP ID";
      $SHORTCODE = "YOUR SHORT CODE";
      $API = "YOUR WEBPAY URL";
    

      $NOTIFYURL = "http://YOUR/NOTIFY/URL";
      $RETURNURL = "http://YOUR/RERURN/URL";
      $TIMEOUT = '30';
      $RECIVER = "COMPANY NAME";
      $totalAmount = 3;
      $subject = "REASON FOR PAYMENT";
    

      $pay1 = new Melaku\Telebirr\Telebirr(
        $PUBLICKEY,
        $APPKEY,
        $APPID,
        $API,
        $SHORTCODE,
        $NOTIFYURL, 
        $RETURNURL,
        $TIMEOUT,
        $RECIVER,
        $totalAmount,
        $subject,
      );
    

      var_dump($pay1->getPyamentUrl());
    

        header("Location:" . $pay1->getPyamentUrl());
      

      $PUBLICKEY = "YOUR PUBLIC KEY";
      $data = "DATA RECIVED FROM TEELEBIRR VIA NOTIFY URL";
    

            $data = file_get_contents('php://input');
          

    $result = new \Melaku\Telebirr\Notify($PUBLICKEY,$data);
    

      var_dump($result->getPaymentInfo());