Modifying Customer Address
To modify an existing customer’s address information, identify the customer you wish to edit, retrieve the customer's current address information from Stax Bill, apply your desired changes, and resubmit the full customer address information to the Stax Bill system.
Use this tutorial to edit:
- Customer Billing Address
- Customer Shipping Address
Step A - Find the Customer (Optional)
If you have already stored the Stax Bill ID of the customer in your system, you do not need this step.
To find the customer using your own customer code that you have stored on the customer, call:
Read CustomerGET https://secure.fusebill.com/v1/customers/?query=reference:YourCode
Note that while the reference value on a customer is intended to be used for your own customer ID, Stax Bill does not enforce uniqueness on this value. The value that uniquely identifies a customer entity is the Stax Bill generated id. This call is actually returning a list of customers, filtered by their reference value. For more details on query parameters, see the string filtering section on the developer reference
Sample Request
curl -X GET "https://secure.fusebill.com/v1/customers?query=reference:YourCode" \
-H "Content-Type: application/json" \
-H "Authorization: Basic YourAPIKeyHere"//query parameter
int queryParameter = "?query=reference:YourCode";
//Setup API key
string apiKey = "Your Api Key Here";
//Configure URI
WebRequest request = WebRequest.Create("HTTPS://secure.fusebill.com/v1/customers/"+queryParameter);
//Add Content type
request.ContentType = "application/json";
//Add Api key authorization
request.Headers.Add(HttpRequestHeader.Authorization, "Basic "+apiKey);
//Set request method
request.Method = "GET";
//Perform the request
var httpResponse = (HttpWebResponse)request.GetResponse();
//Record the response from our request
var result = "";
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
result = streamReader.ReadToEnd();
}Sample Response
[
{
"firstName":"John",
"middleName":null,
"lastName":"Smith",
"companyName":"Acme Inc.",
"suffix":null,
"primaryEmail":null,
"primaryPhone":null,
"secondaryEmail":null,
"secondaryPhone":null,
"title":"Mr",
"reference":null,
"status":"Draft",
"customerAccountStatus":"Good",
"currency":"USD",
"customerReference":{
"reference1":null,
"reference2":null,
"reference3":null,
"salesTrackingCodes":[
],
"id":169456,
"uri":"https://secure.fusebill.com/v1/customers/169456"
},
"customerAcquisition":{
"adContent":null,
"campaign":null,
"keyword":null,
"landingPage":null,
"medium":null,
"source":null,
"id":169456,
"uri":"https://secure.fusebill.com/v1/customers/169456"
},
"monthlyRecurringRevenue":0.0000,
"netMonthlyRecurringRevenue":0.0000,
"salesforceId":null,
"salesforceAccountType":null,
"salesforceSynchStatus":"Enabled",
"netsuiteId":null,
"netsuiteCustomerType":"",
"portalUserName":null,
"parentId":null,
"id":169456,
"uri":"https://secure.fusebill.com/v1/customers/169456"
}
]Step B - Retrieve Country and State Values (Optional)
The Fusebill System accepts standard iSO and iSO3 values for Countries and States. To get a list of all possible code values that can be accepted by the Stax Bill System, call:
Read Country List
Sample Request
curl -X GET "https://secure.fusebill.com/v1/countries/" \
-H "Content-Type: application/json" \
-H "Authorization: Basic {APIKey}"//Setup API key
string apiKey = "{APIKey}";
//Configure URI
WebRequest request = WebRequest.Create("HTTPS://secure.fusebill.com/v1/Countries");
//Add Content type
request.ContentType = "application/json";
request.ContentLength = 0;
//Add Api key authorization
request.Headers.Add(HttpRequestHeader.Authorization, "Basic "+apiKey);
//Set request method
request.Method = "GET";
//Perform the request
var httpResponse = (HttpWebResponse)request.GetResponse();
//Record the response from our request
var result = "";
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
result = streamReader.ReadToEnd();
}Step 1 - Retrieve all Addresses That Belong to the Customer
In order to identify the required address ID to be modified, you will need to retrieve the current address configuration on the customer. To do this call Read Address Preferences:
Read All AddressesGET https://secure.fusebill.com/v1/customeraddresspreferences/FusebillID
Sample Request
curl -X GET "https://secure.fusebill.com/v1/customerAddressPreferences/1234" \
-H "Content-Type: application/json" \
-H "Authorization: Basic YourAPIKeyHere"//path parameter, Fusebill Id which corresponds to the Id Field Returned by Create/Update customer
int pathParameter = 1234;
//Setup API key
string apiKey = "Your Api Key Here";
//Configure URI
WebRequest request = WebRequest.Create("HTTPS://stg-secure.fusebill.com/v1/customerAddressPreferences/"+pathParameter);
//Add Content type
request.ContentType = "application/json";
request.ContentLength = 0;
//Add Api key authorization
request.Headers.Add(HttpRequestHeader.Authorization, "Basic "+apiKey);
//Set request method
request.Method = "GET";
//Perform the request
var httpResponse = (HttpWebResponse)request.GetResponse();
//Record the response from our request
var result = "";
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
result = streamReader.ReadToEnd();
}Sample Response
{
"contactName":"Mr John Smith",
"shippingInstructions":null,
"useBillingAddressAsShippingAddress":true,
"billingAddress":{
"customerAddressPreferenceId":169456,
"companyName":"Fusebill",
"line1":"232 Herzberg Road",
"line2":"Suite 203",
"countryId":124,
"country":"Canada",
"stateId":9,
"state":"Ontario",
"city":"Kanata",
"postalZip":"K2K 2A1",
"addressType":"Billing",
"id":104504,
"uri":"https://secure.fusebill.com/v1/customerAddressPreferences/104504"
},
"shippingAddress":null,
"id":169456,
"uri":"https://secure.fusebill.com/v1/customerAddressPreferences/169456"
}Step 2 - Edit the Desired Address
Copy the object from billingAddress or shippingAddress as desired. This will be the JSON for the upcoming request. Edit the JSON as desired.
Update Address
Sample Request
curl -X PUT "https://secure.fusebill.com/v1/Addresses" \
-H "Content-Type: application/json" \
-H "Authorization: Basic YourAPIKeyHere" \
-d "{customerAddressPreferenceId:YourCustomerIdHere,id:YourAddressIdHere,companyName:'Fusebill',line1:'232 Herzberg Road',line2:'Suite 203',countryId:124,country:'Canada',stateId:9,state:'Ontario',city:'Kanata',postalZip:'K2K 2A1',addressType:'Billing'}"/Json data, Fusebill Id which corresponds to the customerId Field
string jsonData ="{customerAddressPreferenceId:YourCustomerId,id:AdressId,companyName:'Fusebill',line1:'232 Herzberg Road',line2:'Suite 203',countryId:124,country:'Canada',stateId:9,state:'Ontario',city:'Kanata',postalZip:'K2K 2A1',addressType:'Billing'}";
//Setup API key
string apiKey = "Your Api Key Here";
//Configure URI
WebRequest request = WebRequest.Create("HTTPS://secure.fusebill.com/v1/Addresses");
//Add Content type
request.ContentType = "application/json";
//Add Api key authorization
request.Headers.Add(HttpRequestHeader.Authorization, "Basic "+apiKey);
//Set request method
request.Method = "PUT";
//Add the json data to request
using (var streamWriter = new StreamWriter(request.GetRequestStream()))
{
streamWriter.Write(jsonData);
streamWriter.Flush();
streamWriter.Close();
}
//Perform the request
var httpResponse = (HttpWebResponse)request.GetResponse();
//Record the response from our request
var result = "";
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
result = streamReader.ReadToEnd();
}Sample Response
{
"customerAddressPreferenceId": 84421,
"companyName": "DarkSide Inc.",
"line1": "768 Farside",
"line2": null,
"countryId": "124",
"country": "Canada",
"stateId": 9,
"state": "Ontario",
"city": "Ottawa",
"postalZip": "K3Y9Y7",
"addressType": "Billing",
"id": 63406
}Updated about 1 year ago
