1 | <?php |
||
31 | class API extends AbstractAPI |
||
32 | { |
||
33 | /** |
||
34 | * Merchant instance. |
||
35 | * |
||
36 | * @var Merchant |
||
37 | */ |
||
38 | protected $merchant; |
||
39 | |||
40 | // api |
||
41 | const API_PAY_ORDER = 'https://api.mch.weixin.qq.com/pay/micropay'; |
||
42 | const API_PREPARE_ORDER = 'https://api.mch.weixin.qq.com/pay/unifiedorder'; |
||
43 | const API_QUERY = 'https://api.mch.weixin.qq.com/pay/orderquery'; |
||
44 | const API_CLOSE = 'https://api.mch.weixin.qq.com/pay/closeorder'; |
||
45 | const API_REVERSE = 'https://api.mch.weixin.qq.com/secapi/pay/reverse'; |
||
46 | const API_REFUND = 'https://api.mch.weixin.qq.com/secapi/pay/refund'; |
||
47 | const API_QUERY_REFUND = 'https://api.mch.weixin.qq.com/pay/refundquery'; |
||
48 | const API_DOWNLOAD_BILL = 'https://api.mch.weixin.qq.com/pay/downloadbill'; |
||
49 | const API_REPORT = 'https://api.mch.weixin.qq.com/payitil/report'; |
||
50 | const API_URL_SHORTEN = 'https://api.mch.weixin.qq.com/tools/shorturl'; |
||
51 | const API_AUTH_CODE_TO_OPENID = 'https://api.mch.weixin.qq.com/tools/authcodetoopenid'; |
||
52 | |||
53 | // order id types. |
||
54 | const TRANSACTION_ID = 'transaction_id'; |
||
55 | const OUT_TRADE_NO = 'out_trade_no'; |
||
56 | const OUT_REFUND_NO = 'out_refund_no'; |
||
57 | const REFUND_ID = 'refund_id'; |
||
58 | |||
59 | // bill types. |
||
60 | const BILL_TYPE_ALL = 'ALL'; |
||
61 | const BILL_TYPE_SUCCESS = 'SUCCESS'; |
||
62 | const BILL_TYPE_REFUND = 'REFUND'; |
||
63 | const BILL_TYPE_REVOKED = 'REVOKED'; |
||
64 | |||
65 | /** |
||
66 | * API constructor. |
||
67 | * |
||
68 | * @param \EasyWeChat\Payment\Merchant $merchant |
||
69 | */ |
||
70 | 12 | public function __construct(Merchant $merchant) |
|
74 | |||
75 | /** |
||
76 | * Pay the order. |
||
77 | * |
||
78 | * @param Order $order |
||
79 | * |
||
80 | * @return \EasyWeChat\Support\Collection |
||
81 | */ |
||
82 | 1 | public function pay(Order $order) |
|
88 | |||
89 | /** |
||
90 | * Prepare order to pay. |
||
91 | * |
||
92 | * @param Order $order |
||
93 | * |
||
94 | * @return \EasyWeChat\Support\Collection |
||
95 | */ |
||
96 | 1 | public function prepare(Order $order) |
|
102 | |||
103 | /** |
||
104 | * Query order. |
||
105 | * |
||
106 | * @param string $orderNo |
||
107 | * @param string $type |
||
108 | * |
||
109 | * @return \EasyWeChat\Support\Collection |
||
110 | */ |
||
111 | 1 | public function query($orderNo, $type = self::OUT_TRADE_NO) |
|
119 | |||
120 | /** |
||
121 | * Query order by transaction_id. |
||
122 | * |
||
123 | * @param string $transactionId |
||
124 | * |
||
125 | * @return \EasyWeChat\Support\Collection |
||
126 | */ |
||
127 | 1 | public function queryByTransactionId($transactionId) |
|
131 | |||
132 | /** |
||
133 | * Close order by out_trade_no. |
||
134 | * |
||
135 | * @param $tradeNo |
||
136 | * |
||
137 | * @return \EasyWeChat\Support\Collection |
||
138 | */ |
||
139 | 1 | public function close($tradeNo) |
|
147 | |||
148 | /** |
||
149 | * Reverse order. |
||
150 | * |
||
151 | * @param string $orderNo |
||
152 | * @param string $type |
||
153 | * |
||
154 | * @return \EasyWeChat\Support\Collection |
||
155 | */ |
||
156 | 1 | public function reverse($orderNo, $type = self::OUT_TRADE_NO) |
|
164 | |||
165 | /** |
||
166 | * Reverse order by transaction_id. |
||
167 | * |
||
168 | * @param int $transactionId |
||
169 | * |
||
170 | * @return \EasyWeChat\Support\Collection |
||
171 | */ |
||
172 | public function reverseByTransactionId($transactionId) |
||
176 | |||
177 | /** |
||
178 | * Make a refund request. |
||
179 | * |
||
180 | * @param string $orderNo |
||
181 | * @param float $totalFee |
||
182 | * @param float $refundFee |
||
183 | * @param string $opUserId |
||
184 | * @param string $type |
||
185 | * |
||
186 | * @return \EasyWeChat\Support\Collection |
||
187 | */ |
||
188 | 1 | public function refund( |
|
207 | |||
208 | /** |
||
209 | * Refund by transaction id. |
||
210 | * |
||
211 | * @param string $orderNo |
||
212 | * @param float $totalFee |
||
213 | * @param float $refundFee |
||
214 | * @param string $opUserId |
||
215 | * |
||
216 | * @return \EasyWeChat\Support\Collection |
||
217 | */ |
||
218 | public function refundByTransactionId( |
||
227 | |||
228 | /** |
||
229 | * Query refund status. |
||
230 | * |
||
231 | * @param string $orderNo |
||
232 | * @param string $type |
||
233 | * |
||
234 | * @return \EasyWeChat\Support\Collection |
||
235 | */ |
||
236 | 1 | public function queryRefund($orderNo, $type = self::OUT_TRADE_NO) |
|
244 | |||
245 | /** |
||
246 | * Query refund status by out_refund_no. |
||
247 | * |
||
248 | * @param string $refundNo |
||
249 | * |
||
250 | * @return \EasyWeChat\Support\Collection |
||
251 | */ |
||
252 | public function queryRefundByRefundNo($refundNo) |
||
256 | |||
257 | /** |
||
258 | * Query refund status by transaction_id. |
||
259 | * |
||
260 | * @param string $transactionId |
||
261 | * |
||
262 | * @return \EasyWeChat\Support\Collection |
||
263 | */ |
||
264 | public function queryRefundByTransactionId($transactionId) |
||
268 | |||
269 | /** |
||
270 | * Query refund status by refund_id. |
||
271 | * |
||
272 | * @param string $refundId |
||
273 | * |
||
274 | * @return \EasyWeChat\Support\Collection |
||
275 | */ |
||
276 | public function queryRefundByRefundId($refundId) |
||
280 | |||
281 | /** |
||
282 | * Download bill history as a table file. |
||
283 | * |
||
284 | * @param string $date |
||
285 | * @param string $type |
||
286 | * |
||
287 | * @return \EasyWeChat\Support\Collection |
||
288 | */ |
||
289 | 1 | public function downloadBill($date, $type = self::BILL_TYPE_ALL) |
|
298 | |||
299 | /** |
||
300 | * Convert long url to short url. |
||
301 | * |
||
302 | * @param string $url |
||
303 | * |
||
304 | * @return \EasyWeChat\Support\Collection |
||
305 | */ |
||
306 | 1 | public function urlShorten($url) |
|
310 | |||
311 | /** |
||
312 | * Report API status to WeChat. |
||
313 | * |
||
314 | * @param string $api |
||
315 | * @param int $timeConsuming |
||
316 | * @param string $resultCode |
||
317 | * @param string $returnCode |
||
318 | * @param array $other ex: err_code,err_code_des,out_trade_no,user_ip... |
||
319 | * |
||
320 | * @return \EasyWeChat\Support\Collection |
||
321 | */ |
||
322 | public function report($api, $timeConsuming, $resultCode, $returnCode, array $other = []) |
||
336 | |||
337 | /** |
||
338 | * Get openid by auth code. |
||
339 | * |
||
340 | * @param string $authCode |
||
341 | * |
||
342 | * @return \EasyWeChat\Support\Collection |
||
343 | */ |
||
344 | 1 | public function authCodeToOpenId($authCode) |
|
348 | |||
349 | /** |
||
350 | * Merchant setter. |
||
351 | * |
||
352 | * @param Merchant $merchant |
||
353 | * |
||
354 | * @return $this |
||
355 | */ |
||
356 | 1 | public function setMerchant(Merchant $merchant) |
|
360 | |||
361 | /** |
||
362 | * Merchant getter. |
||
363 | * |
||
364 | * @return Merchant |
||
365 | */ |
||
366 | 1 | public function getMerchant() |
|
370 | |||
371 | /** |
||
372 | * Make a API request. |
||
373 | * |
||
374 | * @param string $api |
||
375 | * @param array $params |
||
376 | * @param string $method |
||
377 | * |
||
378 | * @return \EasyWeChat\Support\Collection |
||
379 | */ |
||
380 | 10 | protected function request($api, array $params, $method = 'post') |
|
396 | |||
397 | /** |
||
398 | * Parse Response XML to array. |
||
399 | * |
||
400 | * @param string $response |
||
401 | * |
||
402 | * @return \EasyWeChat\Support\Collection |
||
403 | */ |
||
404 | 10 | protected function parseResponse($response) |
|
412 | } |
||
413 |
Since your code implements the magic setter
_set
, this function will be called for any write access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.