Skip to main content

Refund a credit transfer

Refund incoming transfers with the API.

Guide​

  1. Call the refund mutation.
  2. Add the originTransactionId, consentRedirectUrl, and amount.
  3. Add the RefundSuccessPayload payload.
  4. Add the consent URL to the success payload (line 48): consent > consentUrl.
  5. Add the RefundRejection rejection in case of error.

Mutation​

🔎 Open the mutation in API Explorer

mutation RefundCreditTransfer {
refund(
input: {
consentRedirectUrl: "$YOUR_REDIRECT_URL"
refundTransactions: {
originTransactionId: "YOUR_ORIGIN_TRANSACTION_ID"
amount: { value: "22", currency: "EUR" }
}
}
) {
... on RefundSuccessPayload {
__typename
consent {
id
consentUrl
}
}
... on RefundRejection {
__typename
code
message
}
}
}

Payload​

The payload provides the consentUrl to finalize the refund.

{
"data": {
"refund": {
"__typename": "RefundSuccessPayload",
"consent": {
"id": "YOUR_REFUND_ID",
"consentUrl": "https://identity.swan.io/consent?consentId=$YOUR_CONSENT_ID&env=Sandbox"
}
}
}
}