Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3/4TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

DataFlex Web API Examples

Primary Categories

AWS Translate
Activix CRM
Adyen
Amazon MWS
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Bluzone
CardConnect
ClickBank
Clickatell
Cloudfare
DocuSign
ETrade
Etsy
Facebook
GeoOp
GetHarvest
Jira
MYOB

Magento
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Okta OAuth/OIDC
OneLogin OIDC
PayPal
Peoplevox
Populi
QuickBooks
SOAP finkok.com
Shippo
Shopify
Stripe
SugarCRM
Trello
Twitter
VoiceBase
Vonage
Walmart
Walmart v3
Xero
eBay
effectconnect

 

 

 

(DataFlex) CardConnect Authorization

Demonstrates how to send an Authorization request.

Authorization is the initial step in accepting payment from a cardholder. This action "authorizes" or requests permission from the bank to transfer money from the cardholder to the merchant.

See https://developer.cardconnect.com/cardconnect-api#authorization

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoHttp
    Boolean iSuccess
    Handle hoJson
    String sUrl
    String sResponseStr
    Handle hoJsonResp
    String sAmount
    String sResptext
    String sAcctid
    String sCommcard
    String sCvvresp
    String sRespcode
    String sBatchid
    String sAvsresp
    String sEntrymode
    String sDefaultacct
    String sMerchid
    String sToken
    String sAuthcode
    String sRespproc
    String sBintype
    String sProfileid
    String sRetref
    String sRespstat
    String sAccount
    String sTemp1
    Integer iTemp1
    Boolean bTemp1

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

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End

    Set ComBasicAuth Of hoHttp To True
    Set ComLogin Of hoHttp To "API_USERNAME"
    Set ComPassword Of hoHttp To "API_PASSWORD"

    // Build and send the following JSON:

    // Note: The CardConnect online documentation might use an expiry that is in the past, such as "1218".
    // This causes the request to fail.  Use a month/year that is in the future..
    // (Likewise, this example will have an invalid month/year after Dec 2021)

    // {
    //   "merchid": "MERCHANT_ID",
    //   "accttype": "VISA",
    //   "orderid": "AB-11-9876",
    //   "account": "4111111111111111",
    //   "expiry": "1221",
    //   "amount": "0",
    //   "currency": "USD",
    //   "name": "TOM JONES",
    //   "address": "123 MAIN STREET",
    //   "city": "anytown",
    //   "region": "NY",
    //   "country": "US",
    //   "postal": "55555",
    //   "profile": "Y",
    //   "ecomind": "E",
    //   "cvv2": "123",
    //   "track": null,
    //   "capture": "Y"
    // }

    // Use this online tool to generate the code from sample JSON: 
    // Generate Code to Create JSON
    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Get ComUpdateString Of hoJson "merchid" "MERCHANT_ID" To iSuccess
    Get ComUpdateString Of hoJson "accttype" "VISA" To iSuccess
    Get ComUpdateString Of hoJson "orderid" "AB-11-9876" To iSuccess
    Get ComUpdateString Of hoJson "account" "4111111111111111" To iSuccess
    Get ComUpdateString Of hoJson "expiry" "1221" To iSuccess
    Get ComUpdateString Of hoJson "amount" "20" To iSuccess
    Get ComUpdateString Of hoJson "currency" "USD" To iSuccess
    Get ComUpdateString Of hoJson "name" "TOM JONES" To iSuccess
    Get ComUpdateString Of hoJson "address" "123 MAIN STREET" To iSuccess
    Get ComUpdateString Of hoJson "city" "anytown" To iSuccess
    Get ComUpdateString Of hoJson "region" "NY" To iSuccess
    Get ComUpdateString Of hoJson "country" "US" To iSuccess
    Get ComUpdateString Of hoJson "postal" "55555" To iSuccess
    Get ComUpdateString Of hoJson "profile" "Y" To iSuccess
    Get ComUpdateString Of hoJson "ecomind" "E" To iSuccess
    Get ComUpdateString Of hoJson "cvv2" "123" To iSuccess
    Get ComUpdateNull Of hoJson "track" To iSuccess
    Get ComUpdateString Of hoJson "capture" "Y" To iSuccess

    Move "https://<site>.cardconnect.com:<port>/cardconnect/rest/auth" To sUrl
    Get ComEmit Of hoJson To sTemp1
    Get ComPutText Of hoHttp sUrl sTemp1 "utf-8" "application/json" False False To sResponseStr

    Get ComLastMethodSuccess Of hoHttp To bTemp1
    If (bTemp1 = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // 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.
    Get ComLastStatus Of hoHttp To iTemp1
    Showln "response status code = " iTemp1

    Get Create (RefClass(cComChilkatJsonObject)) To hoJsonResp
    If (Not(IsComObjectCreated(hoJsonResp))) Begin
        Send CreateComObject of hoJsonResp
    End
    Get ComLoad Of hoJsonResp sResponseStr To iSuccess
    Set ComEmitCompact Of hoJsonResp To False

    Showln "response JSON:"
    Get ComEmit Of hoJsonResp To sTemp1
    Showln sTemp1

    // Sample error:

    // {
    //   "respproc": "PPS",
    //   "amount": "0.00",
    //   "resptext": "Invalid amount",
    //   "cardproc": "FNOR",
    //   "acctid": "1",
    //   "retref": "112804260418",
    //   "respstat": "C",
    //   "respcode": "43",
    //   "account": "41XXXXXXXXXX1111",
    //   "defaultacct": "Y",
    //   "merchid": "MERCHANT_ID",
    //   "token": "9418594164541111"
    // }

    // A successful response looks like this:

    // {
    //   "amount": "0.20",
    //   "resptext": "Approval",
    //   "acctid": "1",
    //   "commcard": " C ",
    //   "cvvresp": "M",
    //   "respcode": "00",
    //   "batchid": "1900942291",
    //   "avsresp": "Z",
    //   "entrymode": "ECommerce",
    //   "defaultacct": "Y",
    //   "merchid": "MERCHANT_ID",
    //   "token": "9418594164541111",
    //   "authcode": "PPS158",
    //   "respproc": "FNOR",
    //   "bintype": "",
    //   "profileid": "16618402968441604028",
    //   "retref": "112989260941",
    //   "respstat": "A",
    //   "account": "41XXXXXXXXXX1111"
    // }

    // Use this online tool to generate parsing code from sample JSON: 
    // Generate Parsing Code from JSON

    Get ComStringOf Of hoJsonResp "amount" To sAmount
    Get ComStringOf Of hoJsonResp "resptext" To sResptext
    Get ComStringOf Of hoJsonResp "acctid" To sAcctid
    Get ComStringOf Of hoJsonResp "commcard" To sCommcard
    Get ComStringOf Of hoJsonResp "cvvresp" To sCvvresp
    Get ComStringOf Of hoJsonResp "respcode" To sRespcode
    Get ComStringOf Of hoJsonResp "batchid" To sBatchid
    Get ComStringOf Of hoJsonResp "avsresp" To sAvsresp
    Get ComStringOf Of hoJsonResp "entrymode" To sEntrymode
    Get ComStringOf Of hoJsonResp "defaultacct" To sDefaultacct
    Get ComStringOf Of hoJsonResp "merchid" To sMerchid
    Get ComStringOf Of hoJsonResp "token" To sToken
    Get ComStringOf Of hoJsonResp "authcode" To sAuthcode
    Get ComStringOf Of hoJsonResp "respproc" To sRespproc
    Get ComStringOf Of hoJsonResp "bintype" To sBintype
    Get ComStringOf Of hoJsonResp "profileid" To sProfileid
    Get ComStringOf Of hoJsonResp "retref" To sRetref
    Get ComStringOf Of hoJsonResp "respstat" To sRespstat
    Get ComStringOf Of hoJsonResp "account" To sAccount


End_Procedure

 

© 2000-2019 Chilkat Software, Inc. All Rights Reserved.