fix: include destination parameter in payment method fetch request (#2254)
Serhii committed
May 7, 2025 at 17:48 UTC
a9e05073a5995a9a18384656aae23f2dc2b18e25
1 file changed
+11
-3
lib/buy/onramper/onramper_buy_provider.dart
+11
-3
@@ -60,9 +60,15 @@ class OnRamperBuyProvider extends BuyProvider {
60
Future<List<PaymentMethod>> getAvailablePaymentTypes(
61
String fiatCurrency, CryptoCurrency cryptoCurrency, bool isBuyAction) async {
62
63
- final params = {'type': isBuyAction ? 'buy' : 'sell'};
63
+ final normalizedCryptoCurrency =
64
+ cryptoCurrency.title + _getNormalizeNetwork(cryptoCurrency);
65
+
66
+ final sourceCurrency = (isBuyAction ? fiatCurrency : normalizedCryptoCurrency).toLowerCase();
67
+ final destinationCurrency = (isBuyAction ? normalizedCryptoCurrency : fiatCurrency).toLowerCase();
68
+
69
+ final params = {'type': isBuyAction ? 'buy' : 'sell', 'destination' : destinationCurrency};
70
65
- final url = Uri.https(_baseApiUrl, '$supported$paymentTypes/$fiatCurrency', params);
71
+ final url = Uri.https(_baseApiUrl, '$supported$paymentTypes/$sourceCurrency', params);
72
73
try {
74
final response =
@@ -75,7 +81,9 @@ class OnRamperBuyProvider extends BuyProvider {
81
.map((item) => PaymentMethod.fromOnramperJson(item as Map<String, dynamic>))
82
.toList();
83
} else {
78
- printV('Failed to fetch available payment types');
84
+ final responseBody =
85
+ jsonDecode(response.body) as Map<String, dynamic>;
86
+ printV('Failed to fetch available payment types: ${responseBody['message']}');
87
return [];
88
}
89
} catch (e) {