| @@ -12,7 +12,7 @@ | ||
| 12 | 12 | * @param $message | 
| 13 | 13 | * @param array $raw | 
| 14 | 14 | */ | 
| 15 | - public function __construct($message, $raw = []) | |
| 15 | + public function __construct($message, $raw = [ ]) | |
| 16 | 16 |      { | 
| 17 | 17 |          parent::__construct('-SIGN_ERROR: ' . $message, $raw); | 
| 18 | 18 | } | 
| @@ -30,9 +30,9 @@ discard block | ||
| 30 | 30 | public static function getSubscribedEvents() | 
| 31 | 31 |      { | 
| 32 | 32 | return [ | 
| 33 | - Events\ApiRequestStart::NAME => ['writeApiRequestStartLog', 256], | |
| 34 | - Events\ApiRequestEnd::NAME => ['writeApiRequestEndLog', 256], | |
| 35 | - Events\SignFailed::NAME => ['writeSignFailedLog', 256], | |
| 33 | + Events\ApiRequestStart::NAME => [ 'writeApiRequestStartLog', 256 ], | |
| 34 | + Events\ApiRequestEnd::NAME => [ 'writeApiRequestEndLog', 256 ], | |
| 35 | + Events\SignFailed::NAME => [ 'writeSignFailedLog', 256 ], | |
| 36 | 36 | ]; | 
| 37 | 37 | } | 
| 38 | 38 | |
| @@ -78,7 +78,7 @@ discard block | ||
| 78 | 78 |      { | 
| 79 | 79 | Log::error( | 
| 80 | 80 |              "[ Sign Failed ] Alipay::{$event->getDriver()}()->{$event->getMethod()}() error:[{$event->error}] ", | 
| 81 | - [$event->getResult()] | |
| 81 | + [ $event->getResult() ] | |
| 82 | 82 | ); | 
| 83 | 83 | } | 
| 84 | 84 | } | 
| @@ -129,7 +129,7 @@ | ||
| 129 | 129 |          $config->set('payload', $this->commonParams($config)); | 
| 130 | 130 | |
| 131 | 131 | // 设置支付宝网关 | 
| 132 | -        $base_uri = self::URL[$config->get('env', self::ENV_NORMAL)]; | |
| 132 | +        $base_uri = self::URL[ $config->get('env', self::ENV_NORMAL) ]; | |
| 133 | 133 |          $config->set('base_uri', $base_uri); | 
| 134 | 134 | |
| 135 | 135 | $this->registerLogService(); | 
| @@ -140,7 +140,7 @@ discard block | ||
| 140 | 140 | * | 
| 141 | 141 | * @throws Exceptions\ApplicationException | 
| 142 | 142 | */ | 
| 143 | - public function alipayMethod($method, $params = []) | |
| 143 | + public function alipayMethod($method, $params = [ ]) | |
| 144 | 144 |      { | 
| 145 | 145 | $method = Str::studly($method); | 
| 146 | 146 | // 组装命名空间 | 
| @@ -163,7 +163,7 @@ discard block | ||
| 163 | 163 | * | 
| 164 | 164 | * @return mixed | 
| 165 | 165 | */ | 
| 166 | - public function make(string $gateway, $params = []) | |
| 166 | + public function make(string $gateway, $params = [ ]) | |
| 167 | 167 |      { | 
| 168 | 168 | $app = new $gateway(); | 
| 169 | 169 | |
| @@ -183,7 +183,7 @@ discard block | ||
| 183 | 183 |      { | 
| 184 | 184 |          Support::$config->set('event', [ | 
| 185 | 185 | 'driver' => 'Payment', | 
| 186 | - 'method' => $method ? : $this->method, | |
| 186 | + 'method' => $method ?: $this->method, | |
| 187 | 187 | ]); | 
| 188 | 188 | } | 
| 189 | 189 | |
| @@ -132,7 +132,7 @@ discard block | ||
| 132 | 132 | } | 
| 133 | 133 | |
| 134 | 134 |          if (self::$config->offsetExists($key)) { | 
| 135 | - return self::$config[$key]; | |
| 135 | + return self::$config[ $key ]; | |
| 136 | 136 | } | 
| 137 | 137 | |
| 138 | 138 | return $default; | 
| @@ -207,7 +207,7 @@ discard block | ||
| 207 | 207 | |
| 208 | 208 |          foreach ($params as $k => $v) { | 
| 209 | 209 |              if ($v !== '' && !is_null($v) && $k !== 'sign' && '@' !== substr($v, 0, 1)) { | 
| 210 | - $v = self::characet($v, $params['charset'] ?? 'utf-8'); | |
| 210 | + $v = self::characet($v, $params[ 'charset' ] ?? 'utf-8'); | |
| 211 | 211 | |
| 212 | 212 | $stringToBeSigned .= $k . '=' . $v . '&'; | 
| 213 | 213 | } | 
| @@ -235,7 +235,7 @@ discard block | ||
| 235 | 235 | |
| 236 | 236 |          foreach ($params as $k => $v) { | 
| 237 | 237 |              if ($v !== '' && !is_null($v) && '@' !== substr($v, 0, 1)) { | 
| 238 | - $v = self::characet($v, $params['charset'] ?? 'utf-8'); | |
| 238 | + $v = self::characet($v, $params[ 'charset' ] ?? 'utf-8'); | |
| 239 | 239 | |
| 240 | 240 | $stringToBeSigned .= $k . '=' . urlencode($v) . '&'; | 
| 241 | 241 | } | 
| @@ -286,7 +286,7 @@ discard block | ||
| 286 | 286 | new SignFailed( | 
| 287 | 287 |                      self::$config->get('event.driver'), | 
| 288 | 288 |                      self::$config->get('event.method'), | 
| 289 | - [$data], | |
| 289 | + [ $data ], | |
| 290 | 290 | '支付宝RSA公钥错误。请检查 [ ali_public_key ] 配置项的公钥文件格式或路径是否正确' | 
| 291 | 291 | ) | 
| 292 | 292 | ); | 
| @@ -364,7 +364,7 @@ discard block | ||
| 364 | 364 | $data | 
| 365 | 365 | ) | 
| 366 | 366 | ); | 
| 367 | -        $data = array_filter($data, function ($value) { | |
| 367 | +        $data = array_filter($data, function($value) { | |
| 368 | 368 | return ($value === '' || is_null($value)) ? false : true; | 
| 369 | 369 | }); | 
| 370 | 370 | // 请求支付宝网关 | 
| @@ -431,21 +431,21 @@ discard block | ||
| 431 | 431 | ); | 
| 432 | 432 | } | 
| 433 | 433 | |
| 434 | -        $method = str_replace('.', '_', $data['method']) . '_response'; | |
| 434 | +        $method = str_replace('.', '_', $data[ 'method' ]) . '_response'; | |
| 435 | 435 | |
| 436 | 436 | // 签名不存在抛出应用异常,该异常为支付宝网关错误,例如 app_id 配置错误,没有返回签名,建议检查配置项是否正确 | 
| 437 | -        if (!isset($result['sign'])) { | |
| 437 | +        if (!isset($result[ 'sign' ])) { | |
| 438 | 438 | throw new SignException( | 
| 439 | 439 | '[' . $method . '] Get Alipay API Error: msg [' | 
| 440 | - . $result[$method]['msg'] . ']', | |
| 440 | + . $result[ $method ][ 'msg' ] . ']', | |
| 441 | 441 | $result | 
| 442 | 442 | ); | 
| 443 | 443 | } | 
| 444 | 444 | |
| 445 | - $result_method_content = json_encode($result[$method], JSON_UNESCAPED_UNICODE); | |
| 445 | + $result_method_content = json_encode($result[ $method ], JSON_UNESCAPED_UNICODE); | |
| 446 | 446 | $result_method_content = mb_convert_encoding($result_method_content, self::$respCharset, self::$fileCharset); | 
| 447 | 447 | // 验证支付返回的签名,验证失败抛出应用异常 | 
| 448 | -        if (!self::verifySign($result_method_content, $result['sign'])) { | |
| 448 | +        if (!self::verifySign($result_method_content, $result[ 'sign' ])) { | |
| 449 | 449 | Events::dispatch( | 
| 450 | 450 | SignFailed::NAME, | 
| 451 | 451 | new SignFailed( | 
| @@ -464,19 +464,19 @@ discard block | ||
| 464 | 464 | |
| 465 | 465 | // 业务返回处理,返回码 10000 则正常返回成功数据,其他的则抛出业务异常 | 
| 466 | 466 | // 捕获 BusinessException 异常 获取 raw 元素查看完整数据并做处理 | 
| 467 | -        if ($result[$method]['code'] !== '10000' && Support::getConfig('business_exception', false)) { | |
| 467 | +        if ($result[ $method ][ 'code' ] !== '10000' && Support::getConfig('business_exception', false)) { | |
| 468 | 468 | throw new Exceptions\BusinessException( | 
| 469 | 469 | '[' . $method | 
| 470 | - . '] Business Error: msg [' . $result[$method]['msg'] . ']' | |
| 471 | - . (isset($result[$method]['sub_code']) ? ' - sub_code [' | |
| 472 | - . $result[$method]['sub_code'] . ']' : '') | |
| 473 | - . (isset($result[$method]['sub_msg']) ? ' - sub_msg [' | |
| 474 | - . $result[$method]['sub_msg'] . ']' : ''), | |
| 475 | - $result[$method] | |
| 470 | + . '] Business Error: msg [' . $result[ $method ][ 'msg' ] . ']' | |
| 471 | + . (isset($result[ $method ][ 'sub_code' ]) ? ' - sub_code [' | |
| 472 | + . $result[ $method ][ 'sub_code' ] . ']' : '') | |
| 473 | + . (isset($result[ $method ][ 'sub_msg' ]) ? ' - sub_msg [' | |
| 474 | + . $result[ $method ][ 'sub_msg' ] . ']' : ''), | |
| 475 | + $result[ $method ] | |
| 476 | 476 | ); | 
| 477 | 477 | } | 
| 478 | 478 | |
| 479 | - return new AccessData($result[$method]); | |
| 479 | + return new AccessData($result[ $method ]); | |
| 480 | 480 | } | 
| 481 | 481 | |
| 482 | 482 | /** | 
| @@ -561,17 +561,17 @@ discard block | ||
| 561 | 561 | public static function executeApi($params, $method) | 
| 562 | 562 |      { | 
| 563 | 563 | // 获取公共参数 | 
| 564 | -        $payload = self::$config->get('payload', []); | |
| 564 | +        $payload = self::$config->get('payload', [ ]); | |
| 565 | 565 | // 设置方法 | 
| 566 | - $payload['method'] = $method; | |
| 566 | + $payload[ 'method' ] = $method; | |
| 567 | 567 | // 设置业务参数 | 
| 568 | - $payload['biz_content'] = json_encode($params); | |
| 568 | + $payload[ 'biz_content' ] = json_encode($params); | |
| 569 | 569 | // 过滤空值 | 
| 570 | -        $payload = array_filter($payload, function ($value) { | |
| 570 | +        $payload = array_filter($payload, function($value) { | |
| 571 | 571 | return $value !== '' && !is_null($value); | 
| 572 | 572 | }); | 
| 573 | 573 | // 设置签名 | 
| 574 | - $payload['sign'] = self::generateSign($payload); | |
| 574 | + $payload[ 'sign' ] = self::generateSign($payload); | |
| 575 | 575 | // 获取支付宝网关地址 | 
| 576 | 576 |          $base_uri = self::getConfig('base_uri'); | 
| 577 | 577 | |
| @@ -596,23 +596,23 @@ discard block | ||
| 596 | 596 |      { | 
| 597 | 597 | // 请求跳转类接口,返回字符串组装格式get url或post表单形式,默认POST形式 | 
| 598 | 598 | $http_method = 'POST'; | 
| 599 | -        if (isset($params['http_method'])) { | |
| 600 | - $http_method = isset($params['http_method']) | |
| 601 | - ? $params['http_method'] : 'POST'; | |
| 602 | - unset($params['http_method']); | |
| 599 | +        if (isset($params[ 'http_method' ])) { | |
| 600 | + $http_method = isset($params[ 'http_method' ]) | |
| 601 | + ? $params[ 'http_method' ] : 'POST'; | |
| 602 | + unset($params[ 'http_method' ]); | |
| 603 | 603 | } | 
| 604 | 604 | // 获取公共参数 | 
| 605 | -        $payload = self::$config->get('payload', []); | |
| 605 | +        $payload = self::$config->get('payload', [ ]); | |
| 606 | 606 | // 设置方法 | 
| 607 | - $payload['method'] = $method; | |
| 607 | + $payload[ 'method' ] = $method; | |
| 608 | 608 | // 设置业务参数 | 
| 609 | - $payload['biz_content'] = json_encode($params); | |
| 609 | + $payload[ 'biz_content' ] = json_encode($params); | |
| 610 | 610 | // 过滤空值 | 
| 611 | -        $payload = array_filter($payload, function ($value) { | |
| 611 | +        $payload = array_filter($payload, function($value) { | |
| 612 | 612 | return $value !== '' && !is_null($value); | 
| 613 | 613 | }); | 
| 614 | 614 | // 设置签名 | 
| 615 | - $payload['sign'] = self::generateSign($payload); | |
| 615 | + $payload[ 'sign' ] = self::generateSign($payload); | |
| 616 | 616 | // 获取支付宝网关地址 | 
| 617 | 617 |          $base_uri = self::getConfig('base_uri'); | 
| 618 | 618 | |
| @@ -633,21 +633,21 @@ discard block | ||
| 633 | 633 | public static function executeSdk($params, $method): Response | 
| 634 | 634 |      { | 
| 635 | 635 | // 获取公共参数 | 
| 636 | -        $payload = self::$config->get('payload', []); | |
| 636 | +        $payload = self::$config->get('payload', [ ]); | |
| 637 | 637 | // 设置方法 | 
| 638 | - $payload['method'] = $method; | |
| 638 | + $payload[ 'method' ] = $method; | |
| 639 | 639 | // 设置业务参数 | 
| 640 | - $payload['biz_content'] = json_encode($params); | |
| 640 | + $payload[ 'biz_content' ] = json_encode($params); | |
| 641 | 641 | // 过滤空值 | 
| 642 | -        $payload = array_filter($payload, function ($value) { | |
| 642 | +        $payload = array_filter($payload, function($value) { | |
| 643 | 643 | return $value !== '' && !is_null($value); | 
| 644 | 644 | }); | 
| 645 | 645 | ksort($payload); | 
| 646 | 646 | // 设置签名 | 
| 647 | - $payload['sign'] = self::generateSign($payload); | |
| 647 | + $payload[ 'sign' ] = self::generateSign($payload); | |
| 648 | 648 | |
| 649 | 649 |          foreach ($payload as &$value) { | 
| 650 | - $value = self::characet($value, $payload['charset']); | |
| 650 | + $value = self::characet($value, $payload[ 'charset' ]); | |
| 651 | 651 | } | 
| 652 | 652 | |
| 653 | 653 | return Response::create(http_build_query($payload)); | 
| @@ -666,14 +666,14 @@ discard block | ||
| 666 | 666 |      { | 
| 667 | 667 | $data = ($data === null) ? self::getRequest() : $data; | 
| 668 | 668 | $sign_type = null; | 
| 669 | -        if (isset($data['sign_type'])) { | |
| 670 | - $sign_type = $data['sign_type']; | |
| 671 | - $data['sign_type'] = null; | |
| 669 | +        if (isset($data[ 'sign_type' ])) { | |
| 670 | + $sign_type = $data[ 'sign_type' ]; | |
| 671 | + $data[ 'sign_type' ] = null; | |
| 672 | 672 | } | 
| 673 | 673 | |
| 674 | 674 | return self::verifySign( | 
| 675 | 675 | Support::getSignContent($data), | 
| 676 | - $data['sign'], | |
| 676 | + $data[ 'sign' ], | |
| 677 | 677 | $sign_type | 
| 678 | 678 | ); | 
| 679 | 679 | } |