@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | if (self::$config->offsetExists($key)) { |
| 136 | - return self::$config[$key]; |
|
| 136 | + return self::$config[ $key ]; |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | return $default; |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | |
| 209 | 209 | foreach ($params as $k => $v) { |
| 210 | 210 | if ($v !== '' && !is_null($v) && $k !== 'sign' && '@' !== substr($v, 0, 1)) { |
| 211 | - $v = self::characet($v, $params['charset'] ?? 'utf-8'); |
|
| 211 | + $v = self::characet($v, $params[ 'charset' ] ?? 'utf-8'); |
|
| 212 | 212 | |
| 213 | 213 | $stringToBeSigned .= $k . '=' . $v . '&'; |
| 214 | 214 | } |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | |
| 237 | 237 | foreach ($params as $k => $v) { |
| 238 | 238 | if ($v !== '' && !is_null($v) && '@' !== substr($v, 0, 1)) { |
| 239 | - $v = self::characet($v, $params['charset'] ?? 'utf-8'); |
|
| 239 | + $v = self::characet($v, $params[ 'charset' ] ?? 'utf-8'); |
|
| 240 | 240 | |
| 241 | 241 | $stringToBeSigned .= $k . '=' . urlencode($v) . '&'; |
| 242 | 242 | } |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | new SignFailed( |
| 288 | 288 | self::$config->get('event.driver'), |
| 289 | 289 | self::$config->get('event.method'), |
| 290 | - [$data], |
|
| 290 | + [ $data ], |
|
| 291 | 291 | '支付宝RSA公钥错误。请检查 [ ali_public_key ] 配置项的公钥文件格式或路径是否正确' |
| 292 | 292 | ) |
| 293 | 293 | ); |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | $data |
| 366 | 366 | ) |
| 367 | 367 | ); |
| 368 | - $data = array_filter($data, function ($value) { |
|
| 368 | + $data = array_filter($data, function($value) { |
|
| 369 | 369 | return ($value === '' || is_null($value)) ? false : true; |
| 370 | 370 | }); |
| 371 | 371 | // 请求支付宝网关 |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | self::$config->get('event.driver', ''), |
| 383 | 383 | self::$config->get('event.method', ''), |
| 384 | 384 | $gatewayUrl, |
| 385 | - [], |
|
| 385 | + [ ], |
|
| 386 | 386 | $result |
| 387 | 387 | ) |
| 388 | 388 | ); |
@@ -432,21 +432,21 @@ discard block |
||
| 432 | 432 | ); |
| 433 | 433 | } |
| 434 | 434 | |
| 435 | - $method = str_replace('.', '_', $data['method']) . '_response'; |
|
| 435 | + $method = str_replace('.', '_', $data[ 'method' ]) . '_response'; |
|
| 436 | 436 | |
| 437 | 437 | // 签名不存在抛出应用异常,该异常为支付宝网关错误,例如 app_id 配置错误,没有返回签名,建议检查配置项是否正确 |
| 438 | - if (!isset($result['sign'])) { |
|
| 438 | + if (!isset($result[ 'sign' ])) { |
|
| 439 | 439 | throw new SignException( |
| 440 | 440 | '[' . $method . '] Get Alipay API Error: msg [' |
| 441 | - . $result[$method]['msg'] . ']', |
|
| 441 | + . $result[ $method ][ 'msg' ] . ']', |
|
| 442 | 442 | $result |
| 443 | 443 | ); |
| 444 | 444 | } |
| 445 | 445 | |
| 446 | - $result_method_content = json_encode($result[$method], JSON_UNESCAPED_UNICODE); |
|
| 446 | + $result_method_content = json_encode($result[ $method ], JSON_UNESCAPED_UNICODE); |
|
| 447 | 447 | $result_method_content = mb_convert_encoding($result_method_content, self::$respCharset, self::$fileCharset); |
| 448 | 448 | // 验证支付返回的签名,验证失败抛出应用异常 |
| 449 | - if (!self::verifySign($result_method_content, $result['sign'])) { |
|
| 449 | + if (!self::verifySign($result_method_content, $result[ 'sign' ])) { |
|
| 450 | 450 | Events::dispatch( |
| 451 | 451 | SignFailed::NAME, |
| 452 | 452 | new SignFailed( |
@@ -465,19 +465,19 @@ discard block |
||
| 465 | 465 | |
| 466 | 466 | // 业务返回处理,返回码 10000 则正常返回成功数据,其他的则抛出业务异常 |
| 467 | 467 | // 捕获 BusinessException 异常 获取 raw 元素查看完整数据并做处理 |
| 468 | - if ($result[$method]['code'] !== '10000' && Support::getConfig('business_exception', false)) { |
|
| 468 | + if ($result[ $method ][ 'code' ] !== '10000' && Support::getConfig('business_exception', false)) { |
|
| 469 | 469 | throw new Exceptions\BusinessException( |
| 470 | 470 | '[' . $method |
| 471 | - . '] Business Error: msg [' . $result[$method]['msg'] . ']' |
|
| 472 | - . (isset($result[$method]['sub_code']) ? ' - sub_code [' |
|
| 473 | - . $result[$method]['sub_code'] . ']' : '') |
|
| 474 | - . (isset($result[$method]['sub_msg']) ? ' - sub_msg [' |
|
| 475 | - . $result[$method]['sub_msg'] . ']' : ''), |
|
| 476 | - $result[$method] |
|
| 471 | + . '] Business Error: msg [' . $result[ $method ][ 'msg' ] . ']' |
|
| 472 | + . (isset($result[ $method ][ 'sub_code' ]) ? ' - sub_code [' |
|
| 473 | + . $result[ $method ][ 'sub_code' ] . ']' : '') |
|
| 474 | + . (isset($result[ $method ][ 'sub_msg' ]) ? ' - sub_msg [' |
|
| 475 | + . $result[ $method ][ 'sub_msg' ] . ']' : ''), |
|
| 476 | + $result[ $method ] |
|
| 477 | 477 | ); |
| 478 | 478 | } |
| 479 | 479 | |
| 480 | - return new AccessData($result[$method]); |
|
| 480 | + return new AccessData($result[ $method ]); |
|
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | /** |
@@ -562,17 +562,17 @@ discard block |
||
| 562 | 562 | public static function executeApi($params, $method) |
| 563 | 563 | { |
| 564 | 564 | // 获取公共参数 |
| 565 | - $payload = self::$config->get('payload', []); |
|
| 565 | + $payload = self::$config->get('payload', [ ]); |
|
| 566 | 566 | // 设置方法 |
| 567 | - $payload['method'] = $method; |
|
| 567 | + $payload[ 'method' ] = $method; |
|
| 568 | 568 | // 设置业务参数 |
| 569 | - $payload['biz_content'] = json_encode($params); |
|
| 569 | + $payload[ 'biz_content' ] = json_encode($params); |
|
| 570 | 570 | // 过滤空值 |
| 571 | - $payload = array_filter($payload, function ($value) { |
|
| 571 | + $payload = array_filter($payload, function($value) { |
|
| 572 | 572 | return $value !== '' && !is_null($value); |
| 573 | 573 | }); |
| 574 | 574 | // 设置签名 |
| 575 | - $payload['sign'] = self::generateSign($payload); |
|
| 575 | + $payload[ 'sign' ] = self::generateSign($payload); |
|
| 576 | 576 | // 获取支付宝网关地址 |
| 577 | 577 | $base_uri = self::getConfig('base_uri'); |
| 578 | 578 | |
@@ -597,23 +597,23 @@ discard block |
||
| 597 | 597 | { |
| 598 | 598 | // 请求跳转类接口,返回字符串组装格式get url或post表单形式,默认POST形式 |
| 599 | 599 | $http_method = 'POST'; |
| 600 | - if (isset($params['http_method'])) { |
|
| 601 | - $http_method = isset($params['http_method']) |
|
| 602 | - ? $params['http_method'] : 'POST'; |
|
| 603 | - unset($params['http_method']); |
|
| 600 | + if (isset($params[ 'http_method' ])) { |
|
| 601 | + $http_method = isset($params[ 'http_method' ]) |
|
| 602 | + ? $params[ 'http_method' ] : 'POST'; |
|
| 603 | + unset($params[ 'http_method' ]); |
|
| 604 | 604 | } |
| 605 | 605 | // 获取公共参数 |
| 606 | - $payload = self::$config->get('payload', []); |
|
| 606 | + $payload = self::$config->get('payload', [ ]); |
|
| 607 | 607 | // 设置方法 |
| 608 | - $payload['method'] = $method; |
|
| 608 | + $payload[ 'method' ] = $method; |
|
| 609 | 609 | // 设置业务参数 |
| 610 | - $payload['biz_content'] = json_encode($params); |
|
| 610 | + $payload[ 'biz_content' ] = json_encode($params); |
|
| 611 | 611 | // 过滤空值 |
| 612 | - $payload = array_filter($payload, function ($value) { |
|
| 612 | + $payload = array_filter($payload, function($value) { |
|
| 613 | 613 | return $value !== '' && !is_null($value); |
| 614 | 614 | }); |
| 615 | 615 | // 设置签名 |
| 616 | - $payload['sign'] = self::generateSign($payload); |
|
| 616 | + $payload[ 'sign' ] = self::generateSign($payload); |
|
| 617 | 617 | // 获取支付宝网关地址 |
| 618 | 618 | $base_uri = self::getConfig('base_uri'); |
| 619 | 619 | |
@@ -634,21 +634,21 @@ discard block |
||
| 634 | 634 | public static function executeSdk($params, $method): Response |
| 635 | 635 | { |
| 636 | 636 | // 获取公共参数 |
| 637 | - $payload = self::$config->get('payload', []); |
|
| 637 | + $payload = self::$config->get('payload', [ ]); |
|
| 638 | 638 | // 设置方法 |
| 639 | - $payload['method'] = $method; |
|
| 639 | + $payload[ 'method' ] = $method; |
|
| 640 | 640 | // 设置业务参数 |
| 641 | - $payload['biz_content'] = json_encode($params); |
|
| 641 | + $payload[ 'biz_content' ] = json_encode($params); |
|
| 642 | 642 | // 过滤空值 |
| 643 | - $payload = array_filter($payload, function ($value) { |
|
| 643 | + $payload = array_filter($payload, function($value) { |
|
| 644 | 644 | return $value !== '' && !is_null($value); |
| 645 | 645 | }); |
| 646 | 646 | ksort($payload); |
| 647 | 647 | // 设置签名 |
| 648 | - $payload['sign'] = self::generateSign($payload); |
|
| 648 | + $payload[ 'sign' ] = self::generateSign($payload); |
|
| 649 | 649 | |
| 650 | 650 | foreach ($payload as &$value) { |
| 651 | - $value = self::characet($value, $payload['charset']); |
|
| 651 | + $value = self::characet($value, $payload[ 'charset' ]); |
|
| 652 | 652 | } |
| 653 | 653 | |
| 654 | 654 | return Response::create(http_build_query($payload)); |
@@ -667,14 +667,14 @@ discard block |
||
| 667 | 667 | { |
| 668 | 668 | $data = ($data === null) ? self::getRequest() : $data; |
| 669 | 669 | $sign_type = null; |
| 670 | - if (isset($data['sign_type'])) { |
|
| 671 | - $sign_type = $data['sign_type']; |
|
| 672 | - $data['sign_type'] = null; |
|
| 670 | + if (isset($data[ 'sign_type' ])) { |
|
| 671 | + $sign_type = $data[ 'sign_type' ]; |
|
| 672 | + $data[ 'sign_type' ] = null; |
|
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | return self::verifySign( |
| 676 | 676 | Support::getSignContent($data), |
| 677 | - $data['sign'], |
|
| 677 | + $data[ 'sign' ], |
|
| 678 | 678 | $sign_type |
| 679 | 679 | ); |
| 680 | 680 | } |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | * @author liuml <[email protected]> |
| 169 | 169 | * @DateTime 2019-04-28 12:09 |
| 170 | 170 | */ |
| 171 | - public function alipayMethod($method, $params = []) |
|
| 171 | + public function alipayMethod($method, $params = [ ]) |
|
| 172 | 172 | { |
| 173 | 173 | $method = Str::studly($method); |
| 174 | 174 | // 组装命名空间 |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | * @author liuml <[email protected]> |
| 194 | 194 | * @DateTime 2019-04-28 12:09 |
| 195 | 195 | */ |
| 196 | - public function make(string $gateway, $params = []) |
|
| 196 | + public function make(string $gateway, $params = [ ]) |
|
| 197 | 197 | { |
| 198 | 198 | $app = new $gateway(); |
| 199 | 199 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | public function transfer($params): AccessData |
| 46 | 46 | { |
| 47 | - Support::$config->set('event.method', $this->method.'->transfer'); |
|
| 47 | + Support::$config->set('event.method', $this->method . '->transfer'); |
|
| 48 | 48 | return Support::executeApi($params, 'alipay.fund.trans.toaccount.transfer'); |
| 49 | 49 | } |
| 50 | 50 | |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public function fundAuthOrderVoucherCreate($params): AccessData |
| 64 | 64 | { |
| 65 | - Support::$config->set('event.method', $this->method.'->fundAuthOrderVoucherCreate'); |
|
| 65 | + Support::$config->set('event.method', $this->method . '->fundAuthOrderVoucherCreate'); |
|
| 66 | 66 | return Support::executeApi($params, 'alipay.fund.auth.order.voucher.create'); |
| 67 | 67 | } |
| 68 | 68 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | public function fundAuthOperationCancel($params) |
| 82 | 82 | { |
| 83 | - Support::$config->set('event.method', $this->method.'->fundAuthOperationCancel'); |
|
| 83 | + Support::$config->set('event.method', $this->method . '->fundAuthOperationCancel'); |
|
| 84 | 84 | return Support::executeApi($params, 'alipay.fund.auth.order.voucher.create'); |
| 85 | 85 | } |
| 86 | 86 | |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | */ |
| 99 | 99 | public function fundAuthUnfreeze($params) |
| 100 | 100 | { |
| 101 | - Support::$config->set('event.method', $this->method.'->fundAuthUnfreeze'); |
|
| 101 | + Support::$config->set('event.method', $this->method . '->fundAuthUnfreeze'); |
|
| 102 | 102 | return Support::executeApi($params, 'alipay.fund.auth.order.unfreeze'); |
| 103 | 103 | } |
| 104 | 104 | |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | public function fundAuthFreeze($params) |
| 118 | 118 | { |
| 119 | - Support::$config->set('event.method', $this->method.'->fundAuthFreeze'); |
|
| 119 | + Support::$config->set('event.method', $this->method . '->fundAuthFreeze'); |
|
| 120 | 120 | return Support::executeApi($params, 'alipay.fund.auth.order.freeze'); |
| 121 | 121 | } |
| 122 | 122 | |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | */ |
| 133 | 133 | public function fundAuthAppFreeze($params):Response |
| 134 | 134 | { |
| 135 | - Support::$config->set('event.method', $this->method.'->fundAuthAppFreeze'); |
|
| 135 | + Support::$config->set('event.method', $this->method . '->fundAuthAppFreeze'); |
|
| 136 | 136 | return Support::executeSdk($params, 'alipay.fund.auth.order.app.freeze'); |
| 137 | 137 | } |
| 138 | 138 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | public function trade($params): AccessData |
| 48 | 48 | { |
| 49 | - Support::$config->set('event.method', $this->method.'->trade'); |
|
| 49 | + Support::$config->set('event.method', $this->method . '->trade'); |
|
| 50 | 50 | return Support::executeApi($params, 'alipay.trade.query'); |
| 51 | 51 | } |
| 52 | 52 | |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | public function refund($params): AccessData |
| 68 | 68 | { |
| 69 | - Support::$config->set('event.method', $this->method.'->refund'); |
|
| 69 | + Support::$config->set('event.method', $this->method . '->refund'); |
|
| 70 | 70 | return Support::executeApi($params, 'alipay.trade.fastpay.refund.query'); |
| 71 | 71 | } |
| 72 | 72 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | public function faceFtoken($params): AccessData |
| 86 | 86 | { |
| 87 | - Support::$config->set('event.method', $this->method.'->faceFtoken'); |
|
| 87 | + Support::$config->set('event.method', $this->method . '->faceFtoken'); |
|
| 88 | 88 | return Support::executeApi($params, 'zoloz.authentication.customer.ftoken.query'); |
| 89 | 89 | } |
| 90 | 90 | |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | public function transOrder($params): AccessData |
| 104 | 104 | { |
| 105 | - Support::$config->set('event.method', $this->method.'->transOrder'); |
|
| 105 | + Support::$config->set('event.method', $this->method . '->transOrder'); |
|
| 106 | 106 | return Support::executeApi($params, 'alipay.fund.trans.order.query'); |
| 107 | 107 | } |
| 108 | 108 | |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | public function fundAuthOperationQuery($params): AccessData |
| 122 | 122 | { |
| 123 | - Support::$config->set('event.method', $this->method.'->fundAuthOperationQuery'); |
|
| 123 | + Support::$config->set('event.method', $this->method . '->fundAuthOperationQuery'); |
|
| 124 | 124 | return Support::executeApi($params, 'alipay.fund.auth.operation.detail.query'); |
| 125 | 125 | } |
| 126 | 126 | } |