Question Webpage To Receive Payment Notifications/url End-point

Potish

Member
I am working with a vendor that needs to send us notifications when clients complete specific transactions. In order to do so I need to provide the vendor with a URL end-point where they will post a JSON message with transactions details. I am looking to develop a WebSpeed page to act as the URL end-point and capture the JSON response. I have not developed this kind of page before. Does anyone have any sample code that supports a similar function I could reference to for the development

I am using OpenEdge 11.3 running on Windows Server 2012 R2 and IIS 6.0. Testing is conducted on a using localhost.
 

Cecil

19+ years progress programming and still learning.
  • Do you have a license for WebSpeed?
  • Do you need to send back an acknowledgment of some kind (i.e. a JSON string) or HTTP status code ( status: 200)?
  • Can you provide and documentation from the Payment Gateway Provider?
  • What is authentication process to handle the incoming request? I guessing it some kind of random key generated from your side first???
  • Is your Windows Server going to be open/public to the internet.
From what you are asking sound simple but more information is required. I have some free time and I can help you out with the code. Keeping it simple I would create a CGI wrapper to handle the incoming request.

Private Message me if you want to take this off-line.
 

Potish

Member
I have made progress with the solution for the item I had asked about before. I am now able to capture the JSON reponse from the vendor using the following code in WebSpeed. Code is abbreviated to include only sections related to the soltution

Code:
<script language="SpeedScript">
define variable mpJSONData as memptr    no-undo.

Procedure output-headers: 
    if web-context:is-json then
    do:
         SET-SIZE(mpJSONData) = 0.
         COPY-LOB FROM WEB-CONTEXT:FORM-LONG-INPUT TO mpJSONData.
      
        run programToProcessJson.r (input mpJSONData).

   end. /* if web-context:is-json then  */
END procedure.
</script>

The last item I need is code to send a JSON response back to vendor to indicate that I received the JSON they send. The JSON reponse back to vendor needs to look as follows

Code:
{"ResultDesc":"Confirmation Service request accepted succesfully",
"ResultCode":"0"}

I was thinking of adding the following code after the JSON has been processed in webspeed but I am not sure it will work as intended.

Code:
    run programToProcessJson.r (input mpJSONData).

    {&out} '~{"ResultDesc":"Confirmation Service request accepted succesfully",'.
    {&out} '~"ResultCode":"0"}'.
 

Cecil

19+ years progress programming and still learning.
Code:
    run programToProcessJson.r (input mpJSONData).
    {&out} '~{"ResultDesc":"Confirmation Service request accepted succesfully",'.
    {&out} '~"ResultCode":"0"}'.

Include the 'Content Type'.

Code:
    run programToProcessJson.r (input mpJSONData).
    output-http-header("status":U, "200").
    output-content-type("application/json":U).

    {&out} '~{"ResultDesc":"Confirmation Service request accepted succesfully",'.
    {&out} '"ResultCode":"0"}'.

    /* FLUSH THE WEBSTREAM (OPTIONAL) */
    put {&WEBSTREAM} control null.

In the API specification, I'm not sure if you need to include some extra HTTP header information i.e. Authentication...

Also, does the 'ResultCode' value need to be in quotes or not?
 
Last edited:
Top