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