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