Skip to content

Commit

Permalink
Updates for 3.4.0 (#437)
Browse files Browse the repository at this point in the history
* Updates for 3.4.0
  • Loading branch information
ugochukwu-stripe authored Mar 5, 2024
1 parent adf9c6e commit 85ea447
Show file tree
Hide file tree
Showing 397 changed files with 4,849 additions and 5,179 deletions.
21 changes: 20 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@
This document details changes made to the SDK by version. The current status
of each release can be found in the [Support Lifecycle](SUPPORT.md).

## 3.4.0 - 2024-03-04

- New: for Tap to Pay on Android, Added `autoReconnectOnUnexpectedDisconnect` & `localMobileReaderReconnectionListener` to the [`LocalMobileConnectionConfiguration`](https://stripe.dev/stripe-terminal-android/external/com.stripe.stripeterminal.external.models/-connection-configuration/-local-mobile-connection-configuration/index.html). When enabled, the SDK will attempt to restore connection upon any unexpected disconnect to the local mobile reader. See [Stripe Docs](https://stripe.com/docs/terminal/payments/connect-reader?terminal-sdk-platform=android&reader-type=tap-to-pay#handling-disconnects) for details.
- Fix: Removed requirement for devices to support NFC at installation time. Fixes [issue 420](https://github.com/stripe/stripe-terminal-android/issues/420).
- Update: More descriptive `TerminalException` error messages for operations that fail due to network-related errors.
- Update: Charges created with simulated readers now have additional fields defined in [ReceiptDetails](https://stripe.dev/stripe-terminal-android/external/com.stripe.stripeterminal.external.models/-receipt-details/index.html):
- `ReceiptDetails.applicationPreferredName` varies based on the brand of the selected simulated card, e.g. "VISA Debit/Credit (Classic)"
- `ReceiptDetails.dedicatedFileName` varies based on card brand, e.g. "A0000000031010"
- `ReceiptDetails.terminalVerificationResults` is always "0000008000"
- Fix: Formatting on certain fields exposed in `OfflineCardPresentDetails` is now consistent with `CardPresentDetails`
- `brand` is now always lowercase
- `expYear` is a four-digit number
- Fix: Offline `PaymentIntent`'s `created` field is now in seconds
- Update: The [`Terminal.collectInputs`](https://stripe.com/docs/terminal/features/collect-inputs) method can now display optional toggles in each form.
- Fix: Fixes a bug where `PaymentIntent::id` was not `null` for `PaymentIntents` created while operating offline with a smart reader.
- Update: Allow `CollectConfiguration::updatePaymentIntent` to be `true` for offline enabled readers when the `PaymentIntent` was created with `CreateConfiguration::offlineBehavior` set to `REQUIRE_ONLINE`.
- Fix: Fixes a rare bug where Bluetooth/USB readers could get in to a state where they would no longer accept payments. Also forces a disconnect and throws [`READER_MISSING_ENCRYPTION_KEYS`](https://stripe.dev/stripe-terminal-android/external/com.stripe.stripeterminal.external.models/-terminal-exception/-terminal-error-code/-r-e-a-d-e-r_-m-i-s-s-i-n-g_-e-n-c-r-y-p-t-i-o-n_-k-e-y-s/index.html) when this error is encountered on attempt to collect payment method data. Reconnecting to the reader should re-install the keys.
- Fix: Resolves issue where SDK appears to be stuck when updating M2/Chipper readers from older configs. Fixes [issue 430](https://github.com/stripe/stripe-terminal-android/issues/430).

## 3.3.1 - 2024-02-14

### Core
Expand All @@ -27,7 +46,7 @@ of each release can be found in the [Support Lifecycle](SUPPORT.md).
- Update: Location services are no longer required to be enabled during [`Terminal.initTerminal`](https://stripe.dev/stripe-terminal-android/core/com.stripe.stripeterminal/-terminal/-companion/init-terminal.html). Location services will still need to be enabled on the device at the time of reader discovery and when collecting a PaymentIntent, SetupIntent, or Refund, otherwise a [`LOCATION_SERVICES_DISABLED`](https://stripe.dev/stripe-terminal-android/external/com.stripe.stripeterminal.external.models/-terminal-exception/-terminal-error-code/-l-o-c-a-t-i-o-n_-s-e-r-v-i-c-e-s_-d-i-s-a-b-l-e-d/index.html) exception will be thrown. Fixes [issue 401](https://github.com/stripe/stripe-terminal-android/issues/401).
- Update: Added a [`DisconnectReason`](https://stripe.dev/stripe-terminal-android/external/com.stripe.stripeterminal.external.models/-disconnect-reason/index.html) to the [`ReaderReconnectionListener.onReaderReconnectStarted`](https://stripe.dev/stripe-terminal-android/external/com.stripe.stripeterminal.external.callable/-reader-reconnection-listener/on-reader-reconnect-started.html) callback.
- Update: SDKs have been updated to depend on [Kotlin 1.9.10](https://github.com/JetBrains/kotlin/releases/tag/v1.9.10).
- Update: Attempting to connect or use a reader with a critically low battery will result in an automatic disconnection, and a [`READER_BATTERY_CRITICALLY_LOW`](https://stripe.dev/stripe-terminal-android/external/com.stripe.stripeterminal.external.models/-terminal-exception/-terminal-error-code/-r-e-a-d-e-r-_-b-a-t-t-e-r-y-_-c-r-i-t-i-c-a-l-l-y-_-l-o-w/index.html) exception will be thrown. Fixes [issue 343](https://github.com/stripe/stripe-terminal-android/issues/343).
- Update: Attempting to connect or use a reader with a critically low battery will result in an automatic disconnection, and a [`READER_BATTERY_CRITICALLY_LOW`](https://stripe.dev/stripe-terminal-android/external/com.stripe.stripeterminal.external.models/-terminal-exception/-terminal-error-code/-r-e-a-d-e-r_-b-a-t-t-e-r-y_-c-r-i-t-i-c-a-l-l-y_-l-o-w/index.html) exception will be thrown. Fixes [issue 343](https://github.com/stripe/stripe-terminal-android/issues/343).
- Fix: Allow acceptance of Discover cards stored in Apple Pay. Fixes [issue 316](https://github.com/stripe/stripe-terminal-android/issues/316).

### Handoff
Expand Down
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 @@
#Wed Jun 23 16:32:06 EDT 2021
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
13 changes: 6 additions & 7 deletions Example/javaapp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,27 @@ android {

ext {
androidx_lifecycle_version = "2.6.2"
okhttp_version = "4.11.0"
retrofit_version = "2.9.0"
stripeTerminalVersion = "3.3.1"
stripeTerminalVersion = "3.4.0"
}

dependencies {
implementation(fileTree(dir: "libs", include: ["*.jar"]))

implementation("com.google.android.material:material:1.9.0")
implementation("androidx.activity:activity:1.7.2")
implementation("com.google.android.material:material:1.11.0")
implementation("androidx.activity:activity:1.8.2")
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")

// Annotations
implementation("org.jetbrains:annotations:24.0.1")
implementation("org.jetbrains:annotations:24.1.0")

// ViewModel and LiveData
implementation("androidx.lifecycle:lifecycle-livedata:$androidx_lifecycle_version")
implementation("androidx.lifecycle:lifecycle-viewmodel:$androidx_lifecycle_version")

// OK HTTP
implementation("com.squareup.okhttp3:okhttp:$okhttp_version")
implementation("com.squareup.okhttp3:okhttp:4.12.0")

// Retrofit
implementation("com.squareup.retrofit2:retrofit:$retrofit_version")
Expand All @@ -68,5 +67,5 @@ dependencies {
implementation("com.stripe:stripeterminal:$stripeTerminalVersion")

// Leak canary
debugImplementation("com.squareup.leakcanary:leakcanary-android:2.12")
debugImplementation("com.squareup.leakcanary:leakcanary-android:2.13")
}
11 changes: 5 additions & 6 deletions Example/kotlinapp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,15 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KaptGenerateStubs).configureEac
ext {
androidx_lifecycle_version = "2.6.2"
kotlin_coroutines_version = "1.7.3"
okhttp_version = "4.11.0"
retrofit_version = "2.9.0"
stripeTerminalVersion = "3.3.1"
stripeTerminalVersion = "3.4.0"
}

dependencies {
implementation(fileTree(dir: "libs", include: ["*.jar"]))

implementation("com.google.android.material:material:1.9.0")
implementation("androidx.activity:activity-ktx:1.7.2")
implementation("com.google.android.material:material:1.11.0")
implementation("androidx.activity:activity-ktx:1.8.2")
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("androidx.core:core-ktx:1.12.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
Expand All @@ -74,7 +73,7 @@ dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutines_version")

// OK HTTP
implementation("com.squareup.okhttp3:okhttp:$okhttp_version")
implementation("com.squareup.okhttp3:okhttp:4.12.0")

// Retrofit
implementation("com.squareup.retrofit2:retrofit:$retrofit_version")
Expand All @@ -84,5 +83,5 @@ dependencies {
implementation("com.stripe:stripeterminal:$stripeTerminalVersion")

// Leak canary
debugImplementation("com.squareup.leakcanary:leakcanary-android:2.12")
debugImplementation("com.squareup.leakcanary:leakcanary-android:2.13")
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ class TerminalOnlineIndicator @JvmOverloads constructor(

init {
context.theme.obtainStyledAttributes(attrs, R.styleable.TerminalOnlineIndicator, defStyleAttr, defStyleRes).apply {
try { // Get User defined styling
try {
// Get User defined styling
onlineColor = getColor(R.styleable.TerminalOnlineIndicator_onlineColor, Color.GREEN)
offlineColor = getColor(R.styleable.TerminalOnlineIndicator_offlineColor, Color.RED)
unknownColor = getColor(R.styleable.TerminalOnlineIndicator_unknownColor, Color.GRAY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class ConnectedReaderFragment : Fragment() {
Terminal.getInstance().connectedReader?.let {
view.findViewById<TextView>(R.id.reader_description).text = getString(
R.string.reader_description,
it.deviceType, it.serialNumber
it.deviceType,
it.serialNumber,
)
// TODO: Set status as well
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ class EventFragment : Fragment(), ReaderListener {
this@EventFragment.paymentIntent = paymentIntent
addEvent("Created PaymentIntent", "terminal.createPaymentIntent")
viewModel.collectTask = Terminal.getInstance().collectPaymentMethod(
paymentIntent, collectPaymentMethodCallback, collectConfig
paymentIntent,
collectPaymentMethodCallback,
collectConfig
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,22 @@ sealed interface OfflineEvent {
val details: List<Pair<String, String>>
val timestamp: Date

abstract class ChangeEvent<T : Any?>(event: String, previous: T, new: T) :
OfflineEvent {
abstract class ChangeEvent<T : Any?>(
event: String,
previous: T,
new: T,
) : OfflineEvent {
final override val timestamp: Date = Date(System.currentTimeMillis())
override val summary: String = "$timestamp : $event Change from $previous to $new"
override val details: List<Pair<String, String>> = emptyList()
val changed = previous != new
}

data class ConnectivityChange(val previous: NetworkStatus, val new: NetworkStatus, val connectionType: ConnectionType) :
ChangeEvent<NetworkStatus>("Connectivity (${connectionType.type})", previous, new)
data class ConnectivityChange(
val previous: NetworkStatus,
val new: NetworkStatus,
val connectionType: ConnectionType,
) : ChangeEvent<NetworkStatus>("Connectivity (${connectionType.type})", previous, new)

class ForwardingEvent(
summary: String,
Expand Down Expand Up @@ -59,11 +65,15 @@ sealed interface OfflineEvent {
class CaptureEvent(summary: String, details: List<Pair<String, String>>) : OfflineEvent {
override val timestamp = Date(System.currentTimeMillis())
override val summary = "$timestamp : $summary"
override val details = details.apply { if (isNotEmpty()) { plus(TIME to timestamp.toString()) } }
override val details = details.apply {
if (isNotEmpty()) {
plus(TIME to timestamp.toString())
}
}

constructor(paymentIntent: PaymentIntent, error: TerminalException?) : this(
summary = when (error) {
null -> "Captured ${paymentIntent.run { "${identifiers()}, $amount $currency"}}"
null -> "Captured ${paymentIntent.run { "${identifiers()}, $amount $currency" }}"
else -> "Failed to capture ${paymentIntent.identifiers()}"
},
details = when (error) {
Expand All @@ -90,10 +100,10 @@ sealed interface OfflineEvent {
}

private val PRETTY_PRINT_GSON = GsonBuilder()
.setPrettyPrinting()
.serializeNulls()
.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
.create()
.setPrettyPrinting()
.serializeNulls()
.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
.create()

@OptIn(InternalApi::class)
fun PaymentIntent.identifiers(): String {
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ To use the Android SDK, add the SDK to the `dependencies` block of your `build.g


dependencies {
implementation "com.stripe:stripeterminal:3.3.1"
implementation "com.stripe:stripeterminal:3.4.0"
}

Next, since the SDK relies on Java 8, you’ll need to specify that as your target Java version (also in `build.gradle`):
Expand Down Expand Up @@ -129,8 +129,8 @@ To use the Tap to Pay SDK, replace your existing `stripeterminal` dependencies i
your `build.gradle` file with the following:
```groovy
dependencies {
implementation "com.stripe:stripeterminal-localmobile:3.3.1"
implementation "com.stripe:stripeterminal-core:3.3.1"
implementation "com.stripe:stripeterminal-localmobile:3.4.0"
implementation "com.stripe:stripeterminal-core:3.4.0"
}
```

Expand Down
Loading

0 comments on commit 85ea447

Please sign in to comment.