<?php /* *功能:付款过程中服务器通知页面 *版本:2.0 *日期:2008-08-01 '说明: '以下代码只是方便商户测试,提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 '该代码仅供学习和研究支付宝接口使用,只是提供一个参考。 */ require_once "classes/alipay_notify.php"; empty($_POST) && ($_POST =& $_GET); require_once dirname(dirname(__FILE__)) . '/pay_base.php'; $pay = new pay_base('alipay'); $pay->by = 'orders'; $pay->order_sn = $_GET['out_trade_no']; if (!$pay->getData()) { //log_result ("order_failed"); exit("fail"); } $alipay = new alipay_notify($pay->partner, $pay->keyt, 'MD5', $mcharset, 'http'); $verify_result = $alipay->notify_verify(); if ($verify_result) { //认证合格 //获取支付宝的反馈参数 $dingdan = $_POST['out_trade_no']; //获取支付宝传递过来的订单号 $total = $_POST['total_fee']; //获取支付宝传递过来的总价格 /* $receive_name =$_POST['receive_name']; //获取收货人姓名
# echo "<input type=\"hidden\" name=\"paynew[handfee]\" value=\"$paynew[handfee]\">\n"; # echo "<input type=\"hidden\" name=\"paynew[total]\" value=\"$paynew[total]\">\n"; echo "<input type=\"hidden\" name=\"paynew[truename]\" value=\"{$paynew['truename']}\">\n"; echo "<input type=\"hidden\" name=\"paynew[telephone]\" value=\"{$paynew['telephone']}\">\n"; echo "<input type=\"hidden\" name=\"paynew[email]\" value=\"{$paynew['email']}\">\n"; tabfooter('submit', lang('confirm_pay')); } elseif ($deal == 'send') { array_key_exists($paynew['poid'], $poids) || mcmessage('errorpaymode', '?action=payonline'); do { $ordersn = date("YmdHis") . random(6, 1); } while ($db->fetch_one("SELECT pid FROM {$tblprefix}pays WHERE ordersn='{$ordersn}' LIMIT 0,1")); $db->query("INSERT INTO {$tblprefix}pays SET\n\t\t\t\t mid='" . $curuser->info['mid'] . "', \n\t\t\t\t mname='" . $curuser->info['mname'] . "', \n\t\t\t\t ordersn='{$ordersn}',\n\t\t\t\t pmode='1',\n\t\t\t\t poid='{$paynew['poid']}',\n\t\t\t\t amount='{$paynew['amount']}',\n\t\t\t\t handfee=0,\n\t\t\t\t truename='{$paynew['truename']}',\n\t\t\t\t telephone='{$paynew['telephone']}',\n\t\t\t\t email='{$paynew['email']}',\n\t\t\t\t senddate='{$timestamp}',\n\t\t\t\t ip='{$onlineip}'\n\t\t\t\t "); if ($pid = $db->insert_id()) { require_once M_ROOT . 'paygate/pay_base.php'; $poid = $pays[$paynew['poid']]; $pay = new pay_base($paynew['poid']); $pay->account = $poid[0]; $pay->keyt = $poid[1]; $paynew['poid'] == 'alipay' && ($pay->partner = $poid[2]); $pay->by = 'pays'; $pay->dataok = 1; $pay->order_id = $pid; $pay->status = 0; $pay->totalfee = $paynew['amount']; $pay->send($ordersn, lang('account_plaza', $hostname), ''); } else { mcmessage('systemerror'); } } elseif ($deal == 'receive') { empty($pid) && mcmessage('confirmchoosepays'); if (!($item = $db->fetch_one("SELECT * FROM {$tblprefix}pays WHERE pid={$pid}"))) {
require_once M_ROOT . 'paygate/pay_base.php'; switch ($ordernew['paymode']) { //各种付款方式 case 2: //支付宝 if (!in_array('', $pays[2])) { $pay = new pay_base('alipay'); $pay->account = $pays[2][0]; $pay->partner = $pays[2][1]; $pay->keyt = $pays[2][2]; } break; case 3: //财付通 if (!in_array('', $pays[3])) { $pay = new pay_base('tenpay'); $pay->account = $pays[3][0]; $pay->keyt = $pays[3][1]; } break; } if (empty($pay)) { mcmessage('errorpaymode'); } else { $query = $db->query("SELECT subject FROM {$tblprefix}purchases p LEFT JOIN {$tblprefix}archives a ON a.aid=p.aid WHERE oid='{$oid}' LIMIT 0,2"); $count = $db->num_rows($query); $row = $db->fetch_array($query); $subject = $count > 1 ? lang('and_more', $row['subject']) : $row['subject']; $pay->by = 'orders'; $pay->dataok = 1; $pay->order_id = $order['oid'];
<?php //--------------------------------------------------------- //财付通中介担保支付应答(处理回调)示例,商户按照此文档进行开发即可 //--------------------------------------------------------- require_once 'classes/PayResponseHandler.class.php'; /* 创建支付应答对象 */ $resHandler = new PayResponseHandler(); require_once '../pay_base.php'; $pay = new pay_base('tenpay'); $pay->by = 'pays'; $pay->order_sn = $resHandler->getParameter("attach"); if (!$pay->getData()) { echo "<br/>非法请求<br/>"; exit; } $resHandler->setKey($pay->keyt); //判断签名 if ($resHandler->isTenpaySign()) { //交易单号 $transaction_id = $resHandler->getParameter("transaction_id"); //金额,以分为单位 $total_fee = intval($resHandler->getParameter("total_fee")) / 100; //支付结果 $pay_result = $resHandler->getParameter("pay_result"); if ("0" == $pay_result) { //------------------------------ //处理业务开始 //------------------------------ //注意交易单不要重复处理 //注意判断返回金额