Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pulling out from webhook patron data (email , name, pledge amount, etc) #94

Open
ITEvo opened this issue Jun 13, 2022 · 2 comments
Open

Comments

@ITEvo
Copy link

ITEvo commented Jun 13, 2022

Is there an easy way to pull out data from a webhook?

Maybe it's me, but I've not found any kind of documentation, example, anything.
Not here, not on patreon's api...

I need to create a """"simple"""" script which will do

retrieved data > to variables

if pledge:create do stuff
if pledge:delete do stuff
if pledge:update do stuff

Is that so hard to achieve?

@Im-Fran
Copy link

Im-Fran commented May 17, 2023

Actually there's is a document here: https://docs.patreon.com/#webhooks

You can take from here the idea on how to validate the signature:
https://github.com/Patreon/patreon-wordpress/blob/e5c0656b5e0631abbfa93b18ca110c7abd1aafab/classes/patreon_routing.php#L651-L665

And then you can just use this to fetch the json data:

json_decode($raw_post_data, true);

$raw_post_data is the content of the post request as string.

I'm posting this now cuz I was having the same issue, but found this solution. Haven't tried it yet, but let me know if it helps :)

@Im-Fran
Copy link

Im-Fran commented May 17, 2023

Oh, and to check by event you can get the header X-Patreon-Event and check with that, like:

$type = $headers['X-Patreon-Event'];

if($type === 'pledge:create'){
  // TODO
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants