These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Yansongda\Pay\Gateways\Alipay; |
||
4 | |||
5 | use Yansongda\Pay\Contracts\GatewayInterface; |
||
6 | use Yansongda\Pay\Events; |
||
7 | use Yansongda\Pay\Exceptions\GatewayException; |
||
8 | use Yansongda\Pay\Exceptions\InvalidConfigException; |
||
9 | use Yansongda\Pay\Exceptions\InvalidSignException; |
||
10 | use Yansongda\Supports\Collection; |
||
11 | |||
12 | View Code Duplication | class PosGateway implements GatewayInterface |
|
0 ignored issues
–
show
|
|||
13 | { |
||
14 | /** |
||
15 | * Pay an order. |
||
16 | * |
||
17 | * @author yansongda <[email protected]> |
||
18 | * |
||
19 | * @param string $endpoint |
||
20 | * @param array $payload |
||
21 | * |
||
22 | * @throws GatewayException |
||
23 | * @throws InvalidConfigException |
||
24 | * @throws InvalidSignException |
||
25 | * |
||
26 | * @return Collection |
||
27 | */ |
||
28 | public function pay($endpoint, array $payload): Collection |
||
29 | { |
||
30 | $payload['method'] = 'alipay.trade.pay'; |
||
31 | $payload['biz_content'] = json_encode(array_merge( |
||
32 | json_decode($payload['biz_content'], true), |
||
33 | [ |
||
34 | 'product_code' => 'FACE_TO_FACE_PAYMENT', |
||
35 | 'scene' => 'bar_code', |
||
36 | ] |
||
37 | )); |
||
38 | $payload['sign'] = Support::generateSign($payload); |
||
39 | |||
40 | Events::dispatch(new Events\PayStarted('Alipay', 'Pos', $endpoint, $payload)); |
||
41 | |||
42 | return Support::requestApi($payload); |
||
43 | } |
||
44 | } |
||
45 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.