request->all(); // $this->log->callbackLog(__CLASS__.'微信支付回调'.json_encode($params)); // // $this->setConfig(); // $result = $this->pay->wechat($this->config)->callback($params); // $this->callbackData = $result['resource']['ciphertext']; // // if (empty($this->callbackData)) { // $this->log->error(__CLASS__.'获取回调失败'.json_encode($params)); // throw new ErrException('获取回调失败'); // } // // $this->log->info(__CLASS__.'微信支付完成回调'.json_encode($this->callbackData)); // } /** * 确认回调 * @return ResponseInterface */ protected function returnSuccess(): ResponseInterface { $this->setConfig(); return $this->ysdPay->wechat($this->config)->success(); } /** * @return void */ public function setConfig(): void { $this->config = config('ysdPay'); } /** * @param float $money * @param int $orderId * @param string $outTradeNo * @param int $userId * @return Collection|Rocket * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ public function pay(float $money, int $orderId, string $outTradeNo, int $userId): Collection|Rocket { if (empty($this->config)) throw new ErrException('调起支付失败-微信支付配置项不存在'); try { $wxOrder = [ 'out_trade_no' => $outTradeNo, 'description' => '测试订单', 'amount' => [ 'total' => (int)bcmul((string)$money, "100"), 'currency' => 'CNY' ], 'payer' => [ 'openid' => $this->openId, ] ]; $result = $this->ysdPay->wechat($this->config)->mini($wxOrder); $this->log->callbackLog(__CLASS__.'微信支付调起数据|回调地址:'. json_encode($this->config['wechat']['default']).'|回调数据:'.json_encode($result).'|请求数据:'.json_encode($wxOrder)); return $result; } catch (Exception $e) { $this->log->error(__CLASS__.'微信支付调起失败。reason:'.$e->getMessage()); throw new ErrException($e->getMessage()); } } }