I have a problem when I want to integer Stripe on my project in Symfony. I use Stripe v.9.5.0 and I have a different errors when I implement "unit_amount" for Stripe
I have a OrderController:
$product_for_stripe = []; $YOUR_DOMAIN = 'https://localhost:8000/';
//Enregister sur mon entity Order_details
foreach ($cart->getFull() as $product) {
$orderDetails = new OrderDetails();
$orderDetails->setMyOrder($order);
$orderDetails->setProduct($product['product']);
$orderDetails->setQuantity($product['quantity']);
$orderDetails->setPrice($product['product']->getPrix());
$orderDetails->setTotal($product['product']->getPrix() * $product['quantity']);
$this->entityManager->persist($orderDetails);
$product_for_stripe[] = [
'price_data' => [
'currency' => 'eur',
'product_data' => [
'name' => $product['product']->getName(),
'images' => $product['product']->getImage()
],
'unit_amount' => $orderDetails->getPrice(),
],
'quantity' => $product['quantity'],
];
}
//$this->entityManager->flush();
Stripe::setApiKey('sk_test_51LiLoMDGYOFHKYepnY3xMBT5vwMJWH2XR3ntN9GpHXYtapN29AvQVty21GPUx0qVa2J6MWFr69ke3Yq1p3MJL1yV00kCU59YvE');
$checkout_session = Session::create([
'line_items' =>
[$product_for_stripe],
'mode' => 'payment',
'success_url' => $YOUR_DOMAIN . '/success.html',
'cancel_url' => $YOUR_DOMAIN . '/cancel.html',
]);
dump($checkout_session->id);
dd($checkout_session);
When I want debug $checkout_session I have this error:
"Invalid integer: 532.46"
I have tried "round($orderDetails->getPrice())" for "unit_amount" and I have this error:
"Invalid array"
I'm blocked, it's a project for my degree in school, if somebody can help me and have a solution , I would be happy.
Thank you
I'm sorry for my bad english