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

PaymentSheet Crashing on Android since v0.11.0+ #980

Closed
glesperance opened this issue Jun 7, 2022 · 4 comments · Fixed by #1015
Closed

PaymentSheet Crashing on Android since v0.11.0+ #980

glesperance opened this issue Jun 7, 2022 · 4 comments · Fixed by #1015
Labels
bug Something isn't working

Comments

@glesperance
Copy link

Describe the bug
Since v0.11.0 (and above), calling presentPaymentSheet on Android (11) crashes the app with a did not call through to super.onCreate() fatal error.

To Reproduce
I have not had the time to isolate the error in a test-harness project. That being said, my use case simply involves the basic paymentsheet / react native boilerplate setup :

const MyComponent = function() {
  const { initPaymentSheet, presentPaymentSheet } = useStripe()

  const initializePaymentSheet = async () => {
    const { setupIntent, ephemeralKey, customer } = (await stripe.setupIntent()).data

    const { error } = await initPaymentSheet({
      customerId: customer,
      customerEphemeralKeySecret: ephemeralKey,
      setupIntentClientSecret: setupIntent,
      currencyCode: "USD",
      style: "alwaysLight",

      // for @stripe/stripe-react-native v0.11.0 and above
      appearance: {
        colors: {
          primary: color.primary,
        },
        primaryButton: {
          colors: { background: color.invertedBackground },
        },
      },
    })

    if (error) console.error(error)
    else askScreen.setIsStripeLoaded(true)
  }

  const openPaymentSheet = async () => {
    const { error } = await presentPaymentSheet()

    if (error) {
      if (error.code !== "Canceled") console.error(`Error code: ${error.code}`, error.message)
      return false
    }

    return true
  }

  useEffect(() => {
    initializePaymentSheet()
  }, [])

  /* ... */
}

When openPaymentSheet() is invoked by the press of a button, the android app crashes with the following error :

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.paltapio.app.android, PID: 23730
    android.util.SuperNotCalledException: Activity {com.paltapio.app.android/com.stripe.android.paymentsheet.PaymentSheetActivity} did not call through to super.onCreate()
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3812)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4011)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2325)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:246)
        at android.app.ActivityThread.main(ActivityThread.java:8633)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)

Expected behavior
Upon invocation of openPaymentSheet it is expected for the payment sheet to open.

Screenshots
n/a

Smartphone (please complete the following information):

  • Device: Samsung A32 5G
  • OS: Android
  • Version: 11

Additional context
This bug is not present on v0.10.0 but I was able to reproduce on v0.11.0 and v0.12.0 of the stripe-react-native package.
Reverting to v0.10.0 or anterior completely fixes the problem.

@charliecruzan-stripe
Copy link
Collaborator

It looks like this happens when you don't provide a merchantDisplayName to initPaymentSheet 🤔 Can you confirm that adding merchantDisplayName: "anything" results in the correct behavior?

@charliecruzan-stripe charliecruzan-stripe added the bug Something isn't working label Jun 8, 2022
@glesperance
Copy link
Author

@charliecruzan-stripe you are 100% correct. Adding merchantDisplayName: "anything" fixes the issue.

    const { error } = await initPaymentSheet({
      customerId: customer,
      customerEphemeralKeySecret: ephemeralKey,
      setupIntentClientSecret: setupIntent,
      currencyCode: "USD",
      style: "alwaysLight",

      // for @stripe/stripe-react-native v0.11.0 and above
+     merchantDisplayName: "anything",
      appearance: {
        colors: {
          primary: color.primary,
        },
        primaryButton: {
          colors: { background: color.invertedBackground },
        },
      },
    })

@charliecruzan-stripe
Copy link
Collaborator

It looks like there may have been a change to one of our underlying native dependencies, but I think beforehand, not providing the merchantDisplayName would have thrown an error (but not a crash). Are you not seeing the behavior on v0.10?

@glesperance
Copy link
Author

glesperance commented Jun 8, 2022

v0.10 is working w/o merchantDisplayName. Prior to our exchange, keeping the version to v10 was how I managed to keep the app from crashing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants