mirror of
https://gitee.com/technical-laohu/mpay.git
synced 2025-09-17 17:26:40 +08:00
更新扩展结构
This commit is contained in:
parent
6b6335545d
commit
31d1de51e0
50
extend/ImgCaptcha.php
Normal file
50
extend/ImgCaptcha.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
class ImgCaptcha
|
||||
{
|
||||
// 图鉴 http://www.ttshitu.com/
|
||||
public static function ttShiTu(string $image = '', string $typeid = '3'): string
|
||||
{
|
||||
$api_url = 'http://api.ttshitu.com/predict';
|
||||
$info = [
|
||||
'username' => '2679275057',
|
||||
'password' => '7698177hcnTJ',
|
||||
'typeid' => $typeid,
|
||||
'image' => $image
|
||||
];
|
||||
$res = self::getHttpResponse($api_url, [], json_encode($info));
|
||||
$data = json_decode($res, true);
|
||||
$captcha = '';
|
||||
if ($data['success'] === true) {
|
||||
$captcha = $data['data']['result'];
|
||||
}
|
||||
return $captcha;
|
||||
}
|
||||
// 请求外部资源
|
||||
private function getHttpResponse($url, $header = [], $post = null, $timeout = 10)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||||
if ($header) {
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
|
||||
} else {
|
||||
$httpheader[] = "Accept: */*";
|
||||
$httpheader[] = "Accept-Language: zh-CN,zh;q=0.9";
|
||||
$httpheader[] = "Connection: close";
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader);
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_HEADER, false);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
if ($post) {
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
|
||||
}
|
||||
$response = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
return $response;
|
||||
}
|
||||
}
|
66
extend/MpayClass.php
Normal file
66
extend/MpayClass.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
class MpayClass
|
||||
{
|
||||
private $pid;
|
||||
private $key;
|
||||
private $host;
|
||||
private $check_neworder_url;
|
||||
private $submit_records_url;
|
||||
function __construct($config)
|
||||
{
|
||||
$this->pid = $config['pid'];
|
||||
$this->key = $config['key'];
|
||||
$this->host = $config['host'];
|
||||
$this->check_neworder_url = $this->host . '/order.php';
|
||||
$this->submit_records_url = $this->host . '/payHeart';
|
||||
}
|
||||
// 查询新订单
|
||||
public function orderHeart()
|
||||
{
|
||||
$url = $this->check_neworder_url . "?pid={$this->pid}&sign={$this->getSign()}";
|
||||
$res = $this->getHttpResponse($url);
|
||||
return $res;
|
||||
}
|
||||
// 提交收款明细
|
||||
public function upRecords($records, $aid)
|
||||
{
|
||||
$header = ['Content-Type: application/json;charset=UTF-8'];
|
||||
$url = $this->submit_records_url . "?pid={$this->pid}&aid={$aid}&sign={$this->getSign()}";
|
||||
$res = $this->getHttpResponse($url, $header, json_encode($records));
|
||||
return $res;
|
||||
}
|
||||
|
||||
// 签名方法
|
||||
private function getSign()
|
||||
{
|
||||
return md5($this->pid . $this->key);
|
||||
}
|
||||
// 请求外部资源
|
||||
private function getHttpResponse($url, $header = [], $post = null, $timeout = 10)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||||
if ($header) {
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
|
||||
} else {
|
||||
$httpheader[] = "Accept: */*";
|
||||
$httpheader[] = "Accept-Language: zh-CN,zh;q=0.8";
|
||||
$httpheader[] = "Connection: close";
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader);
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_HEADER, false);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
if ($post) {
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
|
||||
}
|
||||
$response = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
return $response;
|
||||
}
|
||||
}
|
BIN
extend/old_payclient.zip
Normal file
BIN
extend/old_payclient.zip
Normal file
Binary file not shown.
BIN
extend/payclient.zip
Normal file
BIN
extend/payclient.zip
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user