PHP code example of foris-master / orange-money-sdk

1. Go to this page and download the library: Download foris-master/orange-money-sdk 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/ */

    

foris-master / orange-money-sdk example snippets

 php
use Foris\OmSdk\OmSdk;

$om = new OmSdk();
// QuickStart
/**
 * You need to set AUTH_HEADER, MERCHANT_KEY,RETURN_URL,CANCEL_URL,NOTIF_URL
 * enviroment variable ( .env file if using dotenv)
 */
$om->webPayment(['amount'=>100]);
// Full Options
$opt=[
        "merchant_key"=> '********',
        "currency"=> "OUV",
        "order_id"=> $id,
        "amount"=> 0,
        "return_url"=> 'http://www.you-site.com/callback/return',
        "cancel_url"=> 'http://www.you-site.com/callback/cancel',
        "notif_url"=>'http://www.you-site.com/callback/notif',
        "lang"=> "fr"
    ];
$om->webPayment($opt);
 php
use Foris\OmSdk\OmSdk;

$om = new OmSdk();

$rep= $om->getToken();
var_dump($rep);
// var_dump result
[
        "token_type"=> 'Bearer',
        "access_token"=> "0213GH123l12kj312k",
        "expires_in"=> "7776000",
];

 php
use Foris\OmSdk\OmSdk;

$om = new OmSdk();

$rep= $om->checkTransactionStatus($orderId,$amount,$pay_token);
var_dump($rep);
// var_dump result
[
         "status" => "SUCCESS",
         "order_id" => "MY_ORDER_ID_08082105_0023457",
         "txnid" => "MP150709.1341.A00073"
];