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 Crashes on Cancel or after payment #176

Open
CastanetLaurentiu opened this issue Oct 11, 2024 · 0 comments
Open

App Crashes on Cancel or after payment #176

CastanetLaurentiu opened this issue Oct 11, 2024 · 0 comments

Comments

@CastanetLaurentiu
Copy link

CastanetLaurentiu commented Oct 11, 2024

I am trying to implement the braintree flow in my app and it seems to work until I click "Cancel and return to.." or I go through the entire payment process and crashes when it has to return to the app.

This is the error I get

E/AndroidRuntime(11837): FATAL EXCEPTION: main
E/AndroidRuntime(11837): Process: net.castanet.app, PID: 11837
E/AndroidRuntime(11837): java.lang.RuntimeException: Unable to start activity ComponentInfo{net.castanet.app/com.braintreepayments.api.DropInActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.os.Bundle.setClassLoader(java.lang.ClassLoader)' on a null object reference
E/AndroidRuntime(11837): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3645)
E/AndroidRuntime(11837): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3782)
E/AndroidRuntime(11837): at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)
E/AndroidRuntime(11837): at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
E/AndroidRuntime(11837): at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
E/AndroidRuntime(11837): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2307)
E/AndroidRuntime(11837): at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(11837): at android.os.Looper.loopOnce(Looper.java:201)
E/AndroidRuntime(11837): at android.os.Looper.loop(Looper.java:288)
E/AndroidRuntime(11837): at android.app.ActivityThread.main(ActivityThread.java:7872)
E/AndroidRuntime(11837): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(11837): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/AndroidRuntime(11837): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
E/AndroidRuntime(11837): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.os.Bundle.setClassLoader(java.lang.ClassLoader)' on a null object reference
E/AndroidRuntime(11837): at com.braintreepayments.api.DropInActivity.getDropInRequest(DropInActivity.java:124)
E/AndroidRuntime(11837): at com.braintreepayments.api.DropInActivity.onCreate(DropInActivity.java:78)
E/AndroidRuntime(11837): at android.app.Activity.performCreate(Activity.java:8305)
E/AndroidRuntime(11837): at android.app.Activity.performCreate(Activity.java:8284)
E/AndroidRuntime(11837): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1417)
E/AndroidRuntime(11837): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3626)
E/AndroidRuntime(11837): ... 12 more
I/Process (11837): Sending signal. PID: 11837 SIG: 9
Lost connection to device.

Exited.

This is my android manifest

    <activity android:name="com.braintreepayments.api.DropInActivity"
android:launchMode="singleTask" android:exported="true" tools:node="merge">
<intent-filter tools:node="removeAll" />
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="${applicationId}.braintree" />
        </intent-filter>
    </activity>
    <activity android:name="com.braintreepayments.api.ThreeDSecureActivity" tools:replace="android:theme"  android:theme="@style/Theme.AppCompat.Light"  android:exported="true">
    </activity>


    <!-- Don't delete the meta-data below.
         This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
    <meta-data
        android:name="flutterEmbedding"
        android:value="2" />
</application>

<queries>
    <intent>
        <action android:name="android.intent.action.PROCESS_TEXT"/>
        <data android:mimeType="text/plain"/>
    </intent>
</queries>

And this is the function for triggering the payment process

void startPayPalPayment(price, message, token) async {
final request = BraintreeDropInRequest(
clientToken: token,
collectDeviceData: true,
paypalRequest: BraintreePayPalRequest(
amount: price,
displayName: 'Castanet',
),
);
BraintreeDropInResult? result = await BraintreeDropIn.start(request);
if (result != null) {
print('Nonce: ${result.paymentMethodNonce.nonce}');
} else {
print('Selection was canceled.');
}
}

Any help is much appreciated.

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

1 participant