Skip to main content

Payment Instruments

Introduction

The Payment Instrument service exposes operations for managing payment instruments. Payment instruments are used for Deposit and Withdrawal operations. Only VERIFIED instruments can be used for withdrawal:

  • Get payment instruments list.
  • Get single payment instrument.
  • Verify payment instrument.
  • Get instrument verification sessions.
  • Delete single payment instrument.

Use the following code to obtain an instance of PaymentInstrumentService:

val instrumentsService = Wallet.getInstance().getPaymentInstrumentService()

Get Payment Instruments

Use getAll method to retrieve a list of payment instruments. PaymentInstrumentsParameters is used to filter the response by instrument type using instrumentType and by payment option using paymentOption. null can be passed instead of PaymentInstrumentsParameters if there are no filters applied.

val paymentInstrumentParameters = PaymentInstrumentsParameters(
instrumentType = InstrumentType.SEPA_BANK_ACCOUNT,
paymentOption = PaymentOption.BANK_TRANSFER
)

try {
val instruments = instrumentsService.getAll(paymentInstrumentParameters)
Log.d(TAG, instruments.toString())
} catch (exception: Exception) {
Log.d(TAG, exception.toString())
}

Add Peruvian Bank Account (CCI)
Feature in development

Use add method to add a new CciBankAccount.

val cciBankAccount = CciBankAccount(
id: null,
customerId: null,
status: null,
accountNumber: "10239485761029384756"
)

try {
val instrument = instrumentsService.add(paymentInstrument: cciBankAccount)
Log.d(TAG, instrument.toString())
} catch (exception: Exception) {
Log.d(TAG, exception.toString())
}

Get Payment Instrument

Use get method to retrieve a single instrument with specific type and identifier.

val paymentInstrumentParameters = PaymentInstrumentParameters(
instrumentId = "123456",
instrumentType = InstrumentType.SEPA_BANK_ACCOUNT
)

try {
val instrument = instrumentsService.get(paymentInstrumentParameters)
Log.d(TAG, instrument.toString())
} catch (exception: Exception) {
Log.d(TAG, exception.toString())
}

Verify Payment Instrument

Use startVerification method to create new instrument verification session and obtain an InstrumentVerification object. The startVerification method accepts a InstrumentType parameter and a String parameter returnUrl. This is the URL that will be started by the system browser on flow completion. This link should deep link back to the client application.

val instrumentVerificationRequest = InstrumentVerificationRequest(
returnUrl = "myapp://verification-completed",
instrumentType = InstrumentType.SEPA_BANK_ACCOUNT
)

try {
val instrumentVerification = instrumentsService.startVerification(instrumentVerificationRequest)
instrumentsService.openExternalVerificationFlow(requireActivity(), instrumentVerification)
} catch (exception: Exception) {
Log.d(TAG, exception.toString())
}
IMPORTANT

It is responsibility of the client application to implement deep link handling, either with custom scheme or universal links.

After obtaining the session with startVerification, you should call openExternalVerificationFlow method to open the instrument verification flow in the system browser. Upon flow completion, the browser will redirect the customer to the provided deep link returnUrl.

After the customer has been redirected back to the application via the provided deep link, use completeExternalVerificationFlow method with the return URL as parameter to verify the status and retrieve an instrument verification session.

val deepLinkUri: Uri = intent.data

try {
val instrumentVerification = instrumentService.completeExternalVerificationFlow(deepLinkUri)
Log.d(TAG, instrumentVerification.toString())
} catch (exception: Exception) {
Log.d(TAG, exception.toString())
}

Get Instrument Verification Session

Use getVerification method to retrieve previously created instrument verification session.

try {
val instrumentVerifications = instrumentsService.getVerification(instrumentVerification.id)
Log.d(TAG, instrumentVerifications.toString())
} catch (exception: Exception) {
Log.d(TAG, exception.toString())
}

Get Instrument Verification Sessions

Use getAllVerifications method to retrieve a list of instrument verification sessions. null can be passed instead of InstrumentVerificationParameters object.

You can achieve pagination by combining the limit and offset filters. For instance, implementing pagination with a page size of 10 results per page would involve configuring:

  • Page 1: limit=10, offset=0
  • Page 2: limit=10, offset=10
  • Page 3: limit=10, offset=20
 val instrumentVerificationParameters = InstrumentVerificationParameters(
limit = 10,
offset = 10,
sessionStatus = InstrumentVerificationStatus.ACTIVE
)

try {
val instrumentVerifications = instrumentsService.getAllVerifications(instrumentVerificationParameters)
Log.d(TAG, instrumentVerifications.toString())
} catch (exception: Exception) {
Log.d(TAG, exception.toString())
}

Delete Single Payment Instrument

Use delete method to remove specific payment instrument.

val paymentInstrumentParameters = PaymentInstrumentParameters(
instrumentId = "123456",
instrumentType = InstrumentType.SEPA_BANK_ACCOUNT
)

try {
val instrument = instrumentsService.delete(paymentInstrumentParameters)
Log.d(TAG, instrument.toString())
} catch (exception: Exception) {
Log.d(TAG, exception.toString())
}