Skip to content

Initialize purchase

/klarna_instant_shopping/initialize_purchase

Target audience: Developers

Release version: 4.4.3

Initialize a Klarna Instant Shopping purchase

Introduction

This endpoint creates a klarna instant shopping session. This is used to gather information on a Klarna Instant Shopping purchase since the purchase is made at the merchant. Payway needs to have this information for setting up the initial order and payment.

If a account_id is not supplied the customer is identified from the data returned from Klarna after making the purchase. If a existing account in Payway can be identified, the purchase is made by that account, otherwise a new account is created.

URI

Environment URI
Stage https://payway-api.stage.adeprimo.se/external/api/v1/klarna_instant_shopping/initialize_purchase
Production https://backend.worldoftulo.com/external/api/v1/klarna_instant_shopping/initialize_purchase

Requirements

Identity Scope
No /external/klarna_payments/w

Curl example

curl --request POST \
  --url https://payway-api.stage.adeprimo.se/external/api/v1/klarna_instant_shopping/initialize_purchase \
  --header 'authorization: Bearer <token>' \
  --header 'content-type: application/json' \
  --data '{
    "purchase_id": "<UUID>",
    "account_id": "7f0d3aa745cfebfb8544ab21",
    "code":  "adeprimo_digital",
    "period_type": "limited",
    "period_id": "5f0d9ea795cfebfb8544ab12",
    "client_ip": "<client ip address>",
    "client_user_agent": "<client user agent>",
    "client_language": "<client language code>",
    "traffic_source": "traffic source",
    "merchant_reference": "merchant reference",
    "validate_purchase": true
  }'

Parameters

The request should be sent as application/json.

Parameter Description Required Format
purchase_id Unique id for the purchase, needs to be generated on the seller site Yes String
account_id Payway account id that is making the purchase. Do not use if the customer is not known. If not supplied a account will be created unless a existing Payway account can be identified based on data from Klarna. No String
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.Use payment periods API for fetching available payment periods Yes String
client_ip Client browser ip, needed for setting up order and payment in Payway Yes String
client_user_agent Client browser user agent string, needed for setting up order and payment in Payway Yes String
client_language Client language Yes String
traffic_source Traffic source to save on order in Payway, must be pre-defined in PAP
Size range: ..128
No String
merchant_reference Merchant reference to use for recurring Klarna payments No String
paywall_id The ID of the paywall.
Size range: ..24
Allowed values: "/^[a-f\d]{24}$/i"
No String
validate_purchase Perform a validation of campaign purchase rules and validation that the customer does not have a active subscription on the package already. Note that the validation takes place when the purchase is being completed and not in the context of creating the purchase session. No Bool
create_account_options Additional information on how a new account should be created
Released in 4.5.7
No Object
account_origin
Where the account/purchase was initialized from No String

Response

The response is sent as application/json.

Example of a successful response:

{
  "item": {
    "purchase_id": "<UUID>"
  }
}

Parameter Description
purchase_id The purchase id that was sent

Errors

This API uses the common error conventions of the Payway API

See common error responses