fix bugs
This commit is contained in:
@@ -128,7 +128,7 @@ function PaytmBusinessForm({ onRequestOTP, onVerifyOTP, onSuccess, onError, isDe
|
||||
onError: (error: string) => void;
|
||||
isDebug: boolean;
|
||||
}) {
|
||||
const [step, setStep] = useState<'credentials' | 'otp' | 'processing'>('credentials');
|
||||
const [step, setStep] = useState<'credentials' | 'otp'>('credentials');
|
||||
const [mobile, setMobile] = useState('');
|
||||
const [otp, setOtp] = useState('');
|
||||
const [sessionId, setSessionId] = useState('');
|
||||
@@ -153,30 +153,22 @@ function PaytmBusinessForm({ onRequestOTP, onVerifyOTP, onSuccess, onError, isDe
|
||||
|
||||
const handleVerifyOTP = async () => {
|
||||
if (!otp || otp.length !== 6) { setErrorMsg('请输入6位验证码'); return; }
|
||||
setLoading(true); setErrorMsg(''); setStep('processing');
|
||||
setLoading(true); setErrorMsg('');
|
||||
try {
|
||||
const res = await onVerifyOTP(WalletType.PAYTM_BUSINESS, { mobile, otp, sessionId });
|
||||
log('VerifyOTP:', res);
|
||||
if (res.success) {
|
||||
onSuccess({ type: WalletType.PAYTM_BUSINESS, success: true, cookie: res.data?.cookie || '', xCsrfToken: res.data?.xCsrfToken || '', qrData: res.data?.qrData || [] });
|
||||
} else {
|
||||
const msg = res.message || 'Failed to verify OTP';
|
||||
setErrorMsg(msg); setStep('otp'); onError(msg);
|
||||
setErrorMsg(res.message || 'Failed to verify OTP');
|
||||
setStep('otp');
|
||||
}
|
||||
} catch (e) {
|
||||
const msg = e instanceof Error ? e.message : 'Failed to verify OTP';
|
||||
setErrorMsg(msg); setStep('otp'); onError(msg);
|
||||
setErrorMsg(e instanceof Error ? e.message : 'Failed to verify OTP');
|
||||
setStep('otp');
|
||||
} finally { setLoading(false); }
|
||||
};
|
||||
|
||||
if (step === 'processing') {
|
||||
return (
|
||||
<View style={ptStyles.container}>
|
||||
<ActivityIndicator size="large" color="#fff" />
|
||||
<Text style={ptStyles.processingText}>处理中...</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={ptStyles.container}>
|
||||
@@ -210,17 +202,16 @@ function PaytmBusinessForm({ onRequestOTP, onVerifyOTP, onSuccess, onError, isDe
|
||||
|
||||
const ptStyles = StyleSheet.create({
|
||||
container: { flex: 1, backgroundColor: 'rgba(0,0,0,0.8)', justifyContent: 'center', alignItems: 'center' },
|
||||
form: { width: '80%', backgroundColor: '#fff', borderRadius: 10, padding: 20 },
|
||||
title: { fontSize: 20, fontWeight: 'bold', textAlign: 'center', marginBottom: 20 },
|
||||
input: { borderWidth: 1, borderColor: '#ddd', borderRadius: 5, padding: 12, fontSize: 16, marginBottom: 15 },
|
||||
errorText: { color: '#ff3b30', fontSize: 14, marginBottom: 10, textAlign: 'center' },
|
||||
button: { backgroundColor: '#007AFF', borderRadius: 5, padding: 15, alignItems: 'center' },
|
||||
buttonDisabled: { backgroundColor: '#ccc' },
|
||||
buttonText: { color: '#fff', fontSize: 16, fontWeight: 'bold' },
|
||||
linkButton: { marginTop: 10, alignItems: 'center' },
|
||||
form: { width: '92%', backgroundColor: '#fff', borderRadius: 20, padding: 28 },
|
||||
title: { fontSize: 22, fontWeight: '700', textAlign: 'center', color: '#111', marginBottom: 24 },
|
||||
input: { borderWidth: 1.5, borderColor: '#e0e0e0', borderRadius: 10, paddingHorizontal: 14, paddingVertical: 14, fontSize: 17, color: '#111', marginBottom: 18, backgroundColor: '#fafafa' },
|
||||
errorText: { color: '#ff3b30', fontSize: 13, marginBottom: 12, textAlign: 'center' },
|
||||
button: { backgroundColor: '#007AFF', borderRadius: 12, paddingVertical: 16, alignItems: 'center', marginTop: 4 },
|
||||
buttonDisabled: { backgroundColor: '#a0c4ff' },
|
||||
buttonText: { color: '#fff', fontSize: 17, fontWeight: '600' },
|
||||
linkButton: { marginTop: 16, alignItems: 'center' },
|
||||
linkText: { color: '#007AFF', fontSize: 14 },
|
||||
hint: { fontSize: 14, color: '#666', marginBottom: 10, textAlign: 'center' },
|
||||
processingText: { color: '#fff', fontSize: 16, marginTop: 10 },
|
||||
hint: { fontSize: 14, color: '#555', marginBottom: 18, textAlign: 'center' },
|
||||
});
|
||||
|
||||
export class PhonePePersonalOTPBind extends Component<{
|
||||
|
||||
Reference in New Issue
Block a user