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
key | type | example | description |
---|---|---|---|
applicationId | String | 123456789 | Your Application Id as provided in your Merchant Portal. (Provided by Volume) |
volumeEnvironment | String | sandbox | Environment to be used, this is either 'live' | 'sandbox' | A full URI if we have provided a specific environment for you. |
Optional Properties
key | type | example | description |
---|---|---|---|
onEvent | VolumeEventListener | Events | Event listener, object that reacts to Volume events, see Events for detailed instructions on how this works |
logger | Logger | Timber or Android.log wrapper | Logger implementation to log Volume information, if not set then no-op implementation is used |
showSandboxBanks | Boolean | true | Flag to enable showing sandbox banks. Used for testing |
minPaymentAmount | BigDecimal | 0.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. |
maxPaymentAmount | BigDecimal | 15000 (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. |
buttonCustomisation | ButtonCustomisation | Tweak the look and feel of the Volume button, properties to make changes to the colours, text, and border of the button. | |
translations | Map String to VolumeTranslations | Map of VolumeTranslations per language like "en" or "de". Allows to translate Volume component. | |
language | String | en (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
Country | Country code | Currency |
---|---|---|
United Kingdom | GB | GBP |
Germany | DE | EUR |
France | FR | EUR |
Netherlands | NL | EUR |
Spain | ES | EUR |
Belgium | BE | EUR |
VolumePaymentView has following setters
key | type | constraints | example | description |
---|---|---|---|---|
onEvent | VolumeEventListener | Event listener, object that reacts to Volume events, see Events for detailed instructions on how this works | ||
setAmount | BigDecimal | Min 0.01, up to 2 decimal places | 1 | Amount to be paid, ie £1.00. |
setCurrency | String | ISO 4217 | GBP | Currency of payment |
setCountry | String | ISO 4217 | GB | Country of origin of the payment. |
setReference | String | Max 18 chars, Alphanumeric | ABC-123 | Pass a bank transfer reference, it will be visible by both a client and merchant in bank transfer history. |
setMerchantPaymentId | String (Optional) | Max 50 chars, unique per payment | 123456 | Pass 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 |
setEnabled | Boolean | true | Changes the Enabled/Disabled state of the Volume button | |
metadata | Map 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). | ||
paymentIdentifiersProvider | PaymentIdentifiersProvider | Optional | Provider 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
Property | Type | Required | Description |
---|---|---|---|
email | String | No | Customer's email address |
name | String | No | Customer's full name |
phone | String | No | Customer's phone number ideally in +XX 123456 format |
account | PayerAccount | No | Customer's bank account details |
address | PayerAddress | No | Customer's address details |
useForUxFlowOptimisation | Boolean | No | Enable UX optimizations like bank detection |
PayerAccount Properties
Property | Type | Required | Description |
---|---|---|---|
holderName | String | No | Account holder's name as it appears on the bank account |
accountNumber | String | No | Bank account number (use with sortCode ) |
sortCode | String | No | Bank sort code without dashes (use with accountNumber ) |
iban | String | No | International Bank Account Number |
PayerAddress Properties
Property | Type | Required | Description |
---|---|---|---|
addressLine1 | String | No | First line of the address |
addressLine2 | String | No | Second line of the address |
countryCode | String | No | ISO 3166-1 alpha-2 country code |
town | String | No | City or town |
postCode | String | No | Postal 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
andsortCode
should benull
or not provided - Account Number Method: When
accountNumber
andsortCode
are provided,iban
should benull
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 totrue
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.