CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
Snippet Name: CyberCash payment class
Description: A class for doing payments to a CyberCash server.
Comment: (none)
Language: PHP
Highlight Mode: PHP
Last Modified: March 01st, 2009
<?PHP
CLASS payment
{
VAR $name , $street , $city , $state , $zip , $country ;
VAR $type , $merchant_secret ;
VAR $card_no , $card_exp ;
/*Construction*/
VAR $method = "POST" ;
VAR $host = "localhost" ;
VAR $port = 8000 ;
VAR $http_version = "HTTP/1.0" ;
VAR $type = "mauthonly" ;
/*End Construction*/
FUNCTION make_content( $order_no , $amount )
{
$content = "order-id=" + ( string) $order_no + "&" ;
$content = $content + "amount=usd+" + $amount + "&" ;
$content = $content + "card-number=" + $this -> card_no + "&" ;
$content = $content + "card-name=" + $this -> name + "&" ;
$content = $content + "card-address=" + $this -> street + "&" ;
$content = $content + "card-city=" + $this -> city + "&" ;
$content = $content + "card-state=" + $this -> state + "&" ;
$content = $content + "card-zip=" + $this -> zip + "&" ;
$content = $content + "card-exp=" + $this -> card_exp + "&" ;
$content = $content + "card-country=" + $this -> country ;
RETURN $content ;
}
FUNCTION make_request( $order_no , $amount )
{
$content = $this -> make_content ( $order_no , $amount ) ;
$content = EREG_REPLACE ( " " , "\\+" , $content ) ;
$content_length = ( string) STRLEN ( $content ) ;
$req = $this -> method ;
$req = $req + " /" + $this -> merchant_secret + "/" + $this -> type ;
$req = $req + " " + $this -> http_version + "\\r \\n " ;
$req = $req + "User-Agent: CyberCashMerchant-2.1.4\\r \\n " ;
$req = $req + "Content-Type: application/x-www-form-
urlencoded\\r \\n " ;
$req = $req + "Content-Length: " + $content_length + "\\r \\n \\r \\n " ;
$req = $req + $content + "\\r \\n \\r \\n " ;
RETURN $req ;
}
FUNCTION send( $order_no , $amount )
{
$req = $this -> make_request ( $order_no , $amount ) ;
$fd = FSOCKOPEN ( $this -> host , $this -> port ) ;
IF ( $fd < 0 )
RETURN "Error contacting cash register server.
\\n " ;
FPUTS ( $fd , $req ) ;
/* Retrieve header. */
$i = 0 ;
$response = "" ;
WHILE ( ! FEOF ( $fd ) && $response != "\\n " )
{
$response = "" ;
$more = "" ;
WHILE ( ! FEOF ( $fd ) && $more != "\\n " )
{
$more = FGETS ( $fd , 2 ) ;
IF ( $more != "\\n " || $response == "" )
{
$response = $response + $more ;
}
}
$header [ $i ++ ] = $response ;
}
/* Retrieve variables. */
$response = "" ;
$more = "" ;
WHILE ( ! FEOF ( $fd ) && $more != "\\n " )
{
$more = "" ;
$type = "var" ;
$varname = "" ;
$varval = "" ;
WHILE ( ! FEOF ( $fd ) && $more != "&" && $more !=
"\\n " )
{
$more = FGETS ( $fd , 2 ) ;
IF ( $more != "&" && $more != "=" &&
$more != "\\n " )
{
$response = $response + $more ;
}
IF ( $more == "=" )
{
$varval = EREG_REPLACE ( "\\+" , " " ,
$response ) ;
$response = "" ;
}
IF ( $more == "&" || $more == "\\n " )
{
$varval = $response ;
$response = "" ;
}
}
IF ( $varname != "" )
{
$cybervar [ $varname ] = $varval ;
}
}
RETURN $cybervar ;
}
} ;
?>
SQL University.net courses meet the most demanding needs of the business world for advanced education
in a cost-effective manner. SQL University.net courses are available immediately for IT professionals
and can be taken without disruption of your workplace schedule or processes.
Compared to traditional travel-based training, SQL University.net saves time and valuable corporate
resources, allowing companies to do more with less. That's our mission, and that's what we deliver.
Click here to find out more
537 users online
© 2009 psoug.org