#Dooing-Subscription
1 messages ยท Page 1 of 1 (latest)
Hi there, you can use subscription if the products require recurring payments.
Does your products need recurring payments or just one-time payments
both
the customer generally wants subscriptions, but the customer can buy one time addons
on top
It really depends on your business. There are many pricing models and you can decide which one fits best to your business https://stripe.com/docs/products-prices/pricing-models
This is not at all helpful. I know there are different models.
- Should I create 3 products, with each having different prices? Or should I simply create 19 different products, wouldnt that be simpler?
- And how to retrieve recurring products / prices vs. one time? MaybeType Service vs Good?
You can create many prices under one product. When you create a price, you can also set a recurring (https://stripe.com/docs/api/prices/create?lang=node#create_price-recurring) components if this price requires recurring payments, otherwise it's one-time.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I know I can. The question is, what is recommended. In the end, all I need is a price. So is it better to use many prices under one product, or just several products, each having one price?
second, I know there are recurring and one time payments. I am trying to retrieve the products / prices from the api, and I found a type parameter SERVICE vs GOOD. But I did not fine RECURRING vs. ONE_TIME. So my question is, that the one and the same, or do I need a different selector to only retrieve recurring / one time prices?
I prefer creating prices under one product, that's what I'll do, but you need to test it out and see if this suits your business.
https://stripe.com/docs/api/prices/list?lang=node#list_prices-type here's the param you can pass to filter recurring / one time prices.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Thanks.
Is there wa way, I can retrieve the list of all products, and for each product, the list of its available prices?
I searched the api and tried in code, but I did not find any such option.
It seems, I can ask the price for the product it belongs to.. but I assume to make this work I'd need to add some expand?
And while this may be one possibility.. it woul dbe much better to have all products to iterate over, with their prices attached, then, the other way round...
(because in the ui, you'd iterate over each product, and the list its prices)
https://stripe.com/docs/api/products/list?lang=node#list_products you can use this API to get a list of products
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Once you select a product, you can call the list_prices API with the product ID (https://stripe.com/docs/api/prices/list?lang=node#list_prices-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.
Are you saying, there is no other way then to call the prices api for each product, so calling the prices api multiple times?
Wouldnt it then be more efficent to retrieve the list of prices, and ask for the product of each price?
DO I need to add an expand?
Or you just make a API call to list_prices (https://stripe.com/docs/api/prices/list?lang=node#list_prices) and expand the product field, so you have both products and prices data
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
yes, and how can I expand it?
expand:["data.product"]
For a subscription, that is currently in creation... and has a trial... can I call
.addExpand("latest_invoice.payment_intent")
on the subscription, to get the payment intent secret so the frontend can confirm a payment method added?
will answer that one in a sec
yes you can do that
For retrieving a list of products... how can I define - get me only the RECURRING products vs get me only the one time products?
I assume:
.setType(ProductListParams.Type.SERVICE)
and .setType(ProductListParams.Type.GOODS)
?
you can't
ah actually you can
it's https://stripe.com/docs/api/prices/list#list_prices-type with recurring or one_time. Please ignore that Service/Good stuff for Products as it's not relevant. You're listing Prices anyway, not Products, so it's doubly not relevant.
just try it in test mode, much faster than asking here.
aaaah! So that means, at least theoretically, you could have / setup a PRODUCT, that has BOTH - recurring AND one time prices attached to it.
just try it in test mode, much faster than asking here
Yes /.
yes / no. Yes only when you know what you know ๐
I am in my code, and using the client library... so then I am looking for the methods... and if I dont find a method for recurring.. because I am on product not price,... then
running my not compiling code wont help either
Hey, taking over here. Let me know if there's any follow-up Qs I can answer!
actually all answered.. here's a new one -
there are products and prices - in the api, I can see BOTH have metadata. In the dashboard however, I cant seem to find metadata for prices? How to add them>
When creating a new product or price from the dashboard you can't specify metada, but after editing in the dashboard you can add them
https://dashboard.stripe.com/prices/price_...
Could you describe what flow you did, and what error you got ? so that I can reproduce
I went into the dashboard
created a product with a price
edited the price
no meta data existing
Could you share a screenshot on what you are seeing in the dashboard page of the price details
https://dashboard.stripe.com/prices/price_
This popup is for editing the price, you need to look at the page showing the details of the price
๐ taking over for my colleague. Let me know if there's any follow-up Qs I can answer!
THanks Tarzan.
The above is closed, but we have another issue now, and perfect to talk to you.. as it is related to our last discussion.
shoot
public SubscriptionSetupDTO setupSubscription(String stripeCustomerId, String stripePriceId, Long endOfTrialTimestamp) {
try {
SubscriptionCreateParams subCreateParams = SubscriptionCreateParams.builder()
.addItem(SubscriptionCreateParams.Item.builder()
.setPrice(stripePriceId)
.build())
.setCustomer(stripeCustomerId)
.setTrialEnd(endOfTrialTimestamp)
.setPaymentBehavior(SubscriptionCreateParams.PaymentBehavior.DEFAULT_INCOMPLETE)
.setPaymentSettings(SubscriptionCreateParams.PaymentSettings.builder()
.setSaveDefaultPaymentMethod(SubscriptionCreateParams.PaymentSettings.SaveDefaultPaymentMethod.ON_SUBSCRIPTION)
.build())
.addExpand("latest_invoice.payment_intent")
//.addExpand("pending_setup_intent")
.build();
Subscription subscription = Subscription.create(subCreateParams, requestOptions);
String subscriptionId = subscription.getId();
String clientSecret = subscription.getLatestInvoiceObject()
.getPaymentIntentObject()
.getClientSecret();
return SubscriptionSetupDTO.of(subscriptionId, clientSecret);
} catch (StripeException e) {
throw new StripeExternalException(e);
}
}
this is now what we do for a subscription with a trial
we need the payment intent, the UI tellss us
but since it is a trial.. there is no payment object yet, since this is what we are trying to confirm in the first place
so we get a NullPointer Exception
that's why we discussed using pending_setup_intent that you commented out
yeah we did
this works in the backend.
but it will throw an exception in the UI
Uncaught (in promise) IntegrationError: Invalid value for stripe.confirmCardPayment intent secret: value should be a PaymentIntent client secret. You specified: a SetupIntent client secret.
because if you do remember we've also discussed this, on the front-end you either use confirmCardPayment for PaymentIntent or confirmCardSetup for SetupIntent
oh ok a different method
yes
no I dont remember
no worries
but I will forward to the UI guy ๐
I know it's been a while since our long discussion about this
it's good to keep the url of that thread somewhere safe #dev-help message
did you manage to make it work?
I forwarded the info to the UI guy
and I think he is currently in his lunch break
the link... no idea what it si
is
it's our previous conversation here in discord
not fully.. but I found th thread to click on, inside your link, ok