Repository navigation
feat(billing): allow site-relative EPay V2 endpoint - #267
Merged
Ember-Moth merged 2 commits intoOct 28, 2026
Merged
Conversation
Reject canonical escapes and repeated slashes before trimming the deployment path, and preserve escaped path serialization when constructing the client URL. Cover configuration normalization, gateway opening, root deployment redirects and both checkout modes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
#266 让 V1 页面支付的 EPay 地址可以填
/pay这类站内路径:浏览器拿到的付款链接保持相对,跟着用户当前访问的域名走;服务端查单用支付方式的Domain拼出完整地址。V2(RSA)目前做不到这一点。
protocol.NewClient要求BaseURL是不带路径的 HTTPS 根地址,openEPay也只对 V1 页面支付解析相对地址。结果是:/pay或//pay.example/pay会在保存或打开支付方式时直接报错;https://pay.example/pay),V2 也无法使用。面板通过多个域名或多层反向代理对外服务、而 EPay 部署在面板站点子路径下时,V2 用户和 V1 用户遇到的是同一个问题。
改动
protocol.NewClient:BaseURL仍然必须是 HTTPS、不带凭据、查询串和片段,但允许规范的部署路径(path.Clean后不变,不含..、重复斜杠和转义字符)。所有请求按BaseURL + /api/...拼接。openEPay:V2(页面支付和 API 下单)与 V1 页面支付一样,用epayEndpoint解析站内路径和协议相对地址;站内路径必须配置Domain,且 V2 要求它是 HTTPS。StartPayment:V2 页面支付的跳转链接与 V1 一样,站内路径时只返回RequestURI,协议相对时去掉https:。两处共用browserURL。normalizeEPay:V2 的相对地址先按占位域名做校验,保存时保留原写法,不会被改写成绝对地址。checkout_mode=api)行为不变。docs/guide/epay.md和docs/guide/epay-zh.md中的地址规则。测试
新增
internal/module/billing/internal/gateway/epay_v2_relative_test.go,使用现有的billingtest.NewEPayV2(独立签名验签的 V2 测试桩):/pay:页面支付返回/pay/api/pay/submit?...,签名参数完整;服务端查单请求/pay/api/pay/query。/pay/api/pay/create。https://…/pay/和协议相对//…/pay:链接前缀正确,查单走/pay/api/pay/query。Domain、或Domain是 HTTP 时拒绝打开。/pay、/pay/、//pay.example/pay、https://pay.example/pay原样;拒绝/pay?key=x、/pay#fragment、///host、/pay/../admin、/pay/%2e%2e、http://…。protocol/client_test.go新增TestClientAcceptsDeploymentPath,覆盖带路径基址的拼接,以及 HTTP、查询串、片段、凭据、..、重复斜杠、转义字符的拒绝。逐一撤回各处改动做过反向验证,对应测试均会失败。