<?php require_once dirname(__FILE__) . "/../../common.inc.php"; include_once CFG_CACHEPATH . '/sys_pay.cache.php'; //支付配置文件 require_once dirname(__FILE__) . "/paypal_config.php"; $result = fsockPost($paypal[url], $_POST); //获取支付宝的反馈参数 $dingdan = $_REQUEST['invoice']; //获取订单号 $total_fee = trim($_REQUEST['mc_gross']); //获取总价格 $status = $_REQUEST['payment_status']; $receiver_email = trim($_REQUEST['receiver_email']); if (eregi("VERIFIED", $result)) { if (isset($paypal['business'])) { if (stristr($status, "Completed") == false) { log_result("succeed _{$status}\r\n"); return; } if (strcmp($paypal['business'], $receiver_email) != 0) { log_result("cheat _{$receiver_email}\r\n"); return; } //执行支付成功操作 include_once INC_PATH . "/recharge.class.php"; $rechargeobj = RechargeClass::init(); //收取手续费的规则 $total_fee = $total_fee * 0.96 - 0.3; $money = $rechargeobj->ratechange($total_fee, 'USD'); $rechargeobj->paysuccess($dingdan, $money);
<?php require_once dirname(dirname(dirname(__FILE__))) . '/app.php'; //$post_url = "https://www.sandbox.paypal.com/cgi-bin/webscr"; $post_url = "https://www.paypal.com/row/cgi-bin/webscr"; $result = fsockPost($post_url, $_POST); // assign posted variables to local variables $item_name = $_POST['item_name']; $item_number = $_POST['item_number']; $payment_status = $_POST['payment_status']; $payment_amount = $_POST['mc_gross']; $payment_currency = $_POST['mc_currency']; $txn_id = $_POST['txn_id']; $receiver_email = $_POST['receiver_email']; $payer_email = $_POST['payer_email']; if (eregi("VERIFIED", $result)) { $out_trade_no = $item_number; $total_fee = $payment_amount; @(list($_, $order_id, $city_id, $_) = explode('-', $out_trade_no, 4)); if ($_ == 'charge') { @(list($_, $user_id, $create_time, $_) = explode('-', $out_trade_no, 4)); ZFlow::CreateFromCharge($total_fee, $user_id, $create_time, 'paypal'); } else { $currency = $payment_currency; $service = 'paypal'; $bank = 'PayPal'; ZOrder::OnlineIt($order_id, $out_trade_no, $total_fee, $currency, $service, $bank); } } function fsockPost($url, $data) {
<?php // this page only process a POST from paypal website // so make sure that the one requesting this page comes // from paypal. we can do this by checking the remote address // the IP must begin with 66.135.197. if (strpos($_SERVER['REMOTE_ADDR'], '66.135.197.') === false) { exit; } require_once './paypal.inc.php'; // repost the variables we get to paypal site // for validation purpose $result = fsockPost($paypal['url'], $_POST); //check the ipn result received back from paypal if (eregi("VERIFIED", $result)) { require_once '../../library/config.php'; // check that the invoice has not been previously processed $sql = "SELECT od_status\r\n FROM tbl_order\r\n WHERE od_id = {$_POST['invoice']}"; $result = dbQuery($sql); // if no invoice with such number is found, exit if (dbNumRows($result) == 0) { exit; } else { $row = dbFetchAssoc($result); // process this order only if the status is still 'New' if ($row['od_status'] !== 'New') { exit; } else { // check that the buyer sent the right amount of money $sql = "SELECT SUM(pd_price * od_qty) AS subtotal\r\n FROM tbl_order_item oi, tbl_product p\r\n WHERE oi.od_id = {$_POST['invoice']} AND oi.pd_id = p.pd_id\r\n GROUP by oi.od_id"; $result = dbQuery($sql);
$dsp->AddBackButton("\" OnClick=\"javascript: refreshParent()"); $dsp->AddContent(); } else { $dsp->NewContent(t('Transaktionsfehler oder unerlaubter Zugriff')); $dsp->AddSmartyTpl('javascript', 'paypal'); $dsp->AddSingleRow("<font color=\"red\">" . t('Bitte melden sie sich beim einem Admin damit der die Zahlung prüfen kann.') . "</font>"); $dsp->AddDoubleRow(t('Vorname'), $_POST['first_name']); $dsp->AddDoubleRow(t('Nachname'), $_POST['last_name']); $dsp->AddDoubleRow(t('E-Mail'), $_POST['payer_email']); $dsp->AddDoubleRow(t('Zahlungsnummer'), $_POST['txn_id']); $dsp->AddDoubleRow(t('Zahlungsdatum'), $_POST['payment_date']); $dsp->AddBackButton("\" OnClick=\"javascript: refreshParent()"); $dsp->AddContent(); } break; case 5: $result = fsockPost($cfg['paypal_url'], $_POST); if (eregi("VERIFIED", $result)) { create_csv_file("ext_inc/paypal/ipn_success.txt.php", $_POST); } else { create_csv_file("ext_inc/paypal/ipn_error.txt.php", $_POST); } break; case 10: $dsp->NewContent(t('Fehler')); $dsp->AddSingleRow(t('Die Transaktion konnte nicht durchgeführt werden.')); $dsp->AddBackButton("\" OnClick=\"javascript: refreshParent()"); $dsp->AddContent(); break; } echo $smarty->fetch('modules/paypal/templates/sendbox.htm');
function main() { //get global configuration information // Debugging. If you want to trace through what happens, // turn this on here. THen turn on the "file_put_contents" at // the bottom of the method. $log = SysLogOpen('IPN'); sysLogEntry($log, 'Began work in x_paypalipn, next entry is $_POST'); # KFD 10/1/08, add more logging. Project CME occassionally # misses the trx, we want more logging. ob_start(); hprint_r($_POST); sysLogEntry($log, ob_get_clean()); sysLogEntry($log, 'Invoice ' . a($_POST, 'invoice', '')); global $paypal; include_once 'paypal_global_config.inc.php'; //get pay pal configuration file include_once 'paypal_config.inc.php'; //decide which post method to use sysLogEntry($log, 'Paypal postmethod is ' . $paypal['post_method']); switch ($paypal['post_method']) { case "libCurl": //php compiled with libCurl support $result = libCurlPost($paypal['url'], $_POST); break; case "curl": //cURL via command line $result = curlPost($paypal['url'], $_POST); break; case "fso": //php fsockopen(); $result = fsockPost($paypal['url'], $_POST); break; default: //use the fsockopen method as default post method $result = fsockPost($paypal['url'], $_POST); break; } sysLogEntry($log, "Next log entry is postback result"); sysLogEntry($log, $result); //check the ipn result received back from paypal if (eregi("VERIFIED", $result)) { sysLogEntry($log, "Verified, continuing"); if (function_exists('paypal_ipn_success')) { sysLogEntry($log, "Calling function paypal_ipn_success"); paypal_ipn_success($log); } else { sysLogEntry($log, "ERROR, function paypal_ipn_success does not exist"); } } else { sysLogEntry($log, "Not verified, no further action"); if (function_exists('paypal_ipn_cancel')) { sysLogEntry($log, "Calling function paypal_ipn_cancel"); paypal_ipn_cancel($log); } else { sysLogEntry($log, "Function paypal_ipn_cancel does not exist"); } } syslogEntry($log, 'end of processing'); sysLogClose($log); }