1

I want to pass a few app specific credentials with stripe url for checkout.

I tried something like the following,

 const paymentLink = await stripe.paymentLinks.create({ line_items: [{price: "price_1XXXXK", quantity: 1}], metadata: { author_id: "author_id", server_id: "server_id", }, }); 

But in payments tab, the metadata is still empty.

I can only see those metadata in generated payment link section. But I can't find any relations or references about the link that was used to make the purchase on the payment response data.

So is there any better way to add metadata to the checkout while creating a payment link, instead of adding metadata just for the generated link?

2 Answers 2

0

Passing the metadata parameter when creating a Payment Link will only persist on the generated Checkout Session object, and not the underlying payment:

Metadata associated with this Payment Link will automatically be copied to checkout sessions created by this payment link.

But I can't find any relations or references about the link that was used to make the purchase on the payment response data.

To reconcile the Payment Intent object with the associated Payment Link that was the origin of the payment:

  1. List all Checkout Sessions, passing the payment_intent parameter.
  2. Expand the payment_link field on the returned Checkout Session object.
Sign up to request clarification or add additional context in comments.

2 Comments

So.. is there any other straight forward way to pass metadata to the underlying payment during link creation? Or manually fetching the payment link reference and then making another request to fetch metadata of the payment link is the only way?
You can't set the metadata on the payment directly from a Payment Link no. You could setup a webhook handler for this: listen for checkout.session.completed events and the update the associated Payment Intent/Charge with the metadata fields from the Checkout Session object.
0

The Create method for Checkout Sessions supports these parameters:

  • payment_intent_data
    • metadata passed this way will be available in both payment_intent.succeeded and charge.succeeded events.
  • setup_intent_data
  • subscription_data

That let you pass data to the underlying payment_intent/setup_intent/subscription objects and it supports metadata.

So you'd be able to pass metadata to, say, a PaymentIntent this way.

See: https://support.stripe.com/questions/using-metadata-with-checkout-sessions


In passing / rant: most people will need to use metadata so as to get an "easy" way to know which products are in the order, because out of the box the Stripe API does NOT tell you, in an event, which product was ordered 🙄 (except for Payment Links).

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.