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

App crash when /create-intent request fails during apple pay #1748

Open
bartoszboruta opened this issue Oct 9, 2024 · 1 comment
Open

App crash when /create-intent request fails during apple pay #1748

bartoszboruta opened this issue Oct 9, 2024 · 1 comment

Comments

@bartoszboruta
Copy link

bartoszboruta commented Oct 9, 2024

Describe the bug
When you pay with applepay and any kind of error is returned from /create-intent the app is being crashed.
Docs with the flow we follow: https://docs.stripe.com/payments/accept-a-payment-deferred?platform=react-native

To Reproduce
Steps to reproduce the behavior:
return error from the backend /create-intent request during applepay from @stripe/stripe-react-native presentPaymentSheet method

Expected behavior
Nn error is displayed instead of the app crashing

Screenshots

✅ /create-intent returns client_secret

intent.ok.mp4

🔴 /create-intent throws an error - card is working well, apple pay - app crashes

intent.fails.mp4

Demo repository with app & server code
just provide your sandbox keys in server, run the server and build the app locally
https://github.com/bartoszboruta/stripern

Smartphone (please complete the following information):

  • Device: iPhone 15 - any kind of iphones
  • OS: 17

Additional context

Thread 9 Crashed:
0   libsystem_kernel.dylib        	       0x1113353b0 0x11132c000 + 37808
1   libsystem_c.dylib             	       0x10fac75c0 0x10fa54000 + 472512
2   libswiftCore.dylib            	       0x10f12f0cc 0x10ee5c000 + 2961612
3   libswiftCore.dylib            	       0x10f12f0e8 0x10ee5c000 + 2961640
4   libswiftCore.dylib            	       0x10f179c50 0x10ee5c000 + 3267664
5   CoreFoundation                	       0x10d5b9288 0x10d488000 + 1249928
6   CoreFoundation                	       0x10d5bb5ac 0x10d488000 + 1258924
7   PassKitCore                   	       0x1328586dc 0x1323cc000 + 4769500
8   PassKitCore                   	       0x132858344 0x1323cc000 + 4768580
9   stripern                      	       0x10549c56c @nonobjc PKPaymentAuthorizationResult.init(status:errors:) + 152
10  stripern                      	       0x105494bf0 PKPaymentAuthorizationResult.__allocating_init(status:errors:) + 52
11  stripern                      	       0x105494894 closure #1 in STPApplePayContext.paymentAuthorizationController(_:didAuthorizePayment:handler:) + 536 (STPApplePayContext.swift:380)
12  stripern                      	       0x105496618 closure #1 in STPApplePayContext._completePayment(with:completion:) + 508 (STPApplePayContext.swift:517)
13  stripern                      	       0x105497d40 closure #1 in closure #2 in STPApplePayContext._completePayment(with:completion:) + 1680 (STPApplePayContext.swift:559)
14  stripern                      	       0x1054a04a0 partial apply for closure #1 in closure #2 in STPApplePayContext._completePayment(with:completion:) + 132
15  stripern                      	       0x105a5e740 closure #1 in ApplePayContextClosureDelegate.applePayContext(_:didCreatePaymentMethod:paymentInformation:completion:) + 476 (STPApplePayContext+PaymentSheet.swift:67)
16  stripern                      	       0x105f14344 StripeSdk.intentCreationCallback(result:resolver:rejecter:) + 2128 (StripeSdk.swift:152)
17  stripern                      	       0x105f14660 @objc StripeSdk.intentCreationCallback(result:resolver:rejecter:) + 204
18  CoreFoundation                	       0x10d5bb760 0x10d488000 + 1259360
19  CoreFoundation                	       0x10d5b8ac4 0x10d488000 + 1247940
20  CoreFoundation                	       0x10d5b8d5c 0x10d488000 + 1248604
21  stripern                      	       0x104c2a758 -[RCTModuleMethod invokeWithBridge:module:arguments:] + 1796 (RCTModuleMethod.mm:584)
22  stripern                      	       0x104c2e7e4 facebook::react::invokeInner(RCTBridge*, RCTModuleData*, unsigned int, folly::dynamic const&, int, (anonymous namespace)::SchedulingContext) + 1688 (RCTNativeModule.mm:196)
23  stripern                      	       0x104c2df80 facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int)::$_0::operator()() const + 128 (RCTNativeModule.mm:113)
24  stripern                      	       0x104c2def4 invocation function for block in facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int) + 28 (RCTNativeModule.mm:104)
25  libdispatch.dylib             	       0x10e7be104 0x10e7bc000 + 8452
26  libdispatch.dylib             	       0x10e7bf978 0x10e7bc000 + 14712
27  libdispatch.dylib             	       0x10e7c7b10 0x10e7bc000 + 47888
28  libdispatch.dylib             	       0x10e7c8688 0x10e7bc000 + 50824
29  libdispatch.dylib             	       0x10e7d3a84 0x10e7bc000 + 96900
30  libdispatch.dylib             	       0x10e7d30d0 0x10e7bc000 + 94416
31  libsystem_pthread.dylib       	       0x11ab1b814 0x11ab18000 + 14356
32  libsystem_pthread.dylib       	       0x11ab1a5d4 0x11ab18000 + 9684
@FerdinandvHagen
Copy link

We are experiencing the same issue.
Passing any error to the intentCreationCallback in the deferred payment case when using Apple Pay will lead to a crash of the app. Using a credit card will work as expected.

To replicate this is a minimal confirmHandler for initPaymentSheet:

const confirmHandler = async (
  paymentMethod: Result,
  shouldSavePaymentMethod: boolean,
  intentCreationCallback: (result: PaymentSheet.IntentCreationCallbackParams) => void,
) => {
  const error = {
    code: PaymentSheetError.Failed,
    message: "There was an unexpected error -- try again in a few seconds",
    localizedMessage: "There was an unexpected error -- try again in a few seconds",
  } as StripeError<PaymentSheetError.Failed>;
  
  callback({ error });
};
Screen.Recording.2024-12-23.at.09.39.56.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants