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
:
- Kotlin
- Swift
val deposits = Wallet.getInstance().getDepositService()
import PaysafeWallet
let deposits = Wallet.instance.depositService
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).
- Kotlin
- Swift
try {
val depositOptions: List<PaymentOptionDetails> = deposits.getOptions()
Log.d(TAG, depositOptions.toString())
} catch (exception: Exception) {
Log.d(TAG, exception.toString())
}
deposits.getOptions(completion: { result in
switch result {
case .success(let depositOptions):
// Handle depositOptions
case .failure(let error):
// Handle error
}
})
Get Deposits List
- Kotlin
- Swift
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())
}
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.
let getDepositsParameters = Wallet.GetDepositsParameters(limit: nil,
merchantRefNum: "2b01127a-4929-4d0e-b9cb-a29a8d1c499c",
offset: nil,
slipID: nil)
deposits.getAll(getDepositsParameters: getDepositsParameters, completion: { result in
switch result {
case .success(let deposits):
// Handle deposits
case .failure(let error):
// Handle error
}
})
Get Single Deposit
Use get
method to retrieve a deposit by its id.
- Kotlin
- Swift
val depositId = "123"
try {
val deposit = deposits.get(depositId)
Log.d(TAG, deposit.toString())
} catch (exception: Exception) {
Log.d(TAG, exception.toString())
}
let depositId = "123"
deposits.get(id: depositId, completion: { result in
switch result {
case .success(let deposit):
// Handle deposit
case .failure(let error):
// Handle error
}
})
Get Paysafecash locations Feature in development
Use getPaysafecashLocations
method to retrieve a list of physical locations where Paysafecash can be used.
- Kotlin
- Swift
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())
}
To to retrieve the list of locations you should use PaysafecashLocationRequest
object.
let paysafecashLocationRequest = Wallet.PaysafecashLocationRequest(latitude: 30.249,
longitude: -81.529,
radius: 1000, // in meters
limit: 100)
deposits.getPaysafecashLocations(paysafecashLocationRequest: paysafecashLocationRequest, completion: { result in
switch result {
case .success(let paysafecashLocation):
paysafecashLocation.forEach { location in
// Handle each location
}
case .failure(let error):
// Handle error
}
})
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.
- Kotlin
- Swift
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())
}
To initiate deposit you should use DepositRequest
object.
let depositRequest = Wallet.DepositRequest(amount: 100,
currencyCode: "USD",
paymentOption: PaymentOptionType.bankTransfer,
paymentInstrumentReference: .init(id: "123",
instrumentType: .usBankAccount),
merchantRefNum: "2b01127a-4929-4d0e-b9cb-a29a8d1c499c",
returnUrls: nil,
paymentProperties: nil)
deposits.preview(depositRequest: depositRequest, completion: { result in
switch result {
case .success(let depositPreview):
// Handle depositPreview
case .failure(let error):
// Handle error
}
})
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.
- Kotlin
- Swift
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())
}
For Card
deposit with a new card, paymentInstrument
should be CardPaymentInstrument and
additional card details should be added in paymentProperties
.
Use DepositCreate
object to create the deposit. Pass the depositId
from the CustomerDeposit
object returned by the preview
method.
let depositCreate = DepositCreate(id: "123",
paymentProperties: nil,
paymentInstrument: nil)
deposits.create(depositCreate: depositCreate, completion: { result in
switch result {
case .success(let deposit):
// Handle deposit
case .failure(let error):
// Handle error
}
})
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.
- Kotlin
- Swift
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())
}
Use DepositConfirm
object to create the deposit. Pass the depositId
from the CustomerDeposit
object returned by the create
method.
let depositConfirm = DepositConfirm(id: "123",
paymentProperties: nil)
deposits.confirm(depositConfirm: depositConfirm, completion: { result in
switch result {
case .success(let deposit):
// Handle deposit
case .failure(let error):
// Handle error
}
})
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.