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

erenergul's avatar

Stripe Token Error !

This is my view code

            <form action="{{route('payment.store')}}" method="POST" id="payment-form">
                {{csrf_field()}}
                <span class="payment-errors"></span>

                <div class="form-row">
                    <label>
                        <span>Card Number</span>
                        <input class="form-control" type="text" size="20" data-stripe="number">
                    </label>
                </div>

                <div class="form-row">
                    <label>
                    <span>Expiration (MM/YY)</span>
                    <input class="form-control" type="text" size="2" data-stripe="exp_month">
                    <span> / </span>
                    <input class="form-control" type="text" size="2" data-stripe="exp_year">
                    </label>
                </div>

                <div class="form-row">
                    <label>
                        <span>CVC</span>
                        <input class="form-control" type="text" size="4" data-stripe="cvc">
                    </label>
                </div>

                <input type="submit" class="submit thm-btn" value="Submit Payment">
            </form>

And this is my controller. When I use dd(); for token. It returns null.

{
        // your secret key: remember to change this to your live secret key in production
        // See your keys here: https://dashboard.stripe.com/account/apikeys
        \Stripe\Stripe::setApiKey("sk_test_1QiGpAEaK2pEWeXemc6HIMRE");


        dd($token = $request->stripeToken);

        // Create a charge: this will charge the user's card
        try {
            $charge = \Stripe\Charge::create(array(
                "amount" => Cart::total() * 100, // Amount in cents
                "currency" => "usd",
                "source" => $token,
                "description" => "Example charge"
            ));
        } catch (\Stripe\Error\Card $e) {
            // The card has been declined
        }

    }

I am sorry. I am new on laravel. I checked stripe error logs too.

And Error looks like :

Parsed Request POST Body

{ "amount": "12100", "currency": "usd", "description": "Example charge" } Response body

{ "error": { "type": "invalid_request_error", "message": "Must provide source or customer." } }

I don't know why. If someone help. I will be grateful.

0 likes
14 replies
fraserk's avatar

Are you sure the $token is getting the correct stripeToken?

erenergul's avatar

Sorry Guys.

I fixed it. I think its about api key. I just update my api key and wait little bit and It worked. I don't understand why but it works without any change. Thank you for help

mannai's avatar

@fraserk hey , accually im facing same error and when i try printing it with dd(...) i see it is null

mannai's avatar

@fraserk sorry , but i have the same code as erenergul

this is the view

        <span class="payment-errors"></span>

        <div class="form-row">
            <label>
                <span>Card Number</span>
                <input type="text" size="20" data-stripe="number">
            </label>
        </div>

        <div class="form-row">
            <label>
                <span>Expiration (MM/YY)</span>
                <input type="text" size="2" data-stripe="exp_month">
                <span> / </span>
                <input type="text" size="2" data-stripe="exp_year">
            </label>
        </div>

        <div class="form-row">
            <label>
                <span>CVC</span>
                <input type="text" size="4" data-stripe="cvc">
            </label>
        </div>


        <input type="submit" class="submit button success" value="Submit Payment">
    </form>
    </div>
</div>

and this is the controller

// Set your secret key: remember to change this to your live secret key in production // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey("sk_test_0Uex74Tgikui4g7esQLg8NEy");

// Get the credit card details submitted by the form $token = $request->stripeToken;

// Create a charge: this will charge the user's card try { $charge = \Stripe\Charge::create(array( "amount" => Cart::total()*100, // Amount in cents "currency" => "usd", "source" => $token, "description" => "Example charge" )); } catch (\Stripe\Error\Card $e) { // The card has been declined }

fraserk's avatar

@mannai this is usually an issue with the Api Key. Check and make sure you using the correct ApiKey

mannai's avatar

@fraserk , i checked the ApiKey and still have the same problem even i create another stripe account but same, this is the test data POST /v1/charges 2017/04/27 16:46:02 Summary

ID: req_AYLV0SsASWNHhO Time: 2017/04/27 16:46:02 Method: POST URL: /v1/charges Status: 400 IP address: 197.9.6.143 Version: 2017-04-06 (latest) Source: Stripe/v1 PhpBindings/4.8.1

Parsed Request Query Parameters No query parameters Parsed Request POST Body

{ "amount": "10500", "currency": "usd", "description": "Example charge" }

Response body

{ "error": { "type": "invalid_request_error", "message": "Must provide source or customer." }

fraserk's avatar

@mannai Well that's the issue. dd($request->all()) you you have a stripToken key?

1 like
mannai's avatar

yep i have this array:1 [▼ "_token" => "u0AH5A3sm71e6ejurUKw7JDZpYCTrNgU0cE7p3Dp" ]

fraserk's avatar

no, you should should have a stripeToken, that is what you need to charge the customer

1 like
johnlight's avatar

Hi , i have the same error with stripeToken ?

Please or to participate in this conversation.