Refund a payment

Refunding a payment

1. Get payment token

Start by generating a payment token. Read our guide on how to request a refund to understand how.

2. Create refund request

Next create a RR. Send an HTTP POST request to the relevant endpoint + /api/v1/partners/refunds/init/ including the header Authorization: Bearer <payment_token>. You can use the same payment token generated in the first step.

Request

curl --location --request POST 'https://uat.app.payvyne.com/api/v1/partners/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
        }
    ]
}'

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"
        }
    ]
}

Refund status updates

Vyne offers 2 ways for partners to be updated on the status of refunds.

Approach 1: Webhook status updates

Vyne provides 2 webhooks, to inform of payment status updates along with refund status update. More details can be found here.

Approach 2: Get refund status

You can request the status of on any refund at any time by sending an HTTP GET request to the relevant base URL + /api/v1/partners/refunds/ including the headers Authorization: Bearer <payment_token>. Generate a fresh payment token for the <payment_token>.

Request

curl --location --request GET 'https://uat.app.payvyne.com/api/v1/partners/refunds/REFUND-1bd7805da16df89e' \
--header 'Authorization: Bearer <payment_token>' \
--header 'Content-Type: application/json'

Response

{
  "refundId": "1715e35b3894ba09",
  "status": "COMPLETED",
  "paymentId": "f4fce78db4020045",
  "amount": 5.00,
  "currency": "GBP",
  "merchantReference": "65fav",
  "customerReference": "customer x"
}

Refund statuses

Refunds requests can be in a number of statuses. These statuses reflect the what stage in the payment executing journey the refund request is at. Find out more about refund statuses here.