Sneha S
Sneha S

Reputation: 288

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?

Upvotes: 0

Views: 256

Answers (1)

phillipuniverse
phillipuniverse

Reputation: 2045

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" />

Upvotes: 0

Related Questions