部署仓库初始化: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 等敏感与临时文件
This commit is contained in:
opencode committed 2026-10-21 13:05:20 +08:00
commit b7613ba082
176 files changed
+47057

No files matched your search

+96
View File
@@ -0,0 +1,96 @@
<?php
namespace Stripe;
use Exception;
class Webhook
{
const DEFAULT_TOLERANCE = 300;
const EXPECTED_SCHEME = 'v1';
public static function constructEvent($payload, $sigHeader, $secret, $tolerance = self::DEFAULT_TOLERANCE)
{
if (!self::verifyHeader($payload, $sigHeader, $secret, $tolerance)) {
throw new Exception('Invalid signature');
}
$data = json_decode($payload, true);
if (!$data) {
throw new Exception('Invalid payload');
}
return $data;
}
public static function verifyHeader($payload, $header, $secret, $tolerance = null)
{
// Extract timestamp and signatures from header
$timestamp = self::getTimestamp($header);
$signatures = self::getSignatures($header, self::EXPECTED_SCHEME);
if (!$timestamp || empty($signatures)) {
return false;
}
// Check if expected signature is found in list of signatures from
// header
$signedPayload = "{$timestamp}.{$payload}";
$expectedSignature = self::computeSignature($signedPayload, $secret);
$signatureFound = false;
foreach ($signatures as $signature) {
if ($expectedSignature === $signature) {
$signatureFound = true;
break;
}
}
if (!$signatureFound) {
return false;
}
// Check if timestamp is within tolerance
if (($tolerance > 0) && (abs(time() - $timestamp) > $tolerance)) {
return false;
}
return true;
}
private static function getTimestamp($header)
{
$items = explode(',', $header);
foreach ($items as $item) {
$itemParts = explode('=', $item, 2);
if ('t' === $itemParts[0]) {
if (!is_numeric($itemParts[1])) {
return false;
}
return (int) ($itemParts[1]);
}
}
return false;
}
private static function getSignatures($header, $scheme)
{
$signatures = [];
$items = explode(',', $header);
foreach ($items as $item) {
$itemParts = explode('=', $item, 2);
if (trim($itemParts[0]) === $scheme) {
$signatures[] = $itemParts[1];
}
}
return $signatures;
}
private static function computeSignature($payload, $secret)
{
return hash_hmac('sha256', $payload, $secret);
}
}