Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Bacchus's avatar

Cashier Charge method results in Response::setContent error

Hello,

I can toggle this error by commenting or uncommenting the following code:

        try {
            $stripeCharge = auth()->user()->charge((int) number_format($order->total(), 0, "", ""), request('payment-id'));
        } catch (Exception $e) {
            dd($e);
        }

The error is as follows

TypeError
Argument 1 passed to Symfony\Component\HttpFoundation\Response::setContent() must be of the type string or null, object given, called in /Users/jhall/code/projects/dolstore/vendor/laravel/framework/src/Illuminate/Http/Response.php on line 65

The charges are succeeding in Stripe. It is just failing to return an instance of Laravel\Cashier\Payment as it should be. I am not sure what the problem here is.

Thanks!

0 likes
2 replies
Nakov's avatar
Nakov
Best Answer
Level 73

@bacchus is it really failing on this line, or when you try to return from the controller method?

Because if you try this:

$stripeCharge = auth()->user()->charge((int) number_format($order->total(), 0, "", ""), request('payment-id'));
dd($stripeCharge);

I believe it should return an instance of Laravel\Cashier\Payment and the problem should be when you return from the controller as this error:

Symfony\Component\HttpFoundation\Response::setContent()

comes from Laravel.

1 like
Bacchus's avatar

You're right. I successfully got the Payment object when I just had it return a view. It was at the return. Thank you.

Please or to participate in this conversation.