#Adi - checkout events
1 messages · Page 1 of 1 (latest)
That sounds reasonable, but I can't say if you're missing something because only you have all the context for what your business needs.
Let me flip things around: are you having any issues or cases you're missing and unable to track?
If so, please explain, and I can perhaps offer guidance on how to track those
checkout.session.completed doesn't actually complete payment fulfillment is this right?
so if I want to email customer that payment is successful and card was charged successfully then is checkout.session.completed sufficient or no?
That depends on whether you have automatic receipt emails turned on for successful payments
If you want to send your own receipts then yea you'd want to use that event
but does this event checkout.session.completed guarantee payment was successful or is there any other event which I have to listen to?
You can check the payment status but yes the payment should have succeeded by that point
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
So I am doing something like this: (Note: I am using payment_status === paid check)
case 'checkout.session.completed': {
const session = event.data.object;
// Save an order in your database, marked as 'awaiting payment'
// Check if the order is paid (for example, from a card payment)
//
// A delayed notification payment will have an `unpaid` status, as
// you're still waiting for funds to be transferred from the customer's
// account.
if (session.payment_status === 'paid') {
try {
const { customer_email, customer: customer_id, subscription: subscription_id, metadata, currency } = session;
const { user_id, price_id } = metadata;
const filter = { user_id: user_id };
const update = {
email: customer_email,
price_id: price_id,
currency: currency,
subscription_id: subscription_id,
customer_id: customer_id,
subscription_plan: priceIdAndPlanMapping[price_id]
};
const options = { upsert: true };
await users.findOneAndUpdate(filter, update, options);
} catch (error) {
console.error("checkout.session.completed error: ", error)
}
}
break;
}
is this ok? or any suggestions/recommendations?