Replies: 3 comments
|
I was kind of able to achieve this in the |
|
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 |
|
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. 🙏🏻 |
Uh oh!
There was an error while loading. Please reload this page.
👋 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?
thingsThing(Stripe Product) through the checkout process. They can also come back later and buy anotherThingthrough 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.completedwebhook.Fulfillment in webhooks
stripe.charge.succeeded
metadatais empty in thestripe.charge.succeededwebhook.Thingthey bought.stripe.checkout.session.completed
metadatais available here!UserandThing, but no way to find what charge is associated with this session.Fullfillment using Extensions/Concerns
metadatais empty herething_idAny ideas where I've went astray here? Should metadata passed at checkout time, be available in the
Chargeobject and instripe.chargecallbacks?Thanks for your time! 🙏🏻
All reactions