Card View


If you would like your customer to complete the payment on your checkout page without being redirected to another page (except for the 3D Secure page) and the PCI DSS compliance is a blocker, MyFatoorah embedded payment feature is your optimum solution.

MyFatoorah embedded payment form is a Javascript library that provides a form for collecting card information. This form can be placed and styled on your checkout page. When your customer enters correct card data then submits the form, MyFatoorah will collect the card details throw IFrame. Then you can smoothly complete the payment using ExecutePayment endpoint by following the below steps.


Supported Payment Methods

This kind of integration only supports Visa/Master, MADA, and AMEX.

The following is the default MyFatoorah embedded payment form used on the checkout page. In the card number input field, gateway icons will be shown indicating the enabled payment methods in your MyFatoorah account. Note that the supported method icons only will be included.


How it Works


Before You start

Kindly refer to the prerequisite section in the Embedded Payment.

The following detailed steps will explain how to add MyFatoorah embedded payment form to your checkout page.

1. Include the Javascript library

Choose the test or the live library according to your working environment.

// Test Environment
<script src=""></script>

// Live Environment Except Saudi Arabia and Qatar
<script src=""></script>

// Live Environment For Saudi Arabia
<script src=""></script>

// Live Environment For Qatar
<script src=""></script>

2. Add the form

You need to define a div element with a unique id attribute. The form will be loaded inside this div after passing the div id to the configuration variable.

<div id="card-element"></div>

3. Configure your Card View

Now you need to add the configuration variables. Place the following snippet in a new script tag after loading the library in step 1, replace the sessionId parameter with the "SessionId" you receive from InitiateSession Endpoint.

For the countyCode parameter check our list of ISO Lookups.

var config = {
    countryCode: "", // Here, add your Country Code you receive from InitiateSession Endpoint.
    sessionId: "", // Here you add the "SessionId" you receive from InitiateSession Endpoint.
    cardViewId: "card-element",

4. Submit Action

After that, you need to handle your submit button to call MyFatoorah submit() action, copy the below code to your submit event handler section. Then, you need to pass the sessionId to your back end.

    function (response) {
        // In case of success
        // Here you need to pass session id to you backend here
        var sessionId = response.sessionId;
        var cardBrand = response.cardBrand; //cardBrand will be one of the following values: Master, Visa, Mada, Amex
    function (error) {
        // In case of errors

5. Call the ExecutePayment Endpoint

Then, you need to send the SessionId to your server to process the actual transaction, which should be done in your backend environment using ExecutePayment endpoint.


Parameters conflict

Do not pass the PaymentMethodId parameter in the ExecutePayment request and use the SessionId parameter instead. As PaymentMethodId overwrite SessionId.

The "SessionId" you receive from InitiateSession Endpoint can not be used directly in ExecutePayment Endpoint.

You will get the PaymentURL in the Response Model. This payment URL is the 3D Secure page URL as this type of payment support only the 3D Secure Flow. In this case, you should redirect the customer to this URL to complete the 3D Secure challenge.

   "CustomerName":"fname lname",
   "CustomerEmail":"[email protected]",
         "ItemName":"item name",
   "Message":"Invoice Created Successfully!",


Payment Status

To update your system automatically instead of manually following up with your customers via your portal account, you can use the Webhook feature or/and set the CallBackURL/ErrorUrl parameter, that MyFatoorah will invoke once the payment is done.