/m2upay

Maybank2u Pay - PHP SDK

Primary LanguagePHP

Maybank2U Pay - PHP SDK

Latest Stable Version

This is an PHP SDK library for Maybank2U Pay

Installation

Composer (recommended)

Use Composer to install this library from Packagist: putera/m2upay

Run the following command from your project directory to add the dependency:

composer require putera/m2upay

Alternatively, add the dependency directly to your composer.json file:

{
	"require": {
    		"putera/m2upay": "*"
	}
}

Direct download

Download the ZIP file and extract into your project. An autoloader script is provided in src/autoload.php which you can require into your script. For example:

require_once '/path/to/m2upay/src/autoload.php';

The classes in the project are structured according to the PSR-4 standard, so you can also use your own autoloader or require the needed files directly in your code.

Usage

<?php

use M2U\M2UPay;

$m2upay = new M2UPay();

// Environment Type
// 0 : Sandbox
// 1 : User Acceptance Test (UAT)
// 2 : Production / Live
$envType = 0;

$mydata = array(
	'amount' => 100.00,
	'accountNumber' => "A123456",
  	'payeeCode' => "***"
);

$encryptedData = $m2upay->getEncryptionData($mydata, $envType);


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

<script type="text/javascript" src="/path/to/m2upay/src/M2UPay.js"></script>

<script>
	var encrypt_data = <?php echo $encryptedData; ?>
	M2UPay.initPayment(encrypt_data.encryptedString, encrypt_data.actionUrl, 'OT');
</script>

Thanks !