Enabling an Account on Payment Using Workflows
The following Workflow will enable an account on payment.
Configuration
This script checks the users balance when a payment is made, if the balance is equal to or less than zero, the account will be enabled.
Workflow Event
Name – “Payment”
Event Code – Payment.Create
Action Script
Name – “Enable customer on payment”
Payment pay = Payment.GetByID(Convert.ToInt32(context["PaymentID"]));
User user = User.GetByID(pay.GetUser().ID);
ViewUserBalanceFuture vubf = ViewUserBalanceFuture.SearchByUserID(user.ID)[0];
if (vubf.Balance <= 0)
{
user.UserStatusTypeID = user.GetActingOwner().SearchUserStatusTypeByName("Enabled")[0].ID;
user.Update();
}
return true;