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

acoustic85's avatar

Stripe charging is not working

Hi everyone,

I am trying to charge a card with stripe but for some reason after I submit the pager is showing me only blank page.

This is my controller :

 public function store(Request $request) 
   {
       try {

        

        $charge = Stripe::charges()->create([
            'amount' => Cart::total() / 100,
            'currency' => 'CAD',
            'source' => $request->stripeToken,
            'description' => 'Order',
            'receipt_email' => $request->email,
            'metadata' => [
                
            ],
        ]);

          //success
          return back()->with('success_message', 'Thank you! Your payment has been successfully accepted!');
       } catch(Exception $e) {

       }
   }


and this is my blade:

    <form action="{{ route('checkout.store') }}" method="POST" id="payment-form">
              @csrf
              <h2>Billing Address</h2>
               <div class="form-group">
                 <label for="email">Email address</label>
                 <input type="email" class="form-control" id="email" name="email" value="">
              
               </div>

               <div class="form-group">
                <label for="name">Name</label>
                <input type="text" class="form-control" id="name" name="name" value="">
             
              </div>


              <div class="form-group">
                <label for="address">Address</label>
                <input type="text" class="form-control" id="address" name="address" value="">
             
              </div>

           <div class="half-form">
              <div class="form-group">
                <label for="city">City</label>
                <input type="text" class="form-control" id="city" name="city" value="">
             
              </div>


              <div class="form-group">
                <label for="province">Province</label>
                <input type="text" class="form-control" id="province" name="province" value="">
             
              </div>
            </div><!--- end halfform--->  


             <div class="half-form">

              <div class="form-group">
                <label for="postalcode">Postal Code</label>
                <input type="text" class="form-control" id="postalcode" name="postalcode" value="">
             
              </div>

              <div class="form-group">
                <label for="phone">Phone</label>
                <input type="text" class="form-control" id="phone" name="phone" value="">
             
              </div>


            </div><!--- end halfform -->


            <div class="spacer"></div>

            <h2>Payment Details</h2>
             <div class="form-group">
                 <label for="name_on_card">Name on card</label>
                 <input type="text" class="form-control" id="name_on_card" name="name_on_card" value="">

             </div>

             <div class="form-group">
                  <label for="card-element">Credit or debit card</label>
                  <div id="card-element">

                  </div>

                  <div id="card-errors" role="alert"></div>

                  <div class="spacer"></div>

                 
             </div>

             <button type="submit" class="button-primary full-width">Complete Order</button>

            </form>

I have set my keys in the .env file as well but its not working. Any help will be appreciated.

0 likes
0 replies

Please or to participate in this conversation.