Page 1 of 1

Broadleaf paypal intedgration

Posted: Fri Aug 22, 2014 8:13 pm
by learn.broadleaf
Hi Broadleaf community:

I am trying to set up the demo shop to do checkout with paypal. I have limited knowledge about payment gateway in general, so this seems to be the most difficult part for me.

i found this document: http://www.broadleafcommerce.com/docs/core/2.2/appendix/paypal-environment-setup

however, this setup documentation is for broadleaf version 2.2, and in version 3.0, blc-paypal is a separate module, i wonder if the same instructions still applied.

i follow this url https://github.com/BroadleafCommerce/blc-paypal/blob/master/docs/PayPal-Environment-Setup.md to setup, but maven dependency version for

Code: Select all

<version>2.6.0-GA</version>
is not available on the repo .. so i wonder if this instruction is applicable.

also, i've not had much experience with payment gateway in general, besides reading document paypal.com, do you guys have any resource that you guys can recommend ?

Thanks!

Re: Broadleaf paypal intedgration

Posted: Sun Aug 24, 2014 1:10 am
by learn.broadleaf
Hi All,

after more research and reading, i was able to get this up and running, but i still have a few questions, hope you guys can help me out.

first, i wasn't able to resolve the 2.6.0-GA dependency

Code: Select all

<dependency>
    <groupId>org.broadleafcommerce</groupId>
    <artifactId>broadleaf-paypal</artifactId>
    <version>2.6.0-GA</version>
    <type>jar</type>
    <scope>compile</scope>
</dependency>
dependency, so i have to use version 2.6.0-SNAPSHOT instead.

Code: Select all

            <dependency>
                <groupId>org.broadleafcommerce</groupId>
                <artifactId>broadleaf-paypal</artifactId>
                <version>2.6.0-SNAPSHOT</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>


second, when i use express checkout on paypal-hosted site, the lineItems are emptied .. however, i like to list out all items on paypal express checkout page. i follow this url https://github.com/BroadleafCommerce/blc-paypal

the instructions says
You must override the OrderToPaymentRequestDTOService implementation to construct the LineItemDTO's on the PaymentRequestDTO in your application, so that it conforms to the API restrictions of this gateway. The NVP API validates that the amounts of the line item DTO's that you pass in equal the Subtotal amount that you passed in.

Your algorithm might look something like this:


Code: Select all

Money amountItemSubtotal = new Money(0);
    List<OrderItem> orderItems = order.getOrderItems();
    for (OrderItem orderItem : orderItems) {
        requestDTO.lineItem()
                .shortDescription(orderItem.getName())
                .systemId(orderItem.getId().toString())
                .amount(orderItem.getTotalPrice().toString())
                .quantity(orderItem.getQuantity() + "")
                .done();
        amountItemSubtotal = amountItemSubtotal.add(orderItem.getPrice().multiply(orderItem.getQuantity()));
    }

    Money additionalFees = new Money(0);
    for (FulfillmentGroup fg : order.getFulfillmentGroups()){
        for (FulfillmentGroupFee fee : fg.getFulfillmentGroupFees()){
            additionalFees = additionalFees.add(fee.getAmount());
        }
    }

    if (additionalFees.greaterThan(new Money(0))) {
        requestDTO.lineItem()
                .shortDescription("Additional Fees")
                .amount(additionalFees.getAmount())
                .quantity(1L)
                .done();
        amountItemSubtotal = amountItemSubtotal.add(additionalFees);
    }

    if (order.getTotalAdjustmentsValue() != null &&
      order.getTotalAdjustmentsValue().greaterThan(new Money(0))){
        requestDTO.lineItem()
                .shortDescription("Promotion Code")
                .amount(order.getTotalAdjustmentsValue().getAmount().negate())
                .quantity(1L)
                .done();
        amountItemSubtotal = amountItemSubtotal.subtract(order.getTotalAdjustmentsValue());
    }

    // add additional payment methods like customer credit or gift cards etc...

    requestDTO.subTotal(amountItemSubtotal.toString());


I am not quite sure how i would override OrderToPaymentRequestDTOService , do i create a another spring bean, and extend this OrderToPaymentRequestDTOService and override populateDefaultLineItemsAndSubtotal method, so where would this new bean go ?

Thank you for your help.

Re: Broadleaf paypal intedgration

Posted: Mon Aug 25, 2014 9:07 am
by elbertbautista
Yes, you're on the right track. In order to override the OrderToPaymentRequestDTOService you would override it like any other implementation in broadleaf. Just extend it and tell spring about your custom implementation:

Code: Select all

<bean id="blOrderToPaymentRequestDTOService" class="com.mycompany.MyCustomOrderToPaymentDTOServiceImpl"/>


See: http://www.broadleafcommerce.com/docs/c ... g-services

Also, the 2.6.0-GA version of the PayPal module should be publicly available from our nexus: http://nexus.broadleafcommerce.org/nexu ... /2.6.0-GA/

- thanks
Elbert

Re: Broadleaf paypal intedgration

Posted: Mon Aug 25, 2014 12:23 pm
by phillipuniverse
To get the releases repository, add this to your pom.xml:

Code: Select all

<repository>
    <id>public releases</id>
    <name>public releases</name>
    <url>http://nexus.broadleafcommerce.org/nexus/content/repositories/releases/</url>
</repository>