#hemabhravee
1 messages · Page 1 of 1 (latest)
Hello! We'll be with you shortly. Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- hemabhravee, 2 hours ago, 7 messages
- hemabhravee, 5 days ago, 16 messages
- hemabhravee, 6 days ago, 10 messages
hi there!
on which object do you create the metadata? on the Payment Link itself?
if so, it's expected that you won't find it on the PaymentIntent/Charge object
you could use this to set the metadata directly on the PaymentIntent: https://stripe.com/docs/api/payment_links/payment_links/create#create_payment_link-payment_intent_data-metadata
yepp I'm setting this value as well
Here is the code I'm using to create a payment link
const paymentLink = await this.stripe()?.paymentLinks.create(
{
line_items: priceList.map((itr) => ({
price: itr.id,
quantity: itr.quantity,
})),
metadata: {
type: 'topup',
},
payment_intent_data: {
metadata: {
type: 'topup',
},
setup_future_usage: 'on_session',
},
},
{
stripeAccount: accountId,
},
);
so where exactly is the metadata missing? on which object? can you share an obejct ID?
sure - ch_3OhS6aPKYvckR8WV0tXZZPRJ - this is a charge associated with a payment link which was created using the above code
this Charge comes from this PaymentLink: plink_1OhS69PKYvckR8WVfM60cruw
and this one has no payment_intent_data.metadata set
in this case the metadata is only set on the PaymentLink object itself
But I see the following event after creating a payment link -
{
"id": "plink_1OhVZpPKYvckR8WVvnsq1Npx",
"object": "payment_link",
"active": true,
"after_completion": {
"hosted_confirmation": {
"custom_message": null
},
"type": "hosted_confirmation"
},
"allow_promotion_codes": false,
"application": "ca_PS3VYLX4WzCcQ94S7T4fM910Olr9rlGX",
"application_fee_amount": null,
"application_fee_percent": null,
"automatic_tax": {
"enabled": false,
"liability": null
},
"billing_address_collection": "auto",
"consent_collection": null,
"currency": "usd",
"custom_fields": [],
"custom_text": {
"after_submit": null,
"shipping_address": null,
"submit": null,
"terms_of_service_acceptance": null
},
"customer_creation": "if_required",
"inactive_message": null,
"invoice_creation": {
"enabled": false,
"invoice_data": {
"account_tax_ids": null,
"custom_fields": null,
"description": null,
"footer": null,
"issuer": null,
"metadata": {},
"rendering_options": null
}
},
"livemode": false,
"metadata": {
"type": "topup"
},
"on_behalf_of": null,
"payment_intent_data": {
"capture_method": "automatic",
"description": null,
"metadata": {
"type": "topup"
},
"setup_future_usage": "on_session",
"statement_descriptor": null,
"statement_descriptor_suffix": null,
"transfer_group": null
},
"payment_method_collection": "if_required",
"payment_method_types": null,
"phone_number_collection": {
"enabled": false
},
"restrictions": null,
"shipping_address_collection": null,
"shipping_options": [],
"submit_type": "auto",
"subscription_data": null,
"tax_id_collection": {
"enabled": false
},
"transfer_data": null,
"url": "https://buy.stripe.com/test_7sIaHe1LAdkM6mk6ot"
}
This object contains both the metadata variables which I populated
Sure, but the Charge you shared was not created by this Payment Link
so that's irrelevant
ooh, okay
So this is the code I'm using to find charges -
const charges = await stripe.charges.list(
{},
{
stripeAccount: accountId,
}
);
But not a single charge object in the response has any metadata.
And after every payment link I create, the charge count in the response goes up by one.
can you share a Charge object created by a PaymentLink that sets the metadata on the PaymentIntent?
I dont know how to find the charge associated with a payment link. Can you pls tell me
having a look
thanks
it requires a bit of work:
- list all Checkout Sessions created by a specific Payment Link with https://stripe.com/docs/api/checkout/sessions/list
- for each Checkout Session, check it's
payment_intentfield
note you can do both 1 and 2 in one API call if you use Expand: https://stripe.com/docs/expand
cool will try this out and share the charge object I find
- So I'm able to find the checkout session for a payment link and it contains the metadata I'm looking for but there is not payment intent attached to it.
- Once I've actually made the payment, then the payment intent does show up.
- I'm still unclear on how I can find the transaction history for any connect account using metadata queries
1 + 2 yep, that's how it works
But I want to find all charges which have a certain key value pair in their metadata
then why not do a search on PaymentIntents using status:succeeded and the metadata filter ? https://stripe.com/docs/search#query-fields-for-payment-intents Then if you want the Charge object ch_xxx specifically, that can be accessed via the latest_charge field on each PaymentIntent.
you could also do https://stripe.com/docs/api/payment_intents/list and apply filtering for status and metadata in your code that looks at the results
Just tested out this flow and its working
thank you for your help
these flows also helped improve my understand of how all these objects relate with each other as well
yes, and to clarify, metadata on a PaymentIntent object is not copied down to the Charge objects it creates, they can have separate metadata
although actually my team's KB says
When a PaymentIntent is confirmed, we do a one-time copy of the PaymentIntent’s metadata (as well as some other fields) over to the Charge. It is important to note that this is a one-time copy - for example any subsequent updates to the PaymentIntent’s metadata are not synced to the Charge object (or vice-versa)
so I'm wrong on that point actually