/** * @brief 检查订单的支付状态,该函数会引起远程网络调用,不能放在事物中处理 * * @return 查询交易状态 * @retval * @see * @note * @author 吕宝贵 * @date 2016/03/10 10:28:03 **/ public function checkPayStatus($out_trade_no = null) { $data = []; if (empty($out_trade_no)) { $data = $this->_notifyData; } else { $data['out_trade_no'] = $out_trade_no; } if (empty($data['transaction_id']) && empty($data['out_trade_no'])) { $this->addError('transaction_id', 'transaction_id参数为必备参数'); return false; } else { $payOrder = new WechatPayOrder($this->_config); $orderResult = $payOrder->queryPayStatus($data); $this->_notifyData = $orderResult->toArray(); if ($this->_notifyData['return_code'] !== 'SUCCESS') { $this->addError('wechat-pay', $orderResult['return_msg']); return false; } if ($this->_notifyData['result_code'] !== 'SUCCESS') { $this->addError('wechat-pay-error', $orderResult['err_code_des']); return false; } //支付成功 if ($this->_notifyData['trade_state'] === 'SUCCESS') { return true; } return true; } }
/** * @brief 统一下单接口 * * @return protected function * @retval * @see * @note * @author 吕宝贵 * @date 2016/03/12 16:31:32 **/ protected function generateUnifiedOrder($orderParams) { $wxPayOrder = new WechatPayOrder($this->_config); $response = $wxPayOrder->generateUnifiedOrder($orderParams); $unifiedOrderData = $response->getAttributes(); if ($unifiedOrderData['return_code'] !== 'SUCCESS') { //$this->addError('wechat-pay-unified-order', $unifiedOrderData['return_msg']); $this->addError('wechat-pay-unified-order', $unifiedOrderData); $this->addError(__METHOD__, $response); return false; } if ($unifiedOrderData['result_code'] !== 'SUCCESS') { //$this->addError('wechat-pay-unified-order', $unifiedOrderData['err_code_des']); $this->addError('wechat-pay-unified-order', $unifiedOrderData); return false; } return $response; }