Update IP and port in WHMCS

Revision as of 11:47, 17 June 2021 by TCAWiki (talk | contribs)

When you create a game server with the billing API WHMCS does not get updated with the game server's IP and port. This can be updated using the built in recurring task or custom scripts.


Option 1 - Built in recurring task to update the WHMCS database every day

  • Go to Settings > Recurring Tasks.
  • Create a new recurring task and configure it to execute daily.
  • In the Actions tab add a new action of type "Sync Service IP with Billing".
  • Enter the information required to connect to your WHMCS database. If you use custom billing software you can specify a custom SQL update command.
  • When the task runs the product's domain field in WHMCS should have the game server's IP and port.

Option 2 Custom recurring task to update the WHMCS database every day using the WHMCS API

import clr
import urllib2
import urllib

clr.AddReference("TCAdmin.GameHosting.SDK")
from TCAdmin.GameHosting.SDK.Objects import Service

WHMCS_URL = "https://your-whmcs-site.com/includes/api.php"
WHMCS_API_IDENTIFIER = "xxxxxxx"
WHMCS_API_SECRET = "yyyyyyy"

AllServices = Service.GetServices()

for ThisService in AllServices:
  Script.WriteToConsole("Updating " + ThisService.ConnectionInfo)
  query = urllib.urlencode({'action' : 'UpdateClientProduct', 'username' : WHMCS_API_IDENTIFIER, 'password' : WHMCS_API_SECRET, 'serviceid' : ThisService.BillingId, 'domain' : ThisService.ConnectionInfo, 'responsetype' : 'json'})
  try:
    urllib2.urlopen(WHMCS_URL, data=query)
  except urllib2.HTTPError, e:
    Script.WriteToConsole("Error updating " + ThisService.ConnectionInfo + ": " + str(e.code) + " " + e.reason)

Option 3 - Use these scripts in the after created event

Update_WHMCS_database_after_the_game_server_has_been_created

Retrieved from "https://help.tcadmin.com/index.php?title=Update_IP_and_port_in_WHMCS&oldid=2435"