Developers

Payfric API

Introduction

This document is intended to assist software developers who want to develop applications using Payfric.com. It fully documents our application programming interface (API) that allows developers to interact with our system. To use the information provided here, you should first have access to an active Payfric.com account. Login to your Payfric.com account and set your api setting to allow api, every account default api on Payfric.com is dissallow api.

  • RESTful web services
  • HTTP/1.1
  • JSON (JavaScript Object Notation)

Application Program Interface will allow you to automate the process of making payment, receiving payment, fetching your account balance, fetching your account history of transactions within your own software. Since our API is based on REST principles, it's very easy to write and test applications. You can use your browser to access URLs, and you can use pretty much any HTTP client in any programming language to interact with the API. All responses from Payfric.com API are in JSON format.

Getting account balance

This section describes how to retrieve your payfric balance.

Resource URI

http://payfric.co/v1.0/secure.php/

Endpoint: /balance/$refrence

Send a Get request with the endpoint /balance/ and your wallet id.
For example, let say your wallet id is NPAYFRIC, then send a get request to
http://payfric.co/v1.0/secure.php/balance/NPAYFRIC
PHP Example code:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, http://payfric.co/v1.0/secure.php/balance/NPAYFRIC);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$request = curl_exec($ch);
curl_close($ch);
if ($request) {
$result = json_decode($request);
return $result;
}else{
return '';
}

RESPONSE
If the request was successful
{
"error": false,
"message": "Account Found",
"data": {
"balance": 2454.325,
"total_credit": 2500,
"total_debit": 45.675,
"user_id": 6
}
}
if the request failed
{
"error": true,
"message": "user id not found"
}

Accept Payment

This section describes how to accept payment from buyers.

A payment is performed by doing an HTML form post of POST to the URL: https://payfric.com/webpay/pay The following input fields are required:

Input field name Description Example Value
PAYMENT_AMOUNT The amoount you want to charge the buyer 1000
PAYMENT_WALLET Your payfric account number to receive the payment NPAYFRIC
PAYMENT_ID A 20 lenght generated string not more than 20 in lenght. UP9UTJ32WGDKJ0B0G93U
PAYMENT_URL A url to your site where the system will redirect to when payment is made http://example.com/confirm
NOPAYMENT_URL A url link to your site where payfric.com will redirect to when the payment was cancel http://example.com/cancel

Response

Upon confirmation, the system will redirect the user back to the appropriate url with a GET post with the following values

Input field name Description Example Value
reference The payment code UP9UTJ32WGDKJ0B0G93U
Amount The amount paid 1000

Confirm payment

This section describes how to confirm user payment.

Resource URI

http://payfric.co/v1.0/secure.php/

Endpoint: /confirmpayment/$refrence

Send a Get request with the endpoint /confirmpayment/ and the payment reference code.
For example, let say reference code is "JOIEFU0945JLGVJSIOE0R2PIRFLSD", then send a get request to
http://payfric.co/v1.0/secure.php/confirmpayment/JOIEFU0945JLGVJSIOE0R2PIRFLSD
PHP Example code:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, http://payfric.co/v1.0/secure.php/confirmpayment/JOIEFU0945JLGVJSIOE0R2PIRFLSD);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$request = curl_exec($ch);
curl_close($ch);
if ($request) {
$result = json_decode($request);
return $result;
}else{
return '';
}

RESPONSE
If the request was successful
{
"error": false,
"message": "Payment Confirmed",
"data": {
"amount": 10
}
}
if the request failed
{
"error": false,
"message": "Payment Confirmed",
"data": {
"amount": 0
}
}
Notice the amount the system return when the request failed. The amount return will be 0 which means you can stop the order.