NAV
javascript php java

Introduction

Maybank2u Pay is an online payment platform that simplifies payment process for your business. With our payment gateway, your customers can make purchases instantly from your website with just the click. Apply now for Maybank2u Pay to utilise a secure online payment system to meet your business needs.

You may contact us at maybank2upay@maybank.com regarding on SDK support. We will response to you on the next business day.

Implementation Flow

SCROLL DOWN FOR SAMPLE CODES

The overall flow of the implementation:

1. Generate encrypt array based on input parameters from backend SDK function. `m2upay_backend.getEncryptionString`

2. Pass the encrypted array to front end SDK function to initiate Maybank2u pop up. `m2upay.initPayment`

3a. Testing environment - Maybank2u Pay pop up status will be shown.

3b. Production environment - Customer login Maybank2u and confirm payment with TAC code.

4. Payee will be responded with status by either one or both method below:

a. Realtime Payment Notification

Download SDK

Download the compatible language SDK for your programming stack:

Backend

Make sure to replace payeeCode with your Payee Code provided for selected environment.


<?php
include 'm2upay_phpbackend/M2UPay.php';

use M2U\M2UPay;

//Pass in required parameters 
$m2u_json= array(
  'amount'=> 100.00,
  'accountNumber'=>"A123456", //This “accountNumber” field is for you to pass the purchase ref number / invoice number/ bill number. Maybank will pass the same purchase ref number / invoice number/ bill number back to you (under parameters 'AcctId') to match the transaction status when Maybank send you the  Realtime Payment Notification (RPN).  
  'payeeCode'=>"***"
);

$envType = 0; 
$M2UPay = new M2UPay();
$encrypt_json = $M2UPay->getEncryptionString($m2u_json, $envType);

?>

PGParams params = new PGParams();
int envType= 0;

params.setAmount("100.00");
params.setAccountNumber("A123456"); //This “accountNumber” field is for you to pass the purchase ref number / invoice number/ bill number. Maybank will pass the same purchase ref number / invoice number/ bill number back to you (under parameters 'AcctId') to match the transaction status when Maybank send you the  Realtime Payment Notification (RPN). 
params.setPayeeCode("***");

HashMap encrypt_json = PaymentGateway.getEncryptionString(params, envType);



var m2uPay_backend = require('./m2uPay_backend.js');

var M2U_PAYMENT= {
        'payeeCode':"***",
        'amount':"100.00",
        'accountNumber':"A123456" //This “accountNumber” field is for you to pass the purchase ref number / invoice number/ bill number. Maybank will pass the same purchase ref number / invoice number/ bill number back to you (under parameters 'AcctId') to match the transaction status when Maybank send you the  Realtime Payment Notification (RPN).  
   };

var envType = 0; 

var encrypt_json = m2upay_backend.getEncryptionString(M2U_PAYMENT, envType);

If encryption successful, the encrypt_json returns JSON structured like this:

{
  "encryptedString":"uGJ6%2Bl4prlW5E%2BdLg%2FOaS%2BNAyl0xTJmTiSTUFbeyIUjjErW3eCZ7lSRB3dpQULlUl3YRbfCVHn%2Bem%2FDZowvTds94W%2FZqk7Y1a1K7FOZaEG9g9zuqxEucb1ixT7qW5awAeojMCujqWsi1d39D61hLaiBgJu14cEtwYut4Gk76Dfd83kf9zDIiDPPvF4ps6O08SU8Trl4mr5YihOAFQjuv9w%3D%3D",
  "actionUrl":"https://..."
}
  1. encryptedString

  2. actionUrl

Parameters Type Length Required Description
amount Decimal 9 Mandatory This is the amount field.
Sample for RM100.00:
100.00
accountNumber Alphanumeric 30 Mandatory What Is This Field For?
This “accountNumber” field is for you to pass the purchase ref number / invoice number/ bill number.
Maybank will pass the same purchase ref number / invoice number/ bill number back to you (under parameters 'AcctId') to match the transaction status when Maybank send you the Realtime Payment Notification (RPN).

