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

PaymentSheet now always shows Apple Pay as a button above the saved P… #3543

Merged
merged 3 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### PaymentSheet
* [Added] Support for Multibanco with PaymentIntents.
* [Fixed] Fixed an issue where STPPaymentHandler sometimes reported errors using `unexpectedErrorCode` instead of a more specific error when customers fail a next action.
* [Changed] PaymentSheet displays Apple Pay as a button when there are saved payment methods and Link isn't available instead of within the list of saved payment methods.
* [Fixed] Expiration dates more than 50 years in the past (e.g. `95`) are now blocked.

### Payments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ final class PaymentSheetLoader {
let (defaultSelectedIndex, paymentOptionsViewModels) = SavedPaymentOptionsViewController.makeViewModels(
savedPaymentMethods: filteredSavedPaymentMethods,
customerID: configuration.customer?.id,
showApplePay: isFlowController ? isApplePayEnabled : PaymentSheetViewController.shouldShowApplePayAsSavedPaymentOption(hasSavedPaymentMethods: !filteredSavedPaymentMethods.isEmpty, isLinkEnabled: isLinkEnabled, isApplePayEnabled: isApplePayEnabled),
showApplePay: isFlowController ? isApplePayEnabled : false,
showLink: isFlowController ? isLinkEnabled : false
)
analyticsClient.logPaymentSheetLoadSucceeded(loadingStartDate: loadingStartDate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,10 @@ class PaymentSheetViewController: UIViewController {
case .addingNew:
return isWalletEnabled
case .selectingSaved:
// When selecting saved we only add the wallet header for Link -- ApplePay by itself is inlined
return isLinkEnabled
return isLinkEnabled || isApplePayEnabled
}
}

/// This is a hack to encapsulate this logic so that it can be reused by PaymentSheetLoader to determine whether Apple Pay will be shown as a payment option or not.
static func shouldShowApplePayAsSavedPaymentOption(hasSavedPaymentMethods: Bool, isLinkEnabled: Bool, isApplePayEnabled: Bool) -> Bool {
return hasSavedPaymentMethods && !isLinkEnabled && isApplePayEnabled
}

// MARK: - Writable Properties
weak var delegate: PaymentSheetViewControllerDelegate?
private(set) var intent: Intent
Expand Down Expand Up @@ -206,7 +200,7 @@ class PaymentSheetViewController: UIViewController {
savedPaymentMethods: savedPaymentMethods,
configuration: .init(
customerID: configuration.customer?.id,
showApplePay: Self.shouldShowApplePayAsSavedPaymentOption(hasSavedPaymentMethods: !savedPaymentMethods.isEmpty, isLinkEnabled: isLinkEnabled, isApplePayEnabled: isApplePayEnabled),
showApplePay: false,
showLink: false,
removeSavedPaymentMethodMessage: configuration.removeSavedPaymentMethodMessage,
merchantDisplayName: configuration.merchantDisplayName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class PaymentSheetSnapshotTests: STPSnapshotTestCase {
var runAgainstLiveService: Bool = false
override func setUp() {
super.setUp()
// recordMode = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that you can rerun these by choosing the "AllStripeFrameworks-RecordMode" scheme and running the test, you don't need to add this line anymore

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oooh thanks


configuration = PaymentSheet.Configuration()
configuration.merchantDisplayName = "Example, Inc."
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading