> ## Documentation Index
> Fetch the complete documentation index at: https://paydocs.dashu.sa/llms.txt
> Use this file to discover all available pages before exploring further.

# Make Refund

> Using this endpoint you'll have the ability to make a refund full/partial for a specific invoice or payment.

### Query Parameters

<ParamField body="apiKey" type="string" placeholder="API Key" required>
  The API Key of your account.
</ParamField>

<ParamField body="data" type="object" required>
  <Expandable title="properties" defaultOpen={true}>
    <ResponseField name="Key" type="string" requried>
      Refers to the invoice number or payment ID based on the key type

      Samples: `3308076` or `100325710000064334`.
    </ResponseField>

    <ResponseField name="KeyType" type="string" required>
      The key type should be either `InvoiceId` or `PaymentId`.
    </ResponseField>

    <ParamField body="Suppliers" type="array" required>
      <Expandable title="properties" defaultOpen={true}>
        <ResponseField name="SupplierCode" type="integer" required>
          Your Supplier Code (you'll get it after joining DashPay)

          Sample: `123`.
        </ResponseField>
      </Expandable>
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="test" type="boolean" initialValue={true}>
  Set this property to `true` to send the request to the development
  environment.
</ParamField>

<ResponseExample>
  ```json Success theme={null}
  {
    "IsSuccess": true,
    "Message": "Refund Created Successfully!",
    "ValidationErrors": null,
    "Data": {
      "Key": "3445302",
      "RefundId": 86815,
      "RefundReference": "2024000022",
      "RefundInvoiceId": 3449413,
      "Amount": 1,
      "Comment": "partial refund to the customer"
    }
  }
  ```

  ```json Error theme={null}
  {
    "success": false,
    "code": 5,
    "message": "`Suppliers` is not valid."
  }
  ```
</ResponseExample>

### Response properties

<ResponseField name="IsSuccess" type="boolean" required>
  The response status.
</ResponseField>

<ResponseField name="Message" type="string" required>
  The description of the response status.
</ResponseField>

<ResponseField name="ValidationErrors" type="array|null" required>
  List of validation errors (if any).
</ResponseField>

<ResponseField name="Data" type="object" required>
  <Expandable title="properties" defaultOpen={true}>
    <ResponseField name="Key" type="string" required>
      The key value you have passed for the Request Transaction.
    </ResponseField>

    <ResponseField name="RefundId" type="integer" required>
      A unique number indicates the Refund request in DashPay system.
    </ResponseField>

    <ResponseField name="RefundReference" type="string" required>
      The refund reference generated by DashPay for following up with the finance team.
    </ResponseField>

    <ResponseField name="RefundInvoiceId" type="string" required>
      The InvoiceId of the refunded amount.
    </ResponseField>

    <ResponseField name="Amount" type="string" required>
      The amount to be refunded.
    </ResponseField>

    <ResponseField name="Comment" type="string" required>
      The comments that you have passed in the request.
    </ResponseField>
  </Expandable>
</ResponseField>

## Error Codes

Here's a list of possible error codes of this endpoint.

| **Code** | **Description**                    |
| -------- | ---------------------------------- |
| 1        | Missing or invalid api key         |
| 2        | `Key` is a required parameter.     |
| 3        | `KeyType` is a required parameter. |
| 4        | `Key` is invalid.                  |
| 5        | `Suppliers` is not valid.          |
| 6        | wrong supplier code.               |
| 7        | An error meessage from the bank.   |
