4 Customer API


The related collection of entities associated with the "Customer": 
  • Customer - the main entity that represents the account being invoiced. This may represent either an individual or an organization
  • billingContact - this child entity of the customer represents the specific contact (individual) that will receive the invoice. The "Bill To" fields on the invoice will reflect this value if not overridden at the invoice level. This entity is required when creating a Customer entity. Note that the billingContact is an instance of the CustomerContact class.
  • salesContact - this child entity of the customer is optional and represents the default "Ship To" details. As before, an invoice may override the "Ship To" fields for that specific invoice. Note that the salesContact is an instance of the CustomerContact class.
  • CustomerFinancials - this entity represents provides a snapshot of the customer's current financial standing with fields such as current balance, last payment, etc.
  • PaymentMethodDTO - this is a generic Data Transfer Object that contains a specific payment method embedded inside. This is used when you wish to automatically charge the customer on the invoice due date by having the customer's payment information on file. Examples of the specific payment method include creditCardPaymentMethod and achPaymentMethod.

Customer Fields


Field Name

Data Type

Required

(C = Conditional)

Notes

Record Type

String(3)

Y

Must be set to “CUS”

Update Mode

String(1)

N

U = Update

I = Insert (default)

Set to “U” to indicate this is a previously sent invoice that now needs to be updated (e.g., the invoice was adjusted or cancelled). If blank, defaults to “I’ indicating Insert.

Customer Account Number

String (50)

Y

The unique customer account that is displayed on invoice.

CRM Customer ID

String (25)

N

This is the internal ID of the customer in the CRM system. Used to synchronize information between systems

ERP Customer ID

String (25)

N

This is the internal ID of the customer in the ERP system. Used to synchronize information between systems

CUS Custom Options

String (100)

N

Used for customization, leave blank unless instructed otherwise

Postal Mail Enabled

Boolean

N

If Y, then invoices will be delivered by first class US postal mail. Please contact support beforehand, additional charges apply.

Notification Preference

Enum

N

refers to the customer preference in receiving their invoices, payment receipts. They can choose between

'None' - No Emails except dunning/overdue notices

 

'HTMLEmail' - Email contains invoice in HTML format

 

'EmailWithPDF' - HTML email with pdf attachment (Default)

 

Currency Code

String(3)

N

Currency code, default to “USD” if not provided

Outstanding Balance

Money

N

Set this value to indicate the net total of what the customer owes across all open invoices. Usually set on the initial load only to indicate any carried forward balances.

Display Name

String (100)

N

Override to display a different name from the first and last name.

Status

Enum

N

 

Custom Field1

String (100)

N

Please contact support for custom fields. These fields display on the “Settings” tab of the Customer Account Summary page in the eBill admin portal.

Custom Field2

String (100)

N

 

Custom Field3

String (100)

N

 

Custom Field4

String (100)

N

 

Custom Field5

String (100)

N

 

Custom Field6

String (100)

N

 

Custom Field7

String (100)

N

 

Custom Field8

String (100)

N

 

Custom Field9

String (100)

N

 

Custom Field10

String (1,000)

N

Note that the 10th field is extra long and is stored encrypted.



CustomerContact Fields

First Name

String (30)

Y

Billing Contact’s First Name

Last Name

String (30)

Y

Billing Contact’s Last Name

Company Name

String (50)

N

Name of the Organization

Primary Email

String (100)

Y

Email that invoice notifications and payments receipts are sent.

Login

String (50)

C

Used by the customer to manage their account information. If left blank, system will use the email as the Login. Not applicable if the customer will not be using the self-service portal

Password

String (50)

C

Used by the customer to manage their account. The system can auto generate this field if desired. Not applicable if the customer will not be using the self-service portal. This field cannot be retrieved again since a cryptographically secure hash of the password is stored.

Primary Phone

String (10-30)

N

If supplied, must be between 10 to 30 characters

Cell Phone

String (10-30)

N

If supplied, must be between 10 to 30 characters

Street

String (100)

N

Customer address will be used as the default “Bill To” address if there is no “Bill To” address at the Invoice level.

Suite/Dept

String (100)

N

City

String (50)

N

State / Province

String (50)

N

Zip / Postal Code

String (20)

N

Country

String (50)

N

The following payment methods must be encapsulated inside a generic PaymentMethodDTO object. See the Section 4.1.7 for an example.

CreditCardPaymentMethod Fields

Field Name

Data Type

Required

(C = Conditional)

Notes

Customer Account Number

String (50)

Y

The unique customer account that is displayed on invoice.

CRM Customer ID

String (25)

N

This is the internal ID of the customer in the CRM system. Used to synchronize information between systems

ERP Customer ID

String (25)

N

This is the internal ID of the customer in the ERP system. Used to synchronize information between systems

CCD Custom Options

String (100)

