admin管理员组

文章数量:1291643

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?

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?

Share Improve this question edited Feb 13 at 14:35 DarkBee 15.6k8 gold badges72 silver badges116 bronze badges asked Feb 13 at 14:17 arun kumararun kumar 7372 gold badges15 silver badges38 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

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.

本文标签: phpChoose a product from 3 products with trialStack Overflow