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'
Parameter | Type | Description | |
---|---|---|---|
customer | Json object | Customer name which will applied in checkout page ( it's a Json object ) | |
customer.first_name | String | customer first name (alphanumeric @ - _ . ) | Mandatory |
customer.last_name | String | customer last name (Mandatory) (alphanumeric @ - _ . ) | Mandatory |
customer.email | String | customer email | Optional |
customer.phone | Int | customer mobile | Optional |
customer.address | String | customer address (alphanumeric @ - _ . , : ) | Optional |
customer.customer_unique_id | String | Customer unique id at your end, mandatory for tokenization save card data. | Mandatory IF |
Cart Items | Json array | This contain your products/services which the customer buying it | |
cartitems.name | String | Product/service name | Mandatory |
cartitems.price | decimal | Item price | Mandatory |
cartitems.quantity | Integer | item quantity | Mandatory |
shipping | decimal | Add shipping as item | optional |
cartTotal | decimal | cart total | Mandatory |
currency | String | 'USD', 'EGP', 'SR', 'AED', 'KWD', 'QAR', 'BHD' | Mandatory |
frequency | String | 'once', 'weekly', 'biweekly', 'monthly', 'quarterly' Default:once | Optional |
discountData | JSON | Apply discount on the total amount | Optional |
discountData.type | String | "pcg" (percentage) or "literal" (fixed value) | |
discountData.value | Number | value between 1 - 99 | |
taxData | JSON | Apply percentage discount | Optional |
taxData.title | String | Name of the applied tax | |
taxData.value | Numeric | Percentage numeric value. | |
payLoad | Json | custom filed you can use if you need to connect sending data with receiving data after payment | Optional |
due_date | date Y-m-d | it's an optional field if you need | Optional |
sendEmail | true/false | send invoice notification through an email to your customer | Optional |
sendSMS | true/false | send invoice notification through SMS to your customer | Optional |
redirectionUrls | Json object | links that system will redirect to after customer pay | Optional |
redirectionUrls.successUrl | String | link will redirect to in case of payment process success | Optional |
redirectionUrls.failUrl | String | link will redirect to in case of payment process fail | Optional |
redirectionUrls.pendingUrl | String | this link using case customer choose to pay with payment methods like (fawry - aman) | Optional |
redirectionUrls.webhookUrl | String | Custom paid webhook URL, it overrides the URL in Fawaterak dashboard | 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
}
}