Git Product home page Git Product logo

momoapi's Introduction

PackageMomo

PackageMomo Un package simple en php pour l'integration de l'api MTN Mobile Money.

Produits supportés

  • Collections
  • Disbursements (pas encore disponible)

Avant toute chose

  • S'inscrire sur momodeveloper ou avoir des accès momoapi(prod)
  • Souscrire aux produit de collection

Pour s'inscrire

Veuillez cliquer sur ce lien signup

Souscrire aux Produits

Sur la page Products sur le portail des développeurs, vous devriez voir les éléments auxquels vous pouvez vous abonner:

  • Collections
  • Disbursements
  • Remittances

Installation

La méthode recommandée pour installer PackageMomo est composer.

composer require kouyatekarim/momoapi

Vous pouvez maintenant ajouter l'autoloader et vous aurez accès à la bibliothèque: n'oublier surtout pas de mettre si c'est un projet en php natif

<?php
require 'vendor/autoload.php';

toujours au dessus de tout

<?php
require 'vendor/autoload.php';

pour un projet avec un framework require 'vendor/autoload' n'est pas à faire

Utilisation

Créer une instance de produit

Si vous travaillez avec LARAVEL allez y avant toute chose dans []'vendor/kouyatekarim/momoapi/src/products/product.php' changer à la ligne 17 realpath en base_path ainsi que dans []'vendor/kouyatekarim/momoapi/src/traits/SandboxUserProvisioning.php'.

Si vous travaillez avec du php natif vous pouvez laisser comme c'est.

si vous travaillez un autre framework php, si vous avez une erreur de path verifiez ces deux fichiers []'vendor/kouyatekarim/momoapi/src/traits/SandboxUserProvisioning.php', []'vendor/kouyatekarim/momoapi/src/products/product.php'.

<?php
use Kouyatekarim\Momoapi\Products\Collection;


$options = [
    // 'callbackHost' => '', //(optionel)  http://localhost:8000 est par defaut
    // 'callbackUrl' => '', //(optionel)  http://localhost:8000/callback est par defaut
    // 'environment' => '', //(optionel) sandbox est par defaut
    // 'accountHolderIdType' => '', //(optionel)  msisdn est par defaut
    'subscriptionKey' => '', //la clée produit de souscription
    'xReferenceId' => '', //Api user  (en  format UUID )
    'apiKey' => '', // Api key (obtenu après l'avoir généré à 'Créer une clé API')
   
    //'accessToken' => '' //obligatoire pour requestopay
];

// avec collection
$collection = Collection::create($options);

Sandbox User Provisioning

Créer API User

<?php
use Kouyatekarim\Momoapi\Products\Collection;


// avec collection
$product = Collection::create($options);

$response = $product->createApiUser(); //{"statusCode": 201}

echo $response

Obtenir les details API User

<?php
use Kouyatekarim\Momoapi\Products\Collection;


// Using collection
$product = Collection::create($options);



$apiUser = $product->getApiUser();
echo $apiUser->getProviderCallbackHost(); //http://localhost:8000
echo '</br>';
echo $apiUser->getTargetEnvironment(); //sandbox

Créer API Key

<?php
use Kouyatekarim\Momoapi\Products\Collection;


// Avec collection
$product = Collection::create($options);


$apiKey = $product->createApiKey();
echo $apiKey->getApiKey(); //apiKey

Oauth 2.0

Obtenir le token(jéton)

<?php
use Kouyatekarim\Momoapi\Products\Collection;


// Avec collection
$product = Collection::create($options);



$token = $product->getToken();
echo $token->getAccessToken(); //accessToken
echo '</br>';
echo $token->getTokenType(); //tokenType
echo '</br>';
echo $token->getExpiresIn(); //expiry in seconds

Transactions

Collections

Request to pay

<?php
use Kouyatekarim\Momoapi\Products\Collection;

// Avec collection
$product = Collection::create($options);

$product->requestToPay($externalId, $partyId, $amount, $currency, $payerMessage = '', $payeeNote = ''); // *

Exemple complet

Exemple complet de test(sandbox)

<?php
require 'vendor/autoload.php'; // à enlever si vous travailler avec un framework
use Kouyatekarim\Momoapi\Products\Collection;

$xReferenceId = "afd59405-1bbe-4928-99d2-0c7060956358"; // à générer sur le site [UUID](https://www.uuidgenerator.net/).
$options = [
     'callbackHost' => 'clinic.com', 
    // 'callbackUrl' => '', 
    //'environment' => '', 
    // 'accountHolderIdType' => '', 
    'subscriptionKey' => '<votre_primary_key>', 
    'xReferenceId' =>  $xReferenceId, 
 

];



// Avec collection
$product = Collection::create($options);

$product->createApiUser(); 
$apiUser = $product->getApiUser();
echo $apiUser->getProviderCallbackHost(); //clinic.com
echo '</br>';
echo $apiUser->getTargetEnvironment(); //sandbox
echo '</br>';



$apiKey = $product->createApiKey();


echo $apiKey->getApiKey();






$options = [
    // 'callbackHost' => '', //(optional)
    // 'callbackUrl' => '', //(optional) 
    //'environment' => 'mtnivorycoast', 
    // 'accountHolderIdType' => '', 
    'subscriptionKey' => '<votre_primary_key>', 
    'xReferenceId' => $xReferenceId, //
    'apiKey' => $apiKey->getApiKey(), //  
   
];





$product = Collection::create($options);


$token = $product->getToken();
echo $token->getAccessToken(); //accessToken
$token->getTokenType(); //tokenType
$token->getExpiresIn(); //expiry in seconds




$options = [
    // 'callbackHost' => '', 
    // 'callbackUrl' => '', 
    //'environment' => '', 
    // 'accountHolderIdType' => '', 
    'subscriptionKey' => '', 
    'xReferenceId' =>$xReferenceId, 
    'apiKey' => $apiKey->getApiKey(), 
    'accessToken' => $token 
];


$product = Collection::create($options);

$externalId ="12345";
$partyId = '<un_numero_mtn_mobile_money>'; //numero sans l'indicateur du pays
$amount = 10;
$currency = "EUR";
$product->requestToPay($externalId, $partyId, $amount, $currency, $payerMessage = '', $payeeNote = ''); 

Exemple complet de production

<?php
require 'vendor/autoload.php'; // à enlever si vous travailler avec un framework
use Kouyatekarim\Momoapi\Products\Collection;


$options = [
     'callbackHost' => '<nom_de_domaine>', 
    'callbackUrl' => '<nom_de_domaine>/callback', 
    'environment' => 'mtnivorycoast', //pour la côte d'ivoire
    // 'accountHolderIdType' => '', 
    'subscriptionKey' => '<votre_primary_key_prod>', 
    'xReferenceId' =>  '<votre_api_user>', //Api user obtenu depuis le portail partner de MTN [Partner](https://partnermobilemoney.mtn.ci/partner/).
    'apiKey' => '<votre_api_user>', // Api  key obtenu depuis le portail partner de MTN [Partner](https://partnermobilemoney.mtn.ci/partner

];









$product = Collection::create($options);


$token = $product->getToken();
echo $token->getAccessToken(); //accessToken
$token->getTokenType(); //tokenType
$token->getExpiresIn(); //expiry in seconds




$options = [
     'callbackHost' => '<nom_de_domaine>', 
    'callbackUrl' => '<nom_de_domaine>/callback', 
    'environment' => 'mtnivorycoast', //pour la côte d'ivoire
    // 'accountHolderIdType' => '', 
    'subscriptionKey' => '<votre_primary_key_prod>', 
    'xReferenceId' =>  '<votre_api_user>', //Api user obtenu depuis le portail partner de MTN [Partner](https://partnermobilemoney.mtn.ci/partner/).
    'apiKey' => '<votre_api_user>', // Api  key obtenu depuis le portail partner de MTN [Partner](https://partnermobilemoney.mtn.ci/partner
    'accessToken' =>  $token  ,//obligatoire

];


$product = Collection::create($options);

$externalId ="12345";
$partyId = '<votre_numero_mobile_money>'; //numero sans l'indicateur du pays
$amount = 10;
$currency = "XOF";
$product->requestToPay($externalId, $partyId, $amount, $currency, $payerMessage = '', $payeeNote = ''); 

Bugs

Pour tout bug trouvé, veuillez m'envoyer un e-mail à [email protected]

momoapi's People

Contributors

kkstar34 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.