diff --git a/components/WalletBindComponents.tsx b/components/WalletBindComponents.tsx index fa35726..b72a18b 100644 --- a/components/WalletBindComponents.tsx +++ b/components/WalletBindComponents.tsx @@ -2,7 +2,6 @@ import React, { Component, useState, useEffect } from 'react'; import { Alert, View, Text, TextInput, TouchableOpacity, StyleSheet, ActivityIndicator } from 'react-native'; import { WalletType, - BindErrorCode, MobikwikPersonalBind, FreechargePersonalBindResult, MobikwikPersonalBindResult, @@ -14,32 +13,6 @@ import { } 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; onVerifyOTP: (walletType: WalletType, params: any) => Promise; @@ -69,24 +42,19 @@ export class FreeChargeBind extends Component<{ export class MobikwikPersonalTokenBind extends Component<{ userToken: string; onSuccess: (result: MobikwikPersonalBindResult) => void; + onError: (code: string, message: string) => void; onClose?: () => void; isDebug?: boolean; }> { render() { - const { userToken, onSuccess, onClose, isDebug = false } = this.props; + const { userToken, onSuccess, onError, isDebug = false } = this.props; return ( { - 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)} + onSuccess={onSuccess} + onError={onError} /> ); } diff --git a/screens/HomeScreen.tsx b/screens/HomeScreen.tsx index 33c3566..103523a 100644 --- a/screens/HomeScreen.tsx +++ b/screens/HomeScreen.tsx @@ -31,12 +31,13 @@ import { type TokenAutoRebindDeps, PhonePePersonalBindResult, PaytmPersonalBindResult, + MobikwikPersonalBind, + MobikwikPersonalBindResult, BindErrorCode, } from 'rnwalletman'; import { FreeChargeBind, - MobikwikPersonalTokenBind, MobikwikPersonalOTPBind, PayTmPersonalOTPBind, PhonePePersonalOTPBind, @@ -380,7 +381,7 @@ export default class HomeScreen extends Component { this.setState({ [key]: false, bindPrefillMobile: '' } as any); if (showPaytmPersonalBind && paytmPersonalBindType === 'tokenMode') { - const remoteVersion = '1'; + const remoteVersion = '2'; return ( { Alert.alert('Bind Failed', 'App version outdated. Reinstall required'); 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); }} @@ -638,15 +643,54 @@ export default class HomeScreen extends Component { transparent onRequestClose={close('showMobikwikPersonalBind')} > - { + if (!result.hashId) { + Alert.alert('Bind Failed', 'Please login in Mobikwik app first'); + return; + } + 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')(); + }} /> ); diff --git a/upi.html b/upi.html index 3fa692b..688e41d 100644 --- a/upi.html +++ b/upi.html @@ -235,6 +235,7 @@ Pay Now + @@ -367,6 +368,18 @@ 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 = { 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'), @@ -459,6 +472,12 @@ } catch (_) { } }); + document.getElementById('mobikwik-bank-btn').addEventListener('click', function () { + try { + window.location.href = mobikwikBankTransferLink(); + } catch (_) { } + }); + document.getElementById('airtel-bank-btn').addEventListener('click', function () { try { window.location.href = airtelBankTransferLink();