#Louis Daubié
1 messages · Page 1 of 1 (latest)
I am not sur to understand, i try something like this actually :
const setupIntent = await stripe.setupIntents.create({
customer: customer.stripeCustomerId,
metadata: {
cardName,
},
});
Yes this should work.
But i got nothing in metadata when i log the result of :
await stripe.paymentMethods.list({
customer: customer.stripeCustomerId,
type: 'card',
});
I mean, you forgot to set a key to your metadata:
metadata: {
key: "value",
},
cardName is a key..
In your case:
metadata: {
cardName: cardName,
},
and value i am using js
Then the value is missing. You need to pass both a key and a value. https://stripe.com/docs/api/metadata
futhermore i try with this, same result :
const setupIntent = await stripe.setupIntents.create({
customer: customer.stripeCustomerId,
metadata: {
test: 'test',
},
});
Looks correct to me. Can you share the SetupIntent ID?
This is the SetupIntent ID, and we can see the metadata here: seti_1MxnRMJOEn8vXy6hwD8NAQFk
So what is the issue?
when i log the metadata it's empty
await stripe.paymentMethods.list({
customer: customer.stripeCustomerId,
type: 'card',
});
You are checking the Payment Method here, but you set the metadata on the SetupIntent.
If you want the metadata on the PaymentMethod, then you need to set it yourself.
So i need to do an other api call for add the metadata ?
Because actualy the front end use the client_secvret generate by the paymentItent on the back and send the data directly to stripe
So i need to do an other api call for add the metadata ?
If you want themetadatato be directly on the PaymentMethod object, yes.
Another option is to expand thegenerated_from.setup_intentfield, this way you can see the metadata of the SetupIntent directly https://stripe.com/docs/api/payment_methods/object#payment_method_object-card-generated_from
ok thanks