-
Notifications
You must be signed in to change notification settings - Fork 629
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test mode toggle and simplify playground logic (#8416)
- Loading branch information
1 parent
12ef08f
commit 299f56e
Showing
12 changed files
with
131 additions
and
87 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
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
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
38 changes: 38 additions & 0 deletions
38
...src/main/java/com/stripe/android/financialconnections/example/settings/TestModeSetting.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,38 @@ | ||
package com.stripe.android.financialconnections.example.settings | ||
|
||
import com.stripe.android.financialconnections.example.Flow | ||
import com.stripe.android.financialconnections.example.Merchant | ||
import com.stripe.android.financialconnections.example.data.model.LinkAccountSessionBody | ||
import com.stripe.android.financialconnections.example.data.model.PaymentIntentBody | ||
|
||
data class TestModeSetting( | ||
override val selectedOption: Boolean = false, | ||
override val key: String = "financial_connections_test_mode", | ||
) : Saveable<Boolean>, SingleChoiceSetting<Boolean>( | ||
displayName = "Enable Test Mode", | ||
options = listOf( | ||
Option("On", true), | ||
Option("Off", false), | ||
), | ||
selectedOption = selectedOption | ||
) { | ||
override fun lasRequest( | ||
body: LinkAccountSessionBody, | ||
): LinkAccountSessionBody = body.copy(testMode = selectedOption) | ||
|
||
override fun paymentIntentRequest( | ||
body: PaymentIntentBody, | ||
): PaymentIntentBody = body.copy(testMode = selectedOption) | ||
|
||
override fun valueUpdated(currentSettings: List<Setting<*>>, value: Boolean): List<Setting<*>> { | ||
return replace(currentSettings, this.copy(selectedOption = value)) | ||
} | ||
|
||
override fun shouldDisplay(merchant: Merchant, flow: Flow): Boolean { | ||
return merchant != Merchant.Custom && merchant.canSwitchBetweenTestAndLive | ||
} | ||
|
||
override fun convertToValue(value: String): Boolean = value.toBoolean() | ||
|
||
override fun convertToString(value: Boolean): String = value.toString() | ||
} |