Jump to content

Form Post - Posting Invalid information


stublackett

Recommended Posts

I'm having on and off problems with a PaReq code that I receieve from PayPoint.

 

This is part of a 3D Secure transaction. What happens is, I post to PayPoint the card information, They send me back a URL, MD Code and a PaReq code, The MD and URL are fine. BUT the PaReq is hit and miss.

 

After consulting the tech support at PayPoint they are saying that occassionally the PaReq string is missing the "==" from the end of it.

 

How can this be, If all I am doing is replicating what they send to me?

 

My code is as follows...

 

The Array I receieve from PayPoint :

 

array
'valid' => string 'true' (length=4)
'test_status' => string 'true' (length=4)
'trans_id' => string 'TRAN004' (length=7)
'mpi_status_code' => string '200' (length=3)
'mpi_message' => string 'Payer Verification Required' (length=27)
'acs_url' => string 'https%3A%2F%2Fwww.secpay.com%2Fjava-bin%2FACSSimulator%3Fpartner%3Dsecpay%26VAA%3DB' (length=83)
'MD' => string '1510881303' (length=10)
'PaReq' => string 'eJxVUlFvgjAQft+vIP4AWhANmqPGqcl8YHEb2zspF2SDggUG/vtdFdQ1aXLf3X29u+8Kq77IrV/UdVaqYOLYfLISTxAdNeL2A2WrUUCIdR2naGUJZcwc7vvOlE8nAg7rdzwJGOiC2LYLbITE0/IYq0ZALE/P+1fhuQvuesAGCAXq/VbM+HzqufTu9QC7ukHFBYpcYqly7gC7QJBlqxp9Fr47BzYCaHUujk1TLRnrus6+kjKFtizt9geYiQO793NojVXTe32WiDD67MNt6oVR2IXndbrf3G4AzGRAEjcoXO7Q4b7FF8uZt+Q0ycUPcWEaERSj7gcAlamxfow8eoCk1ajkOMmIAPuqVEgZpOTNhgRrKTZUTGcqtXanNqsKClADJgDsPtDmxcgtG1Lw63vnhtGuD9+CwIh+cZoCGWlGK3QuFQwAZmhs2CcbFk7Wv4/wB5zPtsU' (length=455)

 

The HTML Form I send :

 

<form name='mainform' action='$threedurl' method='POST'>
<center>
<h1>Processing your 3D Secure Transaction</h1>
<h3>Please click Submit to continue
the processing of your 3D Secure
transaction.</h3>
<input type='submit' value='Submit'>
</center>
<input type='hidden' name='PaReq' value='$paymentauth'>
<input type='hidden' name='TermUrl' value='http://localhost/Test Stuff/Payments/pares.php'>
<input type='hidden' name='MD' value='$mdcode'>
</form>
<SCRIPT LANGUAGE='Javascript' >
<!--
function OnLoadEvent()
{
document.mainform.submit();
}
//-->

 

PHP Code to load the array is :

 

<?php

if(isset($_POST['submit'])) {

extract ($_POST);

$soapClient = new SoapClient("https://www.secpay.com/java-bin/services/SECCardService?wsdl");

$params = array(
'mid'                   => '',
'vpn_pswd'          => '',
'trans_id'          => 'TRAN000102',
'ip'                    => '127.0.0.1',
'name'              =>  $card_name,
'card_number'           =>  $card_number,
'amount'                =>  $amount,
'expiry_date'           =>  $card_expire_Month.$card_expire_Year,
'issue_number'      =>  '',
'start_date'            =>  '',
'order'             =>  '',
'shipping'          =>  '',
'billing'               =>  '',
'options'               =>  'test_status=true, test_mpi_status=true',
'device_category'       =>  '',
'accept_headers'        =>  '',
'user_agent'            =>  '',
'mpi_merchant_name' => '',
'mpi_merchant_url'  => '',
'mpi_description'       =>  '',
'purchaseRecurringFrequency'    => '',
'purchaseRecurringExpiry' => '',
'purchaseInstallments' => ''
);

$error = 0;
try {
    // Call The Soap Client threeDSecureEnrolmentRequest - As Per Paypoint Docs...

    $result = $soapClient->__call("threeDSecureEnrolmentRequest", $params);
}
catch(SoapFault $fault) {
  $error = 1; 
  if($fault->faultstring != 'Could not connect to host') {

      throw $fault;
  }
}

if ($error == 0) {

  $args = split("&", substr($result,1));

  foreach ( $args as $arg) {
    list($key, $value) = explode("=", $arg);
    $result_arr[$key] = $value;
  }

  var_dump($result_arr);
  var_dump($params);
   print_r($_POST);

   $mpistatus = $result_arr['mpi_status_code'];

  if ($mpistatus == '200')
  {
        $threedurl = urldecode($result_arr['acs_url']);
        $paymentauth = $result_arr['PaReq'];
        $mdcode = $result_arr['MD'];

        echo 
        "<form name='mainform' action='$threedurl' method='POST'>
            <center>
                <h1>Processing your 3D Secure Transaction</h1>
                <h3>Please click Submit to continue
                the processing of your 3D Secure
                transaction.</h3>
                <input type='submit' value='Submit'>
            </center>
            <input type='hidden' name='PaReq' value='$paymentauth'>
            <input type='hidden' name='TermUrl' value='http://localhost/Test Stuff/Payments/pares.php'>
            <input type='hidden' name='MD' value='$mdcode'>
        </form>
        <SCRIPT LANGUAGE='Javascript' >
        <!--
        function OnLoadEvent()
        {
        document.mainform.submit();
        }
        //-->
        </SCRIPT>
        ";

  } else {

      echo "Fine";
  }
}

} 

?>

 

Any hints, tips or answers on this are much appreciated, As this is an ongoing issue that I'd love to solve. It appears the tech support I've receieved has been pretty poor.

Link to comment
Share on other sites

The problem is the explode using '='. When the data contains any = characters, you loose them. I recommend using parse_str The following should be equivalent to your code (replace the split() statement and the foreach(){} loop) -

 

<?php
$result = substr($result,1); // remove the first character '?'
parse_str($result, $result_arr); // break apart the string on any name=value pairs

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.