Skip to content

nurfaizfy/digiflazz-php-library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Digiflazz PHP Library

Latest Stable Version Total Downloads License

This library is unofficial Digiflazz API written with PHP.


Documentation

For the API documentation, check Digiflazz API Reference.

Installation

Install digiflazz-php-library with composer by following command:

composer require nurfaizfy/digiflazz-php-library

or add it manually in your composer.json file.

Usage

Configure package with your account's secret key obtained from Digiflazz Dashboard.

use Gonon\Digiflazz\Digiflazz;
Digiflazz::initDigiflazz('username', 'apikey');

Methods' Signature and Examples

Balance

Get Balance

\Gonon\Digiflazz\Balance::getBalance();

Usage example:

$getBalance = \Gonon\Digiflazz\Balance::getBalance();
var_dump($getBalance);

Price List

Get Price List

\Gonon\Digiflazz\PriceList::getPrePaid(); // Prepaid product
\Gonon\Digiflazz\PriceList::getPostPaid(); // Postpaid product

Usage example:

$priceList = \Gonon\Digiflazz\PriceList::getPrePaid();
var_dump($priceList);

Deposit

Create Deposit Ticket

\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);

Transaction

Create Transaction

\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);

Inquiry Postpaid

\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);

Pay Postpaid

\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);

Inquiry PLN

\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);

Callback

Get Callback

Use this method to get Callback

\Gonon\Digiflazz\Callback::getCallback();

Use this method to get JSON Callback

\Gonon\Digiflazz\Callback::getJsonCallback();

Exceptions

InvalidArgumentException

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

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());
}

Contributing

For any requests, bugs, or comments, please open an issue

Installing Packages

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.