'How to send images to Stripe Checkout Session in Laravel 8

I am having issues trying to send images using Stripe Checkout Session, I am using Laravel 8, with the Backpack Admin panel plugin. I am using Stripe's prebuilt checkout page. Here is the controller code for stripe.

Stripe Controller Method:

/* Sends the stripe key, and payment info to the stripe api */
    public function payment() {
        // Initialize the array for stripe checkout session

        $line_items = array();

        foreach (Cart::content() as $item) {
            $product = Product::find($item->id);
            $temp_items = array(
                  'price_data' => [
                    'currency' => 'usd',
                    'product_data' => [
                      'name' => $item->name,
                      'images' => ["http://127.0.0.1:8000/$product->image"],
                    ],
                    'unit_amount' => $item->price * 100,
                  ],
                  'quantity' => $item->qty,
            );

            array_push($line_items, $temp_items);
        }

        // Sets up the businesses secret key to receive the payment
        \Stripe\Stripe::setApiKey(env('STRIPE_SECRET'));

        // Sets up payment method, and product information
        $session = \Stripe\Checkout\Session::create ([
            'payment_method_types' => ['card'],
            'line_items' => [[$line_items]],
            'mode' => 'payment',
            'success_url' => 'http://127.0.0.1:8000/',
            'cancel_url' => 'http://127.0.0.1:8000/cart',
        ]);

        return response()->json(['id' => $session->id]);
    }

Images doesn't show in stripe's prebuilt checkout page: enter image description here

My images are stored in public/uploads

Here is how the database is set up enter image description here

Lastly here is the migrations file for products:

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateProductsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */

     public function up()
     {
        Schema::create('products', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('name')->unique();
            $table->integer('category_id')->unsigned();
            $table->string('slug')->default('');
            $table->double('price', 2);
            $table->string('image')->nullable();
            $table->text('content');
            $table->integer('quantity');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */

    public function down()
    {
        Schema::dropIfExists('products');
    }
}

Ask me if you need any more information.



Solution 1:[1]

Stripe Does not let you show local images, or the ones that you have stored in your disk, try storing those images online and fetching it from there, or some cdn links

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ronak Lala