PHP code example of fapshi / payments

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

    

fapshi / payments example snippets



Fapshi\Client;

$client = new Client('your_api_user', 'your_api_key');

// Create a payment link
$link = $client->initiatePay([
    'amount' => 1500,
    'email' => '[email protected]',
    'redirectUrl' => 'https://yourapp.com/payment/return',
]);

// Direct pay to phone
$direct = $client->directPay([
    'amount' => 1500,
    'phone' => '677000000',
    'medium' => 'mobile money',
]);

// Check payment status
$status = $client->getPaymentStatus($link['transId']);

// Expire a payment
$expired = $client->expirePay($link['transId']);

// Get user transactions
$userTx = $client->getTransactionsByUserId('user-123');

// Search transactions
$search = $client->searchTransactions([
    'status' => 'successful',
    'limit' => 10,
]);

// Get balance
$balance = $client->getBalance();

// Payout
$payout = $client->payout([
    'amount' => 2000,
    'phone' => '677000000',
    'medium' => 'mobile money',
]);