Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/Http/Controllers/PaymentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use Laravel\Cashier\Cashier;
use Laravel\Cashier\Http\Middleware\VerifyRedirectUrl;
use Laravel\Cashier\Payment;
use Stripe\Exception\InvalidRequestException as StripeInvalidRequestException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

class PaymentController extends Controller
{
Expand All @@ -25,12 +27,18 @@ public function __construct()
*
* @param string $id
* @return \Illuminate\Contracts\View\View
*
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
*/
public function show($id)
{
$payment = new Payment(Cashier::stripe()->paymentIntents->retrieve(
$id, ['expand' => ['payment_method']])
);
try {
$payment = new Payment(Cashier::stripe()->paymentIntents->retrieve(
$id, ['expand' => ['payment_method']])
);
} catch (StripeInvalidRequestException $exception) {
throw new NotFoundHttpException;
}

$paymentIntent = Arr::only($payment->asStripePaymentIntent()->toArray(), [
'id', 'status', 'payment_method_types', 'client_secret', 'payment_method',
Expand Down