#DevOPS-subscriptions

1 messages ยท Page 1 of 1 (latest)

manic pond
#

Hi there!

#

Do you want to add the add-ons when you create the subscription, or at a later date?

digital palm
#

Yes, I want to add add-ons but users have option to select add-ons while they subscribe any plans

manic pond
digital palm
#

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

manic pond
#

So you want to always have two subscriptions in the Checkout Session, and optionally add one add-ons?

digital palm
#

No, it's optional for user user can select if they want

manic pond
#

Which part is optional?

digital palm
#

user will subscribe at list one plane, second plan and add-ons will be optional

#

and I've two add-ons

manic pond
#

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.

digital palm
#

yes, exactly. do you've any suggestion or can you guide me how can i manage in one session?

manic pond
#

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.

digital palm
#

you mean I can add multiple price in checkout session ??

ashen crater
#

๐Ÿ‘‹ taking over for @manic pond

#

yes you can add multiple items

digital palm
#

Okay, thank you let me proceed with that. ๐Ÿ‘

ashen crater
#

let me know if you need any more help

digital palm
#

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'), ]);

ashen crater
#

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'),
                ]); 
digital palm
#

yes, but this one item have monthly subscription and second one is only one time payment

#

how can I manage payment mode ??

ashen crater
#

you'd put mode 'subscription'

digital palm
ashen crater
#

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.

digital palm
#

But it's apply subscription for both items

#

In my case One item have subscription and another item have one time payment

ashen crater
#

oh my bad we're not using products you already created but a product_data

#

you need to specify that the price is recurring

digital palm
#

$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?

ashen crater
#

seems so but does the price/product etc. are correct?

digital palm
#

yes

#

mode = payment is right?

ashen crater
#

no it's mode 'subscription'

#

but you're using the same product name and the same price for both

digital palm
#

let me proceed and check if it's work or not