Subject getvar array from xbHTTPThread empty ... but can get individual getvar ...please help
From Nestor <> <Nestor <>>
Date Sat, 03 Aug 2019 13:31:29 +0100
Newsgroups xb2net

getvar array from xbHTTPThread empty ...  but can get individual getvar ...please help

xb2net version 3.6.0 for alaska version 19 0355
running windows 10 1903

Kind Regards
From Nestor

Following is the code in question refer: <======= x 2

//-----------------------------------------------------------------------------
PROCEDURE WEB_ITNPAYFAST()
   Local lUpdate  := .t., cStore_path:=""
   Local cMessage := ""
   Local oClient  := ThreadObject()  // this is the xbHTTPThread object
   Local oServer  := oClient:Parent  // this is the xbHTTPServer object
   Local cRemoteHostName:= Lower(oClient:xbSocket:RemoteName())
   Local oResponse:= oClient:HTTPResponse
   Local oHttp, oResp, nlen:=0, I:=0, oForm
   Local cResponseUrl:=""
   Local aITN
   Local cm_payment_id:= "", cPf_payment_id:="", nAmount_gross:=0.00, nAmount_fee:=0.00, nAmount_net:=0.00,;
         cPy_status:="", cPayer_id:="", cPayme_Status:="", cPayer_email:="", cEnv:="", cService:="Payfast"    
   Local aValid_Urls:={"www.payfast.co.za","sandbox.payfast.co.za","w1w.payfast.co.za","w2w.payfast.co.za"}
   cStore_path:=oClient:GetVar("store")
   If empty(cStore_path)
      cStore_path:="/TVHS"
   Endif
   cStore_path:=remright(cStore_path,"/")
   Use (cStore_path+"/data/SHPPARM0.DBF") NEW SHARED
    If SHPPARM0->SHP_ENV == "T" && if in test environment
       cResponseUrl:="sandbox.payfast.co.za"
    Else
       cResponseUrl:="payfast.co.za"
    Endif
    cEnv:=SHPPARM0->SHP_ENV
   Close SHPPARM0
   If AScan( aValid_Urls, cRemoteHostName) > 0  && cRemoteHostName is valid
      //MsgBox("valid: "+cRemoteHostName)
   Else
      Dumpme_payfast("Invalid url",oClient,cEnv, cRemoteHostName, cStore_path )
      //MsgBox("Invalid: "+cRemoteHostName)
   Endif
   oResponse:StatusCode := 200
   oResponse:Content    := ""

   oHttp := xbHTTPClient():new()
   oHttp:Transport := VIA_WININET
   oForm := xbform():new()
   aITN := oClient:GetVar()
   nlen:=len(aITN)
   MsgBox(str(nlen))  <============== 0 !!!! HELP HELP
   /* Load form with notify payfast variables
      not the last one which is the signature */
   for I = 1 to nlen-1
        oForm:SetVar(aITN[I][1],aITN[I][2])
   Next I
   MsgBox(oClient:GetVar("m_payment_id")+"..."+oClient:GetVar("pf_payment_id")) <======== but can get vars
   /*
   MsgBox(aITN[1][1]+"..."+aITN[1][2])
   MsgBox(aITN[2][1]+"..."+aITN[2][2])
   MsgBox(aITN[nlen][1]+"..."+aITN[nlen][2])
   */
/* amount_gross, amount_fee, amount_net */
   oResp := oHttp:Execute("https://"+cResponseUrl+"/eng/query/validate","POST",oForm)
   If oResp:Content == "VALID"
        MsgBox("Vaild respose")
        cM_payment_id :=oClient:GetVar("m_payment_id")      && my invoice number
        cPf_payment_id:=oClient:GetVar("pf_payment_id")     && Transaction id from service provider
        nAmount_gross :=val(oClient:GetVar("amount_gross")) && Gross monetary amount of transaction
        nAmount_fee   :=val(oClient:GetVar("amount_fee"))*-1  && Fee monetary charged by CC service provider
        nAmount_net   :=val(oClient:GetVar("amount_net"))   && Net monetary amount received from service pr
        cPy_status    :=oClient:Getvar("payment_status")    && Transaction status from CC service provider
        if cPy_Status == "COMPLETE"
           cPayme_Status:="Y"
                   MsgBox("payment status = Y")
        Else
           cPayme_Status:="N"
                   MsgBox("payment status = N")
        Endif
        cPayer_email  :=""
        Update_RAPS_Order(cm_payment_id,;
                          cPf_payment_id,;
                          cPayer_id,;
                          nAmount_gross,;
                          nAmount_fee,;
                          nAmount_net,;
                          cPy_status,;
                          cPayme_Status,;
                          cPayer_email, oClient, cEnv, cService, cStore_path)
    Else
           MsgBox("InVaild response"+oResp:Content)
       Dumpme_payfast("Garbage received",oClient,cEnv,cRemoteHostName ,cStore_path )
   Endif  


Return

Recent messages in this thread
 
-# getvar array from xbHTTPThread empty ... but can get individual getvar ...please help (Current message) Nestor <> 03-Aug-2019 08:31 am
.\# Re: getvar array from xbHTTPThread empty ... but can get individual getvar ...please help Nestor <> 03-Aug-2019 08:50 am