diff --git a/src/controllers/PaypalController.php b/src/controllers/PaypalController.php index ac2e423..de363b3 100644 --- a/src/controllers/PaypalController.php +++ b/src/controllers/PaypalController.php @@ -12,8 +12,7 @@ use craft\web\Controller as BaseController; use enupal\paypal\contracts\PaypalIPN; -use enupal\paypal\elements\Order; -use enupal\paypal\enums\OrderStatus; +use yii\web\NotFoundHttpException; use enupal\paypal\Paypal; class PaypalController extends BaseController @@ -88,10 +87,10 @@ public function actionIpn() return $this->asJson(['success' => 'true']); } - /** * @return \yii\web\Response - * @throws \HttpException + * @throws NotFoundHttpException + * @throws \Throwable * @throws \yii\base\Exception */ public function actionCompletePayment() @@ -106,8 +105,8 @@ public function actionCompletePayment() if ($txnId){ $order = Paypal::$app->orders->getOrderByPaypalTransactionId($txnId); - if (!$order) { - throw new \HttpException(400, Craft::t('enupal-paypal', 'Can not find the order for missing PayPal transaction id.')); + if (is_null($order)) { + throw new NotFoundHttpException(Craft::t('enupal-paypal', 'Order does not exists')); } $button = $order->getButton();