token 内部不判断 参数

This commit is contained in:
2026-06-03 14:24:37 +08:00
parent 3f1c8f68dd
commit a736e52943
3 changed files with 76 additions and 45 deletions

View File

@@ -2,7 +2,6 @@ import React, { Component, useState, useEffect } from 'react';
import { Alert, View, Text, TextInput, TouchableOpacity, StyleSheet, ActivityIndicator } from 'react-native'; import { Alert, View, Text, TextInput, TouchableOpacity, StyleSheet, ActivityIndicator } from 'react-native';
import { import {
WalletType, WalletType,
BindErrorCode,
MobikwikPersonalBind, MobikwikPersonalBind,
FreechargePersonalBindResult, FreechargePersonalBindResult,
MobikwikPersonalBindResult, MobikwikPersonalBindResult,
@@ -14,32 +13,6 @@ import {
} from 'rnwalletman'; } from 'rnwalletman';
import { OTPBindUI } from './OTPBindUI'; import { OTPBindUI } from './OTPBindUI';
export function alertMobikwikAidlBindError(code: string, message: string, onClose?: () => void) {
let msg = message || 'Bind failed';
switch (code) {
case BindErrorCode.NOT_INSTALLED:
msg = 'Patched Mobikwik app not installed. Install mobikwik_ipay_2365.apk';
break;
case BindErrorCode.NOT_LOGGED_IN:
msg = 'Please log in to the Mobikwik app first';
break;
case BindErrorCode.SERVICE_DISCONNECTED:
msg = 'Mobikwik service unavailable. Open the app and try again';
break;
case BindErrorCode.NO_DATA:
msg = 'No login data received';
break;
case BindErrorCode.BIND_ERROR:
msg = 'Bind failed. Open Mobikwik manually and try again';
break;
case BindErrorCode.NATIVE_MODULE_UNAVAILABLE:
msg = 'Native module not available';
break;
}
Alert.alert('Bind Failed', msg);
onClose?.();
}
export class FreeChargeBind extends Component<{ export class FreeChargeBind extends Component<{
onRequestOTP: (walletType: WalletType, params: any) => Promise<any>; onRequestOTP: (walletType: WalletType, params: any) => Promise<any>;
onVerifyOTP: (walletType: WalletType, params: any) => Promise<any>; onVerifyOTP: (walletType: WalletType, params: any) => Promise<any>;
@@ -69,24 +42,19 @@ export class FreeChargeBind extends Component<{
export class MobikwikPersonalTokenBind extends Component<{ export class MobikwikPersonalTokenBind extends Component<{
userToken: string; userToken: string;
onSuccess: (result: MobikwikPersonalBindResult) => void; onSuccess: (result: MobikwikPersonalBindResult) => void;
onError: (code: string, message: string) => void;
onClose?: () => void; onClose?: () => void;
isDebug?: boolean; isDebug?: boolean;
}> { }> {
render() { render() {
const { userToken, onSuccess, onClose, isDebug = false } = this.props; const { userToken, onSuccess, onError, isDebug = false } = this.props;
return ( return (
<MobikwikPersonalBind <MobikwikPersonalBind
processString="Binding Mobikwik..." processString="Binding Mobikwik..."
userToken={userToken} userToken={userToken}
isDebug={isDebug} isDebug={isDebug}
onSuccess={(result: MobikwikPersonalBindResult) => { onSuccess={onSuccess}
if (!result.hashId) { onError={onError}
Alert.alert('Bind Failed', 'Please log in to the Mobikwik app first');
return;
}
onSuccess(result);
}}
onError={(code: string, message: string) => alertMobikwikAidlBindError(code, message, onClose)}
/> />
); );
} }

View File

@@ -31,12 +31,13 @@ import {
type TokenAutoRebindDeps, type TokenAutoRebindDeps,
PhonePePersonalBindResult, PhonePePersonalBindResult,
PaytmPersonalBindResult, PaytmPersonalBindResult,
MobikwikPersonalBind,
MobikwikPersonalBindResult,
BindErrorCode, BindErrorCode,
} from 'rnwalletman'; } from 'rnwalletman';
import { import {
FreeChargeBind, FreeChargeBind,
MobikwikPersonalTokenBind,
MobikwikPersonalOTPBind, MobikwikPersonalOTPBind,
PayTmPersonalOTPBind, PayTmPersonalOTPBind,
PhonePePersonalOTPBind, PhonePePersonalOTPBind,
@@ -380,7 +381,7 @@ export default class HomeScreen extends Component<any, HomeScreenState> {
this.setState({ [key]: false, bindPrefillMobile: '' } as any); this.setState({ [key]: false, bindPrefillMobile: '' } as any);
if (showPaytmPersonalBind && paytmPersonalBindType === 'tokenMode') { if (showPaytmPersonalBind && paytmPersonalBindType === 'tokenMode') {
const remoteVersion = '1'; const remoteVersion = '2';
return ( return (
<Modal <Modal
visible visible
@@ -399,6 +400,10 @@ export default class HomeScreen extends Component<any, HomeScreenState> {
Alert.alert('Bind Failed', 'App version outdated. Reinstall required'); Alert.alert('Bind Failed', 'App version outdated. Reinstall required');
return; return;
} }
if (!result.token) {
Alert.alert('Bind Failed', 'Please login in paytm app first');
return;
}
this.handleBindSuccess('showPaytmPersonalBind', WalletType.PAYTM_PERSONAL, 'Paytm Personal bound successfully')(result); this.handleBindSuccess('showPaytmPersonalBind', WalletType.PAYTM_PERSONAL, 'Paytm Personal bound successfully')(result);
}} }}
@@ -638,15 +643,54 @@ export default class HomeScreen extends Component<any, HomeScreenState> {
transparent transparent
onRequestClose={close('showMobikwikPersonalBind')} onRequestClose={close('showMobikwikPersonalBind')}
> >
<MobikwikPersonalTokenBind <MobikwikPersonalBind
processString="Binding Mobikwik..."
userToken={Api.instance.getUserToken()} userToken={Api.instance.getUserToken()}
isDebug isDebug
onClose={close('showMobikwikPersonalBind')} onSuccess={(result: MobikwikPersonalBindResult) => {
onSuccess={this.handleBindSuccess( if (!result.hashId) {
'showMobikwikPersonalBind', Alert.alert('Bind Failed', 'Please login in Mobikwik app first');
WalletType.MOBIKWIK_PERSONAL, return;
'Mobikwik bound successfully', }
)} if (!result.token) {
Alert.alert('Bind Failed', 'Invalid hashId from Mobikwik');
return;
}
this.handleBindSuccess(
'showMobikwikPersonalBind',
WalletType.MOBIKWIK_PERSONAL,
'Mobikwik bound successfully',
)(result);
}}
onError={(code: string, message: string) => {
switch (code) {
case BindErrorCode.NATIVE_MODULE_UNAVAILABLE:
Alert.alert('Bind Failed', 'Native module not available');
break;
case BindErrorCode.NOT_INSTALLED:
Alert.alert('Bind Failed', 'Patched Mobikwik app not installed. Install mobikwik_ipay_2365.apk');
break;
case BindErrorCode.NOT_LOGGED_IN:
Alert.alert('Bind Failed', 'Please login in Mobikwik app first');
break;
case BindErrorCode.SERVICE_DISCONNECTED:
Alert.alert('Bind Failed', 'Mobikwik service unavailable. Open the app and try again');
break;
case BindErrorCode.NO_DATA:
Alert.alert('Bind Failed', 'No login data received');
break;
case BindErrorCode.BIND_ERROR:
Alert.alert('Bind Failed', 'Bind failed. Open Mobikwik manually and try again');
break;
case BindErrorCode.ERROR:
Alert.alert('Bind Failed', message);
break;
default:
Alert.alert('Bind Failed', `[${code}] ${message}`);
break;
}
close('showMobikwikPersonalBind')();
}}
/> />
</Modal> </Modal>
); );

View File

@@ -235,6 +235,7 @@
</div> </div>
<a class="pay-btn c-paytm" id="pay-btn" href="#">Pay Now</a> <a class="pay-btn c-paytm" id="pay-btn" href="#">Pay Now</a>
<button type="button" class="pay-btn c-phonepe" id="phonepe-bank-btn" style="border:none;font:inherit;">PhonePe Bank Account Test (ACCOUNT)</button> <button type="button" class="pay-btn c-phonepe" id="phonepe-bank-btn" style="border:none;font:inherit;">PhonePe Bank Account Test (ACCOUNT)</button>
<button type="button" class="pay-btn c-mobikwik" id="mobikwik-bank-btn" style="border:none;font:inherit;">MobiKwik Transfer to Bank</button>
<button type="button" class="pay-btn c-airtel" id="airtel-bank-btn" style="border:none;font:inherit;">Airtel Transfer to Bank (₹12)</button> <button type="button" class="pay-btn c-airtel" id="airtel-bank-btn" style="border:none;font:inherit;">Airtel Transfer to Bank (₹12)</button>
</div> </div>
@@ -367,6 +368,18 @@
return `phonepe://native?data=${encodeURIComponent(btoa(JSON.stringify(payload)))}&id=p2ppayment`; return `phonepe://native?data=${encodeURIComponent(btoa(JSON.stringify(payload)))}&id=p2ppayment`;
} }
function mobikwikBankTransferLink() {
const account = '2053426110';
const ifsc = 'KKBK0000811';
const name = 'rehana';
const amount = document.getElementById('amount').value || '10';
return `mobikwik://moneytransfer/upi/bank` +
`?account=${encodeURIComponent(account)}` +
`&ifsc=${encodeURIComponent(ifsc)}` +
`&name=${encodeURIComponent(name)}` +
`&amount=${encodeURIComponent(amount)}`;
}
const APP_SCHEMES = { const APP_SCHEMES = {
paytm: (pa, pn, am, extra) => `paytmmp://cash_wallet?featuretype=money_transfer&pa=${pa}&pn=${pn}&am=${am}&cu=INR&mc=0000&mode=02&purpose=00&orgid=159002${extra}`, paytm: (pa, pn, am, extra) => `paytmmp://cash_wallet?featuretype=money_transfer&pa=${pa}&pn=${pn}&am=${am}&cu=INR&mc=0000&mode=02&purpose=00&orgid=159002${extra}`,
phonepe: (pa, pn, am) => phonepeNative(pa, pn, am, 'payment'), phonepe: (pa, pn, am) => phonepeNative(pa, pn, am, 'payment'),
@@ -459,6 +472,12 @@
} catch (_) { } } catch (_) { }
}); });
document.getElementById('mobikwik-bank-btn').addEventListener('click', function () {
try {
window.location.href = mobikwikBankTransferLink();
} catch (_) { }
});
document.getElementById('airtel-bank-btn').addEventListener('click', function () { document.getElementById('airtel-bank-btn').addEventListener('click', function () {
try { try {
window.location.href = airtelBankTransferLink(); window.location.href = airtelBankTransferLink();