Offline payments
The Clover Go SDK does not support offline payments (Store and Forward). The SDK requires an active network connection to process transactions.
Although offline payments are not supported, you must handle scenarios where the device loses connectivity. To provide a smooth user experience, the SDK includes a ReachabilityService that monitors the host device's network status.
This allows your app to detect connection issues immediately and prevent transaction attempts that are destined to fail.
Understand offline behavior
If a transaction is initiated without a viable network connection, the SDK returns a CloverGenericError.offline error.
This error occurs when:
- The host device is offline: The iOS device (iPad or iPhone) has lost its Wi-Fi or cellular connection.
- Clover servers are unreachable: The ping response indicates that the configured payment servers (such as
c.clover.com) are unavailable.
By failing immediately, the SDK prevents the merchant and customer from waiting for network timeouts, which can take several minutes.
Monitor network reachability
You should monitor the reachability status of the SDK and inform the merchant if payments cannot be processed.
Use the ReachabilityService to check the current state or subscribe to status updates.
Check current status
Use currentReachability to get a snapshot of the SDK's connection to Clover servers.
/// Returns the current reachability for the SDK
/// - Returns: ReachabilityState reflecting the reachability of the SDK to Clover servers.
public var currentReachability: ReachabilityService.State {
return ReachabilityService.currentReachability
}
Subscribe to status updates
The following example demonstrates how to subscribe to the reachability publisher and update a UI label based on the network status.
func setReachability() {
self.networkLabel.text = "Network Status: \(CloverPaymentSDK.shared.currentReachability.rawValue.capitalized)"
switch CloverPaymentSDK.shared.currentReachability {
case .offline:
TestLogger.shared.log("🔴 Network Status: Offline")
// Add logic here to alert the merchant (Example: Disable the Charge button)
case .online:
TestLogger.shared.log("🟢 Network Status: Online")
@unknown default:
TestLogger.shared.log("🟣 Network Status: Unknown")
}
}
// Subscribe to the publisher on the main run loop
reachability = ReachabilityService.publisher
.subscribe(on: RunLoop.main)
.receive(on: RunLoop.main)
.sink(receiveValue: { value in
setReachability()
})
// Initial check
setReachability()
Updated about 3 hours ago
