Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] [P1] PaymentSheet closes itself as soon as it appears #4605

Open
deepak2503 opened this issue Feb 27, 2025 · 1 comment
Open

[BUG] [P1] PaymentSheet closes itself as soon as it appears #4605

deepak2503 opened this issue Feb 27, 2025 · 1 comment
Labels
kind:bug triaged Issue has been reviewed by Stripe and is being tracked internally

Comments

@deepak2503
Copy link

deepak2503 commented Feb 27, 2025

Summary

I am integrating StripePaymentSheet and initializing it with below mentioned syntax :-

STPAPIClient.shared.publishableKey = APIs.getpublishableKey
// MARK: Create a PaymentSheet instance
var configuration = PaymentSheet.Configuration()
configuration.returnURL = "ariya://stripe-redirect"
configuration.merchantDisplayName = "Ariya"
configuration.customer = .init(id: customerId, ephemeralKeySecret: customerEphemeralKeySecret)
// Set allowsDelayedPaymentMethods to true if your business handles
// delayed notification payment methods like US bank accounts.
configuration.allowsDelayedPaymentMethods = true
self.paymentSheet = PaymentSheet(paymentIntentClientSecret: paymentIntentClientSecret, configuration: configuration)

in my viewwillAppear but when I trying to open the PaymentSheet it opens and closes by itself through error that Payment failed.

Logs are as below :-

LOG ANALYTICS: mc_complete_init_customer - [(key: "pay_var", value: "paymentsheet"), (key: "ocr_type", value: "none"), (key: "mpe_config", value: ["apple_pay_config": false, "appearance": ["colors": false, "font": false, "shadow": false, "usage": false, "primary_button": false, "border_width": false, "embedded_payment_element": ["row_style": false, "row": false], "corner_radius": false], "billing_details_collection_configuration": ["name": "automatic", "address": "automatic", "attach_defaults": false, "phone": "automatic", "email": "automatic"], "customer_access_provider": "legacy", "return_url": true, "customer": true, "card_brand_acceptance": false, "allows_delayed_payment_methods": true, "save_payment_method_opt_in_behavior": "automatic", "style": 0, "payment_method_layout": "automatic", "default_billing_details": false]), (key: "is_decoupled", value: false), (key: "apple_pay_enabled", value: 1), (key: "active_link_session", value: false)]

LOG ANALYTICS: mc_load_started - [(key: "pay_var", value: "paymentsheet"), (key: "ocr_type", value: "none"), (key: "mpe_config", value: ["allows_delayed_payment_methods": true, "default_billing_details": false, "return_url": true, "apple_pay_config": false, "appearance": ["usage": false, "colors": false, "shadow": false, "border_width": false, "corner_radius": false, "embedded_payment_element": ["row": false, "row_style": false], "font": false, "primary_button": false], "billing_details_collection_configuration": ["attach_defaults": false, "name": "automatic", "email": "automatic", "phone": "automatic", "address": "automatic"], "customer": true, "style": 0, "card_brand_acceptance": false, "customer_access_provider": "legacy", "payment_method_layout": "automatic", "save_payment_method_opt_in_behavior": "automatic"]), (key: "is_decoupled", value: false), (key: "integration_shape", value: "paymentsheet"), (key: "apple_pay_enabled", value: 1), (key: "active_link_session", value: false)]

[Stripe SDK]: GET "/v1/elements/sessions" 200 req_sUFy6JkEThKr1M
LOG ANALYTICS: mc_load_failed - [(key: "pay_var", value: "paymentsheet"), (key: "ocr_type", value: "none"), (key: "mpe_config", value: ["customer": true, "allows_delayed_payment_methods": true, "customer_access_provider": "legacy", "style": 0, "default_billing_details": false, "save_payment_method_opt_in_behavior": "automatic", "appearance": ["usage": false, "font": false, "shadow": false, "colors": false, "corner_radius": false, "border_width": false, "embedded_payment_element": ["row_style": false, "row": false], "primary_button": false], "card_brand_acceptance": false, "return_url": true, "apple_pay_config": false, "billing_details_collection_configuration": ["name": "automatic", "attach_defaults": false, "address": "automatic", "email": "automatic", "phone": "automatic"], "payment_method_layout": "automatic"]), (key: "is_decoupled", value: false), (key: "integration_shape", value: "paymentsheet"), (key: "error_type", value: "invalid_request_error"), (key: "error_code", value: ""), (key: "duration", value

Payment failed: Error Domain=com.stripe.lib Code=51 "There was an unexpected error -- try again in a few seconds" UserInfo={com.stripe.lib:hintKey=Invalid customer ephemeral key secret. You can find more information at https://stripe.com/docs/payments/accept-a-payment?platform=ios#add-server-endpoint, com.stripe.lib:ErrorMessageKey=Invalid API Key provided: ephkey_1*******************V5gn, com.stripe.lib:StripeErrorCodeKey=, NSLocalizedDescription=There was an unexpected error -- try again in a few seconds, com.stripe.lib:StripeErrorTypeKey=invalid_request_error}

Code to reproduce

Try to open Payment sheet with below syntax :-

// MARK: Start the checkout process
paymentSheet?.present(from: self) { paymentResult in
// MARK: Handle the payment result
switch paymentResult {
case .completed:
print("Your order is confirmed")
case .canceled:
print("Canceled!")
case .failed(let error):
print("Payment failed: (error)")
}
}

iOS version

iOS 17.2

Installation method

CocoaPods

SDK version

24.6.0

Other information

when I remove the syntax
configuration.customer = .init(id: customerId, ephemeralKeySecret: customerEphemeralKeySecret)

then payment sheet appears perfectly

@yuki-stripe yuki-stripe added triaged Issue has been reviewed by Stripe and is being tracked internally and removed P1 labels Mar 4, 2025
@yuki-stripe
Copy link
Collaborator

@deepak2503 It looks like you're passing in the ephemeral key id, not its secret.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug triaged Issue has been reviewed by Stripe and is being tracked internally
Projects
None yet
Development

No branches or pull requests

2 participants