Reputation: 1045
Yesterday I added stripe sdk for ios, and used its tutorial to implement adding payment option, and everything worked just fine. Today after a bit of refactor of code (did not change anything crucial) paymentContext.selectedPaymentOption
is nil in delegate method
func paymentContextDidChange(_ paymentContext: STPPaymentContext) {
}
When i init paymentContext
this method is called twice, yesterday first time paymentContext.selectedPaymentOption
was nil but second time it selected default value, today both times i get nil, any idea why?
This is how i init paymentContext
:
let customerContext = STPCustomerContext(keyProvider: StripeClient.sharedClient)
paymentContext = STPPaymentContext(customerContext: customerContext)
Customer is ok, because it can create and read card that are on stripe dashboard, only issue is that default card is not selected.
Upvotes: 1
Views: 1352
Reputation: 1007
The feature is managed locally by the Stripe framework since v16.0.2.
You should store the last payment method ID in your user defaults anywhere and then set STPPaymentContext.defaultPaymentMethod
right after you instantiate the STPPaymentContext
Be sure to follow the note Set this property immediately after initializing STPPaymentContext, or call retryLoading afterwards.
Upvotes: 1
Reputation: 1045
Reason this happened is that at first i was using pod version 15.0.1, and later updated to 16.0.0. I got response from their developer so in short default card is no longer supported.
Here is full response:
That is intentional and it's a change with the PaymentMethods API there is no such concept as a default PaymentMethod any more. Your integration has to maintain that, and explicitly pass the PaymentMethod you want to charge, there simply is no customer-level default
Upvotes: 1