# Creating Payment Session

**Method:** `POST`

**Path:** `/processor/payment-sessions`

Requests can be sent with `Akinon-User-Access-Token` or without a token.

## <mark style="color:red;">Query Parameters​</mark> <a href="#query-parameters" id="query-parameters"></a>

<table><thead><tr><th width="154.6640625">Parameter</th><th width="108.81640625">Type</th><th width="111.43359375">Mandatory</th><th>Description</th></tr></thead><tbody><tr><td>amount</td><td>number</td><td>required</td><td>Total amount of products in the basket.</td></tr><tr><td>currency</td><td>currency</td><td>optional</td><td>Currency of the payment session. If not provided, default is set to TRY.</td></tr><tr><td>order_id</td><td>string</td><td>required</td><td>Unique ID created for the order of the products in the basket.</td></tr><tr><td>conversation_id</td><td>string</td><td>optional</td><td>Conversation number to be sent by the merchant, boomerang value.</td></tr><tr><td>order_date</td><td>string</td><td>required</td><td>Order date.</td></tr><tr><td>cancel_url</td><td>string</td><td>required</td><td>URL redirected when the order is canceled or after an unsuccessful payment transaction.</td></tr><tr><td>success_url</td><td>string</td><td>required</td><td>URL redirected after a successful payment transaction.</td></tr><tr><td>notification_url</td><td>string</td><td>required</td><td>URL to inform the merchant after a successful payment process.</td></tr><tr><td>query_shipping_option_url</td><td>string</td><td>required</td><td>URL where shipping information will be queried.</td></tr><tr><td>query_agreements_url</td><td>string</td><td>If the agreements_iframe_url field is empty, this field is mandatory</td><td>URL where agreements will be queried.</td></tr><tr><td>query_agreement_types_url</td><td>string</td><td>If the agreements_iframe_url field is empty, this field is mandatory</td><td>URL where agreement types will be queried.</td></tr><tr><td>agreements_iframe_url</td><td>string</td><td>If the query_agreements_url and query_agreement_types_url fields are empty, this field is mandatory</td><td>If both query_agreements_url and query_agreement_types_url fields are empty, this field is required for querying agreement types in an iframe.</td></tr><tr><td>preauth</td><td>boolean</td><td>optional</td><td>Determines whether the payment transaction is pre-authorized. Default is false.</td></tr><tr><td>enable_installments</td><td>boolean</td><td>optional</td><td>Used for applying installments if available. Default is true.</td></tr><tr><td>merchant_customer_id</td><td>string</td><td>optional</td><td>Customer identification number belonging to the merchant. If defined, ownership of the payment session is determined.</td></tr><tr><td>merchant_customer_phone_number</td><td>string</td><td>optional</td><td>Customer phone number belonging to the merchant.</td></tr><tr><td>merchant_customer_email</td><td>string</td><td>optional</td><td>Customer email address belonging to the merchant.</td></tr><tr><td>basket</td><td>object</td><td>optional</td><td>Basket holding selected products during the payment session.</td></tr><tr><td>basket.basket_id</td><td>string</td><td>required</td><td>Basket identification number.</td></tr><tr><td>basket.total_product_amount</td><td>number</td><td>required</td><td>Total amount of products in the basket.</td></tr><tr><td>basket.total_discount_amount</td><td>number</td><td>required</td><td>Total discount amount applied to the products in the basket.</td></tr><tr><td>basket.total_amount</td><td>number</td><td>required</td><td>Calculated total amount of products in the basket.</td></tr><tr><td>basket.currency</td><td>currency</td><td>optional</td><td>Currency of the product added to the basket. If not provided, default is set to TRY.</td></tr><tr><td>basket.basket_items[0].sku</td><td>string</td><td>required</td><td>Stock code of the product.</td></tr><tr><td>basket.basket_items[0].basket_item_id</td><td>string</td><td>required</td><td>Unique identification number for each product in the basket.</td></tr><tr><td>basket.basket_items[0].unit_price</td><td>number</td><td>required</td><td>Unit price of each product in the basket.</td></tr><tr><td>basket.basket_items[0].quantity</td><td>long</td><td>required</td><td>Quantity of each product in the basket.</td></tr><tr><td>basket.basket_items[0].price</td><td>number</td><td>required</td><td>Calculated amount of each product in the basket.</td></tr><tr><td>basket.basket_items[0].name</td><td>string</td><td>required</td><td>Name of each product in the basket.</td></tr><tr><td>basket.basket_items[0].image_url</td><td>string</td><td>optional</td><td>URL of the image of each product in the basket.</td></tr><tr><td>basket.discounts[0].description</td><td>string</td><td>optional</td><td>Description of the discount applied to the products in the basket.</td></tr><tr><td>basket.discounts[0].amount</td><td>number</td><td>required</td><td>Percentage of the discount applied to the products in the basket.</td></tr><tr><td>session_owner_id</td><td>string</td><td>optional</td><td>User ID present in the Akinon system. If defined, the payment session is allocated only for this user.</td></tr></tbody></table>

## <mark style="color:red;">Example Request​</mark> <a href="#example-request" id="example-request"></a>

```json
{
"amount" : "80",
"currency" : "TRY",
"order_id" : "28022XX21430",
"conversation_id": "JHsxbsW28022XX21430",
"order_date" : "2021-12-16T15:01:23.51+03:00",
"cancel_url" : "http://localhost:7005/cancel-order/2022022XX43627",
"success_url" : "http://localhost:7005/success-order/2022022XX43627",
"notification_url" : "http://localhost:7005/notify-url/2022022XX43627",
"preauth" : false,
"query_shipping_option_url": "https://61c1c3459dbccaXX17c82102.mockapi.io/api/shipping_options",
"query_agreements_url": "https://61dd7bc1fXXe8f0017668849.mockapi.io/agreements",
"query_agreement_types_url": "http://localhost:7005/query-agreement-types",
"agreements_iframe_url": "http://localhost:7005/agreements-iframe-url",
"enable_installments" : true,
"merchant_customer_id": null,
"merchant_customer_phone_number": null,
"merchant_customer_email": null,
"session_owner_id": "C2C0CE12F64B410XX09BB854D08706F5",
"basket" : {
    "basket_id" : "B-20211XX91524",
    "total_product_amount": "100",
    "total_discount_amount" : "20",
    "total_amount" : "80",
    "currency" : "TRY",
    "total_quantity" : 1,
    "basket_items" : [
        {
            "sku": "2100123574",
            "basket_item_id" : "P-B-20211XX91524-1",
            "unit_price": "100",
            "quantity" : 1,
            "price": "100",
            "brand" : "test brand",
            "name" : "test name",
            "image_url" : "test image url"
        }
    ],
    "discounts" : [
        {
            "description" : "test description",
            "amount" : "20"
        }
    ]
  }
}
```

## <mark style="color:red;">Response Parameters​</mark> <a href="#response-parameters" id="response-parameters"></a>

<table><thead><tr><th width="189.7265625">Field Name</th><th width="133.83984375">Type</th><th>Description</th></tr></thead><tbody><tr><td>merchant_id</td><td>string</td><td>Merchant's identity number to which the session is directed during creation.</td></tr><tr><td>customer_id</td><td>string</td><td>Identification information belonging to the customer.</td></tr><tr><td>amount</td><td>number</td><td>The total amount of products in the basket.</td></tr><tr><td>currency</td><td>currency</td><td>The currency of the payment session.</td></tr><tr><td>description</td><td>string</td><td>Detailed description of the products added to the basket.</td></tr><tr><td>order_id</td><td>string</td><td>Unique ID created for the order of the products added to the basket.</td></tr><tr><td>cvv_required</td><td>boolean</td><td>Information about whether the CVV value of the card needs to be used.</td></tr><tr><td>order_date</td><td>string</td><td>Order date.</td></tr><tr><td>cancel_url</td><td>string</td><td>URL redirected when the order is canceled or after an unsuccessful payment transaction.</td></tr><tr><td>success_url</td><td>string</td><td>URL redirected after a successful payment transaction.</td></tr><tr><td>query_shipping_option_url</td><td>string</td><td>URL where shipping information will be queried.</td></tr><tr><td>query_agreements_url</td><td>string</td><td>URL where agreements will be queried.</td></tr><tr><td>query_agreement_types_url</td><td>string</td><td>URL where agreement types will be queried.</td></tr><tr><td>agreements_iframe_url</td><td>string</td><td>Iframe URL where agreement types will be queried.</td></tr><tr><td>shipping_address</td><td>string</td><td>Key indicating the address to which the shipment will be sent.</td></tr><tr><td>billing_address</td><td>string</td><td>Key indicating the address to which the invoice will be sent.</td></tr><tr><td>shipping_option_key</td><td>string</td><td>Unique identification number for shipments.</td></tr><tr><td>shipping_amount</td><td>number</td><td>Shipping amount.</td></tr><tr><td>total_amount</td><td>number</td><td>Total amount of shipping and products in the basket.</td></tr><tr><td>preauth</td><td>boolean</td><td>Determines whether the payment transaction is pre-authorized. Default is false.</td></tr><tr><td>is_threed</td><td>boolean</td><td>Determines whether the payment transaction is carried out with 3D. Default is false.</td></tr><tr><td>enable_installments</td><td>boolean</td><td>Used for applying installments if available. Default is true.</td></tr><tr><td>session_token</td><td>string</td><td>A unique key created for the session.</td></tr><tr><td>transaction_token</td><td>string</td><td>A unique key created for the session.</td></tr><tr><td>akinon_user_id</td><td>string</td><td>Identification number created for the Akinon user.</td></tr><tr><td>created_date</td><td>string</td><td>Date when the session is created.</td></tr><tr><td>expiry_date</td><td>string</td><td>Date when the session will expire.</td></tr><tr><td>status</td><td>enum</td><td>Session status.</td></tr><tr><td>merchant_customer_id</td><td>string</td><td>Customer identification number belonging to the merchant.</td></tr><tr><td>merchant_customer_phone_number</td><td>string</td><td>Customer phone number belonging to the merchant.</td></tr><tr><td>merchant_customer_email</td><td>string</td><td>Customer email address belonging to the merchant.</td></tr><tr><td>basket</td><td>object</td><td>The basket that holds the selected products and discounts during the payment session.</td></tr><tr><td>basket.basket_id</td><td>string</td><td>The identification number of the basket.</td></tr><tr><td>basket.total_product_amount</td><td>number</td><td>Total amount of products in the basket.</td></tr><tr><td>basket.total_discount_amount</td><td>number</td><td>Total discount amount applied to the products in the basket.</td></tr><tr><td>basket.total_amount</td><td>number</td><td>Calculated total amount of products in the basket.</td></tr><tr><td>basket.currency</td><td>currency</td><td>Currency of the product added to the basket. If not provided, TRY is assigned by default.</td></tr><tr><td>basket.basket_items[0].sku</td><td>string</td><td>Stock code of the product.</td></tr><tr><td>basket.basket_items[0].basket_item_id</td><td>string</td><td>Unique identification number for each product in the basket.</td></tr><tr><td>basket.basket_items[0].unit_price</td><td>number</td><td>Unit price of each product in the basket.</td></tr><tr><td>basket.basket_items[0].quantity</td><td>long</td><td>Quantity of each product in the basket.</td></tr><tr><td>basket.basket_items[0].price</td><td>number</td><td>Calculated amount of each product in the basket. (quantity*unit_price)</td></tr><tr><td>basket.basket_items[0].name</td><td>string</td><td>Name of each product in the basket.</td></tr><tr><td>basket.basket_items[0].image_url</td><td>string</td><td>URL of the image of each product in the basket.</td></tr><tr><td>basket.discounts[0].description</td><td>string</td><td>Description of the discount applied to the products in the basket.</td></tr><tr><td>basket.discounts[0].amount</td><td>number</td><td>Percentage of the discount applied to the products in the basket.</td></tr><tr><td>session_owner_email</td><td>string</td><td>If filled, indicates that the related payment session belongs only to this user.</td></tr></tbody></table>

## <mark style="color:red;">Example Response​</mark> <a href="#example-response" id="example-response"></a>

```json
{
"trace_id": "a4dde67e-2ee5-417e-98XX-45c7aa0e088f",
"response": {
    "merchant_id": "9d36ec04-de2f-11ea-87XX-0242ac130003",
    "customer_id": "CUSTOMER_060X16",
    "amount": 80,
    "currency": "TRY",
    "description": "test description",
    "order_id": "28022XX21430",
    "cvv_required": true,
    "order_date": "2021-12-16T15:01:23.51+03:00",
    "cancel_url": "http://localhost:7005/cancel-order/2022022XX43627",
    "success_url": "http://localhost:7005/success-order/2022022XX43627",
    "query_shipping_option_url": "https://61c1c3459dXXca0017c82102.mockapi.io/api/shipping_options",
    "query_agreements_url": "https://61dd7bc1fXXe8f0017668849.mockapi.io/agreements",
    "query_agreement_types_url": "http://localhost:7005/query-agreement-types",
    "agreements_iframe_url": "http://localhost:7005/agreements-iframe-url",
    "shipping_address": null,
    "billing_address": null,
    "shipping_option_key": null,
    "shipping_amount": null,
    "total_amount": 100,
    "preauth": false,
    "is_threed": false,
    "enable_installments": true,
    "session_token": "e7d624f0-c842-4826-a3XX-8c05cc6d6114",
    "transaction_token": "JGmhG9bOro82/84JdjAWNflDH2dynHsckkrpRRXXpc73NLwSSe5+dzHa9JxdpIBKnWtAEfGhaYpFGrEoBQJlyg==",
    "akinon_user_id": "C2C0CE12F64B41038XXBB854D08706F5",
    "created_date": "2022-03-01T11:08:29.67+03:00",
    "expiry_date": "2022-03-01T12:08:29.66+03:00",
    "status": "ACTIVE",
    "merchant_customer_id": null,
    "merchant_customer_phone_number": null,
    "merchant_customer_email": null,
    "session_owner_email": "john.doe@example.com",
    "basket": {
        "basket_id": "B-20211X191524",
        "total_product_amount": 100,
        "total_discount_amount": 20,
        "total_amount": 80,
        "currency": "TRY",
        "basket_items": [
            {
                "sku": "2100XX3574",
                "basket_item_id": "P-B-20211XX91524-1",
                "unit_price": 100,
                "quantity": 1,
                "price": 100,
                "name": "test name",
                "image_url": "test image url"
            }
        ],
        "discounts": [
            {
                "description": "test description",
                "amount": 20
            }
        ]
      }
  }
}
```
