#D4reDev1l.
1 messages · Page 1 of 1 (latest)
Hello! In the Stripe API metadata values are strings, but you can put whatever string you want in there as long as it fits inside the limits. A lot of people put JSON in there, for example.
I want put an object(in red rectangle) into a stripe.subscription object
is this key length limit and value length limit for each key value pairs?
Yes. If you put a JSON string as the value of a metadata key it needs to be less than 500 characters long.
is it 544 x 50 characters in total limit in metadata?
So, it's per key/value. Any given key can be up to 50 characters, and any given value can be up to 500 characters.
40+2+500+2 is the length limit for each key-value pairs
and it supports up to 50 kiey-value pairs
So I think it is (40+2+500+2) * 50
ok
Oh, my bad, yeah, it's 50 keys, and the key length is 40 characters.
Got those mixed up.
To clarify, though, you can have a metadata key like this (40 characters):
0123456789012345678901234567890123456789
And you can have the value be this (500 characters):
01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
And you can have 50 of those key/value pairs on a given Stripe object.
ok
If I have nested object, I have to make sure the total character is below the limit
If the total limit is 5000 in the metadata, I have to make sure the total characters in the metadata is <= 5000
No. Sorry, I think we might be talking past each other. There is no nesting.
Metadata keys and values are strings.
Period.
ok
I can put foo in as a value, or I can put in {"foo": "bar"} as a value, but either way it's just a String as far as Stripe is concerned.
And the maximum length is 500 characters.
Ok
It might be better to talk about what you're trying to accomplish at a higher level. It looks like you want to store some status updates in the metadata? Can you tell me more about that?
sure
Here is what I want to do
currently I have functions do actions to order(rental order)
And I have two types of customer(Stripe.Customer): Borrower and Lender
Stripe.Subscripitons has two status I remember. But I need more states. So I defined more status. like this.
And for each status to change, it can only be altered by either borrower and lender.
And you need to keep the history of all the status changes? Not just the current status?
for now I saved a checking which stage the subscription get
exactly
Is there a maximum number of status changes that can happen for a given Subscription?
and now I need to save at each stage which type of customer change the status to the next status
yes
the status rental_returned altered by either borrower or lender(if borrower forget to click the return button)
lender will change status to returned and then complete
I want to record this process
this two cases showed in the image
Okay, so what I recommend you do is create a JSON object with the largest/longest number of status transitions possible, then determine how many characters that JSON string is. If it's under 500, good times. If it's over 500 you'll need to figure out how you want to break things up.