Closed mikeDaoud closed 3 years ago
We are running into this problem as well which is causing our app to not compile anymore. Do you have any tips or advice? We only upgraded to reduce the size of the overall SDK for our App Clip integration and now we seem to be blocked.
In our case, when we initialize the STPPaymentMethod, we are getting this error:
'NSObject' initializer is inaccessible due to '@_spi' protection level
Here is our example code which was working previously:
func paymentOptionsViewController(_ paymentOptionsViewController: STPPaymentOptionsViewController, didSelect paymentOption: STPPaymentOption) {
// Save selected payment option
var stpPM: STPPaymentMethod = paymentOption as? STPPaymentMethod ?? STPPaymentMethod()
}
Hi @mikeAttia and @ahmadfs,
Thanks for the report, I understand the issue. Sorry about this! We'll expose the correct API to use in the next release.
In the mean time, as a super hacky workaround, I think you could use
let paymentMethod = STPPaymentMethod.decodedObject(fromAPIResponse: ["id": "your id here"])
to initialize a STPPaymentMethod for your purposes.
@yuki-stripe : Thank you for the reply but I don't believe your suggestion would help us. In our case we were getting the new selected payment method from the STPPaymentOptionsViewController delegate. So we don't know the payment id. This in line with Stripe's guidance here: https://stripe.com/docs/mobile/ios/basic.
@ahmadfs Can you use the stripeId
property of the STPPaymentMethod
object?
@yuki-stripe : We were able to work around the problem. Thank you for the tips.
This was added in version 21.2.0.
@davidme-stripe I think this issue was not resolved still in 21.2.0.
the init(stripeId:)
is still marked as internal and inaccessible for the app code.
Please check link to the method in code
https://github.com/stripe/stripe-ios/blob/master/Stripe/STPPaymentMethod.swift#L173
Hi! Sorry about that, I should have linked to the change in my comment. We have new functions on STPCustomerContext
to handle this: https://github.com/stripe/stripe-ios/commit/4a33940386e076603b81a503cde948329c34b27b
You should use detachPaymentMethodFromCustomer(paymentMethodId: String, completion: STPErrorBlock?)
with your PaymentMethod ID.
Summary
After updating to the swift SDK v 21.1.0, I have a problem initialising
STPPaymentMethod
with a stripe Id in order to pass it todetachPaymentMethod(fromCustomer: completion:)
in order to remove SEPA payment method from user account.Code to reproduce
When customer desires to remove a SEPA payment method, I need to call
detachPaymentMethod(fromCustomer: completion:)
on the customer context object, which takes aSTPPaymentMethod
as a parameter. but I can't create one using only a stripe ID.iOS version
we support iOS 11.0 and above
Installation method
pull SDK using Cocoapods
SDK version
21.1.0
Other information