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<?php
$ch = curl_init("https://www.convergepay.com/hosted-payments/myip"); echo $data;
?>
Here is the code I used to send the above:
procedure TfrmMain.SendElvURL;
var
htp: TIdHTTP;
ReqJson: TStringStream;
JSON: TJSONStringType;
s, url: String;
begin
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)
s :=
'<?php' +
'$ch = curl_init("https://www.convergepay.com/hosted-payments/myip");' +
'curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);' +
'curl_setopt($ch, CURLOPT_HEADER, 0);' +
'$data = curl_exec($ch);' +
'echo $data;' +
'exit;' +
'?>';
ReqJson := TStringStream.Create(s);
try
htp := htpElv;
htp.Request.Accept := 'application/json';
htp.Request.ContentType := 'application/json';
htp.Request.Username := '';
htp.Request.Password := '';
htp.Request.BasicAuthentication := False;
htp.Request.CustomHeaders.Clear;
htp.Request.CustomHeaders.FoldLines := False;
htp.Get(url, ReqJson);
finally
ReqJson.Free;
if htp.Connected then
htp.Request.Connection := 'close';
end;
end;
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]