capacitor-stripe-terminal 3.0.0-beta.8 → 5.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CapacitorStripeTerminal.podspec +2 -2
- package/README.md +46 -40
- package/android/build.gradle +9 -6
- package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/android/src/main/AndroidManifest.xml +6 -8
- package/android/src/main/java/io/event1/capacitorstripeterminal/StripeTerminal.java +73 -76
- package/android/src/main/java/io/event1/capacitorstripeterminal/TerminalUtils.java +114 -44
- package/dist/esm/definitions.d.ts +94 -38
- package/dist/esm/definitions.js +54 -26
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/plugin-registration.js +1 -1
- package/dist/esm/plugin-registration.js.map +1 -1
- package/dist/esm/plugin.d.ts +26 -35
- package/dist/esm/plugin.js +173 -277
- package/dist/esm/plugin.js.map +1 -1
- package/dist/esm/web.d.ts +6 -7
- package/dist/esm/web.js +100 -61
- package/dist/esm/web.js.map +1 -1
- package/ios/Plugin/Plugin.m +3 -2
- package/ios/Plugin/Plugin.swift +128 -63
- package/ios/Plugin/TerminalUtils.swift +55 -21
- package/ios/Podfile +2 -2
- package/ios/Podfile.lock +9 -9
- package/package.json +13 -16
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
s.author = 'eventOne Labs <opensource@event1.io>'
|
|
9
9
|
s.source = { :git => 'https://github.com/eventOneHQ/capacitor-stripe-terminal', :tag => s.version.to_s }
|
|
10
10
|
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
11
|
-
s.ios.deployment_target = '
|
|
11
|
+
s.ios.deployment_target = '15.0'
|
|
12
12
|
s.dependency 'Capacitor'
|
|
13
|
-
s.dependency 'StripeTerminal', '
|
|
13
|
+
s.dependency 'StripeTerminal', '5.3.0'
|
|
14
14
|
end
|
package/README.md
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
</p>
|
|
7
7
|
|
|
8
8
|
<p align="center">
|
|
9
|
-
<img src="https://img.shields.io/maintenance/yes/
|
|
10
|
-
<a href="https://github.com/
|
|
9
|
+
<img src="https://img.shields.io/maintenance/yes/2026?style=flat-square" />
|
|
10
|
+
<a href="https://github.com/eventOneHQ/capacitor-stripe-terminal/actions/workflows/release.yml"><img src="https://img.shields.io/github/actions/workflow/status/eventOneHQ/capacitor-stripe-terminal/release.yml?style=flat-square" /></a>
|
|
11
11
|
<a href="https://www.npmjs.com/package/capacitor-stripe-terminal"><img src="https://img.shields.io/npm/l/capacitor-stripe-terminal?style=flat-square" /></a>
|
|
12
12
|
<br>
|
|
13
13
|
<a href="https://www.npmjs.com/package/capacitor-stripe-terminal"><img src="https://img.shields.io/npm/dw/capacitor-stripe-terminal?style=flat-square" /></a>
|
|
@@ -17,11 +17,14 @@
|
|
|
17
17
|
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
|
18
18
|
</p>
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
## Requirements
|
|
21
21
|
|
|
22
|
-
**
|
|
22
|
+
- **Capacitor**: 8.x
|
|
23
|
+
- **Stripe Terminal SDK**:
|
|
24
|
+
- iOS: 5.3.0 (requires iOS 15.0+)
|
|
25
|
+
- Android: 5.3.0 (requires Android API 23+)
|
|
23
26
|
|
|
24
|
-
|
|
27
|
+
> **📝 Upgrading from an earlier version?** See the [Migration Guide](MIGRATION_V5.md) for details on breaking changes and upgrade instructions.
|
|
25
28
|
|
|
26
29
|
## Maintainers
|
|
27
30
|
|
|
@@ -99,14 +102,15 @@ _Hint: If the user denies Location permission the first time you ask for it, And
|
|
|
99
102
|
```javascript
|
|
100
103
|
import {
|
|
101
104
|
StripeTerminalPlugin,
|
|
102
|
-
|
|
105
|
+
StripeTerminalError,
|
|
106
|
+
DiscoveryMethod,
|
|
103
107
|
} from 'capacitor-stripe-terminal'
|
|
104
108
|
|
|
105
109
|
// First, initialize the SDK
|
|
106
110
|
const terminal = await StripeTerminalPlugin.create({
|
|
107
111
|
fetchConnectionToken: async () => {
|
|
108
112
|
const resp = await fetch('https://your-backend.dev/token', {
|
|
109
|
-
method: 'POST'
|
|
113
|
+
method: 'POST',
|
|
110
114
|
})
|
|
111
115
|
const data = await resp.json()
|
|
112
116
|
|
|
@@ -114,45 +118,46 @@ const terminal = await StripeTerminalPlugin.create({
|
|
|
114
118
|
},
|
|
115
119
|
onUnexpectedReaderDisconnect: () => {
|
|
116
120
|
// handle reader disconnect
|
|
117
|
-
}
|
|
121
|
+
},
|
|
118
122
|
})
|
|
119
123
|
|
|
120
124
|
// Start scanning for readers
|
|
121
|
-
//
|
|
122
|
-
// To stop scanning, unsubscribe from the Observable.
|
|
125
|
+
// To stop scanning, call handle.remove() on the returned handle.
|
|
123
126
|
// You must connect to a reader while scanning
|
|
124
|
-
terminal
|
|
125
|
-
|
|
127
|
+
const discoverHandle = await terminal.discoverReaders(
|
|
128
|
+
{
|
|
126
129
|
simulated: false,
|
|
127
|
-
discoveryMethod: DiscoveryMethod.
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
+
discoveryMethod: DiscoveryMethod.BluetoothScan,
|
|
131
|
+
},
|
|
132
|
+
(readers) => {
|
|
130
133
|
if (readers.length) {
|
|
131
134
|
const selectedReader = readers[0]
|
|
132
135
|
const connectionConfig = {
|
|
133
|
-
locationId: '{{LOCATION_ID}}'
|
|
136
|
+
locationId: '{{LOCATION_ID}}',
|
|
134
137
|
}
|
|
135
138
|
terminal
|
|
136
139
|
.connectBluetoothReader(selectedReader, connectionConfig)
|
|
137
|
-
.then(connectedReader => {
|
|
140
|
+
.then((connectedReader) => {
|
|
138
141
|
// the reader is now connected and usable
|
|
139
142
|
})
|
|
140
143
|
}
|
|
141
|
-
}
|
|
144
|
+
},
|
|
145
|
+
(error) => {
|
|
146
|
+
console.error('discoverReaders error', error)
|
|
147
|
+
},
|
|
148
|
+
)
|
|
142
149
|
|
|
143
150
|
// Once the reader is connected, collect a payment intent!
|
|
144
151
|
|
|
145
|
-
//
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
.subscribe(displayMessage => {
|
|
152
|
+
// listen to user instructions - these should be displayed to the user
|
|
153
|
+
const displayHandle = await terminal.didRequestReaderDisplayMessage(
|
|
154
|
+
(displayMessage) => {
|
|
149
155
|
console.log('displayMessage', displayMessage)
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
.
|
|
154
|
-
|
|
155
|
-
})
|
|
156
|
+
},
|
|
157
|
+
)
|
|
158
|
+
const inputHandle = await terminal.didRequestReaderInput((inputOptions) => {
|
|
159
|
+
console.log('inputOptions', inputOptions)
|
|
160
|
+
})
|
|
156
161
|
|
|
157
162
|
// retrieve the payment intent
|
|
158
163
|
await terminal.retrievePaymentIntent('your client secret created server side')
|
|
@@ -160,12 +165,19 @@ await terminal.retrievePaymentIntent('your client secret created server side')
|
|
|
160
165
|
// collect the payment method
|
|
161
166
|
await terminal.collectPaymentMethod()
|
|
162
167
|
|
|
163
|
-
// and finally,
|
|
164
|
-
|
|
168
|
+
// and finally, confirm the payment intent
|
|
169
|
+
try {
|
|
170
|
+
await terminal.confirmPaymentIntent()
|
|
171
|
+
} catch (err) {
|
|
172
|
+
if (err instanceof StripeTerminalError) {
|
|
173
|
+
// structured decline data is available on card declines
|
|
174
|
+
console.error('decline_code', err.decline_code)
|
|
175
|
+
}
|
|
176
|
+
throw err
|
|
177
|
+
}
|
|
165
178
|
|
|
166
|
-
// once you are done,
|
|
167
|
-
|
|
168
|
-
inputSubscription.unsubscribe()
|
|
179
|
+
// once you are done, call destroy() to remove all listeners and reset the plugin (e.g. in ngOnDestroy)
|
|
180
|
+
await terminal.destroy()
|
|
169
181
|
```
|
|
170
182
|
|
|
171
183
|
## API Reference
|
|
@@ -176,13 +188,7 @@ See the full API docs [here](https://oss.eventone.page/capacitor-stripe-terminal
|
|
|
176
188
|
|
|
177
189
|
<p>
|
|
178
190
|
<a href="https://event1.io/?utm_medium=opensource&utm_source=capacitor-stripe-terminal">
|
|
179
|
-
<img src="https://
|
|
180
|
-
</a>
|
|
181
|
-
</p>
|
|
182
|
-
|
|
183
|
-
<p>
|
|
184
|
-
<a href="https://tableneeds.com/?utm_medium=opensource&utm_source=capacitor-stripe-terminal">
|
|
185
|
-
<img src="https://tableneeds.com/wp-content/uploads/2021/08/tn-new.svg" width="200px">
|
|
191
|
+
<img src="https://brand.event1.io/wordmark/wm-white.svg" width="200px">
|
|
186
192
|
</a>
|
|
187
193
|
</p>
|
|
188
194
|
|
package/android/build.gradle
CHANGED
|
@@ -3,6 +3,9 @@ ext {
|
|
|
3
3
|
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.4.2'
|
|
4
4
|
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.3'
|
|
5
5
|
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.4.0'
|
|
6
|
+
compileSdkVersion = project.hasProperty('compileSdkVersion') ? (project.compileSdkVersion as Integer) : 35
|
|
7
|
+
minSdkVersion = project.hasProperty('minSdkVersion') ? (project.minSdkVersion as Integer) : 23
|
|
8
|
+
targetSdkVersion = project.hasProperty('targetSdkVersion') ? (project.targetSdkVersion as Integer) : 35
|
|
6
9
|
}
|
|
7
10
|
|
|
8
11
|
buildscript {
|
|
@@ -11,17 +14,18 @@ buildscript {
|
|
|
11
14
|
mavenCentral()
|
|
12
15
|
}
|
|
13
16
|
dependencies {
|
|
14
|
-
classpath 'com.android.tools.build:gradle:
|
|
17
|
+
classpath 'com.android.tools.build:gradle:8.3.2'
|
|
15
18
|
}
|
|
16
19
|
}
|
|
17
20
|
|
|
18
21
|
apply plugin: 'com.android.library'
|
|
19
22
|
|
|
20
23
|
android {
|
|
21
|
-
|
|
24
|
+
namespace 'io.event1.capacitorstripeterminal'
|
|
25
|
+
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 35
|
|
22
26
|
defaultConfig {
|
|
23
|
-
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion :
|
|
24
|
-
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion :
|
|
27
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 23
|
|
28
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 35
|
|
25
29
|
versionCode 1
|
|
26
30
|
versionName "1.0"
|
|
27
31
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
@@ -54,7 +58,6 @@ dependencies {
|
|
|
54
58
|
testImplementation "junit:junit:$junitVersion"
|
|
55
59
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
56
60
|
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
57
|
-
implementation "com.stripe:stripeterminal:
|
|
58
|
-
implementation("com.squareup.moshi:moshi:1.14.0")
|
|
61
|
+
implementation "com.stripe:stripeterminal:5.3.0"
|
|
59
62
|
implementation "com.google.code.gson:gson:2.8.8"
|
|
60
63
|
}
|
|
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
|
|
|
2
2
|
distributionPath=wrapper/dists
|
|
3
3
|
zipStoreBase=GRADLE_USER_HOME
|
|
4
4
|
zipStorePath=wrapper/dists
|
|
5
|
-
distributionUrl=https\://services.gradle.org/distributions/gradle-
|
|
5
|
+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
1
2
|
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
|
8
|
-
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
|
|
9
|
-
</manifest>
|
|
3
|
+
<uses-permission android:name="android.permission.BLUETOOTH" />
|
|
4
|
+
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
|
5
|
+
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
|
6
|
+
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
|
|
7
|
+
</manifest>
|
|
10
8
|
|
|
@@ -14,32 +14,31 @@ import com.getcapacitor.annotation.CapacitorPlugin;
|
|
|
14
14
|
import com.getcapacitor.annotation.Permission;
|
|
15
15
|
import com.getcapacitor.annotation.PermissionCallback;
|
|
16
16
|
import com.stripe.stripeterminal.Terminal;
|
|
17
|
-
import com.stripe.stripeterminal.external.callable.
|
|
18
|
-
import com.stripe.stripeterminal.external.
|
|
17
|
+
import com.stripe.stripeterminal.external.callable.AppsOnDevicesListener;
|
|
18
|
+
import com.stripe.stripeterminal.external.api.ApiError;
|
|
19
19
|
import com.stripe.stripeterminal.external.callable.Callback;
|
|
20
20
|
import com.stripe.stripeterminal.external.callable.Cancelable;
|
|
21
21
|
import com.stripe.stripeterminal.external.callable.ConnectionTokenCallback;
|
|
22
22
|
import com.stripe.stripeterminal.external.callable.ConnectionTokenProvider;
|
|
23
23
|
import com.stripe.stripeterminal.external.callable.DiscoveryListener;
|
|
24
|
-
import com.stripe.stripeterminal.external.callable.HandoffReaderListener;
|
|
25
24
|
import com.stripe.stripeterminal.external.callable.LocationListCallback;
|
|
25
|
+
import com.stripe.stripeterminal.external.callable.MobileReaderListener;
|
|
26
26
|
import com.stripe.stripeterminal.external.callable.PaymentIntentCallback;
|
|
27
27
|
import com.stripe.stripeterminal.external.callable.ReaderCallback;
|
|
28
28
|
import com.stripe.stripeterminal.external.callable.TerminalListener;
|
|
29
|
-
import com.stripe.stripeterminal.external.callable.UsbReaderListener;
|
|
30
29
|
import com.stripe.stripeterminal.external.models.BatteryStatus;
|
|
31
30
|
import com.stripe.stripeterminal.external.models.Cart;
|
|
32
31
|
import com.stripe.stripeterminal.external.models.CartLineItem;
|
|
33
|
-
import com.stripe.stripeterminal.external.models.
|
|
32
|
+
import com.stripe.stripeterminal.external.models.CollectPaymentIntentConfiguration;
|
|
33
|
+
import com.stripe.stripeterminal.external.models.ConnectionConfiguration.AppsOnDevicesConnectionConfiguration;
|
|
34
34
|
import com.stripe.stripeterminal.external.models.ConnectionConfiguration.BluetoothConnectionConfiguration;
|
|
35
|
-
import com.stripe.stripeterminal.external.models.ConnectionConfiguration.HandoffConnectionConfiguration;
|
|
36
35
|
import com.stripe.stripeterminal.external.models.ConnectionConfiguration.InternetConnectionConfiguration;
|
|
37
|
-
import com.stripe.stripeterminal.external.models.ConnectionConfiguration.
|
|
36
|
+
import com.stripe.stripeterminal.external.models.ConnectionConfiguration.TapToPayConnectionConfiguration;
|
|
38
37
|
import com.stripe.stripeterminal.external.models.ConnectionConfiguration.UsbConnectionConfiguration;
|
|
39
38
|
import com.stripe.stripeterminal.external.models.ConnectionStatus;
|
|
40
39
|
import com.stripe.stripeterminal.external.models.ConnectionTokenException;
|
|
40
|
+
import com.stripe.stripeterminal.external.models.DisconnectReason;
|
|
41
41
|
import com.stripe.stripeterminal.external.models.DiscoveryConfiguration;
|
|
42
|
-
import com.stripe.stripeterminal.external.models.DiscoveryMethod;
|
|
43
42
|
import com.stripe.stripeterminal.external.models.ListLocationsParameters;
|
|
44
43
|
import com.stripe.stripeterminal.external.models.Location;
|
|
45
44
|
import com.stripe.stripeterminal.external.models.PaymentIntent;
|
|
@@ -52,6 +51,8 @@ import com.stripe.stripeterminal.external.models.ReaderSoftwareUpdate;
|
|
|
52
51
|
import com.stripe.stripeterminal.external.models.SimulateReaderUpdate;
|
|
53
52
|
import com.stripe.stripeterminal.external.models.SimulatedCard;
|
|
54
53
|
import com.stripe.stripeterminal.external.models.SimulatedCardType;
|
|
54
|
+
import com.stripe.stripeterminal.external.models.SimulatedCollectInputsResult;
|
|
55
|
+
import com.stripe.stripeterminal.external.models.SimulatedCollectInputsSkipBehavior;
|
|
55
56
|
import com.stripe.stripeterminal.external.models.SimulatorConfiguration;
|
|
56
57
|
import com.stripe.stripeterminal.external.models.TerminalException;
|
|
57
58
|
import com.stripe.stripeterminal.log.LogLevel;
|
|
@@ -82,10 +83,8 @@ public class StripeTerminal
|
|
|
82
83
|
ConnectionTokenProvider,
|
|
83
84
|
TerminalListener,
|
|
84
85
|
DiscoveryListener,
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
BluetoothReaderListener,
|
|
88
|
-
BluetoothReaderReconnectionListener {
|
|
86
|
+
MobileReaderListener,
|
|
87
|
+
AppsOnDevicesListener {
|
|
89
88
|
|
|
90
89
|
Cancelable pendingDiscoverReaders = null;
|
|
91
90
|
Cancelable pendingCollectPaymentMethod = null;
|
|
@@ -172,11 +171,12 @@ public class StripeTerminal
|
|
|
172
171
|
|
|
173
172
|
String err = "";
|
|
174
173
|
try {
|
|
175
|
-
Terminal.
|
|
176
|
-
this.bridge.
|
|
174
|
+
Terminal.init(
|
|
175
|
+
this.bridge.getContext(),
|
|
177
176
|
logLevel,
|
|
178
177
|
tokenProvider,
|
|
179
|
-
terminalListener
|
|
178
|
+
terminalListener,
|
|
179
|
+
null
|
|
180
180
|
);
|
|
181
181
|
lastReaderEvent = ReaderEvent.CARD_REMOVED;
|
|
182
182
|
isInitialized = true;
|
|
@@ -226,14 +226,11 @@ public class StripeTerminal
|
|
|
226
226
|
public void discoverReaders(final PluginCall call) {
|
|
227
227
|
try {
|
|
228
228
|
Boolean simulated = call.getBoolean("simulated", true);
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
0,
|
|
235
|
-
discoveryMethod,
|
|
236
|
-
simulated
|
|
229
|
+
String locationId = call.getString("locationId", null);
|
|
230
|
+
DiscoveryConfiguration discoveryConfiguration = TerminalUtils.translateDiscoveryMethod(
|
|
231
|
+
call.getInt("discoveryMethod", 0),
|
|
232
|
+
simulated,
|
|
233
|
+
locationId
|
|
237
234
|
);
|
|
238
235
|
Callback statusCallback = new Callback() {
|
|
239
236
|
@Override
|
|
@@ -361,16 +358,13 @@ public class StripeTerminal
|
|
|
361
358
|
// Boolean allowCustomerCancel = call.getBoolean("allowCustomerCancel", false);
|
|
362
359
|
|
|
363
360
|
InternetConnectionConfiguration connectionConfig = new InternetConnectionConfiguration(
|
|
361
|
+
null,
|
|
364
362
|
failIfInUse
|
|
365
363
|
);
|
|
366
364
|
|
|
367
365
|
Terminal
|
|
368
366
|
.getInstance()
|
|
369
|
-
.
|
|
370
|
-
reader,
|
|
371
|
-
connectionConfig,
|
|
372
|
-
this.createReaderCallback(call)
|
|
373
|
-
);
|
|
367
|
+
.connectReader(reader, connectionConfig, this.createReaderCallback(call));
|
|
374
368
|
}
|
|
375
369
|
|
|
376
370
|
@PluginMethod
|
|
@@ -401,12 +395,7 @@ public class StripeTerminal
|
|
|
401
395
|
|
|
402
396
|
Terminal
|
|
403
397
|
.getInstance()
|
|
404
|
-
.
|
|
405
|
-
reader,
|
|
406
|
-
connectionConfig,
|
|
407
|
-
this,
|
|
408
|
-
this.createReaderCallback(call)
|
|
409
|
-
);
|
|
398
|
+
.connectReader(reader, connectionConfig, this.createReaderCallback(call));
|
|
410
399
|
}
|
|
411
400
|
|
|
412
401
|
@PluginMethod
|
|
@@ -425,49 +414,35 @@ public class StripeTerminal
|
|
|
425
414
|
}
|
|
426
415
|
|
|
427
416
|
UsbConnectionConfiguration connectionConfig = new UsbConnectionConfiguration(
|
|
428
|
-
locationId
|
|
417
|
+
locationId,
|
|
418
|
+
false,
|
|
419
|
+
this
|
|
429
420
|
);
|
|
430
421
|
|
|
431
422
|
Terminal
|
|
432
423
|
.getInstance()
|
|
433
|
-
.
|
|
434
|
-
reader,
|
|
435
|
-
connectionConfig,
|
|
436
|
-
this,
|
|
437
|
-
this.createReaderCallback(call)
|
|
438
|
-
);
|
|
424
|
+
.connectReader(reader, connectionConfig, this.createReaderCallback(call));
|
|
439
425
|
}
|
|
440
426
|
|
|
441
427
|
@PluginMethod
|
|
442
|
-
public void
|
|
428
|
+
public void connectAppsOnDevicesReader(final PluginCall call) {
|
|
443
429
|
Reader reader = getReaderFromDiscovered(call);
|
|
444
430
|
|
|
445
431
|
if (reader == null) {
|
|
446
432
|
return;
|
|
447
433
|
}
|
|
448
434
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
if (locationId == null) {
|
|
452
|
-
call.reject("Must provide a location ID");
|
|
453
|
-
return;
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
LocalMobileConnectionConfiguration connectionConfig = new LocalMobileConnectionConfiguration(
|
|
457
|
-
locationId
|
|
435
|
+
AppsOnDevicesConnectionConfiguration connectionConfig = new AppsOnDevicesConnectionConfiguration(
|
|
436
|
+
this
|
|
458
437
|
);
|
|
459
438
|
|
|
460
439
|
Terminal
|
|
461
440
|
.getInstance()
|
|
462
|
-
.
|
|
463
|
-
reader,
|
|
464
|
-
connectionConfig,
|
|
465
|
-
this.createReaderCallback(call)
|
|
466
|
-
);
|
|
441
|
+
.connectReader(reader, connectionConfig, this.createReaderCallback(call));
|
|
467
442
|
}
|
|
468
443
|
|
|
469
444
|
@PluginMethod
|
|
470
|
-
public void
|
|
445
|
+
public void connectTapToPayReader(final PluginCall call) {
|
|
471
446
|
Reader reader = getReaderFromDiscovered(call);
|
|
472
447
|
|
|
473
448
|
if (reader == null) {
|
|
@@ -481,18 +456,15 @@ public class StripeTerminal
|
|
|
481
456
|
return;
|
|
482
457
|
}
|
|
483
458
|
|
|
484
|
-
|
|
485
|
-
locationId
|
|
459
|
+
TapToPayConnectionConfiguration connectionConfig = new TapToPayConnectionConfiguration(
|
|
460
|
+
locationId,
|
|
461
|
+
false,
|
|
462
|
+
null
|
|
486
463
|
);
|
|
487
464
|
|
|
488
465
|
Terminal
|
|
489
466
|
.getInstance()
|
|
490
|
-
.
|
|
491
|
-
reader,
|
|
492
|
-
connectionConfig,
|
|
493
|
-
this,
|
|
494
|
-
this.createReaderCallback(call)
|
|
495
|
-
);
|
|
467
|
+
.connectReader(reader, connectionConfig, this.createReaderCallback(call));
|
|
496
468
|
}
|
|
497
469
|
|
|
498
470
|
@PluginMethod
|
|
@@ -594,7 +566,7 @@ public class StripeTerminal
|
|
|
594
566
|
public void collectPaymentMethod(final PluginCall call) {
|
|
595
567
|
Boolean updatePaymentIntent = call.getBoolean("updatePaymentIntent", false);
|
|
596
568
|
|
|
597
|
-
|
|
569
|
+
CollectPaymentIntentConfiguration collectConfig = new CollectPaymentIntentConfiguration.Builder()
|
|
598
570
|
.updatePaymentIntent(updatePaymentIntent)
|
|
599
571
|
.build();
|
|
600
572
|
|
|
@@ -667,11 +639,11 @@ public class StripeTerminal
|
|
|
667
639
|
}
|
|
668
640
|
|
|
669
641
|
@PluginMethod
|
|
670
|
-
public void
|
|
642
|
+
public void confirmPaymentIntent(final PluginCall call) {
|
|
671
643
|
if (currentPaymentIntent != null) {
|
|
672
644
|
Terminal
|
|
673
645
|
.getInstance()
|
|
674
|
-
.
|
|
646
|
+
.confirmPaymentIntent(
|
|
675
647
|
currentPaymentIntent,
|
|
676
648
|
new PaymentIntentCallback() {
|
|
677
649
|
@Override
|
|
@@ -691,7 +663,25 @@ public class StripeTerminal
|
|
|
691
663
|
|
|
692
664
|
@Override
|
|
693
665
|
public void onFailure(@NonNull TerminalException e) {
|
|
694
|
-
|
|
666
|
+
JSObject data = new JSObject();
|
|
667
|
+
|
|
668
|
+
PaymentIntent failedIntent = e.getPaymentIntent();
|
|
669
|
+
if (failedIntent != null) {
|
|
670
|
+
data.put(
|
|
671
|
+
"payment_intent",
|
|
672
|
+
TerminalUtils.serializePaymentIntent(failedIntent, lastCurrency)
|
|
673
|
+
);
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
ApiError apiError = e.getApiError();
|
|
677
|
+
if (apiError != null) {
|
|
678
|
+
String declineCode = apiError.getDeclineCode();
|
|
679
|
+
if (declineCode != null) {
|
|
680
|
+
data.put("decline_code", declineCode);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
call.reject(e.getErrorMessage(), e.getErrorCode().toString(), e, data);
|
|
695
685
|
}
|
|
696
686
|
}
|
|
697
687
|
);
|
|
@@ -903,7 +893,12 @@ public class StripeTerminal
|
|
|
903
893
|
|
|
904
894
|
SimulatorConfiguration newConfig = new SimulatorConfiguration(
|
|
905
895
|
availableReaderUpdate,
|
|
906
|
-
simulatedCard
|
|
896
|
+
simulatedCard,
|
|
897
|
+
null,
|
|
898
|
+
false,
|
|
899
|
+
new SimulatedCollectInputsResult.SimulatedCollectInputsResultSucceeded(
|
|
900
|
+
SimulatedCollectInputsSkipBehavior.NONE
|
|
901
|
+
)
|
|
907
902
|
);
|
|
908
903
|
|
|
909
904
|
Terminal.getInstance().setSimulatorConfiguration(newConfig);
|
|
@@ -981,10 +976,8 @@ public class StripeTerminal
|
|
|
981
976
|
}
|
|
982
977
|
|
|
983
978
|
@Override
|
|
984
|
-
public void
|
|
985
|
-
|
|
986
|
-
ret.put("reader", TerminalUtils.serializeReader(reader));
|
|
987
|
-
notifyListeners("didReportUnexpectedReaderDisconnect", ret);
|
|
979
|
+
public void onDisconnect(@NonNull DisconnectReason reason) {
|
|
980
|
+
notifyListeners("didReportUnexpectedReaderDisconnect", new JSObject());
|
|
988
981
|
}
|
|
989
982
|
|
|
990
983
|
@Override
|
|
@@ -1095,13 +1088,17 @@ public class StripeTerminal
|
|
|
1095
1088
|
}
|
|
1096
1089
|
|
|
1097
1090
|
@Override
|
|
1098
|
-
public void onReaderReconnectStarted(
|
|
1091
|
+
public void onReaderReconnectStarted(
|
|
1092
|
+
@NonNull Reader reader,
|
|
1093
|
+
@NonNull Cancelable cancelReconnect,
|
|
1094
|
+
@NonNull DisconnectReason reason
|
|
1095
|
+
) {
|
|
1099
1096
|
pendingReaderAutoReconnect = cancelReconnect;
|
|
1100
1097
|
notifyListeners("didStartReaderReconnect", null);
|
|
1101
1098
|
}
|
|
1102
1099
|
|
|
1103
1100
|
@Override
|
|
1104
|
-
public void onReaderReconnectSucceeded() {
|
|
1101
|
+
public void onReaderReconnectSucceeded(@NonNull Reader reader) {
|
|
1105
1102
|
pendingReaderAutoReconnect = null;
|
|
1106
1103
|
notifyListeners("didSucceedReaderReconnect", null);
|
|
1107
1104
|
}
|