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

Giesen's avatar

Laravel Cashier: Error This customer has no attached payment source

Today, I want to integrate Cashier/Stripe into Laravel. I have created to plans: basic and premium. Basic with trail period and premium with no trail period.

The request of the basic package is successful but the premium is unsuccessful. I get the following error.

InvalidRequest in ApiRequestor.php line 98:
This customer has no attached payment source

at ApiRequestor->handleApiError('{ "error": { "type": "invalid_request_error", "message": "This customer has no attached payment source" } } ', '400', array('Server' => 'nginx', 'Date' => 'Mon, 17 Aug 2015 20:06:43 GMT', 'Content-Type' => 'application/json', 'Content-Length' => '120', 'Connection' => 'keep-alive', 'Access-Control-Allow-Credentials' => 'true', 'Access-Control-Allow-Methods' => 'GET, POST, HEAD, OPTIONS, DELETE', 'Access-Control-Allow-Origin' => '*', 'Access-Control-Max-Age' => '300', 'Cache-Control' => 'no-cache, no-store', 'Request-Id' => 'req_6oWwzseRdGbsQW', 'Stripe-Version' => '2015-08-07'), array('error' => array('type' => 'invalid_request_error', 'message' => 'This customer has no attached payment source'))) in ApiRequestor.php line 210

After some searching on the internet I see a post what says that the customer first need to have a creditcard. When I check the customer in stripe the customer didn't have any creditcards attached. That is the reason why it doesn't work.

In the view I add the following code:

<form action="/payment" method="POST">
        <input type="hidden" name="_token" value="{{ csrf_token() }}">
        <script
                src="https://checkout.stripe.com/checkout.js" class="stripe-button"
                data-key="pk_test_o9JyNbaftcr3ueztXphHXDR9"
                data-amount="2000"
                data-name="Demo Site"
                data-description="2 widgets ($20.00)"
                data-image="/128x128.png">
        </script>
    </form>

But when I enter the form I supply the test creditcard information (4242 4242 4242 4242). Does somebody know why the Stripe form doesn't create the card information?

Controller:

    public function handle(PostPayment $payment)
    {
        $user = User::find(Auth::user()->id);

        $user->subscription('premium')->create($payment->get('creditCardToken'));

        return 'done';

    }

Does somebody has a idea why it doesn't work? Thank you already if you take a look at this.

0 likes
1 reply
ericlbarnes's avatar

Just from your code I think you might be mixing things up. Your stripe form looks to be a one time purchase where in your controller you are trying to assign a subscription.

Here is the type of form I believe you need: https://stripe.com/docs/tutorials/forms

Also for the This customer has no attached payment source I have seen that before and I believe for new subscriptions the cause is your StripeToken is not set and your Stripe customer doesn't already have a credit card on file.

You can probably dd($payment->get('creditCardToken')) in your controller to verify that.

2 likes

Please or to participate in this conversation.