Skip to main content

mPay SDK

mPay is a JS utility for service providers to implement a checkout solution for mBnk retailers. Service Providers from various sectors can become partners with mBnk for them to promote their goods or services to end customers through mBnk's Retail Distribution Network, a retailer would sell these goods or services to their customers and transact on their behalf on service providers platform wherein they would pay through the mBnk mPay utility.

note

Before proceeding with the integration, please provide us with the host e.g. https://www.example.com.
Host whitelisting is required to process the transactions.

Examples

N|Solid

Implementation of mBnk mPay


Step 1

A <script> tag must be included in <head> tag of Service Provider's payment page

<script src="https://assets.mbnk.com/mbnk-pay/client/mBnk.pay.min.js"></script>

Step 2

The mBnKPay has to initialized with Payment and Environment Information

  • retailerToken (OPTIONAL) will be provided by mBnk, mBnk Web App opens the website either using iframe or web redirect or mBnk Marketplace App opens through website using Web View. We would pass the retailerToken using GET params to you.
  • key will be provided to you by mBnK and will be unique to you
  • hash to be generated using SHA512 with | as separator of key,transactionId,amount and salt
  • transactionId must be unique transactionId provided by you
  • isProductOrService specify whether your are offering a product or service
  • amount the total amount for goods or services e.g. 100.00/100.50
  • logo The logo url of the service provider (would be shown to retailer in mBnk mPay UI)
  • productOrServices A list of Product or Service information
    • id Product or Service ID assigned by service provider e.g. SKU, id, key
    • categoryId Category ID would be provided by mBnk to you
    • description Product or Service information
    • amount The Amount or Cost of the Product or Service e.g. 100.00/100.50
  • customer Customer information must be passed here
    • mobileNo Customer's Mobile No
    • name Customer's name
    • email Customer's Email ID

The GET parameters passed are

  • mobileNo (Customer Mobile No),
  • name (Customer Name),
  • email (Customer Email) and
  • retailerToken (Retailer's token issued by mBnk never to be stored, needs to be used for that session itself).
note

The mBnKPay function has to invoked with environment information. There are two environment wherein Service Provider can invoke mBnk mPay

  • qa (QA)
  • prd (Production)
info

Service Provider has to integrate and test the implementation in QA first and once ready mBnK will provide prod credentials and go live

note

Hash to be generated using SHA512 with | as separator of key,transactionId,amount and salt

mBnKPay("qa" or "prd", {
retailerToken: "retailerToken", // optional, will be provided by mBnk via GET
key: "your-key", // the key provided by mBnk
hash: "random string", // Hash generated using above logic needs to be set here
transactionId: "123456789", // The unique transaction Id generated by you
isProductOrService: true, // Is it product or service that you are offering
productOrServices: [
{
id: "test", // The Product or Service ID can be a SKU, id, etc.
categoryId: 'test', // Will be provided by mBnk
description: "Test Product", // The information of the Product or Service
amount: "100.00" // The cost of the Product or Service
}
],
customer: { // Optional, if provided would be better
name: "Test Test", // Customer's Name
email: "test@mbnk.com", // Customer's Email ID
mobileNo: "9757000000", // Customer's Mobile No
},
amount: "100.00", // The total amount of the transaction
logo: "https://assets.mbnk.com/logo/mBnk.png" // The service providers logo url to be passed by you
}, transaction => {
console.log(transaction)
}, initFailed => {
console.log(initFailed)
})

Two callbacks needs to be provided as well as part of init function

  • Transaction The transaction object would contain the transaction information
{
amount: "100.00", // The total amount of the transaction
clientTransactionId: "123456789", // The transaction ID provided by you
message: "Transaction Successful", // The transaction message
status: "SUCCESS" or "FAILED" // The status of transaction
transactionId: "aaaaaaaaa", // The transaction ID provided by mBnk
date: "2021-12-30T06:45:06.320Z", // The date of the transaction in ISO8601 format
hash: "random string", // These hash needs to be verified by service provider
}
  • Initialization Failed
{
statusCode: "xxxx",
message: "message" // The error message will be sent in here
}

If the init object is not proper, the initFailed callback would be invoked with error code and message

If everything is fine with the payload, the transaction process would be handled further by mBnK and the response would be provided to service provider with transaction information whether its success or failure with reasons. And if required mBnK can also invoke the service provider's webhook as well for transaction information.

note

Hash needs to verified at server side using SHA512 with | as separator of key, transactionId, clientTransactionId, amount, status and salt

caution

Salt needs to be stored in backend and never to be exposed in client as it is used to verify and generate hash for the transaction.

Try mBnk mPay

Service Provider Information