Subject Authorize.NET ???
From James Loughner <jwrl@suddenlink.net>
Date Thu, 19 Aug 2021 11:23:32 -0400
Newsgroups xb2net


Any get connection to Authorize.NET working?????

Here is my attempt, tried both the JSON and XML coding. I get what
appears to be successful connection but no code comes back. For PayPal
it comes back in the content variable but here no content variable is in
the returned object.

Any Ideas??

Jim




METHOD Authorize:ProcPPCC()
LOCAL cReq:="" ,oJ,jRreq,cURL,ccType:=GetCCtype(Alltrim(
::CCCardNo:EditBuffer() ))
LOCAL oClient := XbHttpClient():New()
LOCAL oForm   := XbForm():New(),a
LOCAL oResponse,cResp,aHeader,lRtn:=.T.,cEXPMonth,cEXPYEAR
    ::StatList:AddItem("Process Credit Card")
    cURL := ::BaseURL
    aHeader := {{"Accept", "text/xml"}}
    cEXPMonth := LEFT(::ExpDate:EditBuffer(),2)
    cEXPYEAR  := "20"+RIGHT(::ExpDate:EditBuffer(),2)

//  XML
    cReq += '<createTransactionRequest
xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">'
    cReq += '  <merchantAuthentication>'
    cReq += '    <name>'+::cUser_ID+'</name>'
    cReq += '    <transactionKey>'+::cSecret+'</transactionKey>'
    cReq += '  </merchantAuthentication>'
    cReq += '  <refId>'+::TICKET+'</refId>'
    cReq += '  <transactionRequest>'
    cReq += '    <transactionType>authCaptureTransaction</transactionType>'
    cReq += '      <amount>'+::Amount:EditBuffer()+'</amount>'
    cReq += '      <payment>'
    cReq += '        <creditCard>'
    cReq += '          <cardNumber>'+Alltrim( ::CCCardNo:EditBuffer()
)+'</cardNumber>'
    cReq += '
<expirationDate>'+cEXPYEAR+'-'+cEXPMonth+'</expirationDate>'
    cReq += '          <cardCode>'+::SecurtyCode:EditBuffer()+'</cardCode>'
    cReq += '        </creditCard>'
    cReq += '      </payment>'
    cReq += '    <order>'
    cReq += '      <invoiceNumber>INV-'+::TICKET+'</invoiceNumber>'
    cReq += '      <description>Product Description</description>'
    cReq += '    </order>'
    cReq += '    <authorizationIndicatorType>'
    cReq += '      <authorizationIndicator>final</authorizationIndicator>'
    cReq += '    </authorizationIndicatorType>'
    cReq += '  </transactionRequest>'
    cReq += '</createTransactionRequest>'

/*    JSON
    cReq +=   '"createTransactionRequest": {'
    cReq +=      '"merchantAuthentication": {'
    cReq +=        '"name": "'+::cUser_ID+'",'
    cReq +=        '"transactionKey": "'+::cSecret+'"'
    cReq +=       '},'
    cReq +=      '"refId": "'+::TICKET+'",'
    cReq +=      '"transactionRequest": {'
    cReq +=        '"transactionType": "authCaptureTransaction",'
    cReq +=        '"amount": "'+::Amount:EditBuffer()+'",'
    cReq +=        '"currencyCode": "USD",'
    cReq +=        '"payment": {'
    cReq +=          '"creditCard": {'
    cReq +=            '"cardNumber": "'+Alltrim(
::CCCardNo:EditBuffer() )+'",'
    cReq +=            '"expirationDate": "'+cEXPYEAR+'-'+cEXPMonth+'",'
    cReq +=            '"cardCode": "'+::SecurtyCode:EditBuffer()+'"'
    cReq +=            '}'
    cReq +=         '}'
    cReq +=      '}'
    cReq +=    '}'
    cReq +=  '}'
*/
    oJ := cReq   //xbJSON():new(cReq)

    oClient:RecvTimeout(60000)        // one min
    oClient:SendTimeout(10000)        // 10 sec
    oResponse := oClient:Execute(cURL, "POST", oJ, aHeader)
    IF !EMPTY(oResponse) .AND. oResponse:StatusCode == 200

ALTD()
       a := oResponse:message
       ::oCreditcarddata := Json2Var(oResponse:message)
       ::StatList:AddItem("Response received")
       ::StatList:AddItem("Card charged")
    ELSE
       cResp := "Error "
       IF !EMPTY(oResponse)
           cResp += STR(oResponse:StatusCode)
       ENDIF
       ::StatList:AddItem(cResp)
       ::StatList:AddItem(oClient:ErrorMessage())
       lRtn := .F.
    ENDIF
return lRtn

Recent messages in this thread
 
-# Authorize.NET ??? (Current message) James Loughner 19-Aug-2021 11:23 am
.|# Re: Authorize.NET ??? Boris Borzic <.> 19-Aug-2021 02:41 pm
.-# Re: Authorize.NET ??? James Loughner 20-Aug-2021 01:21 pm
..-# Re: Authorize.NET ??? James Loughner 27-Aug-2021 09:36 am
...\# Re: Authorize.NET ??? Andreas Gehrs-Pahl 29-Aug-2021 07:51 pm