laravel - How to fix Stripe InvalidRequest Exception - Invalid array exception? (PHP)

one text

I'm trying to make Controller for checkouts on my eshop, Stripe returns InvalidRequestException. It worked when it was hardcoded, it doesn't now.

This is function in my controller:

public function checkoutSession(){
        \Stripe\Stripe::setApiKey('api_key');

        $YOUR_DOMAIN = 'http://example.com';

        $line_items = array();

        foreach(Cart::content() as $row){
          $product_data = ['name' => $row->name];
          $price_data = ['currency' => 'eur', 'unit_amount' => intval($row->price * 100), 'product_data' => $product_data];
          $line = ['price_data' => $price_data, 'quantity' => $row->qty];
          array_push($line_items, $line);
        }

        $checkout_session = \Stripe\Checkout\Session::create([
            'payment_method_types' => ['card'],
            'line_items' => $line_items,
            'mode' => 'payment',
            'success_url' => $YOUR_DOMAIN . '/success.html',
            'cancel_url' => $YOUR_DOMAIN . '/cancel.html',
          ]);

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

This is the response:

Stripe\Exception\InvalidRequestException: Invalid array in file /Users/radoslavkuchar/iSell/vendor/stripe/stripe-php/lib/Exception/ApiErrorException.php on line 38

And this is $line_items array:

[{"price_data":{"currency":"eur","unit_amount":399,"product_data":{"name":"Test product"}},"quantity":2}]

Any help?

Source