Skip to content
Branch: master
Go to file

Latest commit


Failed to load latest commit information.
Latest commit message
Commit time

Omnipay: MOLPay

MOLPay driver for the Omnipay PHP payment processing library

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

Omnipay is a framework agnostic, multi-gateway payment processing library for PHP 5.3+. This package implements MOLPay support for Omnipay.

MOLPay is a payment gateway offering from MOLPay Sdn Bhd. This package follows the MOLPay API Specification (Version 13.7: Updated on 10 Oct 2017).


Omnipay is installed via Composer. To install, simply add it to your composer.json file:

    "require": {
        "leesiongchan/omnipay-molpay": "~2.0"

And run composer to update your dependencies:

$ curl -s | php
$ php composer.phar update

Basic Usage

The following gateways are provided by this package:

  • MOLPay (MOLPay Payment)

For general usage instructions, please see the main Omnipay repository.


Create a purchase request

The example below explains how you can create a purchase request then send it.

$gateway = Omnipay::create('MOLPay');

$gateway->setEnableIPN(true); // Optional
$gateway->setLocale('en'); // Optional

$options = [
    'amount' => '10.00',
    'card' => new CreditCard(array(
        'country' => 'MY',
        'email' => '',
        'name' => 'Lee Siong Chan',
        'phone' => '0123456789',
    'description' => 'Test Payment',
    'transactionId' => '20160331082207680000',
    'paymentMethod' => 'credit', // Optional

$response = $gateway->purchase($options)->send();

// Get the MOLPay payment URL (
$redirectUrl = $response->getRedirectUrl();

Complete a purchase request

When the user submit the payment form, the gateway will redirect you to the return URL that you have specified in MOLPay. The code below gives an example how to handle the server feedback answer.

$response = $gateway->completePurchase($options)->send();

if ($response->isSuccessful()) {
    // Do something
    echo $response->getTransactionReference();
} elseif ($response->isPending()) {
    // Do something
} else {
    // Error

Void or Reverse a 'captured' transaction

Only available for limited merchants and channels

The following is the example to void a captured transaction, your can refer to MOLPay Reversal Request api spec.

$gateway = Omnipay::create('MOLPay');


$request = $gateway->void([
    'transactionReference' => '25248208'
$response = $request->send();

if ($response->isSuccessful()) {
    // Update your data model
} else {
    echo $response->getMessage();

Request Partial Refund for a 'captured' or 'settled' transaction

Only available for limited merchants and channels

To perform a partial refund, you need to specify more parameters as below

$gateway = Omnipay::create('MOLPay');


$request = $gateway->refund([
    'transactionReference'  => '25248208',
    'refId'                 => 'merchant_refund_red_id',
    'amount'                => '10.00',
    'channel'               => $transaction_channel, // data saved from $gateway->purchase() response, e.g FPX_MB2U
    'bankCode'              => $bank_code, // from user who request to refund
    'beneficiaryName'       => $beneficiary_name, // from user who request to refund
    'beneficiaryAccountNo'  => $beneficiary_account_no, // from user who request to refund
$response = $request->send();

// The refund process will take about 7-14 days after the request sent
if ($response->isSuccessful() || $response->isPending() ) {
    // Update your data model
} else {
    echo $response->getMessage();

Out Of Scope

Omnipay does not cover recurring payments or billing agreements, and so those features are not included in this package. Extensions to this gateway are always welcome.


If you are having general issues with Omnipay, we suggest posting on Stack Overflow. Be sure to add the omnipay tag so it can be easily found.

If you want to keep up to date with release anouncements, discuss ideas for the project, or ask more detailed questions, there is also a mailing list which you can subscribe to.

If you believe you have found a bug, please report it using the GitHub issue tracker, or better yet, fork the library and submit a pull request.

You can’t perform that action at this time.