Skip to content

Commit

Permalink
Fix payment cancellation on back press during processing
Browse files Browse the repository at this point in the history
  • Loading branch information
jameswoo-stripe committed Nov 18, 2022
1 parent 264d791 commit a98001e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,8 @@ class PaymentSheetPlaygroundActivity : AppCompatActivity() {
disableViews()
}

println("JAMES: ${paymentResult.toString()}")

viewModel.status.value = paymentResult.toString()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import android.view.ViewGroup
import android.view.WindowManager
import android.widget.ScrollView
import android.widget.TextView
import androidx.activity.addCallback
import androidx.activity.viewModels
import androidx.annotation.IdRes
import androidx.annotation.VisibleForTesting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import android.view.WindowInsets
import android.view.WindowMetrics
import android.widget.ScrollView
import android.widget.TextView
import androidx.activity.addCallback
import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import androidx.annotation.VisibleForTesting
Expand Down Expand Up @@ -186,12 +187,15 @@ internal abstract class BaseSheetActivity<ResultType> : AppCompatActivity() {
overridePendingTransition(AnimationConstants.FADE_IN, AnimationConstants.FADE_OUT)
}

@Deprecated("Deprecated in Java")
override fun onBackPressed() {
if (supportFragmentManager.backStackEntryCount > 0) {
clearErrorMessages()
super.onBackPressed()
} else {
viewModel.onUserCancel()
if (viewModel.processing.value == false) {
if (supportFragmentManager.backStackEntryCount > 0) {
clearErrorMessages()
super.onBackPressed()
} else {
viewModel.onUserCancel()
}
}
}

Expand Down

0 comments on commit a98001e

Please sign in to comment.