Refunding payments with Faster Payments (pacs.007 and pacs.002)
  • 03 Apr 2024
  • 7 Minutes to read
  • Dark
    Light

Refunding payments with Faster Payments (pacs.007 and pacs.002)

  • Dark
    Light

Article Summary

This tutorial describes how you can refund (reverse) Faster Payments (FP) payments with the Refund API (also known as the pacs.007 endpoint of the Payments Hub API).

For this tutorial, consider a scenario where you are a payment provider, and your UK-based merchant has a customer in the UK who purchases an item for which they later want a refund. The Refund API can be used to reverse the GBP transfer and return part of the money from the merchant account to the customer's account.

This tutorial describes, in 2 separate sections, how:

  • You can initiate a refund for an FP payment using the ISO pacs.007 message.

  • You can receive a notification of the refund, allowing you to retrieve its status using the ISO pacs.002 message.

Note

The instructions in this tutorial apply to the sandbox environment.

Prerequisites

Before obtaining the access token, make sure you have a public-private key pair that you can use to sign JWT Bearer tokens.

Click here to email your public key, along with the kid and iss claim values you will use in your JWT Bearer tokens.

Note

  • The public key must be created with RSA and sent in PEM format, without password encryption, and must have a length of at least 2048 bits. If these criteria are not met, the token will be rejected.

  • If you don't have a public-private key pair yet, you can use a predefined JWT Bearer token in the sandbox with no need to create or sign your own tokens for authentication:

    eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6InByb1BheW1lbnRzSHViU2IifQ.eyJzdWIiOiJxTWtaOTBxb0hBTjVJbkE2V2xNYVZBaE41dDhBQWVPeCIsImlzcyI6IlNhbnRhbmRlciIsImlhdCI6MTcxMDg0MjgwNCwibmJmIjoxNzEwODQyODA0LCJleHAiOjE3NDIzNzg4MDQsImp0aSI6ImM3YWY0Yzg0LTRkYzQtNDM2Mi05OTA2LWM5ZTg5N2YyNzUzOCJ9.LOaGmVUnQ6I0HYUQWA1y2vUhREaJrAasAxDlqAnxKbEYGmjP6AKeIViLdkBVVPTUWRETxmnlU6fBQRYU0BN8NEJ9dd_uJ20uiPGWp1ieTFvee27LbqqqS-4AbwD_oJluBUzb77cx4P_1o35gFskcFjbzdl5ert4xJvpbXNOQYa0C7f4YQ6wMLjCGkbdhimwRxeOEGVdYiRoVEizkPpNgUZi_H3o58gATIJ4rSSWqLmKvy9aBlK_YAT947klkJI-ej22KU8qgLCInBbBGdoW9gjg8Zpmizs7Xc7eAvNm7QRiAzd1NT6dgX3hAYDJz2m2dnZYS6zE_UPWOi5cbAyQggw
  • In the sandbox environment, you can use a predefined test SCA JWT Bearer token:

    eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6InByb1BheW1lbnRzSHViU2IifQ.eyJoZCI6Im9XSEZldFBZbzM5YUl1cTU2ZEdyb1BDV0ZudlRiREJOdENPRnNsY1VIdUU9Iiwibm9uY2UiOiI0MGRkMGRlZDJkNDk4OTJlNmZkOCIsImFsZyI6IlNIQTI1NiIsImlzcyI6IlNhbnRhbmRlciIsImlhdCI6MTcxMjA1MTUyMSwibmJmIjoxNzEyMDUxNTIxLCJleHAiOjE3NDM1ODc1MjEsImp0aSI6IjIzY2ExNjQyLTYxMjAtNDg4MC1iMDU1LTEwMzZhNjMxNjcxMCJ9.aoJ1hGVPg4ArEb3gdu0VO7rhnL2SpsRXAtZTk-Ou3CWKYZ1u4_Y31MjGQuYabUHJf8GHMT8h_jsHjyxkqcp6tgkZB7cTYgb9nScwSGYQ0jGCul_-v7YUH6zByt7HBfb2XA3XhzcxOLLCkajAQErWCgvHytW0c5x6lQNFSBfrSdCNmuE3cAnu5sabYRtgFeX_L59JbOkLB5raGltiYT627G1M1RF_Lfjc0dvc4szXlKDhIwYFm-6Z5-pazsDaK03zZ27pnrUo1O7pWhPRJz5l02clipE_e-JktOFcpnESPMifZaDeu8P54gGP0-zEqJFJCuGaXahRc-HYhEAxSnBnmQ

