西来喜页面支付
This commit is contained in:
@@ -86,7 +86,11 @@ class Payment extends Controller
|
|||||||
//引用西来喜
|
//引用西来喜
|
||||||
Loader::import('Xilaixi.Xilaixi', EXTEND_PATH, '.php');
|
Loader::import('Xilaixi.Xilaixi', EXTEND_PATH, '.php');
|
||||||
$xilaixi = new \Xilaixi();
|
$xilaixi = new \Xilaixi();
|
||||||
$result['xlx'] = $xilaixi->XilaixiPay($data, $type);
|
$res = $xilaixi->XilaixiPay($data, $type);// $xilaixi->XilaixiPay($data, $type)
|
||||||
|
if($res['code'] == 1){
|
||||||
|
|
||||||
|
}
|
||||||
|
$result['xlx'] = $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
return V(1, 'app支付', $result);
|
return V(1, 'app支付', $result);
|
||||||
|
|||||||
@@ -1,18 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use think\Env;
|
use think\Env;
|
||||||
|
use think\Log;
|
||||||
|
|
||||||
class Xilaixi
|
class Xilaixi
|
||||||
{
|
{
|
||||||
private $pid;
|
private $pid;
|
||||||
private $key;
|
private $key;
|
||||||
private string $sign_type = 'MD5';
|
private string $sign_type = 'MD5';
|
||||||
private string $mapi_url = 'https://wxjs.980city.com/mapi.php';
|
// private string $mapi_url = 'https://wxjs.980city.com/mapi.php';
|
||||||
|
private string $mapi_url = 'https://wxjs.980city.com/submit.php';
|
||||||
private string $api_url = 'https://wxjs.980city.com/api.php';//https://wxjs.980city.com/api.php?
|
private string $api_url = 'https://wxjs.980city.com/api.php';//https://wxjs.980city.com/api.php?
|
||||||
|
|
||||||
function __construct(){
|
function __construct(){
|
||||||
$this->pid = Env::get('AllinPay.appId');//平台分配的APPID
|
$this->pid = Env::get('XilaixiPay.pid');//平台分配的APPID
|
||||||
$this->key = Env::get('AllinPay.appId');//平台分配的APPID
|
$this->key = Env::get('XilaixiPay.key');//平台分配的APPID
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -21,27 +23,36 @@ class Xilaixi
|
|||||||
public function XilaixiPay($date, $type) {
|
public function XilaixiPay($date, $type) {
|
||||||
//6-西来喜微信,7-西来喜支付宝,8-西来喜QQ钱包,9-西来喜云闪付
|
//6-西来喜微信,7-西来喜支付宝,8-西来喜QQ钱包,9-西来喜云闪付
|
||||||
if($type == 6){
|
if($type == 6){
|
||||||
$type = 'wxpay';
|
$types = 'wxpay';
|
||||||
}elseif ($type == 7){
|
}elseif ($type == 7){
|
||||||
$type = 'alipay';
|
$types = 'alipay';
|
||||||
}elseif ($type == 8){
|
}elseif ($type == 8){
|
||||||
$type = 'qqpay';
|
$types = 'qqpay';
|
||||||
}elseif ($type == 9){
|
}elseif ($type == 9){
|
||||||
$type = 'bank';
|
$types = 'bank';
|
||||||
|
}else{
|
||||||
|
$types = 'wxpay';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$ip = $this->get_client_ip();
|
||||||
|
if ($ip == '::1')
|
||||||
|
$ip = '1.1.1.1';
|
||||||
//构造要请求的参数数组,无需改动
|
//构造要请求的参数数组,无需改动
|
||||||
$parameter = array(
|
$parameter = array(
|
||||||
"pid" => $this->pid,
|
"pid" => $this->pid,
|
||||||
"type" => $type,
|
"type" => $types,
|
||||||
"notify_url" => get_system_config_value("web_site")."/api/Payment/XilaixiPayNotify",
|
"notify_url" => get_system_config_value("web_site")."/api/Payment/XilaixiPayNotify",
|
||||||
"return_url" => '',
|
"return_url" => get_system_config_value("web_site")."/api/Payment/XilaixiPayNotify",
|
||||||
"out_trade_no" => $date['order_sn'],//商户订单号,
|
"out_trade_no" => $date['order_sn'],//商户订单号,
|
||||||
"name" => $date['remarke'],//订单标题(不能有空格),
|
"name" => $date['remarke'],//订单标题(不能有空格),
|
||||||
"money" => $date['money'],
|
"money" => $date['money'],
|
||||||
|
'clientip' => $ip,
|
||||||
);
|
);
|
||||||
|
Log::record("西来喜支付参数:".json_encode($parameter),"info");
|
||||||
$param = $this->buildRequestParam($parameter);
|
$param = $this->buildRequestParam($parameter);
|
||||||
$response = $this->getHttpResponse($this->mapi_url, http_build_query($param));
|
// $response = $this->getHttpResponse($this->mapi_url, http_build_query($param));
|
||||||
return json_decode($response, true);
|
return $this->getHttpRequest($this->mapi_url,$param);
|
||||||
|
// return json_decode($response, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildRequestParam($param){
|
private function buildRequestParam($param){
|
||||||
@@ -132,4 +143,57 @@ class Xilaixi
|
|||||||
return $arr;
|
return $arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//获取当前服务器的IP
|
||||||
|
function get_client_ip() {
|
||||||
|
if ($_SERVER ['REMOTE_ADDR']) {
|
||||||
|
$cip = $_SERVER ['REMOTE_ADDR'];
|
||||||
|
} elseif (getenv("REMOTE_ADDR")) {
|
||||||
|
$cip = getenv("REMOTE_ADDR");
|
||||||
|
} elseif (getenv("HTTP_CLIENT_IP")) {
|
||||||
|
$cip = getenv("HTTP_CLIENT_IP");
|
||||||
|
} else {
|
||||||
|
$cip = "unknown";
|
||||||
|
}
|
||||||
|
return $cip;
|
||||||
|
}
|
||||||
|
|
||||||
|
//拼接参数get请求
|
||||||
|
private function getHttpRequest($url, $param) {
|
||||||
|
// 将参数数组转换为查询字符串
|
||||||
|
$query = http_build_query($param);
|
||||||
|
|
||||||
|
// 拼接完整的URL
|
||||||
|
$fullUrl = $url . '?' . $query;
|
||||||
|
|
||||||
|
// // 初始化curl
|
||||||
|
// $ch = curl_init();
|
||||||
|
//
|
||||||
|
// // 设置curl选项
|
||||||
|
// curl_setopt($ch, CURLOPT_URL, $fullUrl);
|
||||||
|
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
// curl_setopt($ch, CURLOPT_HEADER, false);
|
||||||
|
// curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
||||||
|
// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||||
|
// curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||||||
|
//
|
||||||
|
// // 设置HTTP头
|
||||||
|
// $httpheader[] = "Accept: */*";
|
||||||
|
// $httpheader[] = "Accept-Language: zh-CN,zh;q=0.8";
|
||||||
|
// $httpheader[] = "Connection: close";
|
||||||
|
// curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader);
|
||||||
|
//
|
||||||
|
// // 执行请求
|
||||||
|
// $response = curl_exec($ch);
|
||||||
|
//
|
||||||
|
// // 检查是否有错误
|
||||||
|
// if (curl_errno($ch)) {
|
||||||
|
// Log::record("西来喜支付请求错误: " . curl_error($ch), "error");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // 关闭curl
|
||||||
|
// curl_close($ch);
|
||||||
|
|
||||||
|
return $fullUrl;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user