Skip to content

Commit c798768

Browse files
committed
PayPal PLUS: Generic attribute caching problem. Fixes "Item amount must add up to specified amount subtotal (or total if amount details not specified)".
1 parent a3d5797 commit c798768

3 files changed

Lines changed: 12 additions & 8 deletions

File tree

‎src/Plugins/SmartStore.PayPal/Filters/PayPalPlusCheckoutFilter.cs‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
using System.Web.Mvc;
1+
using System;
2+
using System.Web.Mvc;
23
using System.Web.Routing;
4+
using SmartStore.Core.Domain.Customers;
35
using SmartStore.Services;
6+
using SmartStore.Services.Common;
47
using SmartStore.Services.Payments;
58

69
namespace SmartStore.PayPal.Filters
@@ -9,13 +12,16 @@ public class PayPalPlusCheckoutFilter : IActionFilter
912
{
1013
private readonly ICommonServices _services;
1114
private readonly IPaymentService _paymentService;
15+
private readonly Lazy<IGenericAttributeService> _genericAttributeService;
1216

1317
public PayPalPlusCheckoutFilter(
1418
ICommonServices services,
15-
IPaymentService paymentService)
19+
IPaymentService paymentService,
20+
Lazy<IGenericAttributeService> genericAttributeService)
1621
{
1722
_services = services;
1823
_paymentService = paymentService;
24+
_genericAttributeService = genericAttributeService;
1925
}
2026

2127
public void OnActionExecuting(ActionExecutingContext filterContext)
@@ -28,6 +34,8 @@ public void OnActionExecuting(ActionExecutingContext filterContext)
2834
if (!_paymentService.IsPaymentMethodActive(PayPalPlusProvider.SystemName, store.Id))
2935
return;
3036

37+
_genericAttributeService.Value.SaveAttribute(_services.WorkContext.CurrentCustomer, SystemCustomerAttributeNames.SelectedPaymentMethod, PayPalPlusProvider.SystemName, store.Id);
38+
3139
var routeValues = new RouteValueDictionary(new { action = "PaymentWall", controller = "PayPalPlus" });
3240

3341
filterContext.Result = new RedirectToRouteResult("SmartStore.PayPalPlus", routeValues);

‎src/Plugins/SmartStore.PayPal/Services/PayPalService.cs‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ public class PayPalService : IPayPalService
4141
private readonly IOrderService _orderService;
4242
private readonly IOrderProcessingService _orderProcessingService;
4343
private readonly IOrderTotalCalculationService _orderTotalCalculationService;
44-
private readonly IGenericAttributeService _genericAttributeService;
4544
private readonly IPaymentService _paymentService;
4645
private readonly IPriceCalculationService _priceCalculationService;
4746
private readonly ITaxService _taxService;
@@ -55,7 +54,6 @@ public PayPalService(
5554
IOrderService orderService,
5655
IOrderProcessingService orderProcessingService,
5756
IOrderTotalCalculationService orderTotalCalculationService,
58-
IGenericAttributeService genericAttributeService,
5957
IPaymentService paymentService,
6058
IPriceCalculationService priceCalculationService,
6159
ITaxService taxService,
@@ -68,7 +66,6 @@ public PayPalService(
6866
_orderService = orderService;
6967
_orderProcessingService = orderProcessingService;
7068
_orderTotalCalculationService = orderTotalCalculationService;
71-
_genericAttributeService = genericAttributeService;
7269
_paymentService = paymentService;
7370
_priceCalculationService = priceCalculationService;
7471
_taxService = taxService;
@@ -632,7 +629,7 @@ public PayPalResponse CallApi(string method, string path, string accessToken, Pa
632629
if (result.ErrorMessage.IsEmpty())
633630
result.ErrorMessage = webResponse.StatusDescription;
634631

635-
LogError(null, result.ErrorMessage, result.Json == null ? null : result.Json.ToString(), false);
632+
LogError(null, result.ErrorMessage, string.Concat(data.NaIfEmpty(), "\r\n\r\n", result.Json == null ? "" : result.Json.ToString()), false);
636633
}
637634
}
638635
}
@@ -703,8 +700,6 @@ public PayPalResponse CreatePayment(
703700

704701
//var dateOfBirth = customer.GetAttribute<DateTime?>(SystemCustomerAttributeNames.DateOfBirth);
705702

706-
_genericAttributeService.SaveAttribute(customer, SystemCustomerAttributeNames.SelectedPaymentMethod, PayPalPlusProvider.SystemName, store.Id);
707-
708703
var data = new Dictionary<string, object>();
709704
var redirectUrls = new Dictionary<string, object>();
710705
var payer = new Dictionary<string, object>();

‎src/Plugins/SmartStore.PayPal/changelog.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
##Paypal 2.6.0.3
44
###Bugfixes
55
* PayPal PLUS: Integration review through PayPal
6+
* PayPal PLUS: Generic attribute caching problem. Fixes "Item amount must add up to specified amount subtotal (or total if amount details not specified)".
67

78
##PayPal 2.6.0.1
89
###Improvements

0 commit comments

Comments
 (0)