Creating an Inline Session

Create a new session whenever the customer displays your checkout page.
Inline Specifications
When you send a session request, set the
apSessionsService_paymentFlowMode
field to
inline
.
Cybersource
responds with a pre-approval token in the
apSessionsReply_processorToken
field. Set the Klarna widget installed in the merchant website to token. When the customer completes the checkout using the Klarna widget, the widget responds with an authorization token. Include the authorization token in the authorization request to link the authorization to the session.

Klarna Payment Methods

When you request the session service, you can determine the Klarna payment method you want to offer your customers. Set the optional
paymentMethod_name
request field to a value listed in the Payment Method column.
Payment Methods
Payment Method Field Value
Description
Klarna Products
pay_later
Customer pays total bill at a set date.
  • Klarna Invoice
  • Klarna Pay Later
  • Klarna Pay Later by Card (PLBC)
pay_now
Customer pays total bill at the time of checkout.
  • Klarna Direct Bank Transfer
  • Klarna Direct Debit
pay_over_time
Customer pays bill in equal multiple installments.
  • Klarna Account
  • Klarna Financing
  • Klarna Fixed Installment Plans
  • Klarna Interest Free
Example: Payment Methods in Session Request
<paymentMehtod_name>
pay_later
</paymentMethod_name>

Calculating the Grand Total Amount

Klarna requires that the grand total amount of a purchase be included in the request using the
purchaseTotals_grandTotalAmount
field. The country of the transaction and the use of coupons affect how to calculate the grand total amount.
For more information about how to calculate the grand total amount, see Calculating the Grand Total Amount in the Reference Information section.

Language Specification

To set the language for your Klarna checkout experience, include the
billTo_language
field in your request. By not including this field, the Klarna checkout experience is set to English by default. For a list of all possible values, see the
ISO Standard Language Codes
guide.
Example: Language Specification
<billTo> <language>es</language> </billTo>

Line Items

Klarna uses line items when you send a create session and update session requests. Line items are used to include information about the goods that your customers purchase, such as product name, quantity, and price.
Line items are represented as the
item_#_
fields, starting with
item_0_
, and increasing in numerical order.
For more information about how to properly format line items in your request, see Using Line Items in the Reference Information section.

Endpoints

Set the
apSessionsService_run
field to
true
, and send the request to one of these endpoints:
Production:
https://ics2ws.ic3.com/commerce/1.x/transactionProcessor
Test:
https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor

Response Status

The session service responds with one of these statuses as the
apSessionReply_status
field value:
  • FAILED
    : The session request is not successful. Send a new session request.
  • INITIATED
    : The session is initiated and the customer may now checkout. Send periodic check status requests until the status updates to
    COMPLETED
    . For more information, see Check a Request Status.
The session service also responds with a reason code as the
apSessionReply_reasonCode
field value. For more information about reason codes, see the Reason Codes for the Simple Order API.
When you send a check status request for an initiated session, you can receive one of these statuses when the session updates:
  • ABANDONED
    : The customer did not complete the payment using the redirect URL or widget.
  • COMPLETED
    : The customer completed the checkout process. You can now authorize the funds.

Requesting to Create an Inline Session

