Scenario: Create/Update Customer
MethodName: CreateCustomer()


Inputs:

WebsiteIDRequired, used to identify configuration
MagentoCustomerIDRequired, used for linking in CPMagento
CPCustomerIDOptional-15 chars, CUST_NODefault “”
EmailOptional-50 chars, EMAIL_ADRS_1Default “”

AccountingEmailOptional-50 chars, EMAIL_ADRS_2Default “”

MarketingEmailOptional-50 chars, EMAIL_ADRS_3Default “”

CompanyNameOptional-40 chars, NAMDefault “”

FirstNameOptional-15 chars, FST_NAMDefault “”

LastNameOptional-15 chars, LST_NAMDefault “”

TaxIDOptional-30 chars, TAX_EXEMPT_NODefault “”

BillAddress1Optional-40 chars, ADRS_1Default “”

BillAddress2Optional-40 chars, ADRS_2Default “”

BillAddress3Optional-40 chars, ADRS_3Default “”


BillCityOptional-20 chars, CITY    Default “”

BillStateOptional-10 chars, STATEDefault “”

BillZipcodeOptional-15 chars, ZIP_CODDefault “”

BillCountryOptional-20 chars, CNTRYDefault “”

ShipCompanyNameOptional-40 chars, AR_SHIP_ADRS.NAMDefault “”

ShipFirstNameOptional-15 chars, 

AR_SHIP_ADRS.FST_NAMDefault “”

ShipLastNameOptional-15 chars, 

AR_SHIP_ADRS.LST_NAMDefault “”

ShipAddress1Optional-40 chars, 

AR_SHIP_ADRS.ADRS_1Default “”

ShipAddress2Optional-40 chars,  

AR_SHIP_ADRS.ADRS_2Default “”

ShipAddress3Optional-40 chars,  

AR_SHIP_ADRS.ADRS_3Default “”

ShipCityOptional-20 chars,  

AR_SHIP_ADRS.CITY    Default “”

ShipStateOptional-10 chars,  

AR_SHIP_ADRS.STATEDefault “”

ShipZipcodeOptional-15 chars,  

AR_SHIP_ADRS.ZIP_CODDefault “”

ShipCountryOptional-20 chars,  

AR_SHIP_ADRS.CNTRYDefault “”

ShipPhoneOptional-25 chars,   

AR_SHIP_ADRS.PHONE_1Default “”

CategoryOptional-* chars, Default “”

use “retail” or “wholesale”

PhoneOptional-25 chars, PHONE_1Default “”

ReferenceOptional-10 chars, PROF_COD_1Default “”

WebsiteOptional-100 chars, URL_1Default “”
NewsletterSubscribeOptional – Trims to 1 chars (Y/N), 

INCLUDE_IN_MARKETING_MAILOUTS      Default “Y”


https://50.205.87.42:50937/c5CoreAPI/?action=CreateCustomer&APIToken=123456&WebsiteID=www.mywebsite.com&MagentoCustomerID=134008&CPCustomerID=WEB100099&Email=123%40AOL.COM&FirstName=Harry&LastName=Dresdon&TaxID=123123123&Reference=Referral+-+Outside+Sales+Rep&NewsletterSubscribe=Y&CompanyName=business+name&BillAddress1=1234+Lost+in+Space&BillAddress2=add+2&BillAddress3=add+3&BillCity=THIRD+ROCK&BillState=GA&BillZipcode=99900&BillCountry=US&Phone=382-396-3962&ShipCompanyName=business+name&ShipFirstName=business+name&ShipLastName=begu&ShipAddress1=1234+Lost+in+Space&ShipAddress2=add+2&ShipAddress3=add+3&ShipCity=THIRD+ROCK&ShipState=GA&ShipZipcode=99900&ShipCountry=US


Please note that even though most fields are marked optional, new and modified customers written to the Counterpoint DB will use the default string where a parameter is missing



Logic:


Step 1: Identify if customer exists

Attempt 1: Look for linked customer in CPMagento using WebsiteID and Magento CustomerID
Attempt 2: Look for customer in Counterpoint with matching CUST_NO

Attempt 3: Look for customer in Counterpoint with matching EMAIL_ADRS_1

Attempt 4: Look for customer in Counterpoint with matching PHONE_1.  Phone numbers are stripped of these characters ().- before comparison.



Step 2: Create/Update Counterpoint

All newly created customers inherit all values from the template customer configured in CPMagento.  If Company name is provided, NAM is set to company name and CUST_NAM_TYP is set to “B”, if not – NAM is set to FST_NAM and LST_NAM and CUST_NAM_TYP is set to “P”.  If an invalid PROF_COD_1 is requested, the text value requested will be saved regardless.

Step 3: Create/Update CPMagento


Use:

https://localhost:50937/c5coreapi/?APIToken=123456&action=CreateCustomer&WebsiteID=www.mywebsite.com&MagentoCustomerID=999999&Email=wiley@roadstercrasher.com&CompanyName=Acme%2C+Inc&FirstName=Wiley&LastName=Coyote&TaxID=11-1111111&Address1=999+Route+66&Address2=&Address3=&City=Boulder&State=NM&Zipcode=99999&Country=US&Phone=XXX-XXX-XXXX&Reference=1234&Website=http://www.roadstercrasher.com&NewsletterSubscribe=Y&Category=wholesale


https://192.168.0.167:50937/c5coreapi/?APIToken=123456&action=CreateCustomer&WebsiteID=www.mywebsite.com&MagentoCustomerID=999999&Email=wiley@roadstercrasher.com&CompanyName=Acme%2C+Inc&FirstName=Wiley&LastName=Coyote&TaxID=11-1111111&Address1=999+Route+66&Address2=&Address3=&City=Boulder&State=NM&Zipcode=99999&Country=US&Phone=XXX-XXX-XXXX&Reference=1234&Website=http://www.roadstercrasher.com&NewsletterSubscribe=Y&Category=wholesale


Returns:

{

"CustomerInfo": [{

"CPCustomerID": "WEB100085"

}]

}


Returns: 

{

"Error": "Error Message."

}