Completed
Push — master ( fad130...026505 )
by Songda
01:31
created

src/Gateways/Alipay/AppGateway.php (1 issue)

Upgrade to new PHP Analysis Engine

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 Symfony\Component\HttpFoundation\Response;
6
use Yansongda\Pay\Contracts\GatewayInterface;
7
use Yansongda\Pay\Events;
8
use Yansongda\Pay\Exceptions\InvalidConfigException;
9
10
class AppGateway implements GatewayInterface
11
{
12
    /**
13
     * Pay an order.
14
     *
15
     * @author yansongda <[email protected]>
16
     *
17
     * @param string $endpoint
18
     * @param array  $payload
19
     *
20
     * @throws InvalidConfigException
21
     *
22
     * @return Response
23
     */
24 View Code Duplication
    public function pay($endpoint, array $payload): Response
0 ignored issues
show
This method seems to be duplicated in your project.

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.

Loading history...
25
    {
26
        $payload['method'] = 'alipay.trade.app.pay';
27
        $payload['biz_content'] = json_encode(array_merge(
28
            json_decode($payload['biz_content'], true),
29
            ['product_code' => 'QUICK_MSECURITY_PAY']
30
        ));
31
        $payload['sign'] = Support::generateSign($payload);
32
33
        Events::dispatch(Events::PAY_STARTED, new Events\PayStarted('Alipay', 'App', $endpoint, $payload));
34
35
        return Response::create(http_build_query($payload));
36
    }
37
}
38