Fasapay XML API client
API client which works with fasapay XML API https://www.fasapay.com/en/apiguide/index
Features
- Simple and OOP styled library
- Work with transactions API (transfer money, get transaction details, get transactions history)
- Work with accounts API (get info about account, get account balance)
- PHP7x support
- High quality clean and self documented code
- Full unit tested
- Can use as composer library
How to add Fasapay XML API support
- Login into your fasapay account
- Move to Account Access (API) -> Account API
- Press button Add API
- Fill API name and API_SECRETWORD fields
Requirements
- PHP7x
- Ext-SimpleXML
- Ext-Curl
Install
- Download archive from storage
- Unzip
- Move files to your project folder
- Add this string in your script require_once ’/path-to-library/vendor/autoload.php’;
For small size this zip archive packed after composer install—no-dev command and unit tests will not works, for fix this use composer install from root library directory
Configure
See examples folder
require_once '/path-to-library/vendor/autoload.php'; $config = (new KachitFasapayAPIConfig()) ->setApiKey('API key') ->setApiSecretWord('API secret word') ; $client = new KachitFasapayAPIClient($config);
Work with transactions
//Get transactions history $filter = (new KachitFasapayAPIResourceTransactionsHistoryFilter()) ->setStartDate('2018-08-01') ->setEndDate('2018-08-02') ; $response = $client->transactions()->history($filter); $data = $response->getData();
/* Response */ Array ( [history] => Array ( [page] => Array ( [total_item] => 2 [page_count] => 1 [current_page] => 0 ) [detail] => Array ( [0] => Array ( [batchnumber] => TR0123456789 [datetime] => 2016-09-28 12:49:33 [type] => Transfer In [to] => FP000001 [from] => FP00002 [amount] => 800000.000 [note] => Store comment [status] => FINISH [currency] => IDR [fee] => 0 ) [1] => Array ( [batchnumber] => TR0123456789 [datetime] => 2016-09-28 10:06:56 [type] => Transfer In [to] => FP000001 [from] => FP000002 [amount] => 200000.000 [note] => Store comment [status] => FINISH [currency] => IDR [fee] => 0 ) ) [@attributes] => Array ( [id] => 123456789 [date_time] => 2016-03-21T21:31:36+07:00 ) )
//Get transaction by external IDs $filter = (new KachitFasapayAPIResourceTransactionsDetailsFilter()) ->setDetails(['TR0123456789']); ; $response = $client->transactions()->details($filter); $data = $response->getData();
/* Response */ Array ( [detail] => Array ( [batchnumber] => TR0123456789 [date] => 2016-07-31 [time] => 20:58:08 [from] => FP000001 [to] => FP000002 [amount] => 500000.000 [total] => 500000.00 [currency] => IDR [note] => Store comment [status] => FINISH [fee] => 0 [type] => Transfer In [method] => sci [fee_mod] => FiS [@attributes] => Array ( [mode] => detail [code] => 000 ) ) [@attributes] => Array ( [id] => 123456789 [date_time] => 2016-03-21T21:42:39+07:00 ) )
//Transfer money to another account $transferParams = (new KachitFasapayAPIResourceTransactionsTransferParams()) ->setCurrency('IDR') ->setTo('FP000002') ->setNote('standard operation') ->setAmount(1000.0) ; $response = $client->transactions()->transfer($transferParams); $data = $response->getData();
/* Response */ Array ( [transfer] => Array ( [batchnumber] => TR0123456789 [date] => 2011-07-19 [time] => 14:06:35 [from] => FP000001 [to] => FP000002 [amount] => 1000.0 [fee] => 100 [total] => 1100.0 [fee_mode] => FiS [currency] => IDR [note] => standard operation [status] => FINISH [type] => Keluar [balance] => 2815832.00 [method] => xml_api ) [@attributes] => Array ( [id] => 123456789 [date_time] => 2016-03-21T21:48:03+07:00 ) )
Work with accounts
//Get balance for current account $balanceFilter = (new KachitFasapayAPIResourceAccountsBalanceFilter()) ->withIDR() ->withUSD() ; $response = $client->accounts()->balance($balanceFilter); $data = $response->getData();
/* Response */ Array ( [balance] => Array ( [IDR] => 0.00 [USD] => 0.00 ) [@attributes] => Array ( [id] => 123456789 [date_time] => 2016-03-21T21:46:41+07:00 ) )
//Get account details $filter = (new KachitFasapayAPIResourceAccountsDetailsFilter()) ->addAccount('FP000001') ; $response = $client->accounts()->details($filter); $data = $response->getData();
/* Response */ Array ( [account] => Array ( [fullname] => Test User [account] => FP000001 [status] => Active ) [@attributes] => Array ( [id] => 123456789 [date_time] => 2016-03-21T21:48:03+07:00 ) )
Change log
Version 1.0.1
- Update documentation
Kindly Note: We update new contents like WordPress Themes, Plugins, PHP Scripts everyday. But remember that you should never use this items in a commercial website. All the contents posted here for development & testing purpose only. We’re not responsible for any damage, use at your own RISK! We highly recommend to buy Fasapay XML API client from the The Developer ( kachit ) website. Thank you.
Download = Fasapay XML API client-[Updated].zip