1. Authenticate to get an access token

The Payments Hub API endpoints (including the Refund API) are protected with OAuth 2.0 JWT Bearer grant. To use the API, you must create a JWT Bearer token and use it to get an access token:

2. Refund the payment

A customer is not happy with their purchase and they request a refund from your merchant, who forwards the request to you. You can then initiate the payment refund using the pacs.007 HTTP request.

This section describes how to make a partial refund via a pacs.007 HTTP request to the Refund API. It also illustrates a successful response.

Request

Create and send a request using the following operation:

POST https://sandbox.apis.santander.com/payments/pacs007/v08

Headers

The request must contain the headers shown in the following table.

Table: Refund the payment - Required request headers.

Header name

Description

Required/ Optional

Values

Authorization

Authorization security

Required

Bearer

X-Santander-Client-Id

Client ID

Required

<Client ID>

Content-Type

Format of the request body

Required

application/json

sca-token

SCA JWT bearer token:

  • In the sandbox environment, you can use a predefined test SCA JWT Bearer token (see the Prerequisites section).

  • In the live environment, you must create the token based on the message body (whose details are described below) and sign it with your private key. For more information on the token details, see the Appendix in Authentication guide .

Required

sca-token

Accept

Format of the response body

Required

application/json

Request body

The request must include a JSON payload object in the request body. The JSON payload is a pacs.007 ISO message with the fitoFIPmtRvsl root element, and it contains the request details for refunding a payment.

The following table only provides information about some especially important fields. For details on all the required and optional message fields, see Message field definition for pacs.007 .

Table: Refund the payment - Relevant request body elements.

Message field

Description

Data type

Required/Optional

grpHdr.msgId

Message ID, which must uniquely identify each request you send.

This ID is used internally for idempotency of the API.

String

Required

grpHdr.creDtTm

Date and time of the payment refund request

String

Required

grpHdr.nbOfTxs

Number of transactions within the message.

Value: 1

Number

Required

grpHdr.sttlmInf.sttlmMtd

Settlement method.

Value: CLRG

String

Required

txInf.rvslId

Unique payment refund ID for the end customer.

The value consists of up to 18 char.

If no value is provided, the client reference (the rvslRsnInf.addtlInf field value) is used.

String

Optional

txInf.rvsdIntrBkSttlmAmt

Data structure containing the payment currency and the amount to be refunded.

The currency must be GBP and the amount must be a positive value.

The Refund API validates that the amount is less than the original payment amount.

Object

Required

txInf.rvs

Array of the client reference for the inbound payment to be refunded.

The array can contain the following elements:

  • Element [0] = ID value of the original payment. The following ID values contained within the original payment request can be used:

    • fitoFICstmrCdtTrf.cdtTrfTxInf.rmtInf.strd.cdtrRefInf.ref

    • fitoFICstmrCdtTrf.cdtTrfTxInf.pmtId.endToEndId

    • fitoFICstmrCdtTrf.cdtTrfTxInf.pmtId.txId

    • fitoFICstmrCdtTrf.grpHdr.msgId

    • paymentsHubId returned in the response body of the original payment request.

This element is mandatory.

  • Element [1] = ID type. The possible values are:

    • Null, zero, or rmtinf = Creditor reference ID

    • e2eid = End-to-end ID

    • txid = Transaction ID

    • msgid = Message ID

    • payhubid = Payments Hub ID

      This element is optional. If it is not provided, the value of element [0] must be the creditor reference ID.

  • Element [2] = New end-to-end ID used to track the refund between payment systems.

    This element is optional.

Array

Required

Example request body:

{
  "fitoFIPmtRvsl": {
    "grpHdr": {
      "msgId": "12345324543",
      "creDtTm": "2019-05-16T16:31:49-04:00",
      "nbOfTxs": 1,
      "sttlmInf": {
        "sttlmMtd": "CLRG"
      }
    },
    "txInf": [{
      "rvslId": "12345324543",
      "rvsdIntrBkSttlmAmt": {
        "value": 0.01,
        "ccy": "GBP"
      },
      "rvslRsnInf": [{
        "addtlInf": ["My own inbound reference"]
      }]
    }]
  }
}

Request example

The following example illustrates the request using raw HTTP code:

POST /payments/pacs007/v08 HTTP/1.1
Host: sandbox.apis.santander.com
Content-Type: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN
X-Santander-Client-Id: YOUR_CLIENT_ID
sca-token: eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6InByb1BheW1lbnRzSHViU2IifQ.eyJoZCI6Im9XSEZldFBZbzM5YUl1cTU2ZEdyb1BDV0ZudlRiREJOdENPRnNsY1VIdUU9Iiwibm9uY2UiOiI0MGRkMGRlZDJkNDk4OTJlNmZkOCIsImFsZyI6IlNIQTI1NiIsImlzcyI6IlNhbnRhbmRlciIsImlhdCI6MTcxMjA1MTUyMSwibmJmIjoxNzEyMDUxNTIxLCJleHAiOjE3NDM1ODc1MjEsImp0aSI6IjIzY2ExNjQyLTYxMjAtNDg4MC1iMDU1LTEwMzZhNjMxNjcxMCJ9.aoJ1hGVPg4ArEb3gdu0VO7rhnL2SpsRXAtZTk-Ou3CWKYZ1u4_Y31MjGQuYabUHJf8GHMT8h_jsHjyxkqcp6tgkZB7cTYgb9nScwSGYQ0jGCul_-v7YUH6zByt7HBfb2XA3XhzcxOLLCkajAQErWCgvHytW0c5x6lQNFSBfrSdCNmuE3cAnu5sabYRtgFeX_L59JbOkLB5raGltiYT627G1M1RF_Lfjc0dvc4szXlKDhIwYFm-6Z5-pazsDaK03zZ27pnrUo1O7pWhPRJz5l02clipE_e-JktOFcpnESPMifZaDeu8P54gGP0-zEqJFJCuGaXahRc-HYhEAxSnBnmQ
Content-Length: 798

{
    "fitoFIPmtRvsl": {
        "grpHdr": {
            "msgId": "12345324543",
            "creDtTm": "2019-05-16T16:31:49-04:00",
            "nbOfTxs": 1,
            "sttlmInf": {
                "sttlmMtd": "CLRG"
            }
        },
        "txInf": [
            {
                "rvslId": "12345324543",
                "rvsdIntrBkSttlmAmt": {
                    "value": 0.01,
                    "ccy": "GBP"
                },
                "rvslRsnInf": [
                    {
                        "addtlInf": [
                            "My own inbound reference"
                        ]
                    }
                ]
            }
        ]
    }
}

Response

If the request is valid, you receive an HTTP 201 Created response, which means that the payment refund request was successfully submitted. In addition, the response body returns the data JSON object, which contains payment refund details. If the request is submitted again with the same message ID, you receive an HTTP 200 OK response. For further details of HTTP response codes and instructions on how to handle errors, see HTTP codes and request error handling .

The following table shows the response body elements that are relevant for the current use case. For details on all the response body elements, see Message field definition for pacs.007 .

Table: Refund the payment - Relevant response body elements.

Element

Description

Data type

paymentsHubId

Payments Hub ID, which uniquely identifies your payment refund request in Payments Hub. You can use it if you later need to retrieve the payment refund details.

String

paymentsId

Message ID you defined in the request as the grpHdr.msgId field value

String

status

Current status of the payment refund. Since Payments Hub stores all requests for a while before performing the transaction settlement, this value is returned as PENDING.

String

Extract the value of the paymentsHubId key, as you'll need it in the next section.

Example response body:

{
  "data": {
    "paymentsHubId": "b3141861-b9e7-3906-90a6-ef384f232f82",
    "paymentId": "1587641040",
    "status": "PENDING",
    "creationDateTime": "2020-04-23T11:24:01"
  }
}

3. Retrieve the refund payment status

This section describes how, after receiving a notification, you can retrieve the payment refund status via a pacs.002 HTTP request to the Payments Hub API. To send this request, you need to provide the Payments Hub ID provided in the notification, see Notifications. This section also illustrates a successful response.

Note

Notifications are not used in the sandbox environment.

Request

Create and send a request using the following operation:

GET https://sandbox.apis.santander.com/payments/pacs002/v10/{paymentsHubId}

Headers

The request must contain the headers shown in the following table.

