0
 <?php
    extract($_POST);
    if (isset($price)){
    $xml = "<?xml version='1.0' encoding='UTF-8'?>
    <TKKPG>
    <Request>
    <Operation>CreateOrder</Operation>
    <Language>EN</Language>
    <Order>
    <Merchant>WAYTELL</Merchant>
    <Amount>".$amt."</Amount>
    <Currency>566</Currency>
    <Description>".$prot."</Description>
    <ApproveURL>http://localhost/integration/approved.php</ApproveURL>
    <CancelURL>http://localhost/integration/declined.php</CancelURL>
    <DeclineURL>http://localhost/integration/declined.php</DeclineURL>
    </Order>
    </Request>
    </TKKPG>";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,"https://196.46.20.36:5443/Exec");
    curl_setopt($ch, CURLOPT_SSLVERSION, 3);
    curl_setopt($ch, CURLOPT_VERBOSE, '1');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
    curl_setopt($ch, CURLOPT_TIMEOUT, 5000);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_CAINFO, getcwd().'/cert/CAcert.crt');
    curl_setopt($ch, CURLOPT_SSLCERT, getcwd().'/cert/waytell.pem');
    curl_setopt($ch, CURLOPT_SSLKEY, getcwd().'/cert/waytell.key');
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
    curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
    $response = curl_exec($ch);
    if(!(curl_errno($ch)>0)){
    $parsedxml = simplexml_load_string($response);
    foreach($parsedxml->children() as $RESPONSENODE)
    {
    foreach($RESPONSENODE->children() as $ORDERNODE)
    {
    foreach($ORDERNODE->children() as $child)
    {
    if ($child->getName() == "OrderID")
    $orderid = $child;
    if ($child->getName() == "SessionID")
    $sessionid = $child;
    if ($child->getName() == "URL")
    $url = $child;
    }
    }
    }//end all loop
    $gateway_url = $url."?ORDERID=".$orderid."&SESSIONID=".$sessionid;

    header("location: ".$gateway_url);
    }
    }
    ?>

Can someone help me out

3
Contributors
22
Replies
47
Views
3 Years
Discussion Span
Last Post by Man Event
0

Is this your code?
You need to provide proper indenting - this is difficult to read. Please re-post having indented the code properly.

0

<?php

    extract($_POST);


if (isset($amt)){


    $xml = "<?xml version='1.0' encoding='UTF-8'?>
            <TKKPG>
            <Request>
            <Operation>CreateOrder</Operation>
            <Language>EN</Language>
            <Order>
            <Merchant>WAYTELL</Merchant>
            <Amount>".$amt."</Amount>
            <Currency>566</Currency>
            <Description>".$prod."</Description>
            <ApproveURL>http://localhost/integration/approved.php</ApproveURL>
            <CancelURL>http://localhost/integration/declined.php</CancelURL>
            <DeclineURL>http://localhost/integration/declined.php</DeclineURL>
            </Order>
            </Request>
            </TKKPG>";

    $ch = curl_init(); 
    curl_setopt($ch, CURLOPT_URL,"https://196.46.20.36:5443/Exec"); 
    curl_setopt($ch, CURLOPT_SSLVERSION, 3);
    curl_setopt($ch, CURLOPT_VERBOSE, '1');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
    curl_setopt($ch, CURLOPT_TIMEOUT, 5000);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
    curl_setopt($ch, CURLOPT_CAINFO,  getcwd().'/cert/CAcert.crt');
    curl_setopt($ch, CURLOPT_SSLCERT, getcwd().'/cert/waytell.pem');
    curl_setopt($ch, CURLOPT_SSLKEY, getcwd().'/cert/waytell.key');
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
    curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);

    $response = curl_exec($ch); 

    if(!(curl_errno($ch)>0)){

        $parsedxml = simplexml_load_string($response);

        foreach($parsedxml->children() as $RESPONSENODE)
        {   
            foreach($RESPONSENODE->children() as $ORDERNODE)
            {
                foreach($ORDERNODE->children() as $child)
                {   
                    if ($child->getName() == "OrderID")
                        $orderid = $child;

                    if ($child->getName() == "SessionID")
                        $sessionid = $child;

                    if ($child->getName() == "URL")
                        $url = $child;  
                }
            }   
         }//end all loop

                 $gateway_url = $url."?ORDERID=".$orderid."&SESSIONID=".$sessionid;

                 echo "<iframe src='$gateway_url' style='border:none;' name='manframe' scrolling='no' frameborder='0' marginheight='0' marginwidth='0' height='60px' width='468px'></iframe>";

                 header("location: ".$gateway_url);

}
}

?>

1

I did a little ammendment on the code. This is the most recent.

Votes + Comments
://tinychat.com/js/embed.js
0

You don't say what the issue is with it.

1

the same as this post this post

See that you didn't change to

if ($child->getName() == "URL")
$url = (string) $child; 

have you done a var_dump('$gateway_url'); yet?
post the result

0

This thread seem to be a continuation of a previous one as outlined by pzuurveen. Please keep it organized. AFAIK, the other thread is still active so there doesn't seem to be a need to start a new one. It's getting messy.

0

OK, can you work with me on the other thread? I want you to be involved. I really need help.

0

let me stop the other thread and continue with this one. I prefer it where you and veen are on it. I am stopping the other thread, sorry for the confusion.

0
if ($child->getName() == "URL")
$url = (string) $child; 

Veen, I have corrected it in the main code. Do you want to reflect on the one pasted on the thread.
0

fisfol, sorry for the mess up. How do i stop the other thread. I think prefer to continue with this one.

0

diafol, sorry for the mess up. How do i stop the other thread. I think i prefer to continue with this one.

0

veen, when i include

var_dump('$gateway_url');

And ran the code, there is no output. is anything i am missing?

0

ok
look like if(!(curl_errno($ch)>0)){ is false
That means you have an error in your curl part.
so add an else echo curl_error($ch); between line 69 and 70

p.s. my name is Zuurveen, not veen

Edited by pzuurveen

0

I got a message:

couldn't connect to host

a moment, let me check on something. I quite appreciate your effort Zuurveen.

0

When i ran the code, I could connect to the gateway but the value for amt changed. Is there anyway I can handle this

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.