-
Notifications
You must be signed in to change notification settings - Fork 659
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
Fix bug in PaymentSheet
where newly save payment method is not set as default payment method.
#7496
Conversation
is PaymentSheet.InitializationMode.DeferredIntent -> { | ||
initializationMode.intentConfiguration.mode.setupFutureUse != null || requestedToSave | ||
} | ||
} |
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.
Marking this as especially important to review. Decides if the newly added card should be saved as the default selection.
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.
@tillh-stripe can you also take a look (especially here).
Diffuse output:
APK
DEX
|
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.
This is super well done, and is a huge win. Thanks for doing this @samer-stripe!
...ents-core/src/main/java/com/stripe/android/payments/paymentlauncher/PaymentLauncherResult.kt
Outdated
Show resolved
Hide resolved
paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentSheetViewModel.kt
Outdated
Show resolved
Hide resolved
is PaymentSheet.InitializationMode.DeferredIntent -> { | ||
initializationMode.intentConfiguration.mode.setupFutureUse != null || requestedToSave | ||
} | ||
} |
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.
@tillh-stripe can you also take a look (especially here).
paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentSheetViewModel.kt
Outdated
Show resolved
Hide resolved
09b5c75
to
603dcb6
Compare
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.
Chatted offline, I think it makes sense to add an E2E test or two. But overall looks great.
payments-core/src/main/java/com/stripe/android/payments/paymentlauncher/PaymentLauncher.kt
Outdated
Show resolved
Hide resolved
@@ -531,6 +533,32 @@ internal class PaymentSheetViewModel @Inject internal constructor( | |||
} | |||
} | |||
|
|||
private fun onPaymentLauncherResult(launcherResult: PaymentLauncherResult) { |
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.
With onPaymentResult
now only being used by Link, should we switch it over too (and does that even give us any benefit)?
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.
From what I can tell, Link only produces the payment method that was used by not a stripe intent. If we can pull the intent, then we can make it use PaymentLauncherResult
. Otherwise, there are a few things we can do.
- We could limit
PaymentLauncherResult
to just return the payment method then haveLink
use that result inside ofPaymentResult
. - Have
Link
return its own response type with the payment method and removeonPaymentResult
.
Either way, there isn't any huge benefit to doing it since Link methods aren't saved. onPaymentResult
is a BaseSheetViewModel
method that is used in other places so we'd have to remove them there as well.
603dcb6
to
a5b69c6
Compare
a5b69c6
to
06518f1
Compare
06518f1
to
eb30fb4
Compare
|
||
/* | ||
* TODO(samer-stripe): Once we update `PaymentResult` to return a `StripeIntent`, update the test | ||
* to check against the payment method IDs rather than the last 4 digits. |
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.
Highlighting this comment.
paymentsheet-example/src/androidTest/java/com/stripe/android/lpm/TestCard.kt
Outdated
Show resolved
Hide resolved
paymentsheet-example/src/androidTest/java/com/stripe/android/lpm/TestCard.kt
Outdated
Show resolved
Hide resolved
paymentsheet/src/main/java/com/stripe/android/paymentsheet/utils/SelectionUtils.kt
Show resolved
Hide resolved
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.
LGTM, I wouldn't mind a second set of eyes on the two places I called out. But not blocking.
Summary
Fix bug in
PaymentSheet
where newly save payment method is not set as default payment method.Motivation
RUN_MOBILESDK-2667
Makes sure that newly added payment methods are selected by default.
Testing