休息Api结账/支付Broadleaf

时间:2014-07-17 10:38:18

标签: java api rest broadleaf-commerce

在checkoutEndpoint类中,addPaymentToOrder方法我想使用customerId,addressId和orderId创建OrderPaymentWrapper,以及它所需的任何一个。任何人都可以指导我如何创建OrderPaymentWrapper?

1 个答案:

答案 0 :(得分: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" />