/*配置信息*/
function config(){
$alipay_config = array(
'partner' => '2088210265284197', //PID
'key' => '57i27aczxnq41e7zirduh56frgdgvj5g', //Key值
'sign_type' => 'MD5',
'input_charset' => 'utf-8',
'cacert' => getcwd().'\\cacert.pem',
'transport' => 'http'
);
return $alipay_config;
}
/*支付提交*/
function getsubmit(){
require_once("zhifubao/alipay_submit.class.php");
$alipay_config = $this->config();
$format = "xml";
$v = "2.0";
$req_id = date('Ymdhis');
$notify_url = "http://192.168.1.117/zhifubao/notify_url.php";
$call_back_url = "http://192.168.1.117/zhifubao/call_back_url.php";
$merchant_url = "http://192.168.1.117/zhifubao/aa.php";
$seller_email = empty($_POST['WIDseller_email']) ? '2367705161@' : $_POST['WIDseller_email'];
//商户订单号
$out_trade_no = time();//$_POST['WIDout_trade_no'];
$subject = '产品';//$_POST['WIDsubject'];
//付款金额
$total_fee = '0.01';//$_POST['WIDtotal_fee'];
//请求业务参数详细
$req_data = '' . $notify_url . '' . $call_back_url . '' . $seller_email . '' . $out_trade_no . '' . $subject . '' . $total_fee . '' . $merchant_url . '';
//必填
/************************************************************/
//构造要请求的参数数组,无需改动
$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'];
/**************************根据授权码token调用交易接口alipay.wap.auth.authAndExecute**************************/
//业务详细
$req_data = '' . $request_token . '';
//必填
//构造要请求的参数数组,无需改动
$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', '确认');