stripe / stripe-terminal-android

Stripe Terminal Android SDK
https://stripe.dev/stripe-terminal-android/
Other
93 stars 45 forks source link

Bluetooth unexpectedly disconnected during operation #382

Closed VishnuSivadasVS closed 1 year ago

VishnuSivadasVS commented 1 year ago

I will explain the situation first, We have 2 Stripe M2 readers (Lets call them 1st and 2nd). The app worked perfectly fine with the 1st reader device. When we tried the same app with the 2nd device its showing error.

Error message: Bluetooth unexpectedly disconnected during operation

The reader device is getting discovered, but not connecting through Bluetooth. All the SDK, Android, Java etc are latest version. We tried everything same issue with the 2nd reader device.

Code to reproduce

implementation("com.stripe:stripeterminal:2.23.1")

public void connectBlueTooth(Reader reader) {
        append(textView, "Connecting device through Bluetooth - Start");
        ConnectionConfiguration.BluetoothConnectionConfiguration connectionConfig =
                new ConnectionConfiguration.BluetoothConnectionConfiguration(
                        "location_id_here"
                );
        Terminal.getInstance().connectBluetoothReader(reader, connectionConfig, new BluetoothReaderListener() {
            @Override
            public void onRequestReaderDisplayMessage(@NonNull ReaderDisplayMessage message) {
                toast(message.toString());
            }

            @Override
            public void onReportReaderSoftwareUpdateProgress(float progress) {
                BluetoothReaderListener.super.onReportReaderSoftwareUpdateProgress(progress);
            }

            @Override
            public void onRequestReaderInput(@NonNull ReaderInputOptions options) {
                toast(options.toString());
            }

            @Override
            public void onReportReaderEvent(@NonNull ReaderEvent event) {
                append(textView, "\n" + event.name() + "\n");
                toast(event.name());
            }

            @Override
            public void onStartInstallingUpdate(@NonNull ReaderSoftwareUpdate update, @Nullable Cancelable cancelable) {
                toast("Updating Reader Software");
                append(textView, "Updating Reader Software");
                BluetoothReaderListener.super.onStartInstallingUpdate(update, cancelable);
            }

            @Override
            public void onFinishInstallingUpdate(@Nullable ReaderSoftwareUpdate update, @Nullable TerminalException e) {
                toast("Updating Reader Software Completed");
                append(textView, "Updating Reader Software Completed");
                BluetoothReaderListener.super.onFinishInstallingUpdate(update, e);
            }
        }, new ReaderCallback() {

            @Override
            public void onSuccess(@NonNull Reader reader) {
                enableButtonPay(buttonObject);
                append(textView, "\nSuccessfully connected to reader - " + reader.getSerialNumber());
                toast("Successfully connected to reader");
            }

            @Override
            public void onFailure(@NonNull TerminalException e) {
                append(textView, e.getErrorMessage());
                e.printStackTrace();
            }
        });
    }

Complete Gradle File

plugins {
    id("com.android.application")
}

android {
    namespace = "com.example.stripeterminal"
    compileSdk = 33

    defaultConfig {
        applicationId = "com.example.stripeterminal"
        minSdk = 21
        targetSdk = 33
        versionCode = 1
        versionName = "1.0"

        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            isMinifyEnabled = false
            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"),
                "proguard-rules.pro"
            )
        }
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation("com.google.android.gms:play-services-location:21.0.1")
    implementation("com.android.volley:volley:1.2.1")
    implementation("com.stripe:stripeterminal:2.23.1")
    implementation("androidx.appcompat:appcompat:1.6.1")
    implementation("com.google.android.material:material:1.9.0")
    implementation("androidx.constraintlayout:constraintlayout:2.1.4")
    testImplementation("junit:junit:4.13.2")
    androidTestImplementation("androidx.test.ext:junit:1.1.5")
    androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
}
bperez-stripe commented 1 year ago

It looks like this issue is related to integration support. The fastest way to get support for your integration is to reach out directly to our support team: https://support.stripe.com/contact. Gitlab issues should only be submitted for bug reports or feature requests.