#Pain - Unset metadata

1 messages ยท Page 1 of 1 (latest)

high granite
#

Hi ๐Ÿ‘‹
Have you tried and empty string ""?

#

Where that gets tricky is what each programming language considers "an empty value"

orchid totem
#

I tried an empty string and it did not work, I tried changing it too.

#

Maybe I did something wrong; I will try again.

high granite
#

Can you share a request ID for one of these requests?

orchid totem
#

I was trying to update the charge metadata instead of the intent where I initially set it; would this not update the charge?

#

Just a moment, going to try and do it again just to make sure I'm not doing something stupid.

high granite
#

You should be able to update the Charge record once it is created

orchid totem
#

Okay so it works if I update the intent

high granite
#

๐Ÿค”

orchid totem
#

I will try again with charge

#

Yeah, seems like it does not work?

#

I am listening to the webhook callpack for charge.succeeded

high granite
#

Interesting. Can you share the request ID of the Payment Intent update that succeeded and the Charge update that failed?

orchid totem
#
await stripe.charges.update(
    data.id,
    {metadata: {renew_subscription: ''}}
)
await stripe.paymentIntents.update(
    data.payment_intent,
    {metadata: {renew_subscription: ''}}
);
#

Top does not work, bottom does

#

The data is just the returned construct from the webhook

 const data = event.data.object;
high granite
#

Sorry I meant the request IDs. I want to file this as odd and those examples will help

orchid totem
#

ch_3LT93SITzJ0aXxz71mSMA070

high granite
#

request IDs have the format req_XXX

orchid totem
#

Oh you want request ID sorry, moment

#

req_3BfqRBdg9UCP5d

high granite
#

perfect, thanks

#

So in that case you provided a key and it looks like the key was not present (or was unset by this request)

#

Are you trying to unset all the keys?

orchid totem
#

My current flow goes as follows:

=> off session charge (currently testing 3D secure)
=> charge fails and I set the metadata
=> return user to website with client_secret and pm
=> they fulfill the payment and I dismiss that metadata

#

No I am only trying to unset that specific one

#

but it's not doing anything

#

It works if I use the intent but does not if I use the charge

#

I'm attempting to unset this piece of metadata once the charge succeeds

rare skiff
#

Hi there ๐Ÿ‘‹ I'm jumping in so @high granite can take a break. I'm pulling up that request and taking a closer look.

#

When I look at the response to that request that you provided, I'm seeing that renew_subscription is not in the metadata returned for the Charge. Are you seeing something different?

orchid totem
#

Oh so it seems like Charge does not share the same payment metadata as the intent?

#

Initial request req_0nCnB8auxbuYXY

#

Second request for confirm req_1SUwFsWUdMOHfS

#

Oh wait, what.. its not in the request but it's still on the dashboard

rare skiff
#

Correct, metadata is not inherently shared between objects in the Stripe ecosystem, it remains on the object where it was set. If you want to sync the metadata between two objects then you will need to build logic to monitor for and handle that.

orchid totem
#

๐Ÿค”

#

I see, so I should update the payment intent where I set it originally

#

Since that works, was a bit confused on why I couldn't do the charge; but that makes sense.

rare skiff
#

Yup, updating that on the Payment Intent, I believe, will adjust what you're seeing in the dashboard.

orchid totem
#

Perfect, thank you for the information.

rare skiff
#

Happy to help!

#

Let me know if that still doesn't seem to do what you're looking for.

orchid totem
#

That was it, it works.

#

I have a question about default source

#

so I currently plan to charge the customers default payment source, what's the best way of getting this?

#

What I'm doing currently since I need the paymentMethods from the customer I'm just expanding on the customer object like so

const paymentMethods = await stripe.customers.listPaymentMethods(
    customer,
    {type: 'card',
    expand: ['data.customer']}
);

then accessing the customer.sources

rare skiff
orchid totem
#

I would have to set their payment method default differently if I want to access the invoice_settings.default_payment_method

#

Currently I just set it as default from the dashboard

#

and it isn't in the customer object

#

but it is in the sources

rare skiff
#

Ah, I'm not sure that the dashboard's default maps to a setting in the API objects.

orchid totem
#

Oh alright, then I will need to use the other path since I need to call the API to set their default payment method

#

as I plan to make the first card they save their default payment method

#

then they can adjust it accordingly if they add other cards

rare skiff
#

Exactly!

orchid totem
#

Would it be possible for stripe to implement something down the line to default saved cards?

#

Something like off_session/confirm - a parameter that would automatically set the card as their default too

#

So another parameter that would be used with setup_future_usage

rare skiff
#

That's a good suggestion and I'll capture it as feedback. Typically we err on the side of caution and provide the tools to do various things but avoid doing too much by default.

rare skiff
#

I've raised that feedback to our teams, though while thinking through it, I think it would be very difficult to implement that type of functionality in a good way. For instance, if you got a scenario where there are three Payment Intents created for a Customer, each one intending to update the default payment method during confirmation, then the order in which those payments are confirmed becomes very important.