Open jamzi opened 1 year ago
Hi! On iOS, the currency code is taken from the payment intent that's created on the server
@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.
Currently the only workaround was to handle Apple Pay payment outside of the initPaymentSheet call with confirmPlatformPaySetupIntent, where we could specify the currencyCode.
Ah I see what you mean, yeah we do need to add support for that!
Any progress on this @charliecruzan-stripe?
@charliecruzan-stripe any update on this please?
No update yet, have not started work on this
@charliecruzan-stripe - any updates please?
@charliecruzan-stripe - any updates please?
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).
@charliecruzan-stripe hi, any news on this issue? Thanks!
@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.
Currently the only workaround was to handle Apple Pay payment outside of the initPaymentSheet call with confirmPlatformPaySetupIntent, where we could specify the currencyCode.
Hi @jamzi, may you please describe the workaround while we wait for the fix in place? Many thanks.
Any news on a fix or at least workaround? Thanks!
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.
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#ApplePayParamsWhen 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
Expected behavior
ApplePayParams enable you to pass the
currencyCode
param.Screenshots
Smartphone (please complete the following information):