Get Started

Validate Status

How to validate the status of a payment

Edit "Validate Status" on GitHub

After the payer has completed their payment and returned to the CompleteUrl, you need to validate that the payment has the status Paid so you are able to capture funds.

First of all, you need to find out if the transaction type needs to be captured or not. An Authorization needs to be captured (most payment methods generate these type of transactions), a Sale does not (Trustly and Swish transactions where the funds are captured instantly and automatically).

Perform the GET

You can do this by perfoming a GET on your payment.

The status field should simply have the status Paid. As long as this is the case, you are good to go and proceed to doing the capture.

We also recommend adding an expansion of the paid node. Do this by adding ?$expand=paid after the paymentOrderId. This way, you can retrieve more information about the payment while limiting the amount of calls you have to do towards the API.

Not adding the expansion will result in the same response, apart from the paid node being collapsed.

GET Request with expanded paid node

1
2
3
4
GET /psp/paymentorders/34761895-d1e4-412a-0a30-08dc43423140?$expand=paid HTTP/1.1
Host: api.externalintegration.payex.com
Authorization: Bearer <AccessToken>
Content-Type: application/json;version=3.x/2.0      // Version optional for 3.0 and 2.0

GET Response with expanded paid node

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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
{
    "paymentOrder": {
        "id": "/psp/paymentorders/34761895-d1e4-412a-0a30-08dc43423140",
        "created": "2024-03-13T12:39:58.0608661Z",
        "updated": "2024-03-13T12:40:16.1887572Z",
        "operation": "Purchase",
        "status": "Paid",
        "currency": "SEK",
        "amount": 100,
        "vatAmount": 0,
        "remainingCaptureAmount": 100,
        "remainingCancellationAmount": 100,
        "description": "Test Purchase",
        "initiatingSystemUserAgent": "PostmanRuntime/7.37.0",
        "language": "sv-SE",
        "availableInstruments": [
            "CreditCard",
            "Invoice-PayExFinancingSe",
            "Swish",
            "CreditAccount-CreditAccountSe",
            "Trustly",
            "MobilePay",
            "GooglePay",
            "ClickToPay"
        ],
        "implementation": "PaymentsOnly",
        "integration": "Redirect",
        "instrumentMode": false,
        "guestMode": false,
        "orderItems": {
            "id": "/psp/paymentorders/34761895-d1e4-412a-0a30-08dc43423140/orderitems"
        },
        "urls": {
            "id": "/psp/paymentorders/34761895-d1e4-412a-0a30-08dc43423140/urls"
        },
        "payeeInfo": {
            "id": "/psp/paymentorders/34761895-d1e4-412a-0a30-08dc43423140/payeeinfo"
        },
        "payer": {
            "id": "/psp/paymentorders/34761895-d1e4-412a-0a30-08dc43423140/payers"
        },
        "history": {
            "id": "/psp/paymentorders/34761895-d1e4-412a-0a30-08dc43423140/history"
        },
        "failed": {
            "id": "/psp/paymentorders/34761895-d1e4-412a-0a30-08dc43423140/failed"
        },
        "aborted": {
            "id": "/psp/paymentorders/34761895-d1e4-412a-0a30-08dc43423140/aborted"
        },
        "paid": {
            "id": "/psp/paymentorders/34761895-d1e4-412a-0a30-08dc43423140/paid",
            "number": 40129782830,
            "instrument": "CreditCard",
            "payeeReference": "1710333598",
            "transactionType": "Authorization",
            "amount": 100,
            "submittedAmount": 100,
            "feeAmount": 0,
            "discountAmount": 0,
            "paymentTokenGenerated": false,
            "details": {
                "externalNonPaymentToken": "91dd1ea0eeafc2ac397d24e80abdc",
                "cardBrand": "MasterCard",
                "cardType": "Credit",
                "maskedPan": "522661******3406",
                "expiryDate": "12/2033",
                "issuerAuthorizationApprovalCode": "L00003",
                "acquirerTransactionType": "3DSECURE",
                "acquirerStan": "3",
                "acquirerTerminalId": "40129782830",
                "acquirerTransactionTime": "2024-03-13T12:40:30.361Z",
                "transactionInitiator": "CARDHOLDER",
                "bin": "522661",
                "paymentAccountReference": "91dd1ea0eeafc2ac397d24e80abdc"
            }
        },
        "cancelled": {
            "id": "/psp/paymentorders/34761895-d1e4-412a-0a30-08dc43423140/cancelled",
            "paymentTokenGenerated": false
        },
        "reversed": {
            "id": "/psp/paymentorders/34761895-d1e4-412a-0a30-08dc43423140/reversed",
            "paymentTokenGenerated": false
        },
        "financialTransactions": {
            "id": "/psp/paymentorders/34761895-d1e4-412a-0a30-08dc43423140/financialtransactions"
        },
        "failedAttempts": {
            "id": "/psp/paymentorders/34761895-d1e4-412a-0a30-08dc43423140/failedattempts"
        },
        "postPurchaseFailedAttempts": {
            "id": "/psp/paymentorders/34761895-d1e4-412a-0a30-08dc43423140/postpurchasefailedattempts"
        },
        "metadata": {
            "id": "/psp/paymentorders/34761895-d1e4-412a-0a30-08dc43423140/metadata"
        }
    },
    "operations": [
        {
            "method": "POST",
            "href": "https://api.externalintegration.payex.com/psp/paymentorders/34761895-d1e4-412a-0a30-08dc43423140/cancellations",
            "rel": "cancel",
            "contentType": "application/json"
        },
        {
            "method": "POST",
            "href": "https://api.externalintegration.payex.com/psp/paymentorders/34761895-d1e4-412a-0a30-08dc43423140/captures",
            "rel": "capture",
            "contentType": "application/json"
        },
        {
            "method": "GET",
            "href": "https://ecom.externalintegration.payex.com/checkout/19bd2693ba9f42c700c41eac68a26749987600be3d4757fcccef570754a671a6?_tc_tid=ea84679ddcfc4f879e3d972c62a09028",
            "rel": "redirect-checkout",
            "contentType": "text/html"
        },
        {
            "method": "GET",
            "href": "https://ecom.externalintegration.payex.com/checkout/client/19bd2693ba9f42c700c41eac68a26749987600be3d4757fcccef570754a671a6?culture=sv-SE&_tc_tid=ea84679ddcfc4f879e3d972c62a09028",
            "rel": "view-checkout",
            "contentType": "application/javascript"
        }
    ]
}

