[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Interswitch Connection

Posted on 2014-01-28
2
Medium Priority
?
309 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 111

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 111

Accepted Solution

by:
Ray Paseur earned 2000 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying 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

In this article, I’ll talk about multi-threaded slave statistics printed in MySQL error log file.
WooCommerce is becoming the most powerful e-commerce plugin for Wordpress. And why not. The platform comprises of numerous core plugins that may come in handy, powerful options to make your website development task much easier.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
Suggested Courses

656 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