Search by

mainmoney / mm-aggr-php-sdk

mainmoney

PHP SDK for the MainMoney aggregator merchant API

Package info

github.com/MainMoney-Inc/mm_aggr_php_sdk

pkg:composer/mainmoney/mm-aggr-php-sdk

Statistics

Installs: 178

Dependents: 2

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.2 2026-10-11 02:58 UTC

This package is auto-updated.

Last update: 2026-10-17 21:22:33 UTC


README

Packagist License: MIT

PHP client for the MainMoney aggregator merchant API. Install this package in your PHP application (Laravel, Symfony, WordPress, WooCommerce, or plain PHP).

WordPress and WooCommerce plugins from MainMoney use this SDK on the server. Browser checkout uses the JS/TS frontend SDK and still requires this (or another) backend SDK.

Requirements

  • PHP 8.2 or later (8.4 or 8.5 recommended)
  • Composer
  • A merchant application on MM Aggregator

Install

composer require mainmoney/mm-aggr-php-sdk

Quick start

use MainMoney\Aggregator\Client;

$client = new Client(
    clientId: getenv('MM_CLIENT_ID'),
    secret: getenv('MM_API_SECRET'),
    test: true, // https://testaggregator.mainmoney.net — omit for production
);

$deposit = $client->deposits->create(
    [
        'provider_code' => 'VODACOM_MPESA_COD',
        'reference' => 'ORDER-123',
        'amount' => '100.00',
        'currency' => 'USD',
        'customer_phone' => '243820000000',
    ],
    idempotencyKey: 'ORDER-123',
);

Defaults: production https://aggregator.mainmoney.net/api/v1/, test https://testaggregator.mainmoney.net/api/v1/. Pass baseUri only to override. Configure credentials from your environment. Merchant API docs: /api/v1/docs/merchants/ on the aggregator host.

Exchange client_id and secret for a Bearer access token is handled by the SDK. There is no X-API-KEY header. Resend the same reference and Idempotency-Key only when retrying the same create (same body). When the body changes (new phone number, new currency) use a new Idempotency-Key; after a failed deposit also use a new reference, because a failed one stays reserved. Derive the key from your checkout session, not from the cart or order. Amounts are decimal strings; do not mix currencies.

Verify inbound webhooks with $client->webhooks->verify($rawBody, $signature, $secret).

Do not send merchant API keys to the browser.

License

Copyright (c) 2026 MainMoney SARL. Licensed under the MIT License. See LICENSE.

Examples

A runnable Laravel mini-shop lives in examples/laravel. Pair it with a JS/TS frontend example.

Want to contribute? See CONTRIBUTING.md.