Android Integration
Zoho Payments provides a native Android SDK that lets you securely collect payments within your Android app.
Note: The minimum SDK support for the ZohoPayments SDK is Android 8.
Install Zoho Payments SDK
First, you’ll need to add the Zoho Payments SDK to your Android app to initiate the integration.
To install the SDK in your Android app:
- Add the Zoho Payments dependency (latest SDK version 1.0.0) to your app’s
build-gradle
files at both the project and app levels, as shown below:
allprojects {
repositories {
maven { url 'https://maven.zohodl.com' }
}
}
dependencies {
val payments_version = "1.0.0"
implementation("com.zoho.paymentsdk:paymentsdk:$payments_version")
}
- Initialize Zoho Payments SDK using your API Key and Account ID.
ZohoPaymentsCheckout
CheckoutSDK.initialize(
apiKey = "",//api key of org
accountId = "", //account id of organization
)
Once the SDK is initialized, you can create the payment session.
Create Payment Session
To invoke the checkout widget, you need to obtain the paymentSessionId
. To do this:
- Collect payment information from the website (amount, currency, etc.).
- Call the Payment Session Create API.
The API will return a paymentSessionId
. Use this ID to invoke the checkout widget and initiate the payment process.
Set Up Payment Callbacks
Set up the ZohoPaymentsCheckoutCallback
interface to receive payment results.
interface ZohoPaymentsCheckoutCallback
{
fun onPaymentSuccess(paymentId : String, signature: String)
fun onPaymentFailure(error: String)
}
Invoke Checkout Widget
Invoke the checkout widget from your app to initiate the payment process. Use the CheckoutOptions
with your paymentSessionId
and other parameters such as name, invoice number, and payment method.
Specify the domain as IN, since this integration is currently available only in India.
enum class ZohoPaymentsDomain {
IN
}
The payment parameters for CheckoutOptions
and the supported payment methods are listed below:
Parameter | Description |
---|---|
paymentSessionId |
A unique identifier created for each payment session. Learn how to create a payment session. |
description |
Description of the payment session. The maximum length of the description can be 500 characters. |
invoice_number |
Invoice number of the payment session. The maximum length of the invoice number can be 50 characters. |
reference_number |
Reference number for the payment. |
name |
Name of the customer. |
email |
Email address of the customer. |
phone |
Phone number associated with the customer. |
payment_method |
Type of payment method (e.g., Cards, Net Banking, or UPI). |
Choose your preferred payment method from the below listed enums to receive payments from customers.
enum class PaymentMethod(val rawValue: String) : Parcelable {
CARD,
NET_BANKING,
UPI
}
val options = CheckoutOptions(paymentSessionId = "1234567890", description = "description of this payment",invoiceNumber = "Inv_01" ,referenceNumber = "Ref_01",name = "Patricia Boyle" ,email = "pboyle@zylker.com",phone = "9898xxxxxx" ,paymentMethod = PaymentMethod.CARD)
You can invoke the checkout widget using the following function:
CheckoutSDK.showCheckout(this, options, ZohoPaymentsDomain.IN,object : ZohoPaymentsCheckoutCallback {
override fun onPaymentSuccess(paymentId : String, signature: String) {
//Handle Success case
}
override fun onPaymentFailure(error: String) {
//Handle Failure case
}
})
If you’re facing any errors while processing payments via mobile app, refer to the error messages to identify and resolve the issue.
Confirm the Payment
Once the customer completes the payment, the SDK will return a paymentId
and signature
. You can confirm the payment on your server and update your system.
Verify Payment Status
Use the Payment Retrieve API with the paymentId
to verify the transaction status. Based on the status returned (success, failure, or pending), update your system.