EndPoint
Initiate Payment request
The "ExecutePayment" endpoint is a POST request.
It is used to create a Fawaterak transaction on the selected gateway.
Here is a sample code :
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://staging.fawaterk.com/api/v2/invoiceInitPay',
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 =>'{
"payment_method_id": 2,
"cartTotal": "50",
"currency": "EGP",
"invoice_number" : "123",
"customer": {
"first_name": "mohammad",
"last_name": "hamza",
"email": "[email protected]",
"phone": "01xxxxxxxxx",
"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);
var client = new RestClient("https://staging.fawaterk.com/api/v2/invoiceInitPay");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer d83a5d07aaeb8442dcbe259e6dae80a3f2e21a3a581e1a5acd");
request.AddHeader("Content-Type", "application/json");
var body = @"{" + "\n" +
@" ""payment_method_id"": 4," + "\n" +
@" ""cartTotal"": ""100""," + "\n" +
@" ""currency"": ""EGP""," + "\n" +
@" ""customer"": {" + "\n" +
@" ""first_name"": ""test""," + "\n" +
@" ""last_name"": ""test""," + "\n" +
@" ""email"": ""[email protected]""," + "\n" +
@" ""phone"": ""01000000000""," + "\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"": ""test""," + "\n" +
@" ""price"": ""100""," + "\n" +
@" ""quantity"": ""1""" + "\n" +
@" }" + "\n" +
@" ]" + "\n" +
@"}";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
var axios = require('axios');
var data = JSON.stringify({
"payment_method_id": 4,
"cartTotal": "100",
"currency": "EGP",
"customer": {
"first_name": "test",
"last_name": "test",
"email": "[email protected]",
"phone": "01000000000",
"address": "test address"
},
"redirectionUrls": {
"successUrl": "https://dev.fawaterk.com/success",
"failUrl": "https://dev.fawaterk.com/fail",
"pendingUrl": "https://dev.fawaterk.com/pending"
},
"cartItems": [
{
"name": "test",
"price": "100",
"quantity": "1"
}
]
});
var config = {
method: 'post',
url: 'https://staging.fawaterk.com/api/v2/invoiceInitPay',
headers: {
'Authorization': 'Bearer d83a5d07aaeb8442dcbe259e6dae80a3f2e21a3a581e1a5acd',
'Content-Type': 'application/json'
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import requests
import json
url = "https://staging.fawaterk.com/api/v2/invoiceInitPay"
payload = json.dumps({
"payment_method_id": 4,
"cartTotal": "100",
"currency": "EGP",
"customer": {
"first_name": "test",
"last_name": "test",
"email": "[email protected]",
"phone": "01000000000",
"address": "test address"
},
"redirectionUrls": {
"successUrl": "https://dev.fawaterk.com/success",
"failUrl": "https://dev.fawaterk.com/fail",
"pendingUrl": "https://dev.fawaterk.com/pending"
},
"cartItems": [
{
"name": "test",
"price": "100",
"quantity": "1"
}
]
})
headers = {
'Authorization': 'Bearer d83a5d07aaeb8442dcbe259e6dae80a3f2e21a3a581e1a5acd',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
Initiate payment response
1.Mastercard /Visa Response
{
"status": "success",
"data": {
"invoice_id": 1000428,
"invoice_key": "hyU2vcy3USvT5Tg",
"payment_data": {
"redirectTo": "https://staging.fawaterk.com/link/I0PAH"
}
}
}
2.Fawry Response
{
"status": "success",
"data": {
"invoice_id": 1000425,
"invoice_key": "QqgdnAB7Ad2kmIq",
"payment_data": {
"fawryCode": "981335305",
"expireDate": "2021-07-06 15:53:41"
}
}
}
3.MobileWallet Response
{
"status": "success",
"data": {
"invoice_id": 1000427,
"invoice_key": "2vX8jSkmqbwJ4Ls",
"payment_data": {
"meezaReference": 4266311,
"meezaQrCode":"00020101021226330016A00000073210000101096100559795204152053038185406106.565802EG5922Fawaterk Test Merchant6004Giza624505063424000105271000311116453477230707528640463047821"
}
}
}
4.Aman Response
{
"status": "success",
"data": {
"invoice_id": 1000424,
"invoice_key": "QqgdnAB7Ad2kmIq",
"payment_data": {
"amanCode": "1478581"
}
}
}
5.Basta Response
{
"status": "success",
"data": {
"invoice_id": 1000426,
"invoice_key": "QqgdnAB7Ad2kmIq",
"payment_data": {
"masaryCode": "1554222"
}
}
}
Request parameters Ref.:
Parameter | Type | Description | |
---|---|---|---|
payment_method_id | Int | id from Get payment methods (Step 1) | Mandatory |
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 (Mandatory) | Optional |
customer.phone | Int | customer mobile (Mandatory in case of Mobile Wallet payment method presented) | Optional |
customer.address | String | customer address (alphanumeric @ - _ . , : ) | Optional |
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 |
cartTotal | decimal | cart total | Mandatory |
currency | String | 'USD', 'EGP', 'SAR', 'AED', 'KWD', 'QAR', 'BHD' | Mandatory |
frequency | String | 'once', 'weekly', 'biweekly', 'monthly', 'quarterly' Default:once | Optional |
customExpireDate | String | +2 hours , +4 hours , +6 hours , +12 hours , +1 days , +2 days | 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. | |
authAndCapture | Int | 0 or 1 | Optional |
payLoad | Json | custom filed you can use if you need to connect sending data with receiving data after payment | Optional |
mobileWalletNumber | Int | customer mobile wallet number using only with mobile wallet payment method | 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 |
lang | string | en/ar , default en. The language to show the payment process after redirection. | Optional |
redirectOption | true/false | default false, this is to receive payment redirection URL regardless the payment method. So, you can redirect to Fawaterk to pay using Fawry code instead of handling show the code at your end. | 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 |