#jack_api
1 messages Β· Page 1 of 1 (latest)
π Welcome to your new thread!
β²οΈ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
β±οΈ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
π This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1293025495595876374
π Have more to share? Add more details, code, screenshots, videos, etc. below.
What is the problem youβre facing?
the screen hangs
the app crashes as shown above
Swift 5 / IOS 16
Here is the sanitized code - STPAPIClient.shared.publishableKey = self.stripe_publishable_api_key
// MARK: Create a PaymentSheet instance
var configuration = PaymentSheet.Configuration()
configuration.merchantDisplayName = "BO, Inc."
configuration.customer = .init(id: self.customer_id, ephemeralKeySecret: self.ephemeral_key)
// Set `allowsDelayedPaymentMethods` to true if your business can handle payment methods
// that complete payment after a delay, like SEPA Debit and Sofort.
configuration.allowsDelayedPaymentMethods = true
configuration.returnURL = "www.openbarn.com"
// self.paymentSheet = PaymentSheet(paymentIntentClientSecret: self.payment_intent, configuration: configuration)
self.paymentSheet = PaymentSheet(paymentIntentClientSecret: self.payment_intent, configuration: configuration)
print(self.Tag, " after paymentsheet")
// MARK: Start the checkout process
let paymentHandler = STPPaymentHandler.shared()
// ProgressHUD.present(view: self.view, mview: self)
DispatchQueue.main.async {
self.paymentSheet?.present(from: self) { paymentResult in
print(self.Tag, " paymentResult : " , paymentResult)
switch paymentResult {
case .completed:
print("Your order is confirmed")
case .canceled:
print("Payment canceled!")
case .failed(let error):
print("Payment failed: \(error.localizedDescription)")
}
}
}
podfile install - pod 'Stripe', '~> 23.31.0'
pod 'StripePaymentSheet', '~> 23.31.0'
@lofty sail π
Can you log payment intent client secret and ephemeral key to check those values are set correctly in the configuration?
@lofty sail let me try
when you say payment intent secret do you mean stripe_publishable_api_key?
We are not creating any payment intent, only doing a paymentsheet @lofty sail
both ephemeral key and stripe_publishable_api_key are the same that is shown in the dashboard (stripe.com)
To present a Payment Sheet, a Payment Intent and ephemeral keys should be created first, then set in Payment Sheet configuration and its initialization
Yes. We include it
This has been explained in https://docs.stripe.com/payments/accept-a-payment?platform=ios#ios-collect-payment-details:
// MARK: Fetch the PaymentIntent client secret, Ephemeral Key secret, Customer ID, and publishable key
var request = URLRequest(url: backendCheckoutUrl)
request.httpMethod = "POST"
let task = URLSession.shared.dataTask(with: request, completionHandler: { [weak self] (data, response, error) in
guard let data = data,
let json = try? JSONSerialization.jsonObject(with: data, options: []) as? [String : Any],
let customerId = json["customer"] as? String,
let customerEphemeralKeySecret = json["ephemeralKey"] as? String,
let paymentIntentClientSecret = json["paymentIntent"] as? String,
let publishableKey = json["publishableKey"] as? String,
let self = self else {
// Handle error
return
}
self.paymentSheet = PaymentSheet(paymentIntentClientSecret: self.payment_intent, configuration: configuration)
Yes. We include it already.
What are the values of customerEphemeralKeySecret and paymentIntentClientSecret?
Please see code above
Can you log ephemeral key secret and payment intent secret? What are their values?
Let me run it again and share them here
ephemeral_key ek_test_YWNjdF8xNkQxNFpHRmhIcUpINjc4LFAzVDFGRzgzekduclpOS2JwTUlrM0RZampxeHlCdWY_00f72QECy7 intent : pi_3Q7Sp7GFhHqJH6780ycgzS2V_secret_KeC2DpbknWUzXJNZng92GnKbN
Just checked the Stripe dashboad and they are the same.
I am getting this error in my Xcode simulator
Req ID -
req_kYwc8cGyfRQXJk
@lofty sail π
Thanks for waiting! Discord is busy now. Looking into them
The code and secrets look right to me. Is there any error in your iOS logs?
None
This is where the app crashes
LOG ANALYTICS: mc_load_started - [(key: "pay_var", value: "legacy"), (key: "ocr_type", value: "none"), (key: "mpe_config", value: ["customer": true, "save_payment_method_opt_in_behavior": "automatic", "apple_pay_config": false, "appearance": ["colors": false, "usage": false, "shadow": false, "primary_button": false, "font": false, "corner_radius": false, "border_width": false], "style": 0, "payment_method_layout": "horizontal", "default_billing_details": false, "allows_delayed_payment_methods": true, "billing_details_collection_configuration": ["address": "automatic", "name": "automatic", "email": "automatic", "phone": "automatic", "attach_defaults": false], "customer_access_provider": "legacy", "return_url": true]), (key: "is_decoupled", value: false), (key: "apple_pay_enabled", value: 1), (key: "active_link_session", value: false)]
Error in StripeUICore
@lofty sail π
Please be patient. We are looking into your code
π
Could you share your decoder how to parse the response returned from the server? The common cause it that server respond client_secret but you are trying to parse clientSecret. This will cause the configuration Payment Sheet fails to load due to null client secret reading from the different parameter name
My backend sends the client secret. Same function call for Android and IOS
The stripe payment sheet works for android
Client secret is fetched by the same backend for Android and iOS
The issue is not with the backend. It's the parser at client side
How did you parse the response in iOS? Did you fetch the client secret from the correct parameter name?
I fetch the client secret from backend and pass it to the IOS app
Could you share the decoder at you iOS app on you get the response from the server?
The issue is likely that you get the information from incorrect field at your decoder
Where is the client secret used in the IOS front end?
are you referring to the payment_intent?
We checked the pi_3Q7Sp7GFhHqJH6780ycgzS2V_secret_KeC2DpbknWUzXJNZng92GnKbN and looked the same from the Stripe Dashboard
Hi I'm taking over this thread
Hi Jack Stripe
How does your backend response json looks like? is the client secret returned as client_secret or clientSecret ?
This is your code, is self.payment_intent == paymentIntent.client_secret?
yes
Do you have any crash log?
I don't see any crash here
the stripe paymentsheet hangs
The wheel keeps spinning
Don't see the fields for the user to enter payment
Is your Simulator connected to internet?
Can you share a sample xcode project so that I can run and reproduce?
No I don't need the entire source code, I just a simple xcode project that contains code that I can run and reproduce the problem.
What issue? I'm afraid that I don't understand. I don't see any error in the screenshot
In Xcode this is the line that get's highlighted when the Stripe PaymentSheet starts to hang
Do you pass a default billing address to paymentSheet?
Also are you using the latest version of Stripe iOS SDK?
pod 'Stripe', '~> 23.31.0'
pod 'StripePaymentSheet', '~> 23.31.0'
I don't think we pass default billing address
Is there a parameter?
What happen if you press the continue button?
Added this to the config - configuration.defaultBillingDetails.address.country = "US"
Same issues
Can you check your breakpoint settings and remove unncessary breakpoints?
Ok. Thanks. That helped. I had set breakpoints for all obj-c errors. They were getting triggered. Not sure why.