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

Add a card on STPPaymentOptionsViewController doesn't work for the first time. #1758

Closed
daigok opened this issue Feb 4, 2021 · 3 comments
Closed
Assignees
Labels
triaged Issue has been reviewed by Stripe and is being tracked internally

Comments

@daigok
Copy link

daigok commented Feb 4, 2021

Summary

I'm using STPPaymentOptionsViewController with SwiftUI. The ViewController shows "Add a Card" view if a customer doesn't have a card. If I try to add a card on the "Add a Card" view, it keep loading forever and doesn't call registering apis.

It worked fine with SDK 21.0.1 or lower.

Code to reproduce

The code snippet I'm using is here.

iOS version

14.4

Installation method

Swift Package Manager

SDK version

21.2.1

Other information

I've debugged the SDK and found apiAdapter on STPPaymentOptionsViewController is nil for the first card addition.
https://github.com/stripe/stripe-ios/blob/21.2.1/Stripe/STPPaymentOptionsViewController.swift#L278

This is because apiAdapter is not used if a customer doesn't have a card on the view controller initialization and also apiAdapter is defined as weak.
https://github.com/stripe/stripe-ios/blob/21.2.1/Stripe/STPPaymentOptionsViewController.swift#L88-L127

Hence, the following code is not called and the view keeps loading forever.
https://github.com/stripe/stripe-ios/blob/21.2.1/Stripe/STPPaymentOptionsViewController.swift#L437

Add a Card view keeps loading forever.
Simulator Screen Shot - iPhone SE (2nd generation) - 2021-02-04 at 17 12 51

@Ariandr
Copy link

Ariandr commented Feb 7, 2021

I have the same issue on 21.2.1 (not using SwiftUI)

Happens when I initialize STPPaymentOptionsViewController using this initializer:

  public convenience init(
    configuration: STPPaymentConfiguration,
    theme: STPTheme,
    customerContext: STPCustomerContext,
    delegate: STPPaymentOptionsViewControllerDelegate
  )

I was doing it for the purpose of managing payment options in a "Payment methods" menu item in the user settings in the app.
So, my behavior required not closing the controller after pressing on a method (or adding a new card), but rather setting it as a default payment method.

P.S. When I present this controller by calling present/push on payment context (present or push Payment Options Controller), it works for the first card and there is no loader.

@csabol-stripe
Copy link
Contributor

@daigok thanks for the detailed report! I've got a fix for this that will be included in the next release :)

@csabol-stripe csabol-stripe self-assigned this Feb 8, 2021
@csabol-stripe csabol-stripe added the triaged Issue has been reviewed by Stripe and is being tracked internally label Feb 8, 2021
@davidme-stripe
Copy link
Contributor

This is fixed in 21.3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triaged Issue has been reviewed by Stripe and is being tracked internally
Projects
None yet
Development

No branches or pull requests

4 participants