This commit is contained in:
2026-02-02 22:51:54 +08:00
parent d4cd1cecee
commit 5136e470e4
3 changed files with 84 additions and 38 deletions

118
App.tsx
View File

@@ -45,13 +45,27 @@ interface AppProps {
}
interface WalletmanAppState {
showPaytmBusinessBind: boolean;
/* Paytm Personal */
showPaytmPersonalBind: boolean;
paytmPersonalBindType: 'otpMode' | 'authMode';
showPaytmBusinessBind: boolean;
/* PhonePe Personal */
showPhonePePersonalBind: boolean;
phonePePersonalBindType: 'otpMode' | 'authMode';
showPhonePeBusinessBind: boolean;
/* GooglePay Business */
showGooglePayBusinessBind: boolean;
/* BharatPe Business */
showBharatPeBusinessBind: boolean;
/* Mobikwik Personal */
showMobikwikPersonalBind: boolean;
/* Freecharge Personal */
showFreechargePersonalBind: boolean;
}
@@ -67,7 +81,7 @@ const styles = StyleSheet.create({
backgroundColor: "lightblue",
borderRadius: 5,
width: 200,
height: 50,
height: 55,
},
text: {
fontSize: 20,
@@ -84,17 +98,18 @@ const styles = StyleSheet.create({
alignItems: "center",
},
bindButton: {
padding: 10,
borderRadius: 5,
width: 250,
height: 40,
width: 350,
height: 50,
justifyContent: "center",
alignItems: "center",
margin: 10,
marginBottom : 10,
},
bindButtonText: {
fontSize: 15,
fontWeight: "bold",
textAlign: "center",
textAlignVertical: "center",
},
});
@@ -184,8 +199,10 @@ export default class App extends Component<AppProps, WalletmanAppState> {
constructor(props: AppProps) {
super(props);
this.state = {
paytmPersonalBindType: 'otpMode',
showPaytmBusinessBind: false,
showPaytmPersonalBind: false,
phonePePersonalBindType: 'otpMode',
showPhonePeBusinessBind: false,
showPhonePePersonalBind: false,
showGooglePayBusinessBind: false,
@@ -370,8 +387,8 @@ export default class App extends Component<AppProps, WalletmanAppState> {
};
/* 绑定 Paytm Personal */
handlePaytmPersonalBind = () => {
this.setState({ showPaytmPersonalBind: true });
handlePaytmPersonalBind = (type: 'otpMode' | 'authMode') => {
this.setState({ showPaytmPersonalBind: true ,paytmPersonalBindType: type});
}
/* 上传 Paytm Personal 到服务器 */
@@ -442,8 +459,8 @@ export default class App extends Component<AppProps, WalletmanAppState> {
}
/* 绑定 PhonePe Personal */
handlePhonePePersonalBind = () => {
this.setState({ showPhonePePersonalBind: true });
handlePhonePePersonalBind = (type: 'otpMode' | 'authMode') => {
this.setState({ showPhonePePersonalBind: true ,phonePePersonalBindType: type});
}
/* 上传 PhonePe Personal 到服务器 */
@@ -524,6 +541,44 @@ export default class App extends Component<AppProps, WalletmanAppState> {
renderBindModal = () => {
/* 绑定 Paytm Personal */
if (this.state.showPaytmPersonalBind) {
return (
<Modal visible={this.state.showPaytmPersonalBind} transparent={true} onRequestClose={() => this.setState({ showPaytmPersonalBind: false })}>
<PaytmPersonalBind
processString="Processing Paytm Personal..."
isDebug={true}
otpMode={this.state.paytmPersonalBindType === 'otpMode'}
onRequestOTP={async (walletType: WalletType, params: any) => {
try {
const response = await Api.instance.requestOTP(walletType, params.mobile, {});
return response;
} catch (error) {
return { success: false, message: (error as Error).message };
}
}}
onVerifyOTP={async (walletType: WalletType, params: any) => {
try {
const response = await Api.instance.verifyOTP(walletType, params.mobile, params.otp, {
sessionId: params.sessionId, // 只需要传 sessionId
});
return response;
} catch (error) {
return { success: false, message: (error as Error).message };
}
}}
onSuccess={(result: PaytmPersonalBindResult) => {
this.handleUploadPaytmPersonal(result);
}}
onError={(error) => {
console.log(error);
this.setState({ showPaytmPersonalBind: false });
}}
/>
</Modal>
);
}
/* 绑定 PhonePe Personal */
if (this.state.showPhonePePersonalBind) {
return (
@@ -531,7 +586,7 @@ export default class App extends Component<AppProps, WalletmanAppState> {
<PhonePePersonalBind
processString="Processing PhonePe Personal..."
isDebug={true}
otpMode={true}
otpMode={this.state.phonePePersonalBindType === 'otpMode'}
onRequestOTP={async (walletType: WalletType, params: any) => {
try {
const response = await Api.instance.requestOTP(walletType, params.mobile, {});
@@ -639,25 +694,6 @@ export default class App extends Component<AppProps, WalletmanAppState> {
);
}
/* 绑定 Paytm Personal */
if (this.state.showPaytmPersonalBind) {
return (
<Modal visible={this.state.showPaytmPersonalBind} transparent={true} onRequestClose={() => this.setState({ showPaytmPersonalBind: false })}>
<PaytmPersonalBind
processString="Processing Paytm Personal..."
isDebug={true}
onSuccess={(result: PaytmPersonalBindResult) => {
this.handleUploadPaytmPersonal(result);
}}
onError={(error) => {
console.log(error);
this.setState({ showPaytmPersonalBind: false });
}}
/>
</Modal>
);
}
/* 绑定 Mobikwik Personal */
if (this.state.showMobikwikPersonalBind) {
return (
@@ -749,15 +785,25 @@ export default class App extends Component<AppProps, WalletmanAppState> {
return (
<View style={styles.container}>
{this.renderBindModal()}
<TouchableOpacity style={[styles.bindButton, { backgroundColor: "purple" }]} onPress={this.handlePaytmPersonalBind}>
<Text style={styles.bindButtonText}> Paytm Personal</Text>
</TouchableOpacity>
<View style={[styles.bindButton, { backgroundColor: "transparent", flexDirection: "row", justifyContent: "space-between", alignItems: "center" }]}>
<TouchableOpacity style={[styles.bindButton, { marginBottom : 0,width : '45%', backgroundColor: "#888888" }]} onPress={this.handlePaytmPersonalBind.bind(this, 'otpMode')}>
<Text style={styles.bindButtonText}> Paytm Personal(OTP)</Text>
</TouchableOpacity>
<TouchableOpacity style={[styles.bindButton, { marginBottom : 0,width : '45%', backgroundColor: "#F88888" }]} onPress={this.handlePaytmPersonalBind.bind(this, 'authMode')}>
<Text style={styles.bindButtonText}> Paytm Personal()</Text>
</TouchableOpacity>
</View>
<TouchableOpacity style={[styles.bindButton, { backgroundColor: "lightblue" }]} onPress={this.handlePaytmBusinessBind}>
<Text style={styles.bindButtonText}> Paytm Business</Text>
</TouchableOpacity>
<TouchableOpacity style={[styles.bindButton, { backgroundColor: "#1890ff" }]} onPress={this.handlePhonePePersonalBind}>
<Text style={styles.bindButtonText}> PhonePe Personal</Text>
</TouchableOpacity>
<View style={[styles.bindButton, { backgroundColor: "transparent", flexDirection: "row", justifyContent: "space-between", alignItems: "center" }]}>
<TouchableOpacity style={[styles.bindButton, { marginBottom : 0,width : '45%', backgroundColor: "#C88888" }]} onPress={this.handlePhonePePersonalBind.bind(this, 'otpMode')}>
<Text style={styles.bindButtonText}> PhonePe Personal(OTP)</Text>
</TouchableOpacity>
<TouchableOpacity style={[styles.bindButton, { marginBottom : 0,width : '45%', backgroundColor: "#A88888" }]} onPress={this.handlePhonePePersonalBind.bind(this, 'authMode')}>
<Text style={styles.bindButtonText}> PhonePe Personal()</Text>
</TouchableOpacity>
</View>
<TouchableOpacity style={[styles.bindButton, { backgroundColor: "lightgreen" }]} onPress={this.handlePhonePeBusinessBind}>
<Text style={styles.bindButtonText}> PhonePe Business</Text>
</TouchableOpacity>