Pay By Link (E-Invoice) - Using our APIS
if you already have your own dashboard and you want to generate e-invoices for your clients , you can login to fawry and generat e-invoices using our APIS
Login API
login to fawry with your own dashboard using Login API.
In case you are still in development phase, you will need to call our API using POST at the following staging endpoint API point URL
Meanwhile, whenever you are ready for production, you should use the following production API endpoint URL instead
Detailed description of the parameters that you need to incorporate into your POST request are given in the table below.
Parameter | type | Required | Description |
---|---|---|---|
userIdentifier | String |
required | Identify the user by User Name, E-mail or Phone Number. |
password | String |
required | User's password, required for authontication. |
Sample API Calls
An example call of login API is given below.
function login(transaction_data) {
const loginData = {
userIdentifier: transaction_data.userIdentifier,
password: transaction_data.password,
};
// Use fetch to send request data.
// https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
const response = await fetch('https://atfawry.fawrystaging.com/user-api/auth/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(loginData),
});
// Return and display the result of the charge.
return response.json();
}
$userIdentifier = '01234567899';
$password = "****";
$response =request('POST', 'https://atfawry.fawrystaging.com/user-api/auth/login', [
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json'
],
'body' => json_encode( [
'userIdentifier' => $userIdentifier,
'password' => $password,
] , true)
]);
$response = json_decode($response->getBody()->getContents(), true);
$loginData = $response['type']; // get response values
# importing the requests library
import requests
# importing Hash Library
import hashlib
# FawryPay login API Endpoint
URL = "https://atfawry.fawrystaging.com/user-api/auth/login"
# login Data
userIdentifier = '01234567899'
password = "****"
# defining a params dict for the parameters to be sent to the API
loginData = {
'userIdentifier' : userIdentifier,
'password' : password,
}
# sending get request and saving the response as response object
login_request = requests.get(url = URL, params = json.dumps(logintData))
# extracting data in json format
status_response = status_request.json()
function login() {
let userIdentifier = '01234567899';
let password = "****";
axios.get('https://atfawry.fawrystaging.com/user-api/auth/login', {
'userIdentifier' : userIdentifier,
'password' : password,
})
.then(response => {
// Get Response Contents
let loginData = response.data.loginData;
//
})
.catch(error => {
console.log(error.response.data)
})
}
$ curl https://atfawry.fawrystaging.com/user-api/auth/login\
-H "content-type: application/json" \
-X POST \
-d "{
"userIdentifier" : "01234567899",
"password" : "****",
}"
URL url = new URL ("https://atfawry.fawrystaging.com/user-api/auth/login");
HttpURLConnection con = (HttpURLConnection)url.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("Content-Type", "application/json; utf-8");
con.setRequestProperty("Accept", "application/json");
con.setDoOutput(true);
String jsonInputString = "{
"userIdentifier": "01234567899",
"password": "****",
}";
try(OutputStream os = con.getOutputStream()) {
byte[] input = jsonInputString.getBytes("utf-8");
os.write(input, 0, input.length);
}
try(BufferedReader br = new BufferedReader(
new InputStreamReader(con.getInputStream(), "utf-8"))) {
StringBuilder response = new StringBuilder();
String responseLine = null;
while ((responseLine = br.readLine()) != null) {
response.append(responseLine.trim());
}
System.out.println(response.toString());
}
using System;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using Newtonsoft.Json;
namespace FawryPayRequest
{
public class Program
{
static void Main(string[] args)
{
PostJson("https://atfawry.fawrystaging.com/user-api/auth/login", new login_request
{
userIdentifier = "01234567899",
password = "****",
});
}
private static void PostJson(string uri, login_request postParameters)
{
string postData = JsonConvert.SerializeObject(postParameters);
byte[] bytes = Encoding.UTF8.GetBytes(postData);
var httpWebRequest = (HttpWebRequest) WebRequest.Create(uri);
httpWebRequest.Method = "POST";
httpWebRequest.ContentLength = bytes.Length;
httpWebRequest.ContentType = "text/json";
using (Stream requestStream = httpWebRequest.GetRequestStream())
{
requestStream.Write(bytes, 0, bytes.Count());
}
var httpWebResponse = (HttpWebResponse) httpWebRequest.GetResponse();
if (httpWebResponse.StatusCode != HttpStatusCode.OK)
{
string message = String.Format("GET failed. Received HTTP {0}", httpWebResponse.StatusCode);
throw new ApplicationException(message);
}
}
}
public class login_request
{
public string userIdentifier { get; set; }
public string password { get; set; }
}
}
Request Parameters
Regardless of the choice of your preferred language, any of the code snippets above should produce an POST request containing the following JSON object in the request header:
{
"userIdentifier": "01234567899",
"password": "****"
}
Response Parameters
FawryPay Sample Response
Whenever you call Login API, you may expect a response in the form of JSON object which contains all login processing information.
Sample Login API Response
Response Parameters Description
Parameter | type | Description | example |
---|---|---|---|
token | String |
Used to allow the application to access the API. | MjxvQLYbauKzK0dNc5LSWKH5jVZhs0g6jMw7zpMjoCI |
refreshToken | String |
special kind of token used to obtain a renewed access token. You can request new access tokens until the refresh token is expired. | WF0IjoxNjE0NcwMyIsInVzdCI6IkJVU0lODI0n3MS0xMWMzLTQxZmM |
mustChangePassword | Boolean |
is set when the password is expired and you have to change the password. | false |
Error Handling
After submitting an API call to FawryPay, you receive a response back to inform you that your request was received and processed. A sample error response can be found below.
Depending on the HTTP status code of the response, you should build some logic to handle any errors that a request or the system may return. A list of possible potential error codes that you may receive can found below. For a full list of all possible error codes can be found in the Error Codes section.
Error Code | Description |
---|---|
200 | Operation done successfully. |
400 | Bad Request. |
POSThttps://atfawry.fawrystaging.com/user-api/auth/login
Response
// API Response Data Should Appear here
// This is a sample successful Response
{
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOlsiZnAiLCJpbnYiXSwic3ViIjoiMDEyMzQ1Njc4OTkiLCJybG0iOiJCRSIsImZwYSI6IjQwMDAwMDAwNDcwMyIsInVzdCI6IkJVU0lORVNTX0VOVElUWSIsImJlaSI6OTIsImlzcyI6ImZhd3J5LmNvbSIsImV4cCI6MTYxNDQyNzYxNSwiaWF0IjoxNjE0NDI0MDE1LCJqdGkiOiI5Y2QwZGE3MS0xMWMzLTQxZmMtOTc2ZS1jODA5MWVjNmI3NmEifQ.MjxvQLYbauKzK0dNc5LSWKH5jVZhs0g6jMw7zpMjoCI",
"refreshToken": "WF0IjoxNjE0NcwMyIsInVzdCI6IkJVU0lODI0n3MS0xMWMzLTQxZmM",
"mustChangePassword": false
}
Was this page helpful?
Thank you for helping improve FawryPay's documentation. If you need help or have any questions, please consider contacting support.