fix: 恢复抖音过期支付并完善原生状态确认

This commit is contained in:
Codex
2026-09-09 16:29:30 +08:00
parent fd3dc6870a
commit 2e9a732f9d
9 changed files with 142 additions and 19 deletions
@@ -1,5 +1,7 @@
import { InitOptions, PayOptions, PayCallback } from '../interface.uts'
import { configure, invoke } from '../common.uts'
import { configure, invoke, resetPending } from '../common.uts'
export function resetDypay(): void { resetPending() }
export function initDypay(options: InitOptions): boolean {
if (!configure(options.appId)) return false
@@ -12,6 +12,13 @@ public class TbDouyinPayNative {
public static func available() -> Bool { DypayAPI.canOpenDypay() }
public static func resetPending() {
DispatchQueue.main.async {
generation = UUID()
pending = nil
}
}
public static func pay(_ payload: String, _ done: @escaping (String) -> Void) {
DispatchQueue.main.async {
guard pending == nil else {
@@ -34,8 +41,8 @@ public class TbDouyinPayNative {
DypayAPI.openDypay(withInfo: info, from: controller) { result in
finish(result as? [AnyHashable: Any], ticket)
}
// Keep a native lock after timeout: a late URL callback cannot identify a new order.
// The host must query the pending order rather than immediately initiate another pay.
// Only authenticated server reconciliation can release a missing callback's lock.
// URL callbacks are hints, never payment success; the host always queries its saved order.
}
}
@@ -1,7 +1,12 @@
import { UIApplication } from 'UIKit'
import { URL, NSUserActivity } from 'Foundation'
import { InitOptions, PayOptions, PayCallback } from '../interface.uts'
import { configure, invoke } from '../common.uts'
import { configure, invoke, resetPending } from '../common.uts'
export function resetDypay(): void {
resetPending()
TbDouyinPayNative.resetPending()
}
export function initDypay(options: InitOptions): boolean {
if (options.callbackScheme.trim().length == 0 || !configure(options.appId)) return false
@@ -4,6 +4,12 @@ let appId = ''
let busy = false
let sequence = 0
// Host calls only after authenticated server reconciliation of the saved transaction.
export function resetPending(): void {
busy = false
sequence += 1
}
export function configure(id: string): boolean {
if (busy || id.trim().length == 0) return false
appId = id