Skip to content
This repository has been archived by the owner on Feb 2, 2021. It is now read-only.

Text Tutorial

Dan Dumont edited this page Jul 13, 2019 · 6 revisions

Contents


Installation

Please remember WHMCS_2019 is the package name, not WHMCS_API. WHMCS_API is the outdated version.


Normal Implementation

using System;
using WHMCS;
using WHMCS.Clients;

namespace WHMCS_Example
{
    public partial class Example
    {
        private void Example_Load()
        {
            try
            {
                API api = new API("WHMCS_USERNAME", "WHMCS_PASSWORD", "WHMCS_ACCESSKEY", "WHMCS_FRONTEND_URL");
                Contact contact = new Contact("Bill", "Gaits", "Microhard", "BillGaits@mmail.com");
                int contactId = api.AddContact(1, contact);

                Console.WriteLine("Contact Id: {0}", contactId);
            }
            catch (Exception exception)
            {
                Console.WriteLine("API Error: {0}", exception.Message);
            }
        }
    }
}

Asynchronous Implementation

using System;
using System.Threading.Tasks;
using WHMCS;

namespace WHMCS_Example
{
    public partial class Example
    {
        private async Task ExampleAddInvoiceAsync(int invoiceId, string transactionId, string gateway)
        {
            try
            {
                API api = new API("WHMCS_USERNAME", "WHMCS_PASSWORD", "WHMCS_ACCESSKEY", "WHMCS_FRONTEND_URL");
                await api.AddInvoicePaymentAsync(invoiceId, transactionId, gateway);
            }
            catch (Exception exception)
            {
                Console.WriteLine("API Error: {0}", exception.Message);
            }
        }
    }
}