Xbase++ Requires Chilkat v11.0.0+
Xbase++
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 Xbase++ Downloads
LOCAL nSuccess
LOCAL oHttp
LOCAL oJson
LOCAL cUrl
LOCAL oResp
nSuccess := 0
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
oHttp := CreateObject("Chilkat.Http")
oHttp:BasicAuth := 1
oHttp:Login := "API_USERNAME"
oHttp:Password := "API_PASSWORD"
oJson := CreateObject("Chilkat.JsonObject")
nSuccess := oJson:UpdateString("merchid", "MERCHANT_ID")
cUrl := "https://<site>.cardconnect.com:<port>/cardconnect/rest/"
oResp := CreateObject("Chilkat.HttpResponse")
nSuccess := oHttp:HttpStr("PUT", cUrl, oJson:Emit(), "utf-8", "application/json", oResp)
IF (nSuccess == 0)
? oHttp:LastErrorText
oHttp:destroy()
oJson:destroy()
oResp:destroy()
RETURN
ENDIF
// If we get a 200 response status and an HTML response saying "CardConnect REST Servlet", then our credentials are correct.
? "response status code = " + Str(oResp:StatusCode)
? "response string:"
? oResp:BodyStr
// Sample output:
// response status code = 200
// response string:
// <html lang="en"><body><h1>CardConnect REST Servlet</h1></body></html>
oHttp:destroy()
oJson:destroy()
oResp:destroy()