クラス
RedirectRoutes
Declares all redirect routes for WCEX Amazon Pay
ソース ソース
ファイル: src/Routing/RedirectRoutes.php
class RedirectRoutes extends RequestKeyRouter { /** * Amazon Pay module object * * @var AmazonPay */ private $module; /** * Instantiates `RequestKeyRouter` * * @author Evan D Shaw <evandanielshaw@gmail.com> * @param AmazonPay $module */ public function __construct(AmazonPay $module) { $this->module = $module; parent::__construct('/wcexaap'); } /** * Declares request key routes * * @author Evan D Shaw <evandanielshaw@gmail.com> * @param WordPressRouteCollector $r * @return void */ public function declareRoutes(WordPressRouteCollector $r) { $login = new LoginWithAmazon($this->module); $r->addPublicRoute('GET', '/loginWithAmazon', [$login, 'memberPageLogin']); // Welcart normal checkout redirect routes $r->addGroup('/checkout/welcart', function (WordPressRouteCollector $r) { // middleware $middleware = new Middleware(); $amazonMiddleware = new AmazonMiddleware($this->module); // route guards $routeGuards = new RedirectRouteGuards($this->module, new RestRouteGuards($this->module)); $amazonRouteGuards = new AmazonRedirectRouteGuards($this->module); $r->addPublicRoute( ['POST', 'GET'], '/payandship/once/review', function () { (new Views\ConfirmPageReview\Factory())->getInstance($this->module)->init()->addHooks(); }, [ $amazonRouteGuards->sessionIdExistsOrExit(), $amazonMiddleware->putGetCheckoutSessionResponseInSession(), $amazonMiddleware->setDeliveryDataWithCheckoutSession(true), $middleware->updateWelcartEntries(), $routeGuards->addressCheck(), ] ); $r->addPublicRoute( ['POST', 'GET'], '/payonly/once/review', function () { (new Views\ConfirmPageReview\Factory())->getInstance($this->module)->init()->addHooks(); }, [ $amazonRouteGuards->sessionIdExistsOrExit(), $amazonMiddleware->putGetCheckoutSessionResponseInSession(), ] ); }); // QuickPay redirect routes $r->addGroup('/checkout/quickpay', function (WordPressRouteCollector $r) use ($login) { // handlers $payAndShipCartReview = (new Views\CheckoutReview\PayAndShip\Factory())->getInstance($this->module); $payOnlyCartReview = (new Views\CheckoutReview\PayOnly\Factory())->getInstance($this->module); $dlsellerLogin = (new Views\CustomerPage\Factory())->getInstance($this->module); // route guards $routeGuards = new RedirectRouteGuards($this->module, new RestRouteGuards($this->module)); $amazonRouteGuards = new AmazonRedirectRouteGuards($this->module); // middleware $middleware = new Middleware(); $amazonMiddleware = new AmazonMiddleware($this->module); $payAndShipOnceMiddlewares = [ $amazonRouteGuards->sessionIdExistsOrExit(), $routeGuards->cartNotEmptyOrExit(), $routeGuards->itemsInStockOrCartRedirect(), $login->loginWithAmazonCheckoutSession(), $amazonMiddleware->setPaymentMethodToAmazonPay(), $amazonMiddleware->putGetCheckoutSessionResponseInSession(), $amazonMiddleware->setCustomerDataWithCheckoutSession(true), $amazonMiddleware->setDeliveryDataWithCheckoutSession(), $middleware->updateWelcartEntries(), $routeGuards->addressCheck(), $middleware->updateFees(), $middleware->setOrderConditions(), $middleware->setMemberPoints(), $routeGuards->dlsellerLoginRedirect(), ]; $payOnlyOnceMiddlewares = [ $amazonRouteGuards->sessionIdExistsOrExit(), $routeGuards->cartNotEmptyOrExit(), $routeGuards->itemsInStockOrCartRedirect(), $login->loginWithAmazonCheckoutSession(), $amazonMiddleware->setPaymentMethodToAmazonPay(), $amazonMiddleware->putGetCheckoutSessionResponseInSession(), $amazonMiddleware->setCustomerDataWithCheckoutSession(false), $amazonMiddleware->payOnlyClearDeliverySession(), $middleware->updateWelcartEntries(), $middleware->updateFees(), $middleware->setOrderConditions(), $middleware->setMemberPoints(), $routeGuards->dlsellerLoginRedirect(), ]; $r->addPublicRoute( ['POST', 'GET'], '/dlsellerLogin', [$dlsellerLogin, 'loadPage'], [$routeGuards->quickPayRedirectOnLoginSuccess()] ); $r->addPublicRoute( ['POST', 'GET'], '/payandship/once/review', [$payAndShipCartReview, 'loadPage'], $payAndShipOnceMiddlewares ); $r->addPublicRoute( ['POST', 'GET'], '/payonly/once/review', [$payOnlyCartReview, 'loadPage'], $payOnlyOnceMiddlewares ); }); } }
- __construct — Instantiates RequestKeyRouter
- declareRoutes — Declares request key routes