简体   繁体   中英

Rest Api checkout/payment Broadleaf

In the checkoutEndpoint class, addPaymentToOrder method i would like to create the OrderPaymentWrapper using customerId, addressId and orderId and whichever is neccessary for it. Can anyone guide how i can create OrderPaymentWrapper?

Assuming that you're talking about customizing the existing OrderPaymentWrapper, create a subclass of the wrapper:

@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;
    }
}

Then in applicationContext-rest-api.xml, provide an override for the OrderPaymentWrapper:

<bean id="org.broadleafcommerce.core.web.api.wrapper.OrderPaymentWrapper" class="com.mycompany.core.api.CustomPaymentWrapper" scope="prototype" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM