-
Notifications
You must be signed in to change notification settings - Fork 988
CHECK-384: Enable Google Pay support in Stripe PaymentSheet behind a feature gate #2565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package com.kickstarter.utils | ||
|
|
||
| import android.annotation.SuppressLint | ||
| import com.google.android.gms.wallet.IsReadyToPayRequest | ||
| import com.google.android.gms.wallet.PaymentsClient | ||
| import com.stripe.android.googlepaylauncher.GooglePayAvailabilityClient | ||
| import com.stripe.android.googlepaylauncher.GooglePayRepository | ||
| import kotlinx.coroutines.tasks.await | ||
| import org.json.JSONObject | ||
|
|
||
| object GooglePayAvailabilityUtil { | ||
| /* This is a workaround that allows Google Pay to work in `Test` mode, pulled directly from | ||
| * the associated Issue in the Stripe SDK: https://github.com/stripe/stripe-android/issues/13968 */ | ||
| fun overrideGooglePayAvailabilityClient() { | ||
| @SuppressLint("RestrictedApi") | ||
| GooglePayRepository.googlePayAvailabilityClientFactory = | ||
| object : GooglePayAvailabilityClient.Factory { | ||
| override fun create(paymentsClient: PaymentsClient) = | ||
| object : GooglePayAvailabilityClient { | ||
| override suspend fun isReady(request: IsReadyToPayRequest): Boolean { | ||
| val relaxed = JSONObject(request.toJson()) | ||
| .apply { remove("existingPaymentMethodRequired") } | ||
| return paymentsClient | ||
| .isReadyToPay(IsReadyToPayRequest.fromJson(relaxed.toString())) | ||
| .await() | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -110,7 +110,7 @@ class RewardsSelectionViewModel(private val environment: Environment, private va | |
| emitCurrentState() | ||
| } | ||
|
|
||
| if (!refreshData) return | ||
| // if (!refreshData) return | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this is technically a quick fix for the bug that nondeterministically prevents the rewards carousel from loading for Late Pledge Projects. I will create a separate PR for it at some point soon.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A legitimate fix now provided by #2566 |
||
|
|
||
| viewModelScope.launch(CoroutineExceptionHandler { _, throwable -> Timber.e(throwable, "CoroutineExceptionHandler") }) { | ||
| mutableShippingUIState.update { previous -> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package com.kickstarter.libs.utils.extensions | ||
|
|
||
| import com.kickstarter.KSRobolectricTestCase | ||
| import org.junit.Test | ||
|
|
||
| class ContextExtTest : KSRobolectricTestCase() { | ||
| @Test | ||
| fun `test getGooglePayConfiguration()`() { | ||
| val context = application() | ||
| assertNull(context.getGooglePayConfiguration(false, "USD")) | ||
| assertNull(context.getGooglePayConfiguration(true, null)) | ||
| assertNull(context.getGooglePayConfiguration(true, " ")) | ||
| assertNotNull(context.getGooglePayConfiguration(true, "EUR")) | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe worth mentioning here the
googlePayCurrencyCodeis the merchant's ( Kickstarter ), not the project, took a moment to realize why ongetGooglePayConfiguration"US" was hardcoded as country code and same withgetPaymentSheetConfiguration"USD"There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, I'll update the comments to add more clarification:
countryCodeset in theGooglePayConfigurationobject is the country code of the business' (Kickstarter's) Stripe account, so that's hardcoded to"US". (Stripe docs, tech plan)currencyCodefor theGooglePayConfigurationObjectis required for Setup Intents and should be set to the Project's currency. Only in Payment Method Settings, where there is no Project, it was decided to hardcode the value to"USD". Luke's comment here provides more context. So that's where you're seeing an explicit call tothis.getPaymentSheetConfiguration(userEmail, googlePayEnabled, "USD")only inPaymentMethodSettingsActivity.flowControllerPresentPaymentOption(). On the other screens it's variable.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interestingly, in a follow up message to Stripe reps, they responded today suggesting the
countryCodemay also need to be variable based on the Project (if I'm understanding their reply correctly). So if we need to makecountryCodevariable for Crowdfund & Late Pledge checkouts, I anticipate doing so in a separate PR but following the same pattern.