#mxd
1 messages ยท Page 1 of 1 (latest)
You can't add metadata to Events, but you can add metadata to pretty much any of the objects contained within the events. Can you elaborate more on what you're trying to do?
yeah so from this instruction here: If need user_id: user_id to provision the subscription (add it to metadata)
basically I need to retrieve that user_id or some form of id from the webhook so i can store it in the database
What Im trying to do is, provision access to paid features, so once the customer pays, I have an sqlalchemy trigger that stores info on that user and the subscription type..then reroute them to a paid membership page that checks who the user is and displays features relevant to that user and their subscription
Ah, okay. So which webhook event are you listening for that you need this info from? It's okay if you're not sure which is best, but I figured I'd start there
yeah Idk because I looked through the event types and I only did: checkout.session.completed customer.bank_account.updated customer.card.updated customer.source.updated customer.subscription.created customer.subscription.deleted invoice.paid invoice.payment_failed
looking at the meta data, its empty: "metadata": { },
just dont know how to get that in the webhook
๐ stepping in for my colleague who needs to step away
im on this page: https://dashboard.stripe.com/test/webhooks/
in the docs example, # 3 above mentions that, as part of this example company's integration, they add metadata to Checkout sessions and subscriptions
yeah, but I dont see that option on the webhooks page
i think I saw it once, the add meta data option
metadata will be empty unless explicitly added. metadata isn't added to a webhook but an object (e.g. PaymentIntent, Charge, Checkout Session, etc.)
idk how to do that
If we continue with the same example, metadata can be added when creating the checkout session: https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-metadata
you can also add metadata that will be passed over to the subscription object when creating the checkout session: https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-subscription_data-metadata
better yet how do I do that here: ``` if event_type == 'checkout.session.completed':
# Payment is successful and the subscription is created.
# You should provision the subscription and save the customer ID to your database.
print(data)
elif event_type == 'invoice.paid':
# Continue to provision the subscription as payments continue to be made.
# Store the status in your database and check when a user accesses your service.
# This approach helps you avoid hitting rate limits.
print(data)
elif event_type == 'invoice.payment_failed':
# The payment failed or the customer does not have a valid payment method.
# The subscription becomes past_due. Notify your customer and send them to the
# customer portal to update their payment information.
print(data)
else:
print('Unhandled event type {}'.format(event_type))
return jsonify({'status': 'success'})```
save the customer ID to your database
okay, the "customer ID" in this case is completely separate from any metadata you add. the comment above is referring to the customer property on the checkout session object
are you referencing a specific doc that includes the webhook handler code above?
yeah https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=checkout#provision-and-monitor
I cant create the product because it doesn't trigger the webhook, so I created the product in the pricing table feature in the stripe dashboard
is the meta data this thing?
Okay, I'm not exactly sure what you're trying to do. that webhook handler code has conditionals based on the event type. if you need to inspect metadata on the checkout session, you'll need to inspect data_object.metadata
yes, that's metadata that's on the Product. you can add metadata to a product either via the Dashboard (your screenshots) or via the API: https://stripe.com/docs/api/products/object#product_object-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'm not sure you're understanding how metadata works
Metadata should be used if you want to store key/value pairs on Stripe objects. These values are likely values that you use to identify items in your own databases
For example, if you don't want to only rely on Stripe's Customer IDs (that are in the format "cus_###...") and use your own IDs to identify customers on your end, you can add your internal customer IDs as metadata on customer objects. Does this make sense?
it is a little bit
got it. does your team need to use metadata, then?
does stripe have phone support or is it only discord?
Support options are listed here once you log in: https://support.stripe.com/?contact=true
That said, in terms of real time developer support, Discord is the best place