Files
wordpress-theme-aksrt/assets/admin/src/schema/sections/payment/gateway.js
T
kate522 aad83072a8 refactor(pay): 统一流水号,移除订单/流水/提现三类号码前缀
订单号、资金流水号、提现单号此前各自带前缀配置,同一笔业务在不同界面会
呈现多个号码口径,对账与客诉排查都要先做一次前缀换算。现收敛为单一流水号
分配器,不再按业务类型区分号码形态。

- 删除 payment_order_prefix / payment_flow_prefix /
  payment_withdrawal_prefix 三项配置项及其生成、校验链路
- BusinessNumber::allocate() 成为唯一入口,输出 {YmdHis}{6 位随机},
  共 20 位无前缀,满足 VARCHAR(32) 与网关 out_trade_no ≤ 32 的限制
- 订单、资金流水、提现、卡密渠道交易号四处生成点全部改走该分配器
- 后台支付中心表头「订单号 / 提现单号」统一为「流水号」
- 前台用户中心与订单卡片文案同步统一;前台订单详情合并为单行流水号,
  账本流水号不再下发到前台,避免同一单据出现两个对外号码
- 同步更新 financial-flow / pay-card / card-pass-order-numbers 契约测试
  与 BusinessNumberTest 断言

按用户要求不做双路逻辑与数据迁移,直接替换为统一方案,历史行不做转换。

验证:node --test tests/**/*.test.cjs 362/364 通过,新增 37 项契约;失败的
2 项在改动前的干净 HEAD 基线上同样失败(基线 327 项 / 失败 2 项),分别命中
遗留的 fa fa- 标记与 FA 版本号断言,与本次改动无关。phpunit 44 项 / 103
断言全部通过;php -l 全部改动的 PHP 文件通过。
2026-09-18 22:14:27 +08:00

347 lines
17 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/** PayPal / Stripe 结算货币选项(参考主题同款 26 种)。 */
const currencyOptions = [
{ label: '澳元 (AUD)', value: 'AUD' },
{ label: '巴西雷亚尔 (BRL)', value: 'BRL' },
{ label: '加拿大元 (CAD)', value: 'CAD' },
{ label: '人民币 (CNY)', value: 'CNY' },
{ label: '克朗 (CZK)', value: 'CZK' },
{ label: '丹麦克朗 (DKK)', value: 'DKK' },
{ label: '欧元 (EUR)', value: 'EUR' },
{ label: '港币 (HKD)', value: 'HKD' },
{ label: '匈牙利福林 (HUF)', value: 'HUF' },
{ label: '印度卢比 (INR)', value: 'INR' },
{ label: '以色列新谢克尔 (ILS)', value: 'ILS' },
{ label: '日元 (JPY)', value: 'JPY' },
{ label: '马来西亚林吉特 (MYR)', value: 'MYR' },
{ label: '墨西哥比索 (MXN)', value: 'MXN' },
{ label: '新台币 (TWD)', value: 'TWD' },
{ label: '新西兰元 (NZD)', value: 'NZD' },
{ label: '挪威克朗 (NOK)', value: 'NOK' },
{ label: '菲律宾比索 (PHP)', value: 'PHP' },
{ label: '波兰兹罗提 (PLN)', value: 'PLN' },
{ label: '英镑 (GBP)', value: 'GBP' },
{ label: '俄罗斯卢布 (RUB)', value: 'RUB' },
{ label: '新加坡元 (SGD)', value: 'SGD' },
{ label: '瑞典克朗 (SEK)', value: 'SEK' },
{ label: '瑞士法郎 (CHF)', value: 'CHF' },
{ label: '泰铢 (THB)', value: 'THB' },
{ label: '美元 (USD)', value: 'USD' },
]
/**
* 收款接口 — 参考主题双下拉式重构:微信/支付宝接口选择(官方/易支付/关闭)、
* PayPal/Stripe 独立开关、货币与结算、订单与编号、
* 收款接口显示顺序,以及 5 个凭据配置块(支付宝/微信/PayPal/Stripe/易支付)。
*/
export const gatewaySchema = {
key: 'payment.gateway',
title: '收款接口',
icon: 'fa fas fa-credit-card',
description: '配置收款通道:微信与支付宝可在官方/易支付之间选择,PayPal 与 Stripe 独立开关。订单、资金流水与提现统一使用同一套自动流水号,无需配置前缀。',
defaults: {
pay_wechat_sdk_options: 'null',
pay_alipay_sdk_options: 'null',
pay_paypal_sdk_s: false,
pay_stripe_sdk_s: false,
pay_currency_mark: '¥',
pay_currency_unit: '元',
pay_wechat_settle: { settle_rate: '1', settle_mark: '¥', settle_unit: '元' },
pay_alipay_settle: { settle_rate: '1', settle_mark: '¥', settle_unit: '元' },
pay_sdk_custom_title_s: false,
pay_sdk_custom_title: '',
payment_order_expiry: 30,
pay_wait_float_s: true,
pay_sdk_order: {},
alipay_appid: '',
alipay_privatekey: '',
alipay_payment_type: 'page',
alipay_app_public_cert_path: '',
alipay_public_cert_path: '',
alipay_root_cert_path: '',
wechat_merchantid: '',
wechat_appid: '',
wechat_payment_type: 'native',
wechat_api_v3_key: '',
wechat_private_key_path: '',
wechat_cert_path: '',
paypal_client_id: '',
paypal_client_secret: '',
paypal_currency: 'USD',
paypal_rates: '0.14',
paypal_sandbox: false,
stripe_secret_key: '',
stripe_publishable_key: '',
stripe_webhook_secret: '',
stripe_currency: 'USD',
stripe_rates: '0.14',
stripe_test_mode: false,
epay_apiurl: '',
epay_pid: '',
epay_key: '',
epay_device: 'auto',
},
groups: [
{
key: 'notice',
title: '说明',
icon: 'fa fas fa-info-circle',
fields: [
{
key: 'gateway_notice',
label: '',
type: 'content',
ui_only: true,
content: '<ul style="margin:0 0 0 18px;line-height:1.9"><li>以下收款接口,主题仅提供API接入服务,收款平台的可靠性请自行斟酌!</li><li>涉及到资金及信息安全,有相关执照的商家推荐使用官方接口</li><li>微信 / 支付宝接口可在「官方」与「易支付」之间选择;PayPal 与 Stripe 独立开关</li><li>异步回调由各网关验签,无需额外口令;回调地址固定为 /wp-json/aksrt/v1/payment/{gateway}/{notify|return}</li></ul>',
},
],
},
{
key: 'channels',
title: '收款接口选择',
icon: 'fa fas fa-toggle-on',
description: '微信与支付宝各选一种接入方式;选「易支付」后需在下方易支付配置块填写接口信息。',
fields: [
{
key: 'pay_wechat_sdk_options',
label: '微信收款接口',
type: 'select',
default: 'null',
options: [
{ label: '微信官方', value: 'official_wechat' },
{ label: '易支付-微信', value: 'epay' },
{ label: '关闭微信收款', value: 'null' },
],
},
{
key: 'pay_alipay_sdk_options',
label: '支付宝收款接口',
type: 'select',
default: 'null',
options: [
{ label: '支付宝企业支付/当面付', value: 'official_alipay' },
{ label: '易支付-支付宝', value: 'epay' },
{ label: '关闭支付宝收款', value: 'null' },
],
},
{ key: 'pay_paypal_sdk_s', label: 'PayPal支付(贝宝)', type: 'switch', default: false, help: '启用后请在下方配置参数' },
{ key: 'pay_stripe_sdk_s', label: 'Stripe支付', type: 'switch', default: false, help: '启用后请在下方配置参数' },
],
},
{
key: 'currency',
title: '货币与结算',
icon: 'fa fas fa-coins',
fields: [
{ key: 'pay_currency_mark', label: '本地货币符号', type: 'input', default: '¥', help: '显示在金额前面(例如 $ 或 ¥)' },
{ key: 'pay_currency_unit', label: '本地货币单位名称', type: 'input', default: '元', help: '金额后缀,例如:人民币填「元」、美元填「dollars」' },
{
key: 'pay_wechat_settle',
label: '微信结算配置',
type: 'fieldset',
default: { settle_rate: '1', settle_mark: '¥', settle_unit: '元' },
fields: [
{ key: 'settle_rate', label: '结算汇率', type: 'input', default: '1' },
{ key: 'settle_mark', label: '结算货币符号', type: 'input', default: '¥' },
{ key: 'settle_unit', label: '结算货币单位', type: 'input', default: '元' },
],
},
{
key: 'pay_alipay_settle',
label: '支付宝结算配置',
type: 'fieldset',
default: { settle_rate: '1', settle_mark: '¥', settle_unit: '元' },
fields: [
{ key: 'settle_rate', label: '结算汇率', type: 'input', default: '1' },
{ key: 'settle_mark', label: '结算货币符号', type: 'input', default: '¥' },
{ key: 'settle_unit', label: '结算货币单位', type: 'input', default: '元', help: '如果接入的收款方式与本地的货币类型不同,则在此配置结算汇率及单位' },
],
},
{ key: 'pay_sdk_custom_title_s', label: '自定义收款标题', type: 'switch', default: false, help: '默认为付款类型加网站名,如需自定义请开启' },
{ key: 'pay_sdk_custom_title', label: '自定义收款标题', type: 'input', default: '', dependsOn: { key: 'pay_sdk_custom_title_s', value: true }, help: '可使用变量:订单类型 %order_type%,例如:%order_type%-AKSRT;注意控制总长度,太长会导致部分接口报错' },
],
},
{
key: 'order',
title: '订单与编号',
icon: 'fa fas fa-hashtag',
description: '订单支付时效与浮窗提示;订单、资金流水与提现的流水号由系统统一自动分配,无需配置。',
fields: [
{ key: 'payment_order_expiry', label: '订单支付时效(分钟)', type: 'number', default: 30, min: 5, max: 1440, help: '用户下单后,最大支付时间,超过后订单将自动关闭(不能低于5分钟)' },
{ key: 'pay_wait_float_s', label: '浮窗显示待支付订单', type: 'switch', default: true, help: '将用户待支付订单一直显示在右上角,提醒用户付款' },
],
},
{
key: 'sdk-order',
title: '收款接口显示顺序',
icon: 'fa fas fa-sort-amount-down',
fields: [
{
key: 'pay_sdk_order',
label: '显示顺序',
type: 'sortable',
default: {},
items: [
{ key: 'wechat', label: '微信' },
{ key: 'alipay', label: '支付宝' },
{ key: 'paypal', label: 'PayPal(贝宝)' },
{ key: 'stripe', label: 'Stripe' },
{ key: 'balance', label: '余额' },
{ key: 'card_pass', label: '卡密' },
],
help: '收银台支付方式显示顺序;仅显示已开启的接口',
},
],
},
{
key: 'alipay',
title: '支付宝官方',
icon: 'fa fas fa-credit-card',
description: '支付宝官方接口(当面付 / 网站应用)。',
collapsible: true,
expandWhen: 'pay_alipay_sdk_options',
dependsOn: { key: 'pay_alipay_sdk_options', value: 'official_alipay' },
fields: [
{
key: 'alipay_notice',
label: '',
type: 'content',
ui_only: true,
content: '<ul style="margin:0 0 0 18px;line-height:1.9"><li>支付宝公钥为必填项目(公钥错误可以成功付款,但会回调失败)</li><li>回调地址固定为 /wp-json/aksrt/v1/payment/alipay/{notify|return}</li><li>同时填写了企业支付以及当面付参数,则优先使用当面付</li></ul>',
},
{ key: 'alipay_appid', label: '当面付:APPID', type: 'input', default: '' },
{ key: 'alipay_privatekey', label: '当面付:应用私钥', type: 'textarea', sanitize_type: 'code', default: '', rows: 4 },
{
key: 'alipay_payment_type',
label: '支付方式',
type: 'select',
default: 'page',
options: [
{ label: '电脑网站支付(web)', value: 'page' },
{ label: '手机网站支付(wap)', value: 'wap' },
],
},
{ key: 'alipay_app_public_cert_path', label: '应用公钥证书路径', type: 'input', default: '', help: 'appCertPublicKey.crt 绝对路径。' },
{ key: 'alipay_public_cert_path', label: '支付宝公钥证书路径', type: 'input', default: '', help: 'alipayCertPublicKey_RSA2.crt 绝对路径。' },
{ key: 'alipay_root_cert_path', label: '支付宝根证书路径', type: 'input', default: '', help: 'alipayRootCert.crt 绝对路径。' },
],
},
{
key: 'wechat',
title: '微信官方',
icon: 'fa fab fa-weixin',
description: '微信企业支付官方接口。',
collapsible: true,
expandWhen: 'pay_wechat_sdk_options',
dependsOn: { key: 'pay_wechat_sdk_options', value: 'official_wechat' },
fields: [
{
key: 'wechat_notice',
label: '',
type: 'content',
ui_only: true,
content: '<ul style="margin:0 0 0 18px;line-height:1.9"><li>微信企业支付:官方接口,商家可申请,有年费,申请较为复杂</li><li>回调地址固定为 /wp-json/aksrt/v1/payment/wechatpay/{notify|return},请配置 Native 支付回调链接</li></ul>',
},
{ key: 'wechat_merchantid', label: '商户号 PartnerID', type: 'input', default: '' },
{ key: 'wechat_appid', label: '授权绑定的AppID', type: 'input', default: '' },
{
key: 'wechat_payment_type',
label: '支付方式',
type: 'select',
default: 'native',
options: [
{ label: '扫码支付(Native)', value: 'native' },
{ label: 'H5支付', value: 'h5' },
],
},
{ key: 'wechat_api_v3_key', label: '支付APIv3密钥', type: 'input', default: '', help: '微信商户平台设置的 APIv3 密钥(32位)。' },
{ key: 'wechat_private_key_path', label: '商户私钥路径', type: 'input', default: '', help: 'apiclient_key.pem 绝对路径,用于签名。' },
{ key: 'wechat_cert_path', label: '商户API证书路径', type: 'input', default: '', help: 'apiclient_cert.pem 绝对路径。' },
],
},
{
key: 'paypal',
title: 'PayPal(贝宝)',
icon: 'fa fab fa-paypal',
description: '常见的海外支付接口。',
collapsible: true,
expandWhen: 'pay_paypal_sdk_s',
dependsOn: { key: 'pay_paypal_sdk_s', value: true },
fields: [
{
key: 'paypal_notice',
label: '',
type: 'content',
ui_only: true,
content: '<ul style="margin:0 0 0 18px;line-height:1.9"><li>PayPal(贝宝)是常见的海外支付接口</li><li>如果您的收款账户为中国大陆地区,则账户类型必须是企业,且只能收取非中国大陆区的PayPal付款</li><li>REST 应用申请:https://developer.paypal.com/dashboard/applications</li></ul>',
},
{ key: 'paypal_client_id', label: 'Client ID', type: 'input', default: '' },
{ key: 'paypal_client_secret', label: 'Client Secret', type: 'input', default: '' },
{ key: 'paypal_currency', label: '结算货币', type: 'select', case_insensitive: true, default: 'USD', options: currencyOptions },
{ key: 'paypal_rates', label: '货币汇率', type: 'input', default: '0.14', help: '根据你选择的货币类型与您定价货币的汇率进行填写,例如1元人民币兑换0.137美元(USD),则此处填0.137' },
{ key: 'paypal_sandbox', label: '沙盒调试模式', type: 'switch', default: false, help: '沙箱模式(Sandbox)是PayPal支付的测试环境。开启后请使用沙箱环境生成的收款账户和付款账户进行测试。' },
],
},
{
key: 'stripe',
title: 'Stripe',
icon: 'fa fab fa-cc-stripe',
description: '常见的海外信用卡收款接口。',
collapsible: true,
expandWhen: 'pay_stripe_sdk_s',
dependsOn: { key: 'pay_stripe_sdk_s', value: true },
fields: [
{
key: 'stripe_notice',
label: '',
type: 'content',
ui_only: true,
content: '<ul style="margin:0 0 0 18px;line-height:1.9"><li>Stripe 是常见的海外信用卡收款接口</li><li>API 密钥申请:https://dashboard.stripe.com/apikeys</li><li>Webhook 事件:checkout.session.completed</li><li>测试环境请使用 sk_test_ 开头的 Secret Key</li></ul>',
},
{ key: 'stripe_secret_key', label: '私钥Secret Key', type: 'input', default: '', help: 'Stripe Dashboard → Developers → API keys → Secret key' },
{ key: 'stripe_publishable_key', label: 'Publishable Key', type: 'input', default: '' },
{ key: 'stripe_webhook_secret', label: '签名密钥Webhook Secret', type: 'input', default: '', help: 'Developers → Webhooks → 端点 → Signing secret(whsec_ 开头)' },
{ key: 'stripe_currency', label: '结算货币', type: 'select', case_insensitive: true, default: 'USD', options: currencyOptions },
{ key: 'stripe_rates', label: '货币汇率', type: 'input', default: '0.14', help: '根据你选择的货币类型与您定价货币的汇率进行填写,例如1元人民币兑换0.137美元(USD),则此处填0.137' },
{ key: 'stripe_test_mode', label: '测试模式', type: 'switch', default: false, help: '如果使用的测试开放模式,则请使用 sk_test_ 测试密钥与 Stripe 测试卡进行配置' },
],
},
{
key: 'epay',
title: '易支付',
icon: 'fa fas fa-university',
description: '易支付(彩虹协议)聚合收银台;通道由上方微信/支付宝接口选择控制。',
collapsible: true,
expandWhen: 'pay_wechat_sdk_options',
dependsOn: {
any: [
{ key: 'pay_wechat_sdk_options', value: 'epay' },
{ key: 'pay_alipay_sdk_options', value: 'epay' },
],
},
fields: [
{
key: 'epay_notice',
label: '',
type: 'content',
ui_only: true,
content: '<ul style="margin:0 0 0 18px;line-height:1.9"><li>易支付是一个常见的支付系统源码,任何人都可以下载并搭建</li><li>同时市面上多数的小规模支付平台都是由易支付修改而来,例如部分码支付、源支付等等</li><li>由于此接口服务商众多,主题只负责技术接入,平台可靠性请自行斟酌</li></ul>',
},
{ key: 'epay_apiurl', label: 'API接口网址', type: 'input', default: '', help: '请填写接口地址,例如:https://pay.xxxxxxx.cn/' },
{ key: 'epay_pid', label: '商户号', type: 'input', default: '' },
{ key: 'epay_key', label: '商户秘钥', type: 'input', default: '', help: 'MD5 通信密钥。' },
{
key: 'epay_device',
label: '下单终端',
type: 'select',
default: 'auto',
options: [
{ label: '自动(按 UA)', value: 'auto' },
{ label: '电脑端 submit', value: 'pc' },
{ label: '移动端 mapi', value: 'mobile' },
],
},
],
},
],
}