2017 © Pedro PelĂĄez
 

yii2-extension yii2-ceca-tpv

Manage payment form generator from CECA TPV

image

macklus/yii2-ceca-tpv

Manage payment form generator from CECA TPV

  • Wednesday, May 18, 2016
  • by macklus
  • Repository
  • 1 Watchers
  • 0 Stars
  • 19 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 6 % Grown

The README.md

CECA Tpv plugin

Manage payment form generator from CECA TPV, (*1)

Installation

The preferred way to install this extension is through composer., (*2)

Either run, (*3)

php composer.phar require --prefer-dist macklus/yii2-ceca-tpv "*"

or add, (*4)

"macklus/yii2-ceca-tpv": "*"

to the require section of your composer.json file., (*5)

Configure

Configure tpv component, using:, (*6)

'tpv' => [
            'class' => 'macklus\CECATpv\Tpv',
            'mode' => 'prod',
            'debug' => [
                'AcquirerBIN' => '0000XXXXXX',
                'MerchantID' => '0XXXXXXXX',
                'TerminalID' => '0000000X',
                'Exp' => 'X',
                'URL_OK' => '',
                'URL_NOK' => '',
                'Key' => 'XXXXXXXX',
            ],
            'prod' => [
                'AcquirerBIN' => '0000XXXXXX',
                'MerchantID' => '0XXXXXXXX',
                'TerminalID' => '0000000X',
                'Exp' => 'X',
                'URL_OK' => '',
                'URL_NOK' => '',
                'Key' => 'XXXXXXXX',
            ],
        ],

The mode variable define usage mode, so far:, (*7)

  1. prod: production mode
  2. debug: debug mode

Generate the payment form

You can generate the payment form using next code in your view:, (*8)



= Yii::$app->tpv->generateForm($Num_operacion, $Importe, $TipoMoneda = 978, $idioma = 1, $showButton = true) ?>
  • Num_operation: Alphanumeric code who identifies this order
  • Importe: The total amount of payment
  • TipoMoneda: Coin
  • Idioma: Language
  • showButton: if true, the form include submit button. If false, you should submit it througt javascript. Remember that form id is always ceca-tpv-form

Handle TPV response

Once you have been pay, TPV should POST payment info (if you configure it). To handle that, you should use in your action:, (*9)

<?php
class PaymentsController extends Controller
{

    public function init()
    {
        if (isset($_POST)) {
            /* Turn off CSRF */
            Yii::$app->request->enableCsrfValidation = false;
        }
    }

    public function actionTpv()
    {
        $logfile = Yii::getAlias('@runtime/tpv.log');

        if (isset($_POST)) {
            file_put_contents($logfile, print_R($_POST, true), FILE_APPEND);
        }

        $response = Yii::$app->tpv->getTPVResponse();
        if ($response && $response->isValid()) {
          // do some stuff on your database or app
          if( myStuffWorkFine ) {
            $response->returnOkToServer();
          } else {
            $response->returnErrorToServer();
          }
        }

        Yii::$app->request->enableCsrfValidation = true;
    }
}

The Versions

18/05 2016

dev-master

9999999-dev

Manage payment form generator from CECA TPV

  Sources   Download

GPL-3.0+

The Requires

 

by José Pedro Andrés

extension yii2 payment tpv ceca ibercaja

18/05 2016

1.0.0

1.0.0.0

Manage payment form generator from CECA TPV

  Sources   Download

GPL-3.0+

The Requires

 

by José Pedro Andrés

extension yii2 payment tpv ceca ibercaja