新的paytmbiz 魔改包
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import React, { Component, useState, useEffect } from 'react';
|
||||
import { Alert, View, Text, TextInput, TouchableOpacity, StyleSheet, ActivityIndicator } from 'react-native';
|
||||
import { Alert, NativeModules, View, Text, TextInput, TouchableOpacity, StyleSheet, ActivityIndicator } from 'react-native';
|
||||
import {
|
||||
WalletType,
|
||||
BindErrorCode,
|
||||
MobikwikPersonalBind,
|
||||
FreechargePersonalBindResult,
|
||||
MobikwikPersonalBindResult,
|
||||
@@ -338,3 +339,53 @@ export class AmazonPayOTPBind extends Component<{
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// ---- PaytmBusinessTokenBind: AIDL token mode ----
|
||||
|
||||
const { PaytmBusinessModule } = NativeModules;
|
||||
|
||||
export const PaytmBusinessTokenBind: React.FC<{
|
||||
isDebug: boolean;
|
||||
processString: string;
|
||||
onSuccess: (result: any) => void;
|
||||
onError: (code: string, message: string) => void;
|
||||
}> = ({ isDebug, processString, onSuccess, onError }) => {
|
||||
const log = (...args: any[]) => { if (isDebug) console.log('[PaytmBiz]', ...args); };
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
if (!PaytmBusinessModule) {
|
||||
onError(BindErrorCode.NATIVE_MODULE_UNAVAILABLE, 'Paytm Business native module not available');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
log('Connecting to Paytm Business AIDL service...');
|
||||
const raw = await PaytmBusinessModule.getGbPayInfo();
|
||||
const data = JSON.parse(raw);
|
||||
log('Raw data:', data);
|
||||
if (!data?.AUTH?.accessToken) {
|
||||
onError(BindErrorCode.NOT_LOGGED_IN, 'Please login in Paytm Business app first');
|
||||
return;
|
||||
}
|
||||
onSuccess({
|
||||
mobile: data.phone ?? '',
|
||||
accessToken: data.AUTH.accessToken,
|
||||
refreshToken: data.AUTH.refreshToken ?? '',
|
||||
chType: data.chType ?? 'paytmbiz',
|
||||
chVersion: data.chVersion ?? '1',
|
||||
version: data.version ?? '',
|
||||
});
|
||||
} catch (e: any) {
|
||||
log('Error:', e);
|
||||
onError(e?.code ?? BindErrorCode.ERROR, e?.message ?? String(e));
|
||||
}
|
||||
})();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<View style={{ flex: 1, backgroundColor: 'rgba(0,0,0,0.6)', justifyContent: 'center', alignItems: 'center' }}>
|
||||
<ActivityIndicator size="large" color="#fff" />
|
||||
<Text style={{ color: '#fff', marginTop: 16, fontSize: 15 }}>{processString}</Text>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user