foris-master/orange-money-sdk

This is a php sdk for orange operator mobile money api.

0.8.0 2023-07-06 14:22 UTC

This package is not auto-updated.

Last update: 2024-04-18 01:51:49 UTC


README

Latest Version Software License Build Status Coverage Status Quality Score Total Downloads

Note: orange-money-sdk.

This is a php sdk for orange operator mobile money api.

Install

Via Composer

$ composer require foris-master/orange-money-sdk

Confing

Set AUTH_HEADER, MERCHANT_KEY,RETURN_URL,CANCEL_URL,NOTIF_URL enviroment variable ( .env file if using dotenv),
you get all related to you console at https://developer.orange.com/

Usage

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);

API

Get token

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",
];

Web Payment

use Foris\OmSdk\OmSdk;

$om = new OmSdk();
$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"
           ];
$rep= $om->webPayment($opt);
var_dump($rep);
// var_dump result
[
        "status"=> 201,
        "message"=> "OK",
        "pay_token"=> "87a9f2f8ebca97sdfdsbb49795f77981f5be1face7b6a543c8a1304d81e4299fd",
        "payment_url"=>"https://webpayment-sb.orange-money.com/payment/pay_token/87a9f2f8ebca97sdfdsbb49795f77981f5be1face7b6a543c8a1304d81e4299fd"
        "notif_token"=> "793d6157d9c7d52ae3920dc596956206"
];

Note

webPayment method automatically call getToken and set it in request header.

Transaction Status

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"
];

Note

The status could take one of the following values: INITIATED; PENDING; EXPIRED; SUCCESS; FAILED

  • INITIATED waiting for user entry
  • PENDING user has clicked on “Confirmer”, transaction is in progress on Orange side
  • EXPIRED user has clicked on “Confirmer” too late (after token’s validity)
  • SUCCESS payment is done
  • FAILED payment has failed

Production

  For production your need to set your target country code in COUNTRY enviroment variable ( .env file if using dotenv)
  example : COUNTRY=cm

Testing

$ phpunit

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.