<?php
|
/* *
|
* 功能:支付宝手机网站支付接口(alipay.trade.wap.pay)接口调试入口页面
|
* 版本:2.0
|
* 修改日期:2016-11-01
|
* 说明:
|
* 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。
|
请确保项目文件有可写权限,不然打印不了日志。
|
*/
|
|
header("Content-type: text/html; charset=utf-8");
|
|
|
require_once dirname ( __FILE__ ).DIRECTORY_SEPARATOR.'service/AlipayTradeService.php';
|
require_once dirname ( __FILE__ ).DIRECTORY_SEPARATOR.'buildermodel/AlipayTradeWapPayContentBuilder.php';
|
require dirname ( __FILE__ ).DIRECTORY_SEPARATOR.'./../config.php';
|
|
//获取订单详情
|
$ShopOrdID = $_GET["ShopOrdID"];
|
$key='apivcomcn20170421';
|
|
$method = "Order_detail";
|
$arr = array("method"=>$method,"ShopOrdID"=>$ShopOrdID);
|
ksort($arr);
|
$i=0;
|
$stringA='';
|
foreach($arr as $k=>$v){
|
$stringA=$stringA.$k.$v;
|
}
|
$stringSignTemp=$stringA.$key;
|
$stringSignTemp=str_replace(" ", "%20", $stringSignTemp);
|
|
$sign=MD5($stringSignTemp);
|
$content = 'method='.$method.'&ShopOrdID='.$ShopOrdID;
|
$content .= '&Sign='.$sign;
|
$order_url='http://api.v.com.cn/order/?'.$content;
|
$order_url=str_replace(" ", "%20", $order_url);
|
// var_dump($order_url);exit;
|
$orderinfo=file_get_contents($order_url);
|
$orderinfo=json_decode($orderinfo,true);
|
if($orderinfo["result"] == "2" || empty($orderinfo)){
|
echo "<script>location.href='orderdlist.php;</script>";exit;
|
}
|
$pricefen = $orderinfo["ConsumeMoney"] + $orderinfo["PostageMoney"] - $orderinfo["DiscountMoney"] - $orderinfo["AcceptMoney"];
|
if($orderinfo["ProgressM"]=="1" || $orderinfo["ProgressM"]=="4" || $pricefen <= 0){
|
echo "<script>location.href='/phpmvcomcn/orderdetail.php?ShopOrdID=$ShopOrdID'</script>";exit;
|
}
|
if($orderinfo["ProgressM"] != "1" && $orderinfo["ProgressM"] != "4"){
|
if($pricefen<=0){
|
echo "<script>location.href='/phpmvcomcn/orderdetail.php?ShopOrdID=$ShopOrdID'</script>";exit;
|
}else{
|
$PriceTotal = $pricefen;
|
}
|
// $PriceTotal = 1;
|
}
|
// var_dump($ShopOrdID);exit;
|
$details = $orderinfo["details"];
|
if(count($details)>1){
|
$subject = $details[0]["strItmName"]."等共".count($details)."件商品";
|
}else{
|
$subject = $details[0]["strItmName"];
|
}
|
|
$out_trade_no = $orderinfo["ShopOrdID"];
|
|
|
//付款金额,必填
|
$total_amount = $PriceTotal;
|
//商品描述,可空
|
$body = $subject;
|
|
//超时时间
|
$timeout_express="1m";
|
|
$payRequestBuilder = new AlipayTradeWapPayContentBuilder();
|
$payRequestBuilder->setBody($body);
|
$payRequestBuilder->setSubject($subject);
|
$payRequestBuilder->setOutTradeNo($out_trade_no);
|
$payRequestBuilder->setTotalAmount($total_amount);
|
$payRequestBuilder->setTimeExpress($timeout_express);
|
|
$payResponse = new AlipayTradeService($config);
|
$result=$payResponse->wapPay($payRequestBuilder,$config['return_url'],$config['notify_url']);
|
|
|
|
?>
|