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.

Notice

To generate secrete key, your account must be verified on Payfric account.
First you verified your account then submit your request to for your secrete key to be generated. Thank you.

Getting account balance

This section describes how to retrieve your Payfric balance.

// Send GET OR POST WITH your secrete_key parameters and your payfric email address parameters $url = 'https://payfric.com/wp-json/payfric/v1/'; $endpoint = '/balance'; $secret_key = 'PfGhjjfimR20fljwHeqqKck7yXdQgRV6'; $email = '[email protected]'; //For example, if you are sending with a GET method, the full url will now be $url = 'https://payfric.com/wp-json/payfric/v1/balance/[email protected]il.com'

Now let us write an example code with PHP

$result = array(); $url = 'https://payfric.com/wp-json/payfric/v1/balance/[email protected]il.com' $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $request = curl_exec($ch); curl_close($ch); if ($request) { $result = json_decode($request); return $result; }else{ return ''; }

Response on Success

Notice the error data is 0;

{ "status": "OK", "response": "Response OK", "code": 200, "data": { "error": 0, "message": "Account found", "data": { "balance": 5836.045, "currency": "NGN" } } }

Response on Failure

Notice the error data is 1;

{ "status": "OK", "response": "Response OK", "code": 200, "data": { "error": 1, "message": "Account not found", "data": { "balance": 0, "currency": "NGN" } } }

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/ 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 email address to receive the payment [email protected]
PAYMENT_ID A 10 length generated string not more than 10 in length. UP9UTJ32WGDKJ0B0G93U
SECRETE KEY Your developer secrete key PfGhjjfimR20fljwHeqqKck7yXdQgRV6
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.

/** Send a GET OR POST request with the endpoint /confirm/ and the payment reference code. For example, let say reference code is "JOIEFU0945", then send a GET OR POST request to https://payfric.com/wp-json/payfric/v1/confirm/?secret_key=PfGhjjfimR20fljwHeqqKck7yXdQgRV6&reference=JOIEFU0945 **/

PHP Example code:

$url = "https://payfric.com/wp-json/payfric/v1/confirm/?secret_key=PfGhjjfimR20fljwHeqqKck7yXdQgRV6&reference=JOIEFU0945"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $request = curl_exec($ch); curl_close($ch); if ($request) { $result = json_decode($request); return $result; }else{ return ''; }

Response on Success

Notice the error data is 0;

{ "status": "OK", "response": "Response OK", "code": 200, "data": { "amount": 986, "error": 0, "message": "Payment Confirmed" } }

Response on Failure

Notice the error data is 1;

{ "status": "OK", "response": "Response OK", "code": 200, "data": { "amount": 0, "error": 1, "message": "Payment not successful" } }

Notice the amount the system return when the request failed. The amount return will be 0 which means you can stop the order.

Have an issue?