shell php csharp javascript html

Introduction

Fatora gateway provides robust features for processing online payments, it processes payments securely and conveniently in real time.

Start With Fatora Gateway

If you are new to Fatora gateway, you have to subscribe at the beginning.
To subscribe, you have to send the following information to Maktapp support.

After subscription, Maktapp support will send you an APIKEY, which is provide to merchant, and later you will use it in calling Fatora API.

Steps Of Payment

An online payment goes through the following steps:

1. Initialize payment:

2. Process payment:

3. Verify request source:

Tokenization

Fatora gateway support tokenization to save your clients from having to re-enter card details in checkout page in each time they pay from your application. This will improve clients' user experience when making payments through your application.

Examples:

1.Autosave payment

When a client makes his first purchase in your application, after processing payment and in success case Fatora gateway will send token (which is Card Token) to your application, your application should save it.

Therefore, when the client returns to your application to make another purchase, your application should send this token to Fatora gateway to use it in deducting amount directly from the client account without redirecting him to the checkout page.

2.Recurring payment or subscription

When a client subscribes in a service in your application, after processing subscription and in success case, Fatora gateway will send token to your application.

Therefore, in each time a payment is due, your application will send this token to Fatora gateway to use it in deducting amount from the client account automatically.

Payment

Onetime Payment

<? php
init();
function init()
{
 $url = 'https://maktapp.credit/v3/AddTransaction';
 $data = array(
 'token'           => "E4B73FEE-F492-4607-A38D-852B0EBC91C9",
 'FcmToken'        => "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
 'currencyCode'    => "XXX", 
 'orderId'         => "XXXXXXX",
 'amount'          =>  XXXX, 
 'customerEmail'   => "XXXX",
 'customerName'    => "XXXX",
 'customerPhone'   => "XXXX",
 'customerCountry' => "XXXX",
 'lang'            => "ar",
 'note'            => "XXXXX"
);

 $response = curl_post( $url , $data );
 $data_json_decode = json_decode($response);
 $result = $data_json_decode->{'result'};

 return  $result;
}

function curl_post($url, array $post = NULL, array $options = array())
{ 
 $defaults = array(
 CURLOPT_POST           => 1,
 CURLOPT_HEADER         => 0,
 CURLOPT_URL            => $url,
 CURLOPT_FRESH_CONNECT  => 1,
 CURLOPT_RETURNTRANSFER => 1,
 CURLOPT_FORBID_REUSE   => 1,
 CURLOPT_TIMEOUT        => 500,
 CURLOPT_POSTFIELDS     => http_build_query($post)
 );
 $ch = curl_init();
 curl_setopt_array($ch, ($options + $defaults));
 if( ! $result = curl_exec($ch))
 {
 trigger_error(curl_error($ch));
 }
 curl_close($ch);
 return $result;
}
?>
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | 
                                       SecurityProtocolType.Tls   | SecurityProtocolType.Ssl3;
string apiUrl = "https://maktapp.credit/v3/AddTransaction ";
using (WebClient wc = new WebClient())
{
wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
System.Collections.Specialized.NameValueCollection postData = new System.Collections.Specialized.NameValueCollection();
 {
    {"token", "E4B73FEE-F492-4607-A38D-852B0EBC91C9"}, 
    {"FcmToken", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"},
    {"currencyCode", "XXX"},
    {"orderId", "XXXXXXX"}, 
    {"amount", XXX},
    {"customerEmail", "XXXX"},   
    {"customerName",  "XXXX"},
    {"customerPhone", "XXXX"},
    {"customerCountry", "XXXX"},  
    {"lang", "ar"}, 
    {"note", "testpayment"}
 };
var res       = wc.UploadValues(apiUrl, postData);
string resStr = Encoding.UTF8.GetString(res);
}
<form>
<input type="button" id="SubmitPay" name="SubmitPay" value="submit" onclick="return pay();" />
</form>
<script>
function pay() {    
    var dataToPost = {
    "token": "E4B73FEE-F492-4607-A38D-852B0EBC91C9",
    "FcmToken ":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    "currencyCode": "XXX",
    "orderId": "XXXXXXX",
    "amount": XXXX,      
    "customerEmail": "XXXX",
    "customerName":"XXXX",
    "customerPhone":"XXXX",
    "customerCountry": "XXXX",
    "lang": "ar",
    "note": ""                
      };

    $.ajax({            
    url: 'https://maktapp.credit/v3/AddTransaction',
    data: dataToPost,
    type: "POST",
    dataType: "json",
    success: function (res) {                
             window.location.href = res.result;                                
        },
    error: function (result) {               
            alert("error: " + result);
        }
    });        
}
</script>

#POST curl https://maktapp.credit/v3/AddTransaction 
-H "Content-Type: application/json" 
-d ' {
"token":"E4B73FEE-F492-4607-A38D-852B0EBC91C9",
"FcmToken":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"currencyCode":"XXX", 
"orderId":"XXXXXXX", 
"amount":XXXX,
"customerEmail":"XXXX",
"customerName":"XXXX",
"customerPhone":"XXXX",
"customerCountry":"XXX",
"lang":"ar", 
"note":"XXXX"
}'

The above request will returns JSON structured if all parameters are valid like this:

{ 
    "result": "https://maktapp.credit/pay/MCPaymentPage?paymentID=XXXXXXXXXX" 
}

The above request will returns JSON structured if one parameter is null or not valid like this:

{ 
    "result": x 
} [-1, -2, -3, -6, -8, -10, -20, -21 ] 


This API allows the merchant application to initialize a onetime payment and get the URL of checkout page.

HTTP Request

POST https://maktapp.credit/v3/AddTransaction

Request Parameters

Parameter Restriction Description
token Required String value.
API token.
FcmToken Optional String value.
Mobile FCM Token.
currencyCode Optional String value.
currency code of your country as an ISO 4217 alpha code.
The default code is QAR.
If you want to support more than one currency, contact with Maktapp support.
orderId Required String value.
A unique identifier for each payment in your application.
amount Required Decimal value.
Payment amount that will be deducted from the client account.
customerEmail Required String value, it should have valid email address format.
Client email address.
customerName Optional String value.
Client Name.
customerPhone Optional String value.
Client phone, including country code.
customerCountry Optional String value.
Client country.
lang Optional String value, it should have one of these value{"en","ar"}.
Language of checkout page.
Default value is "ar".
note Optional String value.
Notes about the payment.

If all the required parameters are valid, Fatora gateway will return URL of checkout page in a JSON format, like following:

Response JSON

{ "result": "https://maktapp.credit/pay/MCPaymentPage?paymentID=XXXXXXXXXX" }

If the value of one parameter are not valid, Fatora gateway will return a response in JSON format containing error code, like following:

Response JSON

{ "result": x } [-1, -2, -3, -6, -8, -10, -20, -21 ]

After getting the URL of checkout page, the merchant application should redirect his client to this URL, when the client enters his card data in checkout page and clicks on pay button, Fatora gateway will process the payment and redirects the client to success or failure page of the merchant application.

In success case, Fatora gateway will redirect client to merchant success page, and will request the merchant success page with the following parameters:

Redirect to success page

Merchant_SUCCESS_URL?transId=XXX&orderId=XXX&mode=XXX

In failure case, Fatora gateway will redirect client to merchant failure page, and will request merchant failure page with the following parameters:

Redirect to failure page

Merchant_FAILURE_URL?transId=XXX&orderId=XXX&Failerdescription=XXX

Request Parameters

Parameter Description
transId Transaction id of payment created by bank.
orderId OrderId of payment(sent by your application at requesting Initialize Payment API).
mode It has one of the following values {"test", "live"} according to merchant mode.
Failerdescription It describes why the payment is failed.

Recurring Payment

<? php
init();
function init()
{
 $url = 'https://maktapp.credit/v3/AddTransaction';
 $data = array(
 'token'           => "E4B73FEE-F492-4607-A38D-852B0EBC91C9",
 'FcmToken'        => "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
 'currencyCode'    => "XXX", 
 'orderId'         => "XXXXXXX",
 'amount'          =>  XXXX, 
 'customerEmail'   => "XXXX",
 'customerName'    => "XXXX",
 'customerPhone'   => "XXXX",
 'customerCountry' => "XXXX",
 'lang'            => "ar",
 'isRecurring'     => true, 
 'note'            => "XXXXX"
);

 $response = curl_post( $url , $data );
 $data_json_decode = json_decode($response);
 $result = $data_json_decode->{'result'};

 return  $result;
}

function curl_post($url, array $post = NULL, array $options = array())
{ 
 $defaults = array(
 CURLOPT_POST           => 1,
 CURLOPT_HEADER         => 0,
 CURLOPT_URL            => $url,
 CURLOPT_FRESH_CONNECT  => 1,
 CURLOPT_RETURNTRANSFER => 1,
 CURLOPT_FORBID_REUSE   => 1,
 CURLOPT_TIMEOUT        => 500,
 CURLOPT_POSTFIELDS     => http_build_query($post)
 );
 $ch = curl_init();
 curl_setopt_array($ch, ($options + $defaults));
 if( ! $result = curl_exec($ch))
 {
 trigger_error(curl_error($ch));
 }
 curl_close($ch);
 return $result;
}
?>
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | 
                                       SecurityProtocolType.Tls   | SecurityProtocolType.Ssl3;
string apiUrl = "https://maktapp.credit/v3/AddTransaction ";
using (WebClient wc = new WebClient())
{
wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
System.Collections.Specialized.NameValueCollection postData = new System.Collections.Specialized.NameValueCollection();
 {
    {"token", "E4B73FEE-F492-4607-A38D-852B0EBC91C9"}, 
    {"FcmToken", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"},
    {"currencyCode", "XXX"},
    {"orderId", "XXXXXXX"}, 
    {"amount", XXX},
    {"customerEmail", "XXXX"},   
    {"customerName",  "XXXX"},
    {"customerPhone", "XXXX"},
    {"customerCountry", "XXXX"},  
    {"lang", "ar"},
    {"isRecurring", true},  
    {"note", "testpayment"}
 };
var res = wc.UploadValues(apiUrl, postData);
string resStr = Encoding.UTF8.GetString(res);
}
<form>
<input type="button" id="SubmitPay" name="SubmitPay" value="submit" onclick="return pay();" />
</form>
<script>
function pay() {    
    var dataToPost = {
    "token": "E4B73FEE-F492-4607-A38D-852B0EBC91C9",
    "FcmToken ":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    "currencyCode": "XXX",
    "orderId": "XXXXXXX",
    "amount": XXXX,      
    "customerEmail": "XXXX",
    "customerName":"XXXX",
    "customerPhone":"XXXX",
    "customerCountry": "XXXX",
    "lang": "ar",
    "isRecurring":true, 
    "note": ""                     
      }; 

    $.ajax({            
    url: 'https://maktapp.credit/v3/AddTransaction',
    data: dataToPost,
    type: "POST",
    dataType: "json",
    success: function (res) {                
             window.location.href = res.result;                                
        },
    error: function (result) {               
            alert("error: " + result);
        }
    });        
}
</script>

#POST curl https://maktapp.credit/v3/AddTransaction 
-H "Content-Type: application/json" 
-d ' {
"token":"E4B73FEE-F492-4607-A38D-852B0EBC91C9",
"FcmToken":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"currencyCode":"XXX", 
"orderId":"XXXXXXX", 
"amount":XXXX,
"customerEmail":"XXXX",
"customerName":"XXXX",
"customerPhone":"XXXX",
"customerCountry":"XXX",
"lang":"ar",
"isRecurring":true, 
"note":"XXXX" 
}' 

The above request will returns JSON structured if all parameters are valid:

{ 
    "result": "https://maktapp.credit/pay/MCPaymentPage?paymentID=XXXXXXXXXX" 
}

The above request will returns JSON structured if one parameter is null or not valid:

{ 
    "result": x
}  [-1, -2, -3, -6, -8, -10, -20, -21 ]

This API allows the merchant application to initialize a recurring payment and get the URL of checkout page.

HTTP Request

POST https://maktapp.credit/v3/AddTransaction

Request Parameters

Parameter Restriction Description
token Required String value.
API token.
FcmToken Optional String value.
Mobile FCM Token.
currencyCode Optional String value.
currency code of your country as an ISO 4217 alpha code.
The default code is QAR.
If you want to support more thant one currency, contact with Maktapp support.
orderId Required String value.
A unique identifier for each payment in your application.
amount Required Decimal value.
Payment amount that will be deducted from the client's account.
customerEmail Required String value, it should have valid email address format.
Clients email address.
isRecurring Optional Boolean value.
To indicate the payment is recurring or not.
customerName Optional String value.
Clients Name.
customerPhone Optional String value.
Clients phone, including country code.
customerCountry Optional String value.
Clients country.
lang Optional String value, it should have one of these value{"en","ar"}.
Language of checkout page..
Default value is "ar".
note Optional String value.
Notes about the payment.

If all the required parameter are valid, Fatora gateway will return URL of checkout page in a JSON format, like following:

Response JSON

{ "result": "https://maktapp.credit/pay/MCPaymentPage?paymentID=XXXXXXXXXX" }

If the value of one parameter are not valid, Fatora gateway will return a response in JSON format containing error code, like following:

Response JSON

{ "result": x } [-1, -2, -3, -6, -8, -10, -20, -21 ]

After getting URL of checkout page, the merchant application should redirect the client to this page, when the client enters his card data in checkout page and clicks on pay button, Fatora gateway will process payment and redirects the client to success or failure page in the merchant application.

In success case, Fatora gateway will redirect client to merchant success page, and will request the merchant success page with the following parameters

Redirect to success page

Merchat_SUCCESS_URL?orderId=XXX&transId=XXX&token=XXX&mode=XXX

In failure case, Fatora gateway will redirect client to merchant failure page, and will request the merchant failure page with the following parameters:

Redirect to failure page

Merchat_FAILURE_URL?orderId=XXX&transId=XXX&token=XXX&mode=XXX&Failerdescription=XXX

Request Parameters

Parameter Description
transId Transaction id of payment created by bank.
orderId OrderId of payment(sent by your application at requesting initialize Payment API).
mode It has one of the following values {"test", "live"} according to merchant's mode.
cardToken Unique identifier extracted from card detail, you will use it to get a new payment from client automatically when the next payments is due.
Failerdescription It describes why the payment is failed.

Autosave Payment

