PHP code example of mboateng / sppay-laravel

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

    

mboateng / sppay-laravel example snippets


use Mboateng\Sppay\Facades\Sppay;

$response = Sppay::oauthPasswordGrant();
Sppay::setAccessToken($response['access_token']);

$transactions = Sppay::listTransactions(['page_size' => 10]);

use Mboateng\Sppay\Facades\Sppay;

$token = Sppay::oauthToken([
    'grant_type' => 'password',
    'client_id' => config('sppay.client_id'),
    'client_secret' => config('sppay.client_secret'),
    'username' => config('sppay.username'),
    'password' => config('sppay.password'),
]);

Sppay::setAccessToken($token['access_token']);

$transactions = Sppay::listTransactions(['page_size' => 10]);

use Mboateng\Sppay\Contracts\SppayClientContract;

public function __construct(
    private SppayClientContract $sppay
) {}

public function example(): void
{
    $this->sppay->setAccessToken($token);
    $this->sppay->getTransaction('REFERENCE');
}

use Mboateng\Sppay\SppayClient;

$client = new SppayClient(
    baseUrl: 'https://engine.sppay.dev',
    accessToken: $token,
);

$client->initiatePayment([/* ... */]);
bash
php artisan vendor:publish --tag=sppay-config