Jump to content

Problems retrieving variables from an online payment service


El_Guapo

Recommended Posts

Hi there a friend of mine with no programming experience has asked me to look at integrating a payment solution into a website he is working on, and as i am pretty new to PHP myself i thought i'd turn to the experts.

 

The customer is based in Norway and has chosen a Scadinavian based service called DIBS as their payment system of choice. The issue i am having is when the information is entered into a payment form (customer details such as name, address atc) and sent to DIBS i input test credit card details which is processed fine and i am sent back to a payment accepted screen of my own creation, but i can't get the values i submitted into the original form back from DIBS to display on this screen as a form of receipt.

 

Maybe i am over simplifying it somewhat, but i would of thought that all i needed to do to display these values (such as customer name, email etc) is to use $_REQUEST["input field name"].

 

The payment form is in a file called payment_form.php and the form itself looks like this:

 

<form name="payform" method="post" action="popup.php">
        <table width="529" border="0" cellpadding="0" cellspacing="1">
          <tr>
            <td colspan="2" class="style5">
              <input type="hidden" name="merchant" value="4258318" />
              <input type="hidden" name="orderid" value="LS2008" />
              <input type="hidden" name="lang" value="en" />
              <input type="hidden" name="test" value="yes" />
              <input type="hidden" name="popaction" value="PopUp"></td>
          </tr>
          
          <tr>
            <td width="111" class="style5">Amount</td>
          <td width="415">
            <input type="textbox" name="amount" value="1400000" />
            <span class="style5"> (14,000.00 NOK) </span></td>
          </tr>
          <tr>
            <td class="style5">
		<input type="hidden" name="currency" value="578" />
		<input type="hidden" name="accepturl" value="http://www.energyclaims.net/payment_accepted.php?popresult=accept&popaction=PopDown" /></td>
            <td class="style5">Please note: the last two last digits '00' are decimals</td>
            <input type="hidden" name="cancelurl" value="http://www.energyclaims.net/payment_cancelled.html" />
          </tr>
          <tr>
            <td colspan="2" class="style5"> </td>
          </tr>
          <tr>
            <td class="style5">Name of Attendee</td>
            <td>
              <input name="attendee" value="" size="40" /></td>
          </tr>
          <tr>
            <td class="style5">Company Name</td>
            <td>
              <input name="company" value="" size="40" /></td>
          </tr>
          <tr>
            <td class="style5">City</td>
            <td>
              <input name="city" value="" size="40" /></td>
          </tr>
          <tr>
            <td class="style5">Subject</td>
            <td>
              <input id="subject" name="subject" value="Lillehammer 2008" size="40" /></td>
          </tr>
          <tr>
            <td colspan="2">
              <input type="submit" value="Start Payment" /></td>
          </tr>
        </table>
</form>

 

 

The popup.php code is as follows (this is DIBs' own PHP script):

 

//Define site-specific variables here
$AcceptURL = "payment_accepted.php"; //Your original accepturl without parameters
$CancelURL = "payment_cancelled.html"; //Your original cancelurl without parameters
$ParentWindow = "payment_form.php"; //The name the window that opened the popup
//////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////
//This is the main script
//On the way to DIBS payment window
if ( $_REQUEST['popaction'] == "PopUp" ) {
  PopUp();
}

//On the way back from DIBS payment window
if ( $_REQUEST['popaction'] == "PopDown") {
  if ( $_REQUEST['popresult'] == "Accept" ) {
    PopDown($AcceptURL,$ParentWindow);
  }
  if ( $_REQUEST['popresult'] == "Cancel" ) {
    PopDown($CancelURL,$ParentWindow);
  }
}

function PopUp() {
  printf ("<html>");
  printf ("<body onload=\"document.DIBSForm.submit();\" >");
  printf ("<form method=\"post\" name=\"DIBSForm\" action=\"https://payment.architrade.com/payment/start.pml\">");
  while (list($key, $val) = each($_REQUEST)) {
    printf ("<input type=\"hidden\" name=\"%s\" value=\"%s\">",$key,$val);
  }
  printf ("</form>");
  printf ("</body></html>");
}

function PopDown($URL,$Window) {
  printf ("<html>");
  printf ("<body onload=\"document.ReturnFromDIBSForm.submit(); setTimeout('self.close()',250);\" >");
  printf ("<form method=\"post\" name=\"ReturnFromDIBSForm\" action=\"%s\" target=\"%s\" >",$URL,$Window);
  while (list($key, $val) = each($_REQUEST)) {
    printf ("<input type=\"hidden\" name=\"%s\" value=\"%s\">",$key,$val);
  }
  printf ("</form>");
  printf ("</body>");
  printf ("</html>");
}

?>

 

 

finally the payment accepted page code looks like this:

 

<p>Your card has been accepted and your payment is complete.</p>

      <p>Order ID: <?php echo $_REQUEST["orderid"]; ?></p>
      <p>Customer Name: <?php echo $_REQUEST["attendee"]; ?></p>
      <p>Company: <?php echo $_REQUEST["company"]; ?></p>
      <p>City: <?php echo $_REQUEST["city"]; ?></p>
      <p>Amount: <?php echo $_REQUEST["fee"]; ?></p>
      <p>Payment Type: <?php echo $_REQUEST["paytype"]; ?></p>
      <p>Currency: <?php echo $_REQUEST["currency"]; ?></p> 

 

None of the values from the original form are being returned here. Is it my bad PHP knowledge or something in DIBS that is causing these values to not be retrieved.

 

Many thanks in advance.

Generally you don't connect to payment gateways using the method you are attempting. On dibs website there is this link

 

http://www.dibs.dk/teknik/teknik/

 

This link has all the technical information you will need.  You are going to be using a secured socket connection.  Something like Curl or Fsockopen is going to be your answer.  What you have now will not work, nor be safe for your client or yourself.

Thanks for your reply, i've already had a look at the DIBs tech help and to be honest it is pretty dreadful, hence the reason i turned to you guys.

 

Setting the security concerns aside for a second, can you see why the $_REQUEST would not return the values passed into DIBS?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.