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

johnk's avatar
Level 1

Stripe: Must provide source or customer error

I have this form for a payment with Stripe. When the "Pay" is clicked the stripe modal don't appears, user is redirected to "http://proj.test/chargeStripe" and shows : "{ "status": "Must provide source or customer."}".

Form for payment with stripe:


<form action="{{ route('payment.chargeStripe') }}" method="post" id="paymentForm">
    {{csrf_field()}}
    <div id="credit_card_section">
        <span>Please click in "Pay" to pay.</span>
        <input type="hidden" name="stripeToken" id="stripeToken"/>
        <input type="submit" href="" id="payment" class="btn btn-primary" value="Pay"/>
    </div>
</form>

JS:


$(function () {
    alert("test");
    let stripe = StripeCheckout.configure({
        key: "{{config('services.stripe.key')}}",
        image: "",
        locale: "auto",
        token: (token) => {
            document.querySelector('#stripeToken').value = token.id;
        }
    });
});
0 likes
4 replies
johnk's avatar
Level 1

"alert($('#stripeToken').value);" shows "undefined".

Cronix's avatar

Where does token come from?

document.querySelector('#stripeToken').value = token.id;
johnk's avatar
Level 1

From:

 <input type="hidden" name="stripeToken" id="stripeToken"/>
Cronix's avatar

No it doesn't. You're trying to set that value to token.id (see the code I posted of yours). So, where does token.id come from?

Please or to participate in this conversation.