|
@@ -4,7 +4,7 @@ namespace app\common\library;
|
|
|
|
|
|
class Changlian
|
|
|
{
|
|
|
- public function changlian_pay(){
|
|
|
+ public function changlian_pay($money,$order_no,$notifyUrl,$returnUrl){
|
|
|
//请求支付地址
|
|
|
$api = 'https://api2.payunk.com/index/unifiedorder?format=json';
|
|
|
//商户appid->到平台首页自行复制粘贴
|
|
@@ -14,17 +14,17 @@ class Changlian
|
|
|
$app_key = 'MHBRLkI4vFaAhLgdPkjp3QNMqsNrz8al';
|
|
|
|
|
|
//订单号码,发起订单时带的订单信息,一般为用户名,交易号,等字段信息
|
|
|
- $out_trade_no = date("YmdHis") . mt_rand(10000, 99999);
|
|
|
+ $out_trade_no = $order_no;
|
|
|
//支付类型
|
|
|
$pay_type = 'partnerJs';
|
|
|
//支付金额
|
|
|
- $amount = sprintf("%.2f",0.01);
|
|
|
+ $amount = sprintf("%.2f",$money);
|
|
|
//异步通知接口url->用作于接收成功支付后回调请求
|
|
|
- $callback_url = 'https://api2.payunk.com/callback_demo.php';
|
|
|
+ $callback_url = $notifyUrl;
|
|
|
//支付成功后自动跳转url
|
|
|
- $success_url = 'https://api2.payunk.com';
|
|
|
+ $success_url = $returnUrl;
|
|
|
//支付失败或者超时后跳转url
|
|
|
- $error_url = 'https://api2.payunk.com';
|
|
|
+ $error_url = $returnUrl;
|
|
|
//版本号
|
|
|
$version = 'v1.0';
|
|
|
//用户网站的请求支付的额外信息,请严格对接文档填写参数
|
|
@@ -43,7 +43,7 @@ class Changlian
|
|
|
];
|
|
|
|
|
|
//拿APPKEY与请求参数进行签名
|
|
|
- $sign = $this->getSign($app_key, $data);
|
|
|
+ $sign = getSign($app_key, $data);
|
|
|
$data['sign']=$sign;
|
|
|
|
|
|
$post_data = json_encode($data,320);
|
|
@@ -68,29 +68,4 @@ class Changlian
|
|
|
// print_r($output);die;
|
|
|
return $output;
|
|
|
}
|
|
|
- public function getSign($secret, $data){
|
|
|
- if(isset($data['sign'])){
|
|
|
- unset($data['sign']);
|
|
|
- }
|
|
|
- // 去空
|
|
|
- $data = array_filter($data);
|
|
|
- //签名步骤一:按字典序排序参数
|
|
|
- ksort($data);
|
|
|
- // var_dump($data);
|
|
|
- $string_a = http_build_query($data);
|
|
|
- $string_a = urldecode($string_a);
|
|
|
-
|
|
|
- //签名步骤二:在string后加入mch_key
|
|
|
- $string_sign_temp = $string_a . "&key=" . $secret;
|
|
|
- // var_dump($string_sign_temp);
|
|
|
- //签名步骤三:MD5加密
|
|
|
- $sign = md5($string_sign_temp);
|
|
|
-
|
|
|
- // 签名步骤四:所有字符转为大写
|
|
|
- $result = strtoupper($sign);
|
|
|
- // var_dump($result);
|
|
|
- return $result;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
}
|