Recent

Author Topic: Elavon my IP returning redirect  (Read 1239 times)

RedOctober

  • Sr. Member
  • ****
  • Posts: 401
Elavon my IP returning redirect
« on: May 14, 2021, 05:22:21 pm »
Platform:  Lazarus 2.0.10   FPC 3.2.0   IndyHTTP   Windows Server 2016
Goal: To allow my clients to pay for my services on line.  I will be using Elavon's Hosted Page model.
Current status: I am at the very beginning of this process.  I am trying to get WhiteListed
Others involved:  I am in contact with the Elavon developer support team, who are not familiar with Lazarus, IndyHTTP, etc.
I am following the instructions given in my introductory email, which are as follows:


https://www.convergepay.com/hosted-payments/myip

Code: PHP  [Select][+][-]
  1. <?php
  2.   $ch = curl_init("https://www.convergepay.com/hosted-payments/myip");
  3.   curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  4.   curl_setopt($ch, CURLOPT_HEADER, 0);
  5.   $data = curl_exec($ch);
  6.   echo $data;
  7.   exit;
  8. ?>

Here is the code I used to send the above:

Code: Pascal  [Select][+][-]
  1.  
  2. procedure TfrmMain.SendElvURL;
  3. var
  4.   htp: TIdHTTP;
  5.   ReqJson: TStringStream;
  6.   JSON: TJSONStringType;
  7.   s, url: String;
  8.  
  9. begin
  10.   url := 'https://urldefense.proofpoint.com/v2/url?u=https-3A__www.convergepay.com_hosted-2Dpayments_myip&d='; //  (last part removed, in case it is a private ID for me only)
  11.  
  12.   s :=
  13.     '<?php' +
  14.       '$ch = curl_init("https://www.convergepay.com/hosted-payments/myip");' +
  15.       'curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);' +
  16.       'curl_setopt($ch, CURLOPT_HEADER, 0);' +
  17.       '$data = curl_exec($ch);' +
  18.       'echo $data;' +
  19.       'exit;' +
  20.     '?>';
  21.  
  22.   ReqJson := TStringStream.Create(s);
  23.  
  24.   try
  25.  
  26.     htp := htpElv;
  27.  
  28.     htp.Request.Accept := 'application/json';
  29.     htp.Request.ContentType := 'application/json';
  30.     htp.Request.Username := '';
  31.     htp.Request.Password := '';
  32.     htp.Request.BasicAuthentication := False;
  33.  
  34.     htp.Request.CustomHeaders.Clear;
  35.     htp.Request.CustomHeaders.FoldLines := False;
  36.  
  37.     htp.Get(url, ReqJson);
  38.  
  39.   finally
  40.  
  41.  
  42.     ReqJson.Free;
  43.  
  44.     if htp.Connected then
  45.       htp.Request.Connection := 'close';
  46.  
  47.   end;
  48.  
  49. end;
  50.  
  51.  

The result of executing this procedure is that my app stops, and displays a modal error message: 


[Window Title]
cwp

[Content]
HTTP/1.1 302 Found.

Press OK to ignore and risk data corruption.
Press Abort to kill the program.

[OK] [Abort]

So my question is...

1) Am I setting all the properties correctly to perform the "GET" as requested by Elavon?
2) Is this expected behavior of the IdHTTP component?
3) Is there a better, proper way for me to handle a 302 message, instead of it displaying an error and stopping my app, so I have to manually click "OK" to get it to start up again?

Thanks in advance for any help you can provide.

[Edited to add code tags]
« Last Edit: May 15, 2021, 02:33:19 am by trev »

PierceNg

  • Full Member
  • ***
  • Posts: 110
Re: Elavon my IP returning redirect
« Reply #1 on: May 15, 2021, 06:23:15 am »
https://www.convergepay.com/hosted-payments/myip

This link just tells you what your public IP is, as seen by the website.

Your Pascal code is sending a PHP code snippet to what appears to be proofpoint.com's API, telling said API that the PHP code is in JSON format when it is not. The Pascal code is most likely not doing whatever you want done.

 

TinyPortal © 2005-2018