fix: include destination parameter in payment method fetch request (#2254)

This commit is contained in:
Serhii 2025-05-07 17:48:13 +03:00 committed by GitHub
parent c6f9d12a8e
commit a9e05073a5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -60,9 +60,15 @@ class OnRamperBuyProvider extends BuyProvider {
Future<List<PaymentMethod>> getAvailablePaymentTypes( Future<List<PaymentMethod>> getAvailablePaymentTypes(
String fiatCurrency, CryptoCurrency cryptoCurrency, bool isBuyAction) async { 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 { try {
final response = final response =
@ -75,7 +81,9 @@ class OnRamperBuyProvider extends BuyProvider {
.map((item) => PaymentMethod.fromOnramperJson(item as Map<String, dynamic>)) .map((item) => PaymentMethod.fromOnramperJson(item as Map<String, dynamic>))
.toList(); .toList();
} else { } 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 []; return [];
} }
} catch (e) { } catch (e) {