【问题标题】:Rest Api checkout/payment BroadleafRest Api 结帐/付款 阔叶
【发布时间】:2014-07-21 05:20:55
【问题描述】:

在 checkoutEndpoint 类的 addPaymentToOrder 方法中,我想使用 customerId、addressId 和 orderId 以及任何必要的方法来创建 OrderPaymentWrapper。谁能指导我如何创建 OrderPaymentWrapper?

【问题讨论】:

    标签: java api rest broadleaf-commerce


    【解决方案1】:

    假设您正在讨论自定义现有的 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" />
    

    【讨论】:

    • No.. 我想使用 customerid、addressid 和订单 ID 等输入填充 OrderPayment,而不是将整个 Orderpayment 作为方法的输入发送。
    猜你喜欢
    • 2016-09-17
    • 2013-08-29
    • 2018-01-20
    • 2017-07-13
    • 2021-09-15
    • 2014-09-12
    • 2019-06-15
    • 2022-11-29
    • 2017-05-13
    相关资源
    最近更新 更多