1. Download the AAR
Download dropin.aar file by clicking on the link below Download dropin.aar2. Add the AAR to Your Project
-
Create a
libsdirectory: In your Android project’sappmodule, create a new folder namedlibsif it doesn’t already exist. The path should beapp/libs/. -
Place the AAR file: Copy the
dropin.aarfile into theapp/libs/directory. -
Update
build.gradle(Module: app):
3. Declare Required Dependencies
Our SDK relies onGson for JSON serialization/deserialization, OkHttp and Volley for network requests. It’s crucial to include these as dependencies in your app/build.gradle to ensure compatibility and prevent runtime issues. Please use the exact versions specified by the SDK to avoid dependency conflicts.
4. Initialize the SDK
Initialize the SDK in your Application class or main Activity:5. Add Terms & Conditions View
In your layout XML:6. List Available UPI Apps
7. Generate Billing Session (Backend)
Important: The generation of the billing session, including thebillingSessionId and token, involves sensitive API keys (x-api-key, x-signature) that must not be exposed in your mobile application. This process should be handled securely on your backend server. Your mobile application should call your backend, which then communicates with TransactBridge to obtain these details.
Your backend should make an API call to TransactBridge’s /billingSession/v1.0/generateBillingSession endpoint. The response from this endpoint will contain the billingSessionId and token which your backend should then securely relay to your mobile application.
8. Launch UPI Payment
9. Handling Payment Results
ThePaymentResultListener provides callbacks for onSuccess, onFailure, and onCancel. Handle these outcomes appropriately:
- onSuccess(PaymentResult result): The payment was successful. You should typically verify this status with your backend before confirming the order or service to the user. The
resultobject contains details liketransactionId. - onFailure(PaymentResult result): The payment failed. The
resultobject will contain error details if available. Inform the user and guide them on next steps. - onCancel(): The user cancelled the payment flow. Inform the user that the payment was not completed.