/place_order

/adyen/place_order

Target audience: Developers

1
Release version: 4.2.0

Introduction

This endpoint places an Adyen order. Depending on the result further actions might need to be taken. See here.

Attention

This API gives access to Adyen 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/adyen/place_order
Production https://backend.worldoftulo.com/external/api/v1/adyen/place_order

Requirements

Identity Scope
Yes /external/adyen/w

Curl example

Request

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
curl --request POST \
  --url https://payway-api.stage.adeprimo.se/external/api/v1/adyen/place_order \
  --header 'authorization: Bearer <token-with-identity>' \
  --header 'content-type: application/json' \
  --data '{
  "payment_method": {
    "type": "scheme",
    "issuer": "265"
  },
  "product_code": "package_code",
  "period_id": "5e4beac909c04c404a46c730",
  "return_url": "https://returnurl.com",
  "traffic_source": "facebook",
  "subscription_start_date": "2015-05-15",
  "discount_code": "code",
  "origin": "https://example.purchase.org",
  "browser_info": {
    "browser_ip": "127.0.0.1",
    "browser_language": "sv-FI",
    "browser_user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36",
    "referer": "https://adeprimokuriren.se",
    "acceptHeader": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
    "colorDepth": 24,
    "screenHeight": 723,
    "screenWidth": 1536,
    "timeZoneOffset": 0,
    "javaEnabled": true
  },
  "delivery_address": {
    "first_name": "Donald",
    "last_name": "Duck",
    "street": "Webfoot Walk",
    "street_number": "1313",
    "zip_code": "83145",
    "city": "Ankeborg",
    "country_code": "SE"
  }
}'

Parameters

Parameter Description Required Format Type
payment_method Payment method received from state data in onSubmit event Yes Provided by Adyen widget Object
product_code The product code for a package/campaign. Yes Size range: 1..50 Allowed values: "/^[a-zA-Z-_0-9]+$/" String
period_id Id of the selected payment period Yes Size range ..24
Allowed values: "/^[a-f\d]{24}$/i"
String
return_url URI for payment provider redirects, e.q. 3D Secure 1 Yes Size range: ..1024 Allowed values: uri regex that is too long to show here. Must be absolute String
traffic_source The source of the purchase. E.g. facebook, web. Traffic sources need to be setup in PAP Optional Size range: ..100 String
origin URI where purchase is performed (E.g. https://purchase.example.org) Yes Size range: ..1024 Allowed values: uri regex that is too long to show here. Must be absolute String
subscription_start_date Date when the subscription will be activated Optional Allowed values: 2020-05-15 DateTime
discount_code Discounted price. Code needs to be defined in PAP Optional Size range: 1..100 String
browser_info Information about client browser Yes Object
browser_ip
Client ip-address Yes e.q. "127.0.0.1" String
browser_language
Client language Yes e.q. "sv-FI" or "sv-SE" String
browser_user_agent
Client user agent Yes e.q. "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36" String
referer
Origin URI of the request Yes e.q. "https://adeprimokuriren.se" String
accept_header
Client accept header Yes e.q. "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8" String
color_depth
Color depth of client browser Yes e.q. 24 Integer
screen_height
Screen height of client browser Yes e.q. 723 Integer
screen_width
Screen width of client browser Yes e.q. 1536 Integer
time_zone_offset
TimeZoneOffset of client browser Yes e.q. 0 Integer
java_enabled
Is java enabled on client browser Yes e.q. true/false Boolean
delivery_address Address object. Fields marked as required is always required in order to update any field of the address. Optional Object
first_name
First name Required String
last_name
Last name Required String
street
Streetname Required String
street_number
The street number, some subscription-systems only allow numerical values Optional String
zip_code
The zipcode Required String
floor
The floor Optional String
apartment_number
The apartment number Optional String
entrance
The entrance Optional String
city
The city Required String
dropbox
Dropbox Optional String
country_code
Country code Required SE, FI or AX String

Here we can receive three types of answers. Depending on the status code received you will have to perform additional actions to complete the payment.

Purchase complete

1
2
3
4
5
6
7
8
9
HTTP 200 Purchase complete
{
  "item": {
    "receipt_id": "5e4becc109c04c404a46c744",
    "order_id": "ADEPRIMO-123",
    "message": "The payment was successfully authorised.",
    "status": "complete"
  }
}
If the status is "complete" then no additional actions need to be taken.

The "receipt_id" can be used to fetch the receipt for the recently made payment using the Me API.

Payment pending
1
2
3
4
5
6
7
HTTP 200 Payment pending
{
  "item": {    
    "message": "It's not possible to obtain the final status of the payment at this time.",
    "status": "pending"
  }
}

If the status is "pending" the user has completed the payment but the final result is not yet known. Payway will receive a callback when it is.

Payway either fails or completes the payment depending on the result.

For a successful result, the events associated with a completed purchase will be triggered. For instance order_closed.

In turn, all the events associated with a failed purchase will be triggered on an unsuccessful result. For instance payment_failure.

Action required
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
HTTP 200 Action required
{
  "item": {
    "action": {
      "paymentMethodType": "scheme",
      "token": "eyJ0aHJlZURTTWV0aG9kTm90aWZpY...",
      "type": "threeDS2Fingerprint"
    },
    "session_reference": "session_reference",
    "message": "The issuer requires further shopper interaction before the payment can be authenticated. Returned for 3D Secure 2 transactions.",
    "status": "action_required"
  }
}

If you receive the status "action_required" you need to perform additional action(s) to complete the purchase.

See here for more info.

Errors

The error response is sent as application/JSON and will have an HTTP status code ranging between 400-500.

An error message will contain these properties in every response. Some error responses will add additional data for troubleshooting. Third-party errors from Adyen for example.

Error example

1
2
3
4
5
6
{
  "code": "error_code",
  "field": "field",
  "message": "error message",
  "correlation_id": "correlation_id only available for third party errors"
}