Follow these steps to successfully create an inline session.
  1. Send a request to the
    https://ics2ws.ic3.com/commerce/1.x/transactionProcessor
    endpoint and include these required fields:
    Do not send any personally identifiable information (PII) data about the customer in the request to create a session.
    Set to
    KLI
    .
    apSessionService_paymentFlowMode
    Set to
    inline
    to display the Klarna widget on your checkout page.
    apSessionsService_cancelURL
    Set to the URL to which the customer is redirected after cancelling the Klarna payment.
    Set to the URL to which the customer is redirected after the Klarna payment fails.
    apSessionsService_paymentMethod_name
    Set to one of these values to display the Klarna product you are offering:
    • pay_later
      : pay later
    • pay_now
      : pay now
    • pay_over_time
      : pay over time
    Set to
    true
    .
    Set to
    N
    .
    Set to the URL to which the customer is redirected after successfully completing the Klarna payment.
    Add
    /Klarna/Reply.jsp
    to the end of the URL.
    https://www.test.com
    /Klarna/Reply.jsp
    Replace the
    #
    character with the number
    0
    for the first item and consecutive numbers for any additional items.
    Replace the
    #
    character with the number
    0
    for the first item and consecutive numbers for any additional items.
    Replace the
    #
    character with the number
    0
    for the first item and consecutive numbers for any additional items.
    Replace the
    #
    character with the number
    0
    for the first item and consecutive numbers for any additional items.
  2. You can include these optional fields in the request:
    billTo_language
    If this field is not included, the language is set to English by default.
    For a list of possible values, see the
    ISO Standard Language Codes
    guide.
  3. To include an optional coupon in the request, include these fields:
    Set to
    coupon
    .
    Replace the
    #
    character with the number
    0
    for the first item and consecutive numbers for any additional items.
    Replace the
    #
    character with the number
    0
    for the first item and consecutive numbers for any additional items.
    Replace the
    #
    character with the number
    0
    for the first item and consecutive numbers for any additional items.
    Replace the
    #
    character with the number
    0
    for the first item and consecutive numbers for any additional items.
    Replace the
    #
    character with the number
    0
    for the first item and consecutive numbers for any additional items.
  4. Set the Session Token ID in the Klarna widget to the
    processorToken
    field value from the session response.
    ID
    eyJhbGciOiJSUzI1NiIsImtpZCI6IjgyMzA1ZWJjLWI4MTEtMzYzNy...
  5. When the customer completes the payment using the Klarna widget, the Klarna widget creates a unique authorization token. Store the token for the authorization request.
    Authorizaiton Token:
    a6b2229c-665b-5660-a5fe-063bef3d9a1e
  6. When you send the follow-on authorization request, set the
    apAuthService_preapprovalToken
    request field to the authorization token value created by the Klarna widget.
    <preapprovalToken>a6b2229c-665b-5660-a5fe-063bef3d9a1e</preapprovalToken>

XML Example: Creating a Session

Light Dark
Inline Request
12345678910111213141516171819202122232425262728293031323334353637
<="urn:schemas-cybersource-com:transaction-data-1.213"> <merchantID>test_merchant</merchantID> <merchantReferenceCode>refnum-1234</merchantReferenceCode> <billTo> <firstName>John</firstName> <lastName>Smith</lastName> <street1>123 Happy St</street1> <city>Sunnyville</city> <state>VA</state> <postalCode>12345</postalCode> <country>US</country> <email>john@email.com</email> </billTo> <item> <unitPrice>9.00</unitPrice> <quantity>1</quantity> <productCode>A4890B5023</productCode> <productName>Skirt on the sky</productName> <productSKU>skirtonsky$bluegreen</productSKU> <taxAmount>1.00</taxAmount> <totalAmount>10.00</totalAmount> <productDescription>Amnesiac Shirt</productDescription> </item> <purchaseTotals> <currency>USD</currency> <grandTotalAmount>10.00</grandTotalAmount> </purchaseTotals> <apPaymentType>KLI</apPaymentType> <apSessionsService run="true"> <cancelURL>https://www.merchant.com/Klarna/Reply.jsp</cancelURL> <successURL>https://www.merchant.com/Klarna/Reply.jsp</successURL> <failureURL>https://www.merchant.com/Klarna/Reply.jsp</failureURL> <sessionsType>N</sessionsType> <paymentMethod_name>pay_now</paymentMethod_name> <paymentFlowMode>inline</paymentFlowMode> </apSessionsService> </>
Inline Response
12345678910111213141516171819
<:c="urn:schemas-cybersource-com:transaction-data-1.213"> <merchantReferenceCode>refnum-1234</merchantReferenceCode> <requestID>6958601255246857703007</requestID> <decision>ACCEPT</decision> <reasonCode>100</reasonCode> <requestToken>AxjnrwSTeTn93WXAQw5f/6IZYjWmdmbZq0orKCojmjrTtjSBX0GY0MmkmXoxZaH/pN5Of3dZcBDDl8AA9DNl</requestToken> <purchaseTotals> <currency>USD</currency> </purchaseTotals> <apSessionsReply> <reasonCode>100</reasonCode> <responseCode>00000</responseCode> <processorToken>eyJhbGciOiJSUzI1NiIsIm_TEST_TOKEN_1ZWJjLWI4MTEtMzYzNy1hYTRjLTY2ZWNhM</processorToken> <amount>10.00</amount> <reconciliationID>XFZ3YMYURE2A</reconciliationID> <status>COMPLETED</status> <dateTime>2023-09-28T00:15:26Z</dateTime> </apSessionsReply> </>