#merino-checkout-subscriptiondata

1 messages · Page 1 of 1 (latest)

cunning jungleBOT
ivory rapids
#

Supp TS, hope you're doing well...
So my code literally is:

  const session = await stripe.checkout.sessions.create({
    billing_address_collection: 'auto', //(auto -> Stripe pega qnd necessário / required ->sempre pega)
    line_items: [{price:price_id_flat, quantity:1},{price:price_id_credits}
    // line_items: [{price:price_id_flat},
    ],
    customer: customer.data[0].id,
    mode: 'subscription',
    success_url: process.env.VUE_APP_URL + '/success?session_id={CHECKOUT_SESSION_ID}',
    cancel_url: process.env.VUE_APP_URL+ '/cancel?session_id={CHECKOUT_SESSION_ID}',
    subscription_data:plan,
  });
#

This last line subscription_data:plan,

#

I've wrote it in a lot of ways and I can't seem to get it to work

#

Which should be something like subscription_data.metadata:plan right?

twilit reef
#

Hi apologies for the wait. The server is busy. Circling back to this now

ivory rapids
#

Np dude

loud oak
#

@ivory rapids do you have an example request id req_123 of the error for me to look at?

#

it should be returned in the error in the response

#

merino-checkout-subscriptiondata

ivory rapids
#

(node:2569) UnhandledPromiseRejectionWarning: Error: Received unknown parameter: subscription_data.metadata. Did you mean subscription_data? at Function.generate (/home/andre_merino/signup/node_modules/stripe/lib/Error.js:38:24) at res.toJSON.then.StripeAPIError.message (/home/andre_merino/signup/node_modules/stripe/lib/RequestSender.js:104:43) at processTicksAndRejections (internal/process/task_queues.js:97:5) (node:2569) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)

#

I couldn`t find it

#

That was the last error I`ve got

#

is the rejection at the endå

#

?

loud oak
#

can you give me an example cs_test_123 you created successfully?

#

I can work backwards from it

ivory rapids
#

I didn`t had a single successfull checkout session created with this parameter

loud oak
#

I mean without the parameter

#

once I have an example id in your account I can find your logs and show you

#

So if you can give me a cs_test_123 before you tried to use metadata, or a Customer id cus_123 for example I can then look it up

ivory rapids
#

req_D81DyVL4e3EWmx

#

Like this?

loud oak
#

yep perfect, let me have a look

ivory rapids
#

ok

loud oak
#

can you share your exact code?

ivory rapids
#

Sure

loud oak
#

like what you attempted last, and then I can show you how to tweak it

ivory rapids
#
const session = await stripe.checkout.sessions.create({
    billing_address_collection: 'auto', //(auto -> Stripe pega qnd necessário / required ->sempre pega)
    line_items: [{price:price_id_flat, quantity:1},{price:price_id_credits}
    // line_items: [{price:price_id_flat},
    ],
    customer: customer.data[0].id,
    mode: 'subscription',
    success_url: process.env.VUE_APP_URL + '/success?session_id={CHECKOUT_SESSION_ID}',
    cancel_url: process.env.VUE_APP_URL+ '/cancel?session_id={CHECKOUT_SESSION_ID}',
    subscription_data.metadata:plan,
  });

#

Except for the subscription_data everything was working fine

loud oak
#

okay so you want this instead: subscription_data: { metadata: { my_plan_id: plan, } }

#

like metadata are a dictionary of key/value pairs. And everything in our API needs to be passed with the right "nesting"

ivory rapids
#

Thaaank you very much

#

I didn't realize I couldn't use the dot

#

Actually I did, but everything I tried was wrong lol

#

Thanks dude, have a good one

loud oak
#

yeah it's a bit annoying until you get why

#

quick question: why did you say "sup TS"?

#

I got thrown off by this (weirdly it's my team's name's acronym lol)

ivory rapids
#

'cuz in the begging it was two-shoes who was sent here by dingo the bot xD

loud oak
#

BAHAHAHAHA

#

we both were like "wait how did that person know, what's going on"

ivory rapids
#

And you guys alredy helped me a lot xP

ivory rapids