<?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

Member Avatar for diafol

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

<?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);

}
}

?>

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

Member Avatar for diafol

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

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

Member Avatar for diafol

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.

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

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.

How do i stop the other thread?

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.

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

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

Member Avatar for diafol

Done.

Thanks diafol.

veen, when i include

var_dump('$gateway_url');

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

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

ok Zuurveen

I got a message:

couldn't connect to host

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

Hi
I am back

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

I have corrected the problem for the amt. thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.