private function delivery_notify($order) { if (strcasecmp($order['payment'], 'wxpay') != 0) { return true; } $payment = M('b2c_payment')->where(array('token' => $this->token, 'branch_id' => $this->branch_id, 'pay_code' => 'wxpay'))->find(); $wxpay_config = unserialize($payment['pay_config']); $wxuser = M('wxuser')->where(array('status' => 1, 'token' => $this->token))->find(); $trade = M('b2c_wxtrade')->where(array('token' => $this->token, 'branch_id' => $this->branch_id, 'order_sn' => $order['sn']))->find(); if (!empty($wxpay_config) && !empty($trade) && $wxuser['type'] == 1 && $wxuser['is_authed'] == 1) { require_once COMMON_PATH . '/WeixinAPI.php'; $weixin = new WeixinAPI($wxuser['appid'], $wxuser['appsecret']); $access_token = $weixin->getAccessToken(); import("@.ORG.LzWxPayHelper"); $lzWxPayHelper = new LzWxPayHelper($wxpay_config); $ret = $lzWxPayHelper->delivernotify($access_token, $trade); return $ret; } else { Log::record('wxpay delivery type:' . $wxuser['type'] . ' auth:' . $wxuser['is_authed'] . ' config:' . print_r($wxpay_config, true), Log::INFO); Log::save(); } return true; }
function checkAccessToken($params = array()) { require_once COMMON_PATH . '/WeixinAPI.php'; $weixin = new WeixinAPI($params['appid'], $params['appsecret']); return $weixin->getAccessToken(); }