---
updatedAt: 2025-11-11T23:57:12.000Z
agentTools:
  projectIndex: https://docs.myfatoorah.com/llms.txt
---

# Cordova

Guide for Cordova

## Demo project

Cordova Plugin: [cordova-plugin-myfatoorah](https://www.npmjs.com/package/cordova-plugin-myfatoorah)\
Cordova Plugin Demo: [cordova-demo](https://dev.azure.com/myfatoorahsc/MF-SDK-Cross-Platforms-Demos/_git/MF-SDK-Cross-Platforms-Demos?version=GBcordova_demo)

## Installation

* Run the following commands on your Terminal on the parent directory of your project.

```text
npm i cordova-plugin-myfatoorah
cordova plugin add cordova-plugin-myfatoorah

// for Android
cordova platforms add android 
cordova run android

// for iOS
cordova platforms add ios
cordova run ios
```

## Usage

1. Initiate MyFatoorah Plugin with the following line:

```javascript
function init() {
  cordova.plugins.MyFatoorahCordovaPlugin.initiate(
    "Put your API Key here",
    cordova.plugins.MyFatoorahCordovaPlugin.MFCountry.KUWAIT,
    cordova.plugins.MyFatoorahCordovaPlugin.MFEnvironment.TEST
  );
}
```

2. (Optional)

```javascript
// Use the following lines if you want to set up the title of the page.

function setUpTitle() {
  cordova.plugins.MyFatoorahCordovaPlugin.setUpTitle("MyFatoorah Payment", true);
}
```

> 📘 After testing
>
> Once your testing is finished, simply replace the environment from **TEST** to **LIVE** and the **API Key** with the live one, click [here ](https://docs.myfatoorah.com/docs/live-account)for more information.

## Initiate / Execute Payment

As described earlier for the [Gateway Integration](https://docs.myfatoorah.com/docs/gateway-integration), we are going to have the SDK integrated with the same steps to make a successful integration with the SDK

> 🚧 Initiate Payment
>
> As a good practice, you don't have to call the [Initiate Payment](https://docs.myfatoorah.com/docs/initiate-payment) function every time you need to execute payment, but you have to call it at least once to save the PaymentMethodId that you will need to call [Execute Payment](https://docs.myfatoorah.com/docs/execute-payment)

```javascript
// Initiate Payment

function initiatePayment() {
  var initiatePaymentRequest = new cordova.plugins.MyFatoorahCordovaPlugin.MFInitiatePaymentRequest();
  initiatePaymentRequest.invoiceAmount = 0.100;
  initiatePaymentRequest.currencyIso = cordova.plugins.MyFatoorahCordovaPlugin.MFCurrencyISO.KUWAIT_KWD;

  cordova.plugins.MyFatoorahCordovaPlugin.initiatePayment(
  initiatePaymentRequest,
  cordova.plugins.MyFatoorahCordovaPlugin.MFLanguage.ARABIC,
  function (result) {
    if (result["status"] == "success") {
      alert("data:" + JSON.stringify(result["data"]))
    }
    else if (result["status"] == "error") {
      alert("error:" + result["message"])
    }
  });
}

// Eexcute Payment

function executePayment(paymentMethodId) {
  var executePaymentRequest = new cordova.plugins.MyFatoorahCordovaPlugin.MFExecutePaymentRequest();
  executePaymentRequest.invoiceValue = 0.100
  executePaymentRequest.paymentMethod = paymentMethodId

  cordova.plugins.MyFatoorahCordovaPlugin.executePayment(
    executePaymentRequest,
    cordova.plugins.MyFatoorahCordovaPlugin.MFLanguage.ENGLISH,
    function (result) {
      if (result["status"] == "success") {
        alert("data:" + JSON.stringify(result["data"]))
      } else if (result["status"] == "error") {
        alert("error:" + JSON.stringify(result))
      }
    }
  );
}
```

## Send Payment

We have explained in the [Send Payment](https://docs.myfatoorah.com/docs/send-payment) section earlier, the different usage cases for it and how it works, here we are going to embed some sample code for calling it through the SDK on the different platforms

```javascript
function sendPayment() {
  var sendPaymentRequest = new cordova.plugins.MyFatoorahCordovaPlugin.MFSendPaymentRequest();
  sendPaymentRequest.invoiceValue = 0.100
  sendPaymentRequest.customerName = "customerName"
  sendPaymentRequest.notificationOption = cordova.plugins.MyFatoorahCordovaPlugin.MFNotificationOption.LINK

  cordova.plugins.MyFatoorahCordovaPlugin.sendPayment(
    sendPaymentRequest,
    cordova.plugins.MyFatoorahCordovaPlugin.MFLanguage.ENGLISH,
    function (result) {
      if (result["status"] == "success") {
        alert("data:" + JSON.stringify(result["data"]))
      } else if (result["status"] == "error") {
        alert("error:" + JSON.stringify(result))
      }
    }
  )
}
```

## Payment Enquiry

We have explain the main usage for the [Payment Inquiry](https://docs.myfatoorah.com/docs/payment-inquiry) function, that will enable your application to get the full details about a certain invoice / payment. You can use this function within your application on the different platforms as well. Here we are explaining some samples of its usage through the SDK.

```javascript
function getPaymentStatus() {
  var getPaymentStatusRequest = new cordova.plugins.MyFatoorahCordovaPlugin.MFPaymentStatusRequest();
  getPaymentStatusRequest.key = "1515410";
  getPaymentStatusRequest.keyType = cordova.plugins.MyFatoorahCordovaPlugin.MFKeyType.INVOICEID;
  
  cordova.plugins.MyFatoorahCordovaPlugin.getPaymentStatus(
    getPaymentStatusRequest,
    cordova.plugins.MyFatoorahCordovaPlugin.MFLanguage.ENGLISH,
    function (result) {
      parseResult(result);
    }
  )
}
```