@Override
public void addCustomerAttributeToCustomer(Long customerId, String customerAttributeKey, String customerAttributeValue) throws PaymentException {
Customer currentCustomer = CustomerState.getCustomer();
Long currentCustomerId = currentCustomer.getId();
if (customerId != null && !currentCustomerId.equals(customerId)) {
logWarningIfCustomerMismatch(currentCustomerId, customerId);
currentCustomer = customerService.readCustomerById(customerId);
}
CustomerAttribute customerAttribute = new CustomerAttributeImpl();
customerAttribute.setName(customerAttributeKey);
customerAttribute.setValue(customerAttributeValue);
customerAttribute.setCustomer(currentCustomer);
currentCustomer.getCustomerAttributes().put(customerAttributeKey, customerAttribute);
customerService.saveCustomer(currentCustomer);
}