-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[BUG] ApplePayContextDelegate completions aren't sendable #4324
Comments
Hi @blsage thanks for reporting, we'll look into this |
HI @blsage, can you try to call the completion handler on the MainActor? Maybe something like this func applePayContext(
_ context: STPApplePayContext,
didCreatePaymentMethod paymentMethod: StripeAPI.PaymentMethod,
paymentInformation: PKPayment,
completion: @escaping STPIntentClientSecretCompletionBlock
) {
let contribution = self.contribution
Task {
do {
let clientSecret = try await contribution.clientSecret
// Switch explicitly to the main actor
await MainActor.run {
completion(clientSecret, nil)
}
} catch {
// Switch to the main actor for completion as well
await MainActor.run {
completion(nil, error)
}
}
}
} |
Tried all variations of that. The fundamental problem is that you need to make the completion be sendable or you can't send it to the main actor. |
But maybe it's best to triage this issue until you migrate the whole API to async/await and swift 6? Seems a bit like trying to fit a square peg into a round hole. |
My ultimate solution was to create a sendable wrapper class and initialize it with the completion as a |
Summary
When you try to await your client secret within your
applePayContext
delegate function, you receive an error regarding Sendable:Code to reproduce
iOS version
18.1.1
Installation method
SPM
SDK version
Stripe 24.1.0
The text was updated successfully, but these errors were encountered: