2017 © Pedro PelĂĄez
 

symfony-bundle etransactions-bundle

Payment gateway for E-transactions (Crédit Agricole).

image

snowbaha/etransactions-bundle

Payment gateway for E-transactions (Crédit Agricole).

  • Monday, July 31, 2017
  • by Snowbaha
  • Repository
  • 2 Watchers
  • 0 Stars
  • 52 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 3 Versions
  • 13 % Grown

The README.md

E-transactionsBundle

SensioLabsInsight Latest Stable Version Total Downloads, (*1)

This bundle allows to implement a Payment Solution working with E-transactions for your symfony project. E-transactions is a payment proposed by the following bank "Crédit Agricole". Don't hesitate to contact me to improve it ;), (*2)

Installation

Step 1 : Import using Composer

Using composer :, (*3)

{
    "require": {
        "snowbaha/etransactions-bundle": "~1.0"
    }
}

Step 2 : Enable the plugin

Enable the bundle in the kernel:, (*4)

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Snowbaha\EtransactionsBundle\SnowbahaEtransactionsBundle(),
    );
}

Step 3 : Configure the bundle

Mandatory fields PARAMETER:, (*5)

# E-Transactions (don't forget the validation of the HMAC key 'certif_test/prod' by email)
    etransactions_id: ~
    etransactions_site: ~
    etransactions_certif_test: ~
    etransactions_certif_prod: ~

Mandatory fields CONFIG :, (*6)

snowbaha_etransactions:
    # Credentials
    identifiant: "%etransactions_id%"
    site: "%etransactions_site%"
    rang: "01" #change it with your RANK
    # Keys
    key_dev: "%etransactions_certif_test%"
    key_prod: "%etransactions_certif_prod%"
    # SETTING OPTIONAL
    env_mode: TEST # TEST by default - Possible values : TEST / PRODUCTION
    # check_signature: false # /!\ KEEP IT to false because it doesn't work and i DONT KNOW WHY (let me know if you have a solution) false by Default (if you want to check the signature of the IPN Bank

How to use

Controller

Create a Transaction

To initiate a new Transaction, you need to create an action in one of your controller and call the snowbaha.etransactions service. All mandatory fields are used with their default value. You can configure all the common fields of your transactions in the app/config/config.yml file., (*7)

To see what fields are available see the PDF official doc., (*8)

Service Method
  • init($order_id, $amount, $email_buyer, $currency = 978) allows you to specify the id, amount, email of buyer and the currency of the transaction.
  • setOptionnalFields(array) allows you to specify any field.
Example
    /**
     * @Route("/initiate-payment/id-{id}", name="pay_online")
     * @Template()
     */
    public function payOnlineAction($id)
    {
        // ...
        $etransactions = $this->get('snowbaha.etransactions')
            ->init(99, 100, 'buyer@buy.com')
            ->setOptionnalFields(array(
                'PBX_ERREUR' => 'http://www.example.com/error'
            ))
        ;

        return $this->render('YOURBUNDLEBundle:Etransactions:pay_online.html.twig', array(
                    'paymentUrl' => $etransactions->getPaymentUrl(),
                    'fields' => $etransactions->getFields(),
                ));
    }

Handle the response from the server

This route will be called by the E-Transactions service to update you about the payment status. This is the only way to correctly handle payment verfication., (*9)

Service Method: * responseBankServer(Request) is used to update the transaction status (in database) * You will get a array with : * sucessPayment: (should be true to validate the payment) * amount: (your pbx_total var) * ref: (your pbx_cmb var) * error:E; (error with 00000 if nothing) * auto:A; (autorisation) * sign:K (signature to check), (*10)

Example
    // YOUR CONTROLLER
    /**
     * THIS ROUTE have to be public to allow the bank access, it is the URL you will provide to your account 
     * @Route("/payment/verification")
     * @param Request $request
     */
    public function paymentVerificationAction(Request $request)
    {
        // ...
         $responseBank = $this->get('snowbaha.etransactions')->responseBankServer($request);

        $id_order = (int)$responseBank['ref'];
        $Order = $this->get('app.provider.order')->getOneByID( $id_order );

        // Success
        if($responseBank['sucessPayment'] === true && !is_null($Order)) :

            $Order->setState("order.state.success_payment");
            $Order->setPaymentError(0);

            // Email notification
            $this->get('app.mailing.order')->sendNewOrderNotif($Order);

        elseif( !is_null($Order) ) :
            // Error
            $Order->setState('order.state.success_payment_error');
            $Order->setPaymentError($responseBank['error']);
        endif;

        //...
    }

Template

This is how the template for the payOnlineAction() may look like. You can use the paiementForm twig function to automatically generate the form based on the fields created in the service and returned by the getFields() function., (*11)

    <html>

        <i class="fa fa-refresh fa-spin margin-top margin-bottom" style="font-size: 50px"></i> {# With http://fontawesome.io/icons/ #}
        <h3>Redirect to the paiement page...</h3>
        <form action="{{ paymentUrl }}" method="POST" id="etransactions-form">
            {{ paiementForm(fields) }}

            {# If no JS, show the button to submit#}
            <noscript>
                <input type="submit" value="Pay">
            </noscript>
        </form>

    </html>
    <script type="text/javascript">
        document.getElementById('etransactions-form').submit();
    </script>

LOG

When you will get an error with the payment, you can have more information with the log : ENV.etransaction.log, (*12)

The Versions

31/07 2017

dev-master

9999999-dev

Payment gateway for E-transactions (Crédit Agricole).

  Sources   Download

MIT

The Requires

 

bank credit paiement banque etransactions agricole

03/05 2017

1.0.1

1.0.1.0

Payment gateway for E-transactions (Crédit Agricole).

  Sources   Download

MIT

The Requires

 

bank credit paiement banque etransactions agricole

02/05 2017

1.0.0

1.0.0.0

Payment gateway for E-transactions (Crédit Agricole).

  Sources   Download

MIT

The Requires

 

bank credit paiement banque etransactions agricole