Skip to content

Commit

Permalink
Don't show Link cards in SPM mode (stripe#3248)
Browse files Browse the repository at this point in the history
## Summary
Every time a user uses Link, it adds another card to the Customer
object. Just like Apple Pay and Google Pay, we should filter these out.

## Testing
Updated unit tests, tested manually on a test account
  • Loading branch information
davidme-stripe authored Feb 5, 2024
1 parent 392f6d0 commit d788aee
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Stripe/StripeiOSTests/STPPaymentMethodCardWalletTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class STPPaymentMethodCardWalletTest: XCTestCase {
XCTAssertEqual(STPPaymentMethodCardWallet.type(from: "SAMSUNG_PAY"), .samsungPay)
XCTAssertEqual(STPPaymentMethodCardWallet.type(from: "visa_checkout"), .visaCheckout)
XCTAssertEqual(STPPaymentMethodCardWallet.type(from: "VISA_CHECKOUT"), .visaCheckout)
XCTAssertEqual(STPPaymentMethodCardWallet.type(from: "link"), .link)
XCTAssertEqual(STPPaymentMethodCardWallet.type(from: "LINK"), .link)
}

// MARK: - STPAPIResponseDecodable Tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,10 @@ final class PaymentSheetLoader {
continuation.resume(throwing: error)
return
}
// Remove cards that originated from Apple or Google Pay
// Remove cards that originated from Apple Pay, Google Pay, or Link
paymentMethods = paymentMethods.filter { paymentMethod in
let isAppleOrGooglePay = paymentMethod.type == .card && [.applePay, .googlePay].contains(paymentMethod.card?.wallet?.type)
return !isAppleOrGooglePay
let isWalletCard = paymentMethod.type == .card && [.applePay, .googlePay, .link].contains(paymentMethod.card?.wallet?.type)
return !isWalletCard
}
continuation.resume(returning: paymentMethods)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public enum STPPaymentMethodCardWalletType: Int {
case samsungPay
/// Visa Checkout
case visaCheckout
/// Link
case link
/// An unknown Card Wallet type.
case unknown
}
Expand Down Expand Up @@ -61,6 +63,7 @@ public class STPPaymentMethodCardWallet: NSObject, STPAPIResponseDecodable {
"masterpass": NSNumber(value: STPPaymentMethodCardWalletType.masterpass.rawValue),
"samsung_pay": NSNumber(value: STPPaymentMethodCardWalletType.samsungPay.rawValue),
"visa_checkout": NSNumber(value: STPPaymentMethodCardWalletType.visaCheckout.rawValue),
"link": NSNumber(value: STPPaymentMethodCardWalletType.link.rawValue),
]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,8 @@ extension STPPaymentMethodCardWalletType: CustomStringConvertible {
return "masterpass"
case .samsungPay:
return "samsungPay"
case .link:
return "link"
case .unknown:
return "unknown"
case .visaCheckout:
Expand Down

0 comments on commit d788aee

Please sign in to comment.