public function actionAlipayReturn() { $data = Yii::$app->request->get(); /* $data = array ( 'body' => '测试商品', 'buyer_email' => '*****@*****.**', 'buyer_id' => '2088002336746485', 'exterface' => 'create_direct_pay_by_user', 'is_success' => 'T', 'notify_id' => 'RqPnCoPT3K9%2Fvwbh3InTs%2FZBNErNo1YRPH5%2BP%2BfYEDbLzoUY7QdU4VLRgBvQDF5ZImOT', 'notify_time' => '2015-04-23 13:56:10', 'notify_type' => 'trade_status_sync', 'out_trade_no' => 'IDY000009', 'payment_type' => '1', 'seller_email' => '*****@*****.**', 'seller_id' => '2088411582940602', 'subject' => '测试商品', 'total_fee' => '0.01', 'trade_no' => '2015042300001000480051224268', 'trade_status' => 'TRADE_SUCCESS', 'sign' => '3cfc49a535c7bbb519c3e237080142ec', 'sign_type' => 'MD5' ); */ $user = Yii::$app->util->isLogin(); $para_filter = AlipayDirect::paraFilter($data); $para_sort = AlipayDirect::argSort($para_filter); $mysign = Yii::$app->alipay->buildRequestMysign($para_sort); if ($data['sign'] !== $mysign || !$user) { $this->redirect(Url::toRoute('main/index')); } $isPay = true; $sign = $data['sign']; $tradeNo = $data['trade_no']; $tradeStatus = $data['trade_status']; $outTradeNo = $data['out_trade_no']; $notifyTime = $data['notify_time']; $isSuccess = $data['is_success']; // TODO: 需要有签名验证处理 // XXX: 需要再次明确$isSuccess的用途 if (!$isSuccess || $tradeStatus !== 'TRADE_SUCCESS' && $tradeStatus !== 'TRADE_FINISHED') { $isPay = false; } $mOrder = new Order(); $order = $mOrder->getByOrderNo($outTradeNo, $user['uid']); if ($order) { $now = time(); $order['ispay'] = Order::STATUS_ISPAY; $order['update_time'] = $now; $order['pay_at'] = $now; // XXX: weixinno字段应该调整字段命名 $order['trade_no'] = $tradeNo; if (!$order->save()) { $isPay = false; } else { try { $mActiProd = new ActivityProduct(); $mActiProd->changeStock($order['rel_id'], 1); } catch (Exception $e) { // TODO: 需要增加日志记录 } } } else { // TODO: 订单不存在处理 $isPay = false; } $refreshUrl = Url::toRoute(['demo/alipay-result', 'orderno' => $order['orderno']]); echo <<<EOF <script type="text/javascript"> window.top.location = "{$refreshUrl}"; </script> EOF; }
public function actionWeixinpaydone() { //用户是否登陆 $user = PublicLibrary::is_login(); if (isset($user['uid'])) { $uid = $user['uid']; } else { return $this->redirect(['product/index']); exit; } //接收传递过来的信息 $data = Yii::$app->request->get(); $orderno = isset($data['orderno']) ? strip_tags($data['orderno']) : ''; //判断该订单是不是这个用户的 $model_order = new Order(); $res = $model_order->getByOrderNo($orderno, $uid); if (!$res) { return $this->redirect(['product/index']); exit; } $photo = $res['product']['name']; $album = $res['product']['album']; $ispay = $res['ispay']; //显示支付成功页面 return $this->render('alipay-return', ['order' => $res, 'isPay' => $ispay]); }