function stripe_customer_from_webhook in Stripe 7
Retrieve a Stripe Customer from a webhook event.
Parameters
$event: A safely-loaded \Stripe\Event.
Return value
bool|\Stripe\Customer A fully-loaded Stripe Customer if successful, FALSE otherwise.
File
- stripe_customer/
stripe_customer.module, line 91 - Provides integration with Stripe and Drupal Users as Customers.
Code
function stripe_customer_from_webhook($event) {
stripe_load_library();
if (!$event instanceof \Stripe\Event) {
$event = \Stripe\Event::retrieve($event->id);
}
if ($event->data->object->object == 'customer') {
$customer = stripe_get_customer($event->data->object);
}
else {
$customer = stripe_get_customer($event->data->object->customer);
}
return isset($customer) ? $customer : FALSE;
}