require_once(app_path() . "/Tool/Alipay/alipay.config.php");
require_once(app_path() . "/Tool/Alipay/lib/alipay_submit.class.php") ;
## //Server asynchronous notification page path
$ notify_url = "http://" . $_SERVER['HTTP_HOST'] . '/service/pay/ali_notify';
//Requires full path in http:// format, ?id= is not allowed 123 Such custom parameters
//Page jump synchronization notification page path
$call_back_url = "http://" . $_SERVER[' HTTP_HOST'] . '/service/pay/ali_result';
//Requires a full path in http:// format, custom parameters such as ?id=123 are not allowed
/ /http://127.0.0.1:8800/WS_WAP_PAYWAP-PHP-UTF-8/call_back_url.php
## //Operation interruption return address
$seller_email = 'ajjnae2770@sandbox.com';
//Required
//Merchant order number
$out_trade_no = $_POST ['order_no'];
//The unique order number in the order system of the merchant website, required
Log::info('out_trade_no:' . $out_trade_no);
//Order name
$subject = $_POST['name'];
//Required
//Payment amount
$total_fee = $_POST['total_price'];
//Required
/ /Request business parameter details
$req_data = '<direct_trade_create_req><notify_url>' . $notify_url . '</notify_url><call_back_url>' . $call_back_url . '</call_back_url><seller_account_name>' . $seller_email . '</seller_account_name><out_trade_no>' . $out_trade_no . '</out_trade_no><subject>' . $subject . '</subject><total_fee>' . $total_fee . '</total_fee><merchant_url>' . $merchant_url . '</merchant_url></direct_trade_create_req>';
//必填
/************************************************************/
//构造要请求的参数数组,无需改动
$para_token = array(
"service" => "alipay.wap.trade.create.direct",
"partner" => trim($alipay_config['partner']),
"sec_id" => trim($alipay_config['sign_type']),
"format" => $format,
"v" => $v,
"req_id" => $req_id,
"req_data" => $req_data,
"_input_charset" => trim(strtolower($alipay_config['input_charset']))
);
//建立请求
$alipaySubmit = new \AlipaySubmit($alipay_config);
//报错点
$html_text = $alipaySubmit->buildRequestHttp($para_token);
//URLDECODE返回的信息
$html_text = urldecode($html_text);
//解析远程模拟提交后返回的信息
$para_html_text = $alipaySubmit->parseResponse($html_text);
//获取request_token
$request_token = $para_html_text['request_token'];
/************************Call the transaction interface alipay.wap.auth.authAndExecute************ based on the authorization code token **************/
//业务详细
$req_data = '<auth_and_execute_req><request_token>' . $request_token . '</request_token></auth_and_execute_req>';
//必填
//构造要请求的参数数组,无需改动
$parameter = array(
"service" => "alipay.wap.auth.authAndExecute",
"partner" => trim($alipay_config['partner']),
"sec_id" => trim($alipay_config['sign_type']),
"format" => $format,
"v" => $v,
"req_id" => $req_id,
"req_data" => $req_data,
"_input_charset" => trim(strtolower($alipay_config['input_charset']))
);
//建立请求
$alipaySubmit = new \AlipaySubmit($alipay_config);
$html_text = $alipaySubmit->buildRequestForm($parameter, 'get', '确认');
return $html_text;
}
韦小宝2018-02-08 11:09:34
The request_token was not obtained. Did you not apply for payment authorization?