#theconfused_

1 messages · Page 1 of 1 (latest)

tiny patioBOT
viral schooner
#

Hello there. Can you share the evt_xxx that failed?

brisk egret
#

soorry theres 4 but ill just get one

#

evt_3OHOvJJ63lRNHhBz0tbA5Puy

viral schooner
#

Also, what endpoint do you call in your webhook that returns the No such Charge error?

brisk egret
#

the first two hooks fail returned a 500 because we got a 404 trying to modify the charge at CHarge.modify

viral schooner
#

Do you happen to have the req_xxx IDs for those 404 requests?

brisk egret
#

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'

viral schooner
#

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

brisk egret
#

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

viral schooner
#

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?

brisk egret
#

sorry what do you mean by webhook code?

viral schooner
#

The code that handles the evt_xxx and call Charge.modify() that gives you the 404 error

brisk egret
#

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

plucky heron
#

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

brisk egret
#

Im sorry but that doesn't make sense. Why would it then succeed on the third attempt?

plucky heron
#

Could you please share the successful Request ID?

brisk egret
#

evt_3OHOQlJ63lRNHhBz1Bh1qHlq
req_L4hSJEQumFhC0Q

plucky heron
#

It seems this one is made with an OAuth access token.

#

That's why it's correctly accessing the Charge on the Connected account.

brisk egret
#

Can you show me this, as we didn't change any code and we use the stripe sdk for this

plucky heron
#

I don't think you can see this info on the Dashboard.

#

But are you using OAuth access tokens?

brisk egret
#

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

plucky heron
brisk egret
brisk egret
plucky heron
#

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 stripe

self.stripe.api_key = branch.stripe_secret_key

tiny patioBOT
brisk egret
#

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

prisma sequoia
#

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

brisk egret
#

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