Skip to content
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

Wrong behavior on select payment method. #1806

Closed
valentynsmetanin opened this issue Nov 11, 2019 · 2 comments · Fixed by #1820
Closed

Wrong behavior on select payment method. #1806

valentynsmetanin opened this issue Nov 11, 2019 · 2 comments · Fixed by #1820
Assignees
Labels
triaged Issue has been reviewed by Stripe and is being tracked internally

Comments

@valentynsmetanin
Copy link

Summary

Wrong behavior on select payment method.
After calling presentPaymentMethodSelection(), if a user already has selected payment method and on click "back" on the activity AppBar or with the hardware button - onActivityResult receive Activity.RESULT_OK, but need to return Activity.RESULT_CANCELED.

Code to reproduce

private val paymentSession by lazy { PaymentSession(this) }

override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        paymentSession.init(paymentSessionListener, PaymentSessionConfig.Builder().build(), savedInstanceState)
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data) // received resultCode = -1 (Activity.RESULT_OK)
        data?.let {
            paymentSession.handlePaymentData(requestCode, resultCode, it)
        }
}

Android version

6, 7, 8, 9, 10

Impacted devices

Google Pixel, Google Pixel 3

Installation method

Gradle

SDK version

12.3.0

Other information

On click "back" on the activity AppBar back on selecting a payment method must return resultCode = Activity.RESULT_CANCELED (0) in onActivityResult instead of Activity.RESULT_OK (-1)

@mshafrir-stripe
Copy link
Collaborator

@valentynsmetanin thanks for filing. Can you help me understand the underlying issue you're running into? Is it that the behavior changed from when you upgraded to the latest version, or that you simply expect a user tapping back to return Activity.RESULT_CANCELED?

I recommend not checking the result code yourself - let paymentSession.handlePaymentData() handle it.

@mshafrir-stripe mshafrir-stripe self-assigned this Nov 11, 2019
@mshafrir-stripe mshafrir-stripe added the triaged Issue has been reviewed by Stripe and is being tracked internally label Nov 11, 2019
@valentynsmetanin
Copy link
Author

@mshafrir-stripe It's expected result in onActivityResult (Activity.RESULT_CANCELED) on back pressed. Also I have PaymentSession.PaymentSessionListener with own business logic. And I receive data in onPaymentSessionDataChanged on click "back" on the activity AppBar or with the hardware button too.

mshafrir-stripe added a commit that referenced this issue Nov 12, 2019
…Data() logic

`PaymentMethodsActivity` should use `Activity.RESULT_CANCELED`
when the user taps back via the toolbar or back button;
`Activity.RESULT_OK` otherwise.

This signals to the user what happened during in
`PaymentMethodsActivity`.

Fixes #1806
mshafrir-stripe added a commit that referenced this issue Nov 13, 2019
…Data() logic (#1820)

`PaymentMethodsActivity` should use `Activity.RESULT_CANCELED`
when the user taps back via the toolbar or back button;
`Activity.RESULT_OK` otherwise.

This signals to the user what happened during in
`PaymentMethodsActivity`.

Fixes #1806
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triaged Issue has been reviewed by Stripe and is being tracked internally
Projects
None yet
2 participants