PHP code example of samandeggs / silverstripe-stripewebhook
1. Go to this page and download the library: Download samandeggs/silverstripe-stripewebhook library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
samandeggs / silverstripe-stripewebhook example snippets
use Stripe\Event;
use Vulcan\StripeWebhook\Handlers\StripeEventHandler;
use SilverStripe\Security\Member;
class CustomerEventsHandler extends StripeEventHandler
{
private static $events = [
'customer.created',
'customer.deleted'
];
public static function handle($event, Event $data)
{
// $event is the string identifier of the event
if ($event == 'customer.created') {
// create member
return "Member created";
}
$member = Member::get()->filter('Email', $event->data->object->email)->first();
if (!$member) {
return "Member did not exist";
}
$member->delete();
return "Member deleted";
}
}