Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PureBasic) CardConnect Create ProfileDemonstrates how to create a profile. A PUT call to the profile endpoint creates a new profile or adds a new account to an existing profile. ... See https://developer.cardconnect.com/cardconnect-api?lang=json#create-update-profile-request
IncludeFile "CkJsonObject.pb" IncludeFile "CkHttp.pb" Procedure ChilkatExample() ; This example assumes the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. http.i = CkHttp::ckCreate() If http.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success.i CkHttp::setCkBasicAuth(http, 1) CkHttp::setCkLogin(http, "API_USERNAME") CkHttp::setCkPassword(http, "API_PASSWORD") ; Build and send the following JSON: ; { ; "region": "AK", ; "phone": "7778789999", ; "accttype": "VISA", ; "postal": "19090", ; "ssnl4": "3655", ; "expiry": "0214", ; "city": "ANYTOWN", ; "country": "US", ; "address": "123 MAIN STREET", ; "merchid": "496400000840", ; "name": "TOM JONES", ; "account": "4444333322221111", ; "license": "123451254", ; } json.i = CkJsonObject::ckCreate() If json.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkJsonObject::ckUpdateString(json,"region","AK") CkJsonObject::ckUpdateString(json,"phone","7778789999") CkJsonObject::ckUpdateString(json,"accttype","VISA") CkJsonObject::ckUpdateString(json,"postal","19090") CkJsonObject::ckUpdateString(json,"ssnl4","3655") CkJsonObject::ckUpdateString(json,"expiry","0214") CkJsonObject::ckUpdateString(json,"city","ANYTOWN") CkJsonObject::ckUpdateString(json,"country","US") CkJsonObject::ckUpdateString(json,"address","123 MAIN STREET") CkJsonObject::ckUpdateString(json,"merchid","MERCHANT_ID") CkJsonObject::ckUpdateString(json,"name","TOM JONES") CkJsonObject::ckUpdateString(json,"account","4444333322221111") CkJsonObject::ckUpdateString(json,"license","123451254") url.s = "https://<site>.cardconnect.com:<port>/cardconnect/rest/profile" responseStr.s = CkHttp::ckPutText(http,url,CkJsonObject::ckEmit(json),"utf-8","application/json",0,0) If CkHttp::ckLastMethodSuccess(http) = 0 Debug CkHttp::ckLastErrorText(http) CkHttp::ckDispose(http) CkJsonObject::ckDispose(json) ProcedureReturn EndIf ; A response status of 200 indicates potential success. The JSON response body ; must be examined to determine if it was truly successful or an error. Debug "response status code = " + Str(CkHttp::ckLastStatus(http)) jsonResp.i = CkJsonObject::ckCreate() If jsonResp.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkJsonObject::ckLoad(jsonResp,responseStr) CkJsonObject::setCkEmitCompact(jsonResp, 0) Debug "response JSON:" Debug CkJsonObject::ckEmit(jsonResp) ; A successful response looks like this: ; { ; "country": "US", ; "address": "123 MAIN STREET", ; "resptext": "Profile Saved", ; "city": "ANYTOWN", ; "acctid": "1", ; "respcode": "09", ; "defaultacct": "Y", ; "accttype": "VISA", ; "token": "9441149619831111", ; "license": "123451254", ; "respproc": "PPS", ; "phone": "7778789999", ; "profileid": "16392957457306633141", ; "name": "TOM JONES", ; "auoptout": "N", ; "postal": "19090", ; "expiry": "0214", ; "region": "AK", ; "ssnl4": "3655", ; "respstat": "A" ; } ; Use this online tool to generate parsing code from sample JSON: ; Generate Parsing Code from JSON country.s = CkJsonObject::ckStringOf(jsonResp,"country") address.s = CkJsonObject::ckStringOf(jsonResp,"address") resptext.s = CkJsonObject::ckStringOf(jsonResp,"resptext") city.s = CkJsonObject::ckStringOf(jsonResp,"city") acctid.s = CkJsonObject::ckStringOf(jsonResp,"acctid") respcode.s = CkJsonObject::ckStringOf(jsonResp,"respcode") defaultacct.s = CkJsonObject::ckStringOf(jsonResp,"defaultacct") accttype.s = CkJsonObject::ckStringOf(jsonResp,"accttype") token.s = CkJsonObject::ckStringOf(jsonResp,"token") license.s = CkJsonObject::ckStringOf(jsonResp,"license") respproc.s = CkJsonObject::ckStringOf(jsonResp,"respproc") phone.s = CkJsonObject::ckStringOf(jsonResp,"phone") profileid.s = CkJsonObject::ckStringOf(jsonResp,"profileid") name.s = CkJsonObject::ckStringOf(jsonResp,"name") auoptout.s = CkJsonObject::ckStringOf(jsonResp,"auoptout") postal.s = CkJsonObject::ckStringOf(jsonResp,"postal") expiry.s = CkJsonObject::ckStringOf(jsonResp,"expiry") region.s = CkJsonObject::ckStringOf(jsonResp,"region") ssnl4.s = CkJsonObject::ckStringOf(jsonResp,"ssnl4") respstat.s = CkJsonObject::ckStringOf(jsonResp,"respstat") CkHttp::ckDispose(http) CkJsonObject::ckDispose(json) CkJsonObject::ckDispose(jsonResp) ProcedureReturn EndProcedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.