fix: 补全iOS抖音支付SDK回跳URL

This commit is contained in:
Codex
2026-09-11 13:58:55 +08:00
parent f568fa0f7a
commit b6e45cd707
5 changed files with 78 additions and 3 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
{
"id": "tb-douyin-pay",
"displayName": "TB 抖音支付",
"version": "0.2.2",
"version": "0.2.3",
"description": "独立实现的抖音支付官方 SDK UTS 桥接",
"engines": { "HBuilderX": ">=4.36.0" },
"uni_modules": {
@@ -9,8 +9,19 @@ export function resetDypay(): void {
}
export function initDypay(options: InitOptions): boolean {
if (options.callbackScheme.trim().length == 0 || !configure(options.appId)) return false
TbDouyinPayNative.initialize(options.appId, options.callbackScheme, options.universalLink ?? '')
let callbackURL = options.callbackScheme.trim()
if (callbackURL.length == 0) return false
// CFBundleURLSchemes contains a bare scheme, but Dypay's callbackScheme API
// requires a complete URL. Official registration example: <scheme>://dypay.
// https://pay.douyinpay.com/wiki/639fd757f4a57b0226bb2066/639fd78317c2f3021d238378
if (callbackURL.indexOf('://') < 0) {
callbackURL = callbackURL + '://dypay'
} else if (callbackURL.endsWith('://')) {
callbackURL = callbackURL + 'dypay'
}
if (!new RegExp('^[A-Za-z][A-Za-z0-9+.-]*://dypay$').test(callbackURL)) return false
if (!configure(options.appId)) return false
TbDouyinPayNative.initialize(options.appId, callbackURL, options.universalLink ?? '')
return true
}
@@ -1,5 +1,6 @@
export type InitOptions = {
appId: string,
// Host's registered scheme; iOS converts it to <scheme>://dypay for the SDK.
callbackScheme: string,
universalLink?: string | null
}