# 1. Create Payment

## Initiate Payment / QR-Based

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

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

\
[<mark style="color:green;">**PaymentAPI Address**</mark>](https://developer.paywall.one/payment-orchestration-integration-document/environment)
{% 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="92">Type</th><th width="143">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="245">Parameter</th><th width="104">Type</th><th width="183">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="broken-reference">APM</a></p></td></tr><tr><td>ApmConnectionId</td><td>int</td><td>Yes (Conditional)</td><td>It is the Id (identifier) information obtained from the APM listing service connections. In scenarios where you dynamically generate your payment screen, you can initiate payments through the relevant connection using this parameter.</td></tr><tr><td>CurrencyId</td><td>int</td><td>Yes</td><td>The currency in which the payment is to be processed.<br><br>Bkz: <a href="../../system-data/currency">Currencies</a></td></tr><tr><td>MerchantUniqueCode</td><td>string</td><td>Yes</td><td>The unique identifier 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>Description of the payment. Depending on the provider, this description may be displayed on the payment screen.</td></tr><tr><td>Provider</td><td>object</td><td>No</td><td>This is used when there are specific information requirements from the provider. It is not currently active for QR-based payments and can be passed as null.</td></tr><tr><td>UserRedirectUrl</td><td>string</td><td>No</td><td>This is the address provided for redirection in wallet applications where scanning the QR code and successful payment may lead the user.</td></tr><tr><td>MerchantSuccessBackUrl</td><td>string</td><td>Yes</td><td>This is the address where the successful result of the payment will be reported via POST.</td></tr><tr><td>MerchantFailBackUrl</td><td>string</td><td>Yes</td><td>This is the address where the unsuccessful result of the payment will be reported via POST.</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
{
    "ApmKey": "papara",
    "ApmConnectionId": null, // Eğer bağlantı kimlik Id'sini biliyorsanız
    "CurrencyId": 1,
    "MerchantUniqueCode": "55555454544333545435",
    "UserRedirectUrl": "https://merchantsite.com/?paymentId=13114141",
    "MerchantSuccessBackUrl": "https://merchantsite.com/callback/success",
    "MerchantFailBackUrl": "https://merchantsite.com/callback/fail",
    "Amount": 1,
    "Description": "PW 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, providing 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><tr><td>Body:FormatType</td><td>int</td><td><p>It indicates the format of the QR code.</p><p><br>Bkz: <a href="broken-reference">Formatlar</a></p></td></tr></tbody></table>

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

```json
{
    "ErrorCode": 0,
    "Result": true,
    "Message": "",
    "Body": {
        "ApmKey": "ProviderKey",
        "ApmConnectionId": 62,
        "ApmTransactionId": 11676,
        "UniqueCode": "273162b1-ffae-45c6-9e22-724ca27f826a",
        "MerchantUniqueCode": "55555454544333545435",
        "Amount": 1.0,
        "QrDetail": {
            "FormatType": 1,
            "Content": "%BASE64CONTENT%"
        }
    }
}
```

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