|
|
@@ -6,95 +6,61 @@ class Lakala
|
|
|
{
|
|
|
|
|
|
private $appid;
|
|
|
- private $mchSerialNo;
|
|
|
- private $mercId;
|
|
|
- private $termNo;
|
|
|
+ private $serial_no;
|
|
|
+ private $merchant_no;
|
|
|
+ private $term_no;
|
|
|
private $merchantPrivateKeyPath;
|
|
|
private $lklCertificatePath;
|
|
|
private $subject;
|
|
|
private $schema = 'LKLAPI-SHA256withRSA';
|
|
|
private $version = '3.0';
|
|
|
- private $exterOrderSource = 'OS10000071';
|
|
|
private $preUrl = '';
|
|
|
|
|
|
public function __construct($params)
|
|
|
{
|
|
|
$this->appid = $params['appid'];
|
|
|
- $this->mchSerialNo = $params['mchSerialNo'];
|
|
|
- $this->mercId = $params['mercId'];
|
|
|
- $this->termNo = $params['termNo'];
|
|
|
+ $this->serial_no = $params['serial_no'];
|
|
|
+ $this->merchant_no = $params['merchant_no'];
|
|
|
+ $this->term_no = $params['term_no'];
|
|
|
$this->merchantPrivateKeyPath = $params['merchantPrivateKeyPath'];
|
|
|
$this->lklCertificatePath = $params['lklCertificatePath'];
|
|
|
- $this->subject = $params['subject'] ?? '奥式生活订单';
|
|
|
-
|
|
|
if (getenv('YII_ENV') == 'production') {
|
|
|
$this->preUrl = 'https://s2.lakala.com/api/v3/labs/trans/';
|
|
|
} else {
|
|
|
$this->preUrl = 'https://test.wsmsd.cn/sit/api/v3/labs/trans/';
|
|
|
}
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- public function wechat()
|
|
|
- {
|
|
|
- $reqInfo = new LabsOrderPreOrderPayReq();
|
|
|
- $reqInfo->mercId = '822162070120015';
|
|
|
- $reqInfo->termNo = '47827142';
|
|
|
- $reqInfo->payMode = 'ALIPAY';
|
|
|
- $reqInfo->openId = 'olpr-0pHIp1AjaAr29LENlHi0cJ0';
|
|
|
- $reqInfo->amount = 1;
|
|
|
- $reqInfo->spbillCreateIp = '127.0.0.1';
|
|
|
- $reqInfo->transType = '41';
|
|
|
- $reqInfo->orderId = '2020072915yhl142212';
|
|
|
- $reqInfo->appId = 'wx9ef39b708f16694d';
|
|
|
- $reqInfo->subject = '奥式生活订单';
|
|
|
- $reqInfo->exterOrderSource = 'OS10000071';
|
|
|
-
|
|
|
- $termExtInfo = new TermExtInfo();
|
|
|
- $termExtInfo->termLoc = '';
|
|
|
-
|
|
|
- $baseRequestVO = new BaseRequestVO();
|
|
|
- $baseRequestVO->reqData = $reqInfo;
|
|
|
- $baseRequestVO->termExtInfo = $termExtInfo;
|
|
|
- $baseRequestVO->timestamp = mt_rand(10000000, 99999999);
|
|
|
- $baseRequestVO->ver = $this->version;
|
|
|
-
|
|
|
- return json_encode($baseRequestVO, JSON_UNESCAPED_UNICODE);
|
|
|
}
|
|
|
|
|
|
//支付宝
|
|
|
- public function aliPay($orderId, $amount)
|
|
|
+ public function aliPay($orderSn, $amount)
|
|
|
{
|
|
|
- $reqInfo = new LabsOrderPreOrderPayReq();
|
|
|
- $reqInfo->mercId = $this->mercId;
|
|
|
- $reqInfo->termNo = $this->termNo;
|
|
|
- $reqInfo->payMode = 'ALIPAY';
|
|
|
- // $reqInfo->openId = 'olpr-0pHIp1AjaAr29LENlHi0cJ0';
|
|
|
- $reqInfo->amount = $amount * 100;
|
|
|
- $reqInfo->spbillCreateIp = '127.0.0.1';
|
|
|
- $reqInfo->transType = '41';
|
|
|
- $reqInfo->orderId = $orderId;
|
|
|
- // $reqInfo->appId = 'wx9ef39b708f16694d';
|
|
|
- $reqInfo->subject = '奥式生活订单';
|
|
|
- $reqInfo->exterOrderSource = $this->exterOrderSource;
|
|
|
-
|
|
|
- $termExtInfo = new TermExtInfo();
|
|
|
- // $termExtInfo->termLoc = '+155621.316,-125622.12';
|
|
|
-
|
|
|
- $baseRequestVO = new BaseRequestVO();
|
|
|
- $baseRequestVO->reqData = $reqInfo;
|
|
|
- $baseRequestVO->termExtInfo = $termExtInfo;
|
|
|
- $baseRequestVO->timestamp = time();
|
|
|
- $baseRequestVO->ver = $this->version;
|
|
|
-
|
|
|
+ $location_info = ['request_ip' => '183.250.29.250'];
|
|
|
+ $arr = [
|
|
|
+ 'merchant_no' => $this->merchant_no,
|
|
|
+ 'term_no' => $this->term_no,
|
|
|
+ 'out_trade_no' => $orderSn,
|
|
|
+ 'account_type' => 'ALIPAY',
|
|
|
+ 'trans_type' => '41',
|
|
|
+ 'total_amount' => $amount * 100,
|
|
|
+ 'location_info' => $location_info,
|
|
|
+ 'subject' => '奥式生活订单',
|
|
|
+ 'notify_url' => '',
|
|
|
+ 'remark' => '',
|
|
|
+ ];
|
|
|
+ $baseRequestVO = [
|
|
|
+ 'req_data' => $arr,
|
|
|
+ 'req_time' => date("YmdHis"),
|
|
|
+ 'version' => $this->version,
|
|
|
+ ];
|
|
|
$body = json_encode($baseRequestVO, JSON_UNESCAPED_UNICODE);
|
|
|
-
|
|
|
$authorization = $this->getAuthorization($body);
|
|
|
-echo $this->preUrl . 'preorder';
|
|
|
return $this->post($this->preUrl . 'preorder', $body, $authorization);
|
|
|
}
|
|
|
|
|
|
+ public function wechat()
|
|
|
+ {
|
|
|
+ }
|
|
|
+
|
|
|
//验签
|
|
|
public function signatureVerification($authorization, $body)
|
|
|
{
|
|
|
@@ -122,27 +88,24 @@ echo $this->preUrl . 'preorder';
|
|
|
$nonceStr = mt_rand(10000000, 99999999);
|
|
|
$timestamp = time();
|
|
|
|
|
|
- $message = $this->appid . "\n" . $this->mchSerialNo . "\n" . $timestamp . "\n" . $nonceStr . "\n" . $body . "\n";
|
|
|
+ $message = $this->appid . "\n" . $this->serial_no . "\n" . $timestamp . "\n" . $nonceStr . "\n" . $body . "\n";
|
|
|
|
|
|
$key = openssl_get_privatekey(file_get_contents($this->merchantPrivateKeyPath));
|
|
|
|
|
|
openssl_sign($message, $signature, $key, OPENSSL_ALGO_SHA256);
|
|
|
openssl_free_key($key);
|
|
|
|
|
|
- return $this->schema . " appid=\"" . $this->appid . "\"," . "serial_no=\"" . $this->mchSerialNo . "\"," . "timestamp=\"" . $timestamp . "\"," . "nonce_str=\"" . $nonceStr . "\"," . "signature=\"" . base64_encode($signature) . "\"";
|
|
|
+ return $this->schema . " appid=\"" . $this->appid . "\"," . "serial_no=\"" . $this->serial_no . "\"," . "timestamp=\"" . $timestamp . "\"," . "nonce_str=\"" . $nonceStr . "\"," . "signature=\"" . base64_encode($signature) . "\"";
|
|
|
}
|
|
|
|
|
|
//请求
|
|
|
public function post($url, $data, $authorization)
|
|
|
{
|
|
|
-
|
|
|
$headers = [
|
|
|
"Authorization: " . $authorization,
|
|
|
"Accept: application/json",
|
|
|
"Content-Type:application/json",
|
|
|
];
|
|
|
-print_r($headers);
|
|
|
-print_r($data);
|
|
|
$ch = curl_init();
|
|
|
curl_setopt($ch, CURLOPT_POST, 1);
|
|
|
curl_setopt($ch, CURLOPT_URL, $url);
|
|
|
@@ -152,7 +115,7 @@ print_r($data);
|
|
|
curl_setopt($ch, CURLOPT_POST, 1);
|
|
|
$res = curl_exec($ch);
|
|
|
curl_close($ch);
|
|
|
-var_dump($res);
|
|
|
+print_r($res);die;
|
|
|
return json_decode($res, 1);
|
|
|
}
|
|
|
|