Search…
Simulate Refunds
Simulate a refund from a merchant to a virtual card.
A refund is a request by a merchant to return money to a virtual card. The refund must be associated with a previously created debit.

Create a Simulated Refund

A simulated refund is created by calling the simulate refund API and supplying the identifier of a previous debit and the amount to refund.
The debitId is the identifier of a debit that was created by calling the Create a Simulated Debit API. The amount supplied as input is expressed as a multiple of the smallest unit of currency the merchant accepts. For example if the currency is US dollar then the amount is the number of US cents.
An example implementation of creating a simulated refund is:
TypeScript
Swift
Kotlin
1
try {
2
const result = await simulatorClient.simulateRefund({
3
debitId: debit.id,
4
amount: 1200,
5
})
6
} catch (error) {
7
// Handle error
8
}
Copied!
1
let refundInput = SimulateRefundInput(
2
amount: 1200,
3
debitId: debit.id
4
)
5
simulatorClient.simulateRefundWithInput(refundInput) { result in
6
switch result {
7
case .success:
8
// Refund has been created
9
case .failure:
10
// Handle/notify the user of exception
11
}
12
}
Copied!
1
val refundInput = SimulateRefundInput(
2
debitId = debit.id,
3
amount = 1200
4
)
5
launch {
6
try {
7
val refund = withContext(Dispatchers.IO) {
8
simulatorClient.simulateRefund(refundInput)
9
}
10
// Refund has been created
11
} catch (e: RefundException) {
12
// Handle/notify the user of exception
13
}
14
}
Copied!
This API call creates a simulated refund against a virtual card. If an exception occurs, the error or exception will contain a description of the fault that caused the exception.
Last modified 14d ago
Copy link