1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* MIT License |
5
|
|
|
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace SprykerEco\Yves\Computop\Controller; |
9
|
|
|
|
10
|
|
|
use Spryker\Yves\Kernel\Controller\AbstractController; |
11
|
|
|
use Symfony\Component\HttpFoundation\JsonResponse; |
12
|
|
|
use Symfony\Component\HttpFoundation\RedirectResponse; |
13
|
|
|
use Symfony\Component\HttpFoundation\Request; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @method \SprykerEco\Yves\Computop\ComputopFactory getFactory() |
17
|
|
|
* @method \SprykerEco\Client\Computop\ComputopClientInterface getClient() |
18
|
|
|
*/ |
19
|
|
|
class ExpressCheckoutController extends AbstractController |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @uses CheckoutPageRouteProviderPlugin::ROUTE_NAME_CHECKOUT_PLACE_ORDER |
23
|
|
|
* @var string |
24
|
|
|
*/ |
25
|
|
|
protected const ROUTE_NAME_CHECKOUT_PLACE_ORDER = 'checkout-place-order'; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @uses CheckoutPageRouteProviderPlugin::ROUTE_NAME_CHECKOUT_SUCCESS |
29
|
|
|
* @var string |
30
|
|
|
*/ |
31
|
|
|
protected const ROUTE_NAME_CHECKOUT_SUCCESS = 'checkout-success'; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @return \Symfony\Component\HttpFoundation\JsonResponse |
35
|
|
|
*/ |
36
|
|
|
public function preparePayPalExpressAction(): JsonResponse |
37
|
|
|
{ |
38
|
|
|
$quoteTransfer = $this->getFactory()->getQuoteClient()->getQuote(); |
39
|
|
|
$payPalExpressPrepareHandler = $this->getFactory()->createComputopPayPalExpressPrepareHandler(); |
40
|
|
|
$computopApiPayPalExpressPrepareResponseTransfer = $payPalExpressPrepareHandler->handle($quoteTransfer); |
41
|
|
|
|
42
|
|
|
return new JsonResponse([ |
43
|
|
|
'orderId' => $computopApiPayPalExpressPrepareResponseTransfer->getOrderId(), |
44
|
|
|
'merchantId' => $computopApiPayPalExpressPrepareResponseTransfer->getMid(), |
45
|
|
|
'payId' => $computopApiPayPalExpressPrepareResponseTransfer->getPayID(), |
46
|
|
|
]); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @param \Symfony\Component\HttpFoundation\Request $request |
51
|
|
|
* |
52
|
|
|
* @return \Symfony\Component\HttpFoundation\RedirectResponse |
53
|
|
|
*/ |
54
|
|
|
public function placeOrderPayPalExpressAction(Request $request): RedirectResponse |
55
|
|
|
{ |
56
|
|
|
$quoteTransfer = $this->getFactory()->getQuoteClient()->getQuote(); |
57
|
|
|
$payPalExpressInitHandler = $this->getFactory()->createComputopPayPalExpressInitHandler(); |
58
|
|
|
$payPalExpressInitHandler->handle($quoteTransfer, $request->query->all()); |
59
|
|
|
|
60
|
|
|
return $this->redirectResponseInternal(static::ROUTE_NAME_CHECKOUT_PLACE_ORDER); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @param \Symfony\Component\HttpFoundation\Request $request |
65
|
|
|
* |
66
|
|
|
* @return \Symfony\Component\HttpFoundation\RedirectResponse |
67
|
|
|
*/ |
68
|
|
|
public function completeOrderPayPalExpressAction(Request $request): RedirectResponse |
|
|
|
|
69
|
|
|
{ |
70
|
|
|
$quoteTransfer = $this->getFactory()->getQuoteClient()->getQuote(); |
71
|
|
|
$payPalExpressCompleteHandler = $this->getFactory()->createComputopPayPalExpressCompleteHandler(); |
72
|
|
|
|
73
|
|
|
$payPalExpressCompleteHandler->handle($quoteTransfer); |
74
|
|
|
|
75
|
|
|
return $this->redirectResponseInternal(static::ROUTE_NAME_CHECKOUT_SUCCESS); |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.