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

CardConnect Validate Merchant-Level Credentials

See more CardConnect Examples

To test and validate merchant-level credentials, you can make a PUT request, including the merchant ID in the body of the request, to the base URL. The Gateway verifies that the MID matches the credentials provided in the header.

Chilkat Lua Downloads

Lua
local chilkat = require("chilkat")

-- This example assumes the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.

local http = chilkat.Http.new()

http.basic_auth = true
http.login = "API_USERNAME"
http.password = "API_PASSWORD"

local json = chilkat.JsonObject.new()
local success = json:update_string("merchid", "MERCHANT_ID")

local url = "https://<site>.cardconnect.com:<port>/cardconnect/rest/"

local resp = chilkat.HttpResponse.new()
success = http:http_str("PUT", url, json:emit(), "utf-8", "application/json", resp)
if not success then
    print(http.last_error_text)
    return
end

-- If we get a 200 response status and an HTML response saying "CardConnect REST Servlet", then our credentials are correct.
print("response status code = " .. resp.status_code)

print("response string:")
print(resp.body_str)

-- Sample output:

-- response status code = 200
-- response string:
-- <html lang="en"><body><h1>CardConnect REST Servlet</h1></body></html>