N

Used for customization, leave blank unless instructed otherwise

Autopay preference

Integer

N

A number from 1 to 3 indicating the order in which payments will be attempted if this customer has more than 1 payment method on file. If blank, then 1 is assumed

Credit Card No

String(20)

Y

The credit card number (saved in encrypted form). This field cannot be retrieved once processed.

Card Expiry Date

String(10)

Y

The credit expiry date in MM/YYYY format (saved in encrypted form). This field cannot be retrieved once processed.

 

Card Type

String(16)

Y

Valid card types are one of:

'Mastercard', 'Visa', 'Amex', 'Discover', 'JCB', 'Diners'

Cardholder Name

String (100)

N

Note that not sending these values will affect your AVS (address validation service), and consequently the merchant fees charged by your payment processor

Cardholder Street

String (100)

N

Cardholder City

String (50)

N

Cardholder State

String (50)

N

Cardholder Zip

String (20)

N

Cardholder Country

String (50)

N



ACHPaymentMethod Fields

Field Name

Data Type

Required

(C = Conditional)

Notes

Customer Account Number

String (50)

Y

The unique customer account that is displayed on invoice.

CRM Customer ID

String (25)

N

This is the internal ID of the customer in the CRM system. Used to synchronize information between systems

ERP Customer ID

String (25)

N

This is the internal ID of the customer in the ERP system. Used to synchronize information between systems

ACH Custom Options

String (100)

N

Used for customization, leave blank unless instructed otherwise

Autopay preference

Integer

N

A number from 1 to 3 indicating the order in which payments will be attempted if this customer has more than 1 payment method on file. If blank, then 1 is assumed

ABA Routing Number

String (9)

Y

The 9 digit routing number found on the check that identifies the unique FDIC bank.

Account Number

String (128)

Y

The customer’s bank account number

Institution Name

String (50)

Y

Name of Bank

Account Type

String (16)

Y

Must be “Savings” or “Checking” to indicate the account type.

Account Name

String (50)

Y

This is normally the company name or the account holder name.

First Name

String (50)

N

These settings may be required depending on your ACH processor/bank

Last Name

String (50)

N

Accountholder Street

String (100)

N

Accountholder City

String (50)

N

Accountholder  State

String (50)

N

Accountholder Zip

String (20)

N




4.1 Retrieve Customer

Note: eBill will NEVER return any of the *PaymentMethod objects or sensitive fields like passwords for security reasons (you may replace the current values however).

GET /rest/customer/[id]?format=xml
GET /rest/customer? format=xml&extCustomerRef=[code]


4.2. Retrieve CustomerContact

Returns either the billingContact or SalesContact


GET /rest/customer/[id]/salesContact?format=xml
GET /rest/customer/salesContact?format=xml&extCustomerRef=[code]
GET /rest/customer/[id]/billingContact? format=xml
GET /rest/customer/billingContact?format=xml&extCustomerRef=[code]



4.3. Retrieve multiple Customers

Returns a list of matching customers



GET /rest/customers?format=xml&search=[searchTerm]

Returns a paged list of customers.
Defaults used if the query string parameters are missing:
   statusValue = ignored if not defined
   offset=0
   max=50


GET /rest/customers? format=xml&offset=[n]&max=[m]&status=[statusValue]

4.4. Create a new Customer

