From dd8e9eb4dff078b81a2ae832126297e874bade36 Mon Sep 17 00:00:00 2001 From: Mark Date: Sat, 25 Jan 2025 13:27:52 +0800 Subject: [PATCH 1/6] Implemented handoff connection type --- packages/terminal/README.md | 5 +++ packages/terminal/android/build.gradle | 2 + .../stripe/terminal/StripeTerminal.kt | 39 +++++++++++++++++++ .../stripe/terminal/TerminalConnectTypes.kt | 1 + packages/terminal/src/stripe.enum.ts | 1 + 5 files changed, 48 insertions(+) diff --git a/packages/terminal/README.md b/packages/terminal/README.md index 6c9e1e55b..616e9d866 100644 --- a/packages/terminal/README.md +++ b/packages/terminal/README.md @@ -83,6 +83,10 @@ And add next block to `android/app/build.gradle`. + apply plugin: 'kotlin-android' ``` +If you are developing apps for Stripe Android devices (e.g. Stripe Reader S700), follow the Stripe's documentation for the client-side setup. +- [Stripe - Android configure your app](https://docs.stripe.com/terminal/features/apps-on-devices/build?terminal-sdk-platform=android&lang-android=java#setup-app) + + ## Usage ### Simple collect payment @@ -1048,6 +1052,7 @@ addListener(eventName: TerminalEventsEnum.ReaderReconnectFailed, listenerFunc: ( | **`Bluetooth`** | 'bluetooth' | | **`Usb`** | 'usb' | | **`TapToPay`** | 'tap-to-pay' | +| **`HandOff`** | 'hand-off' | #### SimulateReaderUpdate diff --git a/packages/terminal/android/build.gradle b/packages/terminal/android/build.gradle index daf427c16..9eec65b66 100644 --- a/packages/terminal/android/build.gradle +++ b/packages/terminal/android/build.gradle @@ -8,6 +8,7 @@ ext { volleyVersion = project.hasProperty('volleyVersion') ? rootProject.ext.volleyVersion : '1.2.1' stripeterminalTapToPayVersion = project.hasProperty('stripeterminalTapToPayVersion') ? rootProject.ext.stripeterminalTapToPayVersion : '4.1.0' stripeterminalCoreVersion = project.hasProperty('stripeterminalCoreVersion') ? rootProject.ext.stripeterminalCoreVersion : '4.1.0' + stripeterminalHandoffClientVersion = project.hasProperty('stripeterminalHandoffClientVersion') ? rootProject.ext.stripeterminalHandoffClientVersion : '4.1.0' } buildscript { @@ -71,6 +72,7 @@ dependencies { implementation "com.stripe:stripeterminal-core:$stripeterminalCoreVersion" implementation "com.stripe:stripeterminal-taptopay:$stripeterminalTapToPayVersion" + implementation "com.stripe:stripeterminal-handoffclient:$stripeterminalHandoffClientVersion" implementation "com.android.volley:volley:$volleyVersion" implementation "com.google.android.gms:play-services-wallet:$playServicesWalletVersion" } diff --git a/packages/terminal/android/src/main/java/com/getcapacitor/community/stripe/terminal/StripeTerminal.kt b/packages/terminal/android/src/main/java/com/getcapacitor/community/stripe/terminal/StripeTerminal.kt index d06fcfdc5..0dbee9710 100644 --- a/packages/terminal/android/src/main/java/com/getcapacitor/community/stripe/terminal/StripeTerminal.kt +++ b/packages/terminal/android/src/main/java/com/getcapacitor/community/stripe/terminal/StripeTerminal.kt @@ -29,6 +29,7 @@ import com.stripe.stripeterminal.external.callable.PaymentIntentCallback import com.stripe.stripeterminal.external.callable.ReaderCallback import com.stripe.stripeterminal.external.callable.TapToPayReaderListener import com.stripe.stripeterminal.external.callable.TerminalListener +import com.stripe.stripeterminal.external.callable.HandoffReaderListener import com.stripe.stripeterminal.external.models.BatteryStatus import com.stripe.stripeterminal.external.models.CardPresentDetails import com.stripe.stripeterminal.external.models.Cart @@ -194,6 +195,9 @@ class StripeTerminal( ) { config = DiscoveryConfiguration.BluetoothDiscoveryConfiguration(0, this.isTest!!) this.terminalConnectType = TerminalConnectTypes.Bluetooth + } else if (call.getString("type") == TerminalConnectTypes.HandOff.webEventName) { + config = DiscoveryConfiguration.HandoffDiscoveryConfiguration() + this.terminalConnectType = TerminalConnectTypes.HandOff } else { call.unimplemented(call.getString("type") + " is not support now") return @@ -240,6 +244,8 @@ class StripeTerminal( this.connectUsbReader(call) } else if (this.terminalConnectType == TerminalConnectTypes.Bluetooth) { this.connectBluetoothReader(call) + } else if (this.terminalConnectType == TerminalConnectTypes.HandOff) { + this.connectHandOffReader(call) } else { call.reject("type is not defined.") } @@ -440,6 +446,39 @@ class StripeTerminal( Terminal.getInstance().connectReader(foundReader, config, this.readerCallback(call)) } + private fun connectHandOffReader(call: PluginCall) { + val reader = call.getObject("reader") + val serialNumber = reader.getString("serialNumber") + val foundReader = this.discoveredReadersList.firstOrNull() + + if (serialNumber == null || foundReader == null) { + call.reject("The reader value is not set correctly.") + return + } + + val config: ConnectionConfiguration.HandoffConnectionConfiguration = ConnectionConfiguration.HandoffConnectionConfiguration( + this.handoffReaderListener + ) + + Terminal.getInstance().connectReader(foundReader, config, this.readerCallback(call)) + } + + var handoffReaderListener: HandoffReaderListener = object : HandoffReaderListener { + override fun onDisconnect(reason: DisconnectReason) { + notifyListeners( + TerminalEnumEvent.DisconnectedReader.webEventName, + JSObject().put("reason", reason.toString()) + ) + } + + override fun onReportReaderEvent(event: ReaderEvent) { + notifyListeners( + TerminalEnumEvent.ReaderEvent.webEventName, + JSObject().put("event", event.toString()) + ) + } + } + fun cancelDiscoverReaders(call: PluginCall) { if (discoveryCancelable == null || discoveryCancelable!!.isCompleted) { call.resolve() diff --git a/packages/terminal/android/src/main/java/com/getcapacitor/community/stripe/terminal/TerminalConnectTypes.kt b/packages/terminal/android/src/main/java/com/getcapacitor/community/stripe/terminal/TerminalConnectTypes.kt index fbf712b21..514293121 100644 --- a/packages/terminal/android/src/main/java/com/getcapacitor/community/stripe/terminal/TerminalConnectTypes.kt +++ b/packages/terminal/android/src/main/java/com/getcapacitor/community/stripe/terminal/TerminalConnectTypes.kt @@ -6,4 +6,5 @@ enum class TerminalConnectTypes(val webEventName: String) { Bluetooth("bluetooth"), Usb("usb"), TapToPay("tap-to-pay"), + HandOff("hand-off"), } diff --git a/packages/terminal/src/stripe.enum.ts b/packages/terminal/src/stripe.enum.ts index bf5c601f4..909e525d2 100644 --- a/packages/terminal/src/stripe.enum.ts +++ b/packages/terminal/src/stripe.enum.ts @@ -4,6 +4,7 @@ export enum TerminalConnectTypes { Bluetooth = 'bluetooth', Usb = 'usb', TapToPay = 'tap-to-pay', + HandOff = 'hand-off', } /** From d92d4d18a2ff3cb364e0a05585d71fa0f09134d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A6=8A=E5=8E=9F=E6=98=8C=E5=BD=A6?= Date: Sat, 1 Feb 2025 12:16:26 +0900 Subject: [PATCH 2/6] feat(): update package dependencies. --- packages/identity/CapacitorCommunityStripeIdentity.podspec | 2 +- packages/identity/Package.swift | 2 +- packages/identity/android/build.gradle | 2 +- packages/payment/CapacitorCommunityStripe.podspec | 4 ++-- packages/payment/Package.swift | 2 +- packages/payment/android/build.gradle | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/identity/CapacitorCommunityStripeIdentity.podspec b/packages/identity/CapacitorCommunityStripeIdentity.podspec index 48b5e6700..45d801980 100644 --- a/packages/identity/CapacitorCommunityStripeIdentity.podspec +++ b/packages/identity/CapacitorCommunityStripeIdentity.podspec @@ -13,6 +13,6 @@ Pod::Spec.new do |s| s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}' s.ios.deployment_target = '13.0' s.dependency 'Capacitor' - s.dependency 'StripeIdentity', '~> 24.1.0' + s.dependency 'StripeIdentity', '~> 24.4.1' s.swift_version = '5.1' end diff --git a/packages/identity/Package.swift b/packages/identity/Package.swift index 26acd65b5..05c6cf6c9 100644 --- a/packages/identity/Package.swift +++ b/packages/identity/Package.swift @@ -11,7 +11,7 @@ let package = Package( ], dependencies: [ .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "6.0.0"), - .package(url: "https://github.com/stripe/stripe-ios-spm.git", exact: "24.1.0") + .package(url: "https://github.com/stripe/stripe-ios-spm.git", exact: "24.4.1") ], targets: [ .target( diff --git a/packages/identity/android/build.gradle b/packages/identity/android/build.gradle index d7ed93917..50eaa3e77 100644 --- a/packages/identity/android/build.gradle +++ b/packages/identity/android/build.gradle @@ -5,7 +5,7 @@ ext { androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.5.1' playServicesWalletVersion = project.hasProperty('playServicesWalletVersion') ? rootProject.ext.playServicesWalletVersion : '19.2.+' - identityVersion = project.hasProperty('identityVersion') ? rootProject.ext.identityVersion : '21.2.+' + identityVersion = project.hasProperty('identityVersion') ? rootProject.ext.identityVersion : '21.4.+' } buildscript { diff --git a/packages/payment/CapacitorCommunityStripe.podspec b/packages/payment/CapacitorCommunityStripe.podspec index e379212f5..48ea4ab7d 100644 --- a/packages/payment/CapacitorCommunityStripe.podspec +++ b/packages/payment/CapacitorCommunityStripe.podspec @@ -13,7 +13,7 @@ Pod::Spec.new do |s| s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}' s.ios.deployment_target = '13.0' s.dependency 'Capacitor' - s.dependency 'StripePaymentSheet', '~> 24.1.0' - s.dependency 'StripeApplePay', '~> 24.1.0' + s.dependency 'StripePaymentSheet', '~> 24.4.1' + s.dependency 'StripeApplePay', '~> 24.4.1' s.swift_version = '5.1' end diff --git a/packages/payment/Package.swift b/packages/payment/Package.swift index 6dbd97338..f01a00c71 100644 --- a/packages/payment/Package.swift +++ b/packages/payment/Package.swift @@ -11,7 +11,7 @@ let package = Package( ], dependencies: [ .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "6.0.0"), - .package(url: "https://github.com/stripe/stripe-ios-spm.git", exact: "24.1.0") + .package(url: "https://github.com/stripe/stripe-ios-spm.git", exact: "24.4.1") ], targets: [ .target( diff --git a/packages/payment/android/build.gradle b/packages/payment/android/build.gradle index a75154732..e2ac4266b 100644 --- a/packages/payment/android/build.gradle +++ b/packages/payment/android/build.gradle @@ -5,7 +5,7 @@ ext { androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.5.1' playServicesWalletVersion = project.hasProperty('playServicesWalletVersion') ? rootProject.ext.playServicesWalletVersion : '19.2.+' - stripeAndroidVersion = project.hasProperty('stripeAndroidVersion') ? rootProject.ext.stripeAndroidVersion : '21.2.+' + stripeAndroidVersion = project.hasProperty('stripeAndroidVersion') ? rootProject.ext.stripeAndroidVersion : '21.4.+' gsonVersion = project.hasProperty('gsonVersion') ? rootProject.ext.gsonVersion : '2.10.+' } From 3f47fa8591997db2c940a59746626ac6308e586a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A6=8A=E5=8E=9F=E6=98=8C=E5=BD=A6?= Date: Sat, 1 Feb 2025 12:35:25 +0900 Subject: [PATCH 3/6] chore --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 020d949c1..38e2d59d3 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@

- +

From 47e3a97c6d3647f817765d462822798e4a07b236 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A6=8A=E5=8E=9F=E6=98=8C=E5=BD=A6?= Date: Sat, 1 Feb 2025 12:45:00 +0900 Subject: [PATCH 4/6] chore --- demo/angular/ios/App/Podfile.lock | 92 +++++++++++++++---------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/demo/angular/ios/App/Podfile.lock b/demo/angular/ios/App/Podfile.lock index 2399b49d0..623b6b276 100644 --- a/demo/angular/ios/App/Podfile.lock +++ b/demo/angular/ios/App/Podfile.lock @@ -1,43 +1,43 @@ PODS: - - Capacitor (6.1.2): + - Capacitor (6.2.0): - CapacitorCordova - - CapacitorCommunityStripe (6.4.0-0): + - CapacitorCommunityStripe (6.4.4): - Capacitor - - StripeApplePay (~> 24.1.0) - - StripePaymentSheet (~> 24.1.0) - - CapacitorCommunityStripeIdentity (6.4.0-0): + - StripeApplePay (~> 24.4.1) + - StripePaymentSheet (~> 24.4.1) + - CapacitorCommunityStripeIdentity (6.4.4): - Capacitor - - StripeIdentity (~> 24.1.0) - - CapacitorCommunityStripeTerminal (6.4.0-0): + - StripeIdentity (~> 24.4.1) + - CapacitorCommunityStripeTerminal (6.4.4): - Capacitor - StripeTerminal (~> 4.1.0) - - CapacitorCordova (6.1.2) - - StripeApplePay (24.1.1): - - StripeCore (= 24.1.1) - - StripeCameraCore (24.1.1): - - StripeCore (= 24.1.1) - - StripeCore (24.1.1) - - StripeIdentity (24.1.1): - - StripeCameraCore (= 24.1.1) - - StripeCore (= 24.1.1) - - StripeUICore (= 24.1.1) - - StripePayments (24.1.1): - - StripeCore (= 24.1.1) - - StripePayments/Stripe3DS2 (= 24.1.1) - - StripePayments/Stripe3DS2 (24.1.1): - - StripeCore (= 24.1.1) - - StripePaymentSheet (24.1.1): - - StripeApplePay (= 24.1.1) - - StripeCore (= 24.1.1) - - StripePayments (= 24.1.1) - - StripePaymentsUI (= 24.1.1) - - StripePaymentsUI (24.1.1): - - StripeCore (= 24.1.1) - - StripePayments (= 24.1.1) - - StripeUICore (= 24.1.1) + - CapacitorCordova (6.2.0) + - StripeApplePay (24.4.1): + - StripeCore (= 24.4.1) + - StripeCameraCore (24.4.1): + - StripeCore (= 24.4.1) + - StripeCore (24.4.1) + - StripeIdentity (24.4.1): + - StripeCameraCore (= 24.4.1) + - StripeCore (= 24.4.1) + - StripeUICore (= 24.4.1) + - StripePayments (24.4.1): + - StripeCore (= 24.4.1) + - StripePayments/Stripe3DS2 (= 24.4.1) + - StripePayments/Stripe3DS2 (24.4.1): + - StripeCore (= 24.4.1) + - StripePaymentSheet (24.4.1): + - StripeApplePay (= 24.4.1) + - StripeCore (= 24.4.1) + - StripePayments (= 24.4.1) + - StripePaymentsUI (= 24.4.1) + - StripePaymentsUI (24.4.1): + - StripeCore (= 24.4.1) + - StripePayments (= 24.4.1) + - StripeUICore (= 24.4.1) - StripeTerminal (4.1.0) - - StripeUICore (24.1.1): - - StripeCore (= 24.1.1) + - StripeUICore (24.4.1): + - StripeCore (= 24.4.1) DEPENDENCIES: - "Capacitor (from `../../node_modules/@capacitor/ios`)" @@ -71,20 +71,20 @@ EXTERNAL SOURCES: :path: "../../node_modules/@capacitor/ios" SPEC CHECKSUMS: - Capacitor: 679f9673fdf30597493a6362a5d5bf233d46abc2 - CapacitorCommunityStripe: 93ace959a7a2795e1eb2c1aaf5ef4674175817aa - CapacitorCommunityStripeIdentity: b8d01ae9887b6a1a168942af45526d8eec37cc0d - CapacitorCommunityStripeTerminal: b699474e785a1ec0a1f24099dbf454a9c264d7cb - CapacitorCordova: f48c89f96c319101cd2f0ce8a2b7449b5fb8b3dd - StripeApplePay: 3aa55daa307c3f55b885e24a13380e87cc7c8c87 - StripeCameraCore: fa88de9e322fdf0bdce755573e70bc99613eef84 - StripeCore: 00ade3c22bff1aa803a32c36805ccde8315f57ca - StripeIdentity: fa163cbf51dc6d80f3e94ef827d3c4fa129255b8 - StripePayments: 85a01f84f02ebeb76f179cedc73572d0ace6ecec - StripePaymentSheet: 554aa88117cd837022d611d18cf9fe28c51af22d - StripePaymentsUI: 99c13ac3b2e3c144a0735622523bb8e2b18f5e72 + Capacitor: 1f3c7b9802d958cd8c4eb63895fff85dff2e1eea + CapacitorCommunityStripe: 6781e3b1145d78b422ff471f007b41b5f20df4cd + CapacitorCommunityStripeIdentity: e3321befa430faf1607909ea6ecea0133b5bb4be + CapacitorCommunityStripeTerminal: f1754533df87687547e8d6b5f4f8cd3af6238f37 + CapacitorCordova: b33e7f4aa4ed105dd43283acdd940964374a87d9 + StripeApplePay: e2adcc71d7a0a07e9de85e871eacf55ecce546a9 + StripeCameraCore: 9c3dc9dd77b62cf73b455c9abc2635a001c2cba6 + StripeCore: a2c2f331cf2e105aaadda60416cf405da2d5232b + StripeIdentity: 2b202add9382ef208b4d45ed147db6b9e48b0b3c + StripePayments: 438ec8dc7320a7d601cb6152b88b37d4c34df161 + StripePaymentSheet: da0ee282723f3c0c87c52b5e5cc3eb7e1344eeb9 + StripePaymentsUI: 70414581d3d14089831e370008b705ef03c7cce0 StripeTerminal: e393c25fd8262bd99986785f7ecc91625755d65f - StripeUICore: ac2717acff888b07d32fba5f1a103d360b1074af + StripeUICore: f11561a53f81e210398b4f1bd75f1e87b101197d PODFILE CHECKSUM: c75ca255b97ee461832b20e6cdf6d1da533d4019 From 8e179eb41ef102820be86822384be80a6e227867 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A6=8A=E5=8E=9F=E6=98=8C=E5=BD=A6?= Date: Sat, 1 Feb 2025 12:45:22 +0900 Subject: [PATCH 5/6] 6.5.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c113a0842..8979c8930 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@capacitor-community/stripe", - "version": "6.4.4", + "version": "6.5.0", "engines": { "node": ">=18.0.0" }, From 76b3d65182487981c641793040e7d6086326f802 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A6=8A=E5=8E=9F=E6=98=8C=E5=BD=A6?= Date: Sat, 1 Feb 2025 12:52:54 +0900 Subject: [PATCH 6/6] released --- packages/identity/package-lock.json | 4 ++-- packages/identity/package.json | 2 +- packages/payment/package-lock.json | 4 ++-- packages/payment/package.json | 2 +- packages/terminal/package-lock.json | 4 ++-- packages/terminal/package.json | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/identity/package-lock.json b/packages/identity/package-lock.json index ea9097f2a..db5a80554 100644 --- a/packages/identity/package-lock.json +++ b/packages/identity/package-lock.json @@ -1,12 +1,12 @@ { "name": "@capacitor-community/stripe-identity", - "version": "6.4.4", + "version": "6.5.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@capacitor-community/stripe-identity", - "version": "6.4.4", + "version": "6.5.0", "license": "MIT", "dependencies": { "@stripe/stripe-js": "^2.1.11" diff --git a/packages/identity/package.json b/packages/identity/package.json index f3f2527c1..bdf225ff5 100644 --- a/packages/identity/package.json +++ b/packages/identity/package.json @@ -1,6 +1,6 @@ { "name": "@capacitor-community/stripe-identity", - "version": "6.4.4", + "version": "6.5.0", "engines": { "node": ">=18.0.0" }, diff --git a/packages/payment/package-lock.json b/packages/payment/package-lock.json index 7f3a538be..2ff38cdce 100644 --- a/packages/payment/package-lock.json +++ b/packages/payment/package-lock.json @@ -1,12 +1,12 @@ { "name": "@capacitor-community/stripe", - "version": "6.4.4", + "version": "6.5.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@capacitor-community/stripe", - "version": "6.4.4", + "version": "6.5.0", "license": "MIT", "devDependencies": { "@capacitor/android": "^6.0.0", diff --git a/packages/payment/package.json b/packages/payment/package.json index 5880825e4..a2a9da8ed 100644 --- a/packages/payment/package.json +++ b/packages/payment/package.json @@ -1,6 +1,6 @@ { "name": "@capacitor-community/stripe", - "version": "6.4.4", + "version": "6.5.0", "engines": { "node": ">=18.0.0" }, diff --git a/packages/terminal/package-lock.json b/packages/terminal/package-lock.json index 50e48ed79..c7ce1b6e7 100644 --- a/packages/terminal/package-lock.json +++ b/packages/terminal/package-lock.json @@ -1,12 +1,12 @@ { "name": "@capacitor-community/stripe-terminal", - "version": "6.4.4", + "version": "6.5.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@capacitor-community/stripe-terminal", - "version": "6.4.4", + "version": "6.5.0", "license": "MIT", "dependencies": { "@stripe/terminal-js": "^0.13.0" diff --git a/packages/terminal/package.json b/packages/terminal/package.json index f0122fb79..5ebd1e9a7 100644 --- a/packages/terminal/package.json +++ b/packages/terminal/package.json @@ -1,6 +1,6 @@ { "name": "@capacitor-community/stripe-terminal", - "version": "6.4.4", + "version": "6.5.0", "engines": { "node": ">=18.0.0" },