How To: Credit Card and ACH (e-check) Integration with 4D (4th Dimension)
This is the second in a series of postings on how to integrate credit card and ACH/E-check transactions into various systems. This installment demonstrates code used for processing payments (credit card and/or ACH) within a 4D (4th Dimension) application.
This was taken from the NELiX TransaX FleXport toolkit documentation. Credit card integration examples can be downloaded on the NELiX TransaX FleXport page.
Assumptions:
- Using NELiX TransaX Payment Gateway
- Communicating using NELiX TransaX Webservice
Download 4D (4th Dimension) credit card and ACH (e-check) integration examples
This was taken from the NELiX TransaX FleXport toolkit documentation. Credit card integration examples can be downloaded on the NELiX TransaX FleXport page.
Assumptions:
- Using NELiX TransaX Payment Gateway
- Communicating using NELiX TransaX Webservice
If you need any assistance with payment processing integration with your4D database, we are here to help!
C_TEXT($vString)
C_BLOB($vBlobIn;$vBlobOut)
$vString:=""+Char(13) "+Char(13)
$vString:=$vString+""+Char(13) "+Char(13)
$vString:=$vString+""+transactiontype+" "+Char(13)
$vString:=$vString+""+username+" "+Char(13)
$vString:=$vString+""+password+" "+Char(13)
$vString:=$vString+""+merchantdefined1+" "+Char(13)
$vString:=$vString+""+merchantdefined2+" "+Char(13)
If (transactiontype="void")
$vString:=$vString+""+transid+" "+Char(13)
If (paymenttype="check")
$vString:=$vString+""+paymenttype+" "+Char(13)
End if
End if
If (transactiontype="refund")
$vString:=$vString+""+amount+" "+Char(13)
$vString:=$vString+""+transid+" "+Char(13)
If (paymenttype="check")
$vString:=$vString+""+paymenttype+" "+Char(13)
End if
End if
If (transactiontype="capture")
$vString:=$vString+""+amount+" "+Char(13)
$vString:=$vString+""+transid+" "+Char(13)
$vString:=$vString+""+orderid+" "+Char(13)
$vString:=$vString+""+tracking_number+" "+Char(13)
$vString:=$vString+""+shipping_carrier+" "+Char(13)
If (paymenttype="check")
$vString:=$vString+""+paymenttype+" "+Char(13)
End if
End if
If (transactiontype="update")
$vString:=$vString+""+transid+" "+Char(13)
$vString:=$vString+""+tracking_number+" "+Char(13)
$vString:=$vString+""+shipping_carrier+" "+Char(13)
If (paymenttype="check")
$vString:=$vString+""+paymenttype+" "+Char(13)
End if
End if
If (customer_vault_action="delete_customer")
$vString:=$vString+""+customer_vault_action+" "+customer_vault_id+"
End if
If (transactiontype="sale") | (transactiontype="auth") | (customer_vault_action="add_customer") | (customer_vault_action="update_customer")
$vString:=$vString+""+paymenttype+" "+Char(13)
If (customer_vault_action="add_customer") | (customer_vault_action="update_customer")
$vString:=$vString+""+customer_vault_action+" "+Char(13)
End if
$vString:=$vString+""+customer_vault_id+" "+Char(13)
If (paymenttype="creditcard")
$vString:=$vString+""+ccnumber+" "+Char(13)
$vString:=$vString+""+ccexpire+" "+Char(13)
$vString:=$vString+""+cvv2+" "+Char(13)
End if
If (paymenttype="check")
$vString:=$vString+""+checkname+" "+Char(13)
$vString:=$vString+""+routing+" "+Char(13)
$vString:=$vString+""+account+" "+Char(13)
$vString:=$vString+""+accountholdertype+" "+Char(13)
$vString:=$vString+""+accounttype+" "+Char(13)
$vString:=$vString+""+seccode+" "+Char(13)
End if
$vString:=$vString+""+payment_plan_sku+" "+Char(13)
$vString:=$vString+""+amount+" "+Char(13)
$vString:=$vString+""+tax+" "+Char(13)
$vString:=$vString+""+shipping+" "+Char(13)
$vString:=$vString+""+description+" "+Char(13)
$vString:=$vString+""+orderid+" "+Char(13)
$vString:=$vString+""+ponumber+" "+Char(13)
$vString:=$vString+""+firstname+" "+Char(13)
$vString:=$vString+""+lastname+" "+Char(13)
$vString:=$vString+""+company+" "+Char(13)
$vString:=$vString+""+address1+" "+Char(13)
$vString:=$vString+""+address2+" "+Char(13)
$vString:=$vString+""+city+" "+Char(13)
$vString:=$vString+""+state+" "+Char(13)
$vString:=$vString+""+zip+" "+Char(13)
$vString:=$vString+""+country+" "+Char(13)
$vString:=$vString+""+phone+" "+Char(13)
$vString:=$vString+""+fax+" "+Char(13)
$vString:=$vString+""+email+" "+Char(13)
$vString:=$vString+""+website+" "+Char(13)
$vString:=$vString+""+shipfirstname+" "+Char(13)
$vString:=$vString+""+shiplastname+" "+Char(13)
$vString:=$vString+""+shipcompany+" "+Char(13)
$vString:=$vString+""+shipaddress1+" "+Char(13)
$vString:=$vString+""+shipaddress2+" "+Char(13)
$vString:=$vString+""+shipcity+" "+Char(13)
$vString:=$vString+""+shipstate+" "+Char(13)
$vString:=$vString+""+shipzip+" "+Char(13)
$vString:=$vString+""+shipcountry+" "+Char(13)
$vString:=$vString+""+shipemail+" "+Char(13)
$vString:=$vString+""+processorid+" "+Char(13)
$vString:=$vString+""+descriptor+" "+Char(13)
$vString:=$vString+""+descriptorphone+" "+Char(13)
End if
$vString:=$vString+"
$vString:=$vString+""
$result:=""
TEXT TO BLOB($vString;$vBlobIn;Text without length )
SET WEB SERVICE PARAMETER("MyXMLInputBlob";$vBlobIn)
CALL WEB SERVICE("https://www.nelixtransax.com/roxapi/rox.asmx";"https://www.nelixtransax.com/roxapi/ProcessTransaction";"ProcessTransaction";"https://www.nelixtransax.com/roxapi/";Web Service Manual )
If (OK=1)
GET WEB SERVICE RESULT($vBlobOut;"ProcessTransactionResult";*) ` Memory clean-up on the final return value.
$result:=BLOB to text($vBlobOut;Text without length )
End if
$xml_Value:=""
$xml_Parent_Ref:=DOM Parse XML variable($result)
$xml_Child_Ref:=DOM Get first child XML element($xml_Parent_Ref)
$xml_Element_Value:=DOM Get XML element($xml_Child_Ref;"TRANS_ID";1;$TRANS_ID)
$xml_Element_Value:=DOM Get XML element($xml_Child_Ref;"STATUS_CODE";1;$STATUS_CODE)
$xml_Element_Value:=DOM Get XML element($xml_Child_Ref;"STATUS_MSG";1;$STATUS_MSG)
$xml_Element_Value:=DOM Get XML element($xml_Child_Ref;"AUTH_CODE";1;$AUTH_CODE)
$xml_Element_Value:=DOM Get XML element($xml_Child_Ref;"AVS_CODE";1;$AVS_CODE)
$xml_Element_Value:=DOM Get XML element($xml_Child_Ref;"AVS_MSG";1;$AVS_MSG)
$xml_Element_Value:=DOM Get XML element($xml_Child_Ref;"CVV2_CODE";1;$CVV2_CODE)
$xml_Element_Value:=DOM Get XML element($xml_Child_Ref;"CVV2_MSG";1;$CVV2_MSG)
$xml_Element_Value:=DOM Get XML element($xml_Child_Ref;"ORDERID";1;$ORDERID)
$xml_Element_Value:=DOM Get XML element($xml_Child_Ref;"CUSTOMER_VAULT_ID";1;$CUSTOMER_VAULT_ID)
vResult:="STATUS CODE: "+$STATUS_CODE+Char(13)
vResult:=vResult+"STATUS MSG: "+$STATUS_MSG+Char(13)
vResult:=vResult+"TRANS ID: "+$TRANS_ID+Char(13)
vResult:=vResult+"AUTH CODE: "+$AUTH_CODE+Char(13)
vResult:=vResult+"AVS CODE: "+$AVS_CODE+Char(13)
vResult:=vResult+"AVS MSG: "+$AVS_MSG+Char(13)
vResult:=vResult+"CVV2 CODE: "+$CVV2_CODE+Char(13)
vResult:=vResult+"CVV2 MSG: "+$CVV2_MSG+Char(13)
vResult:=vResult+"ORDER ID: "+$ORDERID+Char(13)
vResult:=vResult+"CUSTOMER VAULT ID: "+$CUSTOMER_VAULT_ID+Char(13)
DOM CLOSE XML($xml_Parent_Ref)
Download 4D (4th Dimension) credit card and ACH (e-check) integration examples
Comments