The XML that is POSTED should contain the Customer object, the billingContact (required) and optionally the salesContact. It returns the full XML (same response as the "GET customer/[id]?format=xml"

POST /rest/customers?format=xml

Sample POST payload:



<customer>
  <name>Acme Co</name> 
  <status>Active</status>
  <extCustomerRef>bj444</extCustomerRef>   <crmCustomerId>xyz12345</crmCustomerId> 
  <erpCustomerId>abc9876</erpCustomerId> 
  <isBusinessAccount>true</isBusinessAccount>
  <paymentTermsValue>30</paymentTermsValue>
  <paymentTermsUnits>Days</paymentTermsUnits>
  <currency id="USD"/>
  <billingContact>
    <username>bill0004</username>
    <passwd>Sachxwe001</passwd>
    <firstName>Bill</firstName>
    <lastName>Joseph</lastName>
    <emailPrimary>Bill@acme.com</emailPrimary>
    <workPhone>555 555 1234</workPhone>
    <address>
      <street1>43 Main Av</street1>
      <city>Chicago</city>
      <state>IL</state>
      <zip>12345</zip>
      <country>United States</country>
      <countryCode>usa</countryCode>
    </address>
  </billingContact>
</customer>

 

4.5. Update an existing Customer

The XML that is POSTED could contain only the Customer object, or it could optionally include the billingContact and the salesContact. It returns the full XML (same response as the "GET customer/[id]? format=xml"



PUT /rest/customer/[id]?format=xml
PUT /rest/customer? format=xml&extCustomerRef=[code]

The following calls permit an existing Customer Contact to be updated. The returned XML is the same as the corresponding GET call



PUT /rest/customer/[id]/salesContact?format=xml
PUT /rest/customer/ [id]/billingContact?format=xml
PUT /rest/customer/salesContact?format=xml&extCustomerRef=[code]
PUT /rest/customer/billingContact?format=xml&extCustomerRef=[code]


4.6. Delete a Customer

It returns the confirmation status



DELETE /rest/customer/[id]?format=xml
DELETE /rest/customer? format=xml&extCustomerRef=[code]


4.7. Add or Replace an autopay method

The XML that is POSTED should contain one paymentMethodDTO. Inside the we could have either an or a . This maps to the customerService.savePaymentMethod.

Returns success or error XML. Note that PaymentMethods such as credit cards and ACH cannot be queried / retrieved for security reasons, they can only be created or updated. If the autopayPreference field is the same, then the previous autopay method will be replaced by the current one. Note that each customer can have up to 3 payment methods on file as indicated by the <autopayPreference> value which can range from 1 to 3. The system will process payment using the 1st preferred payment method, and try the 2nd preferred payment method only if the 1st one declines, etc.

If the "validate=true" is passed in with the querystring params, then the credit card is validated via a call to the configured payment gateway (note: this requires that your payment gateway permits $0 transactions, please check beforehand on approvals required and transaction charges)



PUT /rest/customer/[id]/autopay?format=xml&validate=true
PUT /rest/customer/autopay?format=xml&extCustomerRef=[code]&validate=true


Sample POST:

<autopay>
  <paymentMethodDTO type="CreditCard">
    <creditCardPaymentMethod>
      <autopayPreference>1</autopayPreference>
      <cardNumber>4111111111111111</cardNumber>
      <expiry>2010-12-31</expiry>
      <cardType>Visa</cardType>
      <cardholderName>John Villanova</cardholderName>
      <cvv>1234</cvv>
      <billingAddress>
        <street1>9872 Central St</street1>
        <city>Anytown</city>
        <state>AK</state>
        <zip>11001</zip>
        <country>USA</country>
      </billingAddress>
    </creditCardPaymentMethod>
  </paymentMethodDTO>
</autopay>


4.8. Other operations on a Customer

The [actionName] may be one of the following:

  [suspend] - suspend a customer's billing activity.
  [activate] - activate a new customer or a suspended customer.



POST /rest/customer/[id]?format=xml&actionName=[command]
POST /rest/customer?format=xml&extCustomerRef= [code]&actionName=[command]

4.9 Customer Transitions

Customers can transition between various states depending on whether their accounts are current or overdue ("ageing" or "dunning"). The actual transitions may be configured by logging into BluBilling and accessing the "System >> Overdue Notifications" menu. The following states are available:


        'Active',

        'Overdue1',

        'Overdue2',

        'Overdue3',

        'Suspended1',

        'Suspended2',

        'Suspended3',

        'InActive1',

        'InActive2',

As an example, you may choose to set the customer status to 'Overdue1" when they are 15 days behind their payment, then change the status to 'Overdue2' at 30 days, and finally to 'Suspended1' at 60 days. So the customer status will change at 15, 30, and 60 days so that you may take appropriate steps on your side such as disabling users, etc.


If you wish to receive a callback notification to your website/application via a HTTP POST, then select the events of interest to you under the "System >> Website Callbacks". On this screen, you can register your URL (https recommended) as well as the events of interest (such as Customer transitions, payment failed, payment success, etc.) The data sent in the HTTP POST is the same XML data that is retrieved in a REST query (see below).

On the other hand, you may wish to query for the customer transitions within a date range:

GET /rest/customers/transitions?format=xml
GET /rest/customers/transitions?format=xml&startDate=[date1]&endDate=[date2]
GET /rest/customers/transitions?format=xml&endDate=[date]&daysAgo=30
Note: The endDate defaults to today if not specified, startDate defaults to 30 days prior to the endDate
Dates must be specified as YYYY-MM-DD (example "2010-12-31" for Dec 12, 2010).

<list>
  <customerTransition id="1">
    <dateTransitioned>2010-11-01</dateTransitioned>
    <previousStatus>Active</previousStatus>
    <newStatus>Overdue1</newStatus>
    <customer id="316">
      <extCustomerRef>JRICH</extCustomerRef>
      ...
    </customer>
  </customerTransition>
  <customerTransition id="2">
    <dateTransitioned>2010-11-01</dateTransitioned>
    <previousStatus>Overdue1</previousStatus>
    <newStatus>Suspended1</newStatus>
    <customer id="832">
      <extCustomerRef>AGEORGE</extCustomerRef>
      ...
    </customer>
  </customerTransition>
</list>

Comments