#farfa7886
1 messages ยท Page 1 of 1 (latest)
Hello! Can you clarify what you mean by "it doesn't get sent"?
Do you have an example request ID I can take a look at?
In this code
switch (event.type) {
case "payment_intent.succeeded":
const paymentIntentSucceeded = event.data.object;
console.log(paymentIntentSucceeded.metadata.userId);
try {
let userData = await User.findById(
paymentIntentSucceeded.metadata.userId
);
userData.balance += Number(paymentIntentSucceeded.metadata.amount);
userData.markModified("balance");
await userData.save();
} catch (err) {}
break;
default:
console.log(`Unhandled event type ${event.type}`);
}```
When the request is made via the CLI I can access the `paymentIntentSucceeded.metadata` object, but when using the code above the `metadata` object is empty
evt_3O83iZIoOgSh9ZaU2eL1pmiO
๐ let me take a look
Ah, that's the event for the Payment Intent - is your goal to set metadata on the checkout session that'll be automatically set on the Paymetn Intent?
i guess yeah
im still new to stripe ๐
in the docs there is written that I can attach a metadata object but the object becomes null when payment intent succeeded
If you want the metadata to be on the Paynment Intent you'll need to use payment_intent_data.metadata instead (https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-payment_intent_data-metadata)