1. Initialization
Initialize the SDK in your Application’sonCreate method. This only needs to be done once when your application starts. The SDK uses a singleton pattern for all interactions.
2. Configuration
You can configure the SDK instance after initialization.2.1. Log Level
The SDK provides three log levels:TransactBridge.LogLevel.VERBOSE: Logs all messages.TransactBridge.LogLevel.ERROR: Logs only error messages. This is the default.TransactBridge.LogLevel.NONE: Disables all logging.
2.2. Auto Close
By default, the checkout view will close automatically when the flow is complete. You can disable this behavior globally:Builder.
3. Usage
To start a checkout session, create aTransactBridge.Builder to configure listeners and session-specific settings. Then, call the open() method on the TransactBridge singleton instance.
4. Event Handling
The SDK uses listeners to notify your application of events for a specific session.4.1. TransactionListener
onTxnData(TransactionData transactionData): Called with transaction details.
4.2. SessionListener
onSessionData(SessionData sessionData): Called for session-related events.
4.3. CloseListener
onClose(): Called when the sdk is closed.
4.4. TransactBridgeErrorListener
onError(int errorCode, String message, @Nullable Bundle extras): Called when an error occurs.
errorCode provides a specific reason for the error.
4.5. Advanced Event Handling
The SDK handles several types of events automatically to provide a smooth user experience.- URL Redirection: When a user action in the checkout flow needs to navigate to an external webpage, the SDK automatically opens it in a secure Chrome Custom Tab. This keeps the user within the context of your app while providing a full browser experience.
- Intent Redirection: For payment methods that require invoking another app (like a UPI payment app), the SDK will automatically fire the necessary Android Intent to switch to that app.
- Invoice Downloads: If the checkout process provides an invoice for download, the SDK will handle the download intent to allow the user to save the invoice.
4.6. Deep Link Configuration
The SDK has built-in support for handling deep links. If your app’s Activity that integrates the TransactBridge SDK uses alaunchMode other than standard (e.g., singleTop, singleTask, or singleInstance), you must forward deep link intents to the SDK.
In your Activity, override the onNewIntent method and pass the Intent to the TransactBridge.handleDeepLink() method: