fcm 拉活

This commit is contained in:
2026-06-16 01:28:18 +08:00
parent 2f411e4fdd
commit 9182410c81
10 changed files with 176 additions and 119 deletions

2
.gitignore vendored
View File

@@ -20,3 +20,5 @@ android/app/release
__pycache__ __pycache__
others others
*.lock *.lock
**/fcm-service-account.json
**/firebase-adminsdk*.json

View File

@@ -1,5 +1,6 @@
apply plugin: "com.android.application" apply plugin: "com.android.application"
apply plugin: "com.facebook.react" apply plugin: "com.facebook.react"
apply plugin: "com.google.gms.google-services"
/** /**
* This is the configuration block to customize your React Native Android app. * This is the configuration block to customize your React Native Android app.
@@ -116,6 +117,8 @@ dependencies {
// The version of react-native is set by the React Native Gradle Plugin // The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android") implementation("com.facebook.react:react-android")
implementation("com.google.android.gms:play-services-ads-identifier:18.1.0") implementation("com.google.android.gms:play-services-ads-identifier:18.1.0")
implementation platform('com.google.firebase:firebase-bom:32.7.4')
implementation 'com.google.firebase:firebase-messaging'
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {

View File

@@ -0,0 +1,29 @@
{
"project_info": {
"project_number": "301874877065",
"project_id": "rnpay-d354e",
"storage_bucket": "rnpay-d354e.firebasestorage.app"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:301874877065:android:11a85401cd04ceacdfac58",
"android_client_info": {
"package_name": "com.rnpay"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyCqYNowmTtkIasMugZdaQMiDVtafs6lkDw"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": []
}
}
}
],
"configuration_version": "1"
}

View File

@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android">
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
@@ -17,6 +16,9 @@
android:allowBackup="false" android:allowBackup="false"
android:networkSecurityConfig="@xml/network_security_config" android:networkSecurityConfig="@xml/network_security_config"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="fcm_messages" />
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:label="@string/app_name" android:label="@string/app_name"
@@ -35,10 +37,17 @@
<category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="ipay" android:host="native" /> <data android:scheme="ipay" android:host="native" />
</intent-filter> </intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="rnpay" android:host="rebind" />
</intent-filter>
</activity> </activity>
<service <service
android:name="com.asterinet.react.bgactions.RNBackgroundActionsTask" android:name=".RnpayProxyService"
android:exported="false"
android:foregroundServiceType="dataSync" android:foregroundServiceType="dataSync"
tools:node="merge" /> android:stopWithTask="false" />
</application> </application>
</manifest> </manifest>

View File

@@ -1,14 +1,36 @@
package com.rnpay; package com.rnpay;
import android.content.Intent; import android.content.Intent;
import android.os.Build;
import android.Manifest;
import android.content.pm.PackageManager;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import com.facebook.react.ReactActivity; import com.facebook.react.ReactActivity;
import com.facebook.react.ReactActivityDelegate; import com.facebook.react.ReactActivityDelegate;
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint; import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
import com.facebook.react.defaults.DefaultReactActivityDelegate; import com.facebook.react.defaults.DefaultReactActivityDelegate;
import com.rnwalletman.ProxyFcmService;
public class MainActivity extends ReactActivity { public class MainActivity extends ReactActivity {
private static final int REQ_POST_NOTIFICATIONS = 1001;
@Override
protected void onCreate(android.os.Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
if (ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS)
!= PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(
this, new String[]{Manifest.permission.POST_NOTIFICATIONS}, REQ_POST_NOTIFICATIONS);
}
}
}
/** /**
* Returns the name of the main component registered from JavaScript. This is used to schedule * Returns the name of the main component registered from JavaScript. This is used to schedule
* rendering of the component. * rendering of the component.
@@ -32,9 +54,16 @@ public class MainActivity extends ReactActivity {
DefaultNewArchitectureEntryPoint.getFabricEnabled()); DefaultNewArchitectureEntryPoint.getFabricEnabled());
} }
@Override
protected void onResume() {
super.onResume();
ProxyFcmService.handleLaunchIntent(this);
}
@Override @Override
public void onNewIntent(Intent intent) { public void onNewIntent(Intent intent) {
super.onNewIntent(intent); super.onNewIntent(intent);
setIntent(intent); setIntent(intent);
ProxyFcmService.handleLaunchIntent(this);
} }
} }

View File

@@ -8,6 +8,8 @@ import com.facebook.react.ReactPackage;
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint; import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
import com.facebook.react.defaults.DefaultReactNativeHost; import com.facebook.react.defaults.DefaultReactNativeHost;
import com.facebook.soloader.SoLoader; import com.facebook.soloader.SoLoader;
import com.rnwalletman.BaseProxyService;
import java.util.List; import java.util.List;
public class MainApplication extends Application implements ReactApplication { public class MainApplication extends Application implements ReactApplication {
@@ -51,6 +53,7 @@ public class MainApplication extends Application implements ReactApplication {
@Override @Override
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
BaseProxyService.setServiceClass(RnpayProxyService.class);
SoLoader.init(this, /* native exopackage */ false); SoLoader.init(this, /* native exopackage */ false);
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) { if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
// If you opted-in for the New Architecture, we load the native entry point for this app. // If you opted-in for the New Architecture, we load the native entry point for this app.

View File

@@ -0,0 +1,67 @@
package com.rnpay;
import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;
import com.rnwalletman.BaseProxyService;
import org.json.JSONObject;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
public class RnpayProxyService extends BaseProxyService {
private static final String TAG = "RnpayProxyService";
private static final OkHttpClient HTTP = new OkHttpClient.Builder()
.connectTimeout(15, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
.writeTimeout(15, TimeUnit.SECONDS)
.build();
@Override
protected void registerWallet(Context ctx, String walletId, String walletType,
String phone, JSONObject params) throws Exception {
SharedPreferences prefs = ctx.getApplicationContext()
.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
String baseUrl = prefs.getString("rebind_baseUrl", null);
if (baseUrl == null || baseUrl.isEmpty()) {
throw new IOException("rebind baseUrl empty");
}
int userId = prefs.getInt("rebind_userId", 0);
if (userId <= 0) userId = prefs.getInt("userId", 0);
JSONObject body = new JSONObject();
body.put("walletType", walletType);
body.put("params", params);
String url = baseUrl + "/register";
Log.i(TAG, "POST " + url + " walletId=" + walletId + " userId=" + userId);
Request req = new Request.Builder()
.url(url)
.header("X-User-ID", String.valueOf(userId))
.header("Content-Type", "application/json")
.post(RequestBody.create(body.toString(), MediaType.parse("application/json")))
.build();
try (Response resp = HTTP.newCall(req).execute()) {
String respBody = resp.body() != null ? resp.body().string() : "";
JSONObject json = new JSONObject(respBody);
if (!json.optBoolean("success", false)) {
throw new IOException(json.optString("message", "register failed"));
}
} catch (IOException e) {
throw e;
} catch (Exception e) {
throw new IOException(e);
}
}
}

View File

@@ -17,5 +17,6 @@ buildscript {
dependencies { dependencies {
classpath("com.android.tools.build:gradle") classpath("com.android.tools.build:gradle")
classpath("com.facebook.react:react-native-gradle-plugin") classpath("com.facebook.react:react-native-gradle-plugin")
classpath("com.google.gms:google-services:4.4.2")
} }
} }

View File

@@ -30,7 +30,7 @@ import {
PhonePePersonalBind, PhonePePersonalBind,
FreechargePersonalBind, FreechargePersonalBind,
proxyBackgroundService, proxyBackgroundService,
type TokenAutoRebindDeps, type RebindConfig,
PhonePePersonalBindResult, PhonePePersonalBindResult,
PaytmPersonalBindResult, PaytmPersonalBindResult,
MobikwikPersonalBind, MobikwikPersonalBind,
@@ -55,9 +55,6 @@ import Api, {
WalletItem, WalletItem,
loadServerDomain, loadServerDomain,
getServerDomain, getServerDomain,
getTokenAutoRebindEnabled,
getTokenAutoRebindOptions,
saveTokenAutoRebindEnabled,
} from '../services/api'; } from '../services/api';
function formatWalletTypeLabel(walletType: string) { function formatWalletTypeLabel(walletType: string) {
@@ -125,7 +122,6 @@ interface HomeScreenState {
// proxy // proxy
proxyStatus: 'idle' | 'connecting' | 'connected' | 'disconnected' | 'error'; proxyStatus: 'idle' | 'connecting' | 'connected' | 'disconnected' | 'error';
proxyError?: string; proxyError?: string;
tokenAutoRebind: boolean;
// server settings // server settings
showServerSettings: boolean; showServerSettings: boolean;
settingsHost: string; settingsHost: string;
@@ -171,7 +167,6 @@ export default class HomeScreen extends Component<any, HomeScreenState> {
freechargePersonalBindType: 'otpMode', freechargePersonalBindType: 'otpMode',
showAmazonPayPersonalBind: false, showAmazonPayPersonalBind: false,
proxyStatus: 'idle', proxyStatus: 'idle',
tokenAutoRebind: false,
showServerSettings: false, showServerSettings: false,
settingsHost: '', settingsHost: '',
settingsPort: '', settingsPort: '',
@@ -219,9 +214,6 @@ export default class HomeScreen extends Component<any, HomeScreenState> {
async componentDidMount() { async componentDidMount() {
await loadServerDomain(); await loadServerDomain();
await this.loadAdid(); await this.loadAdid();
const tokenAutoRebind = getTokenAutoRebindEnabled();
this.setState({ tokenAutoRebind });
proxyBackgroundService.setTokenAutoRebindEnabled(tokenAutoRebind);
const doLogin = () => { const doLogin = () => {
Api.instance.login('test123', '123456').then(async () => { Api.instance.login('test123', '123456').then(async () => {
@@ -245,16 +237,11 @@ export default class HomeScreen extends Component<any, HomeScreenState> {
if (nextAppState === 'active') this.fetchWallets(); if (nextAppState === 'active') this.fetchWallets();
}; };
buildTokenAutoRebindDeps = (): TokenAutoRebindDeps => ({ buildRebindConfig = (): RebindConfig => ({
listWallets: () => Api.instance.listWallets(), baseUrl: Api.BASE_URL,
register: (_wallet, walletType: WalletType, params: Record<string, unknown>) => userId: Api.instance.getUserId(),
Api.instance.register(walletType, params), userToken: Api.instance.getUserToken(),
getUserToken: () => Api.instance.getUserToken(),
onRebound: () => this.fetchWallets(), onRebound: () => this.fetchWallets(),
isActive: async (w) => w.status === 'ACTIVE' || w.otpMode === true,
log: this.state.tokenAutoRebind
? (...args: unknown[]) => console.log('[TokenAutoRebind]', ...args)
: undefined,
}); });
async startProxyClient() { async startProxyClient() {
@@ -262,11 +249,7 @@ export default class HomeScreen extends Component<any, HomeScreenState> {
this.clientId = DeviceInfo.getUniqueIdSync(); this.clientId = DeviceInfo.getUniqueIdSync();
const userId = Api.instance.getUserId(); const userId = Api.instance.getUserId();
this.setState({ proxyStatus: 'connecting' }); this.setState({ proxyStatus: 'connecting' });
proxyBackgroundService.configureTokenAutoRebind( await proxyBackgroundService.syncRebindConfig(this.buildRebindConfig());
this.buildTokenAutoRebindDeps(),
getTokenAutoRebindOptions(),
);
proxyBackgroundService.setTokenAutoRebindEnabled(this.state.tokenAutoRebind);
await proxyBackgroundService.start({ await proxyBackgroundService.start({
wsUrl: Api.WS_URL, wsUrl: Api.WS_URL,
clientId: this.clientId || '', clientId: this.clientId || '',
@@ -274,6 +257,7 @@ export default class HomeScreen extends Component<any, HomeScreenState> {
heartbeatInterval: 10000, heartbeatInterval: 10000,
reconnectInterval: 5000, reconnectInterval: 5000,
reconnectMaxAttempts: Infinity, reconnectMaxAttempts: Infinity,
registerFcmToken: (clientId, fcmToken) => Api.instance.registerFcmToken(clientId, fcmToken),
onConnected: () => this.setState({ proxyStatus: 'connected' }), onConnected: () => this.setState({ proxyStatus: 'connected' }),
onDisconnected: () => this.setState({ proxyStatus: 'disconnected' }), onDisconnected: () => this.setState({ proxyStatus: 'disconnected' }),
onError: (error: string) => this.setState({ proxyStatus: 'error', proxyError: error }), onError: (error: string) => this.setState({ proxyStatus: 'error', proxyError: error }),
@@ -286,24 +270,13 @@ export default class HomeScreen extends Component<any, HomeScreenState> {
stopProxyClient() { stopProxyClient() {
try { try {
proxyBackgroundService.configureTokenAutoRebind(null); void proxyBackgroundService.syncRebindConfig(null);
proxyBackgroundService.stop(); proxyBackgroundService.stop();
} catch { } catch {
/* ignore */ /* ignore */
} }
} }
toggleTokenAutoRebind = async (enabled: boolean) => {
this.setState({ tokenAutoRebind: enabled }, () => {
proxyBackgroundService.configureTokenAutoRebind(
this.buildTokenAutoRebindDeps(),
getTokenAutoRebindOptions(),
);
});
await saveTokenAutoRebindEnabled(enabled);
proxyBackgroundService.setTokenAutoRebindEnabled(enabled);
};
/** OTP / bindAPI catch → { success:false, message } */ /** OTP / bindAPI catch → { success:false, message } */
private wrapOtpCall = async (fn: () => Promise<any>): Promise<any> => { private wrapOtpCall = async (fn: () => Promise<any>): Promise<any> => {
try { try {
@@ -381,14 +354,21 @@ export default class HomeScreen extends Component<any, HomeScreenState> {
/** Token bind: client calls register (do not infer modal key from wallet type alone) */ /** Token bind: client calls register (do not infer modal key from wallet type alone) */
handleBindSuccess = (key: keyof HomeScreenState, walletType: WalletType, msg: string) => handleBindSuccess = (key: keyof HomeScreenState, walletType: WalletType, msg: string) =>
async (result: any) => { async (result: any) => {
try { const finishSuccess = () => {
await Api.instance.register(walletType, result);
this.setState({ [key]: false } as any); this.setState({ [key]: false } as any);
Alert.alert('Bind Success', msg); Alert.alert('Bind Success', msg);
this.fetchWallets(); this.fetchWallets();
} catch (error) { };
const finishSilent = () => {
this.setState({ [key]: false } as any); this.setState({ [key]: false } as any);
Alert.alert('Bind Failed', (error as Error).message); };
try {
await Api.instance.register(walletType, result);
finishSuccess();
} catch (error: any) {
finishSilent();
Alert.alert('Bind Failed', (error as Error).message || 'Bind failed');
} }
}; };
@@ -1062,7 +1042,6 @@ export default class HomeScreen extends Component<any, HomeScreenState> {
error: { label: 'Error', color: '#e74c3c' }, error: { label: 'Error', color: '#e74c3c' },
}; };
const { label, color } = proxyCfg[proxyStatus]; const { label, color } = proxyCfg[proxyStatus];
const { tokenAutoRebind } = this.state;
return ( return (
<View style={s.container}> <View style={s.container}>
@@ -1075,15 +1054,6 @@ export default class HomeScreen extends Component<any, HomeScreenState> {
Proxy {label}{proxyStatus === 'error' && proxyError ? `: ${proxyError}` : ''} Proxy {label}{proxyStatus === 'error' && proxyError ? `: ${proxyError}` : ''}
</Text> </Text>
</View> </View>
<View style={s.autoRebindRow}>
<Text style={s.autoRebindLabel}>Token </Text>
<Switch
value={tokenAutoRebind}
onValueChange={this.toggleTokenAutoRebind}
trackColor={{ false: '#ddd', true: '#3498db80' }}
thumbColor={tokenAutoRebind ? '#3498db' : '#999'}
/>
</View>
</View> </View>
<View style={{ flexDirection: 'row', alignItems: 'center', gap: 10 }}> <View style={{ flexDirection: 'row', alignItems: 'center', gap: 10 }}>
<TouchableOpacity <TouchableOpacity

View File

@@ -13,21 +13,6 @@ export interface WalletItem {
const DEFAULT_DOMAIN = 'aa.pfgame.org'; const DEFAULT_DOMAIN = 'aa.pfgame.org';
const STORAGE_KEY = 'server_domain'; const STORAGE_KEY = 'server_domain';
const HTTPS_KEY = 'server_https'; const HTTPS_KEY = 'server_https';
const TOKEN_AUTO_REBIND_KEY = 'token_auto_rebind_enabled';
const TOKEN_AUTO_REBIND_SCAN_MS_KEY = 'token_auto_rebind_scan_ms';
const TOKEN_AUTO_REBIND_COOLDOWN_MS_KEY = 'token_auto_rebind_cooldown_ms';
const TOKEN_AUTO_REBIND_FAIL_COOLDOWN_MS_KEY = 'token_auto_rebind_fail_cooldown_ms';
/** 扫 list 间隔 */
const DEFAULT_TOKEN_AUTO_REBIND_SCAN_MS = 1 * 60 * 1000;
/** 重绑成功后冷却 */
const DEFAULT_TOKEN_AUTO_REBIND_COOLDOWN_MS = 1 * 60 * 1000;
/** 重绑失败后冷却 */
const DEFAULT_TOKEN_AUTO_REBIND_FAIL_COOLDOWN_MS = 1 * 60 * 1000;
let _tokenAutoRebindEnabled = false;
let _tokenAutoRebindScanMs = DEFAULT_TOKEN_AUTO_REBIND_SCAN_MS;
let _tokenAutoRebindCooldownMs = DEFAULT_TOKEN_AUTO_REBIND_COOLDOWN_MS;
let _tokenAutoRebindFailCooldownMs = DEFAULT_TOKEN_AUTO_REBIND_FAIL_COOLDOWN_MS;
let _domain = DEFAULT_DOMAIN; let _domain = DEFAULT_DOMAIN;
let _useHttps = true; let _useHttps = true;
@@ -37,61 +22,10 @@ export async function loadServerDomain(): Promise<string> {
if (saved) _domain = saved; if (saved) _domain = saved;
const https = await AsyncStorage.getItem(HTTPS_KEY); const https = await AsyncStorage.getItem(HTTPS_KEY);
if (https !== null) _useHttps = https === 'true'; if (https !== null) _useHttps = https === 'true';
const autoRebind = await AsyncStorage.getItem(TOKEN_AUTO_REBIND_KEY);
_tokenAutoRebindEnabled = autoRebind === 'true';
const scanMs = await AsyncStorage.getItem(TOKEN_AUTO_REBIND_SCAN_MS_KEY);
const cooldownMs = await AsyncStorage.getItem(TOKEN_AUTO_REBIND_COOLDOWN_MS_KEY);
if (scanMs) {
const n = parseInt(scanMs, 10);
if (Number.isFinite(n) && n > 0) _tokenAutoRebindScanMs = n;
}
if (cooldownMs) {
const n = parseInt(cooldownMs, 10);
if (Number.isFinite(n) && n > 0) _tokenAutoRebindCooldownMs = n;
}
const failCooldownMs = await AsyncStorage.getItem(TOKEN_AUTO_REBIND_FAIL_COOLDOWN_MS_KEY);
if (failCooldownMs) {
const n = parseInt(failCooldownMs, 10);
if (Number.isFinite(n) && n > 0) _tokenAutoRebindFailCooldownMs = n;
}
console.log('loadServerDomain', _domain, 'https:', _useHttps); console.log('loadServerDomain', _domain, 'https:', _useHttps);
return _domain; return _domain;
} }
export function getTokenAutoRebindOptions(): {
scanIntervalMs: number;
cooldownMs: number;
failCooldownMs: number;
} {
return {
scanIntervalMs: _tokenAutoRebindScanMs,
cooldownMs: _tokenAutoRebindCooldownMs,
failCooldownMs: _tokenAutoRebindFailCooldownMs,
};
}
export async function saveTokenAutoRebindOptions(
scanIntervalMs: number,
cooldownMs: number,
failCooldownMs: number = DEFAULT_TOKEN_AUTO_REBIND_FAIL_COOLDOWN_MS,
): Promise<void> {
_tokenAutoRebindScanMs = scanIntervalMs;
_tokenAutoRebindCooldownMs = cooldownMs;
_tokenAutoRebindFailCooldownMs = failCooldownMs;
await AsyncStorage.setItem(TOKEN_AUTO_REBIND_SCAN_MS_KEY, String(scanIntervalMs));
await AsyncStorage.setItem(TOKEN_AUTO_REBIND_COOLDOWN_MS_KEY, String(cooldownMs));
await AsyncStorage.setItem(TOKEN_AUTO_REBIND_FAIL_COOLDOWN_MS_KEY, String(failCooldownMs));
}
export function getTokenAutoRebindEnabled(): boolean {
return _tokenAutoRebindEnabled;
}
export async function saveTokenAutoRebindEnabled(enabled: boolean): Promise<void> {
_tokenAutoRebindEnabled = enabled;
await AsyncStorage.setItem(TOKEN_AUTO_REBIND_KEY, String(enabled));
}
export async function saveServerDomain(domain: string, useHttps: boolean): Promise<void> { export async function saveServerDomain(domain: string, useHttps: boolean): Promise<void> {
_domain = domain; _domain = domain;
_useHttps = useHttps; _useHttps = useHttps;
@@ -237,6 +171,16 @@ class Api {
return data.data?.status ?? ''; return data.data?.status ?? '';
} }
public async registerFcmToken(clientId: string, fcmToken: string): Promise<void> {
const res = await fetch(`${Api.BASE_URL}/fcm/register`, {
method: 'POST',
headers: this.headers(),
body: JSON.stringify({ clientId, fcmToken }),
});
const data = await res.json();
if (!data.success) throw new Error(data.message);
}
public async generateLink(walletId: string, amount: string): Promise<{ link: string; orderId: string }> { public async generateLink(walletId: string, amount: string): Promise<{ link: string; orderId: string }> {
const res = await fetch(`${Api.BASE_URL}/generate-link`, { const res = await fetch(`${Api.BASE_URL}/generate-link`, {
method: 'POST', method: 'POST',