> For the complete documentation index, see [llms.txt](https://developer.paywall.one/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.paywall.one/payment-orchestration-integration-document/alternative-methods-apm/checkoutpage/1.-initiate-payment-by-id.md).

# 1. Initiate Payment (By ID)

## Initiate Payment (ID)

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

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

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

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

<table><thead><tr><th width="178">Parameter</th><th width="97">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="234.30078125">Parameter</th><th width="92">Type</th><th width="132.65234375">Compulsory</th><th width="336">Description</th></tr></thead><tbody><tr><td>ApmId</td><td>int</td><td>Yes</td><td>APM provider connection identity information returned during listing</td></tr><tr><td>CurrencyId</td><td>int</td><td>Yes</td><td>Currency in which the payment is requested<br><br>See: <a href="/pages/bahfUMz1dqpN1ZCnpVtM">Currency</a></td></tr><tr><td>MerchantUniqueCode</td><td>string</td><td>Yes</td><td>Unique number you created for the payment</td></tr><tr><td>MerchantSuccessBackUrl</td><td>string</td><td>Yes</td><td>Address to which the successful payment result will be sent receives Post Body response</td></tr><tr><td>MerchantFailBackUrl</td><td>string</td><td>Yes</td><td>Address to which the successful payment result will be sent receives Post Body response</td></tr><tr><td>Amount</td><td>decimal</td><td>Yes</td><td>Payment amount<br><br><mark style="color:yellow;">*</mark> <code>If IsRecurring</code> is <mark style="color:$success;"><code>true</code></mark> this value represents the maximum amount to be charged</td></tr><tr><td>Description</td><td>string</td><td>Yes</td><td>Description of the payment Depending on the provider this description may be displayed on the payment screen</td></tr><tr><td>IsRecurring</td><td>bool</td><td>No</td><td>If the APM provider supports receiving payment instructions this parameter should be sent as <code>true</code><br><br>Supported Provider <strong>Masterpass</strong></td></tr><tr><td>ExpireDay</td><td>int</td><td>No</td><td>Used if the APM provider supports expiration date on the relevant page/payment flow expects number of days and adds it on top of the current active day<br><br>Supported Provider <strong>Masterpass</strong></td></tr><tr><td>IsAutoCommit</td><td>bool</td><td>No (true)</td><td><p>By default, the value is <strong>"true"</strong>. If you want to change it, it should be set to <strong>"false"</strong></p><p></p><p>When <strong>true</strong> is sent → After the 3D process, once the payment is completed on the screen, the amount is immediately charged from the card</p><p>When <strong>false</strong> is sent → After the payment, a callback is triggered and then a separate <strong>commit</strong> request must be sent</p></td></tr><tr><td>Payer</td><td><mark style="color:orange;">Payer</mark></td><td>Yes</td><td><p>Object containing the payer information for the payment</p><p>The required fields within this object may vary depending on the parameters expected by the provider</p><p></p><p>It is recommended to send all information</p></td></tr></tbody></table>

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

<table><thead><tr><th width="187.81640625">Parameter</th><th width="128.875">Type</th><th width="188.796875">Compolsory</th><th width="336">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 the card is 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>

**An example JSON file to be sent to the service is as follows:**

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

```json5
{
    "ApmId": 1,
    "CurrencyId": 1,
    "MerchantUniqueCode": "TESTMERCHANTUNIQUECODE",
    "MerchantSuccessBackUrl": "https://webhook.site/38a6fa6f-3414-40db-b2a7-a6c38894b6a3",
    "MerchantFailBackUrl": "https://webhook.site/38a6fa6f-3414-40db-b2a7-a6c38894b6a3",
    "Amount": 1,
    "Description": "test",
    "Payer": {
        "Fullname": "",
        "CardNumber": "",
        "CardId": "",
        "Phone": "",
        "Email": "",
        "UserIdentity": "",
        "ConsumerIdentity": "",
        "Birthday": null
    },
    "Products": [
        {
            "ProductId": "123",
            "ProductName": "Name",
            "ProductCategory": "Food",
            "ProductDescription": "Description of Product",
            "ProductAmount": 1
        }
    ]
}
```

{% endcode %}
{% 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. If the transaction is successful, it returns a value of '0'.</td></tr><tr><td>Result</td><td>bool</td><td>It returns a boolean value where 'true' indicates a successful transaction.</td></tr><tr><td>Message</td><td>string</td><td>If the transaction fails, this message specifies the error and provides language support based on the 'locale' parameter.</td></tr><tr><td>Body</td><td>object</td><td>If the transaction fails, this object provides details about the error.</td></tr></tbody></table>

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

```json
{
    "ErrorCode": 0,
    "Result": true,
    "Message": "",
    "Body": {
        "RedirectUrl": "https://dev-payment-agent.itspaywall.com/paywall/callbackapm?UniqueNumber=dd224827-8433-45f7-9454-97025e57fa9e",
        "Transaction": {
            "ApmTransactionId": 29,
            "UniqueCode": "dd224827-8433-45f7-9454-97025e57fa9e",
            "MerchantUniqueCode": "TESTMERCHANTUNIQUECODE",
            "Amount": 1.0
        }
    }
}
```

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