Sample code for 30+ languages & platforms
Lua 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 Lua Downloads

Lua
local chilkat = require("chilkat")

local http = chilkat.Http.new()

-- 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..."
-- }
local json = chilkat.JsonObject.new()
json:update_string("payload", "2he28Ddhwj242he28Ddhwj...")

http:set_request_header("X-API-Key", "Your_API_key")

local resp = chilkat.HttpResponse.new()
local success = http:http_json("POST", "https://checkout-test.adyen.com/v41/payments/result", json, "application/json", resp)
if not success then
    print(http.last_error_text)
    return
end

local sbResponseBody = chilkat.StringBuilder.new()
resp:get_body_sb(sbResponseBody)

local jResp = chilkat.JsonObject.new()
jResp:load_sb(sbResponseBody)
jResp.emit_compact = false

local respStatusCode = resp.status_code
print("Status Code = " .. respStatusCode)
print("Response Body:")
print(jResp:emit())

if respStatusCode >= 400 then
    print("Response Header:")
    print(resp.header)
    print("Failed.")
    return
end

-- 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

local pspReference = jResp:string_of("pspReference")
local resultCode = jResp:string_of("resultCode")
local merchantReference = jResp:string_of("merchantReference")
local paymentMethod = jResp:string_of("paymentMethod")
local shopperLocale = jResp:string_of("shopperLocale")