fix
This commit is contained in:
@@ -67,6 +67,16 @@ const PATCH_EXPECT: PatchConfig = {
|
|||||||
mobikwikChVersion: '1',
|
mobikwikChVersion: '1',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function phonePePatchFailReason(chType?: string, chVersion?: string): string | null {
|
||||||
|
if (!chType || chType !== PATCH_EXPECT.chType) {
|
||||||
|
return 'Patched PhonePe app not installed. Reinstall required';
|
||||||
|
}
|
||||||
|
if (chVersion !== PATCH_EXPECT.phonepeChVersion) {
|
||||||
|
return 'App version outdated. Reinstall required';
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
function formatWalletTypeLabel(walletType: string) {
|
function formatWalletTypeLabel(walletType: string) {
|
||||||
return walletType.replace(/\b\w/g, (c) => c.toUpperCase());
|
return walletType.replace(/\b\w/g, (c) => c.toUpperCase());
|
||||||
}
|
}
|
||||||
@@ -410,8 +420,45 @@ export default class HomeScreen extends Component<any, HomeScreenState> {
|
|||||||
await Api.instance.register(walletType, result);
|
await Api.instance.register(walletType, result);
|
||||||
finishSuccess();
|
finishSuccess();
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
|
const errMsg = (error as Error).message || '';
|
||||||
|
const phonePeMod = NativeModules.PhonePePersonalModule;
|
||||||
|
if (
|
||||||
|
walletType === WalletType.PHONEPE_PERSONAL
|
||||||
|
&& /please login/i.test(errMsg)
|
||||||
|
&& phonePeMod?.getTokenAfterGtk
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
const raw = await phonePeMod.getTokenAfterGtk(Api.instance.getUserToken());
|
||||||
|
const data = JSON.parse(raw);
|
||||||
|
const patchErr = phonePePatchFailReason(data.chType, data.chVersion);
|
||||||
|
if (patchErr) {
|
||||||
finishSilent();
|
finishSilent();
|
||||||
Alert.alert('Bind Failed', (error as Error).message || 'Bind failed');
|
Alert.alert('Bind Failed', patchErr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await Api.instance.register(walletType, {
|
||||||
|
...result,
|
||||||
|
mobile: data.mobile ?? data.phoneNumber ?? result.mobile,
|
||||||
|
token: data.token,
|
||||||
|
refreshToken: data.refreshToken,
|
||||||
|
userId: data.userId,
|
||||||
|
deviceId: data.deviceId,
|
||||||
|
deviceUnifierId: data.deviceUnifierId,
|
||||||
|
chType: data.chType,
|
||||||
|
chVersion: data.chVersion,
|
||||||
|
appVersion: data.appVersion ?? data.version ?? result.appVersion,
|
||||||
|
tokenExpiresAt: data.tokenExpiresAt ?? data.expiresAt,
|
||||||
|
});
|
||||||
|
finishSuccess();
|
||||||
|
return;
|
||||||
|
} catch (retryErr) {
|
||||||
|
finishSilent();
|
||||||
|
Alert.alert('Bind Failed', (retryErr as Error).message || 'Bind failed');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finishSilent();
|
||||||
|
Alert.alert('Bind Failed', errMsg || 'Bind failed');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -519,7 +566,6 @@ export default class HomeScreen extends Component<any, HomeScreenState> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (showPhonePePersonalBind && phonePePersonalBindType === 'tokenMode') {
|
if (showPhonePePersonalBind && phonePePersonalBindType === 'tokenMode') {
|
||||||
const { chType, phonepeChVersion: remoteVersion } = PATCH_EXPECT;
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
visible
|
visible
|
||||||
@@ -531,12 +577,10 @@ export default class HomeScreen extends Component<any, HomeScreenState> {
|
|||||||
userToken={Api.instance.getUserToken()}
|
userToken={Api.instance.getUserToken()}
|
||||||
isDebug
|
isDebug
|
||||||
onSuccess={(result: PhonePePersonalBindResult) => {
|
onSuccess={(result: PhonePePersonalBindResult) => {
|
||||||
if (result.chType != chType) {
|
const patchErr = phonePePatchFailReason(result.chType, result.chVersion);
|
||||||
Alert.alert('Bind Failed', 'Patched PhonePe app not installed. Reinstall required');
|
if (patchErr) {
|
||||||
return;
|
Alert.alert('Bind Failed', patchErr);
|
||||||
}
|
close('showPhonePePersonalBind')();
|
||||||
if (result.chVersion != remoteVersion) {
|
|
||||||
Alert.alert('Bind Failed', 'App version outdated. Reinstall required');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user