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 instrument
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
1
2
3
4
GET /psp/paymentorders/09ccd29a-7c4f-4752-9396-12100cbfecce/ HTTP/1.1
Host: api.externalintegration.payex.com
Authorization: Bearer <AccessToken>
Content-Type: application/json;version=3.1/3.0/2.0 // Version optional for 3.0 and 2.0
GET Payment Order Response
Response
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
53
54
55
56
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8; version=3.1/3.0/2.0
api-supported-versions: 3.1/3.0/2.0
{
"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"
}
]
}
Field | Type | Description |
---|---|---|
paymentOrder |
object |
The payment order 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 |
The ISO-8601 date of when the payment order was created. |
updated |
string |
The ISO-8601 date of when the payment order was updated. |
operation |
string |
Purchase |
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 |
The currency of the payment order. |
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 40 character length textual description of the purchase. |
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 |
The payment token created for the purchase used in the authorization to create One-Click Payments. |
recurrenceToken |
string |
The created recurrenceToken, if operation: Verify , operation: Recur or generateRecurrenceToken: true was used. |
unscheduledToken |
string |
The generated unscheduledToken, if operation: Verify , operation: UnscheduledPurchase or generateUnscheduledToken: true was used. |
transactionOnFileToken |
string |
The created transactionOnFileToken, if operation: Verify and generateTransactionOnFileToken: true was used. |
nonPaymentToken |
string |
The result of our own card tokenization. Activated in POS for the merchant or merchant group. |
externalNonPaymentToken |
string |
The result of an external tokenization. This value will vary depending on card types, acquirers, customers, etc. For Mass Transit merchants, transactions redeemed by Visa will be populated with PAR. For Mastercard and Amex, it will be our own token. |
urls |
id |
The URL to the urls resource where all URLs related to the payment order can be retrieved. |
payeeInfo |
id |
The URL to the payeeInfo resource where information related to the payee can be retrieved. |
payers |
id |
The URL to the payer resource where information about the payer can be retrieved. |
orderItems |
id |
The URL to the orderItems resource where information about the order items can be retrieved. |
metadata |
id |
The URL to the payments resource where information about all underlying payments can be retrieved. |
payments |
id |
The URL to the payments resource where information about all underlying payments can be retrieved. |
currentPayment |
id |
The URL to the 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.
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>