<?php


include("/home/centrepo/public_html/Sfa/BillToAddress.php");
include("/home/centrepo/public_html/Sfa/CardInfo.php");
include("/home/centrepo/public_html/Sfa/Merchant.php");
include("/home/centrepo/public_html/Sfa/MPIData.php");
include("/home/centrepo/public_html/Sfa/ShipToAddress.php");
include("/home/centrepo/public_html/Sfa/PGResponse.php");
include("/home/centrepo/public_html/Sfa/PostLibPHP.php");
include("/home/centrepo/public_html/Sfa/PGReserveData.php");

 $oMPI                 =         new         MPIData();

 $oCI                =        new        CardInfo();

 $oPostLibphp        =        new        PostLibPHP();

 $oMerchant        =        new        Merchant();

 $oBTA                =        new        BillToAddress();

 $oSTA                =        new        ShipToAddress();

 $oPGResp        =        new        PGResponse();

 $oPGReserveData = new PGReserveData();




 $oMerchant->setMerchantDetails("00011718","00011718","INDSOFT","193.545.34.33",rand()."","Ord123","http://www.test.com/SFAResponse.php","POST","INR","INV123","req.Sale","10.00","","Ext1","true","Ext3","Ext4","Ext5");

 $oBTA->setAddressDetails ("BOB","BOB","The Book Review Literary Trust","Customer name","Mobile No","E-mail ID","ABC","ABC","IND","ABC");

# $oSTA->setAddressDetails ("Original transaction amount","Add2","Add3","Add4","Add5","443543","IND","ABC"); 

$oSTA->setAddressDetails ("10.00","Add2","Add3","Add4","Add5","443543","IND","ABC");

 #$oMPI->setMPIRequestDetails("1000","INR10.00","356","2","","","","","0","","image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, application/x-shockwave-flash, */*","Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)");
 $oMPI->setMPIRequestDetails("1000","INR10.00","356","2","","","","","0","","image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, application/x-shockwave-flash, */*","Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)");

 $oPGReserveData->setReserveObj("1","2","3","4","5","6","7","8","9","10");

 $oPGResp=$oPostLibphp->postSSL($oBTA,$oSTA,$oMerchant,$oMPI,$oPGReserveData);


        if($oPGResp->getRespCode() == '000'){

                $url        =$oPGResp->getRedirectionUrl();
                #$url =~ s/http/https/;
                #print "Location: ".$url."\n\n";
                #header("Location: ".$url);
                redirect($url);



           }else{

                        print "Error Occured.<br>";
                        print "Error Code:".$oPGResp->getRespCode()."<br>";
                        print "Error Message:".$oPGResp->getRespMessage()."<br>";

         }


# This will remove all white space
#$oResp =~ s/\s*//g;

# $oPGResp->getResponse($oResp);

 #print $oPGResp->getRespCode()."<br>";

 #print $oPGResp->getRespMessage()."<br>";

 #print $oPGResp->getTxnId()."<br>";


 #print $oPGResp->getEpgTxnId()."<br>";




  function redirect($url) {

         if(headers_sent()) {

         ?>
         <html><head>
         <script language="javascript" type="text/javascript">

          window.self.location='<?php print($url);?>';

         </script>
         </head></html>
         <?php
         exit;

         } else {

         header("Location: ".$url);
         exit;

         }

 }




 ?>
