Completed
Pull Request — dev (#9)
by Andrey
07:12 queued 03:40
created

WidgetController::walletWidgetAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Apache OSL-2
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerEco\Yves\AmazonPay\Controller;
9
10
use Spryker\Yves\Kernel\Controller\AbstractController;
11
12
/**
13
 * @method \SprykerEco\Yves\AmazonPay\AmazonPayFactory getFactory()
14
 * @method \SprykerEco\Client\AmazonPay\AmazonPayClient getClient()
15
 */
16
class WidgetController extends AbstractController
17
{
18
    const AMAZON_PAY_CONFIG = 'amazonpayConfig';
19
    const LOGOUT = 'logout';
20
21
    /**
22
     * @return array
23
     */
24
    public function payButtonAction()
25
    {
26
        return [
27
            static::AMAZON_PAY_CONFIG => $this->getAmazonPayConfig(),
28
            static::LOGOUT => (int)$this->isLogout(),
29
        ];
30
    }
31
32
    /**
33
     * @return bool
34
     */
35
    protected function isLogout()
36
    {
37
        $quote = $this->getFactory()->getQuoteClient()->getQuote();
38
39
        return $quote->getAmazonpayPayment()
40
            && $quote->getAmazonpayPayment()->getResponseHeader()
41
            && !$quote->getAmazonpayPayment()->getResponseHeader()->getIsSuccess();
42
    }
43
44
    /**
45
     * @return array
46
     */
47
    public function checkoutWidgetAction()
48
    {
49
        return [
50
            static::AMAZON_PAY_CONFIG => $this->getAmazonPayConfig(),
51
        ];
52
    }
53
54
    /**
55
     * @return array
56
     */
57
    public function walletWidgetAction()
58
    {
59
        return [
60
            static::AMAZON_PAY_CONFIG => $this->getAmazonPayConfig(),
61
        ];
62
    }
63
64
    /**
65
     * @return \SprykerEco\Shared\AmazonPay\AmazonPayConfigInterface
66
     */
67
    protected function getAmazonPayConfig()
68
    {
69
        return $this->getFactory()->createAmazonPayConfig();
70
    }
71
}
72