public function actionSubscriptionExpressCreate($price, $modelId = null, $period = 30, $description = null) { if (!Yii::$app->getModule('payment')->enableSubscriptionExpress) { throw new \yii\web\NotFoundHttpException('Page Not Found'); } if ($modelId == 'null') { $modelId = null; } if (!is_null($modelId)) { $model = PaypalSubscriptionExpress::findOne($modelId); $subscription = Yii::$app->getModule('payment')->getPaypalSubscriptionExpress(); $subscription->setAttributes($model->getAttributes()); $subscription->id = $model->id; $subscription->isNewRecord = false; } else { $subscription = Yii::$app->getModule('payment')->getPaypalSubscriptionExpress(); $subscription->period = $period; $subscription->price = $price; } if (empty($subscription)) { throw new \yii\web\NotFoundHttpException('Page Not Found'); } try { if ($subscription->prepareSubscriptionUrl()) { $url = $subscription->paymentUrl; Yii::info('User #' . Yii::$app->user->getId() . ' redirected to paypal with token is "' . $subscription->getToken() . '"', 'payment'); return $this->redirect($url); } } catch (Exception $ex) { throw new \yii\web\NotFoundHttpException('Page Not Found'); } throw new BadRequestHttpException('Something went wrong'); }