stripe-react-native: CurrencyCode prop missing on ApplePay settings for initPaymentSheet

Describe the bug

We initialized a new payment sheet with support for Apple Pay. In the initPaymentSheet is a config object for Apple Pay with the ApplePayParams: https://stripe.dev/stripe-react-native/api-reference/modules/PaymentSheet.html#ApplePayParams

When we use the cartItems with the item (label, amount, paymentType), and we see this in the native Apple Pay sheet.

The issue is that ApplePayParams does not accept any currencyCode param and the value of cartItems is displayed only in USD. The Apple docs show that PkPaymentRequest received currencyCode (https://developer.apple.com/documentation/passkit/pkpaymentrequest/1619248-currencycode) .

Is there a way to get this working, to either enable currencyCode to be passed in or suggest another way of doing this?

To Reproduce

  1. Create a new initPaymentSheet
  2. Pass in ApplePay params
  3. Observe the Apple Pay native sheet always showing USD

Expected behavior

ApplePayParams enable you to pass the currencyCode param.

Screenshots

image image

Smartphone (please complete the following information):

  • Device: iPhone 14 (Simulator)
  • OS: iOS 16
  • Version: 0.26.0

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 5
  • Comments: 16

Most upvoted comments

@charliecruzan-stripe - any updates please?

Ah I see what you mean, yeah we do need to add support for that!

We also encountered this problem on our application. Apple is becoming more strict during the reviews and demands that all Apple Pay details are present and correct. We need to be able to customize the currency of the Apple Pay summary and/or cart items during a payment method configuration (setup intent created from server).

Will preface this with the following: This is in no way a good workaround, should be used just as a temporariy patch until this is fixed internally. Someone with a bit more time can probably make it nicer/more versatile so will leave this here.

Issue stemps from Pods -> StripePaymentSheet -> STPApplePayContext+PaymentSheet.swift where we have:

let paymentRequest = StripeAPI.paymentRequest(
          withMerchantIdentifier: applePay.merchantId,
          country: applePay.merchantCountryCode,
          currency: intent.currency ?? "USD"
      )

Considering SetupIntent does not allow for currency to be set nor we have that option within initPaymentSheet the quickest way i found is to actually just change the default based on need. This works for situations where single currency is needed.

Within podfile and under post_install do |installer| amend your post_install hook to include:

installer.pods_project.targets.each do |target|
      if target.name == 'StripePaymentSheet'
        # Access the source build phase to find the Swift file
        target.source_build_phase.files.each do |file|
          if file.display_name.include?('STPApplePayContext+PaymentSheet.swift')
            # Use `file.file_ref` to get the file reference
            file_ref = file.file_ref
            # Use the real path method to get the correct file path
            path = file_ref.real_path # This should give you the correct absolute path
  
            # Ensure the file has write permissions
            if File.exist?(path)
              puts "Setting write permissions for #{path}" # Debugging line
              system("chmod +w '#{path}'") # This sets write permissions
  
              # Now proceed to replace "USD" with "GBP"
              file_content = File.read(path)
              updated_content = file_content.gsub('"USD"', '"GBP"') # Replace "USD" with "GBP"
              File.write(path, updated_content)
              puts "Replaced currency in #{path}"
            else
              puts "File does not exist at path: #{path}" # Debugging line if file doesn't exist
            end
          end
        end
      end
     end

I’ve tested it both locally (device and simulator) and on a ci/cd built app and it works.

Replace “GBP” with desired currency as per need.

Again please use with caution.

@charliecruzan-stripe - any updates please?

No update yet, have not started work on this

@charliecruzan-stripe Hey Charlie, we are using Setup Intent (future payment instead of immediate payment intent on the server.

The NodeJS call for stripe.setupIntents.create does not include currency or amount.

image

Currently the only workaround was to handle Apple Pay payment outside of the initPaymentSheet call with confirmPlatformPaySetupIntent, where we could specify the currencyCode.