#gary_code

1 messages ยท Page 1 of 1 (latest)

raven pelicanBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1299406056744685673

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

halcyon ember
mental inlet
#

Yes I get an error "Argument type 'StripePaymentView' does not conform to expected type '_stpinternal_STPApplePayContextDelegateBase'" on this line of code "if let applePayContext = STPApplePayContext(paymentRequest: paymentRequest, delegate: self) {"

#

So I added this code as well "extension StripePaymentView: STPApplePayContextDelegate {
func applePayContext(_ context: STPApplePayContext, didCreatePaymentMethod paymentMethod: STPPaymentMethod, completion: @escaping STPIntentClientSecretCompletionBlock) {
// Create a PaymentIntent or SetupIntent on your server and return the client secret.
// Pass the client secret to the completion block.
}
}" but get this error "Cannot find type 'STPApplePayContextDelegate' in scope"

halcyon ember
#

I'm not familiar with the way you are implementing the STPApplePayContext here. Can you trying starting with this code and let me know if this works?

@import Stripe;
@import StripeCore;
@import StripeApplePay;
#import <PassKit/PassKit.h>
@interface CheckoutViewController () <STPApplePayContextDelegate>
@property (nonatomic) PKPaymentButton *applePayButton;
@end
@implementation CheckoutViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    // Only offer Apple Pay if the customer can pay with it
    self.applePayButton.hidden = ![StripeAPI deviceSupportsApplePay];
    [self.applePayButton addTarget:self action:@selector(handleApplePayButtonTapped) forControlEvents:UIControlEventTouchUpInside];
}

from our doc here: https://docs.stripe.com/apple-pay?platform=ios&lang-ios=objc#check-if-apple-pay-supported

mental inlet
#

Thats Objective-C and not Swift, do you have a Swift equivalent?

halcyon ember
#

Oh yeah, I just saw the STPApplePayContextDelegate and figured you were using Objective C

import StripeApplePay
import PassKit

class CheckoutViewController: UIViewController, ApplePayContextDelegate {
    let applePayButton: PKPaymentButton = PKPaymentButton(paymentButtonType: .plain, paymentButtonStyle: .black)

    override func viewDidLoad() {
        super.viewDidLoad()
        // Only offer Apple Pay if the customer can pay with it
        applePayButton.isHidden = !StripeAPI.deviceSupportsApplePay()
        applePayButton.addTarget(self, action: #selector(handleApplePayButtonTapped), for: .touchUpInside)
    }

    // ...continued in next step
}