How Do I Use This Field?
You can use this 'accountNumber' field to match with the 'AcctId' field (sent to you via Payment Notification) to retrieve the transaction status.

Sample:
A12345
payeeCode Numeric 3 Mandatory The payee code is assign by Maybank to the Merchant.

Parameters Type Length Required Description
envType Numeric 1 Mandatory Please specify the right envType for the right environment.
Sample :
0 - playground environment
1 - User Acceptance Test(UAT) environment
2 - Production / Live environment

Frontend

<div id="m2upay" ></div>

<script type="text/javascript" src="m2upay_frontend.js"></script>

<script>
  //TO BE PASS FROM getEncryptionString function.
  var encrypt_json = <?php echo $encrypt_json; ?>

  m2upay.initPayment(encrypt_json.encryptedString,encrypt_json.actionUrl, 'OT');
</script>

<div id="m2upay" ></div>

Payment Notification

Realtime Payment Notification

1. Payee will receive server to server notification in realtime after payment has been made or failed.

2. The realtime notification will be a HTTP POST from Maybank server to the Response URL that you have specified in the Technical Requirement after your Maybank2uPay application has approved.

Payee will receive payment notification from Maybank in JSON format with the parameters shown below:

Sample notification received by payee:

//For sample usage only, please refer to Realtime Payment Notification table for correct parameter's value to be received:

{
  "Msg":{
  "PmtType":"CashPayment",
  "RefId":"M2U112211255",
  "TrnDateTime":"20161109105609",
  "AcctId":"A123456", //This 'AcctId' field is for you to match back the purchase ref number / invoice number/ bill number that has been passed to us.
  "Amt":"10000",
  "StatusCode":"00",
  "StatusDesc":"Successful"

  }
}


Parameters Type Length Description
AcctId Alphanumeric - We will send you the 'AcctId' field for you to match the purchase ref number / invoice number/ bill number which you have passed to getEncryptionString function earlier under field 'accountNumber'.
Sample:
A123456
Amt Numeric - Amount of money paid in cent.
Sample for RM100.00:
10000
PmtType Alpha - Type of Payment.
Sample:
CashPayment or CCardPayment
RefId Alphanumeric - A uniquely generated transaction ID from the bank for this payment.
Sample:
M2UT3695990209302989
StatusCode Numeric 2 Status of the transaction in code.
Sample:
00 = successful, 01 = unsuccessful
StatusDesc Alpha - Status of the transaction in alphabet.
TrnDateTime Numeric - The date and time when the transaction takes place. Time date of 9th November,2016 at 10.56am and 9 seconds will be shown in YYYYMMDDhhmmss format.
Sample:
20161109105609

After receiving the notification, payee needs to return response in the following JSON format with the 2 parameters(RefId & PmtType) received in the notification.

After receiving the notification, payee needs to return response in the following JSON format with the 2 parameters(RefId & PmtType) received in the notification:

//For sample usage only, please refer to Realtime Payment Notification table for correct parameter's value

{
  "Msg": {
    "PmtType": "CashPayment", //This should be the same as the value you received from the notification
    "RefId": "M2U112211255", //This should be the same as the value you received from the notification
    "StatusCode": "0"
  }
}

Parameter receive from payee during notification response as follows in JSON format(check right panel for sample response)

Field Name Description
RefId A uniquely generated transaction ID from the bank for this payment.
**(This should be the same as the value you received from the notification)**
Sample:
M2UT3695990209302989
PmtType Type of Payment.
**(This should be the same as the value you received from the notification)**
Sample:
CashPayment or CCardPayment
StatusCode The various return code from payee’s server.
Sample:
See next table

POSTMAN client screenshot of Maybank sending notification to Payee through HTTP POST method.

Status code expected to receive from payee as follow:

Status Code Description Error Reason
-1 Internal error Error at payee. Request to resend
0 OK Successful
101 Unsuccessful Transaction rejected by merchant
104 Duplicate transaction Merchant has been notified