関数
RestRoutes::declareRoutes( WCEXAAP\Aivec\WordPress\Routing\WordPressRouteCollector $r )
Contains declarations for all routes
パラメータ パラメータ
- $r
(WCEXAAP\Aivec\WordPress\Routing\WordPressRouteCollector) (必須)
ファイル: src/Routing/RestRoutes.php
public function declareRoutes(WordPressRouteCollector $r) { // REST handlers $coupon = new API\Coupon(); $fees = new API\Fees(); $points = new API\Points(); $deliverym = new API\DeliveryMethod(); $register = new API\RegisterWithAmazon(); $syncaccount = new API\SyncAmazonAccount(); $settlementInfo = new Admin\API\SettlementInfo($this->module); $refund = new Admin\API\Refund($this->module); $capture = new Admin\API\Capture($this->module); $cancel = new Admin\API\Cancel($this->module); $ipn = new Admin\API\IPN($this->module); $linkmember = new API\LinkMembersToAmazon(); // route guards $routeGuards = new RestRouteGuards($this->module); // middleware $middleware = new Middleware(); $adminMiddleware = new Admin\API\Middleware($this->module); // REST admin editor wc_management routes $r->add( 'POST', '/admin/getSettlementInfo/{orderId}', [$settlementInfo, 'get'], [$adminMiddleware->isOrderAssociated()], [], ['administrator', 'editor', 'wc_management'] ); $r->add( 'POST', '/admin/refund/{orderId}/{refundAmount}', [$refund, 'post'], [$adminMiddleware->isOrderAssociated()], [], ['administrator', 'editor', 'wc_management'] ); $r->add( 'POST', '/admin/capture/{orderId}/{captureAmount}', [$capture, 'post'], [$adminMiddleware->isOrderAssociated()], [], ['administrator', 'editor', 'wc_management'] ); $r->add( 'POST', '/admin/cancel/{orderId}', [$cancel, 'delete'], [$adminMiddleware->isOrderAssociated()], [], ['administrator', 'editor', 'wc_management'] ); $r->addAdministratorRoute('POST', '/admin/registerIPNEndpoint', [$ipn, 'register']); // REST public routes $r->post('/member/updateAmazonLoginOption/{sync:[0-1]}', [$syncaccount, 'updateSyncMeta']); $r->post('/useCoupon', [$coupon, 'useCoupon'], [$middleware->updateWelcartEntries()]); $r->post('/resetCoupon', [$coupon, 'resetCoupon'], [$middleware->updateWelcartEntries()]); $r->post('/usePoints', [$points, 'usePoints'], [$middleware->updateWelcartEntries()]); $r->post('/updateFees', [$fees, 'updateFees'], [$middleware->updateWelcartEntries()]); $r->post('/updateDeliveryMethod', [$deliverym, 'update'], [$routeGuards->deliveryMethodCheck()]); $authAndCapture = API\CheckoutSession\Update::$authorizeWithCapture; $authOnly = API\CheckoutSession\Update::$authorize; $paymentIntent = $this->module->captureOnPurchase() ? $authAndCapture : $authOnly; // normal Welcart checkout $r->addGroup('/checkout/welcart', function (WordPressRouteCollector $r) use ($middleware, $routeGuards, $paymentIntent) { $payAndShipOnce = new API\CheckoutSession\Create( $this->module, $this->module->redirectRoutes->createPublicQueryUrl( '/checkout/welcart/payandship/once/review', USCES_CART_URL, ['confirm' => 1] ) ); $payOnlyOnce = new API\CheckoutSession\Create( $this->module, $this->module->redirectRoutes->createPublicQueryUrl( '/checkout/welcart/payonly/once/review', USCES_CART_URL, ['confirm' => 1] ) ); $cartUpdate = new API\CheckoutSession\Update( $this->module, add_query_arg(['wcexaapCompletePurchase' => 1], USCES_CART_URL), false, $paymentIntent ); $r->post('/payandship/once/createSession', [$payAndShipOnce, 'post']); $r->post('/payonly/once/createSession', [$payOnlyOnce, 'post']); $r->post( '/payandship/once/updateSession/{id}', function (array $args) use ($cartUpdate) { $cartUpdate->setSettlementType('payandship'); return $cartUpdate->patch($args); }, [ $middleware->updateWelcartEntries(), $routeGuards->cartNotEmptyCheck(), $routeGuards->itemsInStockCheck(), $routeGuards->addressCheck(), ], [$middleware->saveOrderActingData()] ); $r->post( '/payonly/once/updateSession/{id}', function (array $args) use ($cartUpdate) { $cartUpdate->setSettlementType('payonly'); return $cartUpdate->patch($args); }, [ $middleware->updateWelcartEntries(), $routeGuards->cartNotEmptyCheck(), $routeGuards->itemsInStockCheck(), ], [$middleware->saveOrderActingData()] ); }); // QuickPay checkout $r->addGroup('/checkout/quickpay', function (WordPressRouteCollector $r) use ( $middleware, $routeGuards, $paymentIntent, $register, $linkmember ) { $payAndShipOnce = new API\CheckoutSession\Create( $this->module, $this->module->redirectRoutes->createPublicQueryUrl( '/checkout/quickpay/payandship/once/review', USCES_CART_URL ) ); $payOnlyOnce = new API\CheckoutSession\Create( $this->module, $this->module->redirectRoutes->createPublicQueryUrl( '/checkout/quickpay/payonly/once/review', USCES_CART_URL ) ); $cartUpdate = new API\CheckoutSession\Update( $this->module, add_query_arg(['wcexaapCompletePurchase' => 1], USCES_CART_URL), false, $paymentIntent ); $r->post('/payandship/once/createSession', [$payAndShipOnce, 'post']); $r->post('/payonly/once/createSession', [$payOnlyOnce, 'post']); $r->post( '/payandship/once/updateSession/{id}', function (array $args) use ($cartUpdate) { $cartUpdate->setSettlementType('payandship'); return $cartUpdate->patch($args); }, [ $middleware->updateWelcartEntries(), $routeGuards->cartNotEmptyCheck(), $routeGuards->itemsInStockCheck(), $routeGuards->deliveryMethodCheck(), $routeGuards->addressCheck(), $routeGuards->giftShippingCustomerAddressCheck(), $routeGuards->customFieldsCheck(), $register->registerNewMemberIfRequired(), $register->setOrderGetPointIfNewMember(), $linkmember->saveLinkWithYourAmazonAccount(), ], [$middleware->saveOrderActingData()] ); $r->post( '/payonly/once/updateSession/{id}', function (array $args) use ($cartUpdate) { $cartUpdate->setSettlementType('payonly'); return $cartUpdate->patch($args); }, [ $middleware->updateWelcartEntries(), $routeGuards->cartNotEmptyCheck(), $routeGuards->itemsInStockCheck(), $routeGuards->customOrderFieldsCheck(), $linkmember->saveLinkWithYourAmazonAccount(), ], [$middleware->saveOrderActingData()] ); }); }