CW-1153-Enable Revolut Pay for Moonpay (#2759)

* update quote sorting logic for sell action

* аix payment method selection

* fix duplicates payment methods

Updated the logic to consider payment methods as duplicates based only on paymentMethodType, ignoring customTitle. This simplifies duplicate detection and may address issues with adding similar payment methods.

* add revolut support for moonpay

* refactor best rate recommendation logic
This commit is contained in:
Serhii
2025-12-30 16:06:45 +01:00
committed by GitHub
parent 934b50da62
commit 00e5ea4ea8
5 changed files with 29 additions and 4 deletions
+5
View File
@@ -0,0 +1,5 @@
<svg width="200" height="200" viewBox="0 0 1200 1200" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M282.04 0H917.96C1073.73 0 1200 126.274 1200 282.04V917.96C1200 1073.73 1073.73 1200 917.96 1200H282.04C126.274 1200 0 1073.73 0 917.96V282.04C0 126.274 126.274 0 282.04 0Z" fill="white"/>
<path d="M465.747 393.15H313.576V1008.46H465.747V393.15Z" fill="black"/>
<path d="M717.943 664.889C842.616 658.631 942.949 553.88 942.949 428.336C942.949 297.768 836.625 191.54 705.927 191.54H313.576V322.947H687.271C746.418 322.947 795.414 369.414 796.495 426.527C797.037 455.123 786.304 482.112 766.276 502.518C746.241 522.933 719.469 534.183 690.898 534.183H545.325C540.156 534.183 535.948 538.383 535.948 543.551V660.341C535.948 662.327 536.562 664.226 537.717 665.825L784.704 1008.46H965.505L717.943 664.889Z" fill="black"/>
</svg>

After

Width:  |  Height:  |  Size: 836 B

+5
View File
@@ -0,0 +1,5 @@
<svg width="200" height="200" viewBox="0 0 1200 1200" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M282.04 0H917.96C1073.73 0 1200 126.274 1200 282.04V917.96C1200 1073.73 1073.73 1200 917.96 1200H282.04C126.274 1200 0 1073.73 0 917.96V282.04C0 126.274 126.274 0 282.04 0Z" fill="black"/>
<path d="M465.747 393.15H313.576V1008.46H465.747V393.15Z" fill="white"/>
<path d="M717.943 664.889C842.616 658.631 942.949 553.88 942.949 428.336C942.949 297.768 836.625 191.54 705.927 191.54H313.576V322.947H687.271C746.418 322.947 795.414 369.414 796.495 426.527C797.037 455.123 786.304 482.112 766.276 502.518C746.241 522.933 719.469 534.183 690.898 534.183H545.325C540.156 534.183 535.948 538.383 535.948 543.551V660.341C535.948 662.327 536.562 664.226 537.717 665.825L784.704 1008.46H965.505L717.943 664.889Z" fill="white"/>
</svg>

After

Width:  |  Height:  |  Size: 836 B

+4
View File
@@ -383,6 +383,8 @@ class MoonPayProvider extends BuyProvider {
return 'yellow_card_bank_transfer';
case PaymentType.fiatBalance:
return 'fiat_balance';
case PaymentType.revolutPay:
return 'revolut_pay';
default:
return null;
}
@@ -416,6 +418,8 @@ class MoonPayProvider extends BuyProvider {
return PaymentType.sepaOpenBankingPayment;
case 'yellow_card_bank_transfer':
return PaymentType.yellowCardBankTransfer;
case 'revolut_pay':
return PaymentType.revolutPay;
default:
return PaymentType.unknown;
}
+4
View File
@@ -124,6 +124,8 @@ extension PaymentTypeTitle on PaymentType {
return 'assets/images/skrill.svg';
case PaymentType.applePay:
return 'assets/images/apple_pay_round_light.svg';
case PaymentType.revolutPay:
return 'assets/images/revolut_light.svg';
default:
return null;
}
@@ -143,6 +145,8 @@ extension PaymentTypeTitle on PaymentType {
return 'assets/images/skrill.svg';
case PaymentType.applePay:
return 'assets/images/apple_pay_round_dark.svg';
case PaymentType.revolutPay:
return 'assets/images/revolut_dark.svg';
default:
return null;
}
+11 -4
View File
@@ -367,8 +367,7 @@ abstract class BuySellViewModelBase extends WalletChangeListenerViewModel with S
for (var methods in result) {
for (var method in methods) {
final alreadyExists = tempPaymentMethods.any((m) {
return m.paymentMethodType == method.paymentMethodType &&
m.customTitle == method.customTitle;
return m.paymentMethodType == method.paymentMethodType;
});
if (!alreadyExists) {
@@ -468,8 +467,7 @@ abstract class BuySellViewModelBase extends WalletChangeListenerViewModel with S
if (sortedRecommendedQuotes.isNotEmpty) {
sortedRecommendedQuotes.first
..setIsBestRate = true
..recommendations.insert(0, ProviderRecommendation.bestRate);
..setIsBestRate = true;
bestRateQuote = sortedRecommendedQuotes.first;
sortedRecommendedQuotes.sort((a, b) {
@@ -478,6 +476,15 @@ abstract class BuySellViewModelBase extends WalletChangeListenerViewModel with S
return 0;
});
final Quote effectiveBestRateQuote =
sortedRecommendedQuotes.reduce((a, b) {
return isBuyAction ? a.rate < b.rate ? a : b : a.rate > b.rate ? a : b;
});
effectiveBestRateQuote.recommendations
.add(ProviderRecommendation.bestRate);
selectedQuote = sortedRecommendedQuotes.first;
sortedRecommendedQuotes.first.setIsSelected = true;
}