Android SDK
Getting started with Android SDK for Number
The EasyPay Android SDK offers access to the Number API for seamless integration with any and all Android applications. For iOS integration, refer to the iOS SDK integration guide.
Installation
Requirements
Android 6.0 (API level 23) and above
Gradle 8.2 and above
Android Gradle Plugin 8.2.1
Kotlin 1.9.22 and above
Configuration
Add easypay to your dependencies in the build.gradle file.
dependencies {
implementation 'com.easypaysolutions:easypay:1.1.5'
// If you want to use widgets, add the following line
implementation 'com.easypaysolutions:easypay-widgets:1.1.5'
}Get started
Integration
Prerequisites - get API key, HMAC secret and optional Sentry DSN from Number.
During initialization, the RSA certificate download begins. Proceeding with any call before downloading has finished will result with an exception RSA_CERTIFICATE_NOT_FETCHED.
You can check the download status by accessing the following enum:
Using widgets
PaymentSheet
Number's prebuilt payment UI component that allows you to collect credit card information in a secure way and process payments.
Initialize a PaymentSheet inside onCreate of your checkout Fragment or Activity, passing a method to handle the payment result.
When the customer taps the payment button, call present method on the PaymentSheet instance with your configuration. PaymentSheet.Configuration requires the following parameters:
AmountsParam- total $ amount of the payment;ConsentCreatorParam- annual consent details, that contains the following:limitLifeTime- the maximum $ amount that can be charged in total,limitPerCharge- the maximum $ amount that can be charged per transaction,merchantId- the ID of the merchant that the consent is created for,startDate- the date when the consent is created,customerReferenceIdorconsentIdto identify the customer.
Other parameters are optional.
Handle the payment result in the onPaymentSheetResult method.
CustomerSheet
Number's prebuilt UI component that lets your customers manage their saved credit cards.
Initialize a CustomerSheet inside onCreate of your checkout Fragment or Activity, passing a method to handle the customer sheet result.
To present the customer sheet, call the present method on the CustomerSheet instance, passing your configuration. CustomerSheet.Configuration requires the following parameters:
ConsentCreatorParam- annual consent details, that contains the following:limitLifeTime- the maximum $ amount that can be charged in total,limitPerCharge- the maximum $ amount that can be charged per transaction,merchantId- the ID of the merchant that the consent is created for,startDate- the date when the consent is created,customerReferenceIdorconsentIdto identify the customer.
Other parameters are optional.
Handle the customer sheet result in the onCustomerSheetResult method.
Screenshots
Save Card


Manage Cards

Store and Pay

Common components
SecureTextField component
The SDK's widgets use a component called SecureTextField which ensures a safe input of credit card number. It is a subclass of TextInputEditText which enables freedom of styling as needed.
SecureTextField supports only XML layout configuration:
To get the SecureData from the SecureTextField, use the following property:
Common objects
Below you'll find code describing some of the objects that are commonly used in requests or responses. You can use it as a reference. The code includes parameter names, types, and some validation rules.
SecureData
SecureDataMost commonly used as SecureData<String> coming from the SecureTextField component.
CreditCardInfoParam
CreditCardInfoParamAccountHolderDataParam
AccountHolderDataParamAccountHolderBillingAddressParam
AccountHolderBillingAddressParamEndCustomerDataParam
EndCustomerDataParamEndCustomerBillingAddressParam
AmountsParam
AmountsParamPurchaseItemsParam
ConsentCreatorParam
ConsentCreatorParamPublic methods in the Android SDK
1. Charge credit card
This method processes a credit card when the credit card details are entered manually. Details include the card number, expiration date, CVV, card holder name and address.
REST API equivalent: Process a Card Sale Old
Request parameters
ChargeCreditCardBodyParamsencryptedCardNumber: SecureData<String>creditCardInfo: CreditCardInfoParamaccountHolder: AccountHolderDataParamendCustomer: EndCustomerDataParam?amounts: AmountsParampurchaseItems: PurchaseItemsParammerchantId: Int
Response body
The response body will be serialized to ChargeCreditCardResult.
2. List annual consents
A query that returns annual consent details. Depending on the query sent, a single consent or multiple consents may be returned.
REST API equivalent: Query Old
Request parameters
ListAnnualConsentsBodyParamsmerchantId: Int?customerReferenceId: String?rpguid: String?
Either
customerReferenceIdorrpguidmust be provided to get the list of consents of a specific customer.
Response body
The response body will be serialized to ListAnnualConsentsResult.
And the AnnualConsent looks like the following:
3. Create annual consent
This method creates an annual consent by sending the credit card details, which include: card number, expiration date, CVV, and card holder contact data. It is not created by swiping the card through a reader device.
REST API equivalent: Create Annual Consent
Request parameters
CreateAnnualConsentBodyParamsencryptedCardNumber: SecureData<String>creditCardInfo: CreditCardInfoParamaccountHolder: AccountHolderDataParamendCustomer: EndCustomerDataParam?consentCreator: ConsentCreatorParam
Response body
The response body will be serialized to CreateAnnualConsentResult.
4. Cancel annual consent
Cancels an annual consent. Credit card data is removed from the system after the cancellation is complete.
REST API equivalent: Consent Annual Older
Request parameters
CancelAnnualConsentBodyParamsconsentId: Int
Response body
The response body will be serialized to CancelAnnualConsentResult.
5. Process payment for an annual consent
This method uses the credit card stored on file to process a payment for an existing consent.
REST API equivalent: Consent Annual Older
Request parameters
ProcessPaymentAnnualBodyParamsconsentId: Int
Response body
The response body will be serialized to ProcessPaymentAnnualResult.
How to properly consume the API response
All requests are suspended functions, so they should be called from coroutine scope. The result of the request is wrapped in a NetworkResource object, which can be handled in the following way:
Possible exceptions
EasyPaySdkException
Exceptions that are thrown by the SDK.
EASY_PAY_CONFIGURATION_NOT_INITIALIZED
Check if EasyPay.init(...) method has been called.
MISSED_SESSION_KEY
Check if correct SESSION_KEY has been provided in the EasyPay.init(...) method.
MISSED_HMAC_SECRET
Check if correct HMAC_SECRET has been provided in the EasyPay.init(...) method.
RSA_CERTIFICATE_NOT_FETCHED
RSA certificate might not be fetched yet. Check the status by calling the EasyPayConfiguration.getInstance().getRsaCertificateFetchingStatus() method.
RSA_CERTIFICATE_FETCH_FAILED
Contact Number.
RSA_CERTIFICATE_PARSING_ERROR
Contact Number.
EasyPayApiException
Exceptions that are thrown by the Number API.
Semantic versioning
The SDK follows semantic versioning with a three-part version number: MAJOR.MINOR.PATCH.
MAJORversion is incremented when there are incompatible API changes,MINORversion is incremented when functionality is added in a backwards-compatible manner,PATCHversion is incremented when there are backwards-compatible bug fixes.
Feature flags
Rooted device detection
To enable rooted device detection, call the following method before calling EasyPay.init(...):
Last updated
Was this helpful?