Setting the environment

  • Android
  • iOS

In the Application class, you should set the environment you’re running the app in – this will either be Sandbox for testing or Production to enable real bank payments to be made.

Example - sandbox
import io.volt.sdk.Volt

class App : Application() {

  override fun onCreate() {
    super.onCreate()
        
    Volt.init(
      environment = VoltEnvironment.Sandbox,
    )
  }
}

Use VoltSDK.shared.setEnvironment to set the environment you’re running the app in – this will either be .sandbox for testing or .production to enable real bank payments to be made.

Example - sandbox
import SwiftUI
import VoltSDK

@main
struct VoltApp: App {
  var body: some Scene {
    WindowGroup {
      ExampleApp()
        .onAppear {
          VoltSDK.shared.setEnvironment(environment: .sandbox)
        }
    }
  }
}

The linked-accounts endpoint

Endpoint that is responsible for checking if a shopper is a returning one or paying for the first time. The response will include saved banks if there are any, that a shopper has completed a transaction with before.

Location

GET: http://api.localhost/linked-accounts

Parameters

  • currency: string
    Optional, if provided filter list to banks that support given currency.
    Example : EUR

  • shopperEmail: string
    Either the shopperReference or shopperEmail fields are required
    Example: shopper1234@company.com

  • shopperReference: string
    Either the shopperReference or shopperEmail fields are required
    Example: shopper1234

Headers

  • X-Volt-Api-Version: string
    Example: 4

Example request

GET http://api.localhost/linked-accounts
curl --request GET \
  --url http://api.localhost/linked-accounts \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer 123' \
  --header 'X-Volt-Api-Version: 4'

Example response

GET http://api.localhost/linked-accounts
[
  {
    "id": "2a80bcad-737b-42a8-91d7-0cfbce6d5351",
    "name": "revolut",
    "supportedCurrencies": [
      "EUR"
    ],
    "country": {
      "id": "DE",
      "name": "Germany"
    },
    "officialName": "Revolut",
    "active": true,
    "logo": "https://cdn.rc.volt.io/banks/logos/gb_revolut.png",
    "icon": "https://cdn.rc.volt.io/banks/icons/default.png",
    "agreements": {
      "supports": false,
      "hasActive": false
    }
  }
]

Selecting a bank

If there is a bank returned from the /linked-accounts endpoint, bank selection can be skipped. If there is no bank returned or the shopper doesn’t want to use the previously-used bank, then a new bank selection will be required.

Request bank selection through the SDK, and wait for the selected bank.

  • Android
  • iOS
Kotlin
import io.volt.sdk.Volt

val launcher = registerForActivityResult(
  StartActivityForResult(),
  ::onBankSelected,
)

Volt.selectBank(
  context: Context,
  launcher: ActivityResultLauncher<Intent>,
  customerId: String,
)

fun onBankSelected(activityResult: ActivityResult?) {
  val bankData = Volt.getBankData(activityResult)
}
Swift
import VoltSDK

private var voltSdk = VoltSDK.shared
voltSdk.selectBank(customerId: String) { bankModel in
  print("Bank selection view ended")
  print(bankModel)
}

Changing the selected bank

For changing a bank, you should use the changeBank method.  The only difference is that welcome screen will be omitted.

Request the change of bank process through the SDK, and wait for the selected bank.

  • Android
  • iOS
Kotlin
import io.volt.sdk.Volt

val launcher = registerForActivityResult(
  StartActivityForResult(), 
  ::onBankSelected,
)

Volt.changeBank(
  context: Context,
  launcher: ActivityResultLauncher<Intent>,
  customerId: String,
)

fun onBankSelected(activityResult: ActivityResult?) {
  val bankData = Volt.getBankData(activityResult)
}
Swift
import VoltSDK

private var voltSdk = VoltSDK.shared
voltSdk.changeBank(customerId: String) { bankModel in
  print("Bank selection view ended")
  print(bankModel)
}

Creating a payment

After the shopper has selected a bank to proceed with their payment, you’ll need to create a payment using the Volt API.  Detailed documentation on how to handle creating the payment can be found in our API documentation.

Find out more about creating payments View in our API docs

Starting a payment request

Request the payment process with the updated token:

  • Android
  • iOS
Kotlin
Volt.payWithSelectedBank(
	 fragmentManager: FragmentManager,
	 token: String,
)
Swift
VStack(spacing: 44) {
  //View content
}
.voltPaymentSheet(token: $viewModel.token)