PHP code example of nextmux / pay-sdk

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

    

nextmux / pay-sdk example snippets


use Nextmux\PaySDK\ApiClient;
use Nextmux\PaySDK\NextmuxPay;
use Nextmux\PaySDK\PayIn;


$nmpay = NextmuxPay::init(['publicKey' => 'PUBLIC_KEY', 'secretKey' => 'SECRET_KEY']);
$token = $nmpay->getToken();

 
// Vous pouvez utiliser votre token pour des appel curl. Avec la class Http par exemple 

 $response = Http::withHeaders([
    'Authorization' => 'Bearer ' . $token['access_token'],
    'Content-Type' => 'application/json',
    'User-Agent' => 'LE_USER_AGENT' //request()->header('User-Agent'),
    'X-Forwarded-For' =>'L_ADRESSE_IP' // request()->ip()
])->post($nmpay->apiUrl . '/v1/payins', $payload);

if ($response->successful()) {}


// Configurer les clés API et l'URL de l'API une seule fois avec Config si vous souhaitez
$config = Config::getInstance();
$config->setKeys('PUBLIC_KEY', 'SECRET_KEY');
$config->setApiUrl('https://api.nextmux.com');

// Utilisation de la classe Pay
$pay = new Pay();
$response = $pay->with_mobile_money(
    'mtn', // operator_code
    [
        'fullname' => 'John Doe',
        'email' => '[email protected]',
        'phone_number' => '237699999999',
        'amount' => 1000,
        'description' => 'Payment for services'
    ],
    [], // custom_params (optional)
    false // get_link (optional)
);