---
updatedAt: 2026-11-06T20:10:45.000Z
agentTools:
  projectIndex: https://developer-docs.paga.com/llms.txt
---

# Node Sample Code

The Merchant Payment Notification API enables merchants to integrate with the Paga platform. This enables Paga to process automated real-time payment transactions with the Merchant's systems using secure RestFul Web Services.

## 1. Create Paga Business Account

You need to create a [Paga business account](https://mypaga.readme.io/docs/overview#section-2-paga-authentication-details)

## 2. Installation

Download the [Merchant Notification Reverse API Javascript code sample](https://github.com/pagadevcomm/merchant-payment-notification-javascript) to your project :\
`git clone https://github.com/pagadevcomm/merchant-payment-notification-javascript.git`\
`cd paga-notification-reverse-API`\
`npm install or yarn install`\
`cp .env.example .env`\
`npm start`\
NB: .env.example file contains parameters that must be specified in your .env file

## 3. Implementing the service endpoints

## /**getIntegrationServices**

**This service is mandatory.**\
This service allows Paga to verify which of the integration services the merchant implementation supports in order to configure subsequent interaction with the merchant platform.

```javascript sample code
exports.getIntegrationServices = async function(data) {
  try {
    const { isTest } = data;

    const integrationServices = await IntegrationService.find(
      { isTest },
      "service"
    );
    const listOfIntegrationServices = integrationServices.map(
      ({ service }) => service
    );
    return {
      error: false,
      message: listOfIntegrationServices
    };
  } catch (error) {
    throw new Error(error);
  }
};
```

## /**validateCustomer**

**This service is optional.**\
This service allows Paga to check the validity of a customer's details with respect to the merchant's response using several customer properties.

```javascript sample code
exports.validateCustomer = async function(data) {
  try {
    const { customerAccountNumber } = data;
    const customerInfo = await CustomerSchema.findOne({
      customerAccountNumber
    });

    if (!customerInfo) {
      return {
        error: true,
        msg: `Customer does not exist `
      };
    }
    const {
      customerFirstName: firstName,
      customerLastName: lastName,
      customerAccountStatus
    } = customerInfo;

    const today = new Date(Date.now());

    let lastPaymentDate = today.toISOString();

    return {
      status: "SUCCESS",
      message: "Notification processed successfully",
      isValid: true,
      firstName,
      lastName,
      lastPaymentDate,
      accountStatus: customerAccountStatus,
      paymentDueDate: lastPaymentDate,
      isDisplayed: true
    };
  } catch (error) {
    throw new Error(error);
  }
};
```

## /**getMerchantServices**

This service provides the mechanism for Paga to request a list of named merchant services and associated service properties provided by the merchant.

```javascript sample code
exports.getMerchantService = async function() {
  try {
    const merchantServices = await MerchantSchema.find().select([
      "name",
      "price",
      "shortCode",
      "productCode",
      "isPublic"
    ]);
    if (!merchantServices) {
      return {
        return: true,
        message: `Merchant services does not exist`
      };
    }
    return {
      error: false,
      message: merchantServices
    };
  } catch (error) {
    throw new Error(error);
  }
};
```

## /**submitTransaction**

**This service is mandatory.**\
This service provides the mechanism for Paga to submit a payment notification to the merchant systems and receive confirmation of its approval.

```javascript sample code
exports.submitTransaction = async function(data) {
  try {
    const { transaction } = data;
    const {
      utcTransactionDateTime,
      transactionType,
      totalAmount,
      merchantAmount,
      isCredit,
      pagaTransactionId,
      merchantTransactionId,
      currency,
      customerReference,
      customerFirstName,
      customerLastName,
      channel,
      description,
      customerPhoneNumber,
      services
    } = transaction;

    console.log(customerFirstName);
    const validCustomer = CustomerSchema.findOne({
      customerReference,
      customerFirstName,
      customerLastName,
      customerPhoneNumber
    });
    if (!validCustomer) {
      return {
        error: true,
        message: `Invalid customer details`
      };
    }

    const newTransaction = await new TransactionSchema({
      transaction: {
        utcTransactionDateTime,
        transactionType,
        totalAmount,
        merchantAmount,
        isCredit,
        pagaTransactionId,
        merchantTransactionId,
        currency,
        customerReference,
        customerFirstName,
        customerLastName,
        channel,
        description,
        customerPhoneNumber,
        services
      }
    });
    await newTransaction.save();
    const {
      transaction: { uniqueTransactionId, confirmationCode }
    } = newTransaction;

    return {
      status: "SUCCESS",
      uniqueTransactionId,
      customerReference,
      merchantStatus: "200",
      message: "Successfully executed payment",
      confirmationCode
    };
  } catch (error) {
    throw new Error(error);
  }
};
```