Skip to content

Commit

Permalink
4.0.0 release (#521)
Browse files Browse the repository at this point in the history
* 4.0.0 release

* Update CHANGELOG.md

* add v3 docs

* Update README.md
  • Loading branch information
sjl-stripe authored Oct 31, 2024
1 parent 43798b7 commit be819e2
Show file tree
Hide file tree
Showing 3,303 changed files with 196,043 additions and 16,904 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
98 changes: 88 additions & 10 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Example/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
6 changes: 2 additions & 4 deletions Example/javaapp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ android {

lint {
enable += "Interoperability"
disable += "UnusedResources"
disable += "UnknownNullness"
disable += "MergeRootFrame"
}

Expand All @@ -38,7 +36,7 @@ android {

val androidxLifecycleVersion = "2.6.2"
val retrofitVersion = "2.11.0"
val stripeTerminalVersion = "3.10.0"
val stripeTerminalVersion = "4.0.0"

dependencies {
implementation("com.google.android.material:material:1.11.0")
Expand All @@ -61,7 +59,7 @@ dependencies {
implementation("com.squareup.retrofit2:converter-gson:$retrofitVersion")

// Stripe Terminal library
implementation("com.stripe:stripeterminal-localmobile:$stripeTerminalVersion")
implementation("com.stripe:stripeterminal-taptopay:$stripeTerminalVersion")
implementation("com.stripe:stripeterminal-core:$stripeTerminalVersion")

// Leak canary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import androidx.fragment.app.FragmentTransaction;

import com.stripe.example.javaapp.fragment.ConnectedReaderFragment;
import com.stripe.example.javaapp.fragment.offline.OfflinePaymentsLogFragment;
import com.stripe.example.javaapp.fragment.PaymentFragment;
import com.stripe.example.javaapp.fragment.TerminalFragment;
import com.stripe.example.javaapp.fragment.UpdateReaderFragment;
Expand All @@ -26,16 +25,20 @@
import com.stripe.example.javaapp.fragment.location.LocationCreateFragment;
import com.stripe.example.javaapp.fragment.location.LocationSelectionController;
import com.stripe.example.javaapp.fragment.location.LocationSelectionFragment;
import com.stripe.example.javaapp.fragment.offline.OfflinePaymentsLogFragment;
import com.stripe.example.javaapp.model.OfflineBehaviorSelection;
import com.stripe.example.javaapp.network.TokenProvider;
import com.stripe.stripeterminal.Terminal;
import com.stripe.stripeterminal.external.OfflineMode;
import com.stripe.stripeterminal.external.callable.Cancelable;
import com.stripe.stripeterminal.external.callable.ReaderListener;
import com.stripe.stripeterminal.external.callable.InternetReaderListener;
import com.stripe.stripeterminal.external.callable.MobileReaderListener;
import com.stripe.stripeterminal.external.callable.TapToPayReaderListener;
import com.stripe.stripeterminal.external.models.BatteryStatus;
import com.stripe.stripeterminal.external.models.ConnectionStatus;
import com.stripe.stripeterminal.external.models.DisconnectReason;
import com.stripe.stripeterminal.external.models.Location;
import com.stripe.stripeterminal.external.models.Reader;
import com.stripe.stripeterminal.external.models.ReaderDisplayMessage;
import com.stripe.stripeterminal.external.models.ReaderEvent;
import com.stripe.stripeterminal.external.models.ReaderInputOptions;
Expand All @@ -50,7 +53,9 @@
@OptIn(markerClass = OfflineMode.class)
public class MainActivity extends AppCompatActivity implements
NavigationListener,
ReaderListener,
MobileReaderListener,
TapToPayReaderListener,
InternetReaderListener,
LocationSelectionController
{

Expand Down Expand Up @@ -215,8 +220,8 @@ public void onStartInstallingUpdate(@NotNull ReaderSoftwareUpdate update, @Nulla
runOnUiThread(() -> {
List<Fragment> fragments = getSupportFragmentManager().getFragments();
Fragment currentFragment = fragments.get(fragments.size() - 1);
if (currentFragment instanceof ReaderListener) {
((ReaderListener) currentFragment).onStartInstallingUpdate(update, cancelable);
if (currentFragment instanceof MobileReaderListener) {
((MobileReaderListener) currentFragment).onStartInstallingUpdate(update, cancelable);
}
});
}
Expand All @@ -226,8 +231,8 @@ public void onReportReaderSoftwareUpdateProgress(float progress) {
runOnUiThread(() -> {
List<Fragment> fragments = getSupportFragmentManager().getFragments();
Fragment currentFragment = fragments.get(fragments.size() - 1);
if (currentFragment instanceof ReaderListener) {
((ReaderListener) currentFragment).onReportReaderSoftwareUpdateProgress(progress);
if (currentFragment instanceof MobileReaderListener) {
((MobileReaderListener) currentFragment).onReportReaderSoftwareUpdateProgress(progress);
}
});
}
Expand All @@ -237,8 +242,8 @@ public void onFinishInstallingUpdate(@Nullable ReaderSoftwareUpdate update, @Nul
runOnUiThread(() -> {
List<Fragment> fragments = getSupportFragmentManager().getFragments();
Fragment currentFragment = fragments.get(fragments.size() - 1);
if (currentFragment instanceof ReaderListener) {
((ReaderListener) currentFragment).onFinishInstallingUpdate(update, e);
if (currentFragment instanceof MobileReaderListener) {
((MobileReaderListener) currentFragment).onFinishInstallingUpdate(update, e);
}
});
}
Expand All @@ -248,8 +253,8 @@ public void onRequestReaderInput(@NotNull ReaderInputOptions options) {
runOnUiThread(() -> {
List<Fragment> fragments = getSupportFragmentManager().getFragments();
Fragment currentFragment = fragments.get(fragments.size() - 1);
if (currentFragment instanceof ReaderListener) {
((ReaderListener) currentFragment).onRequestReaderInput(options);
if (currentFragment instanceof MobileReaderListener) {
((MobileReaderListener) currentFragment).onRequestReaderInput(options);
}
});
}
Expand All @@ -259,8 +264,8 @@ public void onRequestReaderDisplayMessage(@NotNull ReaderDisplayMessage message)
runOnUiThread(() -> {
List<Fragment> fragments = getSupportFragmentManager().getFragments();
Fragment currentFragment = fragments.get(fragments.size() - 1);
if (currentFragment instanceof ReaderListener) {
((ReaderListener) currentFragment).onRequestReaderDisplayMessage(message);
if (currentFragment instanceof MobileReaderListener) {
((MobileReaderListener) currentFragment).onRequestReaderDisplayMessage(message);
}
});
}
Expand All @@ -270,8 +275,8 @@ public void onReportAvailableUpdate(@NotNull ReaderSoftwareUpdate update) {
runOnUiThread(() -> {
List<Fragment> fragments = getSupportFragmentManager().getFragments();
Fragment currentFragment = fragments.get(fragments.size() - 1);
if (currentFragment instanceof ReaderListener) {
((ReaderListener) currentFragment).onReportAvailableUpdate(update);
if (currentFragment instanceof MobileReaderListener) {
((MobileReaderListener) currentFragment).onReportAvailableUpdate(update);
}
});
}
Expand All @@ -281,8 +286,8 @@ public void onReportReaderEvent(@NotNull ReaderEvent event) {
runOnUiThread(() -> {
List<Fragment> fragments = getSupportFragmentManager().getFragments();
Fragment currentFragment = fragments.get(fragments.size() - 1);
if (currentFragment instanceof ReaderListener) {
((ReaderListener) currentFragment).onReportReaderEvent(event);
if (currentFragment instanceof MobileReaderListener) {
((MobileReaderListener) currentFragment).onReportReaderEvent(event);
}
});
}
Expand All @@ -292,8 +297,8 @@ public void onReportLowBatteryWarning() {
runOnUiThread(() -> {
List<Fragment> fragments = getSupportFragmentManager().getFragments();
Fragment currentFragment = fragments.get(fragments.size() - 1);
if (currentFragment instanceof ReaderListener) {
((ReaderListener) currentFragment).onReportLowBatteryWarning();
if (currentFragment instanceof MobileReaderListener) {
((MobileReaderListener) currentFragment).onReportLowBatteryWarning();
}
});
}
Expand All @@ -303,8 +308,8 @@ public void onBatteryLevelUpdate(float batteryLevel, @NonNull BatteryStatus batt
runOnUiThread(() -> {
List<Fragment> fragments = getSupportFragmentManager().getFragments();
Fragment currentFragment = fragments.get(fragments.size() - 1);
if (currentFragment instanceof ReaderListener) {
((ReaderListener) currentFragment).onBatteryLevelUpdate(batteryLevel, batteryStatus, isCharging);
if (currentFragment instanceof MobileReaderListener) {
((MobileReaderListener) currentFragment).onBatteryLevelUpdate(batteryLevel, batteryStatus, isCharging);
}
});
}
Expand All @@ -314,8 +319,8 @@ public void onDisconnect(@NonNull DisconnectReason reason) {
runOnUiThread(() -> {
List<Fragment> fragments = getSupportFragmentManager().getFragments();
Fragment currentFragment = fragments.get(fragments.size() - 1);
if (currentFragment instanceof ReaderListener) {
((ReaderListener) currentFragment).onDisconnect(reason);
if (currentFragment instanceof MobileReaderListener) {
((MobileReaderListener) currentFragment).onDisconnect(reason);
}
});
}
Expand All @@ -340,6 +345,19 @@ public void onLocationCleared() {
}
}

/**
* ReaderReconnectionListener implementation.
*/
@Override
public void onReaderReconnectSucceeded(@NonNull Reader reader) {
Log.d("MainActivity", "Reader " + reader.getId() + " reconnected successfully!");
}

@Override
public void onReaderReconnectFailed(@NonNull Reader reader) {
Log.d("MainActivity", "Reconnection to reader " + reader.getId() + " failed!");
}

/**
* Initialize the [Terminal] and go to the [TerminalFragment]
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.stripe.stripeterminal.external.callable.TerminalListener;
import com.stripe.stripeterminal.external.models.ConnectionStatus;
import com.stripe.stripeterminal.external.models.PaymentStatus;
import com.stripe.stripeterminal.external.models.Reader;

import org.jetbrains.annotations.NotNull;

Expand All @@ -22,13 +21,6 @@ private TerminalEventListener() {

}

@Override
public void onUnexpectedReaderDisconnect(@NotNull Reader reader) {
Log.i("UnexpectedDisconnect", reader.getSerialNumber() != null ?
reader.getSerialNumber() : "reader's serialNumber is null!");
this.announce(listener -> listener.onUnexpectedReaderDisconnect(reader));
}

@Override
public void onConnectionStatusChange(@NotNull ConnectionStatus status) {
Log.i("ConnectionStatusChange", status.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) {

discoveryMethods.add(DiscoveryMethod.BLUETOOTH_SCAN);
discoveryMethods.add(DiscoveryMethod.INTERNET);
discoveryMethods.add(DiscoveryMethod.LOCAL);
discoveryMethods.add(DiscoveryMethod.TAP_TO_PAY);
discoveryMethods.add(DiscoveryMethod.USB);

if (getArguments() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import com.stripe.stripeterminal.Terminal;
import com.stripe.stripeterminal.external.callable.Callback;
import com.stripe.stripeterminal.external.callable.Cancelable;
import com.stripe.stripeterminal.external.callable.ReaderListener;
import com.stripe.stripeterminal.external.callable.MobileReaderListener;
import com.stripe.stripeterminal.external.models.BatteryStatus;
import com.stripe.stripeterminal.external.models.DisconnectReason;
import com.stripe.stripeterminal.external.models.ReaderDisplayMessage;
Expand All @@ -38,7 +38,7 @@
* The `UpdateReaderFragment` allows the user to check the current version of the [Reader] software,
* as well as update it when necessary.
*/
public class UpdateReaderFragment extends Fragment implements ReaderListener {
public class UpdateReaderFragment extends Fragment implements MobileReaderListener {

@NotNull public static final String TAG = "com.stripe.example.fragment.UpdateReaderFragment";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import com.stripe.stripeterminal.external.callable.Callback;
import com.stripe.stripeterminal.external.callable.Cancelable;
import com.stripe.stripeterminal.external.callable.DiscoveryListener;
import com.stripe.stripeterminal.external.callable.ReaderListener;
import com.stripe.stripeterminal.external.callable.MobileReaderListener;
import com.stripe.stripeterminal.external.models.BatteryStatus;
import com.stripe.stripeterminal.external.models.DisconnectReason;
import com.stripe.stripeterminal.external.models.DiscoveryConfiguration;
Expand All @@ -53,7 +53,7 @@
* The `DiscoveryFragment` shows the list of recognized readers and allows the user to
* select one to connect to.
*/
public class DiscoveryFragment extends Fragment implements DiscoveryListener, ReaderListener, LocationSelectionController {
public class DiscoveryFragment extends Fragment implements DiscoveryListener, MobileReaderListener, LocationSelectionController {

public static final String TAG = "com.stripe.example.fragment.discovery.DiscoveryFragment";
private static final String SIMULATED_KEY = "simulated";
Expand Down Expand Up @@ -233,9 +233,9 @@ public void onFailure(@NotNull TerminalException e) {
} else if (discoveryMethod == DiscoveryMethod.USB) {
config = new DiscoveryConfiguration.UsbDiscoveryConfiguration(0, isSimulated);
} else if (discoveryMethod == DiscoveryMethod.INTERNET) {
config = new DiscoveryConfiguration.InternetDiscoveryConfiguration(null, isSimulated);
} else if (discoveryMethod == DiscoveryMethod.LOCAL) {
config = new DiscoveryConfiguration.LocalMobileDiscoveryConfiguration(isSimulated);
config = new DiscoveryConfiguration.InternetDiscoveryConfiguration(0, null, isSimulated);
} else if (discoveryMethod == DiscoveryMethod.TAP_TO_PAY) {
config = new DiscoveryConfiguration.TapToPayDiscoveryConfiguration(isSimulated);
} else {
throw new IllegalArgumentException("Unknown discovery method: " + discoveryMethod);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
public enum DiscoveryMethod {
BLUETOOTH_SCAN,
INTERNET,
LOCAL,
TAP_TO_PAY,
USB,
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.jetbrains.annotations.NotNull;

import java.lang.ref.WeakReference;
import kotlin.OptIn;

public class ReaderClickListener {
@NotNull private WeakReference<MainActivity> activityRef;
Expand Down Expand Up @@ -87,25 +86,43 @@ public void onFailure(@NotNull TerminalException e) {

switch (viewModel.discoveryMethod) {
case BLUETOOTH_SCAN:
Terminal.getInstance().connectBluetoothReader(reader, new BluetoothConnectionConfiguration(connectLocationId),
activityRef.get(), readerCallback);
Terminal.getInstance().connectReader(
reader,
new BluetoothConnectionConfiguration(
connectLocationId,
activityRef.get()
),
readerCallback
);
return;
case INTERNET:
Terminal.getInstance().connectInternetReader(
Terminal.getInstance().connectReader(
reader,
new ConnectionConfiguration.InternetConnectionConfiguration(),
new ConnectionConfiguration.InternetConnectionConfiguration(
false,
activityRef.get()
),
readerCallback
);
return;
case LOCAL:
Terminal.getInstance().connectLocalMobileReader(reader,
new ConnectionConfiguration.LocalMobileConnectionConfiguration(connectLocationId, true),
case TAP_TO_PAY:
Terminal.getInstance().connectReader(reader,
new ConnectionConfiguration.TapToPayConnectionConfiguration(
connectLocationId,
true,
activityRef.get()
),
readerCallback
);
return;
case USB:
Terminal.getInstance().connectUsbReader(reader, new ConnectionConfiguration.UsbConnectionConfiguration(connectLocationId),
activityRef.get(), readerCallback);
Terminal.getInstance().connectReader(reader,
new ConnectionConfiguration.UsbConnectionConfiguration(
connectLocationId,
activityRef.get()
),
readerCallback
);
return;
default:
Log.w(getClass().getSimpleName(), "Trying to connect unsupported reader");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@
import com.stripe.stripeterminal.external.callable.Callback;
import com.stripe.stripeterminal.external.callable.Cancelable;
import com.stripe.stripeterminal.external.callable.PaymentIntentCallback;
import com.stripe.stripeterminal.external.callable.ReaderListener;
import com.stripe.stripeterminal.external.callable.MobileReaderListener;
import com.stripe.stripeterminal.external.callable.SetupIntentCallback;
import com.stripe.stripeterminal.external.models.AllowRedisplay;
import com.stripe.stripeterminal.external.models.BatteryStatus;
import com.stripe.stripeterminal.external.models.CardPresentParameters;
import com.stripe.stripeterminal.external.models.CollectConfiguration;
Expand Down Expand Up @@ -63,7 +64,7 @@
/**
* The `EventFragment` displays events as they happen during a payment flow
*/
public class EventFragment extends Fragment implements ReaderListener {
public class EventFragment extends Fragment implements MobileReaderListener {

@NotNull
public static final String TAG = "com.stripe.example.fragment.event.EventFragment";
Expand Down Expand Up @@ -217,7 +218,7 @@ public void onSuccess(@NotNull SetupIntent intent) {
setupIntent = intent;
addEvent("Created SetupIntent", "terminal.createSetupIntent");
viewModel.collectTask = Terminal.getInstance().collectSetupIntentPaymentMethod(
setupIntent, true, collectSetupIntentPaymentMethodCallback);
setupIntent, AllowRedisplay.ALWAYS, collectSetupIntentPaymentMethodCallback);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ private String getCheckForUpdateDescriptionText() {
!hasStartedInstallingUpdate.getValue() && readerSoftwareUpdate.getValue() != null) {
return resources.getString(R.string.install_explanation,
readerSoftwareUpdate.getValue().getVersion(),
readerSoftwareUpdate.getValue().getTimeEstimate().getDescription());
readerSoftwareUpdate.getValue().getDurationEstimate().getDescription());
} else if (hasStartedInstallingUpdate.getValue()) {
return hasFinishedInstallingUpdate.getValue() ? resources.getString(R.string.update_complete) :
resources.getString(R.string.update_progress, (progress.getValue() != null ? progress.getValue() : 0F) * 100);
Expand Down
Loading

0 comments on commit be819e2

Please sign in to comment.