Passed
Pull Request — master (#51)
by Aleksey
12:12
created

addPayonePaymentFailureRoute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 7
rs 10
1
<?php
2
3
/**
4
 * Copyright © 2016-present Spryker Systems GmbH. All rights reserved.
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerEco\Yves\Payone\Plugin\Router;
9
10
use Spryker\Yves\Router\Plugin\RouteProvider\AbstractRouteProviderPlugin;
11
use Spryker\Yves\Router\Route\RouteCollection;
12
13
class PayoneRouteProviderPlugin extends AbstractRouteProviderPlugin
14
{
15
    protected const ROUTE_PAYONE_INDEX = 'payone-index';
16
    protected const ROUTE_PAYONE_GET_FILE = 'payone-getfile';
17
    protected const ROUTE_PAYONE_CANCEL_REDIRECT = 'payone-cancel-redirect';
18
    protected const ROUTE_PAYONE_GET_INVOICE = 'payone-getinvoice';
19
    protected const ROUTE_PAYONE_PAYMENT_SUCCESS = 'payone-payment-success';
20
    protected const ROUTE_PAYONE_PAYMENT_FAILURE = 'payone-payment-failure';
21
22
    protected const ROUTE_PAYONE_EXPRESS_CHECKOUT_BUTTON = 'payone-checkout-with-paypal-button';
23
    protected const ROUTE_PAYONE_EXPRESS_CHECKOUT_INIT = 'payone-paypal-express-checkout-init';
24
    protected const ROUTE_PAYONE_EXPRESS_CHECKOUT_FAILURE = 'payone-paypal-express-checkout-failure';
25
    protected const ROUTE_PAYONE_EXPRESS_CHECKOUT_BACK = 'payone-paypal-express-checkout-back';
26
    protected const ROUTE_PAYONE_EXPRESS_CHECKOUT_LOAD_DETAILS = 'payone-paypal-express-checkout-load-details';
27
28
    /**
29
     * {@inheritDoc}
30
     * - Adds Payone specific Routes to the RouteCollection.
31
     *
32
     * @api
33
     *
34
     * @param \Spryker\Yves\Router\Route\RouteCollection $routeCollection
35
     *
36
     * @return \Spryker\Yves\Router\Route\RouteCollection
37
     */
38
    public function addRoutes(RouteCollection $routeCollection): RouteCollection
39
    {
40
        $routeCollection = $this->addPayoneIndexRoute($routeCollection);
41
        $routeCollection = $this->addPayoneGetFileRoute($routeCollection);
42
        $routeCollection = $this->addPayoneCancelRedirectRoute($routeCollection);
43
        $routeCollection = $this->addPayoneGetInvoiceRoute($routeCollection);
44
        $routeCollection = $this->addPayonePaymentSuccessRoute($routeCollection);
45
        $routeCollection = $this->addPayonePaymentFailureRoute($routeCollection);
46
        $routeCollection = $this->addPayoneExpressCheckoutButtonRoute($routeCollection);
47
        $routeCollection = $this->addPayoneExpressCheckoutInitRoute($routeCollection);
48
        $routeCollection = $this->addPayoneExpressCheckoutFailureRoute($routeCollection);
49
        $routeCollection = $this->addPayoneExpressCheckoutBackRoute($routeCollection);
50
        $routeCollection = $this->addPayoneExpressCheckoutLoadDetailsRoute($routeCollection);
51
52
        return $routeCollection;
53
    }
54
55
    /**
56
     * @param \Spryker\Yves\Router\Route\RouteCollection $routeCollection
57
     *
58
     * @return \Spryker\Yves\Router\Route\RouteCollection
59
     */
60
    protected function addPayoneIndexRoute(RouteCollection $routeCollection): RouteCollection
61
    {
62
        $route = $this->buildRoute('/payone', 'Payone', 'Index', 'indexAction');
63
        $route = $route->setMethods(['POST']);
64
        $routeCollection->add(static::ROUTE_PAYONE_INDEX, $route);
65
66
        return $routeCollection;
67
    }
68
69
    /**
70
     * @param \Spryker\Yves\Router\Route\RouteCollection $routeCollection
71
     *
72
     * @return \Spryker\Yves\Router\Route\RouteCollection
73
     */
74
    protected function addPayoneGetFileRoute(RouteCollection $routeCollection): RouteCollection
75
    {
76
        $route = $this->buildRoute('/payone/getfile', 'Payone', 'Index', 'getFileAction');
77
        $route = $route->setMethods(['GET', 'POST']);
78
        $routeCollection->add(static::ROUTE_PAYONE_GET_FILE, $route);
79
80
        return $routeCollection;
81
    }
82
83
    /**
84
     * @param \Spryker\Yves\Router\Route\RouteCollection $routeCollection
85
     *
86
     * @return \Spryker\Yves\Router\Route\RouteCollection
87
     */
88
    protected function addPayoneCancelRedirectRoute(RouteCollection $routeCollection): RouteCollection
89
    {
90
        $route = $this->buildRoute('/payone/regular-redirect-payment-cancellation', 'Payone', 'Index', 'cancelRedirectAction');
91
        $route = $route->setMethods(['GET']);
92
        $routeCollection->add(static::ROUTE_PAYONE_CANCEL_REDIRECT, $route);
93
94
        return $routeCollection;
95
    }
96
97
    /**
98
     * @param \Spryker\Yves\Router\Route\RouteCollection $routeCollection
99
     *
100
     * @return \Spryker\Yves\Router\Route\RouteCollection
101
     */
102
    protected function addPayoneGetInvoiceRoute(RouteCollection $routeCollection): RouteCollection
103
    {
104
        $route = $this->buildRoute('/payone/getinvoice', 'Payone', 'Index', 'getInvoiceAction');
105
        $route = $route->setMethods(['GET']);
106
        $routeCollection->add(static::ROUTE_PAYONE_GET_INVOICE, $route);
107
108
        return $routeCollection;
109
    }
110
111
    /**
112
     * @param \Spryker\Yves\Router\Route\RouteCollection $routeCollection
113
     *
114
     * @return \Spryker\Yves\Router\Route\RouteCollection
115
     */
116
    protected function addPayoneExpressCheckoutButtonRoute(RouteCollection $routeCollection): RouteCollection
117
    {
118
        $route = $this->buildRoute('/payone/checkout-with-paypal-button', 'Payone', 'ExpressCheckout', 'checkoutWithPaypalButtonAction');
119
        $route = $route->setMethods(['GET']);
120
        $routeCollection->add(static::ROUTE_PAYONE_EXPRESS_CHECKOUT_BUTTON, $route);
121
122
        return $routeCollection;
123
    }
124
125
    /**
126
     * @param \Spryker\Yves\Router\Route\RouteCollection $routeCollection
127
     *
128
     * @return \Spryker\Yves\Router\Route\RouteCollection
129
     */
130
    protected function addPayoneExpressCheckoutInitRoute(RouteCollection $routeCollection): RouteCollection
131
    {
132
        $route = $this->buildRoute('/payone/paypal-express-checkout-init', 'Payone', 'ExpressCheckout', 'initPaypalExpressCheckoutAction');
133
        $route = $route->setMethods(['GET']);
134
        $routeCollection->add(static::ROUTE_PAYONE_EXPRESS_CHECKOUT_INIT, $route);
135
136
        return $routeCollection;
137
    }
138
139
    /**
140
     * @param \Spryker\Yves\Router\Route\RouteCollection $routeCollection
141
     *
142
     * @return \Spryker\Yves\Router\Route\RouteCollection
143
     */
144
    protected function addPayoneExpressCheckoutFailureRoute(RouteCollection $routeCollection): RouteCollection
145
    {
146
        $route = $this->buildRoute('/payone/expresscheckout/failure', 'Payone', 'ExpressCheckout', 'failureAction');
147
        $route = $route->setMethods(['GET']);
148
        $routeCollection->add(static::ROUTE_PAYONE_EXPRESS_CHECKOUT_FAILURE, $route);
149
150
        return $routeCollection;
151
    }
152
153
    /**
154
     * @param \Spryker\Yves\Router\Route\RouteCollection $routeCollection
155
     *
156
     * @return \Spryker\Yves\Router\Route\RouteCollection
157
     */
158
    protected function addPayoneExpressCheckoutBackRoute(RouteCollection $routeCollection): RouteCollection
159
    {
160
        $route = $this->buildRoute('/payone/expresscheckout/back', 'Payone', 'ExpressCheckout', 'backAction');
161
        $route = $route->setMethods(['GET']);
162
        $routeCollection->add(static::ROUTE_PAYONE_EXPRESS_CHECKOUT_BACK, $route);
163
164
        return $routeCollection;
165
    }
166
167
    /**
168
     * @param \Spryker\Yves\Router\Route\RouteCollection $routeCollection
169
     *
170
     * @return \Spryker\Yves\Router\Route\RouteCollection
171
     */
172
    protected function addPayoneExpressCheckoutLoadDetailsRoute(RouteCollection $routeCollection): RouteCollection
173
    {
174
        $route = $this->buildRoute('/payone/expresscheckout/load-details', 'Payone', 'ExpressCheckout', 'loadPaypalExpressCheckoutDetailsAction');
175
        $route = $route->setMethods(['GET']);
176
        $routeCollection->add(static::ROUTE_PAYONE_EXPRESS_CHECKOUT_LOAD_DETAILS, $route);
177
178
        return $routeCollection;
179
    }
180
181
    /**
182
     * @param \Spryker\Yves\Router\Route\RouteCollection $routeCollection
183
     *
184
     * @return \Spryker\Yves\Router\Route\RouteCollection
185
     */
186
    protected function addPayonePaymentSuccessRoute(RouteCollection $routeCollection): RouteCollection
187
    {
188
        $route = $this->buildRoute('/payone/payment-success', 'Payone', 'Index', 'paymentSuccessAction');
189
        $route = $route->setMethods(['GET']);
190
        $routeCollection->add(static::ROUTE_PAYONE_PAYMENT_SUCCESS, $route);
191
192
        return $routeCollection;
193
    }
194
195
    /**
196
     * @param \Spryker\Yves\Router\Route\RouteCollection $routeCollection
197
     *
198
     * @return \Spryker\Yves\Router\Route\RouteCollection
199
     */
200
    protected function addPayonePaymentFailureRoute(RouteCollection $routeCollection): RouteCollection
201
    {
202
        $route = $this->buildRoute('/payone/payment-failure', 'Payone', 'Index', 'paymentFailureAction');
203
        $route = $route->setMethods(['GET']);
204
        $routeCollection->add(static::ROUTE_PAYONE_PAYMENT_FAILURE, $route);
205
206
        return $routeCollection;
207
    }
208
}
209