如何在yii2中集成citruspay支付网关? Citruspay提供付款集成库。当我使用该库时,它会出现错误“类'卖家\ citruspay \ lib \ Zend_Config_Ini'未找到” - 任何在此将不胜感激
PHP Fatal Error – yii\base\ErrorException
Class 'seller\modules\citruspay\controllers\CitrusPay' not found
1. in C:\wamp\www\haggl\seller\modules\citruspay\controllers\DefaultController.php at line 44
35363738394041424344454647484950515253
"cardHolderName" => Yii::$app->request->post('cardHolderName'),
"cardNumber" => Yii::$app->request->post('cardNumber'),
"expiryMonth" => Yii::$app->request->post('expiryMonth'),
"cardType" => Yii::$app->request->post('cardType'),
"cvvNumber" => Yii::$app->request->post('cvvNumber'),
"expiryYear" => Yii::$app->request->post('expiryYear'),
"returnUrl" => Yii::$app->request->post('returnUrl'),
"amount" => Yii::$app->request->post('amount'),
);
CitrusPay::setApiKey("apikey",'sandbox');
$response = Transaction::create($tarr,CitrusPay::getApiKey());
$redirectUrl = $response->get_redirect_url();
$response_code = $response->get_resp_code();
if($redirectUrl != "" && $response_code == 200)
{
return $this->redirect($redirectUrl);
}else{
$html = "<p>Response Code is ".$response->get_resp_code()."</p>";
$html .= "<p>Response Message is ".$response->get_resp_msg()."</p>";
2. in C:\wamp\www\haggl\seller\vendor\yiisoft\yii2\base\InlineAction.php – call_user_func_array:{C:\wamp\www\haggl\seller\vendor\yiisoft\yii2\base\InlineAction.php:55}() at line 55
3. in C:\wamp\www\haggl\seller\vendor\yiisoft\yii2\base\Controller.php – yii\base\InlineAction::runWithParams() at line 151
4. in C:\wamp\www\haggl\seller\vendor\yiisoft\yii2\base\Module.php – yii\base\Controller::runAction() at line 455
5. in C:\wamp\www\haggl\seller\vendor\yiisoft\yii2\web\Application.php – yii\base\Module::runAction() at line 83
6. in C:\wamp\www\haggl\seller\vendor\yiisoft\yii2\base\Application.php – yii\web\Application::handleRequest() at line 375
7. in C:\wamp\www\haggl\seller\index.php – yii\base\Application::run() at line 22
16171819202122
require(__DIR__ . '/../common/config/main-local.php'),
require(__DIR__ . '/config/main.php'),
require(__DIR__ . '/config/main-local.php')
);
$application = new yii\web\Application($config);
$application->run();
答案 0 :(得分:0)
解决方案:
在Yii2文件夹中的“index.php”文件中进行如下所示的更改,
<?php
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');
// register CitrusPay path to yii enviornment
set_include_path(realpath(dirname(__FILE__)) . '/components/CitrusPay/lib'.PATH_SEPARATOR.get_include_path());
// register CitrusPay autoloader
require(realpath(dirname(__FILE__)) . '/components/CitrusPay/lib/CitrusPay.php');
// register Composer autoloader
require(__DIR__ . '/vendor/autoload.php');
// include Yii class file
require(__DIR__ . '/vendor/yiisoft/yii2/Yii.php');
Yii::$classMap['CitrusPay'] = (realpath(dirname(__FILE__)) . '/components/CitrusPay/lib/CitrusPay.php');
// load application aliases
require(__DIR__ . '/../common/config/aliases.php');
// load application configuration
$config = yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/../common/config/main.php'),
require(__DIR__ . '/../common/config/main-local.php'),
require(__DIR__ . '/config/main.php'),
require(__DIR__ . '/config/main-local.php')
);
$application = new yii\web\Application($config);
$application->run();
然后使用“use”关键字
调用库类例如: 使用CitrusPay;
它会像魅力一样......