#Dynelight
1 messages ยท Page 1 of 1 (latest)
It's sent immediately when the sub is created. See: https://stripe.com/docs/billing/subscriptions/webhooks#events
What should I use when the payment is confirmed? Because we will use ACH payments
customer.subscription.updated?
You'll get payment_intent.processing when it's confirmed and processing. You'll later get payment_intent.succeeded once it's been charged
We mention some events in this guide: https://stripe.com/docs/payments/ach-debit/accept-a-payment?platform=web&ui=API
It's not for subscriptions, but the webhook events would be the same
payment_intent.succeeded will work for both ACH and card?
Both card payments and ach payments use payment intents
payment intents represent an intent to make a payment and are the way all types of payments with all types of payment methods are represented
Thanks Duchess ๐ Another question: Do I need to persist the payment_intent on the database so I can look for it later? or can the payment_intent somehow save the metadata I passed when I was creating the subscription?
You only need to save the PI ID if you need to do something with it later, so that's up to you really. Are you referring to this metadata? https://stripe.com/docs/api/subscriptions/create#create_subscription-metadata
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I can't seem to have access to the metadata I passed when I created the subscription, on the payment_intent.succeeded webhook
Yeah metadata isn't automatically copied across objects. So if you set metadata on the subscription, it will just be on the subscription
Am I better off using customer.subscription.updated and check if the status went to whatever the approved payment status is?
I am using stripe checkout
Where on the checkout session are you setting metadata?
Can you share your request body?
(There's a couple places you can set it actually)
Let me double check
Oh wow
I don't think I'm actually passing it here
Oh wait, I am
Where are you passing it then?
{:allow_promotion_codes=>true,
:customer=>"cus_MyyLTLe3ck7ysT",
:line_items=>[{:price=>"price_0LMxmU85cJoRoAtChUuFL9gN", :quantity=>1}],
:mode=>"subscription",
:success_url=>"http://newly004.lvh.me:3000/element/8351-test-fund-003?payment_successful=true",
:cancel_url=>"http://newly004.lvh.me:3000/element/8351-test-fund-003",
:subscription_data=>{:description=>"Test 003", :metadata=>{:element_id=>8351}}}
I am passing that object to the checkout
I guess I need to pass it to the actual payment too right?
Hi, stepping in as codename_duchess is away. Let me catch up
Thanks @spice obsidian
From looking at the above, it looks like you're adding the metadata on the subscription level which is an expandable, https://site-admin.stripe.com/docs/api/expanding_objects object, https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-subscription. You can also set the metadata on the Checkout object, https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-metadata
So if you'd like to see the metadata set on the subscription, you can retrieve the Checkout Session, https://stripe.com/docs/api/checkout/sessions/retrieve and expand the subscription, expand: ['subscription']
what I need is the webhook to pick it up though.
I justed tested (I have a joint model in which I can pay for both subscriptions and one time items).
If I only pay for one time items, the payment_intent.suceeded webhook does fire with the metadata I passed when I created the checkout session with the payment intend.
However, for the subscription, since I am creating subscription_data instead of payment_intent_data, then I don't see that metadata on the payment_intent.suceeded webhook
Do I need to use customer.subscription.updated for this case?
Sent when the subscription is successfully started, after the payment is confirmed.
Yes, the customer.subscription.created, https://stripe.com/docs/api/events/types#event_types-customer.subscription.created should have this metadata. Otherwise, you can add the metadata on the Checkout object and listen to checkout.session.completed, https://stripe.com/docs/api/events/types#event_types-checkout.session.completed.
But the checkout.session.completed won't guarantee the payment to be approved by stripe if I am using, say, ACH
Well, Stripe won't approve ACH payments. It's more like your customer's bank approved the payment. With, ACH you can listen to this https://stripe.com/docs/api/events/types#event_types-checkout.session.async_payment_succeeded for async Payment Methods.