示例#1
0
# transactions. Any of the included LinkPoint XML sample files could be
# passed in as an XML string here.
#
# Copyright 2003 LinkPoint International, Inc. All Rights Reserved.
#
# This software is the proprietary information of LinkPoint International, Inc.
# Use is subject to license terms.
# If the library is at loaded at startup in PHP.INI, we don't need this call
dl("liblphp.so");
$xml = "\n    <order>\n        <orderoptions>\n            <result>GOOD</result>\n            <ordertype>SALE</ordertype>\n        </orderoptions>\n        <merchantinfo>\n            <configfile>123456</configfile> <!-- CHANGE THIS TO YOUR STORE NUMBER -->\n        </merchantinfo>\n        <creditcard>\n            <cardnumber>4111111111111111</cardnumber>\n            <cardexpmonth>12</cardexpmonth>\n            <cardexpyear>08</cardexpyear> \n        </creditcard>\n        <payment>\n            <chargetotal>1.03</chargetotal>\n        </payment>\n    </order>";
$cert = "./123456.pem";
# change this to the name and location of your certificate file
$host = "secure.linkpt.net";
$port = 1129;
// send transaction to liblphp.so
$retstg = send_stg($xml, $cert, $host, $port);
# look at the xml that comes back
print "response:  {$retstg}\n\n";
if (strlen($retstg) < 2) {
    $retstg = "<r_error>Could not execute curl.</r_error>";
}
# Process the XML from here
# Or OPTIONALLY - you could convert XML to a readable array
preg_match_all("/<(.*?)>(.*?)\\</", $retstg, $outarr, PREG_SET_ORDER);
$n = 0;
while (isset($outarr[$n])) {
    $retarr[$outarr[$n][1]] = strip_tags($outarr[$n][0]);
    $n++;
}
# and then look at it like this
while (list($key, $value) = each($retarr)) {
示例#2
0
 function process($data)
 {
     $using_xml = 0;
     $webspace = 1;
     if (isset($data["webspace"])) {
         if ($data["webspace"] == "false") {
             // if explicitly set to false, don't use html output
             $webspace = 0;
         }
     }
     if (isset($data["debugging"]) || isset($data["debug"])) {
         if ($data["debugging"] == "true" || $data["debug"] == "true") {
             $this->debugging = 1;
             # print out incoming hash
             if ($webspace) {
                 echo "at process, incoming data: <br>";
                 while (list($key, $value) = each($data)) {
                     echo htmlspecialchars($key) . " = " . htmlspecialchars($value) . "<BR>\n";
                 }
             } else {
                 // don't use html output
                 echo "at process, incoming data: \n";
                 while (list($key, $value) = each($data)) {
                     echo "{$key} = {$value}\n";
                 }
             }
             reset($data);
         }
     }
     if (isset($data["xml"])) {
         $using_xml = 1;
         $xml = $data["xml"];
     } else {
         //  otherwise convert incoming hash to XML string
         $xml = $this->buildXML($data);
     }
     // then set up transaction variables
     $key = $data["keyfile"];
     $host = $data["host"];
     $port = $data["port"];
     # FOR PERFORMANCE, Use the 'extensions' statement in your php.ini to load
     # this library at PHP startup, then comment out the next seven lines
     // load library
     if (!extension_loaded('liblphp')) {
         if (!dl('liblphp.so')) {
             exit("cannot load liblphp.so, bye\n");
         }
     }
     if ($this->debugging) {
         if ($webspace) {
             echo "<br>sending xml string:<br>" . htmlspecialchars($xml) . "<br><br>";
         } else {
             echo "\nsending xml string:\n{$xml}\n\n";
         }
     }
     // send transaction to LSGS
     $retstg = send_stg($xml, $key, $host, $port);
     if (strlen($retstg) < 4) {
         exit("cannot connect to lsgs, exiting");
     }
     if ($this->debugging) {
         if ($this->webspace) {
             // we're web space
             echo "<br>server responds:<br>" . htmlspecialchars($retstg) . "<br><br>";
         } else {
             // not html output
             echo "\nserver responds:\n {$retstg}\n\n";
         }
     }
     if ($using_xml != 1) {
         // convert xml response back to hash
         $retarr = $this->decodeXML($retstg);
         // and send it back to caller
         return $retarr;
     } else {
         // send server response back
         return $retstg;
     }
 }
示例#3
0
 public function process($data)
 {
     $using_xml = 0;
     $webspace = 1;
     if (isset($data['webspace'])) {
         if ($data['webspace'] == "false") {
             $webspace = 0;
         }
     }
     if (isset($data['debugging']) || isset($data['debug'])) {
         if ($data['debugging'] == "true" || $data['debug'] == "true") {
             $this->debugging = 1;
             if ($webspace) {
                 echo "at process, incoming data: <br>";
                 while (list($key, $value) = each($data)) {
                     echo htmlspecialchars($key) . " = " . htmlspecialchars($value) . "<BR>\n";
                 }
             } else {
                 echo "at process, incoming data:\n";
                 while (list($key, $value) = each($data)) {
                     echo "" . $key . " = " . $value . "\r\n";
                 }
             }
             reset($data);
         }
     }
     if (isset($data['xml'])) {
         $using_xml = 1;
         $xml = $data['xml'];
     } else {
         $xml = $this->buildXML($data);
     }
     $key = $data['keyfile'];
     $host = $data['host'];
     $port = $data['port'];
     if (!extension_loaded("liblphp")) {
         if (!dl("liblphp.so")) {
             exit("cannot load liblphp.so, bye\n");
         }
     }
     if ($this->debugging) {
         if ($webspace) {
             echo "<br>sending xml string:<br>" . htmlspecialchars($xml) . "<br><br>";
         } else {
             echo "\nsending xml string:\n" . $xml . "\r\n" . "\r\n";
         }
     }
     $retstg = send_stg($xml, $key, $host, $port);
     if (strlen($retstg) < 4) {
         exit("cannot connect to lsgs, exiting");
     }
     if ($this->debugging) {
         if ($this->webspace) {
             echo "<br>server responds:<br>" . htmlspecialchars($retstg) . "<br><br>";
         } else {
             echo "\nserver responds:\n " . $retstg . "\r\n" . "\r\n";
         }
     }
     if ($using_xml != 1) {
         $retarr = $this->decodeXML($retstg);
         return $retarr;
     }
     return $retstg;
 }