fm-labs/cakephp-mpay24

Mpay24 plugin for CakePHP

Installs: 34

Dependents: 0

Suggesters: 1

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:cakephp-plugin

1.0.2 2023-03-27 20:23 UTC

This package is auto-updated.

Last update: 2024-12-28 00:31:40 UTC


README

CakePHP wrapper for Mpay24's official PHP SDK Client MPAY24's official PHP SDK

Installation

You can install this plugin into your CakePHP application using composer.

The recommended way to install composer packages is:

composer require fm-labs/cakephp-mpay24
// src/Application.php

class Application extends \Cake\Application {
    public bootstrap($configDir) {
        // ... your bootstrap code ...
        $this->addPlugin('FmLabs/Mpay24')
    }
}

Configuration

// config/mpay24.php

<?php
return [
    'Mpay24' => [
        'production' => [
            'merchantId' => '',
            'merchantPassword' => '',
            'useTestSystem' => false,
            'debug' => true,
        ],

        'testing' => [
            'merchantId' => '',
            'merchantPassword' => '',
            'useTestSystem' => true,
            'debug' => true,
        ]
    ]
];

Usage

Api Client

try {
    $mpay24 = new \FmLabs\Mpay24\Lib\Mpay24Client('testing');
    
    $mdxi = new \FmLabs\Mpay24\Lib\Mpay24Order()
    // ... setup mdxi order ...

    if (!$mdxi->validate()) {
        throw new \RuntimeException('Failed to validate MDXI.');
    }

    $mpay24Response = $mpay24->paymentPage($mdxi);
    $paymentPageURL = $mpay24Response->getLocation(); // get redirect location to the payment page
    if ($paymentPageURL) {
        // ... redirect user to payment page ... 
    }
} catch (\Exception $ex) {
    debug("Something went wrong: " . $ex->getMessage());
}

Testdata

All testdata in the official docs: https://docs.mpay24.com/docs/test-data

Credit cards

Test data:

Mastercard card number: 5555444433331111
Visa card number: 4444333322221111
Expiry date: arbitrary, see Test scenarios below

Test scenarios: Various scenarios results can be created by providing different expiry dates of the credit card for brand VISA and MASTERCARD: