Skip to content

Conversation

@gbirch-stripe
Copy link
Collaborator

@gbirch-stripe gbirch-stripe commented Dec 18, 2025

Summary

Part 4/x of a factor of the ConfirmButton. Previously the ConfirmButton class supported both the Apple Pay button and confirm buttons, but now it only supports confirm buttons and can be simplified, improve code clarity and SDK binary size.
Draft PR showing the whole change: #5678.

This PR flattens the update code to live directly in the BuyButton. This sets up the BuyButton implementation to replace the ConfirmButton wrapper and itself become the ConfirmButton

Motivation

Testing

Changelog

Comment on lines -71 to -72
private(set) var status: Status = .enabled
private(set) var callToAction: CallToActionType
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These properties are moved to the BuyButton

Comment on lines -153 to -174
self.status = status
self.callToAction = callToAction

// Enable/disable
isUserInteractionEnabled = (status == .enabled || status == .disabled)

// Update the buy button; it has its own presentation logic
self.buyButton.update(status: status, callToAction: callToAction, animated: animated)

if let completion = completion {
let delay: TimeInterval = {
guard animated else {
return 0
}

return status == .succeeded
? PaymentSheetUI.delayBetweenSuccessAndDismissal
: PaymentSheetUI.defaultAnimationDuration
}()

DispatchQueue.main.asyncAfter(deadline: .now() + delay, execute: completion)
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This function and the old BuyButton.update functions are unified into a single BuyButton.update function. For now the ConfirmButton.update functions are just wrappers that pass the data to the BuyButton to complete all logic

return appearance.primaryButton.successBackgroundColor
}

private var status: Status = .enabled
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Before, the ConfirmButton and BuyButton each had their own status property that needed to be kept in sync. Now there's only one, which is the BuyButton's

Comment on lines +355 to +358
self.callToAction = callToAction

// Enable/disable
isUserInteractionEnabled = (status == .enabled || status == .disabled)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is from the old ConfirmButton.update function

Comment on lines +493 to +506

if let completion = completion {
let delay: TimeInterval = {
guard animated else {
return 0
}

return status == .succeeded
? PaymentSheetUI.delayBetweenSuccessAndDismissal
: PaymentSheetUI.defaultAnimationDuration
}()

DispatchQueue.main.asyncAfter(deadline: .now() + delay, execute: completion)
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is from the old ConfirmButton.update function

@github-actions
Copy link

github-actions bot commented Dec 18, 2025

✅ Dead code has been resolved in this PR.

[find-dead-code]

@gbirch-stripe gbirch-stripe marked this pull request as ready for review December 18, 2025 20:06
@gbirch-stripe gbirch-stripe requested review from a team as code owners December 18, 2025 20:07
@gbirch-stripe gbirch-stripe merged commit 06e3d42 into master Jan 8, 2026
8 checks passed
@gbirch-stripe gbirch-stripe deleted the gbirch/confirm-button-move-update-logic branch January 8, 2026 23:16
@gbirch-stripe gbirch-stripe changed the title ConfirmButton refactor 4/x - Move update logic ConfirmButton refactor 4/5 - Move update logic Jan 9, 2026
@gbirch-stripe gbirch-stripe changed the title ConfirmButton refactor 4/5 - Move update logic ConfirmButton refactor 4/6 - Move update logic Jan 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants