- 18 Sep 2024
- 3 Minutes to read
- Print
- DarkLight
Getting payment refund details (pacs.007)
- Updated on 18 Sep 2024
- 3 Minutes to read
- Print
- DarkLight
This tutorial describes how you can get payment refund (reversal) details with the Payments Hub API.
For this tutorial, consider a scenario where a customer wants to see the payment refund ID and refund amount for a refund they have previously requested. The Payments Hub API can be used to retrieve these details. The tutorial describes how you can retrieve the payment refund details using the ISO pacs.007 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
1. Authenticate to get an access token
The Payments Hub API endpoints 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:
To create a JWT Bearer token, see the Appendix in Authentication guide. For a predefined token that you can use in the sandbox for testing purposes, see the Prerequisites in Authentication guide.
For detailed instructions on how to get the access token, see Authentication guide.
2. Retrieve the payment refund details
This section describes how to retrieve the payment refund details via a pacs.007 HTTP request to the Payments Hub API. To send this request, you need to provide the Payments Hub ID. This section also illustrates a successful response.
Request
Create and send a request using the following operation:
GET https://sandbox.api.pagonxt.com/payments/pacs007/v08/{paymentsHubId}
Headers
The request must contain the headers shown in the following table.
Table: Retrieve payment refund details – Required request headers.
Header name | Description | Required/ Optional | Values |
---|---|---|---|
Authorization | Authorization security header | Required | Bearer |
X-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 payment refund details – Request parameter.
Parameter type | Parameter name | Description | Data format | Required/ Optional |
---|---|---|---|---|
Path | paymentsHubId | Payments Hub ID related to the payment refund whose details you want to retrieve. This is the value you received when you originally submitted the payment refund request. | String | Required |
Request example
The following example illustrates the request using raw HTTP code:
GET /payments/pacs007/v08/YOUR_PAYMENTS_HUB_ID HTTP/1.1
Host: sandbox.api.pagonxt.com
Authorization: Bearer YOUR_ACCESS_TOKEN
X-Client-Id: YOUR_CLIENT_ID
Response
If the request is valid, you receive an HTTP 200 OK response, which means that the payment refund details were 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 fIToFIPmtRvsl JSON object, which contains a pacs.007 ISO message. This message contains different elements depending on which payment scheme was used in the original transaction.
Response body
The following table shows the response body elements that are relevant for the current use case for the Faster Payments (FP) payment scheme. For details on all the response body elements for all supported payment schemes, see the Message field definition for pacs.007 .
Table: Retrieve payment refund details – Relevant response body elements.
Element | Description | Data type |
---|---|---|
txInf.rvslId | Unique payment refund ID for the end customer. The value consists of up to 18 char. If no value was provided, the client reference (the rvslRsnInf.addtlInf field value) is used. | String |
txInf.rvsdIntrBkSttlmAmt | Data structure containing the payment currency and the amount to be refunded. The currency is GBP, and the amount is a positive value that is less than the original payment amount. | String |
Extract the values of the txInf.rvslId, txInf.rvsdIntrBkSttlmAmt.value, and txInf.rvsdIntrBkSttlmAmt.ccy keys to see the payment refund ID, amount, and currency.
Example response body for the FP payment scheme:
{
"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"]
}]
}]
}
}