to_pay.php
2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
if(!defined('InEmpireCMS'))
{
exit();
}
if($payr['paymethod']==0)//双接口
{
$use_service='trade_create_by_buyer';
}
elseif($payr['paymethod']==2)//担保接口
{
$use_service='create_partner_trade_by_buyer';
}
else//即时到帐接口
{
$use_service='create_direct_pay_by_user';
}
//------------------ 参数开始 ------------------
$agent="";
$service=$use_service;
//商户号
$partner=$payr['payuser'];
//密钥
$paykey=$payr['paykey'];
//卖家支付宝帐户
$seller_email=$payr['payemail'];
//字符编码格式
$_input_charset="GBK";
//加密方式
$sign_type="MD5";
//返回地址
$notify_url=$PayReturnUrlQz."e/payapi/alipay/payend.php";
$return_url=$PayReturnUrlQz."e/payapi/alipay/payend.php";
//支付方式
$payment_type=1;
//默认支付方式
$paymethod="";
//银行类型
$defaultbank="";
//物流类型
$logistics_type="EXPRESS";
//物流费用
$logistics_fee="0";
//物流支付类型
$logistics_payment="BUYER_PAY";
//------------------ 参数结束 ------------------
if($payr['paymethod']==1)//即时到帐不需要物流
{
$logistics_type="";
$logistics_fee="";
$logistics_payment="";
}
//支付金额
$price=$money;
$quantity=1;
$out_trade_no=$ddno?$ddno:time(); //订单号
esetcookie("checkpaysession",$out_trade_no,0); //设置定单号
//产品信息
$subject=$productname; //商品名称
$body=$productsay; //商品描述
//md5
$parameter=array(
'agent' => $agent,
'service' => $service,
'partner' => $partner,
'seller_email' => $seller_email,
'_input_charset' => $_input_charset,
'notify_url' => $notify_url,
'return_url' => $return_url,
'subject' => $subject,
'body' => $body,
'out_trade_no' => $out_trade_no,
'price' => $price,
'quantity' => $quantity,
'payment_type' => $payment_type,
'paymethod' => $paymethod,
'defaultbank' => $defaultbank,
'logistics_type' => $logistics_type,
'logistics_fee' => $logistics_fee,
'logistics_payment' => $logistics_payment
);
ksort($parameter);
reset($parameter);
$param='';
$sign='';
foreach($parameter AS $key => $val)
{
if(strlen($val)==0)
{
continue;
}
$param.="$key=".urlencode($val)."&";
$sign.="$key=$val&";
}
$param=substr($param,0,-1);
$sign=md5(substr($sign,0,-1).$paykey);
$gotopayurl='https://mapi.alipay.com/gateway.do?'.$param.'&sign='.$sign.'&sign_type='.$sign_type;
?>
<html>
<title>支付宝支付</title>
<meta http-equiv="Cache-Control" content="no-cache"/>
<body>
<script>
self.location.href='<?=$gotopayurl?>';
</script>
<input type="button" style="font-size: 9pt" value="支付宝支付" name="v_action" onclick="self.location.href='<?=$gotopayurl?>';">
</body>
</html>