Solutions Swish for merchants Test Connection

5 Retrieve payment confirmation callback

5 Retrieve payment confirmation callback

5 Retrieve payment confirmation callback

Merchants can retrieve payment confirmation callback by sending GET HTTP to URL:

HTTPS://mss.cpc.getswish.net/swish-cpcapi/api/v1/paymentrequests/{id}

The URL is the “Location” defined in a response of create payment request, check section 5.1 and 5.2 for an example (blue marked areas).

Once MSS receives “Retrieve payment confirmation callback” from merchants, MSS sends a “Payment confirmation” to the merchant’s callback URL. It is possible to simulate all possible values of Payment status by providing the Payment request id of a call made earlier that leads to that outcome.

Remark: MSS stores the necessary information about each incoming “Payment request” in a cache which automatically expires every 24 hours or when the MSS server is restarted.

5.1 Example retrieve payment confirmation callback

curl -v --request GET
https://mss.cpc.getswish.net/swish-cpcapi/api/v1/paymentrequests/AB23D7406ECE4542A80152D909EF9F6B
< HTTP/1.1 200 OK
{
"id": "AB23D7406ECE4542A80152D909EF9F6B",
"payeePaymentReference": "0123456789",
"paymentReference": "6D6CD7406ECE4542A80152D909EF9F6B",
"callbackUrl": "https://example.com/api/swishcb/paymentrequests",
"payerAlias": "07211234567",
"payeeAlias": "1231234567890",
"amount": "100",
"currency": "SEK",
"message": "Kingston USB Flash Drive 8 GB",
"status": "PAID",
"dateCreated": "2015-02-19T22:01:53+01:00",
"datePaid": "2015-02-19T22:03:53+01:00"
}

5.2 Example retrieve payment confirmation callback negative

curl -v --request GET
https://mss.cpc.getswish.net/swish-cpcapi/api/v1/paymentrequests/88C45305089D4186BD4AC141D0911D55
< HTTP/1.1 200 OK
{
"id":"88C45305089D4186BD4AC141D0911D55",
"payeePaymentReference":"0123456789",
"paymentReference":null,
"callbackUrl":"https://example.com/api/swishcb/paymentrequests",
"payerAlias":null,
"payeeAlias":"1231181189",
"amount":100.00,
"currency":"SEK",
"message":"AC05",
"status":"ERROR",
"dateCreated":"2015-10-20T10:01:31.784Z",
"datePaid":null,
"errorCode":"AC05",
"errorMessage":"Payers bank account is closed"
}

5.3 HTTP status codes

Potential HTTP status codes returned for retrieve payment confirmation callback response:

HTTP status codesReturned scenarios
200 OKReturned when Payment request was found. Will return Payment Request Object.
401 UnauthorizedReturned when there are authentication problems with the certificate. Or the Swish number in the certificate is not enrolled. Will return nothing else.
404 Not foundReturned when the Payment request was not found or it was not created by the Merchant. Will return nothing else.
500 Internal Server ErrorReturned if there was some unknown/unforeseen error that occurred on the server, this should normally not happen. Will return nothing else.