---
title: "Refunds"
source_url: https://docs.rapyd.net/en/refunds-369210.html
lang: en
---

# Refunds

Refund a payment.

Rapyd provides a quick and easy method for processing refunds of a purchase made by a customer on your website. Refunds are made to the payment method used in the original payment transaction.

> **Note:**
>
> Only clients with [PCI-DSS](https://docs.rapyd.net/en/glossary.md#UUID-945d98cf-adae-e1cf-2606-c7fae8b4a7e1_dss "Payment Card Industry Data Security Standard") certification can handle personal identifying information for cards. This method is available to merchants who have signed a special agreement with Rapyd.

A customer buys an item on your website for 10.99 USD (U.S. Dollars) with his card. Now the customer wants to return the item for a refund. In this use case, the customer paid by card so the refund is returned to that card.

Your website back end asks Rapyd to process the refund. When the money is returned to the card, Rapyd notifies you that the refund was completed successfully.

### Refunding a Payment Workflow

Finding the specific bank transfer payment methods you'll accept and the corresponding required fields that customers fill out is described under How it Works.

The customer has previously paid for the item. Now the customer fills in all the fields required by your website's **Refund Request** page. You have the ID of the transaction and the amount that needs to be refunded.

![full-refund.jpg](image/img-c292fcb76a9ff067c2213b12ca32bc28.jpg)

1. The website back end requests from Rapyd to process the customer's refund.
2. Rapyd processes the refund transaction and notifies you that it was successful.
3. You send confirmation of the refund to the customer.

### Refund Message Sequences

The message sequence diagrams below describe how information is exchanged between Rapyd, the merchant, and the card issuer.

Refund - Success

![create-card-refund---production-environment.svg](image/img-31cb840599f28a2942566afd6fb8862d.svg)

Refund - Rejected

![create-card-refund---transaction-rejected.svg](image/img-0616ac126a75d51a509f19deb612b8f8.svg)

### Refund Statuses

Description of Statuses

| Status | Description |
| --- | --- |
| Pending | The refund is not yet complete. For example, the refund might still require a customer action, such as withdrawing the refund in cash. |
| Completed | The refund was completed. |
| Rejected | The refund was not made because of an internal error. |
| Error | The refund failed. |

> **Note:**
>
> When requesting a refund, a **Pending** refund status will be applied and the funds will be placed on hold. After the refund is authorized, the funds will be deducted, and the refund will be closed. This is applicable to card payments via Shva to domestic cards.

### How Refunds Work

### Creating the Refund

> **Note:**
>
> To run the examples of this use case, you must create the following ID in your own [sandbox](https://docs.rapyd.net/en/glossary.md#UUID-945d98cf-adae-e1cf-2606-c7fae8b4a7e1_sandbox "Sandbox"):
>
> - 'payment' - Run [Create Payment](https://docs.rapyd.net/en/create-payment.md "Create Payment"). Use the 'id' you get in the response.

When the customer requests a refund on your website, you ask Rapyd to process the refund.

For that, you'll use [Create Refund](https://docs.rapyd.net/en/create-refund.md "Create Refund") with the following parameter:

Description of Body Parameters

| Body Parameter | Description |
| --- | --- |
| payment | Enter the payment 'id' that you received when you created the payment in your sandbox. For purposes of this use case lesson, we are using **payment_1b3e27edf2c43a0b5d1a7de69fbe7102**, which is the payment ID we created in our sandbox. |

You do not need to specify the amount since this is a full refund.

### Create Refund Request

You ask Rapyd to process the refund of the earlier transaction.

- - Request

    - ```
      // Request URL: POST https://sandboxapi.rapyd.net/v1/refunds

      // Message body:
      {
        "payment": "payment_29816514741fe7e4cdee75f7093ccbe1"
      }
      ```
- - .NET Core

    - ```
      using System;
      using System.Text.Json;

      namespace RapydApiRequestSample
      {
          class Program
          {
              static void Main(string[] args)
              {
                  try
                  {
                      var requestObj = new
                      {
                          payment = "payment_29816514741fe7e4cdee75f7093ccbe1",
                      };

                      string request = JsonSerializer.Serialize(requestObj);

                      string result = RapydApiRequestSample.Utilities.MakeRequest("POST", "/v1/refunds", request);

                      Console.WriteLine(result);
                  }
                  catch (Exception e)
                  {
                      Console.WriteLine("Error completing request: " + e.Message);
                  }
              }
          }
      }
      ```
- - JavaScript

    - ```
      const makeRequest = require('../../../../../Utilities/JS/utilities').makeRequest;

      async function main() {
        try {
          const body = {
            payment: 'payment_29816514741fe7e4cdee75f7093ccbe1'
          };
          const result = await makeRequest('POST', '/v1/refunds', body);

          console.log(result);
        } catch (error) {
          console.error('Error completing request', error);
        }
      }
      ```
- - PHP

    - ```
      <?php
      $path = $_SERVER['DOCUMENT_ROOT'];
      $path .= "/code_race_2020/Utilities/PHP/utilities.php";
      include($path);

      $body = [
          "payment" => "payment_29816514741fe7e4cdee75f7093ccbe1"
      ];

      try {
          $object = make_request('post', '/v1/refunds', $body);
          var_dump($object);
      } catch (Exception $e) {
          echo "Error: $e";
      }
      ?>
      ```
- - Python

    - ```
      from pprint import pprint

      from utilities import make_request

      refund_body = {
          "payment": "payment_29816514741fe7e4cdee75f7093ccbe1"
      }

      create_refund_results = make_request(method='post',
                                           path='/v1/refunds',
                                           body=refund_body)

      pprint(create_refund_results)
      ```

### Get Refund Response

Let's take a look at the response.

- - Response

    - ```
      {
          "status": {
              "error_code": "",
              "status": "SUCCESS",
              "message": "",
              "response_code": "",
              "operation_id": "bc321df9-7bb4-47ce-907a-7bbc5a9b32f7"
          },
          "data": {
              "id": "refund_dcdacdb591a117d3d5eb30e59011aadd",
              "amount": 15.65,
              "payment": "payment_29816514741fe7e4cdee75f7093ccbe1",
              "currency": "USD",
              "failure_reason": "",
              "metadata": {},
              "reason": "",
              "status": "Completed",
              "receipt_number": 0,
              "created_at": 1589302965,
              "updated_at": 1589302965,
              "merchant_reference_id": "",
              "payment_created_at": 1589237080,
              "payment_method_type": "us_debit_visa_card",
              "ewallets": [
                  {
                      "ewallet": "ewallet_be4ba8f13da40caa59a7e03022a8acfe",
                      "amount": 15.65
                  }
              ],
              "proportional_refund": true
          }
      }
      ```

The `data` section of this response shows:

- The `amount` is **15.65**.
- The `currency` is **USD**.
- The `status` is **Completed**.

> **Note:**
>
> If the payment was made by cash or a bank redirect, completing the refund process requires the same extra steps as the original payment method. To simulate the action of the customer, run [Complete Refund](https://docs.rapyd.net/en/complete-refund.md "Complete Refund").
>
> Rapyd sends a webhook to notify you that the refund transaction is complete.

After all additional steps have been made, your website shows the customer a confirmation that the refund is complete.

### Viewing Transaction Details

To view the details of the payment and the refund, use [Retrieve Payment](https://docs.rapyd.net/en/retrieve-payment.md "Retrieve Payment").

> **Note:**
>
> Want to see the Rapyd API methods and objects that you'll use? Visit the [Merchant API Reference](https://docs.rapyd.net/en/merchant-api-reference.md "Merchant API Reference") for more technical details.
