PHPackages                             myanmyanpay/mmpay-php-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. myanmyanpay/mmpay-php-sdk

ActiveLibrary

myanmyanpay/mmpay-php-sdk
=========================

PHP SDK for MyanMyanPay Integration

v1.0.0(3mo ago)079PHPPHP &gt;=7.4

Since Jan 23Pushed 3mo agoCompare

[ Source](https://github.com/nawing/MMPay-Php-SDK)[ Packagist](https://packagist.org/packages/myanmyanpay/mmpay-php-sdk)[ RSS](/packages/myanmyanpay-mmpay-php-sdk/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

MMPay PHP SDK
=============

[](#mmpay-php-sdk)

A professional, comprehensive PHP client library for integrating with the MMPay Payment Gateway. This SDK mimics the official Node.js SDK structure, providing robust utilities for payment creation, handshake authentication, and secure webhook verification.

📦 Installation
--------------

[](#-installation)

Requires PHP 7.4 or higher.

Install the package via Composer:

```
composer require myanmyanpay/mmpay-php-sdk
```

🚀 Configuration
---------------

[](#-configuration)

To start, initialize the SDK with your Merchant credentials found in the MMPay Dashboard.

```
use MMPay\MMPay;

$options = [
    'appId'          => 'YOUR_APP_ID',
    'publishableKey' => 'YOUR_PUBLISHABLE_KEY',
    'secretKey'      => 'YOUR_SECRET_KEY',
    'apiBaseUrl'     => '[https://api.mmpay.com](https://api.mmpay.com)'
];

$sdk = new MMPay($options);
```

### Configuration Parameters

[](#configuration-parameters)

ParameterTypeRequiredDescription`appId``string`**Yes**Your unique Application ID.`publishableKey``string`**Yes**Public key used for identification.`secretKey``string`**Yes**Private key used for HMAC SHA256 signing.`apiBaseUrl``string`**Yes**The base URL for the MMPay API.---

🛠 Usage
-------

[](#-usage)

### 1. Create a Payment (Sandbox)

[](#1-create-a-payment-sandbox)

Use `sandboxPay` for testing. This method automatically handles the required handshake and signature generation.

```
try {
    $params = [
        'orderId'       => 'ORD-SANDBOX-001',
        'amount'        => 5000,
        'currency'      => 'MMK',
        'callbackUrl'   => '[https://yoursite.com/webhook/mmpay](https://yoursite.com/webhook/mmpay)',
        'customMessage' => 'Thank you for shopping with us!', // Optional
        'items'         => [
            [
                'name'     => 'Premium Subscription',
                'amount'   => 5000,
                'quantity' => 1
            ]
        ]
    ];

    $response = $sdk->sandboxPay($params);
    print_r($response);

} catch (Exception $e) {
    echo "Payment Failed: " . $e->getMessage();
}
```

#### Parameters: `sandboxPay` / `pay`

[](#parameters-sandboxpay--pay)

ParameterTypeRequiredDescription`orderId``string`**Yes**Unique identifier for this order.`amount``number`**Yes**Total transaction amount.`items``array`**Yes**Array of item objects (see structure below).`currency``string`NoCurrency code (e.g., "MMK").`callbackUrl``string`NoURL where the webhook result will be posted.`customMessage``string`NoA custom message to display on the payment page.#### Structure: `items` (Array of Objects)

[](#structure-items-array-of-objects)

KeyTypeRequiredDescription`name``string`**Yes**Name of the product or service.`amount``number`**Yes**Cost per unit.`quantity``integer`**Yes**Number of units.---

### 2. Create a Payment (Production)

[](#2-create-a-payment-production)

For live transactions, switch to the `pay` method.

```
try {
    $params = [
        'orderId'     => 'ORD-LIVE-888',
        'amount'      => 10000,
        'items'       => [
            ['name' => 'E-Commerce Item', 'amount' => 10000, 'quantity' => 1]
        ]
    ];

    $response = $sdk->pay($params);

    // Redirect user to the payment URL provided in the response
    if (isset($response['url'])) {
        header('Location: ' . $response['url']);
        exit;
    }

} catch (Exception $e) {
    echo "Error: " . $e->getMessage();
}
```

---

### 3. Verify Webhook (Callback)

[](#3-verify-webhook-callback)

Secure your application by verifying the cryptographic signature of incoming webhooks. This ensures the request actually came from MMPay.

**Handling callbacks**

Incoming HTTP POST Parameters

Header

Field NameTypeRequiredDescription**Content-Type**`string`Yes'application/json'**X-Mmpay-Signature**`string`Yes'34834890vfgh9hnf94irfg\_48932i4rt90349849'**X-Mmpay-Nonce**`string`Yes'94843943949349'Body

Field NameTypeRequiredDescription**orderId**`string`YesUnique identifier for the specific order.**amount**`number`YesThe transaction amount.**currency**`string`YesThe 3-letter currency code (e.g., MMK, USD).**vendor**`string`YesIdentifier for the vendor initiating the request.**method**`'QR', 'PIN', 'PWA', 'CARD'`YesIdentifier for the method.**status**`'PENDING','SUCCESS','FAILED','REFUNDED'`YesCurrent status of the transaction.**condition**`'PRESTINE', 'TOUCHED'`YesUsed QR Code scan again or not**transactionRefId**`string`YesThe reference ID generated by the payment provider.**callbackUrl**`string`NoOptional URL to receive webhooks or updates.**customMessage**`string`NoUser provided custom message#### Pure PHP Example

[](#pure-php-example)

```
// 1. Capture the raw POST body (Required for signature check)
$payload = file_get_contents('php://input');

// 2. Capture Headers
$headers = getallheaders();
$nonce = $headers['X-Mmpay-Nonce'] ?? '';
$signature = $headers['X-Mmpay-Signature'] ?? '';

// 3. Verify
try {
    $isValid = $sdk->verifyCb($payload, $nonce, $signature);

    if ($isValid) {
        // ✅ Signature matched. Process the order.
        $data = json_decode($payload, true);
        $status = $data['status'];

        if ($status === 'SUCCESS') {
            // Mark order as paid in DB
        }

        http_response_code(200);
        echo "OK";
    } else {
        // ❌ Signature mismatch. Potential fraud.
        http_response_code(400);
        echo "Invalid Signature";
    }
} catch (Exception $e) {
    http_response_code(400);
    echo "Error: " . $e->getMessage();
}
```

#### Laravel Controller Example

[](#laravel-controller-example)

In Laravel, you should use the `Request` object to fetch headers and the raw content.

```
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use MMPay\MMPay;
use Illuminate\Support\Facades\Log;

class PaymentController extends Controller
{
    public function handleWebhook(Request $request)
    {
        // Initialize SDK (Preferably via Service Provider or Config)
        $sdk = new MMPay([
            'appId'          => config('services.mmpay.app_id'),
            'publishableKey' => config('services.mmpay.key'),
            'secretKey'      => config('services.mmpay.secret'),
            'apiBaseUrl'     => config('services.mmpay.url'),
        ]);

        // 1. Get Raw Content (Crucial for signature verification)
        $payload = $request->getContent();

        // 2. Get Headers
        $nonce = $request->header('X-Mmpay-Nonce');
        $signature = $request->header('X-Mmpay-Signature');

        if (!$nonce || !$signature) {
            return response()->json(['message' => 'Missing Signature Headers'], 400);
        }

        // 3. Verify Signature
        try {
            $isValid = $sdk->verifyCb($payload, $nonce, $signature);

            if (!$isValid) {
                Log::warning('MMPay Webhook Signature Mismatch', ['ip' => $request->ip()]);
                return response()->json(['message' => 'Invalid Signature'], 400);
            }

            // ✅ Signature Valid - Process Logic
            $data = json_decode($payload, true);

            if ($data['status'] === 'SUCCESS' && $data['condition'] === 'PRESTINE') {
                // Update Order Status in Database
                // Order::where('order_id', $data['orderId'])->update(['status' => 'paid']);
            }

            return response()->json(['status' => 'success']);

        } catch (\Exception $e) {
            Log::error('MMPay Webhook Error: ' . $e->getMessage());
            return response()->json(['message' => 'Server Error'], 500);
        }
    }
}
```

#### Parameters: `verifyCb`

[](#parameters-verifycb)

ParameterTypeDescription`payload``string`The **raw, unmodified** JSON string body of the request.`nonce``string`Value of the `X-Mmpay-Nonce` header.`expectedSignature``string`Value of the `X-Mmpay-Signature` header.---

⚠️ Error Handling
-----------------

[](#️-error-handling)

The SDK throws standard PHP `\Exception` when errors occur (e.g., network issues, API validation errors, or handshake failures).

```
try {
    $sdk->pay($params);
} catch (\Exception $e) {
    // Log the error for debugging
    error_log($e->getMessage());

    // Return a user-friendly message
    echo "We could not process your payment at this time.";
}
```

---

Error Codes
-----------

[](#error-codes)

##### Api Key Layer Authentication \[SERVER SDK\]

[](#api-key-layer-authentication-server-sdk)

CodeDescription**`KA0001`**Bearer Token Not Included In Your Request**`KA0002`**API Key Not 'LIVE'**`KA0003`**Signature mismatch**`KA0004`**Internal Server Error ( Talk to our support immediately fot this )**`KA0005`**IP Not whitelisted**`429`**Ratelimit hit only 1000 request / minute allowed##### JWT Layer Authentication \[SERVER SDK\]

[](#jwt-layer-authentication-server-sdk)

CodeDescription**`BA001`**`Btoken` is nonce one time token is not included**`BA002`**`Btoken` one time nonce mismatch**`BA000`**Internal Server Error ( Talk to our support immediately fot this )**`429`**Ratelimit hit only 1000 request / minute allowed---

📄 License
---------

[](#-license)

MIT License.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance80

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

107d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3d4e2194bf560c667f3820a4d426aa328e5e70029f19d020938c8d46eba012f8?d=identicon)[nawing](/maintainers/nawing)

---

Top Contributors

[![nawing](https://avatars.githubusercontent.com/u/23611465?v=4)](https://github.com/nawing "nawing (4 commits)")

### Embed Badge

![Health badge](/badges/myanmyanpay-mmpay-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/myanmyanpay-mmpay-php-sdk/health.svg)](https://phpackages.com/packages/myanmyanpay-mmpay-php-sdk)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.6k509.9M17.0k](/packages/laravel-framework)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M256](/packages/laravel-dusk)[laravel/vapor-cli

The Laravel Vapor CLI

31310.7M8](/packages/laravel-vapor-cli)[netflie/whatsapp-cloud-api

The first PHP SDK to send and receive messages using a cloud-hosted version of the WhatsApp Business Platform

640431.7k4](/packages/netflie-whatsapp-cloud-api)[tempest/framework

The PHP framework that gets out of your way.

2.1k23.1k9](/packages/tempest-framework)[blair2004/nexopos

The Free Modern Point Of Sale System build with Laravel, TailwindCSS and Vue.js.

1.2k2.3k](/packages/blair2004-nexopos)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
