Payment Orders
In order to initialize the Payment Menu, you need to create a Payment Order.
The paymentorders
resource and how you interact with it is described below.
The paymentorders
resource is used when initiating a payment process through
Swedbank Pay Checkout. The payment order is a container for the payment method
object selected by the payer. This will generate a payment that is accessed
through the sub-resources payments
and currentPayment
.
GET Payment Order Request
Request
GET Payment Order Response
Response
1
2
3
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8; version=3.x/2.0
api-supported-versions: 3.x/2.0
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
{
"paymentorder": {
"id": "/psp/paymentorders/09ccd29a-7c4f-4752-9396-12100cbfecce",
"created": "2018-09-14T13:21:29.3182115Z",
"updated": "2018-09-14T13:21:57.6627579Z",
"operation": "Purchase",
"state": "Ready",
"currency": "SEK",
"amount": 1500,
"vatAmount": 0,
"remainingCaptureAmount": 1500,
"remainingCancellationAmount": 1500,
"remainingReversalAmount": 0,
"description": "Test Purchase",
"initiatingSystemUserAgent": "swedbankpay-sdk-dotnet/3.0.1",
"userAgent": "Mozilla/5.0...",
"language": "nb-NO",
"paymentToken": "12345678-1234-1234-1234-123456789010",
"recurrenceToken": "12345678-1234-1234-1234-123456789011",
"unscheduledToken": "12345678-1234-1234-1234-123456789012",
"transactionsOnFileToken": "12345678-1234-1234-1234-123456789013",
"nonPaymentToken": "12345678-1234-1234-1234-1234567890AB",
"externalNonPaymentToken": "1234567890",
"urls" : { "id": "/psp/paymentorders/09ccd29a-7c4f-4752-9396-12100cbfecce/urls" },
"payeeInfo" : { "id": "/psp/paymentorders/09ccd29a-7c4f-4752-9396-12100cbfecce/payeeinfo" },
"payers": { "id": "/psp/paymentorders/09ccd29a-7c4f-4752-9396-12100cbfecce/payers" },
"orderItems" : { "id": "/psp/paymentorders/09ccd29a-7c4f-4752-9396-12100cbfecce/orderItems" },
"metadata": { "id": "/psp/paymentorders/09ccd29a-7c4f-4752-9396-12100cbfecce/metadata" },
"payments": { "id": "/psp/paymentorders/09ccd29a-7c4f-4752-9396-12100cbfecce/payments" },
"currentPayment": { "id": "/psp/paymentorders/09ccd29a-7c4f-4752-9396-12100cbfecce/currentpayment" }
},
"operations": [
{
"method": "PATCH",
"href": "https://api.externalintegration.payex.com/psp/paymentorders/09ccd29a-7c4f-4752-9396-12100cbfecce",
"rel": "update-paymentorder-abort",
"contentType": "application/json"
},
{
"method": "GET",
"href": "https://ecom.externalintegration.payex.com/paymentmenu/5a17c24e-d459-4567-bbad-aa0f17a76119?_tc_tid=30f2168171e142d38bcd4af2c3721959",
"rel": "redirect-paymentorder",
"contentType": "text/html"
},
{
"method": "GET",
"href": "https://ecom.externalintegration.payex.com/paymentmenu/core/scripts/client/px.paymentmenu.client.js?token=5a17c24e-d459-4567-bbad-aa0f17a76119&culture=nb-NO&_tc_tid=30f2168171e142d38bcd4af2c3721959",
"rel": "view-paymentorder",
"contentType": "application/javascript"
}
]
}
paymentOrder
object
id
string
The relative URL and unique identifier of the paymentorder
resource . Please read about URL Usage to understand how this and other URLs should be used in your solution.
created
string
updated
string
operation
string
Determines the initial operation, defining the type of payment order created. Possible options are Purchase, Abort Verify, UnscheduledPurchase, Recur and Payout.
state
string
Ready
, Pending
, Failed
or Aborted
. Indicates the state of the payment order. Does not reflect the state of any ongoing payments initiated from the payment order. This field is only for status display purposes.
currency
string
amount
integer
The transaction amount (including VAT, if any) entered in the lowest monetary unit of the selected currency. E.g.: 10000
= 100.00
SEK, 5000
= 50.00
SEK.
vatAmount
integer
The payment’s VAT (Value Added Tax) amount
, entered in the lowest monetary unit of the selected currency. E.g.: 10000
= 100.00
SEK, 5000
= 50.00
SEK. The vatAmount
entered will not affect the amount
shown on the payment page, which only shows the total amount
. This field is used to specify how much of the total amount
the VAT will be. Set to 0
(zero) if there is no VAT amount
charged.
description
string(40)
A textual description of the purchase. Maximum length is 40 characters.
userAgent
string
The user agent of the payer. Should typically be set to the value of the User-Agent
header sent by the payer’s web browser.
language
string
sv-SE
, nb-NO
, da-DK
, en-US
or fi-FI
.
paymentToken
string
recurrenceToken
string
operation: Verify
, operation: Recur
or generateRecurrenceToken: true
was used.
unscheduledToken
string
operation: Verify
, operation: UnscheduledPurchase
or generateUnscheduledToken: true
was used.
transactionOnFileToken
string
operation: Verify
and generateTransactionOnFileToken: true
was used.
nonPaymentToken
string
externalNonPaymentToken
string
urls
id
urls
resource where all URLs related to the payment order can be retrieved.
payeeInfo
id
payeeInfo
resource where information related to the payee can be retrieved.
payers
id
payer
resource where information about the payer can be retrieved.
orderItems
id
orderItems
resource where information about the order items can be retrieved.
metadata
id
payments
resource where information about all underlying payments can be retrieved.
payments
id
payments
resource where information about all underlying payments can be retrieved.
currentPayment
id
currentPayment
resource where information about the current – and sole active – payment can be retrieved.
operations
array
The array of operations that are possible to perform on the payment order in its current state.
View Payment Order
The view-paymentorder
operation contains the URL of the JavaScript that needs
to be set as a script
element’s src
attribute, either client-side through
JavaScript or server-side in HTML as shown below.
View Payment Order <button aria-describedby="tooltipCopy" class="code-view-copy tooltip" aria-label="Copy json to clipboard" value='<!DOCTYPE html>
1
2
3
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8; version=3.x/2.0
api-supported-versions: 3.x/2.0
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
<!DOCTYPE html>
<html>
<head>
<title>Swedbank Pay Checkout is Awesome!</title>
</head>
<body>
<div id="checkout"></div>
<script src="https://ecom.externalintegration.payex.com/paymentmenu/core/scripts/client/px.paymentmenu.client.js?token=5a17c24e-d459-4567-bbad-aa0f17a76119&culture=nb-NO"></script>
<script language="javascript">
payex.hostedView.paymentMenu({
container: 'checkout',
culture: 'nb-NO',
onPaymentCompleted: function(paymentCompletedEvent) {
console.log(paymentCompletedEvent);
},
onPaymentFailed: function(paymentFailedEvent) {
console.log(paymentFailedEvent);
},
onPaymentCreated: function(paymentCreatedEvent) {
console.log(paymentCreatedEvent);
},
onPaymentToS: function(paymentToSEvent) {
console.log(paymentToSEvent);
},
onPaymentMenuInstrumentSelected: function(paymentMenuInstrumentSelectedEvent) {
console.log(paymentMenuInstrumentSelectedEvent);
},
onError: function(error) {
console.error(error);
},
}).open();
</script>
</body>
</html>