---
title: Refunds the payment
slug: docs/demo/refunds-the-payment
description: Learn how to make a refund request using the REST API of a fictive company with this detailed code example in cURL. Discover how to format headers for accepting and sending JSON data and explore the various parameters included in the request body, includi
docTags: 
createdAt: 2022-03-21T20:12:45.000Z
---

{
  "id": "YOuPe6f3BQiZ6LK0yVUJ9",
  "data": {
    "url": "https://api.fictive.com/REST/api/accounts/{accountReference}/payments/{paymentReference}/refund",
    "name": "Refunds the payment",
    "method": "POST",
    "request": {
      "pathParameters": [
        {
          "kind": "required",
          "name": "accountReference",
          "type": "string"
        },
        {
          "kind": "required",
          "name": "paymentReference",
          "type": "string"
        }
      ],
      "queryParameters": [],
      "headerParameters": [
        {
          "kind": "optional",
          "name": "X-TokenId",
          "type": "string",
          "description": "The eSuite Token Id"
        },
        {
          "kind": "optional",
          "name": "X-SessionId",
          "type": "string",
          "description": "The eSuite Session Id"
        },
        {
          "kind": "required",
          "name": "X-Version",
          "type": "string",
          "description": "The eSuite Version"
        },
        {
          "kind": "optional",
          "name": "Origin",
          "type": "string",
          "description": "The eSuite Origin"
        }
      ],
      "bodyDataParameters": [
        {
          "kind": "required",
          "name": "refundPaymentRequest",
          "type": "object",
          "schema": [
            {
              "kind": "optional",
              "name": "amount",
              "type": "number<double>",
              "example": "",
              "description": "Gets or sets the amount"
            },
            {
              "kind": "optional",
              "name": "triggerBackOfficeEmail",
              "type": "boolean",
              "example": "",
              "description": "Gets or sets the trigger back office email"
            },
            {
              "kind": "optional",
              "name": "reason",
              "type": "string",
              "example": "",
              "description": "Gets or sets the refund reason"
            },
            {
              "kind": "optional",
              "name": "reasonCode",
              "type": "string",
              "example": "",
              "description": "Gets or sets the refund reason code"
            },
            {
              "kind": "optional",
              "name": "refundAsServiceCredits",
              "type": "boolean",
              "example": "",
              "description": "(Optional) Determines if the refund should be done as Service Credits. Defaults to false."
            },
            {
              "kind": "optional",
              "name": "serviceCreditExpiry",
              "type": "string<date-time>",
              "example": "",
              "description": "(Optional) Gets or Set the date when the refunded credits need to be used by. RefundAsServiceCredits must be set to true when specifying a ServiceCreditExpiry"
            },
            {
              "kind": "optional",
              "name": "itemReference",
              "type": "string",
              "example": "",
              "description": "(Optional) Gets or sets the Item Reference"
            }
          ],
          "modelRef": "#/definitions/FictiveGlobal.Api.Rest.Dtos.v2.Payments.RefundPayment",
          "customType": "FictiveGlobal.Api.Rest.Dtos.v2.Payments.RefundPayment",
          "isExpanded": true,
          "description": "Refund Payment Request object class"
        }
      ],
      "formDataParameters": []
    },
    "responses": [
      {
        "isExpanded": true,
        "statusCode": "204",
        "description": "No Content",
        "jsonExample": ""
      },
      {
        "isExpanded": true,
        "statusCode": "400",
        "description": "Bad Request",
        "jsonExample": ""
      },
      {
        "isExpanded": true,
        "statusCode": "401",
        "description": "Not Authorized",
        "jsonExample": ""
      },
      {
        "isExpanded": true,
        "statusCode": "404",
        "description": "Order does not belong to client.",
        "jsonExample": ""
      },
      {
        "isExpanded": true,
        "statusCode": "412",
        "description": "Precondition Failed\r\n            <br />• Service Credit expiry can only be specified when refunding the balance back as a credit.\r\n            <br />• Your client is not configured to use service credits.\r\n            <br />• An item reference is required when performing a partial refund on a bundle purchase \r\n            <br />• Unable to refund an amount greater than the initial item amount.",
        "jsonExample": ""
      },
      {
        "isExpanded": true,
        "statusCode": "500",
        "description": "Internal Server Error",
        "jsonExample": ""
      }
    ],
    "contentType": "application/json",
    "description": "This endpoint will allow you to refund all items or specific items relating to a purchase that has taken place.",
    "examples": {
      "languages": [
        {
          "id": "13dSsMffP8migau_a-GRm",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://api.fictive.com/REST/api/accounts/{accountReference}/payments/{paymentReference}/refund \\\n     --header 'accept: application/json' \\\n     --header 'x-version: string'"
        },
        {
          "id": "NhLHt4ep_mcho5c4SwCtL",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\nmyHeaders.append(\"x-version\", \"string\");\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   redirect: 'follow'\n};\n\nfetch(\"https://api.fictive.com/REST/api/accounts/{accountReference}/payments/{paymentReference}/refund\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "7jpWbTLfA86QAXIUBegWd",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://api.fictive.com/REST/api/accounts/{accountReference}/payments/{paymentReference}/refund\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Post.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/json\"\nrequest[\"x-version\"] = \"string\"\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "8rtmAZkDo9m0x-xu_PIo8",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://api.fictive.com/REST/api/accounts/{accountReference}/payments/{paymentReference}/refund\"\n\npayload = {}\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json',\n   'x-version': 'string'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "13dSsMffP8migau_a-GRm"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-204",
          "language": "204",
          "code": "// No Content\n"
        },
        {
          "id": "response-1-400",
          "language": "400",
          "code": "// Bad Request\n"
        },
        {
          "id": "response-2-401",
          "language": "401",
          "code": "// Not Authorized\n"
        },
        {
          "id": "response-3-404",
          "language": "404",
          "code": "// Order does not belong to client.\n"
        },
        {
          "id": "response-4-412",
          "language": "412",
          "code": "// Precondition Failed\r\n            • Service Credit expiry can only be specified when refunding the balance back as a credit.\r\n            • Your client is not configured to use service credits.\r\n            • An item reference is required when performing a partial refund on a bundle purchase \r\n            • Unable to refund an amount greater than the initial item amount.\n"
        },
        {
          "id": "response-5-500",
          "language": "500",
          "code": "// Internal Server Error\n"
        }
      ],
      "selectedLanguageId": "response-0-204"
    }
  },
  "type": "api-oas-v2",
  "children": [
    {
      "text": ""
    }
  ]
}