fix: include destination parameter in payment method fetch request

This commit is contained in:
Serhii 2025-05-07 16:01:00 +03:00
parent b7473594cb
commit 4c160e5d9f

View file

@ -60,9 +60,15 @@ class OnRamperBuyProvider extends BuyProvider {
Future<List<PaymentMethod>> getAvailablePaymentTypes(
String fiatCurrency, CryptoCurrency cryptoCurrency, bool isBuyAction) async {
final params = {'type': isBuyAction ? 'buy' : 'sell'};
final normalizedCryptoCurrency =
cryptoCurrency.title + _getNormalizeNetwork(cryptoCurrency);
final url = Uri.https(_baseApiUrl, '$supported$paymentTypes/$fiatCurrency', params);
final sourceCurrency = (isBuyAction ? fiatCurrency : normalizedCryptoCurrency).toLowerCase();
final destinationCurrency = (isBuyAction ? normalizedCryptoCurrency : fiatCurrency).toLowerCase();
final params = {'type': isBuyAction ? 'buy' : 'sell', 'destination' : destinationCurrency};
final url = Uri.https(_baseApiUrl, '$supported$paymentTypes/$sourceCurrency', params);
try {
final response =
@ -75,7 +81,9 @@ class OnRamperBuyProvider extends BuyProvider {
.map((item) => PaymentMethod.fromOnramperJson(item as Map<String, dynamic>))
.toList();
} else {
printV('Failed to fetch available payment types');
final responseBody =
jsonDecode(response.body) as Map<String, dynamic>;
printV('Failed to fetch available payment types: ${responseBody['message']}');
return [];
}
} catch (e) {