Android Quick Start
The Android SDK provides a custom view to display Volume checkout and start accepting payments from your customers immediately in any Android app.
Getting Started
Install the Volume Android SDK by adding the GitHub repository:
repositories { maven { name = "GitHubPackages" url = uri("https://maven.pkg.github.com/getvolume/volume-android-sdk") credentials { username volume-public password // Token provided by Volume } } }
Add the SDK dependency (ask the Volume team for the latest version):
dependencies { implementation "com.volume.sdk:volume-android-sdk:2.5.0" }
Volume Provider
Place the VolumeProvider at the root level of your application to configure global SDK settings:
class SampleApplication : Application() { override fun onCreate() { super.onCreate() VolumeProvider.init( volumeSetup = VolumeSetup( applicationId = "", // Provided by Volume volumeEnvironment = "sandbox", onEvent = { Timber.v("[Sample App Volume] On Event: $it") }, logger = logger, showSandboxBanks = true, maxPaymentAmount = 150.toBigDecimal(), minPaymentAmount = 0.01.toBigDecimal(), buttonCustomisation = ButtonCustomisation(), translations = mapOf( "en" to VolumeTranslations(accountHolderNameText = "Name and Surname"), "de" to VolumeTranslations( accountHolderNameText = "Name und Nachname", headingText = "Bezahlen mit", selectBankButtonText = "Zur Zahlung Bank-App auswählen", ) ), language = "en", ), app = this ) VolumeProvider.setLanguage("de") // Change language at runtime } }
VolumeProvider Properties
Required:
key | type | example | description |
|---|---|---|---|
applicationId | String | 123456789 | Application Id from Merchant Portal |
volumeEnvironment | String | sandbox | Environment: 'live' or 'sandbox' |
Optional:
key | type | example | description |
|---|---|---|---|
onEvent | VolumeEventListener | [Events] | Reacts to Volume events |
logger | Logger | Timber / Android.log wrapper | Logs Volume events |
showSandboxBanks | Boolean | true | Show sandbox banks for testing |
minPaymentAmount | BigDecimal | 0.01 | Minimum payment amount |
maxPaymentAmount | BigDecimal | 15000 | Maximum payment amount |
buttonCustomisation | ButtonCustomisation | Customizes Volume button look | |
translations | Map<String, VolumeTranslations> | Localized UI strings | |
language | String | en | Default language for SDK |
For more information on onEvent events, see Events.
The Volume Button
Add the Volume button to your layout:
<com.volume.sdk.payment.VolumePaymentButtonView android:id="@+id/volumePaymentView" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="16dp" app:layout_constraintTop_toBottomOf="@id/volume_toggle" />
Set button properties in your Activity or Fragment:
binding.volumePaymentView.setAmount("1".toBigDecimal()) binding.volumePaymentView.setReference("Example Reference") generateAndSetMerchantPaymentId() binding.volumePaymentView.setCurrency("GBP") binding.volumePaymentView.setCountry("GB") binding.volumePaymentView.setOnButtonEvent { when (it) { is VolumeEvent.NavigateToPaymentConsent -> { generateAndSetMerchantPaymentId() } else -> {} } } binding.volumePaymentView.setMetadata( mapOf( "type" to "shirt", "color" to "black", "owner" to mapOf( "position" to "CTO", "description" to "A tall guy", "details" to mapOf( "name" to "John", "surname" to "Doe", ), "relatedItems" to listOf( mapOf("itemName" to "trousers", "color" to "blue"), mapOf("itemName" to "shoes", "color" to "white") ) ) ) )
Available Countries
Country | Code | Currency |
|---|---|---|
United Kingdom | GB | GBP |
Germany | DE | EUR |
France | FR | EUR |
Netherlands | NL | EUR |
Spain | ES | EUR |
Belgium | BE | EUR |
PaymentIdentifiersProvider (Optional)
Allows pre-fetching merchantPaymentId and reference asynchronously before user clicks Volume Button:
class VolumePaymentIdentifiersProvider : PaymentIdentifiersProvider { override suspend fun providePaymentIdentifiers(): PaymentIdentifiers { return try { PaymentIdentifiers( merchantPaymentId = "123", // From backend reference = "ref123" ) } catch (e: Exception) { PaymentIdentifiers(merchantPaymentId = "", reference = "", errorMessage = e.message) } } } // Usage binding.volumePaymentView.setPaymentIdentifiersProvider(VolumePaymentIdentifiersProvider())
sequenceDiagram actor User participant VolumeButton participant VolumePaymentIdentifiersProvider User->>VolumeButton: Click on Volume Button VolumeButton->>VolumePaymentIdentifiersProvider: Request Payment Identifiers VolumePaymentIdentifiersProvider-->>VolumeButton: Respond with Payment Identifiers VolumeButton->>VolumeButton: Start the payment VolumeButton-->>User: Navigate to bank app
When using paymentIdentifiersProvider, manually set merchantPaymentId and reference values will be ignored.
Merchant Provided Payer Details
Pre-populate payer information to optimize UX:
binding.volumePaymentView.setMerchantProvidedPayerDetails( MerchantProvidedPayerDetails( email = "john.doe@example.com", name = "John Doe", phone = "+44 20 7946 0958", account = PayerAccount( holderName = "John Doe", accountNumber = "12345678", sortCode = "123456", iban = "DE89370400440532013000", ), address = PayerAddress( addressLine1 = "123 Main Street", addressLine2 = "Apt 4B", countryCode = "GB", town = "London", postCode = "SW1A 1AA", ), useForUxFlowOptimisation = true, ) )
Account Rules:
Use either IBAN (EUR) or Account Number + Sort Code (GBP), but not both.
// IBAN method PayerAccount(holderName="John Doe", accountNumber=null, sortCode=null, iban="DE89370400440532013000") // Account Number method PayerAccount(holderName="John Doe", accountNumber="12345678", sortCode="123456", iban=null)
Callback Handling (After Payment Screen)
Properly handle Callback links (deep-links) for smooth user return to your app with payment status.
See: Callback
Testing
Start testing in sandbox environment before switching to live.
Sandbox testing opens banks via browser (not actual banking apps).
For sandbox credentials (Natwest and others), see Sandbox Banks Credentials.
For further support, contact support@getvolume.com.
VolumeEvent
PaymentInitiated
'PaymentInitiated'
When Payment is initiated
NavigateToPaymentConsent
'NavigateToPaymentConsent'
When Payment consent is prepared and user will be navigated to Banking app for consent approval
PaymentError
'PaymentError'
When initiated Payment fails, for example because of Bank specific rules/error Contains message and optional exception object
GenericError
'GenericError'
When any type of error connected with Volume Android SDK occurs, for example list of supported banks cannot be downloaded from Volume server Contains message and optional exception object
PaymentAmountTooSmall
'PaymentAmountTooSmall'
When provided payment amount is too small
PaymentAmountTooLarge
'PaymentAmountTooLarge'
When provided payment amount is too large
NotRendered
'NotRendered'
When Volume button was not rendered (e.g. because of no supported banks are installed on the device)