Exigo Developer Resources

This database contains the documentation for Exigo's OData API's, as well as C# sample code and fully-realized demo applications ready to be customized for your needs. Start building downline viewers, reporting tools and shopping carts on the Exigo platform today!

Create an account Sign In

Billing Information


A simple form demonstrating how to set a customer's saved billing information, such as credit card information, using the web service.


The following sample requires these namespaces:

using ExigoWebService;
using System.Xml.Linq;
using System.Net;
using System.Text;
using System.IO;

Exigo API Authentication

This sample accesses the web service using the ExigoApi object:

    public ExigoApi Exigo
            return new ExigoApi
                ApiAuthenticationValue = new ApiAuthentication
                    LoginName = exigoAPILoginName,
                    Password = exigoAPIPassword,
                    Company = exigoAPICompany


We use jQuery UI Themes for styling.

<link href="<%=this.ResolveUrl("../../Themes/start/jquery-ui.custom.css") %>" rel="stylesheet" type="text/css" />
<script src="<%=this.ResolveUrl("../../Scripts/jquery.min.js") %>" type="text/javascript"></script>
<script src="<%=this.ResolveUrl("../../Scripts/jquery-ui.min.js") %>" type="text/javascript"></script>

Fetching Customer Data

We fetch the customer data using the webservice GetCustomersRequest method:

        return Exigo.GetCustomers(new GetCustomersRequest
            CustomerID = customerID

Populate The Country/Region Dropdown Menus

We use the webservice GetCountryRegions method to request a list of countries.

        // Get the data
        var response = Exigo.GetCountryRegions(new GetCountryRegionsRequest()
            CountryCode = countryCode

The webservice RegionResponse method returns the requested regions.

        // Populate the new regions into the dropdown
        foreach (RegionResponse r in response.Regions)
            regionList.Items.Add(new ListItem()
                Value = r.RegionCode,
                Text = r.RegionName

Fetching Credit Card Tokens

    private string GetCreditCardToken(string creditCardNumber, int expirationMonth, int expirationYear)
        XNamespace ns = "http://payments.exigo.com";
        var xRequest = new XDocument(
            new XElement(ns + "CreditCard",
                new XElement(ns + "CreditCardNumber", creditCardNumber),
                new XElement(ns + "ExpirationMonth", expirationMonth),
                new XElement(ns + "ExpirationYear", expirationYear)
        var xResponse = PostRest("https://payments.exigo.com/1.0/rest/CreateCreditCardToken", exigoPaymentAPILoginName, exigoPaymentAPIPassword, xRequest);

        return xResponse.Root.Element(ns + "CreditCardToken").Value;

    private XDocument PostRest(string url, string username, string password, XDocument element)
        string postData = element.ToString();

        var request = (HttpWebRequest)WebRequest.Create(url);
        request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(username + ":" + password)));
        request.Method = "POST";
        request.ContentLength = postData.Length;
        request.ContentType = "text/xml";

        var writer = new StreamWriter(request.GetRequestStream());

            var response = (HttpWebResponse)request.GetResponse();
            using (var responseStream = new StreamReader(response.GetResponseStream()))
                return XDocument.Parse(responseStream.ReadToEnd());
        catch (WebException ex)
            var response = (HttpWebResponse)ex.Response;
            if (response.StatusCode == HttpStatusCode.Unauthorized) throw new Exception("Invalid Credentials");
            using (var responseStream = new StreamReader(ex.Response.GetResponseStream()))
                XNamespace ns = "http://schemas.microsoft.com/ws/2005/05/envelope/none";
                XDocument doc = XDocument.Parse(responseStream.ReadToEnd());
                throw new Exception(doc.Root.Element(ns + "Reason").Element(ns + "Text").Value);

Update Customer Billing

To save the customer's credit card information, we use the webservice method SetAccountCreditCardTokenRequest. The form data is saved as a new credit card token.

    public SetAccountResponse UpdateCustomerBilling()
        // Fetch a credit card token from the Exigo Payment API 
        string creditCardToken = GetCreditCardToken(txtCreditCardNumber.Text, Convert.ToInt32(lstCreditCardExpirationMonth.SelectedValue), Convert.ToInt32(lstCreditCardExpirationYear.SelectedValue));

        SetAccountCreditCardTokenRequest request = new SetAccountCreditCardTokenRequest();

        request.CustomerID = customerID;

        // Credit Card Information
        request.CreditCardToken = creditCardToken;
        request.BillingName = txtBillingName.Text;
        request.ExpirationMonth = Convert.ToInt32(lstCreditCardExpirationMonth.SelectedValue);
        request.ExpirationYear = Convert.ToInt32(lstCreditCardExpirationYear.SelectedValue);
        request.CreditCardAccountType = creditCardAccountType;

        // Billing Address Information
        request.BillingAddress = txtBillingAddress.Text;
        request.BillingCity = txtBillingCity.Text;
        request.BillingState = lstBillingState.SelectedValue.ToString();
        request.BillingZip = txtBillingZip.Text;
        request.BillingCountry = lstBillingCountry.SelectedValue.ToString();

        return Exigo.SetAccountCreditCardToken(request);