#theconfused_
1 messages · Page 1 of 1 (latest)
Hello there. Can you share the evt_xxx that failed?
Also, what endpoint do you call in your webhook that returns the No such Charge error?
the first two hooks fail returned a 500 because we got a 404 trying to modify the charge at CHarge.modify
Do you happen to have the req_xxx IDs for those 404 requests?
unfortunately not, the errors didnt include them, only the charge id
and stripe seems to only show successful requests
[28/Nov/2023 10:53:54] STRIPE error_code=resource_missing error_message="No such charge: 'ch_3OHOvJJ63lRNHhBz0eOJDn2P'" error_param=id error_type=invalid_request_error message='Stripe API error received'
Hmm should do. Let me do some digging. I suspect this is related to Connect and perhaps not passing Stripe-Account header but will look
hmm
im not 100% clear on connect
its on what we call our legacy account
where our clients were connect accounts i think then they have clients. It smore difficult to find stuff because we have to go through their accounts
where in our newer implmentation everything is in 1 place as all the account are connect
I can't find any logs indicative of those errors on either account related to that event. Can you share the webhook code that throws the error?
sorry what do you mean by webhook code?
The code that handles the evt_xxx and call Charge.modify() that gives you the 404 error
Found a relevant request code
req_ta7FmaTOT92XXC
not the same event but same issue
ch_3OHOQlJ63lRNHhBz1aONyNYg
evt_3OHOQlJ63lRNHhBz1Bh1qHlq
I can't send you the full code as obviously its internal. The part that fails is:
stripe.stripe.Charge.modify(
charge_id,
description=payment_details.item.display_id(),
metadata={
'payment_id': payment.id,
**payment_details.stripe_metadata(branch, role),
},
)
It cannot reach here unless the event is a charge.succeeded event
As my colleague predicted, the Charge exists on the connected account, but you're trying to modify it on the Platform, that's why it can't be found.
You need to add a Stripe-Account header to your modify request: https://stripe.com/docs/connect/authentication
Im sorry but that doesn't make sense. Why would it then succeed on the third attempt?
Could you please share the successful Request ID?
evt_3OHOQlJ63lRNHhBz1Bh1qHlq
req_L4hSJEQumFhC0Q
It seems this one is made with an OAuth access token.
That's why it's correctly accessing the Charge on the Connected account.
Can you show me this, as we didn't change any code and we use the stripe sdk for this
I don't think you can see this info on the Dashboard.
But are you using OAuth access tokens?
How are you seeing it then?
We have a model for Stripe which applies the relevant keys for the relevant clients whenever initialised then we just call stripe.Charge.modify or whatever end point we are trying to reach
import stripe
return stripe
self.stripe.api_key = branch.stripe_secret_key
Those are two seperate bits of code, one where we are importing stripe package to use and a second where we assign the keys. We haven't had to use specific Oauth anywhere because of this
I can see more details on my side.
It's more reliable to use the Stripe-Account header when making requests on behalf of the Connected accounts, instead of trying to manage all the keys: https://stripe.com/docs/connect/authentication
Can you show me the difference between the successful anbd failed requests then please?
I don't see how this helps or is related. We haven't changed our security methods, we aren't having other random 1 off issues because of the way we use keys.
I'm asking if there is a reason the charge doesn't exist when it clearly does in the system. If there is a reason like the system was slow or something that would be really useful to know.
I don't know why, but your code fails to provide the OAuth token when fetching the Charge, that's why it's looking for it on the Platform instead of the Connected account.
This code doesn't tell me much about how you're actually handling the keys:
import stripe
return stripeself.stripe.api_key = branch.stripe_secret_key
Can you show me the difference here because im really finding it hard to believe with 0 evidence.
I also don't understand how it could know the platform keys considering the only keys that i can see applied are related specifically to the connect account.
Sorry if the code isn't clear enough ill make it clearer.
`import stripe
stripe.public_key = object.stripe_public_key
stripe.api_key = object.stripe_secret_key
stripe.Charge.modify(
charge_id,
description=payment_details.item.display_id(),
metadata={
'payment_id': payment.id,
**payment_details.stripe_metadata(branch, role),
},
)
`
Unfortunately discord isn't the best for writting code out but i hope it is clear enough
you can use
backticks
the only keys that i can see applied are related specifically to the connect account.
so you mean you integrate the legacy way where you have some API keys you obtained during OAuth connecting to the account and use those? reading the backscroll, seems that way
so really yeah, all this means is you used your platform API key instead of the correct API key for the connected account, or vice versa, not sure what we can add
Yeah is there anyway you can show that happening? I can't see how thats possible in my code and would need to be able to recreate it
As far as i can see, we did the exact same thing 3 times and it magically worked the third so being able to see what changed would be incredibly useful
oh my god
I profusely apologise for getting aggy throughout
This is completely on me
As you said platform key I assumed you meant the platform key related to the connected account
where it is our other platofrm
Thank you very much for trying to help although why couldn't anyone show me the requests?
would have made this a lot quicker