调至内容部分
创建账户
或
登录
Stripe 文档徽标
/
询问人工智能
创建账户
登录
开始
付款
销售收入
平台和交易市场
资金管理
开发人员资源
概览
关于 Stripe 支付
升级您的集成
支付分析
线上付款
概览查找您的用例Managed Payments
使用 Payment Link
构建结账页面
构建高级集成
构建应用内集成
支付方式
添加支付方式
管理支付方式
用 Link 更快结账
支付接口
Payment Links
结账
Web Elements
应用内 Element
支付场景
处理多种货币
自定义支付流程
灵活收单
编排
线下支付
Terminal
    概览
    接受线下付款
    集成设计
    选择读卡器
    设计集成
    快速开始
    示例应用
    测试
    Terminal 设置
    设置您的集成
    连接读卡器
      网络要求
    接受付款
    收取银行卡付款
    其他支付方式
    支持线下支付
    邮购和电话订购付款
    地区考虑因素
    结账过程中
    收取小费
    收集并保存付款详情以供将来使用
    灵活授权
    结账后
    退款交易
    提供收据
    自定义 Checkout
    购物车显示
    收集屏幕输入内容
    收集刷卡数据
    收集 NFC 设备的轻触数据
    设备上的应用程序
    管理读卡器
    订购、退回、更换读卡器
    注册读卡器
    管理位置和区域
    配置读卡器
    监控读卡器
    加密
    参考
    API 参考
    移动读卡器
    智能读卡器
    SDK 迁移指南
    部署检查表
    Stripe Terminal 读卡器产品表
超越支付功能
成立公司
加密货币
Financial Connections
Climate
了解欺诈
Radar 欺诈保护
管理争议
验证身份
首页付款Terminal

Connect to a reader

Connect your application to a Stripe Terminal reader.

注意

If you haven’t chosen a reader yet, compare the available Terminal readers and choose one that best suits your needs.

Smart readers run Stripe reader software to communicate directly with Stripe over the internet. Connecting your app to a smart reader requires three steps:

  1. Register a reader to your Stripe account.
  2. Discover readers with the SDK.
  3. Connect to a reader with the SDK.

Register a reader
Server-side

Before you can connect your application to a smart reader, you must register the reader to your account.

Register in the Dashboard

You can add your reader directly in the Dashboard.

Register by registration code

  1. In the Readers page, click Register reader.
  2. If you have a Verifone P400, enter the key sequence 0-7-1-3-9 to display a unique registration code. If you have a BBPOS WisePOS E or Stripe Reader S700, go to the reader settings and tap Generate pairing code.
  3. Enter the registration code then click Next.
  4. Optionally, choose a name for the reader.
  5. If you already created a Location, select the reader’s new Location. Otherwise, create a Location by clicking + Add new.
  6. Click Register to finish registering your reader.

Register by serial number

  1. In the Readers page, click Register reader.
  2. Find the serial number on the device and enter the serial number. To register multiple devices at once, you can enter multiple serial numbers separated by commas.
  3. Optionally, choose a name for the reader.
  4. If you already created a Location, select the reader’s new Location. Otherwise, create a Location by clicking + Add new.
  5. Click Register to finish registering your reader.

Register by hardware order

  1. In the Hardware orders page, find an order with a status of either “shipped” or “delivered.” Click the overflow menu () at the end of the row, then click Register.
  2. On the Register Readers page, select one or more readers from the hardware order to register, then click Register.
  3. Optionally, choose a name for the reader. If you selected multiple readers, the name serves as a prefix and we name the readers sequentially (for example, for a given input of “Test reader”, we name the readers “Test reader 1”, “Test reader 2”, and so on).
  4. If you already created a Location, select the reader’s new Location. Otherwise, create a Location by clicking + Add new.
  5. Click Register to finish registering your readers.

Register using the API

For larger deployments, enable users in the field to receive and set up new readers on their own. In your app, build a flow to register a reader with the Stripe API.

  1. If you have a Verifone P400, enter the key sequence 0-7-1-3-9 to display a unique registration code. If you have a BBPOS WisePOS E or Stripe Reader S700, go to the reader settings and tap Generate pairing code.
  2. The user enters the code in your application.
  3. Your application sends the code to Stripe:
Command Line
cURL
Stripe CLI
Ruby
Python
PHP
Java
Node
Go
.NET
No results
curl https://api.stripe.com/v1/terminal/readers \ -u "
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:"
\ -d registration_code={{READER_REGISTRATION_CODE}} \ --data-urlencode label="Alice's reader" \ -d location=
{{LOCATION_ID}}

To confirm that you’ve registered a reader correctly, list all the readers you’ve registered at that location:

Command Line
curl
Ruby
Python
PHP
Java
Node
Go
.NET
No results
curl https://api.stripe.com/v1/terminal/readers \ -u
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:

Discover readers
Client-side

SDK Reference

  • discoverReaders (iOS)
  • InternetDiscoveryConfiguration (iOS)

After registering the reader to your account, search for previously registered readers to connect to your point of sale application with discoverReaders, using InternetDiscoveryConfiguration.

You can scope your discovery using the location you registered the reader to in the previous step.

DiscoverReadersViewController.swift
Swift
Objective C
No results
import StripeTerminal class DiscoverReadersViewController: UIViewController, DiscoveryDelegate { func discoverReadersAction() throws { let config = try InternetDiscoveryConfigurationBuilder() .setLocationId(
"{{LOCATION_ID}}"
) .build() self.discoverCancelable = Terminal.shared.discoverReaders(config, delegate: self) { error in if let error = error { print("discoverReaders failed: \(error)") } else { print("discoverReaders succeeded") } } } }

When discovering smart readers, the DiscoveryDelegate.didUpdateDiscoveredReaders method is only called once per call to discoverReaders. didUpdateDiscoveredReaders returns an empty list of readers if there are no registered readers or if there are no readers associated with the given location. If you make a subsequent discoverReaders call to refresh the list, you must first cancel the previous call with the Cancelable returned by discoverReaders.

The InternetDiscoveryConfiguration supports an optional timeout value for discovering readers online. This ensures quicker fallback to offline reader discovery if the online attempt fails.

Connect to a reader
Client-side

To connect your point of sale application to a reader, call connectReader with the selected reader, using the InternetConnectionConfiguration.

ConnectReaderViewController.swift
Swift
Objective C
No results
let config: InternetConnectionConfiguration do { config = try InternetConnectionConfigurationBuilder(delegate: yourInternetReaderDelegate) .build() } catch { // Handle error building the connection configuration return } Terminal.shared.connectReader(selectedReader, connectionConfig: config) { reader, error in if let reader = reader { print("Successfully connected to reader: \(reader)") } else if let error = error { print("connectReader failed: \(error)") } }

SDK Reference

  • connectReader (iOS)
  • InternetConnectionConfiguration

Multiple connections

Only one instance of the Stripe Terminal SDK can connect to a reader at a given time. By default, when you call connectReader from another application, the incoming connection replaces the existing SDK-to-reader connection, and the previously connected SDK disconnects from the reader. The connectReader method takes a configuration object with a failIfInUse property, whose default value is false. When your application sets failIfInUse to true, the connectReader call has an alternate behavior where the incoming connection fails when the reader is in the middle of a collectPaymentMethod or confirmPaymentIntent call initiated by another SDK. If the reader is connected to another SDK but is idle (displaying the splash screen before collectPaymentMethod is called), setting failIfInUse has no change to the connection behavior, and the incoming connection request can always break the existing SDK-to-reader connection.

ConnectReaderViewController.swift
Swift
Objective-C
No results
let internetReaderDelegate = yourInternetReaderDelegate // implement your internetReaderDelegate let config: InternetConnectionConfiguration do { config = try InternetConnectionConfigurationBuilder(delegate: internetReaderDelegate) .setFailIfInUse(true) .build() } catch { // Handle error building the connection configuration return } Terminal.shared.connectReader(selectedReader, connectionConfig: config, completion: { reader, error in // ... })
failIfInUse is false (default)failIfInUse is true
connectReader called from a new SDK when the reader is idle.The existing SDK-to-reader connection breaks, and the new SDK connects to the reader. The next command from the previously-connected SDK fails with a reader error, and that app’s didDisconnect method is called.The existing SDK-to-reader connection breaks, and the new SDK connects to the reader. The next command from the previously-connected SDK fails with a reader error, and that app’s didDisconnect method is called.
connectReader called from a new SDK when the reader is mid-transaction.The existing SDK-to-reader connection breaks, and the new SDK connects to the reader. The next command from the previously-connected SDK fails with a reader error, and that app’s didDisconnect method is called.The incoming connection fails with a reader error. The existing SDK-to-reader connection doesn’t break and the command in progress continues.

For the least-disruptive connection experience in multi-reader environments, we recommend setting failIfInUse to true on your application’s initial connection attempt. Then, allow your users to retry the connection with failIfInUse set to false if the connection fails the first time.

With this setup, one of your users can’t accidentally interrupt a transaction by inadvertently connecting to an in-use reader, but can still connect if needed.

Handle disconnects

SDK Reference

  • didDisconnect (iOS)

Your app must implement the reader(_, didDisconnect:) callback to handle when a reader disconnects. When you implement this callback, display a UI that notifies your user of the disconnected reader. You can call discoverReaders to scan for readers and initiate reconnection.

Your app can attempt to automatically reconnect to the disconnected reader or display a UI that prompts your user to reconnect to a different reader.

The reader can disconnect from your app if it loses connection to the network. To simulate an unexpected disconnect, power off the reader.

ReaderViewController.swift
Swift
Objective-C
No results
import StripeTerminal class ReaderViewController: UIViewController, InternetReaderDelegate { override func viewDidLoad() { super.viewDidLoad() // Set the reader delegate when connecting to a reader } // ... func reader(_ reader: Reader, didDisconnect reason: DisconnectReason) { // Consider displaying a UI to notify the user and start rediscovering readers } }

Automatic reconnection

Stripe Terminal doesn’t automatically reconnect to a reader when your application starts. Instead, you can build a reconnection flow by storing reader IDs and attempting to connect to a known reader on startup.

  1. When you successfully connect to a reader, save its serial number in a persistent data storage location, such as the UserDefaults API (iOS)
  2. When your app launches, check that persistent store for a saved serial number. If one is found, call the discoverReaders method so your application can try to find that reader again.
  3. If the saved serial number matches any of the discovered readers, try connecting to that reader with the matching reader object returned from the call to discoverReaders. If the previously connected reader isn’t found, stop the discovery process.

Display some UI during the discovery and connection process to indicate that an automatic reconnection is taking place.

Next steps

You’ve connected your application to the reader. Next, collect your first Stripe Terminal payment.

The BBPOS and Chipper™ name and logo are trademarks or registered trademarks of BBPOS Limited in the United States or other countries. The Verifone® name and logo are either trademarks or registered trademarks of Verifone in the United States and/or other countries. Use of the trademarks doesn’t imply any endorsement by BBPOS or Verifone.

此页面的内容有帮助吗?
是否
  • 需要帮助?联系支持。
  • 加入我们的早期使用计划。
  • 查看我们的更改日志。
  • 有问题?联系销售。
  • LLM? Read llms.txt.
  • Powered by Markdoc