#yelseW
1 messages · Page 1 of 1 (latest)
hello! can you share your current code snippet where you're creating the subscription?
curl https://api.stripe.com/v1/subscriptions \
-u sk_test_x: \
-d customer=cus_y \
-d "items[0][price]"=price_z
pass in payment_behavior=default_incomplete
Cheers!
That worked (no error) but the pending_setup_intent is still returning null
the pending_setup_intent is returning null, cause the subscription has a non-zero amount to pay
if you're looking for the client_secret to collect payment for a non-zero subscription, you should look at the payment_intent
I'm looking to create a "draft" with that first incomplete subscription, which I can then continue to update, so that amount is not yet finalised
is there a reason why the amount is not yet finalized?
Because we want to be able to update it if customer intends to upgrade/get something else
the general idea is to have finalized everything already, then create the subscription
I initially tried to do that using an invoice, but I can't add a subscription price id to an invoice. Is there another way for that?
I was planning to use the subscription/invoice object stripe provides to get the pricing summary instead of a manual calculation outside of stripe
you don't add a subscription price id to an invoice, you would do it the other way round - add the one time price to a Subscription :https://stripe.com/docs/api/subscriptions/create#create_subscription-add_invoice_items
But the subscription product already has a price, I just want to add that to a draft invoice
you cannot add a first payment for a Subscription to a draft invoice
And there are no drafting capabilities for a subscription?
I was planning to use the subscription/invoice object stripe provides to get the pricing summary - what you would want to use here is the upcoming invoice API : https://stripe.com/docs/api/invoices/upcoming
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
then once the user has confirmed what they want, you would create a Subscription
you would pass in the Subscription item here : https://stripe.com/docs/api/invoices/upcoming#upcoming_invoice-subscription_items
and the one off items here : https://stripe.com/docs/api/invoices/upcoming#upcoming_invoice-invoice_items
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
With a customer that has no existing subscription, there isn't an upcoming invoice I can use though, am I understanding it wrongly?
you can preview creating a subscription with this API also - https://stripe.com/docs/api/invoices/upcoming#upcoming_invoice-subscription
The identifier of the subscription for which you’d like to retrieve the upcoming invoice. If not provided, but a subscription_items is provided, you will preview creating a subscription with those items....
Sorry, could I get an example for using subscription_item with GET /invoices/upcoming?
what language are you using?
This was my guess, but it gave an error of "No such invoice: 'upcoming'"
curl https://api.stripe.com/v1/invoices/upcoming\?customer=cus_x \
-u sk_test_y \
-d "subscription_items[]"=prod_z
Just curl for now
curl https://api.stripe.com/v1/invoices/upcoming \
-u sk_test_xxx: \
-d subscription_items[0][price]=price_xxx \
-d customer=cus_xxx \
-X GET
And to create an actual subscription can I leverage that, or should I just create a Subscription with the same subscription items?
to create a actual subscription you should call https://stripe.com/docs/api/subscriptions/create
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Yup, I understand creating an actual subscription separately, but will we be able to create an actual subscription from the earlier upcoming-invoice-subscription?
upcoming invoice subscription is a preview, i don't understand what you mean by creating an actual subscription from the earlier upcoming invoice subscription
If we want to go from preview to actual, is there a create_subscription_from_preview or do I just create a subscription normally, independent from the preview, using the same subscription items?
you create a subscription normally, independent from the preview, using the same subscription items