} pmpro_stripeWebhookExit(); } } elseif ($event->type == "customer.subscription.deleted") { //for one of our users? if they still have a membership, notify the admin $user = getUserFromCustomerEvent($event, "success", true); if (!empty($user->ID)) { do_action("pmpro_stripe_subscription_deleted", $user->ID); $pmproemail = new PMProEmail(); $pmproemail->data = array("body" => "<p>" . sprintf(__("%s has had their payment subscription cancelled by Stripe. Please check that this user's membership is cancelled on your site if it should be.", "pmpro"), $user->display_name . " (" . $user->user_login . ", " . $user->user_email . ")") . "</p>"); $pmproemail->sendEmail(get_bloginfo("admin_email")); $logstr .= "Subscription deleted for user ID #" . $user->ID . ". Event ID #" . $event->id . "."; pmpro_stripeWebhookExit(); } else { //check for any user at all $user = getUserFromCustomerEvent($event); if (!empty($user->ID)) { $logstr .= "Stripe tells us a subscription is deleted. This was probably initiated from PMPro and the membership/order is already cancelled. Event ID #" . $event->id . "."; } else { $logstr .= "Stripe tells us a subscription is deleted, but we could not find a user here for that subscription. Could be a subscription managed by a different app or plugin. Event ID #" . $event->id . "."; } pmpro_stripeWebhookExit(); } } } else { if (!empty($event_id)) { $logstr .= "Could not find an event with ID #" . $event_id; } else { $logstr .= "No event ID given."; } pmpro_stripeWebhookExit();
} pmpro_stripeWebhookExit(); } } elseif ($pmpro_stripe_event->type == "customer.subscription.deleted") { //for one of our users? if they still have a membership, notify the admin $user = getUserFromCustomerEvent($pmpro_stripe_event, "success", true); if (!empty($user->ID)) { do_action("pmpro_stripe_subscription_deleted", $user->ID); $pmproemail = new PMProEmail(); $pmproemail->data = array("body" => "<p>" . sprintf(__("%s has had their payment subscription cancelled by Stripe. Please check that this user's membership is cancelled on your site if it should be.", "pmpro"), $user->display_name . " (" . $user->user_login . ", " . $user->user_email . ")") . "</p>"); $pmproemail->sendEmail(get_bloginfo("admin_email")); $logstr .= "Subscription deleted for user ID #" . $user->ID . ". Event ID #" . $pmpro_stripe_event->id . "."; pmpro_stripeWebhookExit(); } else { //check for any user at all $user = getUserFromCustomerEvent($pmpro_stripe_event); if (!empty($user->ID)) { $logstr .= "Stripe tells us a subscription is deleted. This was probably initiated from PMPro and the membership/order is already cancelled. Event ID #" . $pmpro_stripe_event->id . "."; } else { $logstr .= "Stripe tells us a subscription is deleted, but we could not find a user here for that subscription. Could be a subscription managed by a different app or plugin. Event ID #" . $pmpro_stripe_event->id . "."; } pmpro_stripeWebhookExit(); } } } else { if (!empty($event_id)) { $logstr .= "Could not find an event with ID #" . $event_id; } else { $logstr .= "No event ID given."; } pmpro_stripeWebhookExit();