Giter VIP home page Giter VIP logo

cmi-php's Introduction

CMI PHP Payment bindings

CMI PHP PAYMENT is an open source PHP payment handling library. it provides an easier way to communicate with CMI PAYMENT PLATEFORM cmi.co.ma in morocco.

The class is written OOP to make easier to communicate and understand how CMI work.

NB: The small library follows the FIG standard PSR-4 .

System Requirements

cmi-php requires the following components to work correctly

Composer Installation

You can install the bindings via composer. Run the following command:

composer require mehdirochdi/cmi-payment-php

To use the bindings, use Composer's autoload

require_once('vendor/autoload.php');

Manual Installation

If you do not wish to use Composer for some reason, you can usethe bindings, include the init.php file.

require_once('/path/to/cmi-php/init.php');

Getting Started

Example amount text fields example/formRequest.php:

...
    <h1>Payment form CMI</h1>
    <form method="post" action="/example/process.php">
    <label for="amount">Amount</label>
        <input type="text" name="amount" class="input-control" placeholder="put amount here 10.65" value="10.60"> DHS<br/>
        <button type="submit">Buy</button>
    </form>
...

Keeping mind that storekey and clientid are given by CMI, you should contact them cmi.co.ma

<?php
// REQUIRED PARAMS
$client = new Mehdirochdi\CMI\CmiClient([
    'storekey' => '', // STOREKEY
    'clientid' => '', // CLIENTID
    'oid' => '135ABC', // COMMAND ID IT MUST BE UNIQUE
    'shopurl' => 'YOUR_DOMAIN_HERE', // SHOP URL FOR REDIRECTION
    'okUrl' => 'YOUR_DOMAIN_HERE/okFail.php', // REDIRECTION AFTER SUCCEFFUL PAYMENT
    'failUrl' => 'YOUR_DOMAIN_HERE/okFail.php', // REDIRECTION AFTER FAILED PAYMENT
    'email' => '[email protected]', // YOUR EMAIL APPEAR IN CMI PLATEFORM
    'BillToName' => 'mehdi rochdi', // YOUR NAME APPEAR IN CMI PLATEFORM
    'BillToCompany' => 'company name', // YOUR COMPANY NAME APPEAR IN CMI PLATEFORM
    'amount' => $_POST['amount'], // RETRIEVE AMOUNT WITH METHOD POST
    'CallbackURL' => 'YOUR_DOMAIN_HERE/callback.php', // CALLBACK
]);

$client->redirect_post(); // CREATE INPUTS HIDDEN, GENERATE A VALID HASH AND MAKE REDIRECT POST TO CMI
?>

Payment page

Basic test card numbers

Credit Card information cannot be used in test mode. instead, use any of the following test card numbers, a valid expiration date in the future, and any random CVC number, to create a successful payment.

Branch : visa, PAN: 4000000000000010, Expired date: make any date CVC: 000

Branch : MasterCard, PAN: 5453010000066100, Expired date: make any date CVC: 000

3D Secure test card numbers

The following card information try to tests local payments such as Strong Customer Authentication SCA

Branch : MasterCard, PAN: 5191630100004896, Authentication code: 123 Expired date: make any date CVC: 000

Payment page

Optional Params Example

<?php
// REQUIRED PARAMS
$client = new Mehdirochdi\CMI\CmiClient([
    ...
    'AutoRedirect' => 'true',
]);
OR
$client->AutoRedirect = 'true'; // REDIRECT THE CUSTOMER AUTOMATICALY BACK TO THE MERCHANT's WEB SITE WHEN TRANSACION IS ACCEPTED
$client->redirect_post(); // CREATE INPUTS HIDDEN, GENERATE A VALID HASH AND MAKE REDIRECT POST TO CMI

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.