Code Monkey home page Code Monkey logo

digiflazz-php-library's Introduction

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.

digiflazz-php-library's People

Contributors

nurfaizfy avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.