diff --git a/wchat/wx/Recharge.php b/wchat/wx/Recharge.php index d2a2bc4..67ba4d7 100644 --- a/wchat/wx/Recharge.php +++ b/wchat/wx/Recharge.php @@ -77,10 +77,10 @@ class Recharge extends SmallProgram public function reception($prepay_id) { $array = [ - 'appId' => $this->config->getAppid(), - 'nonceStr' => Help::random(32), - 'package' => 'prepay_id=' . $prepay_id, - 'signType' => 'MD5', + 'appId' => $this->config->getAppid(), + 'nonceStr' => Help::random(32), + 'package' => 'prepay_id=' . $prepay_id, + 'signType' => 'MD5', 'timeStamp' => (string)time(), ]; $key = $this->config->getKey(); @@ -95,15 +95,15 @@ class Recharge extends SmallProgram protected function builder() { $data = [ - 'appid' => $this->config->getAppid(), - 'mch_id' => $this->config->getMchId(), - 'nonce_str' => Help::random(32), - 'body' => $this->config->getBody(), - 'out_trade_no' => $this->orderNo, - 'total_fee' => $this->money, + 'appid' => $this->config->getAppid(), + 'mch_id' => $this->config->getMchId(), + 'nonce_str' => Help::random(32), + 'body' => $this->config->getBody(), + 'out_trade_no' => $this->orderNo, + 'total_fee' => $this->money, 'spbill_create_ip' => $_SERVER['REMOTE_ADDR'], - 'notify_url' => $this->config->getNotifyUrl(), - 'trade_type' => $this->config->getTradeType(), + 'notify_url' => $this->config->getNotifyUrl(), + 'trade_type' => $this->config->getTradeType(), ]; $this->data = array_merge($data, $this->data); @@ -137,15 +137,15 @@ class Recharge extends SmallProgram public function cashWithdrawal($money, $openid, $order, $desc = '零钱提现') { $array = [ - 'nonce_str' => Help::random(32), + 'nonce_str' => Help::random(32), 'partner_trade_no' => $order, - 'mchid' => $this->config->getMchId(), - 'mch_appid' => $this->config->getAppid(), - 'openid' => $openid, - 'check_name' => 'NO_CHECK', - 'amount' => $money * 100, + 'mchid' => $this->config->getMchId(), + 'mch_appid' => $this->config->getAppid(), + 'openid' => $openid, + 'check_name' => 'NO_CHECK', + 'amount' => $money * 100, 'spbill_create_ip' => $this->config->getRemoteAddr(), - 'desc' => $desc, + 'desc' => $desc, ]; $key = $this->config->getKey(); @@ -154,7 +154,9 @@ class Recharge extends SmallProgram $this->request->setCallback(function ($data) { $array = Help::toArray($data); - if ($array['result_code'] != 'SUCCESS') { + if ($array['return_code'] != 'SUCCESS') { + $data = ['code' => $array['return_code'], 'message' => $array['return_msg']]; + } else if ($array['result_code'] != 'SUCCESS') { $data = ['code' => $array['err_code'], 'message' => $array['err_code_des']]; } else { $data = ['code' => 0, 'message' => '支付成功'];