@@ 33-82 (lines=50) @@ | ||
30 | * @return bool |
|
31 | * @throws Exception |
|
32 | */ |
|
33 | public function validate($message) |
|
34 | { |
|
35 | //获取当面付配置 |
|
36 | $f2fpay = $this->app->getF2fpay(); |
|
37 | ||
38 | //获取配置参数 |
|
39 | $gatewayUrl = $f2fpay['gateway_url']; |
|
40 | $appId = $f2fpay['app_id']; |
|
41 | $signType = $f2fpay['sign_type']; |
|
42 | $rsaPrivateKey = $f2fpay['merchant_private_key']; |
|
43 | $alipayPublicKey = $f2fpay['alipay_public_key']; |
|
44 | $charset = $f2fpay['charset']; |
|
45 | $notifyUrl = $f2fpay['notify_url']; |
|
46 | ||
47 | if (empty($appId) || trim($appId) == "") { |
|
48 | throw new Exception("appid should not be NULL!"); |
|
49 | } |
|
50 | if (empty($rsaPrivateKey) || trim($rsaPrivateKey) == "") { |
|
51 | throw new Exception("merchant_private_key should not be NULL!"); |
|
52 | } |
|
53 | if (empty($alipayPublicKey) || trim($alipayPublicKey) == "") { |
|
54 | throw new Exception("alipay_public_key should not be NULL!"); |
|
55 | } |
|
56 | if (empty($charset) || trim($charset) == "") { |
|
57 | throw new Exception("charset should not be NULL!"); |
|
58 | } |
|
59 | if (empty($notifyUrl) || trim($notifyUrl) == "") { |
|
60 | throw new Exception("sign_type should not be NULL"); |
|
61 | } |
|
62 | if (empty($gatewayUrl) || trim($gatewayUrl) == "") { |
|
63 | throw new Exception("gateway_url should not be NULL"); |
|
64 | } |
|
65 | if (empty($signType) || trim($signType) == "") { |
|
66 | throw new Exception("sign_type should not be NULL"); |
|
67 | } |
|
68 | ||
69 | //组装请求数据 |
|
70 | $aop = new AopClient(); |
|
71 | $aop->gatewayUrl = $gatewayUrl; |
|
72 | $aop->appId =$appId; |
|
73 | $aop->signType = $signType; |
|
74 | $aop->rsaPrivateKey = $rsaPrivateKey; |
|
75 | $aop->alipayrsaPublicKey = $alipayPublicKey; |
|
76 | $aop->apiVersion = "1.0"; |
|
77 | $aop->charset = $charset; |
|
78 | $aop->format = 'json'; |
|
79 | ||
80 | //验签 |
|
81 | return $aop->rsaCheckV2($message, null); |
|
82 | } |
|
83 | } |
@@ 124-172 (lines=49) @@ | ||
121 | * @author kaylv <[email protected]> |
|
122 | * @throws Exception |
|
123 | */ |
|
124 | private function newAopClient() |
|
125 | { |
|
126 | //获取当面付配置 |
|
127 | $f2fpay = $this->app->getF2fpay(); |
|
128 | ||
129 | //获取配置参数 |
|
130 | $gatewayUrl = $f2fpay['gateway_url']; |
|
131 | $appId = $f2fpay['app_id']; |
|
132 | $signType = $f2fpay['sign_type']; |
|
133 | $rsaPrivateKey = $f2fpay['merchant_private_key']; |
|
134 | $alipayPublicKey = $f2fpay['alipay_public_key']; |
|
135 | $charset = $f2fpay['charset']; |
|
136 | $notifyUrl = $f2fpay['notify_url']; |
|
137 | ||
138 | if (empty($appId) || trim($appId) == "") { |
|
139 | throw new Exception("appid should not be NULL!"); |
|
140 | } |
|
141 | if (empty($rsaPrivateKey) || trim($rsaPrivateKey) == "") { |
|
142 | throw new Exception("merchant_private_key should not be NULL!"); |
|
143 | } |
|
144 | if (empty($alipayPublicKey) || trim($alipayPublicKey) == "") { |
|
145 | throw new Exception("alipay_public_key should not be NULL!"); |
|
146 | } |
|
147 | if (empty($charset) || trim($charset) == "") { |
|
148 | throw new Exception("charset should not be NULL!"); |
|
149 | } |
|
150 | if (empty($notifyUrl) || trim($notifyUrl) == "") { |
|
151 | throw new Exception("sign_type should not be NULL"); |
|
152 | } |
|
153 | if (empty($gatewayUrl) || trim($gatewayUrl) == "") { |
|
154 | throw new Exception("gateway_url should not be NULL"); |
|
155 | } |
|
156 | if (empty($signType) || trim($signType) == "") { |
|
157 | throw new Exception("sign_type should not be NULL"); |
|
158 | } |
|
159 | ||
160 | //组装请求数据 |
|
161 | $aop = new AopClient(); |
|
162 | $aop->gatewayUrl = $gatewayUrl; |
|
163 | $aop->appId =$appId; |
|
164 | $aop->signType = $signType; |
|
165 | $aop->rsaPrivateKey = $rsaPrivateKey; |
|
166 | $aop->alipayrsaPublicKey = $alipayPublicKey; |
|
167 | $aop->apiVersion = "1.0"; |
|
168 | $aop->charset = $charset; |
|
169 | $aop->format = 'json'; |
|
170 | ||
171 | return $aop; |
|
172 | } |
|
173 | ||
174 | /** |
|
175 | * 格式化返回数据 |