Checkout v2

Payment Order

schedule 5 min read

Creating the payment order

Edit "Payment Order" on GitHub

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.

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

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
HTTP/1.1 200 OK
Content-Type: application/json

{
    "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": "PostmanRuntime/3.0.1",
        "userAgent": "Mozilla/5.0...",
        "language": "nb-NO",
        "urls" : { "id": "/psp/paymentorders/09ccd29a-7c4f-4752-9396-12100cbfecce/urls" },
        "payeeInfo" : { "id": "/psp/paymentorders/09ccd29a-7c4f-4752-9396-12100cbfecce/payeeinfo" },
        "settings": { "id": "/psp/paymentorders/09ccd29a-7c4f-4752-9396-12100cbfecce/settings" },
        "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",
            "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",
            "rel": "view-paymentorder",
            "contentType": "application/javascript"
        }
    ]
}
Field Type Description
paymentorder object The payment order object.
└➔ id string The relative URI and unique identifier of the paymentorder resource . Please read about URI Usage to understand how this and other URIs 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 string of the payer’s browser.
└➔ language string sv-SE, nb-NO or en-US.
└➔ urls string The URI to the urls resource where all URIs related to the payment order can be retrieved.
└➔ payeeInfo string The payeeInfo object, containing information about the payee (the recipient of the money). See payeeInfo for details.
└➔ payers string The URI to the payers resource where information about the payee of the payment order can be retrieved.
└➔ orderItems string  
└➔ metadata string The URI to the payments resource where information about all underlying payments can be retrieved.
└➔ payments string The URI to the payments resource where information about all underlying payments can be retrieved.
└➔ currentPayment string The URI to the currentPayment resource where information about the current – and sole active – payment can be retrieved.
└➔ operations array The array of possible operations to perform, given the state of the payment order. See Operations for details.

View Payment Order

The view-paymentorder operation contains the URI 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>