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