PHP code example of stephenjude / providus-sdk

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

    

stephenjude / providus-sdk example snippets


return [
    'id' => env('PROVIDUS_ID'),

    'secret' => env('PROVIDUS_SECRET'),

    'base_url' => env('PROVIDUS_BASE_URL', 'http://154.113.16.142:8088/AppDevAPI/api/'),

    /**
     * Set SDK to demo mode. This mode makes use of the demo signature provided by Providus bank.
     */
    'demo_mode' => env('PROVIDUS_DEMO', false),

    /**
     * Auth signature used for demo requests
     */
    'demo_signature' => 'BE09BEE831CF262226B426E39BD1092AF84DC63076D4174FAC78A2261F9A3D6E59744983B8326B69CDF2963FE314DFC89635CFA37A40596508DD6EAAB09402C7',

    'webhook' => [
        /**
         * This secret is used to verify that the payload has not been tampered with.
         */
        'signing_secret' => env('PROVIDUS_SECRET'),

        /**
         * The name of the header containing the signature.
         */
        'signature_header_name' => 'X-Auth-Signature',

        /**
         * This class will verify that the content of the signature header is valid.
         * It should implement \Providus\Providus\SignatureValidator\SignatureValidator
         */
        'signature_validator' => \Providus\Providus\SignatureValidator\DefaultSignatureValidator::class,

        /**
         * The classname of the controller to be used to process the webhook.
         * This should be set to a class that extends \Providus\Providus\Http\Controllers\WebhookController::class
         */
        'controller' => \Providus\Providus\Http\Controllers\WebhookController::class,

        /**
         * The route path that maps the webhook request to the webhook controller.
         */
        'path' => '/internals/webhook/providus/events',
    ],
];

$bank = new \Providus\Providus\Providus();

$bank->verifyTransactionBySessionId(SETTLEMENT_ID);

//Or use Facade
use \Providus\Providus\Facades\Providus;

Providus::verifyTransactionBySessionId(SETTLEMENT_ID);

$accountDetails = $bank->createDynamicAccountNumber('customer_name');
$accountDetails->accountName;
$accountDetails->accountNumber;

$accountDetails =  $bank->createReservedAccountNumber('customer_name', 'customer_bvn');
$accountDetails->accountName;
$accountDetails->accountNumber;
$accountDetails->bvn;

$accountDetails = $bank->updateAccountName('customer_updated_name', 'customer_account_number');
$accountDetails->accountName;
$accountDetails->accountNumber;

$bank->blacklistAccountNumber('customer_account_number');

$transaction = $bank->verifyTransactionBySessionId('session_id');

$transaction =  $bank->verifyTransactionBySettlementId('settlement_id');

$transaction->sessionId;
$transaction->settlementId;
$transaction->accountNumber;
$transaction->currency;
$transaction->transactionAmount;
$transaction->transactionReference;
$transaction->transactionDate;
$transaction->feeAmount;
$transaction->settledAmount;
$transaction->sourceAccountNumber;
$transaction->sourceAccountNumber;
$transaction->sourceBankName;
$transaction->remarks;
$transaction->channelId;

   /**
     * The classname of the controller to be used to process the webhook.
     * This should be set to a class that extends \Providus\Providus\Http\Controllers\WebhookController::class
     */
    'controller' => App\Http\Controllers\ProvidusWebhookController::class,



namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Providus\Providus\Http\Controllers\WebhookController;

class ProvidusWebhookController extends WebhookController
{
    public function handle(Request $request)
    {
        parent::handle($request);

        if ($this->sessionHasDuplicate($request->input('sessionId'))) {
            return $this->duplicateResponse($request);
        }

       // Webhook request is valid, so you can do your thing here.

        return $this->successfulResponse($request);
    }
    
    public function sessionHasDuplicate(string $sessionId){
    
        // Check if session ID has duplicate. A duplicate sessions is for transaction you have already processed previously.
        
    }
}

bash
php artisan vendor:publish --tag="providus-sdk-config"