PHP code example of viciremittance / vici-php-sdk

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

    

viciremittance / vici-php-sdk example snippets


use ViciApi\Services\Disbursement;

$disbursement = new Disbursement();

$disbursement->setBaseUrl($apiBaseUrl);

$disbursement->setCredentials($clientId, $clientSecret, $signingKey);

$accessToken = $disbursement->refreshAccessToken()['access_token'];
$disbursement->setAccessToken($accessToken);

$banks = $disbursement->bankList();

// extracting bank id
$bankId = $banks['banks'][0]['bank_id'];

// initialize ViciApi class
$vici = new ViciApi();

// set API base url
$vici->setBaseUrl($apiBaseUrl);

// set API credentials
$vici->setCredentials($clientId, $clientSecret, $signingKey);

// request API access token, this also calls setAccessToken
// you should store the access token in your system and refresh when it expires
$accessToken = $vici->refreshAccessToken()['access_token'];

// set access token that will be used to create API calls
$vici->setAccessToken($accessToken);

// request Disbursements Bank List API using createRequest
$vici->createRequest('GET', '/dg/v1/banks');

// comparing and proccessing signature from your callbacks
$isValid = $vici->isValidSignature($signatureToCompare, $method, $path, $timestamp, $body);
if ($isValid) {
  // ... code when signature is valid
} else {
  // ... code when signature is not valid
}

$disbursement = new Disbursement();
$disbursement->setBaseUrl($apiBaseUrl);
$disbursement->setCredentials($clientId, $clientSecret, $signingKey);

// request /dg/v1/bank-account-inquiry API
$disbursement->bankAccountInquiry($accountNo, $bankId, $customerName, $withValidation);

// request /dg/v1/banks API
$disbursement->bankList();

// request ​/dg​/v1​/disbursements API
$disbursement->executeDisbursement($accountNo, $amount, $bankId, $customerName, $referenceId, $description);

// request /dg/v1/disbursements/reference-id/{reference_id} API
$disbursement->checkDisbursementByReferenceId($referenceId);

// request /dg/v1/disbursements/{disbursement_id} API
$disbursement->checkDisbursementByDisbursementId($disbursementId);

// request /cash/me/balance API
$disbursement->checkBalance();

$paymentGateway = new PaymentGateway();
$paymentGateway->setCredentials($clientId, $clientSecret, $signingKey);

// request /pg/v1/payment/reference-id/{reference_id} API
$paymentGateway->checkPaymentByReferenceId($referenceId);

// request /pg/v1/payment/{payment_id} API
$paymentGateway->checkPaymentByPaymentId($paymentId);