# 19. 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>](https://developer.paywall.one/payment-orchestration-integration-document/environment)
{% endhint %}

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

<table><thead><tr><th width="162">Parameter</th><th width="79">Type</th><th width="107">Required</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": "{{externalReference}}",
  "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
{
    "Value": {
        "Id": "5b451d65-3e18-415b-9cb0-b7999fc67a7e",
        "WalletId": "0e5439b8-efa5-43d3-91e9-3cc351cc6ecc",
        "TransactionType": "Cancel",
        "Amount": 1.00,
        "GiftAmount": null,
        "Description": "Cancel of Purchase Eddie Leuschke",
        "ExternalReference": "Eddie Leuschke",
        "CreatedAt": "2025-05-01T18:14:29.6583832Z",
        "UpdatedAt": null,
        "BalanceAfterTransaction": 30.00,
        "SourceWalletId": null,
        "DestinationWalletId": null,
        "GiftBalanceId": null,
        "MainTransactionId": "13d23fb6-effa-4776-8385-c345d24b737e",
        "UniqueCode": "dcfe720f-a77a-46f0-b6f2-0deda66425ec",
        "UsedGiftBalances": null,
        "CashbackAmount": 0
    },
    "Errors": [],
    "IsSuccess": true,
    "IsFailure": false
}
```

{% 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">Paramter</th><th width="162.38671875">Type</th><th width="348.94140625">Description</th></tr></thead><tbody><tr><td>Id</td><td>Guid</td><td>It is the unique identifier generated by the system for the transaction.</td></tr><tr><td>WalletId</td><td>String</td><td>It is the ID of the wallet to which the transaction belongs.</td></tr><tr><td>TransactionType</td><td>String</td><td>It specifies the type of the transaction (e.g., payment, refund, etc.).</td></tr><tr><td>Amount</td><td>Decimal</td><td>The total amount of the transaction.</td></tr><tr><td>GiftAmount</td><td>Decimal</td><td>The amount used from the gift balance.</td></tr><tr><td>Description</td><td>String</td><td>The description or note related to the transaction.</td></tr><tr><td>ExternalReference</td><td>String</td><td>The reference code from external sources.</td></tr><tr><td>CreatedAt</td><td>DateTime</td><td>The date and time when the transaction was created.</td></tr><tr><td>UpdatedAt</td><td>DateTime</td><td>The date and time when the transaction was last updated.</td></tr><tr><td>BalanceAfterTransaction</td><td>Decimal</td><td>The remaining wallet balance after the transaction.</td></tr><tr><td>SourceWalletId</td><td>String</td><td>The ID of the wallet that initiated the transaction (if applicable).</td></tr><tr><td>DestinationWalletId</td><td>String</td><td>The ID of the wallet to which the transaction was sent (if applicable).</td></tr><tr><td>GiftBalanceId</td><td>Guid</td><td>The ID of the used gift balance record.</td></tr><tr><td>MainTransactionId</td><td>Guid</td><td>If this transaction is linked to another parent transaction, it is the ID of the parent transaction.</td></tr><tr><td>UniqueCode</td><td>String</td><td>It is the unique code that defines the transaction.</td></tr><tr><td>UsedGiftBalances</td><td>List</td><td>It is the list of used gift balances.</td></tr><tr><td>CashbackAmount</td><td>Decimal</td><td>The cashback (refund) amount earned related to this transaction.</td></tr></tbody></table>
