1. Go to this page and download the library: Download zainpay/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/ */
zainpay / sdk example snippets
use Zainpay\SDK\Engine;
LOPMENT);
Engine::setToken('<PUBLIC_KEY>');
use Zainpay\SDK\Engine;
use Zainpay\SDK\ZainBox;
key
Engine::setMode(Engine::MODE_DEVELOPMENT);
Engine::setToken('<PUBLIC_KEY>');
// Alternatively, set the mode to production (live server)
Engine::setMode(Engine::MODE_PRODUCTION);
Engine::setToken('<PUBLIC_KEY>');
// Or use the ZainBox class for more flexibility
ZainBox::instantiate()
->withMode(Engine::MODE_PRODUCTION)
->withToken('<PUBLIC_KEY>');
use Zainpay\SDK\Engine;
use Zainpay\SDK\Card;
oken('<PUBLIC_KEY>');
$response = Card::instantiate()->initializeCardPayment(
'3000',
'Q6166237864',
'[email protected]',
'08000000000',
'THbfnDvK5o',
'https://example.net/webhook/zainpay',
);
if ($response->hasSucceeded()){
var_dump($response->getCode());
var_dump($response->getStatus());
var_dump($response->getDescription());
var_dump($response->getData());
}
if ($response->hasFailed()){
var_dump($response->getErrorMessage());
var_dump($response->getCode());
var_dump($response->getStatus());
var_dump($response->getDescription());
var_dump($response->getData()); //this will return error fields or null if there is no data
}
use Zainpay\SDK\Engine;
use Zainpay\SDK\Card;
tToken('<PUBLIC_KEY>');
$response = Card::instantiate()->initializeCardPayment(
'3000', //amount - /payerMobileNo - mp($response->getData());
}
use Zainpay\SDK\Engine;
use Zainpay\SDK\Card;
tToken('<PUBLIC_KEY>');
$response = Card::instantiate()->verifyCardPayment(
'51328349733' //txnRef -
use Zainpay\SDK\Engine;
use Zainpay\SDK\Card;
tToken('<PUBLIC_KEY>');
$response = Card::instantiate()->verifyCardPaymentV2(
'<Transaction-Reference>' //txnRef -
use Zainpay\SDK\Engine;
use Zainpay\SDK\Card;
tToken('<PUBLIC_KEY>');
$response = Card::instantiate()->zainboxTransactionHistory(
'THbxyfjkd20', //zainboxCode - '2023-11-30' //dateTo - optional (string|null) : specify end date
'[email protected]' //email - optional (string|null) : specify payer email address
'success' //status - optional (string|null) : specify txn status (e.g success)
'txn3002747' //txnRef - optional (string|null) : specify txnRef
);
if ($response->hasSucceeded()){
var_dump($response->getData());
}
use Zainpay\SDK\Engine;
use Zainpay\SDK\Card;
tToken('<PUBLIC_KEY>');
$response = Card::instantiate()->reconcileCardPayment(
'CARD1234', //txnRef -
use Zainpay\SDK\Engine;
use Zainpay\SDK\ZainBox;
ken('<PUBLIC_KEY>');
$response = ZainBox::instantiate()->create(
"Box Test 1", //name - /webhook", //callbackUrl - n
false //allowAutoInternalTransfer - optional (bool|null) - if set to true, whenever money is deposited on any of the zainbox VAs it will be automatically transferred to settlement account.
);
if ($response->hasSucceeded()){
var_dump($response->getData());
}
use Zainpay\SDK\Engine;
use Zainpay\SDK\ZainBox;
ken('<PUBLIC_KEY>');
$response = ZainBox::instantiate()->list();
if ($response->hasSucceeded()){
var_dump($response->getData());
}
use Zainpay\SDK\Engine;
use Zainpay\SDK\ZainBox;
ken('<PUBLIC_KEY>');
string $name,
?string $emailNotification,
?array $tags,
?string $callbackUrl,
?string $description,
?bool $allowAutoInternalTransfer,
string $zainboxCode
$response = ZainBox::instantiate()->update(
"Box Test 1", //name - et to true, whenever money is deposited on any of the zainbox VAs it will be automatically transferred to settlement account.
"zainboxCode", //zainboxCode -
use Zainpay\SDK\Engine;
use Zainpay\SDK\ZainBox;
ken('<PUBLIC_KEY>');
$response = ZainBox::instantiate()->profile(
'<ZainboxCode>' //zainboxCode -
use Zainpay\SDK\Engine;
use Zainpay\SDK\ZainBox;
ken('<PUBLIC_KEY>');
$response = ZainBox::instantiate()->createSettlement(
'new-daily-settlement',//name - "1234567890", //accountNumber - "0234567892", //accountNumber - if ($response->hasSucceeded()){
var_dump($response->getData());
}
use Zainpay\SDK\Engine;
use Zainpay\SDK\ZainBox;
ken('<PUBLIC_KEY>');
$response = ZainBox::instantiate()->getSettlement(
'<zainboxCode>' //zainboxCode -
use Zainpay\SDK\Engine;
use Zainpay\SDK\ZainBox;
ken('<PUBLIC_KEY>');
$response = Card::instantiate()->totalPaymentCollectedByZainbox(
'THbxyfjkd20', //zainboxCode - asSucceeded()){
var_dump($response->getData());
}
use Zainpay\SDK\Engine;
use Zainpay\SDK\ZainBox;
ken('<PUBLIC_KEY>');
$response = Card::instantiate()->totalPaymentCollectedByMerchant(
'2022-02', //dateFrom - optional (string|null) : specify start date
'2022-03' //dateTo - optional (string|null) : specify end date
);
if ($response->hasSucceeded()){
var_dump($response->getData());
}
use Zainpay\SDK\Engine;
use Zainpay\SDK\ZainBox;
ken('<PUBLIC_KEY>');
$response = ZainBox::instantiate()->transactionList(
'zainboxCode', //zainboxCode - filter transactions ortherwise use null value.
'deposit', //txnType - optional (string|null) : use to filter transactions ortherwise use null value. e.g [deposit|transfer]
'virtualAccountTransfer', //paymentChannel - optional (string|null) : use to filter transactions ortherwise use null value. e.g [cardPayment|virtualAccountTransfer]
null, //dateFrom - optional (string|null) : use to filter transactions ortherwise use null value.
null, //dateTo - optional (string|null) : use to filter transactions ortherwise use null value.
);
if ($response->hasSucceeded()){
var_dump($response->getData());
}
use Zainpay\SDK\Engine;
use Zainpay\SDK\ZainBox;
ken('<PUBLIC_KEY>');
$response = ZainBox::instantiate()->settlementPaymentsHistory(
'zainboxCode', //zainboxCode - l value. e.g [pending|success|failed]
null, //dateFrom - optional (string|null) : use to filter settlement ortherwise use null value.
null, //dateTo - optional (string|null) : use to filter settlement ortherwise use null value.
);
if ($response->hasSucceeded()){
var_dump($response->getData());
}
use Zainpay\SDK\Engine;
VELOPMENT);
Engine::setToken('<PUBLIC_KEY>');
$response = \Zainpay\SDK\ZainBox::instantiate()->listVirtualAccounts(
'<zainboxCode>' //zainboxCode -
use Zainpay\SDK\Engine;
use Zainpay\SDK\VirtualAccount;
UBLIC_KEY>');
$response = VirtualAccount::instantiate()->createVirtualAccount(
'wemaBank' //bankType - d (string)
'[email protected]' //email - var_dump($response->getData());
}
use Zainpay\SDK\Engine;
use Zainpay\SDK\VirtualAccount;
UBLIC_KEY>');
$response = VirtualAccount::instantiate()->balance(
'7966884043' //virtualAccoutNumber -
use Zainpay\SDK\Engine;
use Zainpay\SDK\VirtualAccount;
_KEY>');
$response = VirtualAccount::instantiate()->changeVirtualAccountStatus(
'zainboxCode', //zainboxCode - }
use Zainpay\SDK\Engine;
use Zainpay\SDK\VirtualAccount;
BLIC_KEY>');
$response = VirtualAccount::instantiate()->allVirtualAccountsBalanceOfZainBox(
'zainboxCode' //zainboxCode -
use Zainpay\SDK\Engine;
use Zainpay\SDK\VirtualAccount;
BLIC_KEY>');
$response = ZainBox::instantiate()->transactionList(
'zainboxCode', //accountNumber - filter transactions ortherwise use null value. e.g [deposit|transfer]
'virtualAccountTransfer', //paymentChannel - optional (string|null) : use to filter transactions ortherwise use null value. e.g [cardPayment|virtualAccountTransfer]
null, //dateFrom - optional (string|null) : use to filter transactions ortherwise use null value.
null, //dateTo - optional (string|null) : use to filter transactions ortherwise use null value.
);
if ($response->hasSucceeded()){
var_dump($response->getData());
}
use Zainpay\SDK\Engine;
use Zainpay\SDK\VirtualAccount;
UBLIC_KEY>');
$response = \Zainpay\SDK\ZainBox::instantiate()->listVirtualAccounts(
'<zainboxCode>' //zainboxCode -
use Zainpay\SDK\Engine;
use Zainpay\SDK\VirtualAccount;
UBLIC_KEY>');
$response = VirtualAccount::instantiate()->verifyTransfer(
'<Transaction-Reference>' //txnRef -
use Zainpay\SDK\Engine;
use Zainpay\SDK\VirtualAccount;
UBLIC_KEY>');
$response = VirtualAccount::instantiate()->verifyDepositTransaction(
'51328349733' //txnRef -
use Zainpay\SDK\Engine;
use Zainpay\SDK\VirtualAccount;
UBLIC_KEY>');
$response = VirtualAccount::instantiate()->verifyDepositTransactionV2(
'<Transaction-Reference>' //txnRef -
use Zainpay\SDK\Engine;
use Zainpay\SDK\VirtualAccount;
UBLIC_KEY>');
$response = VirtualAccount::instantiate()->repushDeposit(
'51328349733' //txnRef -
use Zainpay\SDK\Engine;
use Zainpay\SDK\VirtualAccount;
UBLIC_KEY>');
//depositAccountNumber example
$response = VirtualAccount::instantiate()->reconcileBankDeposit(
'depositAccountNumber', //verificationType -
$response = VirtualAccount::instantiate()->reconcileBankDeposit(
'depositReferenceNumber', //verificationType -
use Zainpay\SDK\Engine;
use Zainpay\SDK\Bank;
tToken('<PUBLIC_KEY>');
$response = Bank::instantiate()->list();
if ($response->hasSucceeded()){
var_dump($response->getData());
}
use Zainpay\SDK\Engine;
use Zainpay\SDK\Bank;
Token('<PUBLIC_KEY>');
$response = Bank::instantiate()->accountNameEnquiry(
"000014", //bankCode -