//授权接口请求参数
$sum = 0.01; //测试用金额
$req_data = '<direct_trade_create_req><subject>充值</subject>';
$req_data .= '<out_trade_no>'.$orderNo.'</out_trade_no>';
$req_data .= '<total_fee>'.$sum.'</total_fee>';
$req_data .= '<call_back_url>'.Url::toRoute(['payment/return'], true).'</call_back_url>';
$req_data .= '<notify_url>'.Url::toRoute(['payment/notify'], true).'</notify_url>';
$req_data .= '<seller_account_name>'.Yii::$app->params['alipay']['seller_email'].'</seller_account_name>';
$req_data .= '</direct_trade_create_req>';
$params = [
'service' => 'alipay.wap.trade.create.direct',
'format' => 'xml',
'v' => '2.0',
'partner' => Yii::$app->params['alipay']['partner'], //合作者省份ID
'req_id' => date('Ymdhis'),
'sec_id' => Yii::$app->params['alipay']['sign_type'],
'req_data' => $req_data,
];
$alipay = new Alipay();
$alipay->key = Yii::$app->params['alipay']['key'];
$alipay->alipay_config = $params;
$url = $alipay->buildPageUrl();
$this->redirect($url);
3. 配置示例:
复制代码 代码如下: