Collect payments while offlineBeta
The Terminal SDK allows your application to continue collecting payments using a smart reader without an Internet connection.
You still need a functioning local network to allow your POS device to communicate with the smart reader. Operating offline with smart readers is intended for scenarios where your POS and reader can’t communicate with Stripe, such as during an ISP outage. If you need to be able to operate offline without a local network, consider Stripe Terminal’s mobile readers.
Warning
When operating offline, payment information is collected at the time of sale, and authorization is only attempted after connectivity is restored and the payment is forwarded. You, as the user, assume all decline risk of the transaction. If the issuer declines the offline transaction, there’s no way to recover the funds, and you might not receive payment from the customer for goods or services already provided.
To reduce the chances of an issuer decline, you’re encouraged to:
- Reestablish internet connectivity as soon as possible to record the payments to Stripe.
- Restrict transactions if they exceed a certain amount.
- Fail all offline payments if the SDK has stored a set of transactions whose sum exceeds a certain amount.
Collect payments while offline
Offline payments follow the same steps as online payments: create, collect, process, and capture the payment. Your device can transition from online to offline at any step in the process.
- Enable offline mode
- Connect to a reader while offline
- Handle offline events
- Create a PaymentIntent while offline
- Collect a payment method
- Confirm the payment
- Wait for payments to forward
- Capture the payment
- Examine offline payments
Enable offline mode
Note
The offline mode feature is in private beta. To request access, please email stripe-terminal-betas@stripe.com. After we enable the changes for your account and you’ve enabled the feature using the Configuration API, you must disconnect and reconnect to your reader using the SDK for the updated configuration to take effect.
To use offline mode, your application needs to consume version 3.2.0 or later of the Terminal SDK.
Use a Configuration object to enable offline mode for the BBPOS WisePOS E. devices at your Location
.
After you’ve enabled offline mode on a Configuration
object you can assign it to a Location
. You can also enable offline mode by default for all Locations
by updating the default Configuration
object for your account. Configuration API changes can take several minutes to propagate to your SDK and reader, and require you to disconnect from and reconnect to your reader to take effect.
Connect to a reader while offline
To collect payments with a smart reader while offline, you must have previously connected to that reader at the same Location
while online, on the same local network, within the last 30 days. The reader stores the Location
information locally after connecting online, and it derives configuration information from that Location
while operating offline.
Your reader and POS device must be on the same local network used to connect online. You can’t switch networks while offline.
Handle offline eventsClient-side
Implement the OfflineDelegate
protocol and pass it to Terminal to notify your application of offline-related events. You must set the OfflineDelegate
before collecting payments while offline.
Create a PaymentIntent while offlineClient-side
To support operating offline, you must use the SDK’s createPaymentIntent
to create PaymentIntent objects.
While operating offline, PaymentIntent
objects have a null stripeId
. We recommend you add a custom identifier to the PaymentIntent’s metadata to help reconcile PaymentIntent
objects created offline. Within your OfflineDelegate.didForwardPaymentIntent
, you can use your identifier to correlate offline payments with payments that are successfully forwarded to Stripe.
Managing risk while offline
The Terminal.createPaymentIntent
accepts a new parameter of type CreateConfiguration
. By default, if you’re operating offline, all offline payments are stored and forwarded to Stripe’s backend when connectivity is restored. You can pass a CreateConfiguration
object with offlineBehavior
set to REQUIRE_ONLINE
to fail the current transaction if you’re operating offline. You might want to disallow transactions above a certain amount or disallow all offline transactions if the reader has stored a set of transactions whose sum exceeds a certain amount (see Terminal.offlineStatus.reader.offlinePaymentAmountsByCurrency
).
The SDK exposes two properties to help you manage risk:
Terminal.offlineStatus.reader.offlinePaymentsCount
Terminal.offlineStatus.reader.offlinePaymentAmountsByCurrency
Managing latency while offline
By default, the Terminal SDK automatically determines whether to collect payments online or offline based on your network connectivity. However, you might want to operate offline despite having an active network connection – for example, if you need to collect transactions quickly and your network connection is slow. You can pass a CreateConfiguration
object with offlineBehavior
set to FORCE_OFFLINE
to collect the payment offline regardless of connectivity. Note that payments collected offline while the Terminal SDK has an active network connection are forwarded in the background.
Collect a payment methodClient-side
Swiping cards isn’t supported while offline. Tapping cards is also not supported in markets where Strong Customer Authentication is required. Your smart reader automatically displays the available payment options to the customer.
Note
Payment liability is your responsibility when operating your reader offline. Because magnetic stripe data is easy to spoof, Stripe disallows this option while operating offline.
Confirm paymentClient-side
This step is similar to processing payments while online. The primary difference is that your integration must handle offline-specific error cases, such as when the transaction exceeds the Stripe-enforced offline maximum of 10,000 USD or equivalent in your operating currency.
Providing receipts
You might require information about the card used to complete a payment while offline. For example, you might need to generate a receipt for customers who require one at the time of purchase.
If the PaymentIntent is processed offline, you can retrieve its OfflineCardPresentDetails from the paymentIntent.offlineDetails.offlineCardPresentDetails
property.
This hash contains a ReceiptDetails property you can use to generate a receipt, as well as other card details like the cardholder name and card brand.
Not all receipt details are available while operating offline. Prebuilt email receipts are only sent after connectivity is restored and the payment is successfully captured.
Wait for payments to forwardClient-side
When network connectivity is restored, the reader automatically begins forwarding the stored offline payments.
If you disconnect or power off your smart reader too soon, your payments might not be forwarded. You can query Terminal.offlineStatus.reader.networkStatus
to make sure your reader is online and can forward payments, and Terminal.offlineStatus.reader.offlinePaymentsCount
to check how many payments remain to be forwarded.
If your smart reader becomes damaged or otherwise unable to take payments, your stored payments can often still be forwarded. Make sure to connect the smart reader to your POS and re-establish Internet access to allow it to re-connect to Stripe.
Capture payment
Note
While offline, you can create PaymentIntents with capture_method
set to automatic
. Once confirmed, these PaymentIntents have a successful
status instead of requires_capture
. They’re captured automatically upon forwarding.
Payments that are successfully forwarded and authorized require capture from your backend or application:
- To capture payments from your backend, use webhooks to listen for PaymentIntents with a
requires_capture
status. - To capture payments from your application, wait for calls to your
OfflineDelegate.didForwardPayment
for each PaymentIntent as it’s forwarded. A PaymentIntent is ready to capture if its status isrequires_capture
.
If your application determines when to capture a PaymentIntent after confirmPaymentIntent
, they’re ready to capture when the status is requires_capture
, and the offlineDetails
is null or has a requiresUpload
of NO
.
Capture a payment after confirmPaymentIntent
, if it’s processed online:
Capture an offline payment after it’s been forwarded in your OfflineDelegate’s didForwardPaymentIntent
:
Examine payments collected offline
After authorization, you can use the PaymentIntents API to examine offline details on a payment. Access the payment method details on the latest Charge object on a PaymentIntent
to determine if it was collected offline.