我还不知道怎么添加按月付款的功能。如何做?
代码:
<?
######################################################################
# PHP-NUKE: Web Portal System
######################################################################
#
# Copyright (c) 2000 by Francisco Burzi (fbc@mandrakesoft.com)
# http://phpnuke.org/
#
######################################################################
# Emporium
######################################################################
#
# Copyright (c) 2002 by Michael Squires (msquires@burnwave.com)
# http://www.burnwave.com/ || http://www.nukescripts.com
#
######################################################################
function cartOrderTableBottom($orderID){
global $prefix, $dbi, $cartconfig;
OpenTable();
echo "
Click on the following button to pay through PayPal (Credit Cards Accepted).
";
$result = sql_query("SELECT ppemail, ipn, currency FROM ".$prefix."_cart_payments_options_paypal", $dbi);
list($ppemail, $ppipn, $ppcurrency) = sql_fetch_row($result, $dbi);
$orderInfo = cartorderinfo($orderID);
$item_name = paypal_formgen_format("$cartconfig[companyName] --- Order #$orderID");
$grandTotal = sprintf("%01.2f", $orderInfo[GrandTotal]);
echo "\n\n
\n\n";
CloseTable();
}
function paypal_formgen_format($string){
$string = ereg_replace('&', '&', $string);
$string = ereg_replace('"', '"', $string);
$string = ereg_replace('<', '<', $string);
$string = ereg_replace('>', '>', $string);
return $string;
}
function formatPaymentString($string){
$string = eregi_replace(";", "%3B", $string);
return $string;
}
function reformatPaymentString($string){
$string = eregi_replace("%3B", ";", $string);
return $string;
}
###################
# PayPal IPN
###################
function cartCallback(){
global $prefix, $dbi, $testcode, $HTTP_POST_VARS;
if($testcode==1){ die("Success! IPN is set up correctly!"); }
$result = sql_query("SELECT ppemail, ipn, currency from ".$prefix."_cart_payments_options_paypal", $dbi);
list($ppemail, $ipn, $currency) = sql_fetch_row($result, $dbi);
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
foreach ($HTTP_POST_VARS as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
// post back to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= 'Content-Length: ' . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);
//post back to eliteweaver.co.uk, can be used for testing NSNCart IPN
#$header .= "POST /testing/ipntest.php HTTP/1.0\r\n";
#$header .= "Host: www.eliteweaver.co.uk\r\n"; // Host on Shared IP
#$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
#$header .= "Content-Length: " . strlen ($req) . "\r\n\r\n";
#$fp = fsockopen ("www.eliteweaver.co.uk", 80, $errno, $errstr, 30);
// assign posted variables to local variables
// note: additional IPN variables also available -- see IPN documentation
$receiver_email = $HTTP_POST_VARS['receiver_email'];
$item_name = $HTTP_POST_VARS['item_name'];
$item_number = $HTTP_POST_VARS['item_number'];
$quantity = $HTTP_POST_VARS['quantity'];
$invoice = $HTTP_POST_VARS['invoice'];
$custom = $HTTP_POST_VARS['custom'];
$option_name1 = $HTTP_POST_VARS['option_name1'];
$option_selection1 = $HTTP_POST_VARS['option_selection1'];
$option_name2 = $HTTP_POST_VARS['option_name2'];
$option_selection2 = $HTTP_POST_VARS['option_selection2'];
$num_cart_items = $HTTP_POST_VARS['num_cart_items'];
$payment_status = $HTTP_POST_VARS['payment_status'];
$pending_reason = $HTTP_POST_VARS['pending_reason'];
$payment_date = $HTTP_POST_VARS['payment_date'];
$settle_amount = $HTTP_POST_VARS['settle_amount'];
$settle_currency = $HTTP_POST_VARS['settle_currency'];
$exchange_rate = $HTTP_POST_VARS['exchange_rate'];
$payment_gross = $HTTP_POST_VARS['payment_gross'];
$payment_fee = $HTTP_POST_VARS['payment_fee'];
$mc_gross = $HTTP_POST_VARS['mc_gross'];
$mc_fee = $HTTP_POST_VARS['mc_fee'];
$mc_currency = $HTTP_POST_VARS['mc_currency'];
$txn_id = $HTTP_POST_VARS['txn_id'];
$txn_type = $HTTP_POST_VARS['txn_type'];
$first_name = $HTTP_POST_VARS['first_name'];
$last_name = $HTTP_POST_VARS['last_name'];
$address_street = $HTTP_POST_VARS['address_street'];
$address_city = $HTTP_POST_VARS['address_city'];
$address_state = $HTTP_POST_VARS['address_state'];
$address_zip = $HTTP_POST_VARS['address_zip'];
$address_country = $HTTP_POST_VARS['address_country'];
$address_status = $HTTP_POST_VARS['address_status'];
$payer_email = $HTTP_POST_VARS['payer_email'];
$payer_id = $HTTP_POST_VARS['payer_id'];
$payer_status = $HTTP_POST_VARS['payer_status'];
$payment_type = $HTTP_POST_VARS['payment_type'];
$notify_version = $HTTP_POST_VARS['notify_version'];
$verify_sign = $HTTP_POST_VARS['verify_sign'];
$xpayer_email = formatPaymentString($payer_email);
$xtxn_id = formatPaymentString($txn_id);
$xtxn_type = formatPaymentString($txn_type);
$xpayment_type = formatPaymentString($payment_type);
$xpayment_status = formatPaymentString($payment_status);
$xpending_reason = formatPaymentString($pending_reason);
$paypal_order_data = "$xpayer_email;$xtxn_id;$xtxn_type;$xpayment_type;$xpayment_status;$xpending_reason";
########################
# Start IPN Validator
########################
if (!$fp) {
echo "Problem!
Error Number: $errno
Error String: $errstr";
exit;
} else {
fputs($fp, $header . $req);
while(!feof($fp)) {
$res = fgets($fp, 1024);
$res = trim($res);
if (strcmp($res, "VERIFIED") == 0) {
if($receiver_email == $ppemail){
if($custom == "emporium"){
if($payment_status == "Completed"){
$order_select = sql_num_rows(sql_query("SELECT * from $prefix"._cart_orders." WHERE orderID='$invoice'", $dbi), $dbi);
if($order_select == 1){
$orderInfo = cartorderinfo($invoice);
$grandTotal = $orderInfo[GrandTotal];
if($payment_gross == $grandTotal){
sql_query("UPDATE $prefix"._cart_orders." SET payMethodData='$paypal_order_data' WHERE orderID='$invoice'", $dbi);
}
}
}
}
}
} else if (strcmp($res, "INVALID") == 0) {
// Uh-oh. Hacker?
}
}
fclose($fp);
}
}
?>