Skip to content

NullPointerException when canceling payment session: RNGosellSdkReactNativeModule is null in sessionCancelled callback #64

@HumedMohammed

Description

@HumedMohammed

When starting a payment session using RNGoSell.goSellSDK.startPayment and then canceling it (e.g., by pressing the back button in the Android payment activity), the app crashes with a NullPointerException. The error occurs because RNGosellSdkReactNativeModule (the React Native bridge module) is null when the native Android code attempts to invoke the onFailure callback during sessionCancelled.

This prevents proper handling of cancellation events and leads to app crashes instead of graceful failure callbacks.

Steps to Reproduce:

  1. Initialize the Tap SDK with valid credentials using RNGoSell.goSellSDK.setInit(appCredentials).
  2. Call RNGoSell.goSellSDK.startPayment(config, 0, callback) with a valid configuration
  3. In the payment UI, Press Google pay press close button, then press cancel button or cancel the session.
  4. Observe the crash with the attached stack trace.

Expected Behavior:

  • The cancellation should trigger the provided callback (e.g., handleResult) with a "CANCELLED" status, without crashing the app.
  • The module should be properly initialized and available for callback invocations.

Actual Behavior:

  • App crashes with NullPointerException because RNGosellSdkReactNativeModule is null.
  • Stack trace points to GoSellSdKDelegate.sessionCancelled failing to call onFailure.

RNGoSell.goSellSDK.startPayment(
tapPaymentConfiguration({ amount }),
0,
handleResult
);

STACK TRACE:
java.lang.NullPointerException: Attempt to invoke virtual method 'void company.tap.goSellSDKExamplee.RNGosellSdkReactNativeModule.onFailure(java.util.Map)' on a null object reference
company.tap.goSellSDKExamplee.GoSellSdKDelegate.sessionCancelled(GoSellSdKDelegate.java:469)
company.tap.gosellapi.internal.activities.GoSellPaymentActivity.onBackPressed(GoSellPaymentActivity.java:275)
company.tap.gosellapi.internal.activities.GoSellPaymentActivity.lambda$setupHeader$1(GoSellPaymentActivity.java:290)
company.tap.gosellapi.internal.activities.GoSellPaymentActivity.$r8$lambda$rPtkCwK31TgO9GTXzhx3MwrlbZg(Unknown Source:0)
company.tap.gosellapi.internal.activities.GoSellPaymentActivity$$ExternalSyntheticLambda0.onClick(D8$$SyntheticClass:0)
android.view.View.performClick(View.java:8054)
android.view.View.performClickInternal(View.java:8031)
android.view.View.-$$Nest$mperformClickInternal(Unknown Source:0)
android.view.View$PerformClick.run(View.java:31472)
android.os.Handler.handleCallback(Handler.java:1001)
android.os.Handler.dispatchMessage(Handler.java:105)
android.os.Looper.loopOnce(Looper.java:268)
android.os.Looper.loop(Looper.java:384)
android.app.ActivityThread.main(ActivityThread.java:8997)
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:907)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions