public function actionAsync() { $response = ['return_code' => 'FAIL', 'return_msg' => '参数格式校验错误']; $post = Wxpay::getXmlPostData(); if (isset($post['return_code']) && isset($post['result_code']) && isset($post['out_trade_no']) && isset($post['transaction_id']) && isset($post['transaction_id'])) { $id = $post['out_trade_no']; $tid = $post['transaction_id']; $status = $post['return_code'] == 'SUCCESS' && $post['result_code'] == 'SUCCESS'; $manager = $this->module->manager; $verified = $manager->verifySign($this->mode, true); $manager->saveNotify($this->mode, $id, $tid, $status, $verified, $post); if ($verified) { $response['return_code'] = 'SUCCESS'; $response['return_msg'] = 'OK'; } else { $response['return_msg'] = '签名验证失败'; } if ($status && $manager->complete($id, $tid) && ($asyncClass = $this->module->asyncClass)) { $asyncClass::paied($id); } } return Wxpay::xmlFormatter($response); }
/** * 使用微信进行支付 * @method getWxpayPayUrl * @since 0.0.1 * @param {string} $async 异步通知地址 * @param {string} $sync 同步通知地址 * @return {array} */ private function getWxpayPayUrl($async, $sync) { $this->payment->url = \Yii::$app->qrcode->create(Wxpay::sdk($this->modes['wxpay'])->createBizpayurl($this->payment->id)); $this->payment->save(); return [$this->modes['wxpay']['qrcodeRoute'], 'id' => $this->payment->id]; }