org.broadleafcommerce.common.web.payment.expression.PaymentGatewayFieldVariableExpression Maven / Gradle / Ivy
/*
* #%L
* BroadleafCommerce Common Libraries
* %%
* Copyright (C) 2009 - 2013 Broadleaf Commerce
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package org.broadleafcommerce.common.web.payment.expression;
import org.broadleafcommerce.common.web.expression.BroadleafVariableExpression;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
/**
* A Thymeleaf Variable Expression implementation for Payment Gateway Specific fields.
* The Payment Module specific names are invoked via the ExtensionManager.
* Therefore, each module will need to register itself properly.
* The input name mappings are those properties defined in the corresponding
* DTOs.
*
*
*
*
* translates to:
*
*
* PayPal PayFlow Pro:
* Braintree:
* etc...
*
*
* @see {@link org.broadleafcommerce.common.payment.dto.PaymentRequestDTO}
* @see {@link org.broadleafcommerce.common.payment.dto.CreditCardDTO}
* @see {@link org.broadleafcommerce.common.payment.dto.AddressDTO}
*
* @author Elbert Bautista (elbertbautista)
*/
public class PaymentGatewayFieldVariableExpression implements BroadleafVariableExpression {
@Resource(name = "blPaymentGatewayFieldExtensionManager")
protected PaymentGatewayFieldExtensionManager extensionManager;
@Override
public String getName() {
return "paymentGatewayField";
}
public String mapName(String fieldName) {
Map fieldNameMap = new HashMap();
fieldNameMap.put(fieldName, fieldName);
extensionManager.getProxy().mapFieldName(fieldName, fieldNameMap);
return fieldNameMap.get(fieldName);
}
public PaymentGatewayFieldExtensionManager getExtensionManager() {
return extensionManager;
}
public void setExtensionManager(PaymentGatewayFieldExtensionManager extensionManager) {
this.extensionManager = extensionManager;
}
}