#krava77 - multiple subscriptions

1 messages ยท Page 1 of 1 (latest)

small orioleBOT
tawny flint
#

We don't have built in functionality to do this. With some custom code you may be able to do something similar. My first instinct would be to add invoice items that represent the other subscriptions and then when the invoice is paid you can just create other subscriptions for that customer with the first month paid or a 100% off for one cycle coupon

#

krava77 - multiple subscriptions

twin barn
#

I need assistance with my Clipboard tax refund for 2022

languid badge
#

@tawny flint THank you for the answer. I can't add recurring prices to the checkout session if it has payment_mode is not subscription. But If I add products with type=onetime payment, I can't use them for creating subscriptions after payment.

tawny flint
#

Yeah, you won't be able to have the Checkout Session do all of this automatically. My idea was basically you can have those type=onetime payment items and on a successful payment your server would check what items were on that checkout session, and create a new subscription with a recurring price for whichever one time items you had that represented a subscription

languid badge
#

@tawny flint I thought so. Let me reproduce this way.
Another way to resolve this issue is the creation of one checkout session with multiple subscription items. It's possible, but I don't know, how to start subscription items on different dates.

#

Is it possible before or after the payment change dates of subscription items?

tawny flint
#

Unfortunately not. When you use a Checkout Session, all subscription items would go on the same subscription. You could do that and then just remove those items from the subscription and create a new one that starts in the future

#

Without a schedule, you can just give each subscription a trial that ends at some point in the future. But those will generate trial invoices so they may be confusing to users

languid badge
#

@tawny flint Could you advise please, what is wrong with my request array?
{
"items": {
"price_data": {
"tax_behavior": "exclusive",
"recurring": {
"interval": "month",
"interval_count": "1"
},
"unit_amount": "6462",
"currency": "usd",
"product_data": {
"metadata": {
"documenttype": "project",
"itemid": "521",
"documentid": "95",
"invoiceid": "514"
},
"name": "Remote Treatment"
}
},
"tax_rates": {
"0": "txr_1MRghOIPaUukacQEGWlZf79Y"
},
"quantity": "1"
},
"customer": "cus_NC4rgOiX9R93kO"
}

#

Response body:
{ "error": { "message": "Invalid array", "param": "items", "request_log_url": "https://dashboard.stripe.com/test/logs/req_6XyBVmKiWPNxRG?t=1678133316", "type": "invalid_request_error" } }

wispy sundial
#

๐Ÿ‘‹ hey there just stepping in for my teammate

#

give me a few minutes ๐Ÿ‘

#

Ah, that items looks like its an object {} and the outer value needs to be an array/list []

languid badge
#

@wispy sundial Sorry, it's not clear for me. What is look like an object?

wispy sundial
#

'items' => [ ['price' => 'price_123' ] ],

languid badge
#

@wispy sundial
I'm using price _data instead of price and price_data looks like an array.
I tried wrapping price_data as an array but no luck. Could you explain, what is wrong?
$arr['items'] = [ 'quantity' => $item->quantity, 'tax_rates' => [ 'txr_1MRghOIPaUukacQEGWlZf79Y' ], [ 'price_data' => [ 'currency' => $item->price->currency, 'unit_amount' => $item->price->unit_amount, 'tax_behavior' => 'exclusive', 'recurring' => [ 'interval' => 'month', 'interval_count' => 1 ], 'product' => $item->price->product->id ] ] ];

wispy sundial
#

in your case you need to set items => [ [ price_data => [ ... ], quantity => 3, ... ] ]

#

Note the outer [ ... ] for the list, and the inner [] for each item object

languid badge
#

@wispy sundial But doesnโ€™t it look like you described?
here is the result:

wispy sundial
#

Is that your code?

#

What is the very outer Array for?

languid badge
#

this is the result of my code. the code is in the previous message.

wispy sundial
#

Ohhh

#

It looks like you have your quantity and tax_rates outside your items[0] object

languid badge
wispy sundial
#

They should be sibling to price_data

#

Move quantity and tax_rates inside that [ opening right before price_data

languid badge
#

You're are the Rock Star ๐Ÿ˜Ž
Many thanks!

#

@wispy sundial may I use product_data array inside price_data instead of product id ?
I'd like to create a new product with the new subscription.

#

I just see product field in the description, but in the session checkout it allows create product and price with the new subscription.

wispy sundial
#

Checkout supports that, yes, but create subscription requests do not, no.

languid badge
#

@wispy sundial the checkout manual told that I can put product ID, and not create a new product. But it allows do it via product_data variable.
I don't see any mentions about product_data variable in the checkout manual, but it's working. Why such a strange behavior?
https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-line_items-data-price-product

tiny sorrel
languid badge
#

@tiny sorrel may I use a product, that I created by checkout session, for creating a new subscription?

tiny sorrel
#

Yep, that should be possible

languid badge
#

hmmm ... Stripe marked the product as inactive after the checkout payment. What did I do wrong?

#

@tiny sorrel

#

here is the project object. Maybe it will help

tiny sorrel
#

Ah, looks like the product that was created during the Checkout Session is actually not editable/updatable, so can't be used to create a subscription

languid badge
#

@tiny sorrel May I create a product in such a way that it is not immediately archival in checkout payment?

tiny sorrel
#

It looks like the only way to do this is to create a product in advance (not using product_data)

languid badge