2026-09-09 12:00:13 +08:00
|
|
|
import { UIApplication } from 'UIKit'
|
|
|
|
|
import { URL, NSUserActivity } from 'Foundation'
|
|
|
|
|
import { InitOptions, PayOptions, PayCallback } from '../interface.uts'
|
2026-09-09 16:29:30 +08:00
|
|
|
import { configure, invoke, resetPending } from '../common.uts'
|
|
|
|
|
|
|
|
|
|
export function resetDypay(): void {
|
|
|
|
|
resetPending()
|
|
|
|
|
TbDouyinPayNative.resetPending()
|
|
|
|
|
}
|
2026-09-09 12:00:13 +08:00
|
|
|
|
|
|
|
|
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 ?? '')
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function canOpenDypay(): boolean {
|
|
|
|
|
return TbDouyinPayNative.available()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function openDypay(options: PayOptions, callback: PayCallback): void {
|
|
|
|
|
invoke(options, callback, (payload: string, loading: boolean, done: (raw: string) => void) => {
|
|
|
|
|
TbDouyinPayNative.pay(payload, done)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class TbDouyinPayHook implements UTSiOSHookProxy {
|
|
|
|
|
applicationOpenURLOptions(app: UIApplication | null, url: URL,
|
|
|
|
|
options: Map<UIApplication.OpenURLOptionsKey, any> | null = null): boolean {
|
|
|
|
|
return TbDouyinPayNative.processURL(url)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
applicationContinueUserActivityRestorationHandler(application: UIApplication | null,
|
|
|
|
|
userActivity: NSUserActivity | null,
|
|
|
|
|
restorationHandler: ((res: [any] | null) => void) | null = null): boolean {
|
|
|
|
|
if (userActivity == null) return false
|
|
|
|
|
return TbDouyinPayNative.processActivity(userActivity!)
|
|
|
|
|
}
|
|
|
|
|
}
|