Files
epay/plugins/fubei/inc/FubeiClient.class.php
T
opencode b7613ba082 部署仓库初始化:epay 部署配置、补丁与插件
- docker-compose.prod.yml:挂载 epay-ui.css/js/head.php 补丁到 staging(镜像升级不丢)
- docker/nginx.conf:补丁静态资源 no-cache,改版立即生效
- patches/:
  - test.php 修复 paytype JSON 对象导致测试支付页空白
  - epay-ui.css 后台全屏/侧栏加宽/导航两列布局覆盖
  - epay-ui.js 去除页面容器宽度限制 + 侧栏当前菜单自动滚动
  - head.php 资源 ?v= 版本号强制回源
  - functions.php is_public_url 白名单等既有补丁
- plugins/ 支付插件源码
- .gitignore 排除 .env 等敏感与临时文件
2026-10-21 13:05:20 +08:00

74 lines
1.9 KiB
PHP

<?php
/**
* https://www.yuque.com/51fubei/openapi
*/
class FubeiClient
{
//支付接口地址
private $gateway_url = 'https://shq-api.51fubei.com/gateway/agent';
private $version = '1.0';
private $sign_method = 'md5';
private $format = 'json';
//​开放平台ID
private $app_id;
//​接口密钥
private $app_secret;
public function __construct($app_id, $app_secret){
$this->app_id = $app_id;
$this->app_secret = $app_secret;
}
//发起请求
public function execute($method, $bizContent)
{
$commonData = [
'app_id' => $this->app_id,
'method' => $method,
'format' => $this->format,
'sign_method' => $this->sign_method,
'nonce' => random(12),
'version' => $this->version,
'biz_content' => json_encode($bizContent, JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE),
];
$commonData['sign'] = $this->make_sign($commonData);
$data = get_curl($this->gateway_url, json_encode($commonData), 0, 0, 0, 0, 0, ['Content-Type: application/json; charset=utf-8']);
$result = json_decode($data, true);
if(isset($result['result_code']) && $result['result_code']==200){
return $result['data'];
}else{
throw new Exception($result['result_message']?$result['result_message']:'返回数据解析失败');
}
}
public function verify($param){
if(!isset($param['sign'])) return false;
$sign = $this->make_sign($param);
return $sign === $param['sign'];
}
private function make_sign($param){
ksort($param);
$signstr = '';
foreach($param as $k => $v){
if($k != "sign" && $v!=''){
$signstr .= $k.'='.$v.'&';
}
}
$signstr = substr($signstr, 0, -1);
$signstr .= $this->app_secret;
$sign = strtoupper(md5($signstr));
return $sign;
}
}