Request refund

1. Get payment token

Start by generating a payment token. Make a HTTP POST request to the relevant endpoint + /api/oauth/token/ using the access token you generated.

Request

curl --location --request POST 'https://uat.app.payvyne.com/api/oauth/token' 
--header 'Content-Type: application/x-www-form-urlencoded' 
--data-urlencode 'grant_type=client_credentials' 
--data-urlencode 'client_id=<payment_key>'
--data-urlencode 'client_secret=<payment_secret>’

2. Create refund request

Then, create a RRRR - Refund Request. Send an HTTP POST request to the relevant endpoint + /api/v1/refunds/init including the headers Authorization: Bearer <payment_token>. The RRRR - Refund Request body should contain an array of payments with paymentId and amount corresponding to each refund required.

Request

curl --location --request POST 'https://uat.app.payvyne.com/api/v1/refunds/init' \
--header 'Authorization: Bearer <payment_token>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "payments": [
        {
            "paymentId": "1ac613c7ca3eca52",
            "amount": 2.4
        },
        {
            "paymentId": "4d6fb61dd6eb0c7b",
            "amount": 9
        },
        {
            "paymentId": "2178e53c08b1f3f5",
            "amount": 0.1
        },
        {
            "paymentId": "1ac613c7ca3eca52",
            "amount": 1.00
        },
        {
            "paymentId": "1a17fe039cd34777",
            "amount": 99999.99
        },
        {
            "paymentId": "4de89355d8fc67b0",
            "amount": 1
        }
    ]
}'

payments

Parameter

Description

paymentId

16 digit alphanumeric unique payment identifier.

amount

The amount to be refunded.

A successful RRRR - Refund Request returns a 202 response code and an object with refunds and/or errors arrays.

If something unexpected happened during the request, the API returns an error response with the appropriate HTTP status code and a JSON response that contains detailed information about the problem.

Response

{
    "refunds": [
        {
            "id": "REFUND-1bd7805da16df89e",
            "status": "NEW",
            "amount": 2.4,
            "currency": "GBP",
            "paymentId": "1ac613c7ca3eca52"
        },
        {
            "id": "REFUND-46713c3a44ad27f0",
            "status": "NEW",
            "amount": 0.1,
            "currency": "GBP",
            "paymentId": "2178e53c08b1f3f5"
        }
    ],
    "errors": [
        {
            "paymentId": "4d6fb61dd6eb0c7b",
            "errorMessage": "Payment is not in SETTLED or PART_REFUNDED status!"
        },
        {
            "paymentId": "1ac613c7ca3eca52",
            "errorMessage": "Multiple refunds cannot be made at the same time"
        },
        {
            "paymentId": "1a17fe039cd34777",
            "errorMessage": "The refund amount cannot be greater than the payment amount"
        },
        {
            "paymentId": "4de89355d8fc67b0",
            "errorMessage": "Could not find payment with ID=4de89355d8fc67b0"
        }
    ]
}

Parameter

Description

refunds

An array of objects containing refunds that were initiated refunds successfully.

errors

Array of objects containing error details for refunds that could not be initiated.

refunds

Parameter

Description

id

16 digit alphanumeric unique refund identifier.

status

The current status of the refund. For all possible statuses see here.

amount

The amount of the refund.

currency

The three-character refund currency using ISO 4217.

paymentId

16 digit alphanumeric unique payment identifier (corresponding to that specified in the RRRR - Refund Request ).

errors

Parameter

Description

paymentId

16 digit alphanumeric unique payment identifier (corresponding to that specified in the RRRR - Refund Request ).

errorMessage

A short description explaining why the refund initiation failed.


Did this page help you?