Solved

Interswitch Connection

Posted on 2014-01-28
2
304 Views
Last Modified: 2014-03-19
Dear Experts, Am a newbie to integrating website to payment gateways. Please help with necessary guide.

1. The payment gateway would send my server an HTTP request in the format provided below:
(See Page1.Txt)

My server is to reply with xml format provided in Page2.Txt

Can anyone please help with a code.

I saw this code on the net but could not make much out of it

$raw_post_data = file_get_contents('php://input');
$raw_post_array = explode('&', $raw_post_data);
$myPost = array();
foreach ($raw_post_array as $keyval) {
      $keyval = explode ('=', $keyval);
      if (count($keyval) == 2)
            $myPost[$keyval[0]] = urldecode($keyval[1]);
}
Page1.txt
Page2.txt
0
Comment
Question by:ukconcepts
  • 2
2 Comments
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 39816010
In PHP, XML processing is usually done with the SimpleXML class.  Get rid of that code you found on the net - it's either useless or flatly wrong.  Please contact the payment gateway and ask them what request method they use to send the XML.  It's probably POST, but we want to verify that before you go too far.

I'll try to show you how to use SimpleXML to parse Page1.txt
0
 
LVL 109

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 39816028
Please see http://www.laprbass.com/RAY_temp_ukconcepts.php

Look at the HEREDOC definition very carefully.  What was posted in Page1.txt is not valid XML.  Several changes were necessary to even get it to create an object!

<?php // RAY_temp_ukconcepts.php
error_reporting(E_ALLL);
echo '<pre>';

$xml = <<<EOD
<?xml version="1.0" encoding="utf-8" ?>
<CustomerInformationRequest>
<MerchantReference>126</MerchantReference>
<CustReference>0123</CustReference>
<PaymentItemCategoryCode>628051043</PaymentItemCategoryCode>
<PaymentItemCode>6280510431000</PaymentItemCode>
<RequestReference>0000000001</RequestReference>
<TerminalId>31WP0001</TerminalId>
<Amount>31WP0001</Amount>
<ServiceUsername></ServiceUsername>
<ServicePassword></ServicePassword>
<FtpUsername></FtpUsername>
<FtpPassword></FtpPassword>
</CustomerInformationRequest>
EOD;

$obj = SimpleXML_Load_String($xml);
var_dump($obj);

Open in new window

How experienced are you with PHP and object-oriented programming?
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
How important is it to take extra precautions to protect your online business? These are some steps you can take to make sure you're free of any cyber crime.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question