php支付宝手机网页支付类实例(2)

//授权接口请求参数
$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. 配置示例:

复制代码 代码如下:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/ae778a2a4370a2548a4378875ebc08a0.html