Skip to content

Commit 243060f

Browse files
committed
Resolves smartstore#855 PayPal standard: Return URLs like PDTHandler require HTTPS
1 parent 37efcea commit 243060f

19 files changed

Lines changed: 293 additions & 392 deletions

changelog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
* #451 Add message token for product shipping surcharge
4040
* #436 Make %Order.Product(s)% token to link the product detail page and a add product thumbnail
4141
* #339 Meta robots setting for page indexing of search engines
42-
* PayPal Direct and Express: Option for API security protocol
42+
* PayPal: Option for API security protocol
4343
* Product filter: Option to sort filter results by their display order rather than by number of matches
4444
* Elmar Shopinfo: Option to export delivery time as availability
4545

@@ -104,6 +104,7 @@
104104
* Faulty permission handling in ajax grid actions (no message, infinite loading icon)
105105
* Grouped products: Display order was not correct
106106
* Deletion of a customer could delete all newsletter subscriptions
107+
* PayPal: Fixed "The request was aborted: Could not create SSL/TLS secure channel."
107108

108109

109110
## SmartStore.NET 2.2.2

src/Plugins/SmartStore.PayPal/Controllers/PayPalDirectController.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public ActionResult Configure(PayPalDirectConfigurationModel model, FormCollecti
9292
_services.Settings.SaveSetting(settings, x => x.UseSandbox, 0, false);
9393

9494
_services.Settings.ClearCache();
95-
NotifySuccess(_services.Localization.GetResource("Plugins.Payments.PayPal.ConfigSaveNote"));
95+
NotifySuccess(_services.Localization.GetResource("Admin.Common.DataSuccessfullySaved"));
9696

9797
return Configure();
9898
}
@@ -180,9 +180,13 @@ public override IList<string> ValidatePaymentForm(FormCollection form)
180180
};
181181

182182
var validationResult = validator.Validate(model);
183-
if (!validationResult.IsValid)
184-
foreach (var error in validationResult.Errors)
185-
warnings.Add(error.ErrorMessage);
183+
if (!validationResult.IsValid)
184+
{
185+
foreach (var error in validationResult.Errors)
186+
{
187+
warnings.Add(error.ErrorMessage);
188+
}
189+
}
186190
return warnings;
187191
}
188192

@@ -216,15 +220,17 @@ public ActionResult IPNHandler()
216220
Debug.WriteLine("PayPal Direct IPN: {0}".FormatWith(Request.ContentLength));
217221

218222
byte[] param = Request.BinaryRead(Request.ContentLength);
219-
string strRequest = Encoding.ASCII.GetString(param);
223+
var strRequest = Encoding.ASCII.GetString(param);
220224
Dictionary<string, string> values;
221225

222226
var provider = _paymentService.LoadPaymentMethodBySystemName("Payments.PayPalDirect", true);
223227
var processor = provider != null ? provider.Value as PayPalDirectProvider : null;
224228
if (processor == null)
225229
throw new SmartException(T("Plugins.Payments.PayPalDirect.NoModuleLoading"));
226230

