As an administrator, you can enable users to purchase credits for their accounts. Additionally, you can configure automatic billing options, ensuring that users' accounts are updated with the necessary credits. This feature streamlines the process, offering users a convenient experience while maintaining their account balance with minimal manual intervention.
Administrator Set Up
To set this up, follow these steps.
1. Create a new "Service" resource that is requestable:
- Visit the Request tab > Rates, and create one or more rates. Provide a clear description for each rate. For example, a $100 package might credit a user's account with $150, while a $50 package credits $60.
Turn on "Invoice automatically" to ensure users are billed immediately upon request.
- Enable Auto-Cancellation:
- Scroll down and activate "Auto cancel automatically invoiced but unpaid reservations" to cancel unpaid reservations after a set period, giving users time to complete payment.
2. Create a Workflow Trigger:
- Set Up the Trigger:
Navigate to Administration > Workflows > Triggers and click "Create Trigger."
Set the event object to "Requests" since the trigger will activate when a user purchases a package from the Account Top-Up resource.
Ensure the trigger runs only after the cancellation window for the Account Top-Up resource to avoid running before successful payment. Unpaid reservations will be canceled automatically if payment is not completed in time.
- Scroll down and add the following tasks to the trigger:
Run a Script:
The script will determine the package purchased and credit the user's account with the appropriate amount. Amounts should be in cents (e.g., $60 is 6000 cents). Assign a unique Task ID which will be used by the two other tasks to reference the output of the script.
Add this script:amount = 0
if reservation['price_int'] == int(5000):
amount = 6000
if reservation['price_int'] == int(10000):
amount = 15000
amount_dollars = amount * 0.01
return {
'amount_cents':amount,
'vars': {
'DOLLARS': '$' + str(int(amount_dollars))
}
}
Credit or Debit a User’s Account:
Add a task to credit or debit the user's account based on the script's output. Enable "Create account if one does not exist" and input the Task ID from the script task to use the script’s results in the Input Script Task ID field.
Send an Email:
Add an email task to notify users once their account has been credited. Reference the script task ID to include the credit amount in the email by pasting it in the Input Script Task ID.
3. Enable User Payments from Accounts:
If you would like all resources with rates to debit from a user's account you can set that up by going to Administration > Site Settings > Invoices and activate "Allow Payments from Site or Portal Accounts". This will allow all resources to debit from user accounts for payment.
Alternatively, to control which resources can debit user accounts, go to the resource’s Rates tab and enable the "Pay from account automatically" toggle for specific resources.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article