#xfechx_api
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1257645022459985951
๐ Have more to share? Add details, code, screenshots, videos, etc. below.
hi!
I just do not understand why in some cases works and some other does not.
what's the current status of your inestigation into that, what have you found?
I also do not know what "described properly, while others are described poorly" means
probably better to write a detailed email to https://support.stripe.com/?contact=true with the examples and screenshots and full details of what you're seeing
this is related to development
not stripe support
what I mean is the descriptions in the dashboard, I have to programatically change them to be more descriptive
It already works - but not in all cases, so I want to know why
I also have another issue, with balance transactions (through API) not coming back with Account details (name, address) while it was before
makes sense I guess, so what is the code that does that, what API call does it make, what happens/does not happen in the cases where it doesn't work?
where it doesn't work it just displays "invoice-473843F09-009" or whatever the stripe invoice default format looks like
rather than the format that I have in the description of the subscription's charge
take a look here
if you see the top payment, it says "invoice 83108..." instead of it's description, all of these charges use the exact same code
they are subscription charges, and through webhook, the payment intent description gets written to use the charge description
so not sure why it is not consistent
sorry you didn't answer anything I asked
so what is the code that does that, what API call does it make, what happens/does not happen in the cases where it doesn't work?
so, on the following events:
invoice.payment succeded, invoice.payment_failed,
charge.succeded, charge.failed
checkout.session.completed
I have a function call, update_payment_intent($payent_intent)
which has the following content
Which URL is that screenshot from?
from the dashboard
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
I also have another question regarding connected accounts and account details not displaying anymore (using same code, different result)
should I open a new thread?
Let's figure out the first issue first please
Is this the ID of a payment with an unexpected description? pi_3PXm8iHlZBj3A1TO19Z3zBNM
yes
I don't see any requests to update that intent like your code implies?
can you see it in the other ones?
like this one:
pi_3PX0t1HlZBj3A1TO1IXZhCl2
or this one, from the day before:
pi_3PXLgVHlZBj3A1TO0adBdid7
Sure, you're updating the description field for those:
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
But that request was never sent for pi_3PXm8iHlZBj3A1TO19Z3zBNM
why was it not sent?
If I haven't changed anything related to webhooks
from one day to the next one
That's only something you can answer I'm afraid
sorry?
I am asking you - why is my webhook if it has responded properly, hasn't updated on subscription charge, and the other one yes.
You're asking me why the API request sent from your integration to update a Payment Intent wasn't sent. The answer is I don't know โ are there any logs in your server indicative of an error around that time?
This is something you will need to debug I'm afraid. There's no evidence of even an attempted/failed update request
My guess is this intent doesn't fulfil any of your if/conditional logic so it just skipped the update request
ah ok, So I can see that in charge.succedded, for the one that did not work the error was:
There was a problem with your transaction<br>No such notification: 'evt_3PXm8iHlZBj3A1TO1mr5cpqD'```
Where in the code you've shared is that thrown?
Ok, I identified the error
And if your webhook code does error, then you shouldn't be returning a 2xx response really as this will prevent automated retry logic
it is because that subscription did not have metadata filled
Great!
ahh sorry
what is more current, or better
plan or price?
to get metadata, in case it was not defined in the subscription
specifically to subscriptions
Plan API/resource is deprecated, use price_xxx
using this:
//if it is an invoice:
if($event_json->data->object->object === 'invoice'){
if($event_json->data->object->lines->data[0]->price->type == 'one_time'){ //it is a one time invoice charge:
$metadata = $event_json->data->object->metadata;
if(empty($metadata)){
$metadata = $event_json->data->object->lines->data[0]->metadata;
}
}
else if ($event_json->data->object->object === 'subscription') { //a subscripiton
$metadata = $event_json->data->object->lines->data[0]->metadata;
if(empty($metadata)){
$metadata = $event_json->data->object->lines->data[0]->price->metadata;
}
}
}```
cannot find metadata under invoice.payment succeded using that code, but I can see it in the event json
where is the metadata stored exactly? on the Subscription, Invoice, Price, somewhere else?
if($event_json->data->object->lines->data[0]->price->type == 'one_time'){ //it is a one time invoice charge:
$metadata = $event_json->data->object->metadata;
if(empty($metadata)){
$metadata = $event_json->data->object->lines->data[0]->metadata;
}
}
else { //a subscripiton
$metadata = $event_json->data->object->metadata;
if(empty($metadata)){
$metadata = $event_json->data->object->lines->data[0]->metadata;
if(empty($metadata)){
$metadata = $event_json->data->object->lines->data[0]->price->metadata;
}
}
}
}```
Sometimes it might be stored in subscription + price, sometimes it might only be on price (i.e when using dashboard to make the subscription, rather than the API)
do you get an error with the above code?
no
my webhook simply doesn't retrieve the API metadata parameter, which is needed to continue
can you share a specific Evenet ID (evt_xxx) where your code didn't find any metadata?
evt_1PXm8nHlZBj3A1TOiigYMhCg
this is the snippet:
//if it is an invoice:
if($event_json->data->object->object === 'invoice'){
if($event_json->data->object->lines->data[0]->price->type == 'one_time'){ //it is a one time invoice charge:
$metadata = $event_json->data->object->metadata;
if(empty($metadata)){
$metadata = $event_json->data->object->lines->data[0]->metadata;
}
}
else { //a subscripiton
$metadata = $event_json->data->object->metadata;
if(empty($metadata)){
$metadata = $event_json->data->object->lines->data[0]->metadata;
if(empty($metadata)){
$metadata = $event_json->data->object->lines->data[0]->price->metadata;
}
}
}
}
//when it is a charge, usually metadata is on the event root
if($event_json->data->object->object === 'charge'){
$metadata = $event_json->data->object->metadata;
}
$API = $metadata->API;```
This line should find it if(empty($metadata)){ $metadata = $event_json->data->object->lines->data[0]->price->metadata;
in this event I do see metadata on the Price. it is in object->lines->data[0]->price
yes
so this is the code, but I cannot retrieve it.
//if it is an invoice:
if($event_json->data->object->object === 'invoice'){
if($event_json->data->object->lines->data[0]->price->type == 'one_time'){ //it is a one time invoice charge:
$metadata = $event_json->data->object->metadata;
if(empty($metadata)){
$metadata = $event_json->data->object->lines->data[0]->metadata;
}
}
else if($event_json->data->object->lines->data[0]->price->type == 'subscription'){ //a subscripiton
$metadata = $event_json->data->object->metadata;
if(empty($metadata)){
$metadata = $event_json->data->object->lines->data[0]->metadata;
if(empty($metadata)){
$metadata = $event_json->data->object->lines->data[0]->price->metadata;
}
}
}
}```
no there are mistakes. for example you wrote $metadata = $event_json->data->object->metadata; so it's missing the [0]
it should be something like $metadata = $event_json->object->lines->data[0]->price I think (you'll need to double check).
I recommend doing this step-by-step with logs. like print $event_json->object and check its value, then print $event_json->object->lines, and so on.
It works with data->object->metadata
for other scenarios, where the metadata is directly under the subscription
Or if you tell me I should omit the data part then I can change it but I don't want to break more things
So how should I use it when metadata is on the price and not on the subscription directly
something like this
if (metadata is on the subscription) {
$metadata = $event_json->object->metadata;
} else if (metadata is on the price) {
$metadata = $event_json->object->lines->data[0]->price->metadata;
}
I don't understand your question, sorry.
oh, you mean my code?
there's proabbly mistakes in it, I wrote it quickly just to give you an idea
yes
hmmm
I am looking for something without mistakes, because on other scenarios it works
like I said, try this step-by-step with some logs until you are sure you get the correct values.
the code I wrote above should work when you receive a Subscription payload. you can write somethign similar for when it's an Invoice payload.
hmmm, that doesn't really help me
because it works on MANY other scenarios
I need someone that can help me please
can you put me someone that works with PHP and knows the API ?
because it works on MANY other scenarios
can you calrify this? your webhook code processing events should handle different types of events usingif. something like this:
if (the event is `invoice.payment_failed`) {
// process the event
}
else if (the event is `customer.subscription.created`) {
// process the event differently
}
so changing one part of the code shouldn't break anything else
ahh I am getting frustrated, I have been working with the API for like 10 years.
and you are talking to me like I started working with it yesterday. I need specific help
so with this:
//if it is an invoice:
if($event_json->data->object->object === 'invoice'){
echo '--- it is an invoice object ---';
if($event_json->data->object->lines->data[0]->price->type == 'one_time'){ //it is a one time invoice charge:
$metadata = $event_json->data->object->metadata;
if(empty($metadata)){
$metadata = $event_json->data->object->lines->data[0]->metadata;
}
}
else if($event_json->object->lines->data[0]->price->type == 'subscription'){ //a subscripiton
echo '--- filling metadata for subscription ---';
$metadata = $event_json->object->metadata;
if(empty($metadata)){
$metadata = $event_json->object->lines->data[0]->metadata;
if(empty($metadata)){
$metadata = $event_json->object->lines->data[0]->price->metadata;
}
}
}
}```
i get this:
--- filling metadata now ------ it is an invoice object ------ API being used is: ------
so it is not even entering the subscription else if
you're making it difficult to help you. can you be more precise in your question?
like, which event exactly is not entering in the else if? a invoice.payment_succeeded, or something else?
yes
ok, thanks a lot, I have resolved this issue.
I have another question
regarding connected accounts, retrieving business data
I can take that next question, soma needs to step away
hello, thank you
So with the same code, now it cannot seem to retrieve account name and address:
$stripe_account_name = $stripe_account->business_name;```
this worked for a while
$stripe_account_name = $stripe_account->display_name;
}```
"Now" compared to when? Are you suggesting something changed in the results without you making a change? Reading the backscroll above, I don't see how this is related to what you've been speaking about so far today
And to put a sharper focus on the issue, is the problem that the retrieval is failing or that the response object does not contain the information you expect it to?