227-
if (processor.VerifyIPN(strRequest, out values))
231+
var settings = _services.Settings.LoadSetting<PayPalDirectPaymentSettings>();
232+
233+
if (PayPalHelper.VerifyIPN(settings, strRequest, out values))
228234
{
229235
#region values
230236
decimal total = decimal.Zero;

src/Plugins/SmartStore.PayPal/Controllers/PayPalExpressController.cs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.Text;
66
using System.Web.Mvc;
77
using SmartStore.Core.Domain.Customers;
8-
using SmartStore.Core.Domain.Directory;
98
using SmartStore.Core.Domain.Discounts;
109
using SmartStore.Core.Domain.Logging;
1110
using SmartStore.Core.Domain.Orders;
@@ -35,10 +34,8 @@ public class PayPalExpressController : PaymentControllerBase
3534
private readonly IOrderService _orderService;
3635
private readonly IOrderProcessingService _orderProcessingService;
3736
private readonly ILogger _logger;
38-
private readonly PaymentSettings _paymentSettings;
3937
private readonly OrderSettings _orderSettings;
4038
private readonly ICurrencyService _currencyService;
41-
private readonly CurrencySettings _currencySettings;
4239
private readonly IOrderTotalCalculationService _orderTotalCalculationService;
4340
private readonly ICustomerService _customerService;
4441
private readonly IGenericAttributeService _genericAttributeService;
@@ -49,10 +46,8 @@ public PayPalExpressController(
4946
IOrderService orderService,
5047
IOrderProcessingService orderProcessingService,
5148
ILogger logger,
52-
PaymentSettings paymentSettings,
5349
OrderSettings orderSettings,
5450
ICurrencyService currencyService,
55-
CurrencySettings currencySettings,
5651
IOrderTotalCalculationService orderTotalCalculationService,
5752
ICustomerService customerService,
5853
IGenericAttributeService genericAttributeService,
@@ -62,10 +57,8 @@ public PayPalExpressController(
6257
_orderService = orderService;
6358
_orderProcessingService = orderProcessingService;
6459
_logger = logger;
65-
_paymentSettings = paymentSettings;
6660
_orderSettings = orderSettings;
6761
_currencyService = currencyService;
68-
_currencySettings = currencySettings;
6962
_orderTotalCalculationService = orderTotalCalculationService;
7063
_customerService = customerService;
7164
_genericAttributeService = genericAttributeService;
@@ -123,22 +116,23 @@ public ActionResult Configure(PayPalExpressConfigurationModel model, FormCollect
123116
_services.Settings.SaveSetting(settings, x => x.UseSandbox, 0, false);
124117

125118
_services.Settings.ClearCache();
126-
NotifySuccess(_services.Localization.GetResource("Plugins.Payments.PayPal.ConfigSaveNote"));
119+
NotifySuccess(_services.Localization.GetResource("Admin.Common.DataSuccessfullySaved"));
127120

128121
return Configure();
129122
}
130123

131124
public ActionResult PaymentInfo()
132125
{
133-
134126
var model = new PayPalExpressPaymentInfoModel();
135127
model.CurrentPageIsBasket = PayPalHelper.CurrentPageIsBasket(this.ControllerContext.ParentActionViewContext.RequestContext.RouteData);
136128

137129
if (model.CurrentPageIsBasket)
138130
{
139131
var culture = _services.WorkContext.WorkingLanguage.LanguageCulture;
132+
var settings = _services.Settings.LoadSetting<PayPalExpressPaymentSettings>(_services.StoreContext.CurrentStore.Id);
140133
var buttonUrl = "https://www.paypalobjects.com/{0}/i/btn/btn_xpressCheckout.gif".FormatWith(culture.Replace("-", "_"));
141-
model.SubmitButtonImageUrl = PayPalHelper.CheckIfButtonExists(buttonUrl);
134+
135+
model.SubmitButtonImageUrl = PayPalHelper.CheckIfButtonExists(settings, buttonUrl);
142136
}
143137

144138
return PartialView(model);
@@ -148,15 +142,17 @@ public ActionResult PaymentInfo()
148142
public ActionResult IPNHandler()
149143
{
150144
byte[] param = Request.BinaryRead(Request.ContentLength);
151-
string strRequest = Encoding.ASCII.GetString(param);
145+
var strRequest = Encoding.ASCII.GetString(param);
152146
Dictionary<string, string> values;
153147

154148
var provider = _paymentService.LoadPaymentMethodBySystemName("Payments.PayPalExpress", true);
155149
var processor = provider != null ? provider.Value as PayPalExpress : null;
156150
if (processor == null)
157151
throw new SmartException(T("PayPal Express module cannot be loaded"));
158152

159-
if (processor.VerifyIPN(strRequest, out values))
153+
var settings = _services.Settings.LoadSetting<PayPalExpressPaymentSettings>();
154+
155+
if (PayPalHelper.VerifyIPN(settings, strRequest, out values))
160156
{
161157
#region values
162158
decimal total = decimal.Zero;

src/Plugins/SmartStore.PayPal/Controllers/PayPalStandardController.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using SmartStore.Core.Domain.Payments;
1111
using SmartStore.Core.Logging;
1212
using SmartStore.PayPal.Models;
13+
using SmartStore.PayPal.Services;
1314
using SmartStore.PayPal.Settings;
1415
using SmartStore.Services;
1516
using SmartStore.Services.Localization;
@@ -67,7 +68,11 @@ public ActionResult Configure()
6768

6869
model.Copy(settings, true);
6970

70-
var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData);
71+
model.AvailableSecurityProtocols = PayPalHelper.GetSecurityProtocols()
72+
.Select(x => new SelectListItem { Value = ((int)x.Key).ToString(), Text = x.Value })
73+
.ToList();
74+
75+
var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData);
7176
storeDependingSettingHelper.GetOverrideKeys(settings, model, storeScope, _services.Settings);
7277

7378
return View(model);
@@ -93,7 +98,7 @@ public ActionResult Configure(PayPalStandardConfigurationModel model, FormCollec
9398
_services.Settings.SaveSetting(settings, x => x.UseSandbox, 0, false);
9499

95100
_services.Settings.ClearCache();
96-
NotifySuccess(_services.Localization.GetResource("Plugins.Payments.PayPal.ConfigSaveNote"));
101+
NotifySuccess(_services.Localization.GetResource("Admin.Common.DataSuccessfullySaved"));
97102

98103
return Configure();
99104
}
@@ -266,15 +271,17 @@ public ActionResult IPNHandler()
266271
Debug.WriteLine("PayPal Standard IPN: {0}".FormatInvariant(Request.ContentLength));
267272

268273
byte[] param = Request.BinaryRead(Request.ContentLength);
269-
string strRequest = Encoding.ASCII.GetString(param);
274+
var strRequest = Encoding.UTF8.GetString(param);
270275
Dictionary<string, string> values;
271276

272277
var provider = _paymentService.LoadPaymentMethodBySystemName("Payments.PayPalStandard", true);
273278
var processor = provider != null ? provider.Value as PayPalStandardProvider : null;
274279
if (processor == null)
275280
throw new SmartException(_localizationService.GetResource("Plugins.Payments.PayPalStandard.NoModuleLoading"));
276281

277-
if (processor.VerifyIPN(strRequest, out values))
282+
var settings = _services.Settings.LoadSetting<PayPalStandardPaymentSettings>();
283+
284+
if (PayPalHelper.VerifyIPN(settings, strRequest, out values))
278285
{
279286
#region values
280287

src/Plugins/SmartStore.PayPal/Filters/PayPalExpressCheckoutFilter.cs

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using SmartStore.Core.Domain.Customers;
77
using SmartStore.Services;
88
using SmartStore.Services.Common;
9-
using SmartStore.Services.Customers;
109
using SmartStore.Services.Payments;
1110

1211
namespace SmartStore.PayPal.Filters
@@ -15,19 +14,18 @@ public class PayPalExpressCheckoutFilter : IActionFilter
1514
{
1615
private static readonly string[] s_interceptableActions = new string[] { "PaymentMethod" };
1716

18-
private readonly IGenericAttributeService _genericAttributeService;
19-
private readonly HttpContextBase _httpContext;
20-
private readonly ICommonServices _services;
21-
private readonly ICustomerService _customerService;
17+
private readonly IGenericAttributeService _genericAttributeService;
18+
private readonly HttpContextBase _httpContext;
19+
private readonly ICommonServices _services;
2220

23-
public PayPalExpressCheckoutFilter(IGenericAttributeService genericAttributeService,
24-
HttpContextBase httpContext, ICommonServices services,
25-
ICustomerService customerService)
21+
public PayPalExpressCheckoutFilter(
22+
IGenericAttributeService genericAttributeService,
23+
HttpContextBase httpContext,
24+
ICommonServices services)
2625
{
27-
_genericAttributeService = genericAttributeService;
28-
_httpContext = httpContext;
29-
_services = services;
30-
_customerService = customerService;
26+
_genericAttributeService = genericAttributeService;
27+
_httpContext = httpContext;
28+
_services = services;
3129
}
3230

3331
private static bool IsInterceptableAction(string actionName)
@@ -37,36 +35,37 @@ private static bool IsInterceptableAction(string actionName)
3735

3836
public void OnActionExecuting(ActionExecutingContext filterContext)
3937
{
40-
if (filterContext == null || filterContext.ActionDescriptor == null || filterContext.HttpContext == null || filterContext.HttpContext.Request == null)
41-
return;
38+
if (filterContext == null || filterContext.ActionDescriptor == null || filterContext.HttpContext == null || filterContext.HttpContext.Request == null)
39+
return;
4240

43-
string actionName = filterContext.ActionDescriptor.ActionName;
41+
string actionName = filterContext.ActionDescriptor.ActionName;
4442

45-
var store = _services.StoreContext.CurrentStore;
46-
var customer = _services.WorkContext.CurrentCustomer;
47-
48-
var attr = Convert.ToBoolean(filterContext.HttpContext.GetCheckoutState().CustomProperties["PayPalExpressButtonUsed"]);
43+
var store = _services.StoreContext.CurrentStore;
44+
var customer = _services.WorkContext.CurrentCustomer;
4945

50-
//verify paypalexpressprovider was used
51-
if (attr == true) {
52-
_genericAttributeService.SaveAttribute<string>(customer, SystemCustomerAttributeNames.SelectedPaymentMethod, "Payments.PayPalExpress", store.Id);
46+
var attr = Convert.ToBoolean(filterContext.HttpContext.GetCheckoutState().CustomProperties["PayPalExpressButtonUsed"]);
5347

54-
var paymentRequest = _httpContext.Session["OrderPaymentInfo"] as ProcessPaymentRequest;
55-
if (paymentRequest == null)
56-
{
57-
_httpContext.Session["OrderPaymentInfo"] = new ProcessPaymentRequest();
58-
}
48+
//verify paypalexpressprovider was used
49+
if (attr == true)
50+
{
51+
_genericAttributeService.SaveAttribute<string>(customer, SystemCustomerAttributeNames.SelectedPaymentMethod, "Payments.PayPalExpress", store.Id);
5952

60-
//delete property for backward navigation
61-
_httpContext.GetCheckoutState().CustomProperties.Remove("PayPalExpressButtonUsed");
53+
var paymentRequest = _httpContext.Session["OrderPaymentInfo"] as ProcessPaymentRequest;
54+
if (paymentRequest == null)
55+
{
56+
_httpContext.Session["OrderPaymentInfo"] = new ProcessPaymentRequest();
57+
}
6258

63-
filterContext.Result = new RedirectToRouteResult(
64-
new RouteValueDictionary {
65-
{ "Controller", "Checkout" },
66-
{ "Action", "Confirm" },
67-
{ "area", null }
68-
});
69-
}
59+
//delete property for backward navigation
60+
_httpContext.GetCheckoutState().CustomProperties.Remove("PayPalExpressButtonUsed");
61+
62+
filterContext.Result = new RedirectToRouteResult(
63+
new RouteValueDictionary {
64+
{ "Controller", "Checkout" },
65+
{ "Action", "Confirm" },
66+
{ "area", null }
67+
});
68+
}
7069
}
7170

7271
public void OnActionExecuted(ActionExecutedContext filterContext)

src/Plugins/SmartStore.PayPal/Localization/resources.de-de.xml

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99

1010
<LocaleResource Name="Plugins.Payments.PayPal" AppendRootKey="false">
1111
<Children>
12-
<LocaleResource Name="ConfigSaveNote">
13-
<Value>Ihre Einstellungen wurden erfolgreich gespeichert.</Value>
14-
</LocaleResource>
1512
<LocaleResource Name="UseSandbox">
1613
<Value>Sandbox benutzen</Value>
1714
</LocaleResource>
@@ -63,7 +60,6 @@
6360
</Children>
6461
</LocaleResource>
6562

66-
6763
<LocaleResource Name="Plugins.FriendlyName.Payments.PayPalExpress" AppendRootKey="false">
6864
<Value>PayPal Express</Value>
6965
</LocaleResource>
@@ -84,6 +80,7 @@
8480
<ol>
8581
<li>In Ihr Premier- oder Business-Konto einloggen.</li>
8682
<li>Auf den Register <b>Mein Profil</b> klicken.</li>
83+
<li>Unter <b>Sprach-Kodierung > Weitere Einstellungen</b> wählen Sie bitte UTF-8.</li>
8784
<li><b>Sofortige Zahlungsbestätigung</b> klicken.</li>
8885
<li><b>Einstellungen für sofortige Zahlungsbestätigungen wählen</b> klicken.</li>
8986
<li>Bei <b>Benachrichtigungs-URL</b> die URL Ihres IPN-Handlers (<b>https://www.yourStore.com/Plugins/SmartStore.PayPal/PayPalExpress/IPNHandler</b>) eingeben.</li>
@@ -119,11 +116,9 @@
119116
<LocaleResource Name="ModeAuth">
120117
<Value>Autorisierung sofort, Abbuchung später</Value>
121118
</LocaleResource>
122-
123119
<LocaleResource Name="SelectionText">
124120
<Value>oder</Value>
125121
</LocaleResource>
126-
127122
<LocaleResource Name="Fields.DisplayCheckoutButton">
128123
<Value>Checkout-Button auf der Warenkorbseite aktivieren</Value>
129124
</LocaleResource>
@@ -161,7 +156,6 @@
161156
<LocaleResource Name="Plugins.FriendlyName.Payments.PayPalDirect" AppendRootKey="false">
162157
<Value>PayPal Direct</Value>
163158
</LocaleResource>
164-
165159
<LocaleResource Name="Plugins.Payments.PayPalDirect" AppendRootKey="false">
166160
<Children>
167161
<LocaleResource Name="AdminInstruction">
@@ -179,6 +173,7 @@
179173
<ol>
180174
<li>In Ihr Premier- oder Business-Konto einloggen.</li>
181175
<li>Auf den Register <b>Mein Profil</b> klicken.</li>
176+
<li>Unter <b>Sprach-Kodierung > Weitere Einstellungen</b> wählen Sie bitte UTF-8.</li>
182177
<li><b>Sofortige Zahlungsbestätigung</b> klicken.</li>
183178
<li><b>Einstellungen für sofortige Zahlungsbestätigungen wählen</b> klicken.</li>
184179
<li>Bei <b>Benachrichtigungs-URL</b> die URL Ihres IPN-Handlers (<b>https://www.yourStore.com/Plugins/SmartStore.PayPal/PayPalDirect/IPNHandler</b>) eingeben.</li>
@@ -219,12 +214,11 @@
219214
<LocaleResource Name="Plugins.FriendlyName.Payments.PayPalStandard" AppendRootKey="false">
220215
<Value>PayPal Standard</Value>
221216
</LocaleResource>
222-
223217
<LocaleResource Name="Plugins.Payments.PayPalStandard" AppendRootKey="false">
224218
<Children>
225219
<LocaleResource Name="AdminInstruction">
226220
<Value>
227-
<![CDATA[<p>Stellen Sie bitte sicher, dass PayPal die Primärwährung Ihres Shops unterstützt, falls Sie dieses Gateway benutzen!</p>
221+
<![CDATA[<p>Stellen Sie bitte sicher, dass PayPal die Primärwährung Ihres Shops unterstützt, falls Sie dieses Gateway benutzen.</p>
228222
<p>Sie müssen PDT (Payment Data Transfer) und die automatische Rückleitung in Ihrem PayPal-Profil aktivieren, um PDT nutzen zu können.
229223
Ferner benötigen Sie einen PDT-Identitäts-Token, der für jede PDT-Kommunikation mit PayPal erforderlich ist.
230224
Folgen Sie den Schritten, um Ihr Konto für PDT zu konfigurieren:</p>
@@ -247,7 +241,8 @@
247241
<ol>
248242
<li>In Ihr Premier- oder Business-Konto einloggen.</li>
249243
<li>Auf den Register <b>Mein Profil</b> klicken.</li>
250-
<li><b>Sofortige Zahlungsbestätigung</b> klicken.</li>
244+
<li>Unter <b>Sprach-Kodierung > Weitere Einstellungen</b> wählen Sie bitte UTF-8.</li>
245+
<li>Zurück zu <b>Mein Profil</b> und auf <b>Sofortige Zahlungsbestätigung</b> klicken.</li>
251246
<li><b>Einstellungen für sofortige Zahlungsbestätigungen wählen</b> klicken.</li>
252247
<li>Bei <b>Benachrichtigungs-URL</b> die URL Ihres IPN-Handlers (<b>https://www.yourStore.com/Plugins/SmartStore.PayPal/PayPalStandard/IPNHandler</b>) eingeben.</li>
253248
<li><b>Speichern</b> klicken. Danach sollten Sie eine Nachricht über die erfolgreiche Aktivierung von IPN erhalten.</li>
@@ -283,18 +278,6 @@
283278
<LocaleResource Name="Fields.PdtValidateOnlyWarn.Hint">
284279
<Value>Legt fest, ob im Falle einer Nichtübereinstimmung des Gesamtbetrags lediglich eine Auftragsnotiz angelegt werden soll. Ansonsten wird ein Fehler erzeugt und der Zahlungsstatus wird nicht aktualisiert.</Value>
285280
</LocaleResource>
286-
<LocaleResource Name="Fields.AdditionalFee">
287-
<Value>Zusätzliche Gebühren</Value>
288-
</LocaleResource>
289-
<LocaleResource Name="Fields.AdditionalFee.Hint">
290-
<Value>Zusätzliche Gebühren, die dem Kunden berechnet werden sollen.</Value>
291-
</LocaleResource>
292-
<LocaleResource Name="Fields.AdditionalFeePercentage">
293-
<Value>Zusätzliche Gebühren (prozentual)</Value>
294-
</LocaleResource>
295-
<LocaleResource Name="Fields.AdditionalFeePercentage.Hint">
296-
<Value>Zusätzliche prozentuale Gebühr zum Gesamtbetrag. Es wird ein fester Wert verwendet, falls diese Option nicht aktiviert ist.</Value>
297-
</LocaleResource>
298281
<LocaleResource Name="Fields.PassProductNamesAndTotals">
299282
<Value>Produktbezeichnungen und Einzelpreise übermitteln</Value>
300283
</LocaleResource>

0 commit comments

Comments
 (0)