Page 6 of 7

Re: Wire payment module or offline transaction module

Posted: Tue Aug 06, 2013 1:31 pm
by elbertbautista
The default BroadleafCheckoutController assumes a standard authorize and debit via a credit card.

If you would like to complete a checkout using a Wire Payment, you will need to extend the BroadleafCheckoutController and override the completeCheckout() method and execute the checkout service directly and not have to deal with any sort of credit card information. You can execute the checkout service and checkout workflow by calling:

Code: Select all

CheckoutResponse checkoutResponse = checkoutService.performCheckout(cart, payments);


You should familiarize yourself with the Checkout and Payment workflows to see how each of these work:
http://docs.broadleafcommerce.org/core/ ... t-workflow
http://docs.broadleafcommerce.org/core/ ... s/checkout

Re: Wire payment module or offline transaction module

Posted: Wed Aug 07, 2013 1:54 am
by hiteshsingla
Thanks Elbert!!
As Ankit said above you are really a life saver :)
Just a small question, I checked the CheckoutServiceImpl.class and found the method performCheckout()
This method is having two parameters:
1.Order order
2.final Map<PaymentInfo, Referenced> payments

I know Order will be the instance of my cart like CartState.getCart()
But what about the Map<PaymentInfo, Referenced>??
I have changed my CheckoutController like this:

Code: Select all

public String completeCheckout(HttpServletRequest request, HttpServletResponse response, Model model,
         @ModelAttribute("billingInfoForm") BillingInfoForm billingForm,
          BindingResult result) throws CheckoutException, PricingException, ServiceException {
      CheckoutResponse checkoutResponse = checkoutService.performCheckout(CartState.getCart(), CartState.getCart().getPaymentInfos());       
   }

But I am getting this error
The method performCheckout(Order, Map<PaymentInfo,Referenced>) in the type CheckoutService is not applicable for the arguments (Order, List<PaymentInfo>)

If you can help me than i will be more than obliged.

Thanks & Regards
Hitesh Singla

Re: Wire payment module or offline transaction module

Posted: Wed Aug 07, 2013 10:01 am
by phillipuniverse
Look at BroadleafCheckoutController (the superclass of CheckoutController) and the method completeSecureCreditCardCheckout. This should give you enough of a pattern to determine what to pass to performCheckout.

Re: Wire payment module or offline transaction module

Posted: Wed Aug 07, 2013 10:12 am
by elbertbautista
Please read through managing Broadleaf Payment Data for Checkout here, as well as the Customizing Payment docs, they should give you a better understanding of how to construct and call the checkout workflow:
http://docs.broadleafcommerce.org/core/ ... compliance
http://docs.broadleafcommerce.org/core/ ... ng-payment

You will need to create the payments map manually.
Something like this:

Code: Select all

Map<PaymentInfo, Referenced> payments = new HashMap<PaymentInfo, Referenced>();
PaymentInfo wire = paymentInfoService.create();
wire.setType(PaymentInfoType.WIRE);
wire.setOrder(order);
wire.setAmount(amount);
wire.setReferenceNumber(uniqueReferenceNumber);
payments.put(wire, wire.createEmptyReferenced());
checkoutService.performCheckout(order, payments);

Re: Wire payment module or offline transaction module

Posted: Wed Aug 07, 2013 11:15 am
by hiteshsingla
Thanks Elbert!!
How to instantiate paymentInfoServie() here??
And "uniqueReferenceNumber" is a object or something??

Re: Wire payment module or offline transaction module

Posted: Wed Aug 07, 2013 2:15 pm
by elbertbautista
1. @Resource(name = "blPaymentInfoService")

2. a unique number/String you want to associate with your wire payment. (e.g. order.getId())

Re: Wire payment module or offline transaction module

Posted: Thu Aug 08, 2013 6:33 am
by hiteshsingla
Thanks Elbert!!
I got what i wanted :)
Just one more query if you could help me, is there any way around to store the paymentInfoType also in the blc_order table?
So that one can know that what is the way of payment for any respective order.

Thanks & Regards
Hitesh Singla

Re: Wire payment module or offline transaction module

Posted: Thu Aug 08, 2013 8:03 am
by phillipuniverse
The intention is that you could pay for an order with multiple payments. For instance, perhaps someone wanted to use a gift card as well as a credit card to pay for an Order. It is by design that there is no payment type on BLC_ORDER and instead stored on the possible multiple PaymentInfos for an Order.

Re: Wire payment module or offline transaction module

Posted: Thu Aug 08, 2013 8:04 am
by phillipuniverse
If you really wanted to do what you're describing, you would need to extend OrderImpl and maintain that new column yourself.

Re: Wire payment module or offline transaction module

Posted: Thu Aug 08, 2013 9:26 am
by hiteshsingla
Thanks phillip!!
I got your point and will try to work for extending OrderImpl.

@Elbert- I customised the blCheckoutWorkflow like this to get to the success in case of wire payment:

Code: Select all

<bean id="blCheckoutWorkflow" class="org.broadleafcommerce.core.workflow.SequenceProcessor">
        <property name="processContextFactory">
            <bean class="org.broadleafcommerce.core.checkout.service.workflow.CheckoutProcessContextFactory"/>
        </property>
        <property name="activities">
            <list>
                <bean class="org.broadleafcommerce.core.offer.service.workflow.VerifyCustomerMaxOfferUsesActivity"/>
                <!--<bean class="org.broadleafcommerce.core.checkout.service.workflow.PaymentServiceActivity"/>-->
                <bean class="org.broadleafcommerce.core.offer.service.workflow.RecordOfferUsageActivity"/>
                <bean class="org.broadleafcommerce.core.checkout.service.workflow.CompleteOrderActivity"/>
            </list>
        </property>
        <property name="defaultErrorHandler" ref="blDefaultErrorHandler"/>
    </bean>

I commented the PaymentServiceActivity and got the order to success.But commenting this activity will result in failure of any other payment type.Like when i tried getting the success using the Paypal, it gives me the following error:
java.lang.NullPointerException
at org.broadleafcommerce.vendor.paypal.service.payment.PayPalCheckoutServiceImpl.completeExpressCheckout(PayPalCheckoutServiceImpl.java:142)
at org.broadleafcommerce.vendor.paypal.web.controller.BroadleafPayPalController.paypalProcess(BroadleafPayPalController.java:141)
at com.marketplace.controller.paypal.PayPalController.paypalProcess(PayPalController.java:47)

Can you please suggest me some work around for this??


Thanks & Regards
Hitesh Singla