# 20. Sale/Expense Cancellation

## Sale/Expense Cancellation

<mark style="color:yellow;">`POST`</mark>`{{WalletUrl}}/api/v1/wallet/purchase/cancel`&#x20;

{% hint style="info" %}
**Note**: To use this service, it is mandatory to include the **apikeypublic** and **apiclientpublic** parameters in the Header field.

\
[<mark style="color:green;">**WalletAPI Address**</mark>](/payment-orchestration-integration-document/environment.md)
{% endhint %}

**The parameters that need to be sent to the service are as follows:**

<table><thead><tr><th width="162">Parameter</th><th width="102.17578125">Type</th><th width="127.8359375">Compulsory</th><th width="403">Description</th></tr></thead><tbody><tr><td>apikeypublic</td><td>string</td><td>Yes</td><td>The general key used for API access.</td></tr><tr><td>apiclientpublic</td><td>string</td><td>Yes</td><td>The general key that defines the client application.</td></tr></tbody></table>

{% tabs %}
{% tab title="Service Reguest - JSON" %}

```json
{
  "ExternalReference": "bea70a60-c631-4c3e-963a-6188ef449601",
  "RollbackFee": true,
  "RollbackCashback": true
}
```

{% endtab %}
{% endtabs %}

## Service Request

<table><thead><tr><th width="192">Parameter</th><th width="147.89192708333331">Type</th><th>Description</th></tr></thead><tbody><tr><td>ExternalReference</td><td>string</td><td>The tracking number for the sale/expense transaction. It is the value provided by you at the time the transaction occurs.</td></tr><tr><td>RollbackFee</td><td>bool</td><td>Should the commissions applied (<mark style="color:blue;">if any</mark>) be reversed as a result of the transaction?</td></tr><tr><td>RollbackCashback</td><td>bool</td><td>Should the cashback applied (<mark style="color:blue;">if any</mark>) be reversed as a result of the transaction?</td></tr></tbody></table>

{% tabs %}
{% tab title="Service Reguest - JSON" %}
{% code lineNumbers="true" %}

```json
{
    "IsSuccess": true,
    "IsFailure": false,
    "Value": {
        "Id": "e1638d79-b78b-4052-934d-9ff49318a981",
        "WalletId": "7883fb19-2359-4a9b-b917-f08a259898ed",
        "Alias": "2816220769",
        "TransactionType": "Cancel",
        "Amount": 10.00,
        "GiftAmount": null,
        "Description": "Cancel of Purchase 6ddf4d59-34f9-447a-9168-c1846bdb5d79",
        "ExternalReference": "6ddf4d59-34f9-447a-9168-c1846bdb5d79",
        "CreatedAt": "2025-08-20T11:57:27.0020678Z",
        "UpdatedAt": null,
        "BalanceAfterTransaction": 99903.80,
        "SourceWalletId": null,
        "DestinationWalletId": null,
        "GiftBalanceId": null,
        "MainTransactionId": "24d912c2-11b1-4fdf-b0e7-6483e526e523",
        "UniqueCode": "744ee08b-33c2-4e5c-be07-336798b08fce",
        "UsedGiftBalances": null,
        "CashbackAmount": 0
    }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Service Response

<table><thead><tr><th width="192">Parameter</th><th width="147.89192708333331">Type</th><th>Description</th></tr></thead><tbody><tr><td>IsFailure</td><td>bool</td><td>It returns true if the service call failed, otherwise false.</td></tr><tr><td>IsSuccess</td><td>bool</td><td>It returns true if the service call was successful, otherwise false.</td></tr><tr><td>Errors</td><td>Array</td><td>It contains the error messages encountered during the transaction.</td></tr><tr><td>Value</td><td>Array&#x3C;Items></td><td>It is the list of data returned in the case of a successful response.</td></tr></tbody></table>

## Service Response (Value)

<table><thead><tr><th width="234.05859375">Parameter</th><th width="162.38671875">Type</th><th width="348.94140625">Description</th></tr></thead><tbody><tr><td>Id</td><td>Guid</td><td>Unique identifier generated by the system for the transaction</td></tr><tr><td>WalletId</td><td>String</td><td>Identifier of the wallet to which the transaction belongs</td></tr><tr><td>TransactionType</td><td>String</td><td>Specifies the type of the transaction (e.g., payment, refund, etc.)</td></tr><tr><td>Amount</td><td>Decimal</td><td>Total amount of the transaction</td></tr><tr><td>GiftAmount</td><td>Decimal</td><td>Amount used from the bonus balance</td></tr><tr><td>Description</td><td>String</td><td>İşleme ait açıklama ya da not.</td></tr><tr><td>ExternalReference</td><td>String</td><td>Sistem dışı kaynaklardan gelen referans kodu.</td></tr><tr><td>CreatedAt</td><td>DateTime</td><td>İşlemin oluşturulduğu tarih/zaman.</td></tr><tr><td>UpdatedAt</td><td>DateTime</td><td>İşlemin son güncellendiği tarih/zaman.</td></tr><tr><td>BalanceAfterTransaction</td><td>Decimal</td><td>İşlem sonrası kalan cüzdan bakiyesi.</td></tr><tr><td>SourceWalletId</td><td>String</td><td>İşlemi başlatan cüzdanın kimliği (varsa).</td></tr><tr><td>DestinationWalletId</td><td>String</td><td>İşlemin gönderildiği cüzdan kimliği (varsa).</td></tr><tr><td>GiftBalanceId</td><td>Guid</td><td>Kullanılan hediye bakiyesi kaydının ID’si.</td></tr><tr><td>MainTransactionId</td><td>Guid</td><td>Bu işlem başka bir ana işleme bağlıysa o işlemin ID’si.</td></tr><tr><td>UniqueCode</td><td>String</td><td>İşlemi tanımlayan benzersiz kod.</td></tr><tr><td>UsedGiftBalances</td><td>List</td><td>Kullanılan hediye bakiyelerine dair liste.</td></tr><tr><td>CashbackAmount</td><td>Decimal</td><td>Bu işleme bağlı kazanılan cashback (iade) tutarı.</td></tr></tbody></table>


---

# 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://developer.paywall.one/payment-orchestration-integration-document/wallet-services/2.-wallet/20.-sale-expense-cancellation.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.
