Payments
Integrate Volume SDK
Android
Get Started

Quick Start

Let's get started with Volume in less than 5 minutes.

Android SDK for Volume is a library with Volume custom view that allows you to display Volume checkout and start accepting payments from your customers in zero time into any Android app.

Getting Started

Get started by installing Volume Android SDK.

    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 dependency to volume-android-sdk (Ask Volume team for the latest version number)

dependencies {
    implementation "com.volume.sdk:volume-android-sdk:2.5.0"
}

Volume Provider

The volume provider should be placed at the root level of your application, this provides key global configuration for using volume in your application.

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") }, // Your own event listener
                logger = logger, // Your own logger implementation
                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") // Use this to change language in runtime
    }
}

Properties

Expand the section below for a quick glance at what you need to know.

VolumeProvider properties

Required Properties

keytypeexampledescription
applicationIdString123456789Your Application Id as provided in your Merchant Portal. (Provided by Volume)
volumeEnvironmentStringsandboxEnvironment to be used, this is either 'live' | 'sandbox' | A full URI if we have provided a specific environment for you.

Optional Properties

keytypeexampledescription
onEventVolumeEventListenerEventsEvent listener, object that reacts to Volume events, see Events for detailed instructions on how this works
loggerLoggerTimber or Android.log wrapperLogger implementation to log Volume information, if not set then no-op implementation is used
showSandboxBanksBooleantrueFlag to enable showing sandbox banks. Used for testing
minPaymentAmountBigDecimal0.01 (default: 0.01)Minimum value for the amount field for each payment, when supplying a value smaller than this, a PAYMENT_AMOUNT_TOO_SMALL event will be emitted and the payment will not reach the volume api.
maxPaymentAmountBigDecimal15000 (default: 15000)Maximum value for the amount field for each payment, when supplying a value greater than this, a PAYMENT_AMOUNT_TOO_LARGE event will be emitted and the payment will not reach the volume api.
buttonCustomisationButtonCustomisationTweak the look and feel of the Volume button, properties to make changes to the colours, text, and border of the button.
translationsMap String to VolumeTranslationsMap of VolumeTranslations per language like "en" or "de". Allows to translate Volume component.
languageStringen (ISO 639)Sets the language to be used on Volume component.
💡

For more information on Events with onEvent. Check out Events.

The Volume Button

When VolumeProvider is initialized then you can add Volume button to your screen by adding VolumePaymentButtonView View:

    <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" />

Then you can set the properties from your Activity/Fragment code

        binding.volumePaymentView.setAmount("1".toBigDecimal())
        binding.volumePaymentView.setReference("Example Reference") // Generate new reference value each time navigateToPaymentConsent event is emitted
        generateAndSetMerchantPaymentId()
        binding.volumePaymentView.setCurrency("GBP")
        binding.volumePaymentView.setCountry("GB")
        binding.contentMain.volumePaymentView.setOnButtonEvent {
            when (it) {
                is VolumeEvent.NavigateToPaymentConsent -> {
                    generateAndSetMerchantPaymentId()
                }
                else -> {}
            }
        }
 
        binding.contentMain.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",
                        ),
                    )
                ),
            )
        )
 
        binding.contentMain.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,
            )
        )
 
        private fun generateAndSetMerchantPaymentId() {
            val merchantPaymentId = "This should be unique value" //TODO Get merchant Payment Id value from backend
 
            binding.contentMain.merchantPaymentId.setText(merchantPaymentId)
        }

Available countries

CountryCountry codeCurrency
United KingdomGBGBP
GermanyDEEUR
FranceFREUR
NetherlandsNLEUR
SpainESEUR
BelgiumBEEUR
VolumePaymentView has following setters
keytypeconstraintsexampledescription
onEventVolumeEventListenerEvent listener, object that reacts to Volume events, see Events for detailed instructions on how this works
setAmountBigDecimalMin 0.01, up to 2 decimal places1Amount to be paid, ie £1.00.
setCurrencyStringISO 4217GBPCurrency of payment
setCountryStringISO 4217GBCountry of origin of the payment.
setReferenceStringMax 18 chars, AlphanumericABC-123Pass a bank transfer reference, it will be visible by both a client and merchant in bank transfer history.
setMerchantPaymentIdString (Optional)Max 50 chars, unique per payment123456Pass a merchantPaymentId to associate a unique identifier for the payment, this will be returned to you in any webhook or api responses for the given payment
setEnabledBooleantrueChanges the Enabled/Disabled state of the Volume button
metadataMap String to Any?metadata is an optional JSON object which will be passed back in webhooks as paymentMetadata. It can only accepts primitives (as well as maps and lists of primitives).
paymentIdentifiersProviderPaymentIdentifiersProviderOptionalProvider for PaymentIdentifiers like MerchantPaymentId and Reference that are generatedPaymentIdentifiers on Merchant backend

Regenerating Merchant Payment ID

Each time VolumeEvent.NavigateToPaymentConsent is emitted Merchant Payment ID should be set to a new unique value.

Rendering Volume Button without MerchantPaymentId (Optional)

The PaymentIdentifiersProvider is an optional feature that allows merchants to provide a MerchantPaymentId and Reference fields when the user clicks the Volume Pay button. This enables the rendering of the Volume Button before creating a Payment entity on the merchant side.

providePaymentIdentifiers(): An asynchronous method that returns a Result<PaymentIdentifiers> object containing the payment identifiers.

class VolumePaymentIdentifiersProvider : PaymentIdentifiersProvider {
    override suspend fun providePaymentIdentifiers(): PaymentIdentifiers {
        return try {
            val merchantPaymentIdFromBackend = "123" // Get merchant Payment Id from backend
            val referenceFromBackend = "ref123" // Get reference from backend
            val generatedPaymentIdentifiers = PaymentIdentifiers(
                merchantPaymentId = merchantPaymentIdFromBackend,
                reference = referenceFromBackend
            )
            generatedPaymentIdentifiers
        } catch (e: Exception) {
            // Return result with error message in case of exception
            // If errorMessage is not null then it will be displayed to the user as an error message
            PaymentIdentifiers(
                merchantPaymentId = "",
                reference = "",
                errorMessage = e.message
            )
        }
    }
}
 
// Usage in the VolumePaymentButtonView
binding.contentMain.volumePaymentView.setPaymentIdentifiersProvider(VolumePaymentIdentifiersProvider())

IMPORTANT: When paymentIdentifiersProvider is provided then merchantPaymentId and reference fields values will be ignored and paymentIdentifiersProvider will be called each time user clicks on the Volume Button.

Merchant Provided Payer Details

The merchantProvidedPayerDetails parameter allows merchants to pre-populate payer information to optimize the user experience during payment flow. This is also required to gain access to Volume's Confirmation of Payer feature, and to enable the search and filtering of payments by these details.

Key Benefits

  • Faster UX: Automatic bank detection based on provided IBAN for EURO payments
  • Improved Conversion: Pre-filled forms reduce user friction
  • Confirmation of Payer: Verify the identity of account holders against your KYC data

Usage

binding.contentMain.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,
    )
)

Properties

PropertyTypeRequiredDescription
emailStringNoCustomer's email address
nameStringNoCustomer's full name
phoneStringNoCustomer's phone number ideally in +XX 123456 format
accountPayerAccountNoCustomer's bank account details
addressPayerAddressNoCustomer's address details
useForUxFlowOptimisationBooleanNoEnable UX optimizations like bank detection

PayerAccount Properties

PropertyTypeRequiredDescription
holderNameStringNoAccount holder's name as it appears on the bank account
accountNumberStringNoBank account number (use with sortCode)
sortCodeStringNoBank sort code without dashes (use with accountNumber)
ibanStringNoInternational Bank Account Number

PayerAddress Properties

PropertyTypeRequiredDescription
addressLine1StringNoFirst line of the address
addressLine2StringNoSecond line of the address
countryCodeStringNoISO 3166-1 alpha-2 country code
townStringNoCity or town
postCodeStringNoPostal code or ZIP code

Account Identification Rules

⚠️

Important: You must use either IBAN (EUR) or the combination of account number and sort code (GBP), but not both:

  • IBAN Method: When iban is provided, accountNumber and sortCode should be null or not provided
  • Account Number Method: When accountNumber and sortCode are provided, iban should be null or not provided

Example with IBAN:

PayerAccount(
    holderName = "John Doe",
    accountNumber = null,
    sortCode = null,
    iban = "DE89370400440532013000",
)

Example with Account Number and Sort Code:

PayerAccount(
    holderName = "John Doe",
    accountNumber = "12345678",
    sortCode = "123456",
    iban = null,
)

Important Notes

⚠️

When using merchantProvidedPayerDetails with IBAN, ensure the country parameter matches the country of the provided IBAN. Note that there are banks like Revolut or Wise that are available in many countries.

  • Bank detection works automatically for EURO payments when a valid IBAN is provided
  • The useForUxFlowOptimisation flag is set to true to enable all UX improvements
  • All fields are optional, allowing partial pre-population based on available data

Implementing the after payment screen (Callback) in mobile app

IMPORTANT: Handling properly Callback links is critical for the smooth User journey ending in Merchant app on payment status page.

Follow instructions for the Volume Callback handling: Callback

Testing

After you have completed the steps above, then you can start testing.

We strongly recommend to use sandbox environment before switching to live environment.

Please note that sandbox testing will not open the Banking app due to lack of testing environment offered by the different banks in the UK. However, a successful test will open the bank environment via the browser. The user experience will differ bank by bank. Ask us more information at support@getvolume.com or use the chat in this page to get immediate assistance.

Please check Sandbox Banks Credentials to be able to test with Natwest Sandbox and other sandbox banks.