Transfers
Introduction
A transfer is the movement of funds between two wallet accounts. The Transfer service exposes features for managing transfers:
- Preview, Create and Confirm a Transfer.
- Get Transfers List.
- Get Single Transfer.
Transfer requires the following parameters:
amount
- The amount in minor units.currencyCode
- Currency of the amountemail
orcustomerId
of the recipient.reason
for the transfer.
For successful transfer the following conditions must be met:
- Customer should have enough balance in the requested currency.
- Recipient customer must exist in the system and must not be restricted.
Use the following code to obtain an instance of TransferService
:
- Kotlin
- Swift
val transferService = Wallet.getInstance().getTransferService()
import PaysafeWallet
let transferService = Wallet.instance.transferService
Preview Transfer
Transfer is created in PREVIEW state, which can be used to determine the recipient and FX amount (if applicable).
Transfers in PREVIEW
state do not create actual transaction in Paysafe Wallet system.
TransferRequest
Parameter | Data type | Description | Example |
---|---|---|---|
amount | Int | Required parameter for amount of transfer in minor units. | 100 |
currencyCode | String | Required parameter for currency of the transfer. Format ISO 4217. | "USD" |
recipient | CustomerTransferRecipient | Contains transfer recipient information. | CustomerTransferRecipient(...) |
merchantRefNum | String | Optional parameter for merchant reference number. | "19481996" |
fxQuote | String | FX Quote ID for the transfer in case currency conversion is required. If not passed currency conversion is not performed. | 404679be-ccbf-4528-b880-e14cc5041753 |
transferDetails | TransferDetails | Required parameter containing transfer reason and description. | TransferDetails(...) |
CustomerTransferRecipient
Parameter | Data type | Description | Example |
---|---|---|---|
customerId | String | The unique identifier of the recipient. | "5435323362" |
email | String | The email address of the recipient. | user@example.com |
TransferDetails
Parameter | Data type | Description | Example |
---|---|---|---|
reason | String | The actual purpose of the transfer. | TransferReason.PEER_TRANSFER / .peerTransfer |
description | String | Optional human readable description for the transfer. | "Holiday Gift!" |
- Kotlin
- Swift
val transferRequest = CustomerTransferRequest(
amount = 200,
currencyCode = "USD",
recipient = CustomerTransferRecipient(
customerId = null,
email = "user@example.com"
),
merchantRefNum = "2b01127a-4929-4d0e-b9cb-a29a8d1c499c",
fxQuote = "404679be-ccbf-4528-b880-e14cc5041753",
transferDetails = TransferDetails(
reason = TransferReason.PEER_TRANSFER,
description = "Transfer money"
)
)
try {
val transferPreview = transferService.preview(transferRequest)
Log.d(TAG, transferPreview.toString())
} catch (exception: Exception) {
Log.d(TAG, exception.toString())
}
let transferRequest = Wallet.CustomerTransferRequest(amount: 100,
currencyCode: "USD",
recipient: .init(email: "user@example.com"),
merchantRefNum: "2b01127a-4929-4d0e-b9cb-a29a8d1c499c",
fxQuote: "404679be-ccbf-4528-b880-e14cc5041753",
transferDetails: .init(reason: .peerTransfer,
description: "Transfer money"))
transferService.preview(transferRequest: transferRequest, completion: { result in
switch result {
case .success(let transferPreview):
// Handle transferPreview
case .failure(let error):
// Handle error
}
})
Create Transfer
Use create
method to perform the required validations and move the transfer in PENDING
state.
Pass the transferId
from the Transfer
object returned by the preview
method.
TransferCreate
Parameter | Data type | Description | Example |
---|---|---|---|
transferId | String | Required parameter for id of the transfer. | "urn:transfer:01HNDA4FJJTN4TK66WK4251SWH" |
paymentProperties | List/Array | Parameter reserved for future use. Currently has no usage. | null/nil |
- Kotlin
- Swift
val transferCreate = TransferCreate(transferId = "urn:transfer:01HNDA4FJJTN4TK66WK4251SWH")
try {
val transfer = transferService.create(transferCreate)
Log.d(TAG, transfer.toString())
} catch (exception: Exception) {
Log.d(TAG, exception.toString())
}
let transferCreate = Wallet.TransferCreate(id: "urn:transfer:01HNDA4FJJTN4TK66WK4251SWH")
transferService.create(transferCreate: transferCreate, completion: { result in
switch result {
case .success(let transfer):
// Handle transfer
case .failure(let error):
// Handle error
}
})
Confirm Transfer
Use confirm
method to confirm the transfer.
Utilize the id
from the CustomerTransfer
object returned by the create
method.
This operation might require Strong Customer Authentication (SCA). Please read Strong Customer Authentication for more information on the process.
If the CustomerTransfer
object returned by confirm
has action: PaymentCompletionAction.SCA
,
the scaDetails
will contain the SCA authentication properties needed to complete the process.
Follow the steps outlined in Submit the SCA Authentication
to confirm the event. After the SCA event is accepted, invoke confirm
method again,
providing scaDetails
in the TransferConfirm
parameter.
TransferConfirm
Parameter | Data type | Description | Example |
---|---|---|---|
transferId | String | Required parameter for id of the transfer. | "urn:transfer:01HNDA4FJJTN4TK66WK4251SWH" |
paymentProperties | List/Array | Parameter reserved for future use. Currently has no usage. | null/nil |
scaDetails | ScaAuthenticationEventRequest | SCA authentication properties used to complete the process. | ScaAuthenticationEventRequest(eventId: "7cebe19b-4a96-4d7b-badd-c07eaee786fc", walletOperationID: "03f44a74-937d-430d-b06e-09b42b0f2b0e") |
- Kotlin
- Swift
val transferConfirm = TransferConfirm(transferId = "urn:transfer:01HNDA4FJJTN4TK66WK4251SWH")
try {
val transfer = transferService.confirm(transferConfirm)
Log.d(TAG, transfer.toString())
} catch (exception: Exception) {
Log.d(TAG, exception.toString())
}
let transferConfirm = TransferConfirm(transferId: "urn:transfer:01HNDA4FJJTN4TK66WK4251SWH")
transferService.confirm(transferConfirm: transferConfirm, completion: { result in
switch result {
case .success(let transfer):
// Handle transfer
case .failure(let error):
// Handle error
}
})
Get Transfer List
Use getAll
method to retrieve a list of transfers by passing the GetTransferParameters
.
If no parameters are passed, last 10 transfers will be returned.
GetTransferParameters
Parameter | Data type | Description | Example |
---|---|---|---|
limit | Int | Optional parameter for the maximum number of customer transfers to return. | 10 |
merchantRefNum | String | Optional parameter for merchant reference number of the customer transfers. | "2b01127a-4929-4d0e-b9cb-a29a8d1c499c" |
offset | Int | Optional parameter used to get customer transfers from a specific starting point. | 10 |
slipId | String | Optional parameter for payment slip id. | "123" |
- Kotlin
- Swift
val parameters = GetTransferParameters(
limit = 10,
merchantRefNum = "2b01127a-4929-4d0e-b9cb-a29a8d1c499c",
offset = 10,
slipId = "123"
)
try {
val transferList = transferService.getAll(parameters)
Log.d(TAG, transferList.toString())
} catch (exception: Exception) {
Log.d(TAG, exception.toString())
}
let parameters = Wallet.GetTransferParameters(limit: 10,
merchantRefNum: "2b01127a-4929-4d0e-b9cb-a29a8d1c499c",
offset: 10,
slipID: "123")
transferService.getAll(getTransferParameters: parameters, completion: { result in
switch result {
case .success(let transferList):
// Handle transferList
case .failure(let error):
// Handle error
}
})
Get Single Transfer
Use get
method to retrieve a customer transfer by passing its id.
- Kotlin
- Swift
val transferId = "urn:transfer:01HNDA4FJJTN4TK66WK4251SWH"
try {
val transfer = transferService.get(transferId)
Log.d(TAG, transfer.toString())
} catch (exception: Exception) {
Log.d(TAG, exception.toString())
}
let transferId = "urn:transfer:01HNDA4FJJTN4TK66WK4251SWH"
transferService.get(id: transferId, completion: { result in
switch result {
case .success(let transfer):
// Handle transfer
case .failure(let error):
// Handle error
}
})