#krava77 - multiple subscriptions
1 messages ยท Page 1 of 1 (latest)
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
I need assistance with my Clipboard tax refund for 2022
@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.
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
@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?
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
We also have schedules for scheduling a subscription to start in future which you may find useful here https://stripe.com/docs/billing/subscriptions/subscription-schedules/use-cases
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
@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" } }
๐ 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 []
@wispy sundial Sorry, it's not clear for me. What is look like an object?
'items' => [ ['price' => 'price_123' ] ],
@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 ] ] ];
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
@wispy sundial But doesnโt it look like you described?
here is the result:
this is the result of my code. the code is in the previous message.
Ohhh
It looks like you have your quantity and tax_rates outside your items[0] object
They should be sibling to price_data
Move quantity and tax_rates inside that [ opening right before price_data
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.
Checkout supports that, yes, but create subscription requests do not, no.
@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
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
@languid badge stepping in for my teammate! You're looking at the Session object, not the create endpoint: https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items-price_data-product_data
@tiny sorrel may I use a product, that I created by checkout session, for creating a new subscription?
Yep, that should be possible
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
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
It's listed as archived: https://dashboard.stripe.com/test/products/prod_NTiXM2QtcW12VL
@tiny sorrel May I create a product in such a way that it is not immediately archival in checkout payment?
It looks like the only way to do this is to create a product in advance (not using product_data)
@tiny sorrel may I create a product for the subscription that it won't visible in the a product dashboard area?
https://dashboard.stripe.com/test/products