API Reference

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.Fawry response

{
    "status": "success",
    "data": {
        "invoice_id": 1000425,
        "invoice_key": "QqgdnAB7Ad2kmIq",
        "payment_data": {
            "fawryCode": "981335305",
            "expireDate": "2021-07-06 15:53:41"
        }
    }
}

2.Meeza Responce

{
    "status": "success",
    "data": {
        "invoice_id": 1000427,
        "invoice_key": "2vX8jSkmqbwJ4Ls",
        "payment_data": {
            "meezaReference": 4266311,
          	"meezaQrCode":"00020101021226330016A00000073210000101096100559795204152053038185406106.565802EG5922Fawaterk Test Merchant6004Giza624505063424000105271000311116453477230707528640463047821"
        }
    }
}

3.Mastercard /Visa response

{
    "status": "success",
    "data": {
        "invoice_id": 1000428,
        "invoice_key": "hyU2vcy3USvT5Tg",
        "payment_data": {
            "redirectTo": "https://staging.fawaterk.com/link/I0PAH"
        }
    }
}

Request parameters Ref.:

ParameterTypeDescription
payment_method_idIntid from Get payment methods (Step 1)Mandatory
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
cartTotaldecimalcart totalMandatory
currencyString'USD', 'EGP', 'SAR', 'AED', 'KWD', 'QAR', 'BHD'Mandatory
frequencyString'once', 'weekly', 'biweekly', 'monthly', 'quarterly'
Default:once
Optional
customExpireDateString+2 hours , +4 hours , +6 hours , +12 hours , +1 days , +2 daysOptional
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.
authAndCaptureInt0 or 1Optional
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
langstringen/ar , default en. The language to show the payment process after redirection. Optional
redirectOptiontrue/falsedefault 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
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
redirectionUrls.webhookUrlStringCustom paid webhook URL, it overrides the URL in Fawaterak dashboardOptional