在 checkoutEndpoint 类的 addPaymentToOrder 方法中,我想使用 customerId、addressId 和 orderId 以及任何必要的方法来创建 OrderPaymentWrapper。谁能指导我如何创建 OrderPaymentWrapper?
问问题
244 次
1 回答
0
假设您正在讨论自定义现有的 OrderPaymentWrapper,请创建包装器的子类:
@XmlRootElement(name = "customPayment")
@XmlAccessorType(value = XmlAccessType.FIELD)
public class CustomPaymentWrapper extends BaseWrapper implements APIWrapper<OrderPayment>, APIUnwrapper<OrderPayment> {
@XmlElement
protected Long addressId;
@XmlElement
protected Long customerId;
public OrderPayment unwrap(HttpServletRequest request, ApplicationContext context) {
OrderPayment payment = super.unwrap(request, context);
//do other stuff with the payment
return payment;
}
}
然后在 applicationContext-rest-api.xml 中,为 OrderPaymentWrapper 提供覆盖:
<bean id="org.broadleafcommerce.core.web.api.wrapper.OrderPaymentWrapper" class="com.mycompany.core.api.CustomPaymentWrapper" scope="prototype" />
于 2014-07-20T21:20:55.200 回答