@@ -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 | } |