stripe-ios icon indicating copy to clipboard operation
stripe-ios copied to clipboard

[BUG] ApplePay does not use the STPAPIClient provided to PaymentSheet

Open MrJackScratch opened this issue 2 years ago • 1 comments

Summary

Using Payment Sheet to collect payments. When creating the payment sheet, we are creating a STPAPIClient with an API key provided by our server. This works to collect credit card payments.

However when using ApplePay, the sheet shows an error that no API key was provided. The way to fix this issue is to set a publishableKey on the shared API client, but this is unexpected, since we would expect all payment methods in the PaymentSheet to use the client the sheet is configured with.

Code to reproduce

DO NOT set STPAPIClient.shared.publishableKey. Leave it as the default key.

Create a PaymentSheet using a different client, which is configured with a valid key.

    var config = PaymentSheet.Configuration()
    config.apiClient = STPAPIClient(publishableKey: serverResponse.publishableKey)
    config.merchantDisplayName = "Example, Inc."
    config.applePay = ApplePayConfiguration(
      merchantId: "merchant.com.example",
      merchantCountryCode: "US"
    )

    return PaymentSheet(paymentIntentClientSecret: intent.paymentIntentClientSecret, configuration: config)

iOS version

15.5

Installation method

Swift Package Manager

SDK version

22.6.0

Other information

MrJackScratch avatar Aug 03 '22 15:08 MrJackScratch

Hi @MrJackScratch -

Thank you so much for reaching out to us. We've looked into this issue and does indeed seem to be a bug. We have identified a fix, and intend to have a fix out in our next scheduled release.

I will be keeping this ticket open, and when the bugfix has been released, I will close this issue.

wooj-stripe avatar Aug 05 '22 22:08 wooj-stripe

Just checking in, since there have been a couple releases since this was marked "fixed in master".

Is this fixed in the current release?

MrJackScratch avatar Nov 02 '22 17:11 MrJackScratch

Oops, hit the wrong button.

MrJackScratch avatar Nov 02 '22 17:11 MrJackScratch

Yes, this is expected to be in the latest release.

The associated commit for this fix is: https://github.com/stripe/stripe-ios/commit/aa66822e09a20da2d42a805e5bbcf8ceafe2dcc7

Which should be part of >=22.7.1

wooj-stripe avatar Nov 03 '22 21:11 wooj-stripe