承接 macklus/yii2-ceca-tpv 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

macklus/yii2-ceca-tpv

最新稳定版本:1.0.0

Composer 安装命令:

composer require macklus/yii2-ceca-tpv

包简介

Manage payment form generator from CECA TPV

README 文档

README

Manage payment form generator from CECA TPV

Installation

The preferred way to install this extension is through composer.

Either run

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

or add

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

to the require section of your composer.json file.

Configure

Configure tpv component, using:

'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:

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

Generate the payment form

You can generate the payment form using next code in your view:

<?php

use Yii;
?>

<?= 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:

<?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;
    }
}

统计信息

  • 总下载量: 137
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0
  • 更新时间: 2016-05-11