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

[BUG] Apple Pay - SDK not dismissing PKPaymentAuthorizationViewController #1838

Open
guilhermebattaglinrentcars opened this issue Sep 19, 2024 · 7 comments

Comments

@guilhermebattaglinrentcars

Describe the bug
SDK do not dismiss PKPaymentAuthorizationViewController modal after cancelation or payment error.

To Reproduce
Steps to reproduce the behavior:

  1. Try pay with Apple Pay
  2. Tap on X to dismiss the modal
  3. Modal not dismissing

Expected behavior
Dismiss modal when tap on the X (close) button

Environment

  • Device: iPhone 15 Pro Max
  • iOS Version: 18.0
  • SDK Version: 4.13.0
  • Package management system: Cocoapods
  • Xcode version: 16.0
  • Mac OS type: Apple Silicon

Relevant source code

paymentAuthorizationViewControllerDidFinish not calling controller dismiss

image
@goergisn
Copy link
Contributor

Hi @guilhermebattaglinrentcars thank you for reporting, we're looking into it 👌

@atmamont
Copy link
Contributor

Hi @guilhermebattaglinrentcars,

We were not able to reproduce the issue.
You mentioned the paymentAuthorizationViewControllerDidFinish doesn't dismiss the view controller. Whenever a user cancels the Apple Pay flow, the component calls the delegate using self.delegate?.didFail(with: ComponentError.cancelled, from: self) and then it's up to you to dismiss the controller.

You can check the example of how the error state (user canceled) is handled in the Demo app: https://github.com/Adyen/adyen-ios/blob/v4/Demo/Common/IntegrationExample.swift#L90

Please let us know if it helps or if you have more questions.

@goergisn
Copy link
Contributor

goergisn commented Oct 7, 2024

Closing due to inactivity - feel free to re-open if there are any open questions :)

@goergisn goergisn closed this as completed Oct 7, 2024
@dgrunvaldsky
Copy link

Hi, we have similar problem. Our scenario:

Prerequisite

  • set a limit for a payment card and payment amount is higher than the limit

Reproduction

  1. Start a payment with Apple Pay
  2. Confirm the payment
  3. Receive the error
  4. Try to close the modal with (X) but not responding

Alternative scenario

  1. Change to another payment card with higher limit
  2. Confirm the payment
  3. Payment completed successfully
  4. Try to close the modal with X but also not responding

Environment

  • Device: iPhone 15 Pro
  • iOS Version: 18.1.1
  • SDK Version: 5.14.0
  • Package management system: Cocoapods
  • Xcode version: 16.0
  • Mac OS type: Apple Silicon

It is look like, that in paymentAuthorizationViewControllerDidFinish delegate's method, where paymentAuthorizationViewController is set to nil, there lost reference to PKPaymentAuthorizationViewControllerDelegate and the modal not respond to the close action. When click on close button before confirm payment, it is working correctly.

Thank you.

@descorp
Copy link
Contributor

descorp commented Dec 11, 2024

Hey @dgrunvaldsky

Are you on Sessions or Advanced (aka \payments) flow?

For Sessions Apple Pay will dismiss itself.
For Advanced - one must call applePayComponent.finalizeIfNeeded(with: success) and dismiss it manually.

@dgrunvaldsky
Copy link

Hi @descorp,
we don't want to dismiss the sheet after a single error. The SDK treats an error in the Apple Pay sheet as the final state, when it obviously is not since the user can switch to a different card and proceed with the payment.
By the way, Adyen supports iOS 12+, but the ApplePayComponent PKPaymentAuthorizationViewControllerDelegate implementation is using method paymentAuthorizationViewController(_:didAuthorizePayment:completion:) which was deprecated as of iOS 11.

Thank you.

@erenbesel
Copy link
Contributor

Hey @dgrunvaldsky
Thank you for the details, we did not receive any deprecation warnings from Xcode so thanks for brining it to our attention!
As for the dismissal, Apple suggests to dismiss the payment controller in this delegate method as they deem it final.

We will look into this in more detail, thanks!

@atmamont atmamont reopened this Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants