Orange Money Sdk
, (*1)
Note: orange-money-sdk
., (*2)
This is a php sdk for orange operator mobile money api., (*3)
Install
Via Composer, (*4)
``` bash
$ composer require foris-master/orange-money-sdk, (*5)
## 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/
```, (*6)
Usage
``` php
use Foris\OmSdk\OmSdk;, (*7)
$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);, (*8)
## API
### Get token
``` 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",
];
Web Payment
``` php
use Foris\OmSdk\OmSdk;, (*9)
$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"
];, (*10)
#### Note
webPayment method automatically call getToken and set it in request header.
### Transaction Status
``` 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"
];
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, (*11)
Production
For production your need to set your target country code in COUNTRY enviroment variable ( .env file if using dotenv)
example : COUNTRY=cm
Testing
bash
$ phpunit
, (*12)
Contributing
Please see CONTRIBUTING for details., (*13)
Credits
License
The MIT License (MIT). Please see License File for more information., (*14)