Replies: 3 comments
-
I was kind of able to achieve this in the |
Beta Was this translation helpful? Give feedback.
-
This is a little tricky because the line_items for the Checkout Session are not included in the webhook payload. Reference to the Price ID and the Product ID for each line item purchased on a Checkout Session is only available through the Checkout Session (with expand), not the PaymentIntent or Charge. Here's how I'd solve: checkout_session_id = event.data.object.id
checkout_session = Stripe::Checkout::Session.retrieve({ id: checkout_session_id, expand: ['line_items'] })
checkout_session.line_items.each do |line_item|
# Do stuff to create Things here:
puts line_item.price # Price object
puts line_item.price.product # Product ID (you can change to `expand: ['line_items.data.price.product']` if you want the full product obj)
end |
Beta Was this translation helpful? Give feedback.
-
Thanks for the suggestion @cjavilla-stripe. Using your example I was able to fill out a local That leave's Pay's You can
You can't
I believe there are two things that would help, individually, or together.
FWIW, I'm not complaining about missing functionality if it seems that way. I'm implementing in-app payments for the first time and trying to stay on the golden path if possible. I would love to be wrong 😄 Thanks for your time! I'm happy to mark this as answered, if you believe it to be. 🙏🏻 |
Beta Was this translation helpful? Give feedback.
-
👋 Thank you for the work on this. I have a question related to two previous ones (#443 #460), but I'm still not sure they answer my question after kicking around different ideas on how to solve my issue.
In short, how can I tell which products a user has purchased?
things
Thing
(Stripe Product) through the checkout process. They can also come back later and buy anotherThing
through a second checkout process.user.purchased_things
).I've likely been staring at this too long, and I suspect I have been, because this seems like something this libray should be able to do.
The problem I'm having is that I'm unable to reliably get the associations and ids needed through webhooks or model concern extensions, even when using metadata.
Checkout with metadata
The metadata sent here is only available in the
checkout.session.completed
webhook.Fulfillment in webhooks
stripe.charge.succeeded
metadata
is empty in thestripe.charge.succeeded
webhook.Thing
they bought.stripe.checkout.session.completed
metadata
is available here!User
andThing
, but no way to find what charge is associated with this session.Fullfillment using Extensions/Concerns
metadata
is empty herething_id
Any ideas where I've went astray here? Should metadata passed at checkout time, be available in the
Charge
object and instripe.charge
callbacks?Thanks for your time! 🙏🏻
Beta Was this translation helpful? Give feedback.
All reactions