Solved

Interswitch Connection

Posted on 2014-01-28
2
297 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 108

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 108

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Often people are aiming at development of perfect Magento websites. Though, it is easier said than done. You know what’s much easier? To ruin everything. It can be done in seconds. Many of us experimented with design, tried to change some values dir…
Read about how to choose the best possible content marketing agency to suit your needs. Content marketing has become an integral part of running a successful tech business, so it is wise to be informed.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now