src/controllers/DefaultController.php
public function actionFetchPlans()
    {
        try {
            $this->requirePostRequest();
            $this->requireAcceptsJson();

            $request = Craft::$app->getRequest();
            $gatewayId = $request->getRequiredBodyParam('gatewayId');
            $gateway = Commerce::getInstance()->getGateways()->getGatewayById($gatewayId);

            if (!$gateway || !$gateway instanceof Gateway) {
                throw new BadRequestHttpException('That is not a valid gateway id.');
            }

            return $this->asJson($gateway->getSubscriptionPlans());
        } catch (\Throwable $e) {
            return $this->asErrorJson($e->getMessage());
        }
    }
public function actionFetchPlans()
    {
        try {
            $this->requirePostRequest();
            $this->requireAcceptsJson();

            $request = Craft::$app->getRequest();
            $gatewayId = $request->getRequiredBodyParam('gatewayId');
            $gateway = Commerce::getInstance()->getGateways()->getGatewayById($gatewayId);

            if (!$gateway || !$gateway instanceof Gateway) {
                throw new BadRequestHttpException('That is not a valid gateway id.');
            }

            return $this->asJson($gateway->getSubscriptionPlans());
        } catch (\Throwable $e) {
            return $this->asErrorJson($e->getMessage());
        }
    }
public function actionFetchPlans ( ) { try { $ this -> requirePostRequest ( ) ; $ this -> requireAcceptsJson ( ) ; $ request = Craft :: $ app -> getRequest ( ) ; $ gatewayId = $ request -> getRequiredBodyParam ( 'gatewayId' ) ; $ gateway = Commerce :: getInstance ( ) -> getGateways ( ) -> getGatewayById ( $ gatewayId ) ; if ( ! $ gateway || ! $ gateway instanceof Gateway ) { throw new BadRequestHttpException ( 'That is not a valid gateway id.' ) ; } return $ this -> asJson ( $ gateway -> getSubscriptionPlans ( ) ) ; } catch ( \ Throwable $ e ) { return $ this -> asErrorJson ( $ e -> getMessage ( ) ) ; } }
Load Stripe Subscription plans for a gateway.

@return Response
Load Stripe Subscription plans for a gateway .