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
Get Invoices Statistics API
invoice-statistics to fawry using your own dashboard.
In case you are still in development phase, you will need to call our API using Get 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
Sample API Calls
An example call of Invoices Statistics API is given below.
// Use fetch to send request data to FawryPay Invoice Statistics API.
// https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
const response = await fetch('https://atfawry.fawrystaging.com/invoice-api/invoices/statistics', {
method: 'Get',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + transaction_data.token, // The token you obtained from the login API
}
}
);
// Return and display the result of the charge.
return response.json();
}
$response =request('Get', 'https://atfawry.fawrystaging.com/invoice-api/invoices/statistics', [
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Authorization' => 'Bearer ' + $token, // The token you obtained from the login API
]
] , true)
]);
$response = json_decode($response->GetBody()->GetContents(), true);
$invoiceStatisticsData = $response['type']; // Get response values
# importing the requests library
import requests
# importing Hash Library
import hashlib
# FawryPay invoices statistics API Endpoint
URL = "https://atfawry.fawrystaging.com/invoice-api/invoices/statistics"
# sending Get request and saving the response as response object
invoice_statistics_request = requests.Get(url = URL ,
headers={'Content-Type':'application/json',
'Authorization': 'Bearer {}'.AccessToken}//The token you obtained from the login API
)
# extracting data in json format
status_response = status_request.json()
function invoice_statistics() {
axios.Get('https://atfawry.fawrystaging.com/invoice-api/invoices/statistics',
headers: {
'Authorization': `Bearer AccessToken` //The token you obtained from the login API
}
)
.then(response => {
// Get Response Contents
let invoiceStatisticsData = response.data.invoiceStatisticsData;
//
})
.catch(error => {
console.log(error.response.data)
})
}
$ curl https://atfawry.fawrystaging.com/invoice-api/invoices/statistics\
-H "content-type: application/json , Authorization: Bearer ACCESS_TOKEN" \
-X Get \
URL url = new URL ("https://atfawry.fawrystaging.com/invoice-api/invoices/statistics");
HttpURLConnection con = (HttpURLConnection)url.openConnection();
con.setRequestMethod("Get");
con.setRequestProperty("Content-Type", "application/json; utf-8");
con.setRequestproperty("Authorization","Bearer " + AccessToken); //The token you obtained from the login API
con.setRequestProperty("Accept", "application/json");
con.setDoOutput(true);
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)
{
GetJson("https://atfawry.fawrystaging.com/invoice-api/invoices/statistics");
}
private static void GetJson(string uri, invoice_statistics_request GetParameters)
{
string GetData = JsonConvert.SerializeObject(GetParameters);
byte[] bytes = Encoding.UTF8.GetBytes(GetData);
var httpWebRequest = (HttpWebRequest) WebRequest.Create(uri);
httpWebRequest.Method = "Get";
httpWebRequest.ContentLength = bytes.Length;
httpWebRequest.Headers.Add("Authorization", "Bearer " + AccessToken);//The token you obtained from the login API
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);
}
}
}
}
Response Parameters
FawryPay Sample Response
Whenever you call FawryPay Invioces Statistics API, you may expect a response in the form of JSON object which contains all Invoices Statistics information.
Sample Invoices Statistics API Response
Response Parameters Description
Parameter | type | Description | example | |
---|---|---|---|---|
allInvoices | ||||
totalCount | integer |
Total count of all invoices. | 46 | |
totalAmount | double |
Total amount of all invoices. | 22787.5 | paidInvoices |
totalCount | integer |
Total count of paid invoices. | 1 | |
totalAmount | double |
Total amount of paid invoices. | 281.5 | unpaidInvoices |
totalCount | integer |
Total count of unpaid invoices. | 37 | |
totalAmount | double |
Total amount of unpaid invoices. | 15788.05 | expiredInvoices |
totalCount | integer |
Total count of expired invoices. | 2 | |
totalAmount | double |
Total amount of unpaid invoices. | 5202 | refundedInvoices |
totalCount | integer |
Total count of refunded invoices. | 0 | |
totalAmount | double |
Total amount of refunded invoices. | 0 | canceledInvoices |
totalCount | integer |
Total count of canceled invoices. | 6 | |
totalAmount | double |
Total amount of canceled invoices. | 1515.95 |
Gethttps://atfawry.fawrystaging.com/invoice-api/invoice-statistics
// please run login API and put your token in the token field below
Response
// API Response Data Should Appear here
// This is a sample successful Response
{
"allInvoices": {
"totalCount": 46,
"totalAmount": 22787.5
},
"paidInvoices": {
"totalCount": 1,
"totalAmount": 281.5
},
"unpaidInvoices": {
"totalCount": 37,
"totalAmount": 15788.05
},
"expiredInvoices": {
"totalCount": 2,
"totalAmount": 5202
},
"refundedInvoices": {
"totalCount": 0,
"totalAmount": 0
},
"canceledInvoices": {
"totalCount": 6,
"totalAmount": 1515.95
}
}
Was this page helpful?
Thank you for helping improve FawryPay's documentation. If you need help or have any questions, please consider contacting support.