This is an API for payment disbursement that retrieves-sends data from the Slightly-big API. This API was created using PHP and Codeigniter.
There are 2 ways to deploy this project, you can choose one of them.
- Clone this git
https://github.com/goodguydul/flip-disburse-api.git
to your htdocs / server. - Import .sql file which provided in the source code to your database.
- If your server have cron, set this command to the cron job :
curl <your-base-url>/check/action
. You can set time interval to triggercron.php
every 30s, 1 minute, etc. This is used to trigger method to check updated data from API endpoint (Slightly-big).
- Clone this git
https://github.com/goodguydul/flip-disburse-api.git
to your Github. - Connect your Heroku account with your Github account, and then set automatic deployment in your Heroku account. You can follow this tutorial here : Tutorial Github + Heroku
- For importing the database, you can follow this tutorial : Here
- Don't forget to add ClearDB and Heroku Scheduler add-ons to your heroku project. Add credit card to your Heroku Billing so your account will be verified and you'll be able to use those addons.
- Heroku scheduler is used as "cron-job" for disburse data update checker. And ClearDB as database.
The general config is in application/config/config.php
The database config is in application/config/database.php
// FOR HEROKU APP
$actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
if (strpos($actual_link, 'localhost') == false || strpos($actual_link, 'heroku')) {
$cleardb_url = parse_url(getenv("CLEARDB_DATABASE_URL"));
$db_server = $cleardb_url["host"];
$db_username = $cleardb_url["user"];
$db_password = $cleardb_url["pass"];
$db_name = substr($cleardb_url["path"],1);
} else {
$db_server = 'localhost';
$db_username = 'root';
$db_password = '';
$db_name = 'flip';
}
Change
$db_server,$db_username, $db_password, $db_name
value if you use localhost / server. If you use heroku, just skip it.
The rest api config is in application/config/rest.php
$config['rest_realm'] = 'REST API';
$config['rest_auth'] = 'basic';
$config['rest_valid_logins'] = ['admin' => '1234'];
change
rest_auth
andrest_valid_logins
value if you want to change the credentials for login API.
This API used basic authentication, so on every request, you must enter a username and password.
Credentials:
username: admin
password: 1234
you can change the credentials refer to here
Base url for all request is: https://flip-disburse-api.herokuapp.com/api
variable | data type |
---|---|
id | bigint |
amount | int |
status | varchar |
timestamp | datetime |
bank_code | varchar |
account_number | bigint |
beneficiary_name | varchar |
remark | varchar |
receipt | text |
time_served | datetime |
fee | int |
METHOD : POST
URL : https://flip-disburse-api.herokuapp.com/api/add
EXAMPLE:
METHOD : GET
URL : https://flip-disburse-api.herokuapp.com/api
URL (with id) : https://flip-disburse-api.herokuapp.com/api?id={id transaction}
EXAMPLE:
Note: this is
update
only for this API, on update checker we use different method.
METHOD : PUT
URL : https://flip-disburse-api.herokuapp.com/api/update
EXAMPLE:
METHOD : DELETE
URL : https://flip-disburse-api.herokuapp.com/api/delete
EXAMPLE:
For update checker, url is https://flip-disburse-api.herokuapp.com/check/action
This auto update checker is triggered every 30s. This setting can be changed on file cron.php
:
$appRoot = "https://flip-disburse-api.herokuapp.com";
$cmd = "curl $appRoot/check/action";
$sleep = 30; // IN SECOND. CHANGE THIS VALUE TO CHANGE THE TIME INTERVAL
while (true) {
exec($cmd);
sleep($sleep);
}
This cron.php is executed in ProcFile when the app is deployed / re-deployed.
There are several resources used in this API. Thanks to the dev.