#peppemu-metadata

1 messages ยท Page 1 of 1 (latest)

proven barn
#

Hi there ๐Ÿ‘‹ metadata can only hold string-based key/value pairs.

atomic storm
#

hi toby

#

all right

#

so just to make sure I get this right

#

I share a quick example

#

can I do this (links are strings) :

metadata[payment_links][0], link_0)
metadata[payment_links][1], link_1)
metadata[payment_links][2], link_2)
etc...

#

??

proven barn
atomic storm
#

all right, thanks

#

then I have a followup questin

#

cause I am not able to do what I just wrote in that example ๐Ÿฅถ

#

let me add some more info

#

I am using this (and I know the i is missing after [metadata])

#

let urlencoded_update_product = new URLSearchParams();

for (let i = 0; i < list.length; i++){
let link = list[i]
urlencoded_update_product.append("metadata[payment_links]",link);
}

#

and I then use the urlencoded_update_product in the body of the api call

#

now, how can u add the index of each item that's coming from a list ?

proven barn
#

Add the index where?

atomic storm
#

as in:
metadata[payment_links][0], link_0
metadata[payment_links][1], link_1

proven barn
#

It's up to you how you structure your data. Looking at your above examples though I want to point out that keys need to be unique values.

atomic storm
#

so I cant have an array of payment links in the metadata?

proven barn
#

Sure, but you'll need a layer that remaps them from an array to a dictionary. Or use the index as the key (though that may make retrieving the information from the Stripe object more tedious).

atomic storm
#

all right and then I would just do:

metadata[payment_links], dictionary

instead of goin through all the items ?

proven barn
#

If you're passing entire URLs, then I suspect your entire dictionary won't fit within the 500 character limit.

What are you actually trying to accomplish here? It sounds like you're trying to save payment links on an object, but would you mind clarifying what type of object and why?

atomic storm
#

sure

#

I want to store in the product metadata all the payment links of that product

proven barn
#

Is that the only thing you're planning to store in the products metadata?

atomic storm
#

yea that\s most important bit I need

#

there is a thread I had with one of your colleagues where you can see how and why we came up with this

#

not sure how I can share it iwth u

proven barn
#

If you're not using metadata on the product for anything else, then you can use the key to map to the index of your array:

1: <second_payment_link,
...}```
atomic storm
#

that's exactly what I want to do

#

but it does not work whne I try it

#

and it gives me an error

#

I am not sure how to set the index given that I am pulling the items using a loop

#

like if I do this:

#

for (let i = 0; i < list.length; i++){
let link = list[i]
urlencoded_update_product.append("metadata[payment_links]["+i+"]",link);
}

#

i get an error....

#

and I cant find any example in your documentation...

proven barn
#

What error do you get? this looks like code that runs on your side, what are you actually sending to Stripe?

atomic storm
#

do you have any link to your documentation to see how to add a dictionary to metadata ?

proven barn
#

No, because our metadata is a series of string-based key/value pairs, so it already is a dictionary. Do you have a request ID (req_XXX) from a request that errored? It'll give us more insight into exactly what you're sending us.

atomic storm
#

the code I pasted above is what I am sending

#

where list = a list of payment links

proven barn
#

Yeah that's not right. You can't pass structured data into metadata like that. You need to decompile it and pass it in as a string-key matched to a string-value, as shown in the code snippet in the metadata documentation that I linked earlier. Is that Node you're working with?

atomic storm
#

ah ah ok, thanks toby

#

that's already a big news for me ๐Ÿ™Œ๐Ÿฝ

#

I saw the documentation but I am still not sure how i can actually do that

solar lynx
#

@atomic storm hey there just stepping in for @proven barn ๐Ÿ‘‹ . do you need more help with this, or is that a sufficient pointer for you to restructure your metadata to get what you need?

atomic storm
#

hi there

#

I am looking into this

#

I am gonna test a few more things and then see

#

is this the only way I can achieve what I'd like to have ?

#

ignore the "payment_links" please

solar lynx
#

Yep you can create a pseudo-array by appending numbers like that if you like ๐Ÿ™‚

#

As long as metadata is a flat object with string keys/values

atomic storm
#

I see