-
-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add currency selection logic update.
- Loading branch information
1 parent
055b469
commit 1e2f7f0
Showing
8 changed files
with
96 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...ecuresms/components/settings/app/subscription/donate/gateway/GatewaySelectorRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.thoughtcrime.securesms.components.settings.app.subscription.donate.gateway | ||
|
||
import io.reactivex.rxjava3.core.Single | ||
import org.thoughtcrime.securesms.components.settings.app.subscription.getAvailablePaymentMethods | ||
import org.whispersystems.signalservice.api.services.DonationsService | ||
import java.util.Locale | ||
|
||
class GatewaySelectorRepository( | ||
private val donationsService: DonationsService | ||
) { | ||
fun getAvailableGateways(currencyCode: String): Single<Set<GatewayResponse.Gateway>> { | ||
return Single.fromCallable { | ||
donationsService.getDonationsConfiguration(Locale.getDefault()) | ||
}.flatMap { it.flattenResult() } | ||
.map { configuration -> | ||
configuration.getAvailablePaymentMethods(currencyCode).map { | ||
when (it) { | ||
"PAYPAL" -> listOf(GatewayResponse.Gateway.PAYPAL) | ||
"CARD" -> listOf(GatewayResponse.Gateway.CREDIT_CARD, GatewayResponse.Gateway.GOOGLE_PAY) | ||
else -> listOf() | ||
} | ||
}.flatten().toSet() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters