Sample code for 30+ languages & platforms
Xbase++ Requires Chilkat v11.0.0+

Adyen Verify Payment Result

See more Adyen Examples

Once a payment has completed, this verifies the result from your server with a /payments/result request.

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oHttp
LOCAL oJson
LOCAL oResp
LOCAL oSbResponseBody
LOCAL oJResp
LOCAL nRespStatusCode
LOCAL cPspReference
LOCAL cResultCode
LOCAL cMerchantReference
LOCAL cPaymentMethod
LOCAL cShopperLocale

nSuccess := 0

oHttp := CreateObject("Chilkat.Http")

//  Use this online tool to generate the code from sample JSON:
//  Generate Code to Create JSON

//  The following JSON is sent in the request body.

//  {
//    "payload": "2he28Ddhwj242he28Ddhwj..."
//  }
oJson := CreateObject("Chilkat.JsonObject")
oJson:UpdateString("payload", "2he28Ddhwj242he28Ddhwj...")

oHttp:SetRequestHeader("X-API-Key", "Your_API_key")

oResp := CreateObject("Chilkat.HttpResponse")
nSuccess := oHttp:HttpJson("POST", "https://checkout-test.adyen.com/v41/payments/result", oJson, "application/json", oResp)
IF (nSuccess == 0)
    ? oHttp:LastErrorText
    oHttp:destroy()
    oJson:destroy()
    oResp:destroy()
    RETURN
ENDIF

oSbResponseBody := CreateObject("Chilkat.StringBuilder")
oResp:GetBodySb(oSbResponseBody)

oJResp := CreateObject("Chilkat.JsonObject")
oJResp:LoadSb(oSbResponseBody)
oJResp:EmitCompact := 0

nRespStatusCode := oResp:StatusCode
? "Status Code = " + Str(nRespStatusCode)
? "Response Body:"
? oJResp:Emit()

IF (nRespStatusCode >= 400)
    ? "Response Header:"
    ? oResp:Header
    ? "Failed."
    oHttp:destroy()
    oJson:destroy()
    oResp:destroy()
    oSbResponseBody:destroy()
    oJResp:destroy()
    RETURN
ENDIF

//  Sample JSON response:

//  {
//    "pspReference": "851559480052382F",
//    "resultCode": "Authorised",
//    "merchantReference": "123",
//    "paymentMethod": "ideal",
//    "shopperLocale": "nl_NL"
//  }

//  Sample code for parsing the JSON response...
//  Use the following online tool to generate parsing code from sample JSON:
//  Generate Parsing Code from JSON

cPspReference := oJResp:StringOf("pspReference")
cResultCode := oJResp:StringOf("resultCode")
cMerchantReference := oJResp:StringOf("merchantReference")
cPaymentMethod := oJResp:StringOf("paymentMethod")
cShopperLocale := oJResp:StringOf("shopperLocale")

oHttp:destroy()
oJson:destroy()
oResp:destroy()
oSbResponseBody:destroy()
oJResp:destroy()