Completed
Pull Request — master (#9)
by Volodymyr
10:57 queued 05:00
created

PaypalExpressController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 8
dl 0
loc 30
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A successAction() 0 8 1
A addShipmentAction() 0 7 1
1
<?php
2
3
/**
4
 * MIT License
5
 * For full license information, please view the LICENSE file that was distributed with this source code.
6
 */
7
8
namespace SprykerEco\Yves\Braintree\Controller;
9
10
use Spryker\Yves\Kernel\Controller\AbstractController;
11
use SprykerEco\Yves\Braintree\Form\CheckoutShipmentForm;
12
use SprykerShop\Yves\CheckoutPage\Plugin\Provider\CheckoutPageControllerProvider;
13
use Symfony\Component\HttpFoundation\Request;
14
15
/**
16
 * @method \SprykerEco\Yves\Braintree\BraintreeFactory getFactory()
17
 */
18
class PaypalExpressController extends AbstractController
19
{
20
    /**
21
     * @param \Symfony\Component\HttpFoundation\Request $request
22
     *
23
     * @return \Symfony\Component\HttpFoundation\JsonResponse
24
     */
25
    public function successAction(Request $request)
26
    {
27
        $payload = $this->getFactory()->getUtilEncodingService()->decodeJson($request->getContent(), true);
28
29
        $this->getFactory()->createResponseProcessor()->processSuccessResponse($payload);
0 ignored issues
show
Bug introduced by
It seems like $payload can also be of type null; however, parameter $payload of SprykerEco\Yves\Braintre...rocessSuccessResponse() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

29
        $this->getFactory()->createResponseProcessor()->processSuccessResponse(/** @scrutinizer ignore-type */ $payload);
Loading history...
30
31
        return $this->jsonResponse([
32
            'redirectUrl' => $this->getApplication()->path(CheckoutPageControllerProvider::CHECKOUT_SUMMARY),
33
        ]);
34
    }
35
36
    /**
37
     * @param \Symfony\Component\HttpFoundation\Request $request
38
     *
39
     * @return \Symfony\Component\HttpFoundation\RedirectResponse
40
     */
41
    public function addShipmentAction(Request $request)
42
    {
43
        $idShipmentMethod = $request->get(CheckoutShipmentForm::FORM_NAME)[CheckoutShipmentForm::FIELD_ID_SHIPMENT_METHOD];
44
45
        $this->getFactory()->createQuoteExpander()->expandQuoteWithShipmentMethod($request, $idShipmentMethod);
46
47
        return $this->redirectResponseInternal(CheckoutPageControllerProvider::CHECKOUT_SUMMARY);
48
    }
49
}
50