API Reference

The "SendPayment" endpoint is a POST request. It is used to create a Fawaterak invoice. Detailed functionality of how to create an invoice is explained in the Invoice Link section.

The endpoint on Swagger is Payment_SendPayment.

Now, we are going to declare the endpoint and its models along with each accepted parameter and possible value.

Request Header:

Add "Authorization": "Bearer {API key}" to request header.
Add 'Content-Type: application/json'

ParameterTypeDescription
customerJson objectCustomer name which will applied in checkout page ( it's a Json object )
customer.first_nameStringcustomer first name (alphanumeric @ - _ . )Mandatory
customer.last_nameStringcustomer last name (Mandatory) (alphanumeric @ - _ . )Mandatory
customer.emailStringcustomer email (Mandatory)Optional
customer.phoneIntcustomer mobile (Mandatory)Optional
customer.addressStringcustomer address (alphanumeric @ - _ . , : )Optional
Cart ItemsJson arrayThis contain your products/services which the customer buying it
cartitems.nameStringProduct/service nameMandatory
cartitems.pricedecimalItem priceMandatory
cartitems.quantityIntegeritem quantityMandatory
shippingdecimalAdd shipping as itemoptional
cartTotaldecimalcart totalMandatory
currencyString'USD', 'EGP', 'SR', 'AED', 'KWD', 'QAR', 'BHD'Mandatory
frequencyString'once', 'weekly', 'biweekly', 'monthly', 'quarterly'
Default:once
Optional
discountDataJSONApply discount on the total amountOptional
discountData.typeString"pcg" (percentage) or "literal" (fixed value)
discountData.valueNumbervalue between 1 - 99
taxDataJSONApply percentage discountOptional
taxData.titleStringName of the applied tax
taxData.valueNumeric Percentage numeric value.
payLoadJsoncustom filed you can use if you need to connect sending data with receiving data after paymentOptional
due_datedate Y-m-dit's an optional field if you needOptional
sendEmailtrue/falsesend invoice notification through an email to your customerOptional
sendSMStrue/falsesend invoice notification through SMS to your customerOptional
redirectionUrlsJson objectlinks that system will redirect to after customer payOptional
redirectionUrls.successUrlStringlink will redirect to in case of payment process successOptional
redirectionUrls.failUrlStringlink will redirect to in case of payment process failOptional
redirectionUrls.pendingUrlStringthis link using case customer choose to pay with payment methods like (fawry - aman)Optional

Sample code:

<?php
$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://staging.fawaterk.com/api/v2/createInvoiceLink',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "cartTotal": "50",
    "currency": "EGP",
    "customer": {
        "first_name": "mohammad",
        "last_name": "hamza",
        "email": "[email protected]",
        "phone": "011252523655",
        "address": "test address"
    },
    "redirectionUrls": {
         "successUrl" : "https://dev.fawaterk.com/success",
         "failUrl": "https://dev.fawaterk.com/fail",
         "pendingUrl": "https://dev.fawaterk.com/pending"   
    },
    "cartItems": [
        {
            "name": "this is test oop 112252",
            "price": "25",
            "quantity": "1"
        },
        {
            "name": "this is test oop 112252",
            "price": "25",
            "quantity": "1"
        }
    ]
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: Bearer d83a5d07aaeb8442dcbe259e6dae80a3f2e21a3a581e1a5acd'
  ),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var client = new RestClient("https://staging.fawaterk.com/api/v2/createInvoiceLink");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer d83a5d07aaeb8442dcbe259e6dae80a3f2e21a3a581e1a5acd");
request.AddHeader("Content-Type", "application/json");
var body = @"{" + "\n" +
@"    ""cartTotal"": ""50""," + "\n" +
@"    ""currency"": ""EGP""," + "\n" +
@"    ""customer"": {" + "\n" +
@"        ""first_name"": ""mohammad""," + "\n" +
@"        ""last_name"": ""hamza""," + "\n" +
@"        ""email"": ""[email protected]""," + "\n" +
@"        ""phone"": ""0123456789""," + "\n" +
@"        ""address"": ""test address""" + "\n" +
@"    }," + "\n" +
@"    ""redirectionUrls"": {" + "\n" +
@"        ""successUrl"": ""https://dev.fawaterk.com/success""," + "\n" +
@"        ""failUrl"": ""https://dev.fawaterk.com/fail""," + "\n" +
@"        ""pendingUrl"": ""https://dev.fawaterk.com/pending""" + "\n" +
@"    }," + "\n" +
@"    ""cartItems"": [" + "\n" +
@"        {" + "\n" +
@"            ""name"": ""this is test oop 112252""," + "\n" +
@"            ""price"": ""25""," + "\n" +
@"            ""quantity"": ""1""" + "\n" +
@"        }," + "\n" +
@"        {" + "\n" +
@"            ""name"": ""this is test oop 112252""," + "\n" +
@"            ""price"": ""25""," + "\n" +
@"            ""quantity"": ""1""" + "\n" +
@"        }" + "\n" +
@"    ]" + "\n" +
@"}";
request.AddParameter("application/json", body,  ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer 1be20fd63420d7023d2c0b4d00befb43df4707be1b800c373a");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
  "cartItems": [
    {
      "name": "this is test oop 112252",
      "price": "25",
      "quantity": "1"
    },
    {
      "name": "this is test oop 112252",
      "price": "25",
      "quantity": "1"
    }
  ],
  "cartTotal": 50,
  "shipping": 0,
  "customer": {
    "first_name": "mohammad",
    "last_name": "hamza",
    "email": "[email protected]",
    "phone": "0123456789",
    "address": "test address"
  },
  "currency": "EGP",
  "payLoad": {},
  "sendEmail": true,
  "sendSMS": false
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://staging.fawaterk.com/api/v2/createInvoiceLink", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
import requests
import json

url = "https://staging.fawaterk.com/api/v2/createInvoiceLink"

payload = json.dumps({
  "cartTotal": "50",
  "currency": "EGP",
  "customer": {
    "first_name": "mohammad",
    "last_name": "hamza",
    "email": "[email protected]",
    "phone": "0123456789",
    "address": "test address"
  },
  "redirectionUrls": {
    "successUrl": "https://dev.fawaterk.com/success",
    "failUrl": "https://dev.fawaterk.com/fail",
    "pendingUrl": "https://dev.fawaterk.com/pending"
  },
  "cartItems": [
    {
      "name": "this is test oop 112252",
      "price": "25",
      "quantity": "1"
    },
    {
      "name": "this is test oop 112252",
      "price": "25",
      "quantity": "1"
    }
  ]
})
headers = {
  'Authorization': 'Bearer d83a5d07aaeb8442dcbe259e6dae80a3f2e21a3a581e1a5acd',
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

Response Body

{
    "status": "success",
    "data": {
        "url": "https://staging.fawaterk.com/link/H7cGZ",
        "invoiceKey": "ONdN0pVvP9x1IZe",
        "invoiceId": 167
    }
}