Otp / Token 模式 OK
This commit is contained in:
@@ -1,8 +1,45 @@
|
||||
import React, { Component, useState, useEffect } from 'react';
|
||||
import { View, Text, TextInput, TouchableOpacity, StyleSheet, ActivityIndicator } from 'react-native';
|
||||
import { WalletType, FreechargePersonalBindResult, MobikwikPersonalBindResult, PaytmPersonalBindResult, PhonePePersonalBindResult, PhonePeBusinessBindResult, BharatPeBusinessBindResult, PaytmBusinessBindResult } from 'rnwalletman';
|
||||
import { Alert, View, Text, TextInput, TouchableOpacity, StyleSheet, ActivityIndicator } from 'react-native';
|
||||
import {
|
||||
WalletType,
|
||||
BindErrorCode,
|
||||
MobikwikPersonalBind,
|
||||
FreechargePersonalBindResult,
|
||||
MobikwikPersonalBindResult,
|
||||
PaytmPersonalBindResult,
|
||||
PhonePePersonalBindResult,
|
||||
PhonePeBusinessBindResult,
|
||||
BharatPeBusinessBindResult,
|
||||
PaytmBusinessBindResult,
|
||||
} from 'rnwalletman';
|
||||
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<{
|
||||
onRequestOTP: (walletType: WalletType, params: any) => Promise<any>;
|
||||
onVerifyOTP: (walletType: WalletType, params: any) => Promise<any>;
|
||||
@@ -28,10 +65,38 @@ export class FreeChargeBind extends Component<{
|
||||
}
|
||||
}
|
||||
|
||||
export class MobikwikOTPBind extends Component<{
|
||||
/** Mobikwik 2365 AIDL bind */
|
||||
export class MobikwikPersonalTokenBind extends Component<{
|
||||
userToken: string;
|
||||
onSuccess: (result: MobikwikPersonalBindResult) => void;
|
||||
onClose?: () => void;
|
||||
isDebug?: boolean;
|
||||
}> {
|
||||
render() {
|
||||
const { userToken, onSuccess, onClose, isDebug = false } = this.props;
|
||||
return (
|
||||
<MobikwikPersonalBind
|
||||
processString="Binding Mobikwik..."
|
||||
userToken={userToken}
|
||||
isDebug={isDebug}
|
||||
onSuccess={(result: MobikwikPersonalBindResult) => {
|
||||
if (!result.hashId) {
|
||||
Alert.alert('Bind Failed', 'Please log in to the Mobikwik app first');
|
||||
return;
|
||||
}
|
||||
onSuccess(result);
|
||||
}}
|
||||
onError={(code: string, message: string) => alertMobikwikAidlBindError(code, message, onClose)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/** Mobikwik web OTP bind */
|
||||
export class MobikwikPersonalOTPBind extends Component<{
|
||||
onRequestOTP: (walletType: WalletType, params: any) => Promise<any>;
|
||||
onVerifyOTP: (walletType: WalletType, params: any) => Promise<any>;
|
||||
onSuccess: (result: MobikwikPersonalBindResult) => void;
|
||||
onSuccess: (result: any) => void;
|
||||
onError: (error: string) => void;
|
||||
isDebug: boolean;
|
||||
initialMobile?: string;
|
||||
@@ -40,7 +105,8 @@ export class MobikwikOTPBind extends Component<{
|
||||
return (
|
||||
<OTPBindUI
|
||||
walletType={WalletType.MOBIKWIK_PERSONAL}
|
||||
title="Bind Mobikwik"
|
||||
title="Bind Mobikwik (OTP)"
|
||||
subtitle="Web OTP login. If you have the 2365 patched app, use Token Mode instead"
|
||||
otpLength={6}
|
||||
onRequestOTP={this.props.onRequestOTP}
|
||||
onVerifyOTP={this.props.onVerifyOTP}
|
||||
@@ -53,6 +119,9 @@ export class MobikwikOTPBind extends Component<{
|
||||
}
|
||||
}
|
||||
|
||||
/** @deprecated Use MobikwikPersonalOTPBind */
|
||||
export const MobikwikOTPBind = MobikwikPersonalOTPBind;
|
||||
|
||||
export class PayTmPersonalOTPBind extends Component<{
|
||||
onRequestOTP: (walletType: WalletType, params: any) => Promise<any>;
|
||||
onVerifyOTP: (walletType: WalletType, params: any) => Promise<any>;
|
||||
|
||||
Reference in New Issue
Block a user