1

I currently have a working Stripe set up where the AddCardViewController is opened first and everything works.

However, when I try to implement the PaymentSettingsViewController first and let user Add/Edit their cards, it won't load.

I am using the first function to initialially present the addCardViewController, I want to replace this with the PaymentOptionsViewController.

func openAddCardViewController(navController: UINavigationController) {
    addCardViewController = STPAddCardViewController()
    addCardViewController?.delegate = self
    self.navController = navController
    navController.pushFromBottom(viewController: addCardViewController!)
}

func openPaymentOptionsViewController(navController: UINavigationController) {
    paymentOptionsViewController = STPPaymentOptionsViewController()
    self.navController = navController
    navController.pushFromBottom(viewController: paymentOptionsViewController!)
}

I would like it to just load and then I take it from there and use existing code from the working setup.

What I don't understand is why when I push the AddCardViewController, the view loads fine, but not with the PaymentOptions, its just a loading indicator, and the cancel button won't pop the view.

Wolfgang
  • 132
  • 11
  • 1
    Can you explain what you mean by "it won't load" - do you get any errors?, also where are you calling `openPaymentOptionsViewController` ? – Wez Jan 23 '20 at 09:49
  • 1
    The UI won't load, the view loads, but where the UI should be is only a loading indicator. Perhaps I need to get some customer context... – Wolfgang Jan 23 '20 at 10:08
  • 1
    @Wez Do I perhaps need to get a new ephemeral key, to retrieve payment methods or let a user create one? – Wolfgang Jan 23 '20 at 10:22
  • 1
    Not sure, but looks like you need to use one of the init methods to get the correct context to load - [have a look at the docs](https://stripe.dev/stripe-ios/docs/Classes/STPPaymentOptionsViewController.html#/c:objc(cs)STPPaymentOptionsViewController(im)initWithConfiguration:theme:customerContext:delegate:) – Wez Jan 23 '20 at 10:24
  • 1
    Yes, you need to have a backend suppling an ephemeral key for a Stripe customer object, and a STPCustomerSession and so on, so there's quite a few prerequisites here. So start with at least the first 3 steps of https://stripe.com/docs/mobile/ios/basic – karllekko Jan 23 '20 at 10:37
  • @karllekko This sounds very correct yes, working on this right now. Thanks guys. I guess the answer to my question is that in order to manage a customers payment settings/methods, you need your backend to supply an ephemeral key to retrieve the customers list of payment methods or to make/update them. Ill see how it goes, cheers! – Wolfgang Jan 23 '20 at 10:50

0 Answers0