#cyau.was.here

1 messages · Page 1 of 1 (latest)

unique flameBOT
viral orchid
#

hi! yes, there is no such thing as price_data.product_data for Subscription Create API. You need to create a Product first and pass its ID within price_data , or create a Price first as well and pass that.

also i'd like those subs to not have any price on them but still to be in stripe's records, any way how?
not sure what this means overall, but the Subscription API requires a Price to be passed, and Prices require/are based on a Product.

#

it's the exact same for Checkout, it just has a shortcut to create the Product, but it's the same thing, you just have to make an extra API call to create the Product.

cinder lance
#

but why when i pass price_data.product_data to subscription data on checkout session, it doesnt make a product..? (because stripe.products.list() gives [])

viral orchid
#

it creates it as a sort of ad-hoc product that exists but isn't returned in list calls yep

cinder lance
#

well is there any way to do that outside of checkout..?

viral orchid
#

nope

cinder lance
#

well that's sad

#

is it possible to make checkout and then just mark it as completed so it turns into sub somehow?

viral orchid
#

not sure what you mean by that exactly. Checkout has a UI and the customer needs to visit that and enter payment information etc.

#

that's the only way to complete the CheckoutSession and have it create a Subscription object.

#

what problem are you trying to solve?

cinder lance
#

users purchase product with checkout, and i'd like to give product to someone for free, but while keeping them somewhere saved (ideally in stripe), so whenever i want to revoke access, i'd just cancel that subscription in stripe and via webhooks it would get revoked

#

or different scenario, i have multiple different subscription tiers (plans) which arent stored in stripe but always made on session create, and when i want to switch tier of someone i just edit metadata, but i can't switch anyone from free to any tier because that would mean i have to create subscription for them

viral orchid
#

not sure I 100% follow.

I'd note that Checkout fully supports free trial periods(and free trials without collecting payment details if that's what you need) https://stripe.com/docs/payments/checkout/free-trials ; if that works better for you than manually creating the Subscription object on the backend.

cinder lance
#

yeah but that free trial would then need to be indefinite

#

not sure if seeing code logic would help you, but look, this is my way of changing x user from plan 1 to plan 2, or canceling their sub

viral orchid
cinder lance
#

not sure what you mean with that

viral orchid
#
const session = await stripe.checkout.sessions.create({
  mode: 'subscription',
  line_items: [
    {
      price: "price_1OUSQjJoUivz182D3gkKGijH", // $0/month
      // For metered billing, do not pass quantity
      quantity: 1,
    },
  ],
  // {CHECKOUT_SESSION_ID} is a string literal; do not change it!
  // the actual Session ID is returned in the query parameter when your customer
  // is redirected to the success page.
  success_url: 'https://example.com/success.html?session_id={CHECKOUT_SESSION_ID}',
  cancel_url: 'https://example.com/canceled.html',
  payment_method_collection:"if_required"
});
cinder lance
#

well yeah but the main thing for me is to avoid user having to go through that session if they are being billed 0$

viral orchid
#

ok. Then sure, create the objects directly on the backend if that's what you need such as the Subscription create call you mentioned at the start. You will need to create Product/Price objects to use Subscriptions, it's just how our Billing product is modelled