PHP code example of nelsius / nelsius-pay-php

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

    

nelsius / nelsius-pay-php example snippets


use Nelsius\NelsiusClient;

$nelsius = new NelsiusClient('your_secret_key', [
    'base_url' => 'https://api.nelsius.com/api/v1',
    'verify_ssl' => false // Set to false for local development (Laragon, WAMP, etc.)
]);

// 1. Get Payment Methods
$methods = $nelsius->charges->methods();

// 2. Create Hosted Checkout Session
$checkout = $nelsius->checkout->createSession([
    'amount' => 5000,
    'currency' => 'XAF',
    'reference' => 'ORDER_12345',
    'description' => 'Purchase Description',
    'return_url' => 'https://your-site.com/success',
    'cancel_url' => 'https://your-site.com/cancel',
    'customer' => [
        'email' => '[email protected]',
        'name' => 'Customer Name'
    ]
]);

header('Location: ' . $checkout['data']['checkout_url']);

// 3. Create Direct Charge (Mobile Money)
$charge = $nelsius->charges->create([
    'amount' => 2500,
    'currency' => 'XAF',
    'method' => 'mobile_money',
    'operator' => 'orange',
    'customer_phone' => '690000000',
    'reference' => 'TXN_REF_001'
]);
bash
composer