# Invoicing for Refunds

To issue an invoice for a refund or cancellation transaction, use the `refundCgInvoice` command.

Send a [standard Hyp API request](/creditguard/introduction/request-and-response-general-structure.md) and, in the `int_in` parameter, include an XML payload for the `refundCgInvoice` command:

```xml
<ashrait>
    <request>
        <version>2000</version>
        <language>ENG</language>
        <command>refundCgInvoice</command>
        <refundCgInvoice>
            <invoiceAtranId>{refundTransactionId}</invoiceAtranId>
            <invoice>
                ...
            </invoice>
        </refundCgInvoice>
    </request>
</ashrait>
```

`invoiceAtranId` should contain the transaction ID (`tranId`) from the response of the refund transaction you're issuing an invoice for. If you don't have the transaction ID, perform a [transaction inquiry](/creditguard/inquiring-transactions/overview.md) to obtain it.

What you include in the `invoice` element of the payload depends on whether you want to reuse the invoice parameters from the original [debit transaction invoice](/creditguard/documents-and-invoicing/issuing-invoices.md).

If you do want to reuse the original debit invoice parameters, such as item properties, date, and email address, then add `createInvoice` with a value of `1` inside the `invoice` element:

```xml
<ashrait>
    <request>
        <version>2000</version>
        <language>ENG</language>
        <command>refundCgInvoice</command>
        <refundCgInvoice>
            <invoiceAtranId>{refundTransactionId}</invoiceAtranId>
            <invoice>
                <createInvoice>1</createInvoice>
            </invoice>
        </refundCgInvoice>
    </request>
</ashrait>
```

If you want to create a refund invoice that uses new invoice parameters (for example, when performing a partial refund), set `createInvoice` to `2` and include the new invoice parameters in the `invoice` element. The set of supported invoice parameters is the same as in the [`addCgInvoice` command](/creditguard/documents-and-invoicing/issuing-invoices.md):

```xml
<ashrait>
    <request>
        <version>2000</version>
        <language>ENG</language>
        <command>refundCgInvoice</command>
        <refundCgInvoice>
            <invoiceAtranId>{refundTransactionId}</invoiceAtranId>
            <terminalNumber>{terminalNumber}</terminalNumber>
            <invoice>
                <createInvoice>2</createInvoice>
                <invoiceCreationMethod>wait</invoiceCreationMethod>
                <invoiceSubject>Your vinyl store refund</invoiceSubject>
                <invoiceItemCode>12345</invoiceItemCode>
                <invoiceItemDescription>Fleetwood Mac. Rumours</invoiceItemDescription>
                <invoiceItemQuantity>1</invoiceItemQuantity>
                <invoiceItemPrice>5700</invoiceItemPrice>
                <companyInfo>Invoice recipient</companyInfo>
                <mailTo>example@acme.io</mailTo>
                <isItemPriceWithTax>1</isItemPriceWithTax>
                <ccDate>2025-08-12</ccDate>
            </invoice>
        </refundCgInvoice>
    </request>
</ashrait>
```

The response structure is similar in both scenarios and matches the one returned after [sending the `addCgInvoice` command](/creditguard/documents-and-invoicing/issuing-invoices.md#response-structure):

```xml
<?xml version='1.0'?>
<ashrait>
    <response>
        <command>refundCgInvoice</command>
        <dateTime>2025-08-12 13:36</dateTime>
        <requestId/>
        <tranId>119427414</tranId>
        <result>000</result>
        <message>Permitted transaction</message>
        <userMessage>Permitted transaction</userMessage>
        <additionalInfo/>
        <version>2000</version>
        <language>Eng</language>
        <refundCgInvoice>
            <invoice>
                <invoiceCreationMethod>wait</invoiceCreationMethod>
                <invoiceResponseCode>100</invoiceResponseCode>
                <invoiceResponseName>Proper Invoice Request</invoiceResponseName>
                <invoiceDocNumber>23940</invoiceDocNumber>
                <invoiceDocUrl>
                    https://demo.ezcount.co.il/front/documents/get/6830ab55-b051-4daf-8de8-d6593f2180df/copy_en
                </invoiceDocUrl>
                <invoiceAtranId>119427406</invoiceAtranId>
                <invoiceCreationDate>1754994995</invoiceCreationDate>
                <mailTo>example@acme.io</mailTo>
                <invoiceCreationCode>000</invoiceCreationCode>
            </invoice>
        </refundCgInvoice>
    </response>
</ashrait>
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.hyp.co.il/creditguard/documents-and-invoicing/refund-invoices.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
