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

Expose init(stripeId:) on STPPaymentMethod #1729

Closed
mikeDaoud opened this issue Dec 11, 2020 · 8 comments
Closed

Expose init(stripeId:) on STPPaymentMethod #1729

mikeDaoud opened this issue Dec 11, 2020 · 8 comments
Assignees
Labels
triaged Issue has been reviewed by Stripe and is being tracked internally

Comments

@mikeDaoud
Copy link

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 to detachPaymentMethod(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 a STPPaymentMethod 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

@ahmadfs
Copy link

ahmadfs commented Dec 16, 2020

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()        
    }

@yuki-stripe yuki-stripe self-assigned this Dec 16, 2020
@yuki-stripe
Copy link
Collaborator

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 yuki-stripe added the triaged Issue has been reviewed by Stripe and is being tracked internally label Dec 16, 2020
@ahmadfs
Copy link

ahmadfs commented Dec 16, 2020

@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.

@yuki-stripe
Copy link
Collaborator

@ahmadfs Can you use the stripeId property of the STPPaymentMethod object?

@ahmadfs
Copy link

ahmadfs commented Dec 17, 2020

@yuki-stripe : We were able to work around the problem. Thank you for the tips.

@davidme-stripe
Copy link
Contributor

This was added in version 21.2.0.

@mikeDaoud
Copy link
Author

@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

@davidme-stripe
Copy link
Contributor

Hi! Sorry about that, I should have linked to the change in my comment. We have new functions on STPCustomerContext to handle this: 4a33940

You should use detachPaymentMethodFromCustomer(paymentMethodId: String, completion: STPErrorBlock?) with your PaymentMethod ID.

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