dev-master
9999999-devManage payment form generator from RedSys TPV
GPL-3.0+
The Requires
by José Pedro Andrés
extension yii2 caixa payment tpv redsys
Manage payment form generator from RedSys TPV
Manage payment form generator from Redsys TPV, (*1)
The preferred way to install this extension is through composer., (*2)
Either run, (*3)
php composer.phar require --prefer-dist macklus/yii2-redsys-tpv "*"
or add, (*4)
"macklus/yii2-redsys-tpv": "*"
to the require section of your composer.json
file., (*5)
Configure tpv component, using:, (*6)
'redsys' => [ 'class' => 'macklus\RedsysTpv\Tpv', 'mode' => 'prod', 'debug' => [ 'Merchant' => '0XXXXXXXX', 'Terminal' => '0000000X', 'Key' => 'XXXXXXXX', 'URL_OK' => '', 'URL_NOK' => '', 'Version' => '', ], 'prod' => [ 'Merchant' => '0XXXXXXXX', 'Terminal' => '0000000X', 'Key' => 'XXXXXXXX', 'URL_OK' => '', 'URL_NOK' => '', 'Version' => '', ], ],
The mode variable define usage mode, so far:, (*7)
You can generate the payment form using next code in your view:, (*8)
= Yii::$app->redsys->generateForm($Num_operacion, $Importe, $TipoMoneda = 978, $idioma = 1, $showButton = true) ?>
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; } }
Manage payment form generator from RedSys TPV
GPL-3.0+
extension yii2 caixa payment tpv redsys