# 1. Initiate Payment

## Initiate Payment (Id)

<mark style="color:green;">`POST`</mark> `{{Base Adres}}/api/paywall/apm/pay`

{% hint style="info" %}
**Important**: To use the APM Payment Initiation (DirectPay) service, you need to include '**apikeypublic**' and '**apiclientpublic**' parameters in the 'Header' field.

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

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

<table><thead><tr><th width="178">Parameter</th><th width="98">Type</th><th width="142">Compulsory</th><th width="403">Description</th></tr></thead><tbody><tr><td>apikeypublic</td><td>string</td><td>Yes</td><td>The Public Key obtained from the merchant panel.</td></tr><tr><td>apiclientpublic</td><td>string</td><td>Yes</td><td>The Public Client obtained from the merchant panel.</td></tr></tbody></table>

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

<table><thead><tr><th width="221">Parameter</th><th width="160">Type</th><th width="186">Compulsory</th><th width="336">Description</th></tr></thead><tbody><tr><td>ApmKey</td><td>int</td><td>Yes (Conditional)</td><td><p>The Key information of the APM provider.</p><p><br>Bkz: <a href="/pages/SBmzwsUcnHQe4CKnuSWt">APM</a></p></td></tr><tr><td>ApmConnectionId</td><td>int</td><td>Yes (Conditional)</td><td>The Id (identifier) information of the connections obtained through the APM listing service. You can initiate payments through the relevant connection using this parameter when dynamically generating your payment screen scenarios.</td></tr><tr><td>CurrencyId</td><td>int</td><td>Yes</td><td>The currency in which the payment is intended to be processed.<br><br>Bkz: <a href="/pages/bahfUMz1dqpN1ZCnpVtM">Currency Units</a></td></tr><tr><td>SectorId</td><td>short?</td><td>No</td><td><p>The sector information where the payment will be processed. Shared with providers.</p><p><br>Sectors</p></td></tr><tr><td>MerchantUniqueCode</td><td>string</td><td>Yes</td><td>The unique identifier you've generated for the payment.</td></tr><tr><td>Amount</td><td>decimal</td><td>Yes</td><td>The payment amount.</td></tr><tr><td>Description</td><td>string</td><td>Yes</td><td>The description of the payment. Depending on the provider, this description can be displayed on the payment screen.</td></tr><tr><td>Payer</td><td><mark style="color:orange;">Payer</mark></td><td>Yes</td><td>This object contains the payer information for the payment. The parameters under this object may vary depending on the requirements of the provider.<br><br><strong>Example</strong>: For a provider that expects CardNumber, the Paywall API makes CardNumber parameter mandatory.</td></tr><tr><td>Products</td><td>List&#x3C;Products></td><td>No</td><td>It will be useful for sending, reporting, and tracking purposes. If these details are sent, the total amount of the sent products is compared with the actual transaction amount. However, if they are not sent, no comparison is made.</td></tr><tr><td>Provider:Parameters</td><td>Dynamic</td><td>Yes/No</td><td>If there are dynamic details expected by the provider at the time of payment, such information is obtained externally and shared with the providers. For example, if a provider expects information like store code or store identity, Paywall API verifies and enforces these details as mandatory.</td></tr></tbody></table>

#### <mark style="color:orange;">Payer</mark> :

<table><thead><tr><th width="179.41015625">Parameter</th><th width="133.55859375">Type</th><th width="176.15625">Compolsory</th><th width="307.7890625">Description</th></tr></thead><tbody><tr><td>Fullname</td><td>string</td><td>Yes (Conditional)</td><td>Payer full name</td></tr><tr><td>CardNumber</td><td>string</td><td>Yes (Conditional)</td><td>Payer card number (e.g., meal card, etc.)</td></tr><tr><td>CardId</td><td>string</td><td>Yes (Conditional)</td><td>Payer card identity number (works if stored in the APM provider)</td></tr><tr><td>Phone</td><td>string</td><td>Yes (Conditional)</td><td>Payer phone number</td></tr><tr><td>Email</td><td>string</td><td>Yes (Conditional)</td><td>Payer email address</td></tr><tr><td>UserIdentity</td><td>string</td><td>Yes (Conditional)</td><td>Payer identity information in your system (TCKN/VKN)</td></tr><tr><td>ConsumerIdentity</td><td>string</td><td>Yes (Conditional)</td><td>Payer identity information in your system (UserId)</td></tr><tr><td>Birthday</td><td>DateTime</td><td>No</td><td>Payer date of birth</td></tr><tr><td>CardAlias</td><td>string</td><td>Yes (Conditional)</td><td>Label of the card belonging to the payer (Masterpass)</td></tr></tbody></table>

**Servise gönderilecek örnek bir JSON dosyası şu şekildedir :**

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

```json
{
    "ApmKey": "ApmProviderKey", // Apm Provider Static Key (ApmConnectionId boş ise)
    "ApmConnectionId": 19, // Apm Connection Id (ApmKey boş ise)
    "CurrencyId": 1,
    "MerchantUniqueCode": "A1s2d3F4G5H6J7K8L9",
    "Amount": 1,
    "Description": "PW",
    "IsPreAuth": false,
    "InstallmentCount": 1,
    "Payer": {
        "Fullname": "",
        "CardNumber": "",
        "CardId": "",
        "Phone": "",
        "Email": "",
        "UserIdentity": "",
        "CardAlias": "",
        "ConsumerIdentity": "",
        "Birthday": null
    },
    "Products": [
        {
            "ProductId": "123",
            "ProductName": "Name",
            "ProductCategory": "Food",
            "ProductDescription": "Description of Product",
            "ProductAmount": 1
        }
    ],
    // MarketPlace tipindeki sağlayıcılar içindir,
    // kullanılmaması durumunda null gönderilebilir
    "Provider": {
        // Dynamic
        "Parameters": {
            "MerchantCode": "**********",
            "TerminalCode": "**********"
        }
    }
}
```

{% endtab %}
{% endtabs %}

**The parameters returned from the service are as follows:**

<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 a true or false value. If the operation is successful, it returns 'true'.</td></tr><tr><td>Message</td><td>string</td><td>If the operation fails, this is the message describing the error, with language support based on the locale parameter.</td></tr><tr><td>Body</td><td>object</td><td>If the operation fails, this is the error detail object.</td></tr></tbody></table>

{% hint style="info" %}
**Important:** If the **PendingOtpConfirm** parameter returns **TRUE**, you must confirm the payment with the request on the **Confirm Payment** page.
{% endhint %}

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

```json
{
    "ErrorCode": 0,
    "Result": true,
    "Message": "",
    "Body": {
        "ApmKey": "FoodCardProvider",
        "ApmConnectionId": 21,
        "ApmTransactionId": 4330,
        "UniqueCode": "85a07d7e-adc4-4698-a4cb-e643bdd705b1",
        "MerchantUniqueCode": "G5H6A4FKAJDLF3457394759834",
        "Amount": 1.0,
        "PendingOtpConfirm": true, // Eğer false ise OTP doğrulama gerekmez
        "ProviderDummyResponse": {
            "ErrorCode": 0,
            "Body": {
                "Success": true,
                "Code": null,
                "Message": null,
                "Status": 0,
                "OtpVerifyCounterInSeconds": 0,
                "Id": 58612,
                "ServiceId": 1000,
                "BatchNo": 102,
                "TransactionSequenceNumber": 35298,
                "TransactionAmount": 100,
                "TransactionApprovalCode": "000000004330",
                "LoyaltyMessage": "",
                "Hash": "fe556fe622f3a3aa2b484666b2d7887c54932a9f469f016c3d00b740ed36de95"
            },
            "HttpCode": 200
        }
    }
}
```

{% endtab %}
{% endtabs %}


---

# 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/alternative-methods-apm/directpay/1.-initiate-payment.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.
