Working with Payplans Triggers. - readybytes/PayplansCustomApp GitHub Wiki
If you have create an skeleton of your new app. Now, what to do with it. You have create it that is suppose to do some work. Like you want to assign some group in other component on Subscription active, want to send a curl request on invoice paid or throw a sql query on transaction creation. Whatever you want to do with this plugin you need to use trigger of Payplans to work.
Here is the example shows you how to work with the trigger of Payplans.
public function onPayplansSubscriptionAfterSave($prev, PayplansSubscription $new)
{
// no need to trigger if previous and current state is same
if($prev != null && $prev->getStatus() == $new->getStatus()){
return true;
}
//write the code here you want to do if subscription is active
if ( $newstatus == PayplansStatus::SUBSCRIPTION_ACTIVE ) {
return true;
}
//write the code here you want to do if subscription is hold
if ( $newstatus == PayplansStatus::SUBSCRIPTION_HOLD ) {
return true;
}
//write the code here you want to do if subscription is expire
if ( $newstatus == PayplansStatus::SUBSCRIPTION_EXPIRED ) {
return true;
}
return true;
}