public function callback() { require_once APP_ROOT_PATH . 'system/api_login/alipay/alipay_notify.php'; es_session::start(); //构造通知函数信息 $alipay = new alipay_notify($this->api['config']['app_key'], $this->api['config']['app_secret'], "MD5", "utf-8", "http"); //计算得出通知验证结果 $verify_result = $alipay->return_verify(); if ($verify_result) { //验证成功 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //请在这里加上商户的业务逻辑程序代码 //——请根据您的业务逻辑来编写程序(以下代码仅作参考)—— //获取支付宝的通知返回参数 $user_id = $_GET['user_id']; //获取支付宝用户唯一ID号 //判断获取到的user_id的值是否在商户会员数据库中存在(即:是否曾经做过支付宝会员免注册登陆) // 若不存在,则程序自动为会员快速注册一个会员,把信息插入商户网站会员数据表中, // 且把该会员的在商户网站上的登录状态,更改成“已登录”状态。并记录在商家网站会员数据表中记录登陆信息,如登陆时间、次数、IP等。 // 若存在,判断该会员在商户网站上的登录状态是否是“已登录”状态 // 若不是,则把该会员的在商户网站上的登录状态,更改成“已登录”状态。并记录在商家网站会员数据表中记录登陆信息,如登陆时间、次数、IP等。 // 若是,则不做任何数据库业务逻辑处理。判定该次反馈信息为重复刷新返回链接导致。 //——请根据您的业务逻辑来编写程序(以上代码仅作参考)—— ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $msg['id'] = $user_id; $msg['name'] = "ali_" . $user_id; $msg['field'] = 'alipay_id'; es_session::set("api_user_info", $msg); $user_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where alipay_id = " . $msg['id'] . " and alipay_id <> 0"); if ($user_data) { $user_current_group = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_group where id = " . intval($user_data['group_id'])); $user_group = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_group where score <=" . intval($user_data['score']) . " order by score desc"); if ($user_current_group['score'] < $user_group['score']) { $user_data['group_id'] = intval($user_group['id']); } es_session::set("user_info", $user_data); $GLOBALS['db']->query("update " . DB_PREFIX . "user set login_ip = '" . get_client_ip() . "',login_time= " . TIME_UTC . ",group_id=" . intval($user_data['group_id']) . " where id =" . $user_data['id']); //$GLOBALS['db']->query("update ".DB_PREFIX."deal_cart set user_id = ".intval($_SESSION['user_info']['id'])." where session_id = '".es_session::id()."'"); es_session::delete("api_user_info"); app_recirect_preview(); } else { app_redirect(url("shop", "user#api_login")); } } else { //验证失败 //如要调试,请看alipay_notify.php页面的return_verify函数,比对sign和mysign的值是否相等,或者检查$veryfy_result有没有返回true echo "fail"; } exit; }
/** * 响应操作 */ function respond() { $payment = get_payment_info('alipay'); $partner = trim($payment['partnerid']); $key = trim($payment['ytauthkey']); $sign_type = "MD5"; $_input_charset = "GBK"; $transport = "http"; $alipay = new alipay_notify($partner, $key, $sign_type, $_input_charset, $transport); $verify_result = $alipay->return_verify(); if ($verify_result) { //验证成功 $dingdan = $_GET['out_trade_no']; //获取订单号 $total_fee = $_GET['total_fee']; //获取总价格 return order_paid($dingdan); } else { return false; } }
public function Pin() { $pname = $_GET['type']; import('@.ORG.Payment.' . $pname); $p = new $pname(); if ($pname == "Paypal") { self::$Model = D("Orders"); $data['orders_status'] = "2"; /* if($p->validate_ipn()==true){ self::$Model->where("sn=".$p->ipn_data['item_number'])->save($data); }*/ if (strcasecmp($_POST['payer_status'], 'verified') == 0) { if (!empty($_POST['item_number'])) { self::$Model->where("sn=" . $_POST['item_number'])->save($data); //赠送用户积分 give_member_points($_POST['item_number']); } } } if ($pname == "Alipay") { $alipay = new alipay_notify(GetValue($pname . "_" . "partner"), GetValue($pname . "_security_code"), "MD5", GetValue($pname . "_" . "input_charset")); $verify_result = $alipay->notify_verify(); //计算得出通知验证结果 if ($verify_result) { $dingdan = $_POST['out_trade_no']; //获取支付宝传递过来的订单号 $total = $_POST['price']; //获取支付宝传递过来的总价格 if ($_POST['trade_status'] == 'WAIT_SELLER_SEND_GOODS' || $_GET['trade_status'] == 'TRADE_FINISHED') { //担保交易和即时到账 self::$Model = D("Orders"); $data['orders_status'] = "2"; self::$Model->where("sn=" . $dingdan)->save($data); give_member_points($_POST['item_number']); } } } }
/** * 构造函数(从配置文件及入口文件中初始化变量) * @param $aOrder array( * 'out_trade_no' => 'QC屋唯一订单号', * 'subject' => "订单名称(商品名称)", * 'body' => "订单描述、订单详细、订单备注", * 'total_fee' => "订单总金额,显示在支付宝收银台里的“应付总额”里", * 'notify_url' => '异步处理程序', * 'return_url' => '同步跳转页面', * 'show_url' => '商品链接', * ) */ function alipay_service($aOrder) { $this->notify_url = $aOrder['notify_url']; $this->return_url = $aOrder['return_url']; $this->show_url = $aOrder['show_url']; $aConfig = $this->loadAlipayConfig(@$aOrder['out_trade_no'], @$aOrder['subject'], @$aOrder['body'], @$aOrder['total_fee']); parent::alipay_notify($aConfig['partner'], $aConfig['key'], $aConfig['sign_type'], $aConfig['_input_charset'], $aConfig['transport']); $this->gateway = "https://www.alipay.com/cooperate/gateway.do?"; $this->_key = $aConfig['key']; $this->sign_type = $aConfig['sign_type']; $this->parameter = para_filter($aConfig['parameter']); //设定_input_charset的值,为空值的情况下默认为GBK if ($aConfig['parameter']['_input_charset'] == '') { $this->parameter['_input_charset'] = 'utf-8'; } //GBK $this->_input_charset = $this->parameter['_input_charset']; //获得签名结果 $sort_array = arg_sort($this->parameter); //得到从字母a到z排序后的签名参数数组 $this->mysign = build_mysign($sort_array, $this->_key, $this->sign_type); }
///////////页面功能说明/////////////// //该页面可在本机电脑测试 //该页面称作“返回页”,是由支付宝服务器同步调用,可当作是支付完成后的提示信息页,如“您的某某某订单,多少金额已支付成功”。 //可放入HTML等美化页面的代码和订单交易完成后的数据库更新程序代码 //该页面可以使用PHP开发工具调试,也可以使用写文本函数log_result进行调试,该函数已被默认关闭,见alipay_notify.php中的函数return_verify //TRADE_FINISHED(表示交易已经成功结束,为普通即时到帐的交易状态成功标识); //TRADE_SUCCESS(表示交易已经成功结束,为高级即时到帐的交易状态成功标识); /////////////////////////////////// error_reporting(0); require_once "class/alipay_notify.php"; require_once "alipay_config.php"; require_once dirname(dirname(dirname(__FILE__))) . "/data/db.config.php"; require_once dirname(dirname(dirname(__FILE__))) . "/include/mysql.class.php"; $db = new mysql($db_config['dbhost'], $db_config['dbuser'], $db_config['dbpass'], $db_config['dbname'], ALL_PS, $db_config['charset']); //构造通知函数信息 $alipay = new alipay_notify($partner, $security_code, $sign_type, $_input_charset, $transport); //计算得出通知验证结果 $verify_result = $alipay->return_verify(); if ($verify_result) { //验证成功 //获取支付宝的通知返回参数 $dingdan = $_GET['out_trade_no']; //获取订单号 $total_fee = $_GET['total_fee']; //获取总价格 $sOld_trade_status = "0"; //获取商户数据库中查询得到该笔交易当前的交易状态 /*假设: sOld_trade_status="0";表示订单未处理; sOld_trade_status="1";表示交易成功(TRADE_FINISHED/TRADE_SUCCESS); */
*日期: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']; //获取收货人姓名 $receive_address =$_POST['receive_address']; //获取收货人地址 $receive_zip =$_POST['receive_zip']; //获取收货人邮编 $receive_phone =$_POST['receive_phone']; //获取收货人电话 $receive_mobile =$_POST['receive_mobile']; //获取收货人手机
public function verifyNotifyUrl() { /*{{{*/ $alipay = new alipay_notify($this->partner, $this->security_code, $this->sign_type, $this->_input_charset, 'http'); return $alipay->notify_verify(); }
public function callback_international() { //trade_create_by_buyer 双接口 ,create_direct_pay_by_user 直接到帐,create_partner_trade_by_buyer 担保接口 log_result("Alipay :: exciting callback_international function."); $oder_success = FALSE; $this->load->library('encryption'); $trade_type = "alipay.trade.direct.forcard.pay"; $seller_email = "*****@*****.**"; // 商家邮箱 $partner = "2088011357497434"; //合作伙伴ID $security_code = "qo58xp4g1ywibtiiyns1gftw5mbv5rs3"; //安全检验码 $_input_charset = "utf-8"; $sign_type = "MD5"; $transport = 'http'; $alipay = new alipay_notify($partner, $security_code, $sign_type, $_input_charset, $transport); $verify_result = $alipay->notify_verify(); $order_status = array("paying" => 1, "payed" => 2, "shiping" => 3, "shipped" => 4, "stayin" => 5, "storage" => 6); if ($verify_result) { $order_id = $_POST['out_trade_no']; //$_POST['out_trade_no']; $trade_status = $_POST['trade_status']; $total_fee = $_POST['total_fee']; //log_result("order_id:" . $order_id . "trade_status:" . $trade_status . "total_fee:" . $total_fee); if (strpos($order_id, 'cz')) { if ($trade_status == 'TRADE_FINISHED' || $trade_status == 'TRADE_SUCCESS') { $order_id_array = explode("-", $order_id); $order_id = $order_id_array[1]; $customer_id = $order_id_array[2]; //log_result("alipay_international_cz this is test order_id:" . $order_id . "this is test customer_id". $customer_id); $data = array('state' => 1, 'successtime' => time(), 'remark' => "OK", 'rid' => $order_id); $this->load->model('account/rechargerecord'); $this->load->model('account/customer'); $this->model_account_rechargerecord->updateRechargerecord($data); $money = $this->model_account_rechargerecord->getMoneybyid($order_id); $this->model_account_customer->editBalance($money, $customer_id); echo "success"; } else { echo "fail"; } } else { if (strpos($order_id, 'yd')) { $this->load->model('order/order'); $sendorder_id_array = explode("-", $order_id); $sendorder_id = $sendorder_id_array[1]; $customer_id = $sendorder_id_array[2]; //log_result("sendorder0".$sendorder_id_array[0]."-sendorder1".$sendorder_id_array[1]."-sendorder2".$sendorder_id_array[2]); //log_result("kennewei".$sendorder_id); $sendorder_array = explode(",", $sendorder_id); //$sendorder_array = array_filter($sendorder_array); $sendorder_info = $this->model_order_order->getSendorderById($sendorder_array[0]); if ($sendorder_info['state'] < 1) { if ($trade_status == 'TRADE_FINISHED' || $trade_status == 'TRADE_SUCCESS') { $this->model_order_order->UpdateSendorderPay($sendorder_array); //插入消费记录 $this->load->model('account/customer'); $customer_info = $this->model_account_customer->getCustomer($customer_id); $first_name = $customer_info['firstname']; $accountmoney = $customer_info['money']; $data2 = array('uid' => $customer_id, 'firstname' => $first_name, 'payname' => '支付宝支付', 'money' => -$total_fee, 'accountmoney' => $accountmoney, 'remark' => "提交运单费用,运单ID:" . $sendorder_id, 'remarktype' => 2, 'remarkdetails' => $sendorder_id, 'addtime' => time()); //log_result("firstname".$first_name . "---money".$total_fee . "---accountmoney".$accountmoney ."---sendorder_id".$value); $this->load->model('account/record'); $this->model_account_record->addRecord($data2); echo "success"; } else { echo "fail"; } } else { echo "fail"; } } else { $this->load->model('checkout/order'); $order_customer = explode("-", $order_id); $order_id = $order_customer[0]; $customer_id = $order_customer[1]; $orders_id = explode(",", $order_id); $order_id = $orders_id[0]; $order_info = $this->model_checkout_order->getOrder($order_id); //log_result("Alipay order_id :: " . $order_id); if ($order_info) { $order_status_id = $order_info["order_status_id"]; //log_result("Alipay order_id :: " . $order_id . " order_status_id = " . $order_status_id . " , trade_status :: " . $trade_status); //log_result("Alipay order_id :: Complete status = " . $order_status['Complete']); // 确定订单没有重复支付 if ($order_status_id < $order_status['payed']) { // 根据接口类型动态使用支付方法,默认使用直接到账接口类型 $this->func_create_direct_pay_by_user($orders_id, $order_status_id, $order_status, $trade_status); //插入消费记录 $this->load->model('account/customer'); $customer_info = $this->model_account_customer->getCustomer($customer_id); $first_name = $customer_info['firstname']; $accountmoney = $customer_info['money']; $order_record = implode(",", $orders_id); $data1 = array('uid' => $customer_id, 'firstname' => $first_name, 'payname' => '支付宝支付', 'money' => -$total_fee, 'accountmoney' => $accountmoney, 'remark' => "提交代购订单费用,订单ID:" . $order_record, 'remarktype' => 1, 'remarkdetails' => $order_record, 'addtime' => time()); $this->load->model('account/record'); $this->model_account_record->addRecord($data1); echo "success"; } else { echo "fail"; } } else { //log_result("Alipay No Order Found."); echo "fail"; } } } } }
public function callback() { //trade_create_by_buyer 双接口 ,create_direct_pay_by_user 直接到帐,create_partner_trade_by_buyer 担保接口 $trade_type = $this->config->get('alipay_trade_type'); $this->log->debug("Alipay :: exciting callback function."); $oder_success = FALSE; $this->load->library('encryption'); $seller_email = $this->config->get('alipay_seller_email'); // 商家邮箱 $partner = $this->config->get('alipay_partner'); //合作伙伴ID $security_code = $this->config->get('alipay_security_code'); //安全检验码 $_input_charset = "utf-8"; //$_input_charset = "GBK"; $sign_type = "MD5"; $transport = 'http'; $alipay = new alipay_notify($partner, $security_code, $sign_type, $_input_charset, $transport); $verify_result = $alipay->notify_verify(); // Order status TODO we need a config page to set these. $order_status = array("Canceled" => 7, "Canceled_Reversal" => 9, "Chargeback" => 13, "Complete" => 5, "Denied" => 8, "Failed" => 10, "Pending" => 1, "Processing" => 2, "Refunded" => 11, "Reversed" => 12, "Shipped" => 3); $this->log->debug("Alipay :: trade_type " . $trade_type . " :: verify_result = " . $verify_result); if ($verify_result) { $order_id = $_POST['out_trade_no']; //$_POST['out_trade_no']; $trade_status = $_POST['trade_status']; $this->load->model('checkout/order'); $order_info = $this->model_checkout_order->getOrder($order_id); $this->log->debug("Alipay order_id :: " . $order_id); if ($order_info) { $order_status_id = $order_info["order_status_id"]; $this->log->debug("Alipay order_id :: " . $order_id . " order_status_id = " . $order_status_id . " , trade_status :: " . $trade_status); $this->log->debug("Alipay order_id :: Complete status = " . $order_status['Complete']); // 确定订单没有重复支付 if ($order_status_id != $order_status['Complete']) { $currency_code = 'CNY'; $total = $order_info['total']; $currency_value = $this->currency->getValue($currency_code); $amount = $total * $currency_value; $total = $_POST['total_fee']; //$_POST['total_fee']; // 确定支付和订单额度一致 $this->log->debug("Alipay total :: " . $_POST['total_fee'] . ",amount :: " . $amount); if ($total < $amount) { $this->log->debug("Alipay order_id :: " . $order_id . " total < amount, order_status_id = " . $order_status_id); $this->model_checkout_order->confirm($order_id, $order_status['Canceled']); echo "success"; } else { // 根据接口类型动态使用支付方法 if ($trade_type == 'trade_create_by_buyer') { $this->func_trade_create_by_buyer($order_id, $order_status_id, $order_status, $trade_status); echo "success"; } else { if ($trade_type == 'create_direct_pay_by_user') { $this->func_create_direct_pay_by_user($order_id, $order_status_id, $order_status, $trade_status); echo "success"; } else { if ($trade_type == 'create_partner_trade_by_buyer') { $this->func_create_partner_trade_by_buyer($order_id, $order_status_id, $order_status, $trade_status); echo "success"; } } } } } else { echo "fail"; } } else { $this->log->debug("Alipay No Order Found."); echo "fail"; } } }
*/ ///////////页面功能说明/////////////// //创建该页面文件时,请留心该页面文件中无任何HTML代码及空格。 //该页面不能在本机电脑测试,请到服务器上做测试。请确保外部可以访问该页面。 //该页面调试工具请使用写文本函数log_result,该函数已被默认开启,见alipay_notify.php中的函数notify_verify //WAIT_BUYER_PAY(表示买家已在支付宝交易管理中产生了交易记录,但没有付款); //WAIT_SELLER_SEND_GOODS(表示买家已在支付宝交易管理中产生了交易记录且付款成功,但卖家没有发货); //WAIT_BUYER_CONFIRM_GOODS(表示卖家已经发了货,但买家还没有做确认收货的操作); //TRADE_FINISHED(表示买家已经确认收货,这笔交易完成); //该服务器异步通知页面面主要功能是:防止订单未更新。如果没有收到该页面打印的 success 信息,支付宝会在24小时内按一定的时间策略重发通知 ///////////////////////////////////// require_once("class/alipay_notify.php"); require_once("alipay_config.php"); $alipay = new alipay_notify($partner,$key,$sign_type,$_input_charset,$transport); //构造通知函数信息 $verify_result = $alipay->notify_verify(); //计算得出通知验证结果 if($verify_result) {//验证成功 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //请在这里加上商户的业务逻辑程序代 //——请根据您的业务逻辑来编写程序(以下代码仅作参考)—— //获取支付宝的通知返回参数,可参考技术文档中服务器异步通知参数列表 $dingdan = $_POST['out_trade_no']; //获取支付宝传递过来的订单号 $total = $_POST['price']; //获取支付宝传递过来的总价格 if($_POST['trade_status'] == 'WAIT_BUYER_PAY') { //该判断表示买家已在支付宝交易管理中产生了交易记录,但没有付款 //判断该笔订单是否在商户网站中已经做过处理(可参考“集成教程”中“3.4返回数据处理”)
function notify_f() { $sn = $this->trans_lib->safe("sn"); $pass = $this->trans_lib->safe("pass"); $paycode = "alipay"; $rs = $this->payment_m->get_one_code($paycode); $order_rs = $this->checkout_m->get_one_sn($sn); $f_rs = $this->payment_m->get_fields($rs["id"]); $data = array(); $id = $order_rs["id"]; include_once LIBS . "payment/alipay_notify.php"; //加载alipay_notify操作类 $alipay = new alipay_notify($f_rs["partner"], $f_rs["code"], "MD5", $f_rs["charset"], $f_rs["transport"]); $tmp_array = array(); $tmp_array[] = $this->config->c; $tmp_array[] = $this->config->f; $tmp_array[] = "sn"; $tmp_array[] = "pass"; $verify_result = $alipay->notify_verify($tmp_array); if (!$verify_result) { exit("fail"); } $payment_status = $this->trans_lib->safe("trade_status"); if ($payment_status == "WAIT_BUYER_PAY") { exit("success"); } if ($payment_status == "TRADE_FINISHED" || $payment_status == "TRADE_SUCCESS") { $data["pay_status"] = 1; $data["pay_price"] = $this->trans_lib->safe("total_fee"); $data["pay_currency"] = $f_rs["currency"]; $data["pay_type"] = $rs["id"]; $data["pay_date"] = $this->system_time; $data["pay_code"] = $this->trans_lib->safe("trade_no"); $this->payment_m->update_order($id, $data); $this->load_lib("email"); $this->email_lib->order_update($id); //通知客户订单信息 $this->email_lib->order_update_admin($id); //通知管理员有订单信息 } exit("success"); }
public function callback() { $oder_success = FALSE; // 获取商家信息 $this->load->library('encryption'); $seller_email = $this->config->get('alipay_direct_seller_email'); // 商家邮箱 $security_code = $this->config->get('alipay_direct_security_code'); //安全检验码 $partner = $this->config->get('alipay_direct_partner'); //合作伙伴ID $_input_charset = "utf-8"; //字符编码格式 目前支持 GBK 或 utf-8 $sign_type = "MD5"; //加密方式 系统默认(不要修改) $transport = 'http'; //访问模式,你可以根据自己的服务器是否支持ssl访问而选择http以及https访问模式(系统默认,不要修改) log_result("callback start."); // 获取支付宝返回的数据 $alipay = new alipay_notify($partner, $security_code, $sign_type, $_input_charset, $transport); $verify_result = $alipay->notify_verify(); if ($verify_result) { //认证合格 //获取支付宝的反馈参数 $order_id = $_POST['out_trade_no']; //获取支付宝传递过来的订单号 $this->load->model('checkout/order'); // 获取订单ID $order_info = $this->model_checkout_order->getOrder($order_id); // 存储订单至系统数据库 if ($order_info) { $order_status_id = $order_info["order_status_id"]; $alipay_direct_order_status_id = $this->config->get('alipay_direct_order_status_id'); $alipay_direct_wait_buyer_pay = $this->config->get('alipay_direct_wait_buyer_pay'); $alipay_direct_wait_buyer_confirm = $this->config->get('alipay_direct_wait_buyer_confirm'); $alipay_direct_trade_finished = $this->config->get('alipay_direct_trade_finished'); $alipay_direct_wait_seller_send = $this->config->get('alipay_direct_wait_seller_send'); if (1 > $order_status_id) { log_result('order->confirm order_status_id=' . $order_status_id); $this->model_checkout_order->confirm($order_id, $alipay_direct_order_status_id); } // 避免处理已完成的订单 log_result('order_id=' . $order_id . ' order_status_id=' . $order_status_id); if ($order_status_id != $alipay_direct_trade_finished) { log_result("No finished."); // 获取原始订单的总额 $currency_code = $this->config->get('alipay_direct_currency_code'); //人民币代号(CNY) $total = $order_info['total']; log_result('total=' . $total); if ($currency_code == '') { $currency_code = 'CNY'; } $currency_value = $this->currency->getValue($currency_code); log_result('currency_value=' . $currency_value); $amount = $total * $currency_value; $amount = number_format($amount, 2, '.', ''); log_result('amount=' . $amount); // 支付宝付款金额 $total = $_POST['total_fee']; // 获取支付宝传递过来的总价格 log_result('total_fee=' . $total); /* $receive_name =$_POST['receive_name']; //获取收货人姓名 $receive_address =$_POST['receive_address']; //获取收货人地址 $receive_zip =$_POST['receive_zip']; //获取收货人邮编 $receive_phone =$_POST['receive_phone']; //获取收货人电话 $receive_mobile =$_POST['receive_mobile']; //获取收货人手机 */ /* 获取支付宝反馈过来的状态,根据不同的状态来更新数据库 //TRADE_FINISHED(表示交易已经成功结束,通用即时到帐反馈的交易状态成功标志); //TRADE_SUCCESS(表示交易已经成功结束,高级即时到帐反馈的交易状态成功标志); */ log_result("trade_status:" . $_POST['trade_status']); if ($_POST['trade_status'] == 'WAIT_BUYER_PAY') { log_result('==alipay_direct_wait_buyer_pay=='); //该判断表示买家已在支付宝交易管理中产生了交易记录,但没有付款 //判断该笔订单是否在商户网站中已经做过处理(可参考“集成教程”中“3.4返回数据处理”) //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序 //如果有做过处理,不执行商户的业务程序 if ($order_status_id != $alipay_direct_trade_finished && $order_status_id != $alipay_direct_wait_buyer_confirm && $order_status_id != $alipay_direct_wait_seller_send) { $this->model_checkout_order->update($order_id, $alipay_direct_wait_buyer_pay); echo "success - alipay_direct_wait_buyer_pay"; //请不要修改或删除 //调试用,写文本函数记录程序运行情况是否正常 log_result('success - alipay_direct_wait_buyer_pay'); } } else { if ($_POST['trade_status'] == 'WAIT_SELLER_SEND_GOODS') { log_result('==alipay_direct_wait_seller_send=='); //该判断表示买家已在支付宝交易管理中产生了交易记录且付款成功,但卖家没有发货 //判断该笔订单是否在商户网站中已经做过处理(可参考“集成教程”中“3.4返回数据处理”) //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序 //如果有做过处理,不执行商户的业务程序 if ($order_status_id != $alipay_direct_trade_finished && $order_status_id != $alipay_direct_wait_buyer_confirm) { $this->model_checkout_order->update($order_id, $alipay_direct_wait_seller_send); echo "success - alipay_direct_wait_seller_send"; //请不要修改或删除 //调试用,写文本函数记录程序运行情况是否正常 log_result('success - alipay_direct_wait_seller_send'); } } else { if ($_POST['trade_status'] == 'TRADE_FINISHED' || $_POST['trade_status'] == 'TRADE_SUCCESS') { //交易成功结束 //这里放入你自定义代码,比如根据不同的trade_status进行不同操作 $this->model_checkout_order->update($order_id, $alipay_direct_trade_finished); echo "success - alipay_direct_trade_finished"; //请不要修改或删除 //调试用,写文本函数记录程序运行情况是否正常 log_result('success - alipay_direct_trade_finished'); log_result("finished."); } else { echo "fail"; log_result("verify_failed"); } } } } } } }