This question is about Stripe java (or REST) api, currently version 2019-05-16 .
We have created one product manually through stripe dashboard and have attached three plans to it, one for monthly, quarterly and yearly payments respectively.
Now if I try to get this product through the REST api (same result using stripe-java
) by doing:
curl https://api.stripe.com/v1/products/prod_...... \
-u sk_test_........:
I get indeed the product object described in the documentation , which has no plans
attribute on it.
However, if I inspect the requests made by the stripe
dashboard itself while visiting the products' page, I can see that in this case the products are indeed retrieved with their respective plans
attached to it (see "plans" in image below right bottom corner). So I guess the dashboard is using another api, perhaps a more convenient one.
My question is, how can I get all the plans of a product given its product id
? I guess I can get instead all the plans and then filter by product id
effectively getting what I want, however this looks to me more like a hack. What are the best practices here?
Why the dashboard api would be different in any case? Thanks all of you in advance.
According to the documentation you can list all the plans filtered by the product:
https://stripe.com/docs/api/plans/list#list_plans-product
Adding the product id as parameter:
curl https://api.stripe.com/v1/plans?product=prod_id ...
product optional
Only return plans for the given product.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.