templates/Subscription.template.js
function (subscription, cb) {

		Subscription.findOrCreate(subscription.id, subscription)
	    .exec(function (err, foundSubscription){
	      if (err) return cb(err);
	      if (foundSubscription.lastStripeEvent > subscription.lastStripeEvent) return cb(null, foundSubscription);
	      if (foundSubscription.lastStripeEvent == subscription.lastStripeEvent) return Subscription.afterStripeCustomerSubscriptionUpdated(foundSubscription, function(err, subscription){ return cb(err, subscription)});
	      Subscription.update(foundSubscription.id, subscription)
	      .exec(function(err, updatedSubscriptions){
	      	if (err) return cb(err);
	      	if(!updatedSubscriptions) return cb(null, null);
	      	Subscription.afterStripeCustomerSubscriptionUpdated(updatedSubscriptions[0], function(err, subscription){
	      		cb(err, subscription);
	      	});
	      });
	    });
	}
function (subscription, cb) {

		Subscription.findOrCreate(subscription.id, subscription)
	    .exec(function (err, foundSubscription){
	      if (err) return cb(err);
	      if (foundSubscription.lastStripeEvent > subscription.lastStripeEvent) return cb(null, foundSubscription);
	      if (foundSubscription.lastStripeEvent == subscription.lastStripeEvent) return Subscription.afterStripeCustomerSubscriptionUpdated(foundSubscription, function(err, subscription){ return cb(err, subscription)});
	      Subscription.update(foundSubscription.id, subscription)
	      .exec(function(err, updatedSubscriptions){
	      	if (err) return cb(err);
	      	if(!updatedSubscriptions) return cb(null, null);
	      	Subscription.afterStripeCustomerSubscriptionUpdated(updatedSubscriptions[0], function(err, subscription){
	      		cb(err, subscription);
	      	});
	      });
	    });
	}
function ( subscription , cb ) { Subscription . findOrCreate ( subscription . id , subscription ) . exec ( function ( err , foundSubscription ) { if ( err ) return cb ( err ) ; if ( foundSubscription . lastStripeEvent > subscription . lastStripeEvent ) return cb ( null , foundSubscription ) ; if ( foundSubscription . lastStripeEvent == subscription . lastStripeEvent ) return Subscription . afterStripeCustomerSubscriptionUpdated ( foundSubscription , function ( err , subscription ) { return cb ( err , subscription ) } ) ; Subscription . update ( foundSubscription . id , subscription ) . exec ( function ( err , updatedSubscriptions ) { if ( err ) return cb ( err ) ; if ( ! updatedSubscriptions ) return cb ( null , null ) ; Subscription . afterStripeCustomerSubscriptionUpdated ( updatedSubscriptions [ 0 ] , function ( err , subscription ) { cb ( err , subscription ) ; } ) ; } ) ; } ) ; }
Stripe Webhook customer.subscription.updated
Stripe Webhook customer . subscription . updated