I would like to offer 3 products for Subscription and allow the customer to choose one.
Below is the PHP code to create the checkout session.
$result = $stripe->checkout->sessions->create([
'mode' => 'subscription',
'line_items' => [
[
'price' => 'price_ddd',
'quantity' => 1,
],
[
'price' => 'price_eee',
'quantity' => 1,
],
[
'price' => 'price_fff',
'quantity' => 1,
],
],
'customer_email' => $useremail,
'subscription_data' => ['trial_period_days' => 14, 'trial_settings' => ['end_behavior' => ['missing_payment_method' => 'cancel']],],
'ui_mode' => 'embedded',
'payment_method_collection' => 'if_required',
'return_url' => site_url("billing/callback") . "?session_id={CHECKOUT_SESSION_ID}"
]);
The checkout page shows like this:
I need the customer to choose the product from the 3 products. It doest not offer the option choose. It only shows the 3 products.
How to allow it to choose the product?
The Checkout payment page does not support 'cart' functionality, where customers can choose which items to purchase. All Price objects passed to the line_items
parameter on session creation are considered a part of the payment
If you want a pre-built UI component that offers plan selection, I'd recommend looking at the pricing table which utilises Checkout for payment.