How to notify members of new invoices by email

Fabman can make it easy for you to bill your members. Charges and invoices are generated automatically and can also be debited directly from your members’ credit card if required.

With this little PHP script you can automatically inform your members via email as soon as a new invoice has been created. It is called via a webhook:


	// Add a webhook for Invoice events in Fabman
	// Call the webhook like this:

	$token = "jeKEGHx34kjDFab";
	if ($_GET['secret'] != $token) {
		print "Webhook not executed due to wrong token (url?secret=token)";

	$obj = json_decode(file_get_contents("php://input"));	

	$url = "".$obj->{'details'}->{'member'}->{'account'}."/billing/invoices/".$obj->{'details'}->{'invoice'}->{'id'};

	$email_to = $obj->{'details'}->{'member'}->{'emailAddress'};
	$subject = "New Fabman invoice available";
	$content = "Download invoice here: ".$url;
	$email_from = ""; // set your sender email address!
	mail($email_to, $subject, $content, $email_from);

Log in to Fabman, go to “Configure / Integrations & API” and add a new Webhook:

Further technical details on Fabman webhooks can be found here:

1 Like