Skip to content

[BUG] ApplePayContextDelegate completions aren't sendable #4324

Open
@blsage

Description

Summary

When you try to await your client secret within your applePayContext delegate function, you receive an error regarding Sendable:

Passing closure as a 'sending' parameter risks causing data races between code in the current task and concurrent execution of the closure; this is an error in the Swift 6 language model
Closure captures 'completion' which is accessible to code in the current task

Code to reproduce

    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
                completion(clientSecret, nil) // <- Here
            } catch {
                completion(nil, error)
            }
        }
    }

iOS version

18.1.1

Installation method

SPM

SDK version

Stripe 24.1.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    kind:bugtriagedIssue has been reviewed by Stripe and is being tracked internally

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions