Solved

Interswitch Connection

Posted on 2014-01-28
2
307 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 110

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 110

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 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