/** * @param int $tagId * * @throws \Exception * * @return RedirectResponse */ public function destroy(int $tagId) { $deleted = $this->tagRepository->deleteById($tagId); if ($deleted) { $this->webUi->successMessage("Deleted tag with ID `{$tagId}`"); } else { $this->webUi->errorMessage("Failed to delete tag with ID `{$tagId}`"); } return $this->redirectToTagsIndex(); }
/** * @param TelegramMessageRequest $request * * @return JsonResponse */ public function store(TelegramMessageRequest $request) { $content = ['chat_id' => StaffTelegramGroup::id(), 'text' => sprintf('(%s) %s', App::environment(), $request->text())]; try { $message = $this->telegram->sendMessage($content); $this->webUi->successMessage("Sent message `{$message->getMessageId()}` to staff"); } catch (\Exception $e) { $this->webUi->errorMessage(sprintf('Failed to send message to staff: %s (%s)', $e->getMessage(), json_encode($content))); } return $this->webUi->redirect('telegram.index'); }
/** * @param StripePaymentRequest $request * * @throws \Exception * * @return string */ public function payAction(StripePaymentRequest $request) { try { /** @var Order $order */ $order = $this->checkout->pay($request->stripeToken()); } catch (Card $e) { Log::warning(sprintf('Stripe | mess: %s | code: %s | stripe: %s | param: %s', $e->getMessage(), $e->getDeclineCode(), $e->getStripeCode(), $e->getStripeParam())); $this->webUi->errorMessage("Sorry, the card payment was not successful: {$e->getMessage()}"); if (isset($order)) { $order->deAllocate(); } return $this->webUi->redirect('sales.customer.checkout.choose-payment'); } catch (Exception $e) { Log::error($e->getMessage()); $this->webUi->errorMessage('Sorry, something went wrong during payment. Please contact us.'); return $this->webUi->redirect('sales.customer.checkout.choose-payment'); } $this->trackOrder($order); $this->webUi->successMessage('Thank you; your order is confirmed.'); return $this->webUi->redirect('sales.customer.order.view', [$order->publicId()]); }
/** * @return RedirectResponse */ private function failure() { $this->webUi->errorMessage('Something went wrong whilst setting up the PayPal payment. You have not been charged. Please try again.'); return $this->webUi->redirect('sales.customer.checkout.choose-payment'); }