<? php
init();
function init()
{
 $url = 'https://maktapp.credit/v3/AddTransaction';
 $data = array(
 'token'           => "E4B73FEE-F492-4607-A38D-852B0EBC91C9",
 'FcmToken'        => "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
 'currencyCode'    => "XXX", 
 'orderId'         => "XXXXXXX",
 'amount'          =>  XXXX, 
 'customerEmail'   => "XXXX",
 'customerName'    => "XXXX",
 'customerPhone'   => "XXXX",
 'customerCountry' => "XXXX",
 'lang'            => "ar",
 'isRecurring'     => false,
 'autoSave'        => "yes",  
 'note'            => "XXXXX"
 );

 $response = curl_post( $url , $data );
 $data_json_decode = json_decode($response);
 $result = $data_json_decode->{'result'};

 return  $result;
}

function curl_post($url, array $post = NULL, array $options = array())
{ 
 $defaults = array(
 CURLOPT_POST           => 1,
 CURLOPT_HEADER         => 0,
 CURLOPT_URL            => $url,
 CURLOPT_FRESH_CONNECT  => 1,
 CURLOPT_RETURNTRANSFER => 1,
 CURLOPT_FORBID_REUSE   => 1,
 CURLOPT_TIMEOUT        => 500,
 CURLOPT_POSTFIELDS     => http_build_query($post)
 );
 $ch = curl_init();
 curl_setopt_array($ch, ($options + $defaults));
 if( ! $result = curl_exec($ch))
 {
 trigger_error(curl_error($ch));
 }
 curl_close($ch);
 return $result;
}
?>
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | 
                                       SecurityProtocolType.Tls   | SecurityProtocolType.Ssl3;
string apiUrl = "https://maktapp.credit/v3/AddTransaction ";
using (WebClient wc = new WebClient())
{
wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
System.Collections.Specialized.NameValueCollection postData = new System.Collections.Specialized.NameValueCollection();
 {
    {"token", "E4B73FEE-F492-4607-A38D-852B0EBC91C9"}, 
    {"FcmToken", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"},
    {"currencyCode", "XXX"},
    {"orderId", "XXXXXXX"}, 
    {"amount", XXX},
    {"customerEmail", "XXXX"},   
    {"customerName",  "XXXX"},
    {"customerPhone", "XXXX"},
    {"customerCountry", "XXXX"},  
    {"lang", "ar"},
    {"isRecurring" false},
    {"autoSave" ,"yes"},
    {"note", "XXXX"}
 };
var res = wc.UploadValues(apiUrl, postData);
string resStr = Encoding.UTF8.GetString(res);
}
<form>
<input type="button" id="SubmitPay" name="SubmitPay" value="submit" onclick="return pay();" />
</form>
<script>
function pay() {    
    var dataToPost = {
    "token": "E4B73FEE-F492-4607-A38D-852B0EBC91C9",
    "FcmToken ":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    "currencyCode": "XXX",
    "orderId": "XXXXXXX",
    "amount": XXXX,      
    "customerEmail": "XXXX",
    "customerName":"XXXX",
    "customerPhone":"XXXX",
    "customerCountry": "XXXX",
    "lang": "ar",
    "isRecurring":false, 
    "autoSave":"yes",  
    "note": ""                      
      };  

    $.ajax({            
    url: 'https://maktapp.credit/v3/AddTransaction',
    data: dataToPost,
    type: "POST",
    dataType: "json",
    success: function (res) {                
        window.location.href = res.result;                                
    },
    error: function (result) {               
        alert("error: " + result);
    }
    });        
}
</script>

#POST curl https://maktapp.credit/v3/AddTransaction 
-H "Content-Type: application/json" 
-d ' {
"token":"E4B73FEE-F492-4607-A38D-852B0EBC91C9",
"FcmToken":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"currencyCode":"XXX", 
"orderId":"XXXXXXX", 
"amount":XXXX,
"customerEmail":"XXXX",
"customerName":"XXXX",
"customerPhone":"XXXX",
"customerCountry":"XXX",
"lang":"ar",
"isRecurring": false,  
"autoSave": "yes",  
"note": "XXXX"
}' 

The above request will returns JSON structured if all parameters are valid:

{ 
    "result": "https://maktapp.credit/pay/MCPaymentPage?paymentID=XXXXXXXXXX" 
}

The above request will returns JSON structured if one parameter is null or not valid:

{ 
    "result": x 
} [-1, -2, -3, -6, -8, -10, -20, -21 ] 

This API allows the merchant application to initialize an autosave payment and get the URL of checkout page.

HTTP Request

POST https://maktapp.credit/v3/AddTransaction

Request Parameters

Parameter Restriction Description
token Required String value.
API token.
FcmToken Optional String value.
Mobile FCM Token.
currencyCode Optional String value.
currency code of your country as an ISO 4217 alpha code.
The default code is QAR.
If you want to support more than one currency, contact with Maktapp support.
orderId Required String value.
A unique identifier for each payment in your application.
amount Required Decimal value.
Payment amount that will be deducted from the client account.
customerEmail Required String value, it should have valid email address format.
Client email address.
autosave Optional String value, should have one of the following values {"no", "yes"}.
To indicate if it is auto save payment or not.
customerName Optional String value.
Client Name.
customerPhone Optional String value.
Client phone, including country code.
customerCountry Optional String value.
Client country.
lang Optional String value, it should have one of these value{"en","ar"}.
Language of checkout page..
Default value is "ar".
note Optional String value.
Notes about the payment.

If all the required parameter are valid, Fatora gateway will return URL of checkout page in a JSON format, like following:

Response JSON

{ "result": "https://maktapp.credit/pay/MCPaymentPage?paymentID=XXXXXXXXXX" }

If the values of one parameter are not valid, Fatora gateway will return a response in JSON format containing error code, like following:

Response JSON

{ "result": x } [-1, -2, -3, -6, -8, -10, -20, -21 ]

After getting URL of checkout page, the merchant application redirects the client to this page, when the client enters his card data in checkout page and clicks on pay button, Fatora API will proccess payment and redirects the client to success or failure page.

In success case, Fatora gateway will redirect client to merchant success page, and will request the merchant success page with the following parameters:

Redirect to success page

Merchat_SUCCESS_URL?orderId=XXX&transId=XXX&token=XXX&mode=XXX

In failure case, Fatora gateway will redirect client to merchant failure page, and will call merchant failure page with the following parameters:

Redirect to failure page

Merchat_FAILURE_URL?orderId=XXX&transId=XXX&token=XXX&mode=XXX&Failerdescription=XXX

Request Parameters

Parameter Description
transId Transaction id of payment created by bank.
orderId OrderId of payment(sent by your application at requesting Initialize API).
mode It has one of the following values {"test", "live"} according to merchant mode.
cardToken Unique identifier extracted from card detail, you will use it to deduct amount from client directly when he makes another purchase in your application without redirecting him to checkout page.
Failedescription It describes why the payment is failed.

Get Card Token

<? php
init();
function init()
{
 $url = 'https://maktapp.credit/v3/AddTransaction';
 $data = array(
 'token'           => "E4B73FEE-F492-4607-A38D-852B0EBC91C9",
 'FcmToken'        => "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
 'currencyCode'    => "XXX", 
 'orderId'         => "XXXXXXX",
 'amount'          =>  XXXX, 
 'customerEmail'   => "XXXX",
 'customerName'    => "XXXX",
 'customerPhone'   => "XXXX",
 'customerCountry' => "XXXX",
 'lang'            => "ar",
 'isRecurring'     => true, 
 'isVoid'          => true,  
 'note'            => "XXXXX"
 );

 $response = curl_post( $url , $data );
 $data_json_decode = json_decode($response);
 $result = $data_json_decode->{'result'};

 return  $result;
}

function curl_post($url, array $post = NULL, array $options = array())
{ 
 $defaults = array(
 CURLOPT_POST           => 1,
 CURLOPT_HEADER         => 0,
 CURLOPT_URL            => $url,
 CURLOPT_FRESH_CONNECT  => 1,
 CURLOPT_RETURNTRANSFER => 1,
 CURLOPT_FORBID_REUSE   => 1,
 CURLOPT_TIMEOUT        => 500,
 CURLOPT_POSTFIELDS     => http_build_query($post)
 );
 $ch = curl_init();
 curl_setopt_array($ch, ($options + $defaults));
 if( ! $result = curl_exec($ch))
 {
 trigger_error(curl_error($ch));
 }
 curl_close($ch);
 return $result;
}
?>
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | 
                                       SecurityProtocolType.Tls | SecurityProtocolType.Ssl3;
string apiUrl = "https://maktapp.credit/v3/AddTransaction ";
using (WebClient wc = new WebClient())
{
wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
System.Collections.Specialized.NameValueCollection postData = new System.Collections.Specialized.NameValueCollection();
 {
    {"token", "E4B73FEE-F492-4607-A38D-852B0EBC91C9"}, 
    {"FcmToken", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"},
    {"currencyCode", "XXX"},
    {"orderId", "XXXXXXX"}, 
    {"amount", XXX},
    {"customerEmail", "XXXX"},   
    {"customerName", "XXXX"},
    {"customerPhone", "XXXX"},
    {"customerCountry", "XXXX"},  
    {"lang", "ar"},
    {"isRecurring" true},
    {"isVoid" ,true},
    {"note", "testpayment"}
 };
var res = wc.UploadValues(apiUrl, postData);
string resStr = Encoding.UTF8.GetString(res);
}
<form>
<input type="button" id="SubmitPay" name="SubmitPay" value="submit" onclick="return pay();" />
</form>
<script>
function pay() {    
var dataToPost = {
"token": "E4B73FEE-F492-4607-A38D-852B0EBC91C9",
"FcmToken ":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"currencyCode": "XXX",
"orderId": "XXXXXXX",
"amount": XXXX,      
"customerEmail": XXXX,
"customerName":"XXXX",
"customerPhone":"XXXX",
"customerCountry": "XXXX",
"lang": "ar",
"isRecurring":true, 
"isVoid":true, 
"note": ""                
  };  

    $.ajax({            
    url: 'https://maktapp.credit/v3/AddTransaction',
    data: dataToPost,
    type: "POST",
    dataType: "json",
    success: function (res) {                
             window.location.href = res.result;                                
        },
    error: function (result) {               
            alert("error: " + result);
        }
    });        
}
</script>
#POST curl https://maktapp.credit/v3/AddTransaction 
-H "Content-Type: application/json" 
-d ' {
"token":"E4B73FEE-F492-4607-A38D-852B0EBC91C9",
"FcmToken":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"currencyCode":"XXX", 
"orderId":"XXXXXXX", 
"amount":XXXX,
"customerEmail":"XXXX",
"customerName":"XXXX",
"customerPhone":"XXXX",
"customerCountry":"XXX",
"lang":"ar",
"isRecurring":true, 
"isVoid":true,  
"note":"XXXX" 
}'

The above request will returns JSON structured if all parameters are valid:


{ 
    "result": "https://maktapp.credit/pay/MCPaymentPage?paymentID=XXXXXXXXXX" 
}

The above request will returns JSON structured if one parameter is null or not valid:

{ 
    "result": x 
}  [-1, -2, -3, -6, -8, -10, -20, -21 ]

This API allows the merchant application to do the following:

HTTP Request

POST https://maktapp.credit/v3/AddTransaction

Request Parameters

Parameter Restriction Description
token Required String value.
API token.
FcmToken Optional String value.
Mobile FCM Token.
currencyCode Optional String value.
currency code of your country as an ISO 4217 alpha code. The default code is QAR.
If you want to support more than one currency, contact with Maktapp support.
orderId Required String value.
A unique identifier for each payment in your application.
amount Required Decimal value.
Payment amount that will be deducted from the client account.
customerEmail Required String value, it should have valid email address format.
Client email address.
isRecurring Optional Boolean value.
To indicate the payment is recurring or not.
autosave Optional String value, should have one of the following values {"no","yes"}.
To indicate if it is auto save payment or not.
isVoid Optional Boolean value.
when this paramter has "true" value, Fatora gatway will try to return deducted amount to client account automatically after successful payment and get card token for the client card. It is used with isrecurring =true or autosave=yes.
customerName Optional String value.
Client Name.
customerPhone Optional String value.
Client phone, including country code.
customerCountry Optional String value.
Client country.
lang Optional String value, it should have one of these value{"en","ar"}.
Language of checkout page..
Default value is "ar".
note Optional String value.
Notes about the payment.

If all the required parameter are valid, Fatora gateway will return URL of checkout page in a JSON format, like following:

Response JSON

{ "result": "https://maktapp.credit/pay/MCPaymentPage?paymentID=XXXXXXXXXX" }

If the values of one parameter are not valid, Fatora gateway will return a response in JSON format containing error code, like following:

Response JSON

{ "result": x } [-1, -2, -3, -6, -8, -10, -20, -21 ]

After processing payment and in "SUCCESS" case, if Fatora gateway succeeded in voiding payment, Fatora gateway will redirect client to merchant success page, and will request merchant success page with the following parameters:

Redirect to success page

Merchat_SUCCESS_URL?transid=XXXX&orderId=XXXX&mode=XXXX&refunded=yes&RTransactionID=XXXX&token=XXXX

If Fatora gateway failed in voiding payment, Fatora gateway will redirect client to merchant success page, and will request Merchant Success page with the following parameters:

Redirect to success page

Merchant_Success_URL?transid=XXXX&orderId=XXXX&mode=XXXX&refunded=no&RefundDescription=XXXX&token=XXXX

In failure case, Fatora gateway will redirect client to merchant failure page, and will call merchant failure page with the following parameters:

Redirect to failure page

Merchat_FAILURE_URL?orderId=XXX&transId=XXX&token=XXX&mode=XXX&Failerdescription=XXX

Request Parameters

