Hi All
I need to be able to post to Stripe to create a subscription with a variable number of subscription items. This works for a single subscription item:
Example:
Price = £30, quantity = 3
https://api.stripe.com/v1/subscriptions?customer=cus_4QFOF3xrvXXXXXX&[items][0][price]=price_1MufTPAu7gwy5xPpeKXXXXXX&[items][0][quantity]=3
If I have, say 5 items to create, how can I update this string to show the 3 items?
Example:
Price = £25, quantity = 2
Price = £40, quantity = 5
Price = £15, quantity =7
It needs to happen in a single call rather than 3 separate calls adding items to the subscription. The quantity is also unknown, could be 1 or could be 87 so I can’t hard code anything on the basis of a known number of items.
Thanks
you can create a list, first by making a parameter in your Jason body, and then when you call it. give it a list of order and on that use ** :format as text ** and inside it make you Jason object.
something like below
{ price: current item price ,
quantity: current item quantity
}
if you stuck, do tag me i would love to help you out.
That makes sense. How would I pre-pend (to each item in the list) both the text that’s required for the call “[items][n]” where “n” is the position of the item in the list?
You you elaborate you question little bit sir.
when you convert a list in to text it give you a window you can add static text and dynamic for each item.
Hi Baloshi - I now get how to use the format text function. What I can’t work out is how to get the number of items. If I have a list of 5 items, I need to tell Stripe I have 5 items by listing them as follows:
[items][0]price=100
[items][1]price=80
[items][2]price=15
[items][3]price=120
[items][4]price=30
There could be 3 items, or 30 items, I can’t be sure when creating the call, so I need to populate the number in bold for each item.
Hope that makes sense?
you can do a search for that item to get a count, i have no idea of you app structure, but doing a lot of work on front end will make you app slow, i suggest backend on each and every bulky work.