Skip to content

Commit f3c2e76

Browse files
authored
Support stripe payment on Android (#6591)
Task/Issue URL: https://app.asana.com/1/137249556945/task/1210380647876465?focus=true ### Description Add support for showing stripe flow on Android ### Steps to test this PR - [x] Apply patch attached in https://app.asana.com/1/137249556945/project/1209991789468715/task/1210448620621729?focus=true - [x] Fresh install - [x] Sign in on grafana.duckduckgo.com - [x] Go to Settings > Subscription Settings and change base URL to https://charmston.duckduckgo.com/subscriptions - [x] Close and open the app - [x] Go to https://charmston.duckduckgo.com/pro?featurePage=stripe - [x] You should see options to buy products, select one of them - [x] Add testing details to purchase the subscription (see [Stripe testing](https://docs.stripe.com/testing#testing-interactively)) - [x] Once purchase successful, check you are redirected to Welcome page - [x] Go to Settings screen and check subscription features are visible and available - [x] Go to Settings > Subscription Settings and check the Free Trial is active ### No UI changes
1 parent fe57cd6 commit f3c2e76

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

subscriptions/subscriptions-impl/src/main/java/com/duckduckgo/subscriptions/impl/RealSubscriptions.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,9 @@ interface PrivacyProFeature {
255255

256256
@Toggle.DefaultValue(DefaultFeatureValue.TRUE)
257257
fun useClientWithCacheForFeatures(): Toggle
258+
259+
@Toggle.DefaultValue(DefaultFeatureValue.TRUE)
260+
fun supportsAlternateStripePaymentFlow(): Toggle
258261
}
259262

260263
@ContributesBinding(AppScope::class)

subscriptions/subscriptions-impl/src/main/java/com/duckduckgo/subscriptions/impl/messaging/SubscriptionMessagingInterface.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,9 +407,11 @@ class SubscriptionMessagingInterface @Inject constructor(
407407

408408
val authV2Enabled = privacyProFeature.enableSubscriptionFlowsV2().isEnabled()
409409
val duckAiSubscriberModelsEnabled = privacyProFeature.duckAiPlus().isEnabled()
410+
val supportsAlternateStripePaymentFlow = privacyProFeature.supportsAlternateStripePaymentFlow().isEnabled()
410411
val resultJson = JSONObject().apply {
411412
put("useSubscriptionsAuthV2", authV2Enabled)
412413
put("usePaidDuckAi", duckAiSubscriberModelsEnabled)
414+
put("useAlternateStripePaymentFlow", supportsAlternateStripePaymentFlow)
413415
}
414416

415417
val response = JsRequestResponse.Success(

subscriptions/subscriptions-impl/src/test/java/com/duckduckgo/subscriptions/impl/messaging/SubscriptionMessagingInterfaceTest.kt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -822,13 +822,14 @@ class SubscriptionMessagingInterfaceTest {
822822
givenSubscriptionMessaging(enabled = true)
823823
givenAuthV2(enabled = true)
824824
givenDuckAiPlus(enabled = true)
825+
givenStripeSupported(enabled = true)
825826

826827
val expected = JsRequestResponse.Success(
827828
context = "subscriptionPages",
828829
featureName = "useSubscription",
829830
method = "getFeatureConfig",
830831
id = "myId",
831-
result = JSONObject("""{"useSubscriptionsAuthV2":true,"usePaidDuckAi":true}"""),
832+
result = JSONObject("""{"useSubscriptionsAuthV2":true,"usePaidDuckAi":true,"useAlternateStripePaymentFlow":true}"""),
832833
)
833834

834835
val message = """
@@ -851,13 +852,14 @@ class SubscriptionMessagingInterfaceTest {
851852
givenSubscriptionMessaging(enabled = true)
852853
givenAuthV2(enabled = false)
853854
givenDuckAiPlus(enabled = true)
855+
givenStripeSupported(enabled = true)
854856

855857
val expected = JsRequestResponse.Success(
856858
context = "subscriptionPages",
857859
featureName = "useSubscription",
858860
method = "getFeatureConfig",
859861
id = "myId",
860-
result = JSONObject("""{"useSubscriptionsAuthV2":false,"usePaidDuckAi":true}"""),
862+
result = JSONObject("""{"useSubscriptionsAuthV2":false,"usePaidDuckAi":true,"useAlternateStripePaymentFlow":true}"""),
861863
)
862864

863865
val message = """
@@ -880,13 +882,14 @@ class SubscriptionMessagingInterfaceTest {
880882
givenSubscriptionMessaging(enabled = true)
881883
givenAuthV2(enabled = true)
882884
givenDuckAiPlus(enabled = false)
885+
givenStripeSupported(enabled = true)
883886

884887
val expected = JsRequestResponse.Success(
885888
context = "subscriptionPages",
886889
featureName = "useSubscription",
887890
method = "getFeatureConfig",
888891
id = "myId",
889-
result = JSONObject("""{"useSubscriptionsAuthV2":true,"usePaidDuckAi":false}"""),
892+
result = JSONObject("""{"useSubscriptionsAuthV2":true,"usePaidDuckAi":false,"useAlternateStripePaymentFlow":true}"""),
890893
)
891894

892895
val message = """
@@ -988,6 +991,12 @@ class SubscriptionMessagingInterfaceTest {
988991
whenever(privacyProFeature.duckAiPlus()).thenReturn(duckAiPlusToggle)
989992
}
990993

994+
private fun givenStripeSupported(enabled: Boolean) {
995+
val stripeSupportedToggle = mock<com.duckduckgo.feature.toggles.api.Toggle>()
996+
whenever(stripeSupportedToggle.isEnabled()).thenReturn(enabled)
997+
whenever(privacyProFeature.supportsAlternateStripePaymentFlow()).thenReturn(stripeSupportedToggle)
998+
}
999+
9911000
private fun checkEquals(expected: JsRequestResponse, actual: JsRequestResponse) {
9921001
if (expected is JsRequestResponse.Success && actual is JsRequestResponse.Success) {
9931002
assertEquals(expected.id, actual.id)

0 commit comments

Comments
 (0)