Parameter Description
transId Transaction id of payment created by bank.
orderId Ordered of payment(sent by your application at requesting Initialize API).
mode It has one of the following values {"test", "live"} according to merchant mode.
cardToken Unique identifier extracted from card detail, you will use it to get deduct amount from client directly when he makes another purchase in your application without redirecting him to checkout page.
refunded Has one of the following values {"yes"
RTransactionID Transaction id of refund process in bank.
RefundDescription It describes why the refund request sent by Fatora gateway is failed.
Failerdescription It describes why the payment is failed.

Refund Payment

<? php
init();
function init()
{
 $url = 'https://maktapp.credit/v3/Refund';
 $data = array(
 'token'           => "E4B73FEE-F492-4607-A38D-852B0EBC91C9",
 'transactionId    => "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", 
 'orderId'         => "XXXXXXX"
 );

 $response = curl_post( $url , $data );
 $data_json_decode = json_decode($response);
 $result = $data_json_decode->{'result'};

 return  $result;
}

function curl_post($url, array $post = NULL, array $options = array())
{ 
 $defaults = array(
 CURLOPT_POST           => 1,
 CURLOPT_HEADER         => 0,
 CURLOPT_URL            => $url,
 CURLOPT_FRESH_CONNECT  => 1,
 CURLOPT_RETURNTRANSFER => 1,
 CURLOPT_FORBID_REUSE   => 1,
 CURLOPT_TIMEOUT        => 500,
 CURLOPT_POSTFIELDS     => http_build_query($post)
 );
 $ch = curl_init();
 curl_setopt_array($ch, ($options + $defaults));
 if( ! $result = curl_exec($ch))
 {
 trigger_error(curl_error($ch));
 }
 curl_close($ch);
 return $result;
}
?>
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | 
                                       SecurityProtocolType.Tls | SecurityProtocolType.Ssl3;
string apiUrl = "https://maktapp.credit/v3/Refund ";
using (WebClient wc = new WebClient())
{
wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
System.Collections.Specialized.NameValueCollection postData = new System.Collections.Specialized.NameValueCollection();
 {
    {"token", "E4B73FEE-F492-4607-A38D-852B0EBC91C9"}, 
    {"transactionId", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"},
    {"orderId", "XXXXXXX"}  
 };
var res = wc.UploadValues(apiUrl, postData);
string resStr = Encoding.UTF8.GetString(res);
}
<form>
<input type="button" id="SubmitPay" name="SubmitPay" value="submit" onclick="return pay();" />
</form>
<script>
function pay() {    
var dataToPost = {
"token": "E4B73FEE-F492-4607-A38D-852B0EBC91C9",
"transactionId ":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"orderId": "XXXXXXX"

  };  

    $.ajax({            
    url: 'https://maktapp.credit/v3/Refund',
    data: dataToPost,
    type: "POST",
    dataType: "json",
    success: function (res) {                
             window.location.href = res.result;                                
        },
    error: function (result) {               
            alert("error: " + result);
        }
    });        
}
</script>
#POST curl https://maktapp.credit/v3/Refund 
-H "Content-Type: application/json" 
-d ' {
"token":"E4B73FEE-F492-4607-A38D-852B0EBC91C9",
"orderId":"XXXXXXX", 
"transactionID":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}'

The above request will returns JSON structured if all parameters are valid:


{ 
   "result": 1,
   "refundState" : XXX ["SUCCESS","Proccessing"],
   "mode": XXX ["test","live"],
   "refundTrnsactionId": XXXXXX 
}

The above request will returns JSON structured if one parameter is null or not valid:

{ 
    "result": x 
}  [-1, -2, -3, -6, -8, -10, -20, -21 ]

This API allows the merchant application to refund a payment.

When Fatora receives a request to refund a payment, Fatora will process this request and send request to bank to return money to client.

Here are two cases:

HTTP Request

POST https://maktapp.credit/v3/Refund

Request Parameters

Parameter Restriction Description
token Required String value.
API token.
orderId Required String value.
A unique identifier for each payment in your application.
transactionID Optional String value.
Transaction id of payment created by bank.

If all the required parameter are valid, Fatora gateway will return result in a JSON format, like following:

Response JSON

{

"result": 1,

"refundState" : XXX ["SUCCESS","Proccessing"],

"mode": XXX ["test", "live"],

"refundTrnsactionId": XXXXXX

}

Response Parameters

Parameter Description
result It has value equal one If all the required parameter are valid. Otherwise it has one of the error code values. [-1, -2, -3, -6, -8, -10, -20, -21 ]
refundState It has one of the following values {"SUCCESS", "Processing"}
"SUCCESS": refund request succeeded and bank returned money back to client.
"Processing": refund request succeeded and the request is under processing and the bank will return money back to client within 2-4 weeks.
mode It has one of the following values {"test", "live"} according to merchant mode.
refundTrnsactionId Transaction id of refund process created by bank.

If the values of one parameter are not valid, Fatora gateway will return a response in JSON format containing error code, like following:

Response JSON

{ "result": x } [-1, -2, -3, -6, -8, -10, -20, -21 ]

Check Payment Status

<? php
init();
function init()
{
 $url = 'https://maktapp.credit/v3/CheckStatus';
 $data = array(
 'token'           => 'E4B73FEE-F492-4607-A38D-852B0EBC91C9', 
 'orderId'         => 'XXXXXXX' 
);

 $response = curl_post( $url , $data );
 $data_json_decode = json_decode($response);
 $result = $data_json_decode->{'result'};

 return  $result;
}

function curl_post($url, array $post = NULL, array $options = array())
{ 
 $defaults = array(
 CURLOPT_POST           => 1,
 CURLOPT_HEADER         => 0,
 CURLOPT_URL            => $url,
 CURLOPT_FRESH_CONNECT  => 1,
 CURLOPT_RETURNTRANSFER => 1,
 CURLOPT_FORBID_REUSE   => 1,
 CURLOPT_TIMEOUT        => 500,
 CURLOPT_POSTFIELDS     => http_build_query($post)
 );
 $ch = curl_init();
 curl_setopt_array($ch, ($options + $defaults));
 if( ! $result = curl_exec($ch))
 {
 trigger_error(curl_error($ch));
 }
 curl_close($ch);
 return $result;
}
?>
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | 
                                       SecurityProtocolType.Tls | SecurityProtocolType.Ssl3;
string apiUrl = "https://maktapp.credit/v3/CheckStatus";
using (WebClient wc = new WebClient())
{
wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
System.Collections.Specialized.NameValueCollection postData =new System.Collections.Specialized.NameValueCollection();
 {
    {"token","E4B73FEE-F492-4607-A38D-852B0EBC91C9"},        
    {"orderId","XXXXXXX"}
 };
var res       = wc.UploadValues(apiUrl, postData);
string resStr = Encoding.UTF8.GetString(res);

ValidateResponse result= Newtonsoft.Json.JsonConvert.DeserializeObject<ValidateResponse>(resStr);
public class ValidateResponse
{
    publicint result { set; get; }
    public PaymentDetails payment { set; get; }
}
public class PaymentDetails
{
public string  transactionID { set; get; }
public string  customerName { set; get; }
public string  customerPhone{set;get;}
public decimal PaymentAmount { set; get; }
public string  CurrencyCode { set; get; }
public string  CustomerEmail { set; get; }
public string  PaymentDate { set; get; }
public string  Paymentstate { set; get; }
public string  Mode { set; get; }
public string  auth { set; get; }
public decimal ExchangeRate { set; get; }
public decimal PaidAmount { set; get; }
public string  token{set;get;}public decimal description {set;get;}
public bool    refundState{set;get;}
public string  refundstatus{set;get;}        public stringrefundDescription{set;get;}
public string  refundTransactionId{set;get;}
}


#POST curl https://maktapp.credit/v3/CheckStatus 
-H "Content-Type: application/json"
-d ' { 
"token":"E4B73FEE-F492-4607-A38D-852B0EBC91C9",
"orderId":"XXXXXXX"
}'

The above request will returns JSON structured if Fatora gateway find the payment:

{ 
    "result": 1,
    "payment":
    {
        "transactionID": "XXXXXXX",
        "amount": XXXX,
        "currencyCode":  "XXX",
        "customerEmail": "XXXX",
        "customerPhone": "XXXX",
        "customerName":  "XXXX",
        "paymentDate":   "XXXX",
        "paymentstate":  "XXXX" [SUCCESS, PENDING,FAILURE], 
        "auth" : "XXXX",
        "mode": "XXX" [Live, Test] ,
        "ExchangeRate":0,
        "token":null,
        "description":"Transation Successfull",
        "refundState":false,
        "refundstatus":null,
        "refundDescription":null,
        "refundTransactionId":null
    } 
}

Response if Fatora gatway dos not find the payment:

{ 
    "result": 0
}

Response in case one of the request parameters is null or not valid:

{ 
    "result": X
} [-1, -2, -3, -6, -8, -10, -20, -21 ]

This API allows merchant application to get payment details, like status [PENDING, SUCCESS, FAILURE], transactionid, amount, currency code, client detail and other details.
You can use this API in each time your success page is requested:

HTTP Request

POST https://maktapp.credit/v3/CheckStatus

Request Parameters

Parameter Restriction Description
token Required API token.
orderId Required OrderId of payment(sent by your application at requesting initialize Payment API).
transactionID Optional Transactionid of payment.

Collect Payment For Recurring

<? php
init();
function init()
{
 $url = 'https://maktapp.credit/v3/GetnewPayment';
 $data = array(
 'token'           => "E4B73FEE-F492-4607-A38D-852B0EBC91C9",
 'cardToken'       => "XXXXXXX" 

);

 $response = curl_post( $url , $data );
 $data_json_decode = json_decode($response);
 $result = $data_json_decode->{'result'};

 return  $result;
}

function curl_post($url, array $post = NULL, array $options = array())
{ 
 $defaults = array(
 CURLOPT_POST           => 1,
 CURLOPT_HEADER         => 0,
 CURLOPT_URL            => $url,
 CURLOPT_FRESH_CONNECT  => 1,
 CURLOPT_RETURNTRANSFER => 1,
 CURLOPT_FORBID_REUSE   => 1,
 CURLOPT_TIMEOUT        => 500,
 CURLOPT_POSTFIELDS     => http_build_query($post)
 );
 $ch = curl_init();
 curl_setopt_array($ch, ($options + $defaults));
 if( ! $result = curl_exec($ch))
 {
 trigger_error(curl_error($ch));
 }
 curl_close($ch);
 return $result;
}
?>
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | 
                                       SecurityProtocolType.Tls   | SecurityProtocolType.Ssl3;
string apiUrl = "https://maktapp.credit/v3/GetnewPayment";
using (WebClient wc = new WebClient())
{
wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
System.Collections.Specialized.NameValueCollection postData = new System.Collections.Specialized.NameValueCollection();
 {
    {"token", "E4B73FEE-F492-4607-A38D-852B0EBC91C9"},    
    {"cardToken","XXXXXXX"}

 };
var res       = wc.UploadValues(apiUrl, postData);
string resStr = Encoding.UTF8.GetString(res);
NewPaymentDetail result = Newtonsoft.Json.JsonConvert.DeserializeObject<NewPaymentDetail >(resStr);

public class NewPaymentDetail
{
    public int    result { set; get; }
    public string transactionID { set; get; }        
    public string Mode { set; get; }
    public string auth { set; get; }
    public string description{ set; get; }
}

#POST curl https://maktapp.credit/v3/GetnewPayment 
-H "Content-Type: application/json"
-d ' {
"token":"E4B73FEE-F492-4607-A38D-852B0EBC91C9",
"cardToken":"XXXXXXX"

}'

The above request will returns JSON structured if fator gateway succeed in getting new payment:

{ 
    "result":1,
    "transactionId":"XXXXXXXXXX", 
    "authcode":"XXXXXXXXXX",
    "mode":"test" 
}

The above request will returns JSON structured if fator gateway failed in getting new payment:

{ 
    "result":0, 
    "transactionid":"XXXXXXXXXX",
    "description":"failure description"
}

This API allows the merchant application to get a new payment from client using cardToken [for a recurring payment ] when the payment is due, directly without requesting checkout page.

HTTP Request

POST https://maktapp.credit/v3/GetnewPayment

Request Parameters

Parameter Restriction Description
token Required API token.
cardToken Required Card token which Fatora gateway send to your application after successful recurring or autosave payment.

Collect Payment For Autosave

<? php
init();
function init()
{
 $url = 'https://maktapp.credit/v3/GetnewPayment';
 $data = array(
 'token'           => 'E4B73FEE-F492-4607-A38D-852B0EBC91C9',
 'cardToken'       => 'XXXXXXX', 
 'orderId'         => 'XXXXXXX', 
 'amount'          =>  XXXX 
);

 $response = curl_post( $url , $data );
 $data_json_decode = json_decode($response);
 $result = $data_json_decode->{'result'};

 return  $result;
}

function curl_post($url, array $post = NULL, array $options = array())
{ 
 $defaults = array(
 CURLOPT_POST           => 1,
 CURLOPT_HEADER         => 0,
 CURLOPT_URL            => $url,
 CURLOPT_FRESH_CONNECT  => 1,
 CURLOPT_RETURNTRANSFER => 1,
 CURLOPT_FORBID_REUSE   => 1,
 CURLOPT_TIMEOUT        => 500,
 CURLOPT_POSTFIELDS     => http_build_query($post)
 );
 $ch = curl_init();
 curl_setopt_array($ch, ($options + $defaults));
 if( ! $result = curl_exec($ch))
 {
 trigger_error(curl_error($ch));
 }
 curl_close($ch);
 return $result;
}
?>
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | 
                                       SecurityProtocolType.Tls   | SecurityProtocolType.Ssl3;
string apiUrl = "https://maktapp.credit/v3/GetnewPayment";
using (WebClient wc = new WebClient())
{
wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
System.Collections.Specialized.NameValueCollection postData = new System.Collections.Specialized.NameValueCollection();
 {
    {"token", "E4B73FEE-F492-4607-A38D-852B0EBC91C9"},    
    {"cardToken","XXXXXXX"},
    {"orderId": "XXXXXXX"},
    {"amount", XXXX}     
 };
var res       = wc.UploadValues(apiUrl, postData);
string resStr = Encoding.UTF8.GetString(res);
NewPaymentDetail result = Newtonsoft.Json.JsonConvert.DeserializeObject<NewPaymentDetail >(resStr);

public class NewPaymentDetail
{
    public int    result { set; get; }
    public string transactionID { set; get; }        
    public string Mode { set; get; }
    public string auth { set; get; }
    public string description{ set; get; }
}
<form>
<input type="button" id="SubmitPay" name="SubmitPay" value="submit" onclick="return pay();" />
</form>
<script>
function pay() {    
    var dataToPost = {
    "token": "E4B73FEE-F492-4607-A38D-852B0EBC91C9",
    "cardToken":"XXXXXXX",
    "orderId": "XXXXXXX",
    "amount": XXXX
      };

    $.ajax({            
    url: 'https://maktapp.credit/v3/GetnewPayment',
    data: dataToPost,
    type: "POST",
    dataType: "json",
    success: function (res) {                
        window.location.href = res.result;                                
    },
    error: function (result) {               
        alert("error: " + result);
    }
    });        
}
</script>
#POST curl https://maktapp.credit/v3/GetnewPayment 
-H "Content-Type: application/json"
-d ' {
"token":"E4B73FEE-F492-4607-A38D-852B0EBC91C9",
"cardToken":"XXXXXXX",
"orderId":"XXXXXXX",
"amount":XXXX   
}'

The above request will returns JSON structured if fator gateway succeed in getting new payment:


{ 
    "result":1,
    "transactionid":"XXXXXXXXXXXXXXXXXXX",
    "authcode":"XXXXXXXXXX",
    "mode":"test" 
}

The above request will returns JSON structured if fator gateway failed in getting new payment:

{ 
    "result":0, 
    "transactionid":"XXXXXXXXXXXXXXXXXXX",
    "description":"failure description"
}

This API allows the merchant application get new payment from client using cardToken, which your application received after a successful autosave payment for the client.

HTTP Request

POST https://maktapp.credit/v3/GetnewPayment

Request Parameters

Parameter Restriction Description
token Required API token.
cardToken Required Card token which Fatora gateway send to your application after successful recurring or autosave payment.
amount Required Amount to be deducted from client account.
orderId Required A unique identifier for each payment in your application.

Deactivate Card Token

<? php
init();
function init()
{
 $url = 'https://maktapp.credit/v3/StopRecurring';
 $data = array(
 'token'           => 'E4B73FEE-F492-4607-A38D-852B0EBC91C9',
 'cardToken'       => 'XXXXXXX' 
);

 $response = curl_post( $url , $data );
 $data_json_decode = json_decode($response);
 $result = $data_json_decode->{'result'};

 return  $result;
}

function curl_post($url, array $post = NULL, array $options = array())
{ 
 $defaults = array(
 CURLOPT_POST           => 1,
 CURLOPT_HEADER         => 0,
 CURLOPT_URL            => $url,
 CURLOPT_FRESH_CONNECT  => 1,
 CURLOPT_RETURNTRANSFER => 1,
 CURLOPT_FORBID_REUSE   => 1,
 CURLOPT_TIMEOUT        => 500,
 CURLOPT_POSTFIELDS     => http_build_query($post)
 );
 $ch = curl_init();
 curl_setopt_array($ch, ($options + $defaults));
 if( ! $result = curl_exec($ch))
 {
 trigger_error(curl_error($ch));
 }
 curl_close($ch);
 return $result;
}
?>
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | 
                                       SecurityProtocolType.Tls   | SecurityProtocolType.Ssl3;
string apiUrl = "https://maktapp.credit/v3/StopRecurring ";
using (WebClient wc = new WebClient())
{
wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
System.Collections.Specialized.NameValueCollection postData = new System.Collections.Specialized.NameValueCollection();
 {
    {"token", "E4B73FEE-F492-4607-A38D-852B0EBC91C9"}, 
    {"cardToken", "XXXXXXX"}
 };
var res       = wc.UploadValues(apiUrl, postData);
string resStr = Encoding.UTF8.GetString(res);
}
#POST curl https://maktapp.credit/v3/StopRecurring 
-H "Content-Type: application/json" 
-d ' {
"token":"E4B73FEE-F492-4607-A38D-852B0EBC91C9",
"cardToken":"XXXXXXX"
}'
<form>
<input type="button" id="SubmitPay" name="SubmitPay" value="submit" onclick="return pay();" />
</form>
<script>
function pay() {    
var dataToPost = {
"token": "E4B73FEE-F492-4607-A38D-852B0EBC91C9",
"cardToken ":"XXXXXXX"     
};  
    $.ajax({            
    url: 'https://maktapp.credit/v3/StopRecurring',
    data: dataToPost,
    type: "POST",
    dataType: "json",
    success: function (res) {                

      },
    error: function (result) {               
            alert("error: " + result);
     }
    });        
}
</script>

The above request will returns JSON structured if fator gateway succeed in deactivate card token :

{ 
    "result":1
}

The above request will returns JSON structured if fator gateway failed in deactivate card token :

{ 
  "result": "X" 
} [-1, -2, -3, -6, -8, -10, -20, -21 ] 

This API allows merchant application to disable card token, so merchant application couldn't able to deduct money from the client account using card token.

HTTP Request

POST https://maktapp.credit/v3/StopRecurring

Request Parameters

Parameter Type Required (Yes, No) Description
token String Yes It is API token.
cardToken String Yes must be Unique, created by bank for client`s card who set autosave payment type to yes.

Test

Now Fatora gateway doesn't support test card data, but you can test your application and see the steps of payment using TestMode for your merchant.

Step of Payment in Test Mode

or Fatora gateway redirects client to failure page with failure details if your enter any value other than 123 in CVV field in checkout page but don`t leave it empty. error payment process

Errors

<? php
function CheckResponseStatus($result, $msg){

    switch ($result){        
        case -1:           
            $msg = "Unauthorized -- API key is invaild(not Valid GUID), or no merchant for this token";
            break;
        case -2:
            $msg = "Not Found -- The specified orderId could not be found.";
            break;
        case -3:
            $msg = "Not Support -- merchnat application doesn't support the sent currency code.";
            break;
        case -7:
            $msg = "Not Found -- there isn't any recurring or autosave payment in Fatora gateway for this merchant with the request parameter.";
            break;
        case -8:
            $msg = "Invalid -- Token is not valid guid.";
            break;
        case -10:
            $msg = "Bad Request -- required parameters requested aren't sent in request.";
            break;
        case -20:
            $msg = "Not Found -- There isn't application data for the merchant for the sent currency in payment gateway.";
            break;
        case -21:
            $msg = "Not Support -- payment gateway doesn't support void payment";
            break;
        default:
            $msg = "success";
            break;
    }
    echo $msg;
} 
?>
public string CheckResponseStatus(int result)
{
    string msg = "";
    switch (result)
    {
        case -1:
            msg = "Unauthorized -- API key is invaild(not Valid GUID), or no merchant for this token";
            break;
        case -2:
            msg = "Not Found -- The specified orderId could not be found.";
            break;
        case -3:
            msg = "Not Support -- merchnat application doesn't support the sent currency code.";
            break;
        case -7:
            msg = "Not Found -- there isn't any recurring or autosave payment in Fatora gateway for this merchant with the request parameter.";
            break;
        case -8:
            msg = "Invalid -- Token is not valid guid.";
            break;
        case -10:
            msg = "Bad Request -- required parameters requested aren't sent in request.";
            break;
        case -20:
            msg = "Not Found -- There isn't application data for the merchant for the sent currency in payment gateway.";
            break;
        case -21:
            msg = "Not Support -- payment gateway doesn't support void payment";
            break;
        default:
            msg = "success";
            break;
    }
    Console.WriteLine(msg);
}

<script>
function  CheckResponseStatus(result)
{
    var msg = "";
    switch (result)
    {   
        case -1:
            msg = "Unauthorized -- API key is invaild(not Valid GUID), or no merchant for this token";
            break;
        case -2:
            msg = "Not Found -- The specified orderId could not be found.";
            break;
        case -3:
            msg = "Not Support -- merchnat application doesn't support the sent currency code.";
            break;
        case -7:
            msg = "Not Found -- there isn't any recurring or autosave payment in Fatora gateway for this merchant with the request parameter.";
            break;
        case -8:
            msg = "Invalid -- Token is not valid guid.";
            break;
        case -10:
            msg = "Bad Request -- required parameters requested aren't sent in request.";
            break;
        case -20:
            msg = "Not Found -- There isn't application data for the merchant for the sent currency in payment gateway.";
            break;
        case -21:
            msg = "Not Support -- payment gateway doesn't support void payment";
            break;
        default:
            msg = "success";
            break;
        }
        alert(msg);
}
</script>

The Fator API uses the following error codes:

Error Code Meaning
-1 Unauthorized -- API key is invaild(not Valid GUID), or no merchant for this token
-2 Not Found -- The specified orderId could not be found.
-3 Not Support -- merchnat application doesn't support the sent currency code
-7 Not Found -- there isn't any recurring or autosave payment in Fatora gateway for this merchant with the request parameter.
-8 Invalid -- Token is not valid guid.
-10 Bad Request -- required parameters requested aren't sent in request.
-20 Not Found -- There isn't application data for the merchant for the sent currency in payment gateway.
-21 Not Support -- payment gateway doesn't support void payment

FAQs

Is card token expired?

Therefore, if you want to collect new payments from the same client, you have to get a new card token again.

What does happen if we generating more than card token?

Does debit card support recurring payments? - No, debit cards issued in Qatar do not support recurring payments; so if a client try to pay a recurring payment using debit card the payment fails.

Does Fatora gateway validate if "OrderId" is unique at your application level when trying to get checkout page URL?

Whats are the possible values that "OrderId" paramter could take?

What does the SUCCESS URL and FAILURE URL look like?

Does card token contain special characters?

What does happen when a client try to open checkout page after paying?

Plugin

SDK

SDK & API

Wix

Integrate Fatora With Wix Store

Fatora simple and creative payment gateway


import wixSite from 'wix-site-backend';
import wixUsers from 'wix-users';
import {generateLink} from 'backend/generateLink';
import wixLocation from 'wix-location';


$w.onReady(() => {

  $w('#button6').label = "⏱ Please wait for the payment URL...";
  var adminEmail = "[email protected]";
  var payLink = "Not Set"
  $w('#thankYouPage1').getOrder().then( (order) => {

    var orderNumber = order.number,
     orderFrom = order.billingInfo.firstName + " " + order.billingInfo.lastName,
     customerEmail = order.billingInfo.email,
     amount  = order.totals.total,
     currency = order.currency;

    generateLink(order.totals.total,order.number,order.billingInfo.email).then(result => {
        payLink = result;
        $w('#buttonID').link = result;
        $w('#buttonID').label = "Pay "+ amount + " now ߛҢ;

          // check if the user is logged in 
        if(wixUsers.currentUser.loggedIn) {    

          const userId = wixUsers.currentUser.id;

          wixUsers.emailUser('ibhMail', userId, {
            variables: {
              "payURL": payLink,
              "amount":amount.toString(),
              "orderId":orderNumber.toString(),
              "name":orderFrom.toString()
          }});

        }else // then let's use the email he used in the checkout and send him a payment link
        {
          const subject = "#" + orderFrom + "Payment Link";
          const body = `
          \rPayment Link: ${encodeURIComponent(payLink)}`;

          /* your code here to sendEmail */
        }

    }).catch(err => console.log(err));

});
});

import {sendWithService} from 'backend/sendGrid';
import wixSite from 'wix-site-backend';

export function sendEmail(subject, body,recipient) {
  const key = "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";
  const sender = "[email protected]";
  return sendWithService(key, sender, recipient, subject, body);
}

import {fetch} from 'wix-fetch';  
import wixUsers from 'wix-users-backend';
import wixSite from 'wix-site-backend';

export function getUserName() {
    return {
                //user_id : wixUsers.currentUser.id,
                websiteEmail : wixSite.generalInfo.getEmail(),
                websitePhone : wixSite.generalInfo.getPhone()
            };
} 

export function generateLink(amount,orderId,customerEmail) {

const fatoraApi = "https://maktapp.credit/v3/AddTransaction";

  return fetch(fatoraApi, {
      method: 'post',
      mode: 'cors',
      body: JSON.stringify({ 
          token: "Add Your token here",
          "amount": amount,
          "orderId": orderId,
          "customerEmail": customerEmail,
          "lang": "ar"
          }),
      headers: {
        "Content-Type": "application/json; charset=utf-8"
      }
    })
    .then(response => response.json())
    .then(json => json.result);
}


export function validatePayment(orderId) {

const fatoraApi = "https://maktapp.credit/v3/ValidatePayment";

  return fetch(fatoraApi, {
      method: 'post',
      mode: 'cors',
      body: JSON.stringify({ 
          token: "Add your token here",
            orderId: orderId

        }),
      headers: {
        "Content-Type": "application/json; charset=utf-8"
      }
    })
    .then(response => response.json())
    .then(json => json.payment.paymentstate);
}

import {fetch} from 'wix-fetch';  

export function sendWithService(key, sender, recipient, subject, body) {
  const url = "https://api.sendgrid.com/api/mail.send.json";

  const headers = {
    "Authorization": "Bearer " + key,
    "Content-Type": "application/x-www-form-urlencoded"
  };

  const data = `from=${sender}&to=${recipient}&subject=${subject}&text=${body}`;

  const request = {
    "method": "post", 
    "headers": headers, 
    "body": data
  };

  return fetch(url, request)
   .then(response => response.json());
}

You can integrate any Wix website with Fatora wither premium or a free Wix website store.

How It Works?

The client buys products from your Wix store now at the default thank page he will get the payment link also he will get an email that contain the payment URL for his order.

Now when user pay for his order and the payment were successfully paid, he will get a confirmation email.

And another email will be sent to the admin store email tell you that a new payment was successfully maid and you MUST change the status of this order at Wix store.

How to do it?

a. Click on add

b. Select Button

c. Select any button you need
thankyou

a. Add this code.

b. You will found tow variables call token in this variables add your token.

c. You can change language from lang variable (en or ar) import.

Shopify

You can integrate any shopify website with Fatora just follow this easy steps.

First Add Custom payment

shopify setting

Payments

Manual payment methods

Create custom payment method

Activate

I think you doing well because now we add a custom payment, continue ……….

Second add our custom code to thanks page

  <script  src="https://code.jquery.com/jquery-3.4.1.min.js"  integrity="sha256CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous">
  </script>
  <script> 
  var token = "Add Your token here";     
  var payBtn = document.getElementById('gotopay');     
  function paynow(){         
  var orderid = ("{{ order_name }}").replace('#','');         
  var shippingAddress = "{{ shipping_address | format_address }}";         
  var country = shippingAddress.substring(shippingAddress.indexOf("\n") + 3);         
  var amount = {{ total_price}} / 100;         
  var dataToPost = {             
  "token": token,             
  "currencyCode": "{{ currency}}",             
  "orderId": orderid,             
  "note": "testpayment",             
  "autoSave ": "Yes",             
  "customerEmail": "{{ email }}",             
  "customerCountry": country,            
  "lang": "ar",             
  "amount": amount,             
  "FcmToken": "device fcm_token" 
  };             
  $.ajax({             
  url: 'https://maktapp.credit/v3/AddTransaction',             
  data: dataToPost,             
  type: "POST",             
  datatype: 'json',             
  cache: false,             
  success: function (res) {                 
  window.location.href = res.result;             
  },             
  error: function (result) {             
  alert("error: " + result);             
  }         
  });         
  }; 
  </script> 
  <br><br><br> 
  <div style="text-align: center;">
  <button style="    background-color: #00a2ff; borderradius: 10px; padding: 15px 100px; margin: auto; text-align: center; color: #FFF; fontsize: 22px;" id="gotopay" onclick="paynow()" class="button__text">Pay Now</button> 
  </div> <br> 

Create success and failure pages

In this section you will create two pages one call "success page" and "failure page" to redirect the client after pay.
If he pay success he will redirect to success page else he will redirect to failure page. Let’s start.

Prestashop

Fatora Module For Prestashop

Install and Module configuration

prestashop  setting

prestashop

Enable module

configure

Add your token and click save

You are done!