Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- STPApplePayContext is a convenience class to handle Apple Pay for one time payments. It unfortunately hasn't yet been extended to support more general use-cases like Subscription.
- To be more specific, the `createPaymentMethod()` delegate method on STPApplePayContext requires a client_secret​ for a PaymentIntent, so the entire class is heavily coupled to PaymentIntents.
- What I would recommend is to instead, integrate directly against PKPaymentAuthorizationViewController, the native class to present to handle Apple Pay.
- Roughly what this would involve is:
- 1) Setting up a PKPaymentRequest (which you are doing already)
- 2) Initializing and presenting the PKPaymentAuthorizationViewController
- 3) implementing PKPaymentAuthorizationViewController delegate methods
- 4) in the didAuthorizePayment()​ delegate method [0] , you call createTokenWithPayment() on STPAPIClient [1]
- 5) With the Token object from step 4, you can attach it to a Customer server-side, which gives you a Card object. You then create a Subscription on the Customer.
- The iOS example app in the SDK has unfortunately migrated its internal example implementation over to STPApplePayContext but if you checkout the example app from v19.0.1 of the iOS SDK (before STPApplePayContext was added), you can find a reference implementation to help you: https://github.com/stripe/stripe-ios/blob/v19.0.1/Example/Non-Card%20Payment%20Examples/ApplePayExampleViewController.m
- [0] https://developer.apple.com/documentation/passkit/pkpaymentauthorizationviewcontrollerdelegate/2865759-paymentauthorizationviewcontroll
- [1] https://stripe.dev/stripe-ios/docs/Classes/STPAPIClient.html#/c:objc(cs)STPAPIClient(im)createTokenWithPayment:completion:
Advertisement
Add Comment
Please, Sign In to add comment