Table: Retrieve the refund payment status - Required request headers.

Header name

Description

Required/Optional

Values

Authorization

Authorization security header

Required

Bearer

X-Santander-Client-Id

Client ID

Required

Accept

Format of the response body

Required

application/json

Parameters

The request must contain the path parameter shown in the following table.

Table: Retrieve the refund payment status - Request parameter.

Parameter type

Parameter name

Description

Data format

Required/Optional

Path

paymentsHubId

Payments Hub ID related to the refund payment, received in the notification

String

Required

Request example

The following example illustrates the request using raw HTTP code:

GET /payments/pacs002/v10/YOUR_PAYMENTS_HUB_ID HTTP/1.1
Host: sandbox.apis.santander.com
Authorization: Bearer YOUR_ACCESS_TOKEN
X-Santander-Client-Id: YOUR_CLIENT_ID

Response

If the request is valid, you receive an HTTP 200 OK response, which means that the refund payment status was successfully retrieved. For further details of HTTP response codes and instructions on how to handle errors, see HTTP codes and request error handling .

In addition to the response code, the response body returns the fIToFIPmtStsRpt JSON object, which contains a pacs.002 ISO message.

The following table shows the response body elements that are relevant for the current use case. For details on all the response body elements, see Message field definition for pacs.002 .

Table: Retrieve the refund payment status - Relevant response body elements.

Element

Description

Data type

txInfAndSts.txSts

Refund payment status.

The possible values are based on the ISO standard. For example: ACCC (accepted) or RJTC (rejected)

String

txInfAndSts.orgn

TxRef.intrBkSttlmAmt|Data structure containing the refund payment currency and amount

Object

Extract the value of the txInfAndSts.txSts key and the txInfAndSts.orgnlTxRef.intrBkSttlmAmt data structure to see the refund payment status and amount.

Example response body:

{
  "fitoFIPmtStsRpt": {
    "grpHdr": {
      "msgId": "1587641040",
      "creDtTm": "2019-05-14T11:30:19.123"
    },
    "txInfAndSts": [
      {
        "orgnlGrpInf": {
          "orgnlMsgId": "1587641040",
          "orgnlMsgNmId": "pacs.007.001.08"
        },
        "orgnlEndToEndId": "e2eId-1587641040",
        "orgnlTxId": "111111",
        "txSts": "ACCC",
        "stsRsnInf": [
          {
            "rsn": {
              "cd": "G000"
            },
            "addtlInf": [
              null,
              null,
              null,
              "tppId_0"
            ]
          }
        ],
        "orgnlTxRef": {
          "intrBkSttlmAmt": {
            "ccy": "GBP"
            "value": 0.50,
          },
          "sttlmInf": {
            "sttlmMtd": "CLRG"
          },
          "pmtTpInf": {
            "svcLvl": {
              "prtry": "FP"
            },
          },
          "rmtInf": {
            "ustrd": [
              "DebtorReference",
              "IGNORED"
            ],
            "strd": [
              {
                "cdtrRefInf": {
                  "ref": "PH PRE-UAT TESTING GB"
                },
                "addtlRmtInf": [
                  "FPID"
                ]
              }
            ]
          },
          "dbtr": {
            "pty": {
              "nm": "Steve",
              "pstlAdr": {
                "adrLine": [
                  "Somewhere in MK"
                ]
              }
            }
          },
          "dbtrAcct": {
            "id": {
              "othr": {
                "id": "GB67ABBY09012803352529"
              }
            },
            "nm": "Mr Steve"
          },
          "dbtrAgt": {
            "finInstnId": {
              "clrSysMmbId": {
                "mmbId": "123456"
              }
            }
          },
          "cdtrAgt": {
            "finInstnId": {
              "clrSysMmbId": {
                "mmbId": "200000"
              }
            }
          },
          "cdtr": {
            "pty": {
              "nm": "Mr Creditor",
              "pstlAdr": {
                "adrLine": [
                  "GB payments hub testing"
                ]
              }
            }
          },
          "cdtrAcct": {
            "id": {
              "othr": {
                "id": "GB69HBUK40333313032018"
              }
            },
          }
        }
      }
    ]
  }
}

ISO20022 API Specification

Check API Documentation

Click below to embark on your journey to new possibilities.

Download Swagger File

Take the next step towards enhanced efficiency and performance.


Was this article helpful?