}
String stateName = Format.getString(payer.getAddress().getStateOrProvince());
State state = Utility.getStateByNameOrCode(site.getSiteId(), stateName);
String countryCode = Format.getString(payer.getAddress().getCountry().toString());
Country country = Utility.getCountryByCode(site.getSiteId(), countryCode);
customer.setSite(site);
customer.setCustPublicName("");
customer.setCustEmail(emailAddress);
customer.setCustSource(Constants.CUSTOMER_SOURCE_PAYPAL);
customer.setCustSourceRef(Format.getString(payer.getPayerID()));
customer.setRecUpdateBy(Constants.USERNAME_CUSTOMER);
customer.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
// customer.setCustPublicName(customer.getCustEmail());
char singleCheckout = contentBean.getSiteDomain().getSite().getSingleCheckout();
if (singleCheckout == Constants.VALUE_YES) {
customer.setSiteDomain(contentBean.getSiteDomain().getSite().getSiteDomainDefault());
}
else {
customer.setSiteDomain(contentBean.getSiteDomain());
}
customerAddress.setCustUseAddress(Constants.CUST_ADDRESS_USE_OWN);
customerAddress.setCustAddressType(Constants.CUSTOMER_ADDRESS_CUST);
customerAddress.setCustPrefix(Format.getString(payer.getPayerName().getSalutation()));
customerAddress.setCustFirstName(Format.getString(payer.getPayerName().getFirstName()));
customerAddress.setCustMiddleName(Format.getString(payer.getPayerName().getMiddleName()));
customerAddress.setCustLastName(Format.getString(payer.getPayerName().getLastName()));
customerAddress.setCustSuffix(Format.getString(payer.getPayerName().getSuffix()));
customerAddress.setCustAddressLine1(payer.getAddress().getStreet1());
customerAddress.setCustAddressLine2(payer.getAddress().getStreet2());
customerAddress.setCustCityName(payer.getAddress().getCityName());
customerAddress.setCustStateCode(state.getStateCode());
customerAddress.setCustStateName(state.getStateName());
customerAddress.setCustCountryName(country.getCountryName());
customerAddress.setCustCountryCode(country.getCountryCode());
customerAddress.setCustZipCode("");
customerAddress.setCustPhoneNum(Format.getString(payer.getContactPhone()));
customerAddress.setCustFaxNum("");
// TODO what if state and country and null
customerAddress.setState(state);