#DevOPS-subscriptions
1 messages ยท Page 1 of 1 (latest)
Hi there!
Do you want to add the add-ons when you create the subscription, or at a later date?
Yes, I want to add add-ons but users have option to select add-ons while they subscribe any plans
So you want the Checkout Session UI to offer some add-ons to customers? If so you could try cross-sell: https://stripe.com/docs/payments/checkout/cross-sells
yes,
Let me review cross-sells if it's work for me.
thank you for your help
Can we add only one add-ons with cross-sell?
I want allow 2 subscription with one add-ons with same transaction
So you want to always have two subscriptions in the Checkout Session, and optionally add one add-ons?
No, it's optional for user user can select if they want
Which part is optional?
user will subscribe at list one plane, second plan and add-ons will be optional
and I've two add-ons
I just did a quick test, and it looks like you can only add a single item as a cross sell.
So if you want to give more options to your customer, that's something that you'll need to handle on your website/app, before redirecting customers to the Checkout Session URL.
yes, exactly. do you've any suggestion or can you guide me how can i manage in one session?
That's completely up to you. You create some kind of form on your website/app to show multiple payment options to your customer. And after they choose, you create a Checkout Session with the correct parameters (like multiple recurring price and some one-off price), and finally redirect the customer to the Checkout Session URL to pay.
you mean I can add multiple price in checkout session ??
Okay, thank you let me proceed with that. ๐
let me know if you need any more help
Yes, can you provide me a example for add multiple price in checkout session?
I've to add multiple price with different payment mode, subscription and one time
Here is my checkout session
$session = \Stripe\Checkout\Session::create([ 'line_items' => [[ 'price_data' => [ 'currency' => 'aud', 'product_data' => [ 'name' => $post['membership_type'] . ' Membership', ], 'unit_amount' => $price * 100, ], 'quantity' => 1, ]], 'customer_email' => $post['email'], 'mode' => 'payment', 'success_url' => URL::to('success'), 'cancel_url' => URL::to('cancel'), ]);
you need a second hash in line_items
'line_items' => [[
'price_data' => [
'currency' => 'aud',
'product_data' => [
'name' => $post['membership_type'] . ' Membership',
],
'unit_amount' => $price * 100,
],
'quantity' => 1,
],[
'price_data' => [
'currency' => 'aud',
'product_data' => [
'name' => $post['membership_type'] . ' Membership2',
],
'unit_amount' => $price2 * 100,
],
'quantity' => 1,
]],
'customer_email' => $post['email'],
'mode' => 'payment',
'success_url' => URL::to('success'),
'cancel_url' => URL::to('cancel'),
]);
yes, but this one item have monthly subscription and second one is only one time payment
how can I manage payment mode ??
you'd put mode 'subscription'
But how can define mode for each item?
something like:
'line_items' => [[
'price_data' => [
'currency' => 'aud',
'product_data' => [
'name' => $post['membership_type'] . ' Membership',
],
'unit_amount' => $price * 100,
],
'quantity' => 1,
],[
'price_data' => [
'currency' => 'aud',
'product_data' => [
'name' => $post['onetime'],
],
'unit_amount' => $price2 * 100,
],
'quantity' => 1,
]],
'customer_email' => $post['email'],
'mode' => 'subscription',
'success_url' => URL::to('success'),
'cancel_url' => URL::to('cancel'),
]); ```
from https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items
For subscription mode, there is a maximum of 20 line items with recurring Prices and 20 line items with one-time Prices. Line items with one-time Prices in will be on the initial invoice only.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
But it's apply subscription for both items
In my case One item have subscription and another item have one time payment
oh my bad we're not using products you already created but a product_data
you need to add this https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items-price_data-recurring
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
you need to specify that the price is recurring
$session = \Stripe\Checkout\Session::create([ 'line_items' => [[ 'price_data' => [ 'currency' => 'aud', 'product_data' => [ 'name' => $post['membership_type'] . ' Membership', ], 'unit_amount' => $price * 100, 'recurring'=>[ 'interval'=>'month' ] ], 'quantity' => 1, ],[ 'price_data' => [ 'currency' => 'aud', 'product_data' => [ 'name' => $post['membership_type'] . ' Membership', ], 'unit_amount' => $price * 100, ], 'quantity' => 1, ]], 'customer_email' => $post['email'], 'mode' => 'payment', 'success_url' => URL::to('success'), 'cancel_url' => URL::to('cancel'), ]);
is it right?
seems so but does the price/product etc. are correct?
no it's mode 'subscription'
but you're using the same product name and the same price for both
yes, I updated it
let me proceed and check if it's work or not