PayPal Express Checkout for nopCommerce 3.0 & 3.10

6 years ago
Hi folks, latest plugin files have been re uploaded.

Please could you add issues to CodePlex for us to track?

Thanks
6 years ago
Is it available for 3.10?
6 years ago
amir.taj wrote:
Is it available for 3.10?


I asked same last month, but no answer yet.

Also, the developer wants comments at codeplex. See above articles.
6 years ago
We are going to do out best to upgrade to 3.10 - the problem is time right now as we are extremely busy with several big projects.

The source code is open - if anyone would like to fork the source code in to a 3.10 branch we would happily pull the changes back in / maintain another branch.

It would be good first to get the 3.00 version working flawlessly before upgrading as any issues would be carried forward. I believe one user is having problem with USPS shipping which we need to get to the bottom of.
6 years ago
The PayPal button needs to be under the Payment step during the checkout process instead of under the check out button for consistency with the rest of the Payment methods and to increase the likelihood of it being selected
6 years ago
I am also getting the following error: "An error occurred setting up your cart for PayPal". Is there a fix for it?


This is the error:
10413: The totals of the cart item amounts do not match order amounts.

A discount was applied, so I suspect that may have something to do with it?


EDIT:

Here is a screenshot
6 years ago
breakskater wrote:
I am also getting the following error: "An error occurred setting up your cart for PayPal". Is there a fix for it?


This is the error:
10413: The totals of the cart item amounts do not match order amounts.

A discount was applied, so I suspect that may have something to do with it?


EDIT:

I've confirmed that it is the discount causing the issue. Making a purchase without the discount appears to be working fine. Here is a screenshot of the error: screenshot
.


I've confirmed that it is the discount causing the issue. Making a purchase without the discount appears to be working fine.

Any ideas what might be causing this?
6 years ago
*delete*
6 years ago
Okay, I have the fix. I will either create a fork or post it here soon
6 years ago
Thought, below you will find the main code for handling discounts and gift cards. I believe reward point amounts is the only thing left to be considered. You will need to add the appropriate signatures to the IPayPalCartItemService. Here is an example of the order summary with a gift card and discount applied.

public PaymentDetailsType[] GetPaymentDetails(IList<ShoppingCartItem> cart)
        {
            var currencyCode = _payPalCurrencyCodeParser.GetCurrencyCodeType(_workContext.WorkingCurrency);

            decimal orderTotalDiscountAmount;
            Discount appliedDiscount;
            int redeemedRewardPoints;
            decimal redeemedRewardPointsAmount;
            List<AppliedGiftCard> appliedGiftCards;
            var orderTotalWithDiscount = _payPalCartItemService.GetCartTotal(cart, out orderTotalDiscountAmount,
                out appliedDiscount,
                out redeemedRewardPoints,
                out redeemedRewardPointsAmount,
                out appliedGiftCards);

            decimal subTotalWithDiscount;
            decimal subTotalWithoutDiscount;
            Discount subTotalAppliedDiscount;
            decimal subTotalDiscountAmount;
            var itemTotalWithDiscount = _payPalCartItemService.GetCartItemTotal(cart,
                out subTotalDiscountAmount,
                out subTotalAppliedDiscount,
                out subTotalWithoutDiscount,
                out subTotalWithDiscount);


            var giftCardsAmount = appliedGiftCards.Sum(x => x.AmountCanBeUsed);

            itemTotalWithDiscount = itemTotalWithDiscount - orderTotalDiscountAmount - giftCardsAmount;

            var taxTotal = _payPalCartItemService.GetTax(cart);
            var shippingTotal = _payPalCartItemService.GetShippingTotal(cart);
            var items = GetPaymentDetailsItems(cart);




            if (orderTotalDiscountAmount > 0 || subTotalDiscountAmount > 0)
            {
                var discountItem = new PaymentDetailsItemType()
                {
                    Name = "Discount",
                    Amount = new BasicAmountType()
                        {
                            currencyID = currencyCode,
                            Value = (-orderTotalDiscountAmount + -subTotalDiscountAmount).ToString("N2")
                        },
                    Quantity = "1"
                };

                Array.Resize(ref items, items.Count() + 1);
                items[items.Count() - 1] = discountItem;
            }

            foreach (var appliedGiftCard in appliedGiftCards)
            {
                var giftCardItem = new PaymentDetailsItemType()
                {
                    Name = "Gift Card (" + appliedGiftCard.GiftCard.GiftCardCouponCode + ")",
                    Amount = new BasicAmountType()
                    {
                        currencyID = currencyCode,
                        Value = (-appliedGiftCard.AmountCanBeUsed).ToString("N2")
                    },
                    Quantity = "1"                  
                };

                Array.Resize(ref items, items.Count() + 1);
                items[items.Count() - 1] = giftCardItem;
            
            }

            /*var rewardPointsAmountItem = new PaymentDetailsItemType()
                {
                    Name = "Reward Points Credit", // Use resource value (e.g. {0} Amount)
                    Amount = new BasicAmountType()
                    {
                        currencyID = currencyCode,
                        Value = -redeemedRewardPointsAmount
                    },
                    Quantity = "1"

                };
                
                 Array.Resize(ref items, items.Count() + 1);
                 items[items.Count() - 1] = rewardPointsAmountItem;
             */




            return new[]
            {
                new PaymentDetailsType
                    {
                        OrderTotal = orderTotalWithDiscount.GetBasicAmountType(currencyCode),
                        ItemTotal = itemTotalWithDiscount.GetBasicAmountType(currencyCode),
                        TaxTotal = taxTotal.GetBasicAmountType(currencyCode),
                        ShippingTotal = shippingTotal.GetBasicAmountType(currencyCode),
                        PaymentDetailsItem = items,
                        PaymentAction = _payPalExpressCheckoutPaymentSettings.PaymentAction,
                        PaymentActionSpecified = true,
                        ButtonSource = "nopCommerce_Cart_EC"
                    }
            };
        }