Hosted Payment Page with Preload.

Trying to convert my Hosted Payment page over to the Preload method.  Using Curl to send the request in PHP on the Development URL, .

the response I get is               

 

Source: - POST-esplusqa.moneris.com.      

I was expecting an Error code or XML to parse. Any idea what the problem is? 

 

I found mpgClasses on GitHub, but is this used for Preload?  Do you have any PHP code utilizing Curl  for the Preload request? The API on the developer's site show how to do the HTTP Post once you have the ticket, but I can't find any examples to make the Curl Request in PHP.   I looked at similar questions, but you always send the example code, but never post it!  I am in the USA. Please help, been struggling for a week to locate an example or find out what is wrong.

  • In reply to RR_Moneris:

    yes that's exactly included in the preload.php page

    echo'<FORM METHOD="POST" ACTION="esqa.moneris.com/.../index.php">';
    echo'<INPUT TYPE="HIDDEN" NAME="hpp_id" VALUE="'.$store_id.'">';
    echo'<INPUT TYPE="hidden" NAME="hpp_preload" >';
    echo'<INPUT TYPE="hidden" NAME="ticket" VALUE="'.$ticket.'">';
    echo'<INPUT TYPE="SUBMIT" NAME="SUBMIT" VALUE="Click to proceed to Secure Page">';
    echo'</FORM>'
  • In reply to flashroiem:

    In the declaration you have used the variable as "$ps_store_id"
    $ps_store_id = "Our store id";

    But in the submit form it is "$store_id"
    echo'<INPUT TYPE="HIDDEN" NAME="hpp_id" VALUE="'.$store_id.'">';
  • In reply to sheron:

    In the submit form I changed :
    echo'<INPUT TYPE="HIDDEN" NAME="hpp_id" VALUE="'.$store_id.'">';

    to :
    echo'<INPUT TYPE="HIDDEN" NAME="hpp_id" VALUE="'.$ps_store_id.'">';

    still getting output:
    "Unable to proceed with transaction. Your card has not been charged. Please try again."
  • In reply to flashroiem:

    What is this?

    $charge_total = "amount";

    Paste your full code, no need to mask amount if that's what you were doing.
  • In reply to flashroiem:

    It would help to see exactly what you are returning to the client for the form... for example the ps_store_id value and ticket. If not wanting to share it on this forum you can send it to eproducts@moneris.com
  • In reply to RR_Moneris:

    My apologies. Below is the full source code of the data preload:

    <?php

    $gArray=array
    (
    'API_VERSION' =>"curl/7.29.0",
    'CLIENT_TIMEOUT' => '60'
    );

    //Setup data to send to Moneris
    $store_id = "<Your Test Store ID>";
    $hpp_key = "<Your HPP Key> ";
    $charge_total = "105.00";

    $url ="esqa.moneris.com/.../index.php"; //QA Url
    $dataToSend = "ps_store_id=$store_id&hpp_key=$hpp_key&charge_total=$charge_total&hpp_preload=";

    //send transaction to Moneris via an HTTPS Post using php Curl
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $dataToSend);
    curl_setopt($ch, CURLOPT_TIMEOUT, $gArray['CLIENT_TIMEOUT']);
    curl_setopt($ch, CURLOPT_USERAGENT, $gArray['API_VERSION']);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

    $response = curl_exec($ch);
    curl_close($ch);
    echo "Raw Response : " . $response . "<br/>";
    if(!$response){
    $response="Error preloading page";
    }else{
    $xmlString = new SimpleXMLElement($response);

    $ticket = $xmlString -> ticket;
    $order_id = $xmlString -> order_id;
    $response_code = $xmlString -> response_code;

    echo "Data recieved : <BR/>";
    echo "Ticket : " . $ticket . "<br/>";
    echo "Order ID : " . $order_id . "<br/>";
    echo "Response Code : " . $response_code . "<br/>";

    if($response_code <50)
    {
    echo "OK: Data successfully loaded <BR/> <br/>";
    echo'<FORM METHOD="POST" ACTION="esqa.moneris.com/.../index.php">';
    echo'<INPUT TYPE="HIDDEN" NAME="hpp_id" VALUE="'.$store_id.'">';
    echo'<INPUT TYPE="hidden" NAME="hpp_preload" >';
    echo'<INPUT TYPE="hidden" NAME="ticket" VALUE="'.$ticket.'">';
    echo'<INPUT TYPE="SUBMIT" NAME="SUBMIT" VALUE="Click to proceed to Secure Page">';
    echo'</FORM>';
    }
    else{
    echo "Error: Data was not successfully loaded <br>";
    }

    }

    ?>


    ------------------------
    Output: Raw Response : Invalid store credentials.

    ------------------------
    error log file result:

    [14-Aug-2018 04:54:25 UTC] PHP Warning: SimpleXMLElement::__construct(): Entity: line 1: parser error : Start tag expected, '&lt;' not found in /home/luvcnd2013/public_html/payment/preload2.php on line 34

    [14-Aug-2018 04:54:25 UTC] PHP Warning: SimpleXMLElement::__construct(): Invalid store credentials. in /home/luvcnd2013/public_html/payment/preload2.php on line 34

    [14-Aug-2018 04:54:25 UTC] PHP Warning: SimpleXMLElement::__construct(): ^ in /home/luvcnd2013/public_html/payment/preload2.php on line 34

    [14-Aug-2018 04:54:25 UTC] PHP Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /home/luvcnd2013/public_html/payment/preload2.php:34
    Stack trace:
    #0 /home/luvcnd2013/public_html/payment/preload2.php(34): SimpleXMLElement->__construct('Invalid store c...')
    #1 {main}
    thrown in /home/luvcnd2013/public_html/payment/preload2.php on line 34

    [14-Aug-2018 04:54:33 UTC] PHP Warning: SimpleXMLElement::__construct(): Entity: line 1: parser error : Start tag expected, '&lt;' not found in /home/luvcnd2013/public_html/payment/preload2.php on line 34

    [14-Aug-2018 04:54:33 UTC] PHP Warning: SimpleXMLElement::__construct(): Invalid store credentials. in /home/luvcnd2013/public_html/payment/preload2.php on line 34

    [14-Aug-2018 04:54:33 UTC] PHP Warning: SimpleXMLElement::__construct(): ^ in /home/luvcnd2013/public_html/payment/preload2.php on line 34

    [14-Aug-2018 04:54:33 UTC] PHP Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /home/luvcnd2013/public_html/payment/preload2.php:34
    Stack trace:
    #0 /home/luvcnd2013/public_html/payment/preload2.php(34): SimpleXMLElement->__construct('Invalid store c...')
    #1 {main}
    thrown in /home/luvcnd2013/public_html/payment/preload2.php on line 34
  • In reply to flashroiem:

    What we need to see is what you are posting for the preload and what you are getting for response. We also need to see what is posted to our hosted paypage (the request that will have the ticket).

    You sent us your code, but not what is actually being sent to us.