# 17. Sale/Expense (Wallet)

## Sale/Expense with Wallet 'Id'

<mark style="color:yellow;">`POST`</mark>`{{WalletUrl}}/api/v1/Wallet/purchase`&#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 representing the API client ID.</td></tr></tbody></table>

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

```json
{
  "Id": "{{walletId}}",
  "Amount": 100,
  "Description": "string",
  "ExternalReference": "{{$randomFullName}}",
  "UseGiftBalances": true, // If there is a defined gift balance, it will be spent first.
  "CashbackApply": true,
  "CashbackType": "Amount",
  "CashbackValue": 100
}
```

{% 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>Id</td><td>Guid</td><td>The identity information of the wallet where the sale/expense transaction took place.</td></tr><tr><td>Amount</td><td>decimal</td><td>The transaction amount.</td></tr><tr><td>Description</td><td>string</td><td>The description of the transaction.</td></tr><tr><td>ExternalReference</td><td>string</td><td>The transaction tracking number.</td></tr><tr><td>UseGiftBalance</td><td>bool</td><td>If there is a gift balance assigned to the wallet where the transaction occurred, should this balance be used?</td></tr><tr><td>CashbackApply</td><td>bool</td><td>Should cashback be applied after the transaction?</td></tr><tr><td>CashbackType</td><td>string</td><td>Cashback type<br><br>See: <a href="broken-reference">Cashback Types</a></td></tr><tr><td>CashbackValue</td><td>decimal</td><td>The cashback value to be given.</td></tr></tbody></table>

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

```json
{
    "Value": {
        "Id": "fa78cd93-81cf-43c8-b28f-638c0fd1120b",
        "WalletId": "30bac1c0-ad6b-4c50-a52e-1b34f9b487a7",
        "TransactionType": "Purchase",
        "Amount": 100,
        "GiftAmount": null,
        "Description": "string",
        "ExternalReference": "Johnathan O'Connell I",
        "CreatedAt": "2025-04-28T07:52:53.8666424Z",
        "UpdatedAt": null,
        "BalanceAfterTransaction": 975.00,
        "SourceWalletId": null,
        "DestinationWalletId": null,
        "GiftBalanceId": null,
        "MainTransactionId": null,
        "UniqueCode": "1c956e17-5745-4306-864f-305f44fedd73",
        "UsedGiftBalances": null,
        "CashbackAmount": 100
    },
    "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 transaction failed, otherwise false.</td></tr><tr><td>IsSuccess</td><td>bool</td><td>It returns true if the transaction was successful, otherwise false.</td></tr><tr><td>Errors</td><td>Array</td><td>A list of error messages.</td></tr><tr><td>Value</td><td>Array&#x3C;Items></td><td>The data set returned as a result of the transaction.</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>It is the unique identifier generated by the system for the transaction. It is in UUID format.</td></tr><tr><td>WalletId</td><td>String</td><td>It is the system identifier of the wallet where the transaction took place. It indicates which wallet the transaction is associated with.</td></tr><tr><td>TransactionType</td><td>String</td><td>It specifies the type of the transaction. For example, it defines transactions such as "Payment," "Refund," or "Transfer."</td></tr><tr><td>Amount</td><td>Decimal</td><td>It is the amount of the transaction, expressed in the currency used.</td></tr><tr><td>GiftAmount</td><td>Decimal</td><td>It is the amount of gift balance used in the transaction. Unlike the regular balance, it represents promotional usage.</td></tr><tr><td>Description</td><td>String</td><td>It is the explanatory information related to the transaction. It can be written by the user or the system.</td></tr><tr><td>ExternalReference</td><td>String</td><td>It is the reference number provided by an external system for the transaction. It is typically used for integration systems.</td></tr><tr><td>CreatedAt</td><td>DateTime</td><td>It is the date and time when the transaction was created. It is recorded according to UTC or the system time.</td></tr><tr><td>UpdatedAt</td><td>DateTime</td><td>It is the date and time when the transaction was last updated. It is updated whenever a change occurs.</td></tr><tr><td>BalanceAfterTransaction</td><td>Decimal</td><td>It is the remaining balance in the wallet after the transaction. It represents the value after account updates.</td></tr><tr><td>SourceWalletId</td><td>String</td><td>It is the ID of the wallet on the sender's side of the transaction. It specifies the wallet from which the money is being withdrawn.</td></tr><tr><td>DestinationWalletId</td><td>String</td><td>It is the ID of the wallet on the recipient's side of the transaction. It specifies the wallet into which the money is being deposited.</td></tr><tr><td>GiftBalanceId</td><td>Guid</td><td>It is the unique identifier for the used gift balance. It is for tracking purposes.</td></tr><tr><td>MainTransactionId</td><td>Guid</td><td>If this transaction is a continuation or part of another transaction, it is the ID of the parent transaction.</td></tr><tr><td>UniqueCode</td><td>String</td><td>It is the unique code generated by the system for the transaction. It guarantees its uniqueness.</td></tr><tr><td>UsedGiftBalances</td><td>List</td><td>It is the list of gift balances used in the transaction. Multiple balances can be used.</td></tr><tr><td>CashbackAmount</td><td>Decimal</td><td>It is the cashback amount earned as a result of the transaction. It is sourced from a campaign or promotion.</td></tr></tbody></table>
