#hemabhravee

1 messages · Page 1 of 1 (latest)

willow saddleBOT
#

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.

north cedar
#

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

solemn latch
#

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,
      },
    );
north cedar
#

so where exactly is the metadata missing? on which object? can you share an obejct ID?

solemn latch
#

sure - ch_3OhS6aPKYvckR8WV0tXZZPRJ - this is a charge associated with a payment link which was created using the above code

north cedar
#

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

solemn latch
#

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

north cedar
#

Sure, but the Charge you shared was not created by this Payment Link

#

so that's irrelevant

solemn latch
#

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.

north cedar
#

can you share a Charge object created by a PaymentLink that sets the metadata on the PaymentIntent?

solemn latch
#

I dont know how to find the charge associated with a payment link. Can you pls tell me

north cedar
#

having a look

solemn latch
#

thanks

north cedar
solemn latch
#

cool will try this out and share the charge object I find

solemn latch
#
  1. 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.
  2. Once I've actually made the payment, then the payment intent does show up.
  3. I'm still unclear on how I can find the transaction history for any connect account using metadata queries
willow saddleBOT
sudden steppe
#

1 + 2 yep, that's how it works

solemn latch
#

But I want to find all charges which have a certain key value pair in their metadata

sudden steppe
solemn latch
#

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

sudden steppe
#

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