# 2. Tsunami 🌊

## Initiate Payment (Tsunami)

<mark style="color:green;">`POST`</mark> `{{Base Adres}}/api/paywall/payment/bulk/big/startdirect`

{% hint style="info" %}
Important: To use the batch payment initiation service, you must include the parameters **apikeypublic** and **apiclientpublic** in the Header section.

\
[<mark style="color:green;">**PaymentAPI Addess**</mark>](https://developer.paywall.one/payment-orchestration-integration-document/environment)
{% endhint %}

{% hint style="info" %}
In the Tsunami model’s batch payment service, you can send up to <mark style="color:orange;">**50,000 transactions**</mark>. After you submit the batch payment request, only the **BulkPaymentId** is returned in the API response. All transactions are then processed by Paywall’s **queue mechanism**.
{% endhint %}

{% hint style="warning" %}
The **Tsunami 🌊 model** is designed to handle high-volume data processing. Therefore, we strongly recommend using <mark style="color:green;">**`GZip`**</mark> or <mark style="color:green;">**`Brotli`**</mark> compression in your requests. This ensures that the data transmitted over the network is compressed, which can reduce latency by up to **90%**.
{% endhint %}

{% hint style="warning" %}
In the **Tsunami 🌊 model**, batch payment requests sent between **23:00 and 00:00** are processed **after midnight at 02:00**. This waiting period is applied to ensure the consistency of financial reports.
{% endhint %}

<table><thead><tr><th width="188">Parameter</th><th width="79">Type</th><th width="107">Compolsory</th><th width="403">Description</th></tr></thead><tbody><tr><td>apikeypublic</td><td>string</td><td>Yes</td><td>The Public Key you obtained from the merchant panel.</td></tr><tr><td>apiclientpublic</td><td>string</td><td>Yes</td><td>The Public Client you obtained from the merchant panel.</td></tr></tbody></table>

**The sample&#x20;**<mark style="color:green;">**JSON**</mark>**&#x20;and&#x20;**<mark style="color:green;">**example codes**</mark>**&#x20;to be sent to the service are as follows:**

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

```json5
{
    "PaymentDetail": {
        "Amount": 4.53,
        "MerchantUniqueCode": "{{$guid}}",
        "CurrencyId": 1,
        "Installment": 2,
        "CallbackAddress": "https://webhook.site/fdd9d71c-4381-481f-abf4-2fba544f8a2d",
        "ChannelId": 0,
        "TagId": 0,
        "ClientIP": "1.1.1.1",
        "Half2D": false,
        "CallbackBodySplit": false,
        "CallbackBodyCompression": false
    },
    "CardMethod": 2, // 1: General card for all products | 2: Single card for each product
    // Eğer 1 gelirse aşağıdaki kart nesnesi
    "CardModel": 1, // 1: ECommerce | 2: Insurance
    "Payments": [
        {
            "Customer": {
                "FullName": "FullName",
                "Phone": "5336662211",
                "Email": "enes@paywall.one",
                "Country": "Country",
                "City": "City",
                "Address": "Address",
                "IdentityNumber": "IdentityNumber",
                "TaxNumber": "TaxNumber"
            },
            "Product": {
                "ProductId": "1",
                "ProductName": "12",
                "ProductCategory": "1",
                "ProductDescription": "denemr",
                "ProductAmount": 1.51
            },
            "Card": {
                "OwnerName": "Enes Tütüncü",
                "Number": "5528790000000008",
                "IdentityNumber": "",
                "ExpireMonth": "12",
                "ExpireYear": "2030",
                "Cvv": "123"
            }
        }
    ]
}
```

{% endcode %}
{% endtab %}

{% tab title="C#" %}

```csharp
// Soon
```

{% endtab %}

{% tab title="GO" %}

```go
// Soon
```

{% endtab %}

{% tab title="Java" %}

```java
// Soon
```

{% endtab %}

{% tab title="PHP" %}

```php
// Soon
```

{% endtab %}

{% tab title="Python" %}

```python
// Soon
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
// Soon
```

{% endtab %}

{% tab title="TypeScript" %}

```typescript
// Soon
```

{% endtab %}

{% tab title="Curl" %}

```sh
// Soon
```

{% endtab %}
{% endtabs %}

<mark style="color:blue;">Root Directory</mark>&#x20;

<table><thead><tr><th width="238">Parameter</th><th width="120.65234375">Type</th><th width="145.140625">Compolsory</th><th width="336">Compolsory</th></tr></thead><tbody><tr><td>PaymentDetail</td><td>json</td><td>Yes</td><td>The JSON object where the payment details will be placed.</td></tr><tr><td>CardMethod</td><td>int</td><td>Yes</td><td>The card method to be used for the payments. Depending on this parameter, each payment will either be processed using a single card or with a unique card for each transaction.<br><br><a href="broken-reference">Types</a></td></tr><tr><td>CardModel</td><td>int</td><td>Yes</td><td>The card method through which the payment will be collected.<br><br><a href="broken-reference">Types</a></td></tr><tr><td>Payments</td><td>List&#x3C;Payment></td><td>Yes</td><td>A JSON object in the form of a list that contains the payments to be collected under the batch payment process.</td></tr></tbody></table>

<mark style="color:blue;">Root Directory:</mark> <mark style="color:orange;">`PaymentDetail`</mark>

<table><thead><tr><th width="235">Parameter</th><th width="106">Type</th><th width="130.96484375">Compolsory</th><th width="336">Description</th></tr></thead><tbody><tr><td>Amount</td><td>string</td><td>Yes</td><td>The total amount to be collected in the payment transaction.</td></tr><tr><td>MerchantUniqueCode</td><td>decimal</td><td>Yes</td><td>A unique code defined specifically for the merchant.</td></tr><tr><td>CurrencyId</td><td>string</td><td>Yes</td><td>Represents the currency in which the transaction will be carried out.<br><br><a href="../../../system-data/currency">Currency</a></td></tr><tr><td>Installement</td><td>integer</td><td>Yes</td><td>Indicates the number of installments selected by the customer in their payment plan.</td></tr><tr><td>CallbackAddress</td><td>string</td><td>Yes</td><td>The address to which the system will send the result information after the transaction is completed.</td></tr><tr><td>ClientIP</td><td>string</td><td>Yes</td><td>Represents the IP address of the user performing the transaction.</td></tr><tr><td>Half2D</td><td>bool</td><td>No</td><td>This parameter supports you in finalizing your payments with a separate request. If you send the <code>Half2D</code> parameter as <code>true</code>, the payment will remain in <mark style="color:yellow;">authorization</mark> at the bank until you make the finalization call.</td></tr><tr><td>CallbackBodySplit</td><td>bool</td><td>No</td><td><p>When the batch payment process is completed, the POST notification is sent in parts if the related parameter is set to <code>true</code>.</p><p></p><p><strong>Example:</strong> For 50,000 payments, if the parameter is sent as <code>true</code>, the system may send the notifications in 5 separate parts of 10,000 each, depending on its current load.<br>This allows you to process the transactions incrementally on your side, reducing the strain on your system.</p></td></tr><tr><td>CallbackBodyCompression</td><td>bool</td><td>No</td><td>The POST notification sent after the payment request is completed may have a large body due to the data it contains.<br>If you set the <code>CallbackBodyCompression</code> parameter to <code>true</code>, the POST notifications will be sent compressed using <strong><code>GZip</code></strong>.<br>In this case, you will need to <strong>decompress the <code>GZip</code> body on your side</strong> before processing it.</td></tr></tbody></table>

<mark style="color:blue;">Room Directory:</mark> <mark style="color:orange;">`Payments`</mark>

<table><thead><tr><th width="178">Parameter</th><th width="106">Type</th><th width="139">Compolsory</th><th width="336">Description</th></tr></thead><tbody><tr><td><mark style="color:yellow;">Customer</mark> > FullName</td><td>string</td><td>Yes</td><td>Customer full name</td></tr><tr><td><mark style="color:yellow;">Customer</mark> > Phone</td><td>string</td><td>Yes</td><td>Customer phone number</td></tr><tr><td><mark style="color:yellow;">Customer</mark> > Email</td><td>string</td><td>Yes</td><td>Customer email address</td></tr><tr><td><mark style="color:yellow;">Customer</mark> > Country</td><td>string</td><td>Yes</td><td>Customer country</td></tr><tr><td><mark style="color:yellow;">Customer</mark> > City</td><td>string</td><td>Yes</td><td>Customer city information</td></tr><tr><td><mark style="color:yellow;">Customer</mark> > Address</td><td>string</td><td>No</td><td>Customer address information</td></tr><tr><td><mark style="color:yellow;">Customer</mark> > IdentityNumber</td><td>string</td><td>No</td><td>Customer identification information</td></tr><tr><td><mark style="color:yellow;">Customer</mark> > TaxNumber</td><td>string</td><td>No</td><td>Customer tax number information</td></tr><tr><td><mark style="color:orange;">Product</mark> > ProductId</td><td>string</td><td>Yes</td><td>Sold product identification information</td></tr><tr><td><mark style="color:orange;">Product</mark> > ProductName</td><td>string</td><td>Yes</td><td>Sold product name</td></tr><tr><td><mark style="color:orange;">Product</mark> > ProductCategory</td><td>string</td><td>Yes</td><td>Category information of the sold product</td></tr><tr><td><mark style="color:orange;">Product</mark> > ProductDescription</td><td>string</td><td>No</td><td>Description information of the sold product</td></tr><tr><td><mark style="color:orange;">Product</mark> > ProductAmount</td><td>decimal</td><td>Yes</td><td><p>Amount information of the sold product</p><p><br><strong>Note:</strong> The total amount of all products must equal the main amount.</p></td></tr><tr><td><mark style="color:red;">Card</mark> > OwnerName</td><td>string</td><td><mark style="color:purple;">Conditional</mark></td><td>Cardholder name</td></tr><tr><td><mark style="color:red;">Card</mark> > Number</td><td>string</td><td><mark style="color:purple;">Conditional</mark></td><td>Card number</td></tr><tr><td><mark style="color:red;">Card</mark> > IdentityNumber</td><td>string</td><td><mark style="color:purple;">Conditional</mark></td><td>Cardholder identification information</td></tr><tr><td><mark style="color:red;">Card</mark> > CardNoFirst</td><td>string</td><td><mark style="color:purple;">Conditional</mark></td><td>First 8 digits of the card</td></tr><tr><td><mark style="color:red;">Card</mark> > CardNoLast</td><td>string</td><td><mark style="color:purple;">Conditional</mark></td><td>Last 4 digits of the card</td></tr><tr><td><mark style="color:red;">Card</mark> > ExpireMonth</td><td>string</td><td><mark style="color:purple;">Conditional</mark></td><td>Card expiration month information</td></tr><tr><td><mark style="color:red;">Card</mark> > ExpireYear</td><td>string</td><td><mark style="color:purple;">Conditional</mark></td><td>Card expiration year information</td></tr><tr><td><mark style="color:red;">Card</mark> > Cvv</td><td>string</td><td><mark style="color:purple;">Conditional</mark></td><td>Card CVV information</td></tr></tbody></table>

**Response returned from the service:**

<table><thead><tr><th width="189">Parameter</th><th width="100.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td>ErrorCode</td><td>int</td><td>Error code. Returns '0' if the operation is successful.</td></tr><tr><td>Result</td><td>bool</td><td>Returns <strong>true</strong> if the operation is successful, and <strong>false</strong> if it fails.</td></tr><tr><td>Message</td><td>string</td><td>Contains information or an error message related to the operation.</td></tr><tr><td>Body</td><td>object</td><td>Detailed information related to the batch payment transaction.</td></tr></tbody></table>

**Example Code:**

{% tabs %}
{% tab title="JSON" %}

```json5
{
    "ErrorCodeType": 1,
    "ErrorMessage": null,
    "ErrorCode": 0,
    "Result": true,
    "Message": "Bulk payment created and enqueued",
    "Body": {
        "BulkPaymentId": 2682,
        "BatchSize": 1000,
        "BatchCount": 5,
        "ProcessedBatchCount": 5,
        "NotProcessedBatchCount": 0,
        "MerchantUniqueCode": "8c404c4a-7bd0-4835-96fc-cc285804c522"
    }
}
```

{% endtab %}
{% endtabs %}
