Skip to main content

Deposits

Introduction

The Deposit service exposes features for managing deposits:

  • Preview Deposit
  • Create Deposit
  • Confirm Deposit
  • Get Deposit Options
  • Get Deposits List
  • Get Single Deposit

Use the following code to obtain an instance of DepositService:

val deposits = Wallet.getInstance().getDepositService()

Get Deposit Options

Use getOptions method to retrieve a list of all available deposit options for the customer.

Deposit options refer to the methods of transferring funds (e.g., bank cards or bank accounts), while instrument types pertain to the specific financial tools or mechanisms used in these transactions (e.g., a concrete bank card or account).

try {
val depositOptions: List<PaymentOptionDetails> = deposits.getOptions()
Log.d(TAG, depositOptions.toString())
} catch (exception: Exception) {
Log.d(TAG, exception.toString())
}

Get Deposits List

Use getAll method to retrieve a list of deposits by passing the GetDepositsParameters. If no parameters are passed, the last 10 deposits will be returned by default.

val getDepositsParameters = GetDepositsParameters(
limit = 10,
merchantRefNum = "2b01127a-4929-4d0e-b9cb-a29a8d1c499c",
offset = 10,
slipId = "123"
)

try {
val result = deposits.getAll(getDepositsParameters)
Log.d(TAG, result.toString())
} catch (exception: Exception) {
Log.d(TAG, exception.toString())
}

Get Single Deposit

Use get method to retrieve a deposit by its id.

val depositId = "123"

try {
val deposit = deposits.get(depositId)
Log.d(TAG, deposit.toString())
} catch (exception: Exception) {
Log.d(TAG, exception.toString())
}

Get Paysafecash locations
Feature in development

Use getPaysafecashLocations method to retrieve a list of physical locations where Paysafecash can be used.

To retrieve the list of locations you should use PaysafecashLocationRequest object.

val paysafecashRequest = PaysafecashLocationRequest(
latitude = 30.249,
longitude = -81.529,
radius = 1000, // in meters
limit = 100
)

try {
val paysafeLocations = deposits.getPaysafecashLocations(paysafecashRequest)
paysafeLocations.forEach { location ->
Log.d(TAG, "${location.latitude}, ${location.longitude}, ${location.address}, ${location.name}, ${location.city}")
}
} catch (exception: Exception) {
Log.d(TAG, exception.toString())
}

Preview Deposit

Use preview method to create a deposit for the current customer. Deposits are created in PREVIEW state. Deposits in PREVIEW state do not create actual transaction in Paysafe Wallet system. It allows to check deposit parameters and display the fees.

To initiate deposit you should use DepositRequest object.

val depositRequest = DepositRequest(
amount = 100,
currencyCode = "USD",
paymentOption = PaymentOptionType.BANK_TRANSFER,
paymentInstrumentReference = PaymentInstrumentReference(
id = "123",
instrumentType = InstrumentType.US_BANK_ACCOUNT
),
merchantRefNum = "2b01127a-4929-4d0e-b9cb-a29a8d1c499c",
returnUrls = null,
paymentProperties = null
)

try {
val depositPreview = deposits.preview(depositRequest)
Log.d(TAG, depositPreview.toString())
} catch (exception: Exception) {
Log.d(TAG, exception.toString())
}
note

For Card deposit with a new card, call the preview method with null/nil paymentInstrumentReference parameter.

For Card, Pago Efectivo and Paysafecash you need to provide DEFAULT type returnUrl in order to be able to handle the redirection back to the client application in the case of a REDIRECT action.

Create Deposit

Use create method to perform the required validations and move the deposit in PENDING state.

Use DepositCreate object to create the deposit. Pass the depositId from the CustomerDeposit object returned by the preview method.

val depositCreate = DepositCreate(depositId = "123",
paymentProperties = null,
paymentInstrument = null
)

try {
val deposit = deposits.create(depositCreate)
Log.d(TAG, deposit.toString())
} catch (exception: Exception) {
Log.d(TAG, exception.toString())
}
note

For Card deposit with a new card, paymentInstrument should be CardPaymentInstrument and additional card details should be added in paymentProperties.

Confirm Deposit

Use confirm method to confirm the deposit and move it in PROCESSING state.

Use DepositConfirm object to create the deposit. Pass the depositId from the CustomerDeposit object returned by the create method.

val depositConfirm = DepositConfirm(depositId = "123", paymentProperties = null)

try {
val deposit = deposits.confirm(depositConfirm)
Log.d(TAG, deposit.toString())
} catch (exception: Exception) {
Log.d(TAG, exception.toString())
}
note

For Pago Efectivo and Paysafecash payment options, after the deposit is confirmed, you will receive an Action REDIRECT/.redirect in CustomerDeposit response object. To complete the deposit, you should use redirectUrl to redirect the user to the payment provider's page.

For Card deposit you can receive 3DS challenge. In order to resolve it you should use redirectUrl to redirect the user to the 3DS page.