#adityaj-webhook

1 messages · Page 1 of 1 (latest)

next heath
#

hi! can you share the rest of the code?
and what's the issue exactly(what error do you get etc)?

drifting creek
#

getting error message
"You are not permitted to configure webhook endpoints on a connected account. Did you mean to create a Connect webhook on your account instead?"

#

code is

$stripe_api = new StripeClient(
[
'api_key' => $secret_key, //access token received by oauth
'stripe_version' => '2020-08-27',
]
);

$data = [
'api_version' => '2020-08-27',
'url' => esc_url( get_home_url() . '/wp-json/cpsw/v1/webhook' ),
'connect' => true,
'enabled_events' => [
'charge.failed',
'charge.succeeded',
'source.chargeable',
'payment_intent.succeeded',
'charge.refunded',
'charge.dispute.created',
'charge.dispute.closed',
'review.opened',
'review.closed',
],
];

$response = $stripe_api->webhooks( 'create', [ $data ] );

next heath
#

yep! as the error says, you're not allowed to do that.

drifting creek
#

One more thing i would like to confirm.
is there a way to retrieve secret key of connected account while Oauth
\Stripe\OAuth::token

next heath
#

you should never be using OAuth

#

and you 100% should never be using the API keys like that

drifting creek
next heath
#

sure, but why?

#

OAuth is the older way of doing this and it would only be used today for certain limited use cases where you are an extension that explicitly needs to read data from a user's existing Stripe account)

#

in any case even if you do use OAuth, never use the access_token

#

you don't need it, you only need the stripe_user_id , per the authentication guide I linked above, it's much easier than storing a bunch of secret keys in your database

drifting creek
#

ok

#

let me try

#

actually we are creating an extension and we want user to use their existing account.
this guide says to create standard-account.
which is not our use case

can you suggest me better way for this condition, any code reference to charge account without using access_token

next heath
#

any code reference to charge account without using access_token
what does "charge account" mean?

drifting creek
#

create any stripe transaction like charge refund etc.

#

currently i am using access token
for any api call

like this

$stripe_api = new StripeClient(
[
'api_key' => $secret_key, //access token received by oauth
'stripe_version' => '2020-08-27',
]
);

next heath
drifting creek
#

ok i'll try that thanx

drifting creek
#

I was looking into authentication url
but as we will be shipping our plugin to users. so will it be good idea to share stripe secret key? what else can be done?

silk jackal
#

You'd guide your plugin users through the onboarding experience via the OAuth link

drifting creek
#

yes we are doing that.
after authentication we are storing access_token and publishable key for further use.
but access_token is not able to create webhook_endpoints.

what is the prefered way to do that.
we can't share platform secret key with plugin

silk jackal
drifting creek
#

can you share some php code reference for creating connect webhook.

#

or any documentation link explaining same

silk jackal
#

I just linked you the docs. Why would you need code? You'd just configure it in the Dashboard

#

You only need a single Connect webhook on your platform account

drifting creek
#

we are creating a wordpress plugin for woocommerce and our plugin (extension) will be installed on clients website we are not having any centalized application where user can connect with api. and webhook url will change as per users website url.
we need to create a webhook that will respond to users website and further status on woocommerce can be updated.

#

i hope my use case is clear now.

silk jackal
#

Well, you can't do that. You can't create a webhook for a connected account without their secret keys and you so never be storing them, really

#

You should instead have a single Connect webhook endpoint that processes events for all your connected accounts