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
Requires
- php: >=8.0
- ext-soap: *
- cakephp/cakephp: ^4.4
- mpay24/mpay24-php: ^5.1
Requires (Dev)
- phpunit/phpunit: ^8.5 || ^9.3
README
CakePHP wrapper for Mpay24's official PHP SDK Client MPAY24's official PHP SDK
- Mpay24 GitHub: https://github.com/mpay24/mpay24-php
- Mpay24 Docs: https://docs.mpay24.com/docs
- Mpay24 Demo: https://docs.mpay24.com/docs/get-started
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: