Subscription Checkout Integration Android Guide
This integration allows you to integrate with a Telr Subscription checkout in your app.Setting Up Mobile SDK
Step 1: Creating a Subscription
The first step in the Subscription Checkout integration is to create a subscription. You need to do this before any payment can be processed. You can add an endpoint to your server which creates this subscription and is used for communication with your frontend.
Once you create subscription, you will get the
subscription_id and subscription_session_id
Step 2: Opening the Subscription Checkout Payment Page
Once the subscription is created, the next step is to open the payment page so the customer can make the payment. Telr Android SDK offer below payment flow. To complete the payment, we can follow the following steps:- Enable Subscription flow flag in Android Manifest
- Create a
CFSubscriptionSessionobject. - Create a
CFWebCheckoutThemeobject (Optional). - Create a
CFSubscriptionPaymentobject. - Set payment callback.
- Initiate the payment using the payment object created from [step 3]
Enable Subscription flow flag
Add the Below entry to your Android manifest file. If you don’t enable this flag, SDK won’t provide a payment callbackCreate a Subscription Session
This object contains essential information about the subscription, including the subscription session ID (subscription_session_id) and subscription ID (subscription_id) obtained from creation step. It also specifies the environment (sandbox or production).
Customize Theme (Optional)
You can customize the appearance of the checkout screen usingCFWebCheckoutTheme. This step is optional but can help maintain consistency with your app’s design.
You can set the NavigationBarBackgroundColor which will set the color for status bar & cashfree loader
Create Subscription Payment Object
Setup payment callback
The SDK exposes an interfaceCFSubscriptionResponseCallback to receive callbacks from the SDK once the payment journey ends.
This interface consists of 2 methods:
Open Checkout Screen
Finally, calldoSubscriptionPayment() to open the Telr Subscription checkout screen. This will present the user with the payment options and handle the payment process.
Step 3: Sample Code
Step 4: Confirming the Payment
After the payment is completed, you need to confirm whether the payment was successful by checking the subscription status. Once the payment finishes, the user will be redirected back to your activity to your implementation of theCFSubscriptionResponseCallback interface.
You must always verify payment status from your backend. Before delivering the goods or services, please ensure you call check the subscription status from your backend. Ensure you check the subscription status from your server endpoint.
Testing
You should now have a working checkout button that redirects your customer to Telr Subscription Checkout. If your integration isn’t working:- Open the Network tab in your browser’s developer tools.
- Click the button and check the console logs.
- Use console.log(session) inside your button click listener to confirm the correct error returned.
Other Options
(Optional) Enable logging to debugging issues
(Optional) Enable logging to debugging issues
To enable SDK logging add the following to your
values.xml file.<integer name="cashfree_pg_logging_level">3</integer>Following are the Logging levels.- VERBOSE = 2
- DEBUG = 3
- INFO = 4
- WARN = 5
- ERROR = 6
- ASSERT = 7