An alternative option to expanding the paid node is performing a GET towards the paid resource.

GET Request directly towards the paid resource

1
2
3
4
GET /psp/paymentorders/5adc265f-f87f-4313-577e-08d3dca1a26c/paid HTTP/1.1
Host: api.externalintegration.payex.com
Authorization: Bearer <AccessToken>
Content-Type: application/json;version=3.x/2.0      // Version optional for 3.0 and 2.0

GET Response directly towards the paid resource

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
{
  "paid": {
    "id": "/psp/paymentorders/5adc265f-f87f-4313-577e-08d3dca1a26c/paid",
    "instrument": "Creditcard",
    "number": 1234567890,
    "payeeReference": "CD123",
    "orderReference": "AB1234",
    "transactionType": "Authorization",
    "amount": 1500,
    "submittedAmount": 1500,
    "feeAmount": 0,
    "discountAmount": 0,
    "paymentTokenGenerated": false,
    "details": {
      "cardBrand": "Visa",
      "cardType": "Credit",
      "maskedPan": "492500******0004",
      "expiryDate": "12/2022",
      "issuerAuthorizationApprovalCode": "L00302",
      "acquirerTransactionType": "STANDARD",
      "acquirerStan": "302",
      "acquirerTerminalId": "70101301389",
      "acquirerTransactionTime": "2022-06-15T14:12:55.029Z",
      "transactionInitiator": "CARDHOLDER",
      "bin": "492500"
    }
  }

Other Statuses

There are several statuses the payment might have in addition to Paid once the payer has reached the completeURL. If any of these appear, no capture is available. You can get more information by doing a GET with the field expanded or directly towards the resource, just like we showed above. The other statuses are:

  • Failed

Returned when a payment has failed. You will find an error message in the Failed response.

  • Cancelled

Returned when an authorized amount has been fully cancelled. It will contain fields from both the cancelled description and paid section. See the Cancelled response.

  • Aborted

Returned when the merchant has aborted the payment, or if the payer cancelled the payment in the redirect integration. See the Aborted response.