Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Cmi Pay Bundle Laravel Package

cmiecom/cmi-pay-bundle

View on GitHub
Deep Wiki
Context7

CMI payment Bundle

Straight forward integration of CMI payment module into Symfony applications.

  • How CMI payment process works?*

    A client fills the form on your side and then submits the form. Then the client will be redirected to CMI payment page to complete the payment. Once the payment has been completed the client has the option to return back to your website and at the same time a callback is send from Cmi to your callback url.

Setup

This bundle allows you to add cmi payment process with minimum changes to your code. These instructions will also guide you through the installation of that bundle.

Installation

Install with composer:

composer require cmiecom/cmi-pay-bundle

Include routes.xml in your routing file :

// config/routes.yaml

_cmi_pay:
    resource: '@CmiPayBundle/Resources/config/routes.xml'

Usage

Rendering the form and redirect client to CMI page payment

The default route configured in:

// src/Resources/config/routes.xml
	<route id="cmi_pay_request" controller="cmi.pay.controller::requestPay" path="/cmi/requestpayment" />

And a controller action to render the form:

namespace CmiPayBundle\Controller;

......

class CmiPayController extends AbstractController
{
    public function requestPay(Request $request)
    {
        $params = new CmiPay();
        // Setup new payment parameters
        $okUrl = $this->generateUrl('cmi_pay_okFail', [], UrlGeneratorInterface::ABSOLUTE_URL);
        $shopUrl = $baseurl = $request->getScheme() . '://' . $request->getHttpHost() . $request->getBasePath();
        $failUrl = $this->generateUrl('cmi_pay_okFail', [], UrlGeneratorInterface::ABSOLUTE_URL);
        $callbackUrl = $this->generateUrl('cmi_pay_callback', [], UrlGeneratorInterface::ABSOLUTE_URL);
        $rnd = microtime();
	//Sample Order Data:
        $params->setGatewayurl('https://....')// Provided by CMI
            ->setclientid('600000000')// Provided by CMI
            ->setTel('05000000')
            ->setEmail('email@domaine.ma')
            ->setBillToName('BillToName')
            ->setBillToCompany('BillToCompany')
            ->setBillToStreet1('BillToStreet1')
            ->setBillToStateProv('BillToStateProv')
            ->setBillToPostalCode('BillToPostalCode')
	//.................
        ;
	//.................        
    }
}

The twig template:

// src/Resources/views/payrequest.html.twig
{% extends 'base.html.twig' %}

{% block title %}Hello {% endblock %}

{% block body %}

    <form name="payForm"  id="payForm" method="post" action="{{url}}">
        {% for name, value in data %}
            <input type="hidden" name="{{ name }}" value="{{ value }}" />
        {% endfor %}
    </form>

{% endblock %}
............

Callback

The default route configured in:

// src/Resources/config/routes.xml
	<route id="cmi_pay_callback" controller="cmi.pay.controller::callback" path="/cmi/callback" />

And a controller action : Callback:

namespace CmiPayBundle\Controller;

......

class CmiPayController extends AbstractController
{
..........
    public function callback(Request $request)
    {
        .......
    }
}

The twig template:

// src/Resources/views/callback.html.twig
{{response}} 

OK / FAIL URL

The default route configured in:

// src/Resources/config/routes.xml
	<route id="cmi_pay_okFail" controller="cmi.pay.controller::okFail" path="/cmi/okFail" />

And a controller action : okFail:

namespace CmiPayBundle\Controller;

......

class CmiPayController extends AbstractController
{
..........
    public function okFail(Request $request)
    {
        ........
    }
}

The twig template:

// src/Resources/views/okFail.html.twig
{{response}}

Calculate Hash value

Controller action : hashValue:

namespace CmiPayBundle\Controller;

......

class CmiPayController extends AbstractController
{
..........
   public function hashValue($data)
    {
        $params = new CmiPay();
        $params->setSecretKey('TEST1234');//Secret key generated from CMI Backoffice
        ..........        
        return $hash;
    }
}
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
nasirkhan/laravel-sharekit
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony