Create session
Info
Target audience: Developers
Create purchase session¶
Introduction¶
This endpoint creates a klarna payments
purchase session. Needed for placing a klarna payments order.
Attention
This API gives access to Klarna payments related endpoints. Since this section is quite specific it has it's own section of documentation. See here for more information.
URI¶
Environment | URI |
---|---|
Stage | https://payway-api.stage.adeprimo.se/external/api/v1/klarna_payments/create_session |
Production | https://backend.worldoftulo.com/external/api/v1/klarna_payments/create_session |
Requirements¶
Identity | Scope |
---|---|
Yes | /external/klarna_payments/w |
Curl example¶
curl --request POST \
--url https://payway-api.stage.adeprimo.se/external/api/v1/klarna_payments/create_session \
--header 'authorization: Bearer <token-with-identity>' \
--header 'content-type: application/json' \
--data '{
"code": "adeprimo_digital",
"period_type": "recurring",
"period_id": "5f0d9ea795cfebfb8544ab12,",
"confirmation_url": "https://confirmation_url.com",
"start_date": "2021-10-30"
}'
Parameters¶
The request should be sent as application/json.
Parameter | Description | Required | Format |
---|---|---|---|
code | The code of the package or campaign e.g. adeprimo_digital | Yes | String |
period_type | limited or recurring. Always set to recurring for campaigns | Yes | String |
period_id | Specific payment period id. Required for trial orders | For trial orders but not regular orders. Use payment periods API for fetching available payment periods | String |
confirmation_url | URL to your confirmation page for the customer | Yes | String |
start_date | Start date of subscription, must be today or a future date if supplied. Format YYYY-MM-DD | No | Date |
disable_account_info_overwrite* | Prevent existing account information from being overwritten by the information received through Klarna Payments. | No (default false) | Boolean |
Disable account information overwrite*¶
It is possible to disable updating existing information on the account that is purchasing using Klarna Payments. This is accomplished by using the parameter disable_account_info_overwrite. The parameter is not required and defaults to false.
The fields first_name, last_name, mobile_phone, ssn and birthdate will be updated if they are empty. The account address will only be updated if all of the following fields are empty: street, building, staircase, apartment_number, drop_box, zip_code, city, company_name, company_reference, company_department, company_crn and company_vat_number.
Please note that the account information will only be overwritten in the case of an actual purchase, and this will as such have no effect if a trial order is placed.
Response¶
The response is sent as application/json.
Example of a successful response:
{
"item": {
"klarna_payments_session_id": "5aba2ca36fc93613f8000012",
"klarna_client_token": "eyJhbGciOIJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjAwMDAwMDAwMDAtMDAwMDAtMDAwMC0wMDAwMDAwMC0wMDAwIiwidXJsIjoiaHR0cHM6Ly9jcmVkaXQtZXUua2xhcm5hLmNvbSJ9.A_rHWMSXQN2NRNGYTREBTkGwYwtm-sulkSDMvlJL87M",
"payment_method_categories": [
{
"identifier": "direct_debit",
"name": "Bankkonto",
"asset_urls": {
"descriptive": "https://x.klarnacdn.net/payment-method/assets/badges/generic/klarna.svg",
"standard": "https://x.klarnacdn.net/payment-method/assets/badges/generic/klarna.svg"
}
},
{
"identifier": "pay_later",
"name": "Få först. Betala sen.",
"asset_urls": {
"descriptive": "https://x.klarnacdn.net/payment-method/assets/badges/generic/klarna.svg",
"standard": "https://x.klarnacdn.net/payment-method/assets/badges/generic/klarna.svg"
}
}
]
}
}
Parameter | Description |
---|---|
klarna_payments_session_id | The id of the session that you just created. This is needed when you place the order. You should store this in the user's session in your backend |
klarna_client_token | You need to use this token when you build the Klarna Payments Widget on your site |
payment_method_categories | Payment methods available for that payment session |
Errors¶
This API uses the common error conventions of the Payway API