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

Mithrandir69's avatar

How to send the input datas in my page to create a product in stripe

I'm intending to create a product in stripe which , stripe product has product name , price id and product ID, so what im trying to do is , when i create a new product from my admin dashboard thee information I have added must go as well to the stripe product :

<form class="form-horizontal" enctype="multipart/form-data" wire:submit.prevent="addProduct">
    <div class="form-group">
        <label class="col-md-4 control-label" >Product Name </label>
        <div class="col-md-4">
            <input type="text" placeholder="Product Name" class="form-control input-md" wire:model="name" wire:keyup="generateSlug"/>
            @error('name') <p class="text-danger">{{$message}}</p>@enderror
        </div>
    </div>
    <div class="form-group">
        <label class="col-md-4 control-label" >Produc tPrice</label>
        <div class="col-md-4">
            <input type="text" placeholder="Account Slug" class="form-control input-md" wire:model="price"/>
            @error('price') <p class="text-danger">{{$message}}</p>@enderror
        </div>
    </div>
<script src="https://code.jquery.com/jquery-3.3.1.js" integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60=" crossorigin="anonymous"></script>
<script>
$(document).ready(function() {
    $('#submit-button').submit(function(e) {
        e.preventDefault();
        $.ajax({
            type: "GET",
            url: '/stripe-product/add',
            data: $(this).serialize(),
        });
    })
})
    </script>

Route web.php:

 Route::get("stripe-product/add", function(){
      return view('stripe-product');
 });

the stripe-product.blade.php:

<?php
\Stripe\Stripe::setApiKey('sk_test_51Jxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');

$product = \Stripe\Product::create([
  'name' => 'TEST',
]);
?>

all i want is to make the added product in my stripe's products have the name and price that i have added

0 likes
1 reply
martinbean's avatar

@mithrandir69 Why on earth are you trying to do this in a view?!

You should be making a POST request to a controller action, and that controller action should then validate the request data and then create it using the Stripe SDK if the data was valid.

Please or to participate in this conversation.