crucialwebstudio / chargify-sdk-php

Chargify SDK for PHP
Apache License 2.0
26 stars 44 forks source link

How Can I use WebHooks? #11

Open gerfigna opened 8 years ago

gerfigna commented 8 years ago

I want to handle webhooks using this library.

Can you show me any code sample?

Thanks !

Powerhead13 commented 7 years ago

I've added PR for this. #14 Once it is approved, you will be able to handle webhooks in this way:

 # Handle webhooks

 $webhook = $chargify->webhook()->handle('webhook.log');

 if($webhook) {
     echo $webhook->getEvent() . PHP_EOL; // payment_success
     echo $webhook->getId()  . PHP_EOL; // 112233
     print_r($webhook->getPayload()); // Array 
 }

 // Generate fake webhook for testing
 $webhook = $chargify->webhook()->handleFake();