1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Omnipay\MyCard\Message; |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
class TokenRequest extends AbstractRequest |
7
|
|
|
{ |
8
|
|
|
|
9
|
|
|
|
10
|
|
|
public function getToken() |
11
|
|
|
{ |
12
|
|
|
$endpoint = $this->getEndpoint('b2b') . '/MyBillingPay/api/AuthGlobal'; |
13
|
|
|
$requestData = [ |
14
|
|
|
'FacServiceId' => $this->getAppId(), |
15
|
|
|
'FacTradeSeq' => $this->getTransactionId(), |
16
|
|
|
'TradeType' => $this->getTradeType(), |
17
|
|
|
'ServerId' => $this->getServerId() ?: '', // 服务器ID |
18
|
|
|
'CustomerId' => $this->getAccountId() ?: $this->getTransactionId(), // 用户ID |
19
|
|
|
'PaymentType' => $this->getPaymentType() ?: '', |
20
|
|
|
'ItemCode' => $this->getItemCode() ?: '', |
21
|
|
|
'ProductName' => $this->getDescription(), |
22
|
|
|
'Amount' => $this->getAmount(), |
23
|
|
|
'Currency' => $this->getCurrency(), |
24
|
|
|
'SandBoxMode' => $this->getTestMode() ? 'true' : 'false', |
25
|
|
|
'Hash' => $this->getSign('token'), |
26
|
|
|
]; |
27
|
|
|
$requestData = array_filter($requestData); |
28
|
|
|
$httpRequest = $this->httpClient->post($endpoint, null, $requestData); |
29
|
|
|
$httpResponse = $httpRequest->send(); |
30
|
|
|
$body = json_decode($httpResponse->getBody(), true); |
31
|
|
|
if ($body['ReturnCode'] != 1) { |
32
|
|
|
throw new DefaultException($body['ReturnMsg']); |
|
|
|
|
33
|
|
|
} |
34
|
|
|
return $body; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
|
38
|
|
|
public function getSign($type = '') |
39
|
|
|
{ |
40
|
|
|
$sandboxMode = $this->getTestMode() ? 'true' : 'false'; |
41
|
|
|
$preSign = ''; |
42
|
|
|
|
43
|
|
|
switch ($type) { |
44
|
|
|
|
45
|
|
|
case 'token': |
46
|
|
|
$preSign = |
47
|
|
|
$this->getAppId() . |
48
|
|
|
$this->getTransactionId() . |
49
|
|
|
$this->getTradeType() . |
50
|
|
|
$this->getServerId() . |
51
|
|
|
($this->getAccountId() ?: $this->getTransactionId()) . |
52
|
|
|
$this->getPaymentType() . |
53
|
|
|
$this->getItemCode() . |
54
|
|
|
strtolower(urlencode($this->getDescription())) . |
55
|
|
|
$this->getAmount() . |
56
|
|
|
$this->getCurrency() . |
57
|
|
|
$sandboxMode . |
58
|
|
|
$this->getAppKey(); |
59
|
|
|
break; |
60
|
|
|
|
61
|
|
|
case 'returnHash': |
62
|
|
|
$preSign = $this->httpRequest->get('ReturnCode') . |
63
|
|
|
$this->httpRequest->get('PayResult') . |
64
|
|
|
$this->httpRequest->get('FacTradeSeq') . |
65
|
|
|
$this->httpRequest->get('PaymentType') . |
66
|
|
|
$this->httpRequest->get('Amount') . |
67
|
|
|
$this->httpRequest->get('Currency') . |
68
|
|
|
$this->httpRequest->get('MyCardTradeNo') . |
69
|
|
|
$this->httpRequest->get('MyCardType') . |
70
|
|
|
$this->httpRequest->get('PromoCode') . |
71
|
|
|
$this->getAppKey(); |
72
|
|
|
break; |
73
|
|
|
|
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
return hash('sha256', $preSign); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths