Offline Payment

Vipaso SDK provides the ability to conduct payments without internet connection.

This feature is experimental

Introduction

Offline payments enable merchants and customers to complete transactions when neither merchant (POS) nor customer (Pay) has an internet connection.

The Vipaso SDK implements offline payments through a pre-authorization mechanism, allowing customers to allocate funds for offline use while they have internet connectivity.

Overview

Pre-authorization

For customers to make payments without an internet connection, they must have a pre-authorized balance on their payment instrument. Pre-authorization is a process where customers allocate a specific amount of funds while online that can later be spent when offline.

A pre-authorized instrument is required before any offline payment can be processed. Without this pre-authorization, offline payments will not be possible.

To implement pre-authorization in your application:

// Create a pre-authorization request
try {
  	// Create a Pre-authorization request with the user custom amount and the ID of the 
  	// instrument which you like to allocate the amount to.
    val request = PreAuthorizationRequest(
        instrumentId = instrumentId,
        amount = amount,
        currency = currency
    )
    
    // Pre-authorize the instrument
    val authorization = vipasoPay.instrument.preAuthorizeInstrument(request)
    
    // Handle successful pre-authorization
    handleSuccessfulPreAuth(authorization)
} catch (e: Throwable) {
    // Handle pre-authorization error
    Log.e("OfflinePayment", "Error pre-authorizing instrument: ${e.message}")
}

Example screenshots from our development application:

Offline Payment Flow

For payment setup and processing, please refer to the Online Payment Use Case, as the flow is the same. The primary difference is that the payer requires a pre-authorization for offline payments, where neither party has internet access.

Automatic Synchronization

In Android, the Vipaso SDK handles offline payment synchronization automatically. When the Pay or POS app reconnects to the internet after being offline, the SDK will detect this state change and automatically synchronize any locally stored offline payments with the backend.

After synchronization, you can fetch your payment details by calling fetchPayments or fetchPayment:

try {
    val payments = vipasoPay.payment.fetchPayments()
    // Process the payments list, which will include previously offline payments
    processPayments(payments)
} catch (e: Throwable) {
    // Handle error fetching payments
    Log.e("OfflinePayment", "Error fetching payments: ${e.message}")
}