This library is unofficial Digiflazz API written with PHP.
For the API documentation, check Digiflazz API Reference.
Install digiflazz-php-library with composer by following command:
composer require nurfaizfy/digiflazz-php-library
or add it manually in your composer.json
file.
Configure package with your account's secret key obtained from Digiflazz Dashboard.
use Gonon\Digiflazz\Digiflazz;
Digiflazz::initDigiflazz('username', 'apikey');
\Gonon\Digiflazz\Balance::getBalance();
Usage example:
$getBalance = \Gonon\Digiflazz\Balance::getBalance();
var_dump($getBalance);
\Gonon\Digiflazz\PriceList::getPrePaid(); // Prepaid product
\Gonon\Digiflazz\PriceList::getPostPaid(); // Postpaid product
Usage example:
$priceList = \Gonon\Digiflazz\PriceList::getPrePaid();
var_dump($priceList);
\Gonon\Digiflazz\Deposit::createDeposit(array $params);
Parameters for this method
Name | Required | Description |
---|---|---|
amount_bank |
yes |
The deposit amount |
bank |
yes |
The name of the destination bank to which your transfer will be made (BRI, BCA, MANDIRI) |
owner_name |
yes |
The name of the account holder who made the deposit transfer to Digiflazz |
Usage example:
$params = [
'amount' => '200000',
'bank' => 'BCA',
'owner_name' => 'Digiflazz',
];
$createDeposit = \Gonon\Digiflazz\Deposit::createDeposit($params);
var_dump($createDeposit);
\Gonon\Digiflazz\Transaction::createTransaction(array $params);
Parameters for this method
Name | Required | Description |
---|---|---|
buyer_sku_code |
yes |
Product SKU |
customer_no |
yes |
Customer number |
ref_id |
yes |
Your unique reference ID |
Usage example:
$params = [
'buyer_sku_code' => 'xl10',
'customer_no' => '08123456789',
'ref_id' => 'some1d',
];
$createTrasaction = \Gonon\Digiflazz\Transaction::createTransaction($params);
var_dump($createTrasaction);
\Gonon\Digiflazz\Transaction::inquiryPostpaid(array $params);
Parameters for this method
Name | Required | Description |
---|---|---|
buyer_sku_code |
yes |
Product SKU |
customer_no |
yes |
Customer number |
ref_id |
yes |
Your unique reference ID |
Usage example:
$params = [
'buyer_sku_code' => 'xl10',
'customer_no' => '08123456789',
'ref_id' => 'some1d',
];
$pascaInquiry = \Gonon\Digiflazz\Transaction::inquiryPostpaid($params);
var_dump($pascaInquiry);
\Gonon\Digiflazz\Transaction::payPostpaid(array $params);
Parameters for this method
Name | Required | Description |
---|---|---|
buyer_sku_code |
yes |
Product SKU |
customer_no |
yes |
Customer number |
ref_id |
yes |
Your unique reference ID |
Usage example:
$params = [
'buyer_sku_code' => 'xl10',
'customer_no' => '08123456789',
'ref_id' => 'some1d',
];
$payPasca = \Gonon\Digiflazz\Transaction::payPostpaid($params);
var_dump($payPasca);
\Gonon\Digiflazz\Transaction::inquiryPLN(array $params);
Parameters for this method
Name | Required | Description |
---|---|---|
customer_no |
yes |
Customer number |
Usage example:
$params = [
'customer_no' => '123456789',
];
$iquiryPLN = \Gonon\Digiflazz\Transaction::inquiryPLN($params);
var_dump($iquiryPLN);
Use this method to get Callback
\Gonon\Digiflazz\Callback::getCallback();
Use this method to get JSON Callback
\Gonon\Digiflazz\Callback::getJsonCallback();
InvalidArgumentException
will be thrown if the argument provided by user is not sufficient to create the request.
For example, there are required arguments such as ref_id
, customer_no
, and buyer_sku_code
to create an transaction. If user lacks one or more arguments when attempting to create one, InvalidArgumentException
will be thrown.
InvalidArgumentException
is derived from PHP's InvalidArgumentException
. For more information about this Exception methods and properties, please check PHP Documentation.
ApiException
wraps up Digiflazz API error. This exception will be thrown if there are errors from Digiflazz API side.
To get exception message:
try {
$transaction = \Gonon\Digiflazz\Transaction::createTransaction(array $params);
} catch (\Gonon\Digiflazz\Exceptions\ApiException $e) {
var_dump($e->getMessage());
}
To get exception HTTP error code:
try {
$transaction = \Gonon\Digiflazz\Transaction::createTransaction(array $params);
} catch (\Gonon\Digiflazz\Exceptions\ApiException $e) {
var_dump($e->getCode());
}
To get exception Digiflazz API error code:
try {
$transaction = \Gonon\Digiflazz\Transaction::createTransaction(array $params);
} catch (\Gonon\Digiflazz\Exceptions\ApiException $e) {
var_dump($e->getErrorCode());
}
For any requests, bugs, or comments, please open an issue
Before you start to code, run this command to install all of the required packages. Make sure you have composer
installed in your computer
composer install
There is a pre-commit hook to run phpcs and phpcbf. Please make sure they passed before making commits/pushes.