fix: 修复iOS抖音支付回跳注册
This commit is contained in:
@@ -33,6 +33,7 @@ function uniMock() {
|
||||
const navigations = [];
|
||||
return { storage, messages, navigations, getStorageSync: k => storage.get(k), setStorageSync: (k,v) => storage.set(k,v),
|
||||
removeStorageSync: k => storage.delete(k), showToast: v => messages.push(v.title), $emit() {},
|
||||
getSystemInfoSync: () => ({ platform: 'android' }),
|
||||
showModal: () => assert.fail('Douyin must not add payment confirmation modals'),
|
||||
showLoading() {}, hideLoading() {},
|
||||
navigateTo: options => { navigations.push(options.url); options.success?.(); },
|
||||
@@ -53,6 +54,34 @@ async function payContext(overrides = {}, app = true) {
|
||||
}
|
||||
const successPage = '/pages/order_package/order_submit_ok/order_submit_ok';
|
||||
const failurePage = '/pages/order_package/order_submit_error/order_submit_error';
|
||||
|
||||
test('iOS always registers the installed host Scheme without a Universal Link', async () => {
|
||||
for (const overrides of [{}, { callbackScheme: 'wrong-app' }, { callbackScheme: 'trustbridgeapp://' },
|
||||
{ universalLink: 'https://app.tbmall.xin/uni-universallinks/__UNI__4910728/' },
|
||||
{ UniversalLinks: 'https://example.com/return/' }]) {
|
||||
let registration;
|
||||
let signedInfo;
|
||||
const ctx = await payContext({
|
||||
initDypay: options => { registration = options; return true; },
|
||||
openDypay: (options, cb) => { signedInfo = options.payInfo; cb({ resultCode: '0' }); }
|
||||
});
|
||||
ctx.uni.getSystemInfoSync = () => ({ platform: 'ios' });
|
||||
const current = { ...payment, douyin: { ...payment.douyin, ...overrides } };
|
||||
const result = await ctx.appDypayFun(current);
|
||||
assert.deepEqual({ ...registration }, { appId: 'app', callbackScheme: 'trustbridgeapp' });
|
||||
assert.deepEqual(signedInfo, ctx.toSdkPayInfo(current));
|
||||
assert.equal(result.state, 'paid');
|
||||
assert.deepEqual(ctx.uni.navigations, [successPage]);
|
||||
}
|
||||
});
|
||||
|
||||
test('Android keeps its existing callback Scheme selection', async () => {
|
||||
let registration;
|
||||
const ctx = await payContext({ initDypay: options => { registration = options; return true; } });
|
||||
await ctx.appDypayFun({ ...payment, douyin: { ...payment.douyin, callbackScheme: 'android-host' } });
|
||||
assert.equal(registration.callbackScheme, 'android-host');
|
||||
assert.equal(registration.appId, 'app');
|
||||
});
|
||||
test('SDK success is confirmed with server before showing success', async () => {
|
||||
let queries = 0;
|
||||
const ctx = await payContext({ request: async () => { queries++; return { bizcode:100, data:{state:2} }; } });
|
||||
|
||||
Reference in New Issue
Block a user