Skip to content

Commit

Permalink
Don't select a new PaymentMethod after deleting one (#1813)
Browse files Browse the repository at this point in the history
Users should explicitly select a new PaymentMethod
  • Loading branch information
mshafrir-stripe authored Nov 11, 2019
1 parent ad73074 commit 225e6ef
Showing 1 changed file with 0 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,8 @@ internal class PaymentMethodsAdapter @JvmOverloads internal constructor(
internal fun deletePaymentMethod(paymentMethod: PaymentMethod) {
val indexToDelete = paymentMethods.indexOfFirst { it.id == paymentMethod.id }
if (indexToDelete >= 0) {
val wasSelectedPaymentMethod =
selectedPaymentMethodId?.let { it == paymentMethod.id } == true
paymentMethods.removeAt(indexToDelete)
notifyItemRemoved(indexToDelete)

// customer has deleted their selected Payment Method,
// so automatically select the most recently added Payment Method
if (wasSelectedPaymentMethod && paymentMethods.isNotEmpty()) {
updateSelectedPaymentMethod(0)
}
}
}

Expand Down

0 comments on commit 225e6ef

Please sign in to comment.