# Session Initiation

POST /partner/v3/shops/:uuid/pos-sessions

To start a payment session in Inbank e-POS, use the POST /shops/:uuid/pos-session. The response includes the identifier of the payment session - posSessionUuid and the URL to which the customer is to be redirected - redirectUrl.

For your convenience, we have listed the minimal data set which needs to be passed to Inbank.

The customerData, customerContactData and merchant objects and parameters included in them are optional. A request that does not contain these objects will be processed correctly. However, if the body does contain these objects, Inbank will validate the parameters passed inside them. Therefore, if the request contains customerData/customerContactData/merchant objects, their parameters become required.

Endpoint: POST /partner/v3/shops/{shopUuid}/pos-sessions
Security: bearerAuth

## Path parameters:

  - `shopUuid` (string, required)
    Example: "a93f1f44-d5dd-4469-bfcc-c1de9e969213"

## Request fields (application/json):

  - `productCode` (string, required)
    Reference to product code.

  - `currency` (string, required)
    Currency code in uppercase. Available option is EUR.

  - `locale` (string, required)
    Language - country codes, for example et-ET.

  - `validUntil` (string)
    The point in time when the payment session is to expire. E.g. 2021-02-17T11:10:00+02:00. After this time, the customer will not be able to complete the financing procedure.

  - `userIp` (string)
    Customer browser IP address as seen by e-shop.

  - `customerData` (string, required)
    Data used to pre-fill credit application fields regarding the customer. Allowed keys:
  - identityCode*
  - firstName*
  - lastName*
  - gender - options: m (male), f (female).

  - `customerContactData` (string, required)
    Data used to pre-fill credit application fields regarding customer contact information. Allowed keys:
  - email*
  - mobile*

  - `purchase` (object, required)

  - `purchase.purchaseReference` (string)
    Unique identifier of the shopping cart or order in the e-shop (i.e. order ID).

  - `purchase.description` (string, required)
    Textual description of the order or shopping cart, meaningful for the customer.

  - `purchase.additionalDetails` (object)
    Any additional details about the order that are not covered with predefined parameters.

  - `purchase.merchant` (array)
    Array of items containing information about the merchant supplying the purchase.

  - `purchase.merchant.[0]` (object)

  - `purchase.merchant.[0].merchantOrderReference` (string)
    Order reference of the merchant.

  - `purchase.merchant.[0].merchantDomainName` (string)
    URL of the merchant. This is the URL of the partner website from which purchases are done.

  - `rentalApplicationData` (object, required)
    Information on the items that is to be the object of Smart Rent.

  - `rentalApplicationData.insuranceUsed` (boolean)
    Whether insurance is added to the assets. If no value is passed in the request, default value true is used.

  - `rentalApplicationData.grossCampaignDiscount` (number)
    The gross amount of the campaign discount.

  - `rentalApplicationData.grossTradeInAmount` (number)
    The gross amount of the traded in asset.

  - `rentalApplicationData.assets` (array, required)
    Information on the items that are to be the objects of Smart Rent. 
Please note, that the hero device (this is the main device that is rented) needs to be first in the list of assets.

  - `rentalApplicationData.assets.[0]` (object)

  - `rentalApplicationData.assets.[0].modelId` (string)
    Required if assets["type"] is MODEL_BASED 
 Required for the hero device. 
Identifier of the model of the product that is to be the object of Smart Rent.

  - `rentalApplicationData.assets.[0].modelName` (string, required)
    The title of the item that is to be the object of Smart Rent.

  - `rentalApplicationData.assets.[0].categoryCode` (number)
    Required if assets["type"] is CATEGORY_BASED
Identifier of the model of the product that is to be the object of Smart Rent.
Category code of the asset from the predefined list. Additional category codes can be agreed with Inbank. Currently available category codes are:
  - add_on
  - copying_fee (is applicable for only Latvia)
  - shipping_fee

  - `rentalApplicationData.assets.[0].netPrice` (number, required)
    The net price (without VAT) of the item that is to be the object of Smart Rent.

  - `rentalApplicationData.assets.[0].type` (string, required)
    The type of the configuration. Available options:
- MODEL_BASED (the assets are categorised by manufacturer and model).
  Please note, the hero device needs to have the type set to MODEL_BASED.
- CATEGORY_BASED (the assets are categorised by product category).
If the type is not sent in the request, default value CATEGORY_BASED is applied.

  - `rentalApplicationData.period` (number, required)
    Smart Rent duration in month.

  - `partnerUrls` (object)

  - `partnerUrls.returnUrl` (string, required)
    Partner defined URL to which the customer should be redirected after the application dialog.

  - `partnerUrls.cancelUrl` (string, required)
    Partner defined URL to which the customer should be redirected in case they deliberately cancelled the application dialog.

  - `partnerUrls.callbackUrl` (string)
    URL for sending server-to-server callback messages about session status changes.

  - `integrationInfo` (string)
    Information about the technical environment of the partner side integration, e.g.: “ecom_platform”:“string”, “Module”:“string"

  - `additionalData` (string)
    Container for additional data that e-shops can pass to e-POS dialogs (pre-filling forms). 
Any keys are allowed.

## Response 201 fields (application/json):

  - `uuid` (string)
    Identifier of the POS session. Store this identifier at the order metadata for later usage.
    Example: "5e3a459a-aada-4d81-b6ad-09cb9483c8bf"

  - `status` (string)
    The status of the POS session.
    Example: "pending"

  - `redirectUrl` (string)
    The link to which the customer is to be redirected to complete the rental process in the e-POS environment.
    Example: "https://demo-epos.inbank.ee/session/5e3a459a-aada-4d81-b6ad-09cb9483c8bf"

## Response 401 fields (application/json):

  - `message` (string)
    Unauthorized
    Example: "unauthorized"

## Response 403 fields (application/json):

  - `message` (string)
    Unauthorized access
    Example: "User is not authorized to access this resource with an explicit deny"

## Response 404 fields (application/json):

  - `message` (string)
    Not Found
    Example: "not_found"

## Response 500 fields (application/json):

  - `message` (string)
    Internal server error
    Example: "internal_server_error"


