Results 1 to 3 of 3

Thread: send response to one callback receveid

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2009
    Location
    milano italy
    Posts
    337

    Default send response to one callback receveid

    Hi
    I should need to send a response to a callback received by a previous http post, but I do not know is possible and how to
    I send a
    Code:
    Get HttpVerbAddrRequest  of hoHttp  spath (AddressOf(sBody))  (Length(sBody))  False "POST" to bok
    see whole function below
    Code:
      Function paymentOrder UChar[]   usAuthtoken  Number namount   String sCoinwalletid ;
                              String  stracking_id String slifetime Integer ipow Returns DinastyPayOrder  
                           
            String spath sBody sjsonresponse  sAuthtoken
            Handle hoJsonObj hoHttp
            Integer iok
            Boolean bok bsuccess
             Get Create (RefClass(cCEHttpTransfer)) to hoHttp
         
            Move "/api/v1/pay/bills" to spath
             Move (UCharArrayToString(usAuthtoken)) to sAuthtoken
               
                Send Reset  of hoHttp       
                Set psRemoteHost   of hoHttp     to C_DINASTYPAYSANDBOXLINK
     
                Set piRemotePort  of hoHttp     to rpHttpSSL         
                Set peTransferFlags  of hoHttp   to ifSecure             
      
                 Get AddHeader    of hoHttp    "Authorization" ( "Bearer" *  (trim(String(sAuthtoken)) ))  to iOK
              
                 Get AddHeader of hoHttp  "Content-Type"   "application/x-www-form-urlencoded"  to iok
                 Get AddHeader  of hoHttp   "Cache-control" "no-cache" to iok
                             
                Move "wallet=%WALLET%&amount=%AMOUNT%&lifetime=%LIFETIME%&pow=%POW%&tracking_id=%TRACK%" to sbody
                 Move (Replace("%WALLET%",sbody,(String(sCoinwalletid)))) to sBody
                Move (Replace("%AMOUNT%",sbody,(String(namount)))) to sBody
                Move (Replace("%LIFETIME%",sbody,slifetime)) to sbody
                Move (Replace("%POW%",sbody,(String(ipow)))) to sbody
                Move (Replace("%TRACK%",sbody,(String(stracking_id)))) to sbody
    
    
                Get Create (RefClass(cJsonObject)) to hoJsonObj
                Send InitializeJsonType of hoJsonObj jsonTypeObject   
                Integer icount i icount2 i2 i3 
                Handle hodata hofrom hoto horate hrow hotransactions hocurrency
                String sval
                DinastyPayOrder stDinastyPayOrder
                  Get HttpVerbAddrRequest  of hoHttp  spath (AddressOf(sBody))  (Length(sBody))  False "POST" to bok
                 If (bOk)  Begin
                     Get psdata of hoHttp to sjsonresponse
    
    
                     Get ParseString of hoJsonObj sjsonresponse to bsuccess 
                     If (Pos("error",sjsonresponse)) Begin 
                        Move sjsonresponse to stDinastyPayOrder.sMessage
                     End
                      Else If bsuccess Begin
                          Get Member  of hoJsonObj "data"  to hodata
                          Get membercount of hodata to icount
                          Get MemberValue of hodata "id" to stDinastyPayOrder.sid
                          Get MemberValue of hodata "url" to stDinastyPayOrder.surl
                          Get MemberValue of hodata "address" to stDinastyPayOrder.saddressRicevente
                          Get MemberValue of hodata "created" to stDinastyPayOrder.sdatetimeCreate
                          Get MemberValue of hodata "expired" to stDinastyPayOrder.sexpired
                          Get MemberValue of hodata "status" to stDinastyPayOrder.sstatus
                          Get MemberValue of hodata "tracking_id" to stDinastyPayOrder.sTrackingId
                          Get MemberValue of hodata "callback_url" to stDinastyPayOrder.sCallbackUrl
                          Get MemberValue of hodata "amount" to stDinastyPayOrder.samount
                          Get MemberValue of hodata "actual_amount" to stDinastyPayOrder.sActualAmount
                          Get MemberValue of hodata "pow" to stDinastyPayOrder.ipow
                          Get Member  of hodata "transactions" to hotransactions
                         
                          Get Member of hodata "currency" to hocurrency //stDinastyPayOrder.scurrency
                             Get MemberValue of hocurrency "alpha"  to stDinastyPayOrder.scurrency
                          
                          Send destroy of hodata 
                          Send destroy of hocurrency 
                      End
               End
                Send Destroy of hoJsonObj
                Send destroy of hoHttp 
                Function_Return stDinastyPayOrder
        End_Function
    It is ok I receive response and fill my structure
    but the api want a response to the callback from me to know that I received with success the informations

    in jquery the function that also send the correct response to callback is:

    Code:
     var settings = {  "async": true,  "crossDomain": true,  "url": "https://paysystemtest.b2broker.info/api/v1/pay/bills",  "method": "POST",  "headers": 
       {    "authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9I6MTUyMDU0NjcyMn0.-AaTOAnhne-u8ioWMJrTozph _25mQhSTQGS2cx3tx6w",   
         "content-type": "application/x-www-form-urlencoded"  },
          "data": {    "wallet": "2",    "amount": "100000",    "lifetime": "0",    "pow": "8"  } }
    
    $.ajax(settings).done(function (response) {  console.log(response); });    <<< the jquery send a response done  like ti send this back to callback   Status: 200  Body : OK
    so question is how I can send a response to a callback function using dataflex http transfer protocol?

    regards
    Franco

  2. #2
    Join Date
    Feb 2009
    Location
    South Florida
    Posts
    3,529

    Default Re: send response to one callback receveid

    i think you are misreading

    in the jquery code the 'done' function is called when the async call finishes without errors. you then put your code to process the response there

    DF not being async you can simply code the finishing code after the HTTP post finishes. you will need to check to make sure the call was successful
    Michael Salzlechner
    StarZen Technologies, Inc
    http.://www.starzen.com

    Development Blog
    http://www.salzlechner.com/dev

    DataFlex Package Manager (aka Nuget for DataFlex)
    http://windowsdeveloper.com/dfPackage

  3. #3
    Join Date
    Apr 2009
    Location
    milano italy
    Posts
    337

    Default Re: send response to one callback receveid

    Quote Originally Posted by starzen View Post
    i think you are misreading

    in the jquery code the 'done' function is called when the async call finishes without errors. you then put your code to process the response there

    DF not being async you can simply code the finishing code after the HTTP post finishes. you will need to check to make sure the call was successful
    Yes I know but just asking maybe there was a trick.... This call require to receive back the response "OK" in the body. It Is first time that I found this. I did hundreds api interfces call with DF this was first time I found similar requirement.
    I will see how I can do it
    thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •