#xfechx-paymentlink
1 messages ยท Page 1 of 1 (latest)
Hi! You are creating the PaymentLink with the API, and you would like to set the metadata of all the charge objects for that PaymentLink?
yes
so that my webhook process the charge.succeded like with other methods of payments
using metadata
?
That's not possible unfortunately.
But if you have the Charge ID, it might be possible to figure out the PaymentLink associated with it. Would that solve your issue?
Yes
how can I do it, because I need to retrieve the metadata
related to the payment link
through a charge.succeded
Give me a few minutes to look into this.
Also, with a checkout session, how can I tell that it is coming from a payment link?
another question, can I update a payment link with a description, afterwards?
sorry a a payment intent from a payment link
HI there ๐ stepping in.
From the Charge object you can check the payment_intent field to find the related Payment Intent. Once you have the Payment Intent you can use it to retrieve the associated Checkout Session:
https://stripe.com/docs/api/checkout/sessions/list#list_checkout_sessions-payment_intent
You can then check the payment_link field on the Checkout Session to find it's related Payment Link.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
And yes, you can update a Payment Intent.
THANKS
can you specify how can I retrieve the checkout session from the payment intent?
I only one the one related to the charge
Sure, you'd use the List Checkout Sessions function that I linked above, and use the Payment Intent ID as your filter criteria.
thanks
a question
can I use this? I am getting an error, I think it is because it is not getting the connected account. But I am passing it, maybe my syntaxis is wrong:
$payment_intent_object = \Stripe\PaymentIntent::retrieve($payment_intent, [], $connected_account);
What's the error?
We are sorry</h4><p><strong>There was a problem with your transaction<br>No such payment_intent: 'pi_3KgplQGZgYEIO0k51TiPLsjD'
Ahhh I think it is because it is trying to pull it on live mode
Ah that could do it.
the problem is that my metadata always includes a test flag
but these charges coming from payment links dont have metadata, very frustrating
Ah gotcha. Every object also has a livemode parameter to help identify what mode they belong to.
can you please check if this one was trying to use live or test?
evt_3KgplQGZgYEIO0k51ivd1DDZ
Test
so not sure why is that not being retrieved?
Usually that error is seen when the object is on the connected account but you're checking the platform, or vice versa
OK, so I am on the platform (under live mode) under a webhook for a connected account
because on platforms, I have to use this to check the webhooks even if they are in test mode
Can you share the ID of a failed request?
Wait, are you not trying to retrieve an object anymore? What is it you're trying to accomplish?
I am trying to process charge.succeded
I am trying to get the "Link" parameter from metadata, but my charge doesn't have metadata, so I am trying to pull the metadata from the checkout, so I need to use the payment_intent first.
in order for me to pull the payment_intent, I need the Link from the metadata, so that it tells my code where the request is comming from and so that it matches the destination (i.e where the webhook is hosted)
this is a filter, so that events from other connected accounts do not interfere.
Okay, and which part of the process is running into a problem, the request to list the Checkout Sessions?
the request to list the payment intent
$payment_intent_object = \Stripe\PaymentIntent::retrieve($payment_intent, [], $connected_account);
I can confirm that connected account is a valid array with the connected account id
[stripe_account => acct_xyz]
Hello. Stepping in for toby here as they have to step out. Give me a bit to catch up
ok
So the question still is why you are getting a no such payment intent error?
Yeah was just confirming what you want to know
Can you share the request id for that request?
As well as the payment intent id and connected account that you are passing in
here
where do i find it? I am on that screen
Also, I need to follow up re SEPA and other payment methods not appearing on checkout for connected account
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
Ok one thing at a time
Can you find that request id that is failing and share it?
Also providing the paymentintent id and connected account id you are using?
I think is this one:
req_u0HFnRHjVb6T5I
acct_1K3kZZGZgYEIO0k5
pi_3KgplQGZgYEIO0k51TiPLsjD
I think you are passing in the connected account incorrectly. Take a look at this guide: https://stripe.com/docs/connect/authentication#stripe-account-header
huh?
I use this in ALL my code
all the time...
what is wrong with this call:
$payment_intent_object = \Stripe\PaymentIntent::retrieve($payment_intent, [], $connected_account);
to start with, are the parameters ok?
I can confirm (AGAIN) that $connected_account is a properly built array with 'stripe_account' => acct__xyz
that variable $connected_account, is used ALL over my code, it works no problem, why would it be different here? I also just printed it and it prints the array for the connected account.
I just printed it testing and it is fine... so why do you say that I am using it incorrectly?
acct_1K3kZZGZgYEIO0k5
Ah I see. I didn't see the first message where you said connected_account pointed to that array
Let me take a look into this again
ok
OK i am able to retrieve it now
the problem was that I didn't need that middle empty array.
the API never shows calls with connected accounts, so it is usually confusing
anyway, the payment intent doesn't have metadata?
it is empty... so I really don't know how to retrieve the metadata from a payment link
Can you share the request for how you are setting the metadata?
From there I can determine the exact object that metadata is set on
Yeah, the payment intent object doesn't contain any metadata
//metadata is empty, let's try to find it:
try{
$payment_intent_object = \Stripe\PaymentIntent::retrieve($payment_intent, $connected_account);
} catch(\Stripe\Error\InvalidRequest $e){
error_messages($e);
} catch (\Stripe\Error\Card $e){
error_messages($e);
} catch (Exception $e){
error_messages($e);
}
$metadata = $payment_intent_object->metadata;
}
$origin_url = $metadata->Link;```
Hi @exotic harness! Stepping in for @thin idol. You are setting metadata on the PaymentLink itself, yes?
I am trying to retrieve it
when it is a charge.succeded
so that I can pull the "Link" element from it
metadata->Link
on the payment link
This issue is about payment links' charge not inheriting payment link metadata
or payment intent metadata
Okay so that is where the metadata will live. It will not exist on the PaymentIntent as it doesn't get carried down afaik.
So are you asking how to get back to your PaymentLink ID to then retrieve the metadata?
ok, i am updating the payment intent anyway on the checkout.completed
so I could do this?
$payment_intent_object = \Stripe\PaymentIntent::update(
$payment_intent,
[
'description' => 'Payment Link No. '.$metadata->Invoice. ' ['.$metadata->Reference.']',
'metadata' => $metadata
],
$connected_account
);
}```
$metadata is the metadata from the checkout session
Yep that looks right to me.
I am getting an error, i think it doesn't accept the metadata array
just like that. Do you know how I can just pass it directly?
without having to re-write each element from the associative array?
Ah I didn't realize that $metadata wasn't already an object
it is been pulled like this:
$metadata = $event_json->data->object->metadata;
it is an object
["Invoice"]=>
string(4) "4572"
["Customer"]=>
string(12) "Luna Escobar"
["CustomerID"]=>
string(3) "197"
["Link"]=>
string(46) "https://app.lunaescobar.com/payment-link/test/"
["Reference"]=>
string(4) "Test"
["Notes"]=>
string(0) ""
["Vendor"]=>
string(23) "lunaescobar18@gmail.com"
["VendorID"]=>
string(3) "197"
["Timestamp"]=>
string(14) "20220324122702"
["API"]=>
string(0) ""
["Affiliate"]=>
string(0) ""
["Tickets"]=>
string(0) ""
["Test"]=>
string(4) "true"
["CFDI"]=>
string(0) ""
}```
that's a var_dump
how do I update the payment intent with that metadata object
it is stored in $metadata
Huh, that does seem fine to me. Can you provide the request ID where you hit the error above when you tried to pass that?
I have the event ID:
evt_1Kgu3gGZgYEIO0k5PNpqFiOl
I get a 500 error
so it is difficult for me to track where, but without that line, it works.
so it must be that
Huh weird. What is the error message on your server?
{"code":"internal_server_error","message":"<p>There has been a critical error on this website.<\/p><p><a href=\"https:\/\/wordpress.org\/support\/article\/faq-troubleshooting\/\">Learn more about troubleshooting WordPress.<\/a><\/p>","data":{"status":500},"additional_errors":[]}
I see that in the std out from the webhook response
but yeah, if I comment the line, and I resend the webhook, all good
so it is that
$payment_intent,
[
'description' => 'Payment Link No. '.$metadata->Invoice. ' ['.$metadata->Reference.']',
'metadata' => $metadata
],
$connected_account
);```
If you wrap $metadata in [] does that change anything?
Sorry, I'm not super familiar syntactically with PHP
Okay let me grab a colleague
thanks
Hi ๐
hi
That syntax looks kind of strange to me. metadata needs to be an associative array of key => value pairs.
it is an object
["Invoice"]=>
string(4) "4572"
["Customer"]=>
string(12) "Luna Escobar"
["CustomerID"]=>
string(3) "197"
["Link"]=>
string(46) "https://app.lunaescobar.com/payment-link/test/"
["Reference"]=>
string(4) "Test"
["Notes"]=>
string(0) ""
["Vendor"]=>
string(23) "lunaescobar18@gmail.com"
["VendorID"]=>
string(3) "197"
["Timestamp"]=>
string(14) "20220324122702"
["API"]=>
string(0) ""
["Affiliate"]=>
string(0) ""
["Tickets"]=>
string(0) ""
["Test"]=>
string(4) "true"
["CFDI"]=>
string(0) ""
}```
How can I convert it , so that I can just pass it like this:
metadata => $metadata
First question, if you remove the line metadata => $metadata does the Update call work?
yes, like mentioned above ๐
Sorry I'm just hopping in
sure no worries
thanks
so yes, it works without that line
the $metadata contains an object, taken from the event
Do you have a Request ID for one of the failed requests?
hmmmm I have a event id
Here's how you can find a request ID: https://support.stripe.com/questions/finding-the-id-for-an-api-request
evt_1Kgu3gGZgYEIO0k5PNpqFiOl
No, but I am resending the webhook only
You can find it with the event id , no?
I'm talking about the request to Update the payment intent
that is a separate API request
are you a php developer? Do you know how can I pass the object $metadata to the new metadata for payment intent?
ok
This is likely specific to our PHP library and how it transforms the arguments you provide into a POST request. It helps me to see the data payload of that POST request, which I can do with the request ID
Perfect, thank you
Okay no, try looking for one that failed
This is a successful request
where do I look for it, for a connected account?
that is the last one I see
req_2QtcZYU9FtaAgy
for payment intents
OK
got it
i needed to convert the php object to associative array
with (array)$metadata
Okay, so since you are passing in the Stripe Account header the request will exist on the Connected Account.
So you can look in their activity logs to find the request.
OK, how can I get the charge from the payment intent? So that I can update the charge's description
because also charges from payment link don't have descriptions
Okay for a second I want to take a step back. Is there a reason you have to assign the metadata to the Checkout Session and then assign it to the Payment Intent?
Why couldn't you just assign it directly to the Payment Intent using the 'payment_intent_data' => ['metadata' => ['key': 'value']] approach when creating the Checkout Session?
https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-payment_intent_data
I am using payment links
I do that for checkout sessions, but I am at the moment implementing payment links
Ooooohhhh.....yeah that makes sense
so I also need to fill in a description for the charge
I already filled in the metadata for the payment intent
so that helps with charge.succeded , I can at least obtain the metadata from that event
Do you make an API call to retrieve the Payment Intent?
yes why
Okay well you should receive the charges list on that Payment Intent. You can examine those charges and update them with the description already on the Payment Intent.
$payment_intent,
[
'description' => 'Payment Link No. '.$metadata->Invoice. ' ['.$metadata->Reference.']',
'metadata' => (array)$metadata
],
$connected_account
);
$charge_object = \Stripe\Charge::update($payment_intent_object->charges->data[0]->id,
[
'description' => $payment_intent_object->description
],
$connected_account);```
You cannot update the charge within the payment intent. That needs to be a separate API call
yeah there are two api calls there, no
?
$charge_object = \Stripe\Charge::update($payment_intent_object->charges->data[0]->id,
[
'description' => $payment_intent_object->description
],
$connected_account);
[
'description' => $payment_intent_object->description
],
$connected_account);```
Sorry, the indentation threw me off. I mostly develop in Python so those have special meaning for me ๐
Those calls look good to me.
ahh,
I have a problem
charge.succeeded comes BEFORE checkout.sessioncompleted
I am updating the payment intent in the checkout.session
Okay. So what is the particular problem? You want to add the description before the Charge succeeds?
yes, because my code sends notification emails when charge.succeeded
and it uses the charge's description
sno not sure how to obtain a description from a charge.succeded (that comes from a payment-link)
?
do you know how to?
Hmmm...in that case the best option I could see would be to delay the sending of the email by a few seconds until the checkout session is also returned.
hmm
better option
to retrieve payment intent, and copy the metadata and description to the charge's
and how can I update the charge description?
can I use:
$charge->description = 'xxyyzz';
$charge->save();
?
honestly I haven't used the PHP library enough to be sure. I'd probably make a $strip->charges->update(['description' => $payment_intent->description]) call.