capacitor-stripe-terminal 5.0.0 → 6.0.0-beta.1

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/Package.swift CHANGED
@@ -3,7 +3,7 @@ import PackageDescription
3
3
 
4
4
  let package = Package(
5
5
  name: "CapacitorStripeTerminal",
6
- platforms: [.iOS(.v15)],
6
+ platforms: [.iOS(.v16)],
7
7
  products: [
8
8
  .library(
9
9
  name: "CapacitorStripeTerminal",
@@ -11,7 +11,7 @@ let package = Package(
11
11
  ],
12
12
  dependencies: [
13
13
  .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.0"),
14
- .package(url: "https://github.com/stripe/stripe-terminal-ios.git", exact: "5.8.0")
14
+ .package(url: "https://github.com/stripe/stripe-terminal-ios-spm.git", exact: "6.0.0")
15
15
  ],
16
16
  targets: [
17
17
  .target(
@@ -19,7 +19,7 @@ let package = Package(
19
19
  dependencies: [
20
20
  .product(name: "Capacitor", package: "capacitor-swift-pm"),
21
21
  .product(name: "Cordova", package: "capacitor-swift-pm"),
22
- .product(name: "StripeTerminal", package: "stripe-terminal-ios")
22
+ .product(name: "StripeTerminal", package: "stripe-terminal-ios-spm")
23
23
  ],
24
24
  path: "ios/Sources/StripeTerminalPlugin"),
25
25
  .testTarget(
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
  <h3 align="center">Capacitor Stripe Terminal</h3>
3
3
  <p align="center"><strong><code>capacitor-stripe-terminal</code></strong></p>
4
4
  <p align="center">
5
- Capacitor plugin for <a href="https://stripe.com/terminal">Stripe Terminal</a> (unofficial)
5
+ Accept in-person card payments in your Capacitor app with <a href="https://stripe.com/terminal">Stripe Terminal</a> (unofficial)
6
6
  </p>
7
7
 
8
8
  <p align="center">
@@ -17,172 +17,81 @@
17
17
  <!-- ALL-CONTRIBUTORS-BADGE:END -->
18
18
  </p>
19
19
 
20
- ## Requirements
20
+ <p align="center">
21
+ <a href="https://eventonehq.github.io/capacitor-stripe-terminal/"><strong>Documentation</strong></a> ·
22
+ <a href="https://eventonehq.github.io/capacitor-stripe-terminal/getting-started/quickstart/">Quickstart</a> ·
23
+ <a href="https://eventonehq.github.io/capacitor-stripe-terminal/api/">API Reference</a> ·
24
+ <a href="https://eventonehq.github.io/capacitor-stripe-terminal/migration/">Migration Guides</a>
25
+ </p>
21
26
 
22
- - **Capacitor**: 8.x
23
- - **Stripe Terminal SDK**:
24
- - iOS: 5.8.0 (requires iOS 15.0+)
25
- - Android: 5.8.1 (requires Android API 23+)
27
+ ## Features
26
28
 
27
- > **📝 Upgrading from an earlier version?** See the [Migration Guide](MIGRATION_V5.md) for details on breaking changes and upgrade instructions.
29
+ - **iOS, Android and web** from one TypeScript API, built on the native Stripe Terminal SDKs and `@stripe/terminal-js`.
30
+ - **Every reader type**: Bluetooth, internet (WisePOS E, Stripe S700), USB, Tap to Pay and [Apps on Devices](https://eventonehq.github.io/capacitor-stripe-terminal/guides/apps-on-devices/).
31
+ - **Bluetooth + internet discovery at once** with the plugin-only `both` mode.
32
+ - **Payments, refunds, SetupIntents, offline payments, on-reader forms and printing**.
33
+ - **Consistent across platforms**.
28
34
 
29
- ## Maintainers
30
-
31
- | Maintainer | GitHub | Social |
32
- | ---------- | ----------------------------------- | ------------------------------------------- |
33
- | Noah Prail | [nprail](https://github.com/nprail) | [@NoahPrail](https://twitter.com/NoahPrail) |
35
+ ## Requirements
34
36
 
35
- ## Installation
37
+ | Component | Version |
38
+ | --------------------------- | --------------------------------- |
39
+ | Capacitor | 8.x |
40
+ | Stripe Terminal iOS SDK | 6.0.0 (iOS 16.0+) |
41
+ | Stripe Terminal Android SDK | 6.0.0 (API 23+, `compileSdk` 35+) |
36
42
 
37
- Using npm:
43
+ ## Install
38
44
 
39
45
  ```bash
40
46
  npm install capacitor-stripe-terminal
41
- ```
42
-
43
- Using yarn:
44
-
45
- ```bash
46
- yarn add capacitor-stripe-terminal
47
- ```
48
-
49
- Sync native files:
50
-
51
- ```bash
52
47
  npx cap sync
53
48
  ```
54
49
 
55
- ## Configuration
56
-
57
- ### iOS
58
-
59
- Follow all Stripe instructions under ["Configure your app"](https://stripe.com/docs/terminal/sdk/ios#configure).
60
-
61
- ### Android
62
-
63
- Add the `ACCESS_FINE_LOCATION` permission to your app's manifest:
64
-
65
- ```xml
66
- <?xml version="1.0" encoding="utf-8"?>
67
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
68
- xmlns:tools="http://schemas.android.com/tools"
69
- package="com.stripe.example.app">
70
-
71
- <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
72
- </manifest>
73
- ```
74
-
75
- On Android, you must also make sure that Location permission has been granted by the user:
76
-
77
- ```javascript
78
- if (Capacitor.getPlatform() === 'android') {
79
- // check if permission is required
80
- let response = await StripeTerminalPlugin.checkPermissions();
81
-
82
- if (response.location === 'prompt') {
83
- // if it is required, request it
84
- response = await StripeTerminalPlugin.requestPermissions();
85
-
86
- if (response.location !== 'granted') {
87
- // if the request fails, show a message to the user
88
- throw new Error('Location permission is required.')
89
- }
90
- }
91
- }
92
-
93
- const terminal = await StripeTerminalPlugin.create({ ... })
94
- ```
95
-
96
- If the user does not grant permission, `StripeTerminalPlugin` will throw an error when you try to initialize it so you will have to handle that.
97
-
98
- _Hint: If the user denies Location permission the first time you ask for it, Android will not display a prompt to the user on subsequent requests for permission and `response` will always be `denied`. You will have to ask the user to go into the app's settings to allow Location permission._
50
+ Then follow the [installation guide](https://eventonehq.github.io/capacitor-stripe-terminal/getting-started/installation/) to configure iOS, Android and location permissions.
99
51
 
100
52
  ## Usage
101
53
 
102
- ```javascript
103
- import {
104
- StripeTerminalPlugin,
105
- StripeTerminalError,
106
- DiscoveryMethod,
107
- } from 'capacitor-stripe-terminal'
54
+ ```ts
55
+ import { StripeTerminalPlugin } from 'capacitor-stripe-terminal'
108
56
 
109
- // First, initialize the SDK
110
57
  const terminal = await StripeTerminalPlugin.create({
111
58
  fetchConnectionToken: async () => {
112
59
  const resp = await fetch('https://your-backend.dev/token', {
113
60
  method: 'POST',
114
61
  })
115
- const data = await resp.json()
116
-
117
- return data.secret
62
+ return (await resp.json()).secret
118
63
  },
119
64
  onUnexpectedReaderDisconnect: () => {
120
- // handle reader disconnect
65
+ // the reader disconnected unexpectedly
121
66
  },
122
67
  })
123
68
 
124
- // Start scanning for readers
125
- // To stop scanning, call handle.remove() on the returned handle.
126
- // You must connect to a reader while scanning
127
- const discoverHandle = await terminal.discoverReaders(
128
- {
129
- simulated: false,
130
- discoveryMethod: DiscoveryMethod.BluetoothScan,
131
- },
132
- (readers) => {
133
- if (readers.length) {
134
- const selectedReader = readers[0]
135
- const connectionConfig = {
136
- locationId: '{{LOCATION_ID}}',
137
- }
138
- terminal
139
- .connectBluetoothReader(selectedReader, connectionConfig)
140
- .then((connectedReader) => {
141
- // the reader is now connected and usable
142
- })
143
- }
144
- },
145
- (error) => {
146
- console.error('discoverReaders error', error)
147
- },
148
- )
69
+ // discover and connect to a reader first, see the quickstart
70
+
71
+ await terminal.retrievePaymentIntent('{CLIENT_SECRET}')
72
+ await terminal.collectPaymentMethod()
73
+ await terminal.confirmPaymentIntent()
74
+ ```
149
75
 
150
- // Once the reader is connected, collect a payment intent!
76
+ The [quickstart](https://eventonehq.github.io/capacitor-stripe-terminal/getting-started/quickstart/) walks through reader discovery, connection and error handling.
151
77
 
152
- // listen to user instructions - these should be displayed to the user
153
- const displayHandle = await terminal.didRequestReaderDisplayMessage(
154
- (displayMessage) => {
155
- console.log('displayMessage', displayMessage)
156
- },
157
- )
158
- const inputHandle = await terminal.didRequestReaderInput((inputOptions) => {
159
- console.log('inputOptions', inputOptions)
160
- })
78
+ ## Coming from Stripe's SDKs?
161
79
 
162
- // retrieve the payment intent
163
- await terminal.retrievePaymentIntent('your client secret created server side')
80
+ The plugin follows Stripe's API closely, so the [Stripe Terminal docs](https://docs.stripe.com/terminal) still apply. The docs here only cover what's different, starting with [Differences from Stripe's SDKs](https://eventonehq.github.io/capacitor-stripe-terminal/guides/differences-from-stripe/) and the [platform support matrix](https://eventonehq.github.io/capacitor-stripe-terminal/guides/platform-support/).
164
81
 
165
- // collect the payment method
166
- await terminal.collectPaymentMethod()
82
+ ## Upgrading
167
83
 
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
- }
178
-
179
- // once you are done, call destroy() to remove all listeners and reset the plugin (e.g. in ngOnDestroy)
180
- await terminal.destroy()
181
- ```
84
+ See the [migration guides](https://eventonehq.github.io/capacitor-stripe-terminal/migration/): [v5 to v6](https://eventonehq.github.io/capacitor-stripe-terminal/migration/v6/) and [v3 to v5](https://eventonehq.github.io/capacitor-stripe-terminal/migration/v5/).
182
85
 
183
- ## API Reference
86
+ ## Contributing
184
87
 
185
- See the full API docs [here](https://oss.eventone.page/capacitor-stripe-terminal).
88
+ Issues and pull requests are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md). Docs live in [`docs/`](docs) and preview with `npm run docs:dev`.
89
+
90
+ ## Maintainers
91
+
92
+ | Maintainer | GitHub | Social |
93
+ | ---------- | ----------------------------------- | ------------------------------------------- |
94
+ | Noah Prail | [nprail](https://github.com/nprail) | [@NoahPrail](https://twitter.com/NoahPrail) |
186
95
 
187
96
  ## Sponsors
188
97
 
@@ -58,7 +58,8 @@ dependencies {
58
58
  testImplementation "junit:junit:$junitVersion"
59
59
  androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
60
60
  androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
61
- implementation "com.stripe:stripeterminal-core:5.8.1"
62
- implementation "com.stripe:stripeterminal-taptopay:5.8.1"
61
+ implementation "com.stripe:stripeterminal-core:6.0.0"
62
+ implementation "com.stripe:stripeterminal-taptopay:6.0.0"
63
+ implementation "com.stripe:stripeterminal-appsondevices:6.0.0"
63
64
  implementation "com.google.code.gson:gson:2.8.8"
64
65
  }
@@ -4,5 +4,7 @@
4
4
  <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
5
5
  <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
6
6
  <uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
7
+ <!-- Required by Stripe Terminal 6.0+ Tap to Pay so payment audio is not muted -->
8
+ <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
7
9
  </manifest>
8
10