#gecko-metadata-problem

1 messages · Page 1 of 1 (latest)

wintry hawk
#

👋 @rough herald what do you need help with?

rough herald
#

hi there

#

'req_z5LYUpLpFpBMKx',

#

I'm getting an error that it must be a string

#

I'm in a create-checout-session

#

and trying to figure out if this is a problem with meadata, or with response URLs

wintry hawk
#

can you share your code?

rough herald
#

I thought i had this working....

wintry hawk
#

basically you're not passing metadata properly

rough herald
#
        metadata: [
            {
                'cid': `${cid}`,
            },
            {
                'sid': `${sid}`,
            },
            {
                'tier': `${tier}`,
            },
            {
                'price': `${price}`,
            },
        ],
        ```
#

as I understood it takes an array of key/val pairs

wintry hawk
#

yep remove those curly brackets!

rough herald
#

no objects?

wintry hawk
#

line_items is an "array of objects" where each line item is an object so you pass line_items: [ {price: 'price_123', quantity: 1}, {price: 'price_456', quantity: 1}]

rough herald
#

that's literally what I have

#

If I remove the braces, then they're not objects

wintry hawk
#

but metadata is an "array of keys" or a hash (every language has their own vocabulary) so you do metadata: [ 'key1': 'value1', 'key2': 'value2']

#

and yeah since you use node you want a hash sorry

#

so for you you want metadata: { 'cid': `${cid}`, 'sid': `${sid}`, 'tier': `${tier}`, 'price': `${price}`, },

rough herald
#

yes that's it, works fine now, thanks! I think I copied the model from line_items or something

#

didn't realize that it's not an array of objects for metadata

#

one last question....when the session returns, metadata is still available, yes?

wintry hawk
#

yes and it's in the checkout.session.completed event too!

#

and yeah metadata is a bit "weird"

rough herald
#

great, thanks, then I don't have to have those in my response URL's, I can extract from metadata, which was what I hoped

#

thx for great advice as always....Stripe support is really the best!