#jshort-paymentlink-metadata
1 messages · Page 1 of 1 (latest)
@mental jackal hello! I'm happy to help but can't do much from a picture.
Can you clarify how you create the PaymentLink, where you set the metadata, etc,?
jshort-paymentlink-metadata
sure,
$stripe = new \Stripe\StripeClient(API_KEY);
$payment_link = $stripe->paymentLinks->create([
'line_items' => [[
'price' => $price->id,
'quantity' => 1
]],
'metadata' => [
'order_description' => $description_short,
'hotelid' => $hotel->hotelid
]
]);
Gives me a payment link I can click on which launches a Stripe payment screen.
ty for responding
The intent of the picture was to illustrate the same code which creates the payment link will sometimes have a checkout session and sometimes not.
Okay so you put the metadata on the PaymentLink, so it does on the Checkout Session. It won't go on the PaymentIntent or the Charge.
Yes
All PaymentLinks will always yield a Checkout Session
the picture you shared is not about PaymentLinks, it's about PaymentIntents (same first word but completely different API)
I was looking under Stripe, Payments, Events and Logs for both payments. One shows a checkout session created but the other payment does not show a checkout session.
Same code seems to yield different Activity Log
I am searching by fingerprint
I'm really sorry but I have no idea what this means for now
I'm a developer and I help developers with their code and right now you seem to just talk about the Dashboard and being lost
Can you give me an example PaymentIntent id pi_123 that is problematic? I'll show you what happened
200 OK
A request to confirm a Checkout Session completed
15/06/2023, 10:54:24
A new payment pi_3NJKNIGShQEngw2R2qyputdN for CA$1,404.48 was created
15/06/2023, 10:54:24
This attempt lets me see the meta-data.
Please try to focus on the questions as a developer yourself, don't just copy-paste everything
All I need is a clear PaymentIntent id pi_123 for the problem. Please only share that one thing
pi_3NJKNIGShQEngw2R2qyputdN
Is this what you need?
This payment intent creates a checkout session
My issue is I have another payment intent which does not create a checkout session.
This payment intent creates a checkout session
no that does not make sense. A PaymentIntent never creates a Checkout Session. It's the opposite
The reason I say it does is because there is a one second differential between the two events.
yes but that is incorrect and it's important to grasp how all those objects relate to each other otherwise you're going to have a really hard time integrating and understanding our API
a PaymentLink is kind of a "reusable link for a specific payment config". You share the URL with end customers, they visit it. Each visit creates a single use Checkout Session (cs_test_123) that is ephemeral (24 hours) for that one end customer to try to pay (or give up). That Checkout Session, when confirmed, will create a PaymentIntent (pi_123)
ok that is helpful as a starting point, ty
So the PaymentIntent you shared earlier is https://dashboard.stripe.com/payments/pi_3NJKNIGShQEngw2R2qyputdN
That's created by the API Request https://dashboard.stripe.com/logs/req_5eTxN6wo0xIRWS which does come from a Checkout Session.
That Session came from a PaymentLink https://dashboard.stripe.com/payment-links/plink_1NJKLxGShQEngw2RyyeO5efd
What you see on that page is not the metadata but instead the Price/Product info I think?
It's tough to say you seem to have reused the same logic for both
You should be trying all of this in Test mode as the developer and setting different value in each of the parameter so that you can reconcile things
The reason I am thinking it is meta-data is because in the webhook.php I am retrieving the metadata property like this:
$stripe_sessions = $stripe->checkout->sessions->all(['limit' => 1]);
$stripe_data = $stripe_sessions['data'];
$stripe_obj = $stripe_data[0];
$stripe_metadata = $stripe_obj->metadata;
$order_description = $stripe_metadata->order_description;
$hotelid = $stripe_metadata->hotelid;
I'm... super lost
This code has been working in circumstances for a few months but I'm finding a case where the metadata is not correct.
I thought the Dashboard would give me a clue as to what is going on.
Why would you use the List Checkout Sessions API and pass limit => 1. That basically means "give me the most recent Checkout Session"
yes, I just noticed that now
Perhaps, no matter what the Dashboard says I need to get the correct session
not the most recent
I will follow that lead, ty
What are you really doing though?
Are you getting a checkout.session.completed Event?
If so you already have the Session in that Event, with its metadata
When I click the Payment link event I want to transmit custom order information to the Stripe payment screen.
yeah see you're wording this in a completely different way again sadly and now I'm lost
what does "transmit custom order information" mean? custom metadata? The content of what is being bought? Something else completely different?
An exact example would be
Comfort Suites Tulsa O/S Amt as at 13-jun-2023 for file(s) 67809,67810
It's a charge for services rendered
I mean this looks a lot more like a description to me than anything else?
That's not really how PaymentLink and Checkout work at all though
It seems like you're almost making one-time use/one-off Prices and Products just to get to that string that is a bit obscure?
I assume that can't even be re-used by anyone and you're using PaymentLinks in a way that is "abnormal" where each link is just for one customer for one specific order?
exactly right
One page will be a listing of charges for a hotel. They can click on/off the checkboxes, which will recreate the payment link.
Then when they click the Pay Now button it takes the custom charges and launches stripe with the custom description
yeah that's not at all how our product is supposed to be used 😅
why do you create a PaymentLink at all?
because the Payment Link seemed like the easiest way to accomplish what I wanted to do.
If you can think of an easier way I'd evaluate it.
Why aren't you just using Checkout directly?
What is the upside of creating the PaymentLink and then immediately sending the Customer to that URL which will really just create a Checkout Session for them?
My business case is many different hotels will log in and then see all their charges. They can click the applicable checkboxes and click the Pay Now button.
How would the Checkout apply in the above scenario?
The upside is minimum amount of clicks to get the customer to pay their bill.
I'm sorry, I have no idea what any of this means
I'm really trying but now you talk about hotels and customers and checkboxes
Can I send you a picture as it will be easier to illustrate?
a pic is worth a 1000 words
if you send it here, sure, otherwise no
Ultimately: if you send the customer to pay to Checkout immediately, it really makes no sense to me that you'd use PaymentLinks
They click a checkbox and then click Pay Invoice. The Pay Invoice will execute the Payment link.
Okay so the end customer is on that page and going to pay for this right?
yes
So really you want Checkout only. Never PaymentLink. You seem to have misunderstood something fundamental here, I'm just not sure what
PaymentLinks would be "I sell a book for $8.99 to anyone who wants it, I want to tweet a link anyone can click to buy that book"
ok so what would Checkout look like? I would click Pay invoices and redirect them to a Checkout link?
I don't want them to change how much they pay once they get to checkout.
Really your code needs to create a Checkout Session directly and never go through PaymentLinks
Would they have to login to Stripe?
not at all
sorry I keep saying this but it's not clicking
All a PaymentLink is is a "factory" to create a Checkout Session
the customer experience for you will be mostly identical. Instead of sending them to a PaymentLink URL which immediately sends them to a Checkout URL under the hood, you just send them to Checkout directly
ah ok, I'll try that. Do you have a good video link which illustrates how to execute?
k I'll try, thx for your patience