Skip to content

Commit 7d7bf95

Browse files
committed
PayPal Plus: Getting started with new payment provider
1 parent a1504dc commit 7d7bf95

18 files changed

Lines changed: 495 additions & 32 deletions

File tree

744 Bytes
Loading
-5.05 KB
Binary file not shown.

src/Plugins/SmartStore.PayPal/Content/smartstore.paypal.css

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,6 @@
1111
#paypal-checkout #paypal-express-button {
1212
cursor: pointer;
1313
}
14-
.configure-paypal-direct .logo,
15-
.configure-paypal-express .logo,
16-
.configure-paypal-standard .logo
17-
.paypal-standard-public .logo{
18-
width: 200px;
19-
height: 53px;
20-
}
2114
.paypal-standard-public {
2215
margin-bottom: 10px;
2316
}
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
using System.Collections.Generic;
2+
using System.Linq;
3+
using System.Web.Mvc;
4+
using SmartStore.PayPal.Models;
5+
using SmartStore.PayPal.Settings;
6+
using SmartStore.Services.Orders;
7+
using SmartStore.Services.Payments;
8+
using SmartStore.Web.Framework.Controllers;
9+
using SmartStore.Web.Framework.Security;
10+
using SmartStore.Web.Framework.Settings;
11+
12+
namespace SmartStore.PayPal.Controllers
13+
{
14+
public class PayPalPlusController : PayPalControllerBase<PayPalPlusPaymentSettings>
15+
{
16+
public PayPalPlusController(
17+
IPaymentService paymentService,
18+
IOrderService orderService,
19+
IOrderProcessingService orderProcessingService) : base(
20+
PayPalPlusProvider.SystemName,
21+
paymentService,
22+
orderService,
23+
orderProcessingService)
24+
{
25+
}
26+
27+
[NonAction]
28+
public override IList<string> ValidatePaymentForm(FormCollection form)
29+
{
30+
var warnings = new List<string>();
31+
return warnings;
32+
}
33+
34+
[NonAction]
35+
public override ProcessPaymentRequest GetPaymentInfo(FormCollection form)
36+
{
37+
var paymentInfo = new ProcessPaymentRequest();
38+
return paymentInfo;
39+
}
40+
41+
[AdminAuthorize, ChildActionOnly]
42+
public ActionResult Configure()
43+
{
44+
var storeScope = this.GetActiveStoreScopeConfiguration(Services.StoreService, Services.WorkContext);
45+
var settings = Services.Settings.LoadSetting<PayPalPlusPaymentSettings>(storeScope);
46+
47+
var model = new PayPalPlusConfigurationModel
48+
{
49+
ConfigGroups = T("Plugins.SmartStore.PayPal.ConfigGroups").Text.SplitSafe(";")
50+
};
51+
52+
model.TransactModeValues = new SelectList(new List<object>
53+
{
54+
new { ID = (int)TransactMode.Authorize, Name = T("Plugins.SmartStore.PayPal.ModeAuth") },
55+
new { ID = (int)TransactMode.AuthorizeAndCapture, Name = T("Plugins.SmartStore.PayPal.ModeAuthAndCapture") }
56+
},
57+
"ID", "Name", (int)settings.TransactMode);
58+
59+
model.AvailableSecurityProtocols = GetSecurityProtocols()
60+
.Select(x => new SelectListItem { Value = ((int)x.Key).ToString(), Text = x.Value })
61+
.ToList();
62+
63+
model.Copy(settings, true);
64+
65+
var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData);
66+
storeDependingSettingHelper.GetOverrideKeys(settings, model, storeScope, Services.Settings);
67+
68+
return View(model);
69+
}
70+
71+
[HttpPost, AdminAuthorize, ChildActionOnly]
72+
public ActionResult Configure(PayPalPlusConfigurationModel model, FormCollection form)
73+
{
74+
if (!ModelState.IsValid)
75+
return Configure();
76+
77+
ModelState.Clear();
78+
79+
var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData);
80+
var storeScope = this.GetActiveStoreScopeConfiguration(Services.StoreService, Services.WorkContext);
81+
var settings = Services.Settings.LoadSetting<PayPalPlusPaymentSettings>(storeScope);
82+
83+
model.Copy(settings, false);
84+
85+
storeDependingSettingHelper.UpdateSettings(settings, form, storeScope, Services.Settings);
86+
87+
// multistore context not possible, see IPN handling
88+
Services.Settings.SaveSetting(settings, x => x.UseSandbox, 0, false);
89+
90+
Services.Settings.ClearCache();
91+
NotifySuccess(T("Admin.Common.DataSuccessfullySaved"));
92+
93+
return Configure();
94+
}
95+
96+
}
97+
}

src/Plugins/SmartStore.PayPal/Description.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
FriendlyName: PayPal
2-
Description: Provides the PayPal payment methods PayPal Express, PayPal Standard and PayPal Direct.
2+
Description: Provides the PayPal payment methods PayPal Standard, PayPal Direct, PayPal Express and PayPal Plus.
33
SystemName: SmartStore.PayPal
44
Group: Payment
5-
Version: 2.5.0.1
5+
Version: 2.5.0.2
66
MinAppVersion: 2.5.0
77
DisplayOrder: 1
88
FileName: SmartStore.PayPal.dll

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

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,23 @@
44
<Value>PayPal Zahlungsarten</Value>
55
</LocaleResource>
66
<LocaleResource Name="Plugins.Description.SmartStore.PayPal" AppendRootKey="false">
7-
<Value>Stellt die PayPal-Zahlungsarten PayPal Express, PayPal Standard und PayPal Direct zur Verfügung.</Value>
7+
<Value>Stellt die PayPal-Zahlungsarten PayPal Standard, PayPal Direct, PayPal Express und PayPal Plus zur Verfügung.</Value>
8+
</LocaleResource>
9+
10+
<LocaleResource Name="ConfigGroups">
11+
<Value>API Zugang;Datenaustausch;Sonstiges</Value>
12+
</LocaleResource>
13+
<LocaleResource Name="ModeAuth">
14+
<Value>Autorisierung sofort, Abbuchung später</Value>
15+
</LocaleResource>
16+
<LocaleResource Name="ModeAuthAndCapture">
17+
<Value>Sofort abbuchen</Value>
18+
</LocaleResource>
19+
<LocaleResource Name="ShowButtonInMiniShoppingCart">
20+
<Value>Button im Miniwarenkorb anzeigen</Value>
21+
</LocaleResource>
22+
<LocaleResource Name="ShowButtonInMiniShoppingCart.Hint">
23+
<Value>Legt fest, ob der Checkout-Button im Miniwarenkorb angezeigt werden soll.</Value>
824
</LocaleResource>
925

1026
<LocaleResource Name="Plugins.Payments.PayPal" AppendRootKey="false">
@@ -89,8 +105,8 @@
89105
</LocaleResource>
90106
</Children>
91107
</LocaleResource>
92-
93-
<LocaleResource Name="Plugins.FriendlyName.Payments.PayPalExpress" AppendRootKey="false">
108+
109+
<LocaleResource Name="Plugins.FriendlyName.Payments.PayPalExpress" AppendRootKey="false">
94110
<Value>PayPal Express</Value>
95111
</LocaleResource>
96112
<LocaleResource Name="Plugins.Payments.PayPalExpress" AppendRootKey="false">
@@ -333,5 +349,37 @@ Zahlungsgebühr: {10}]]>
333349
</Value>
334350
</LocaleResource>
335351
</Children>
336-
</LocaleResource>
352+
</LocaleResource>
353+
354+
<LocaleResource Name="Plugins.FriendlyName.Payments.PayPalPlus" AppendRootKey="false">
355+
<Value>PayPal Plus</Value>
356+
</LocaleResource>
357+
<LocaleResource Name="Plugins.Payments.PayPalPlus" AppendRootKey="false">
358+
<Children>
359+
<LocaleResource Name="AdminInstruction">
360+
<Value>
361+
<![CDATA[<p>Stellen Sie bitte sicher, dass PayPal die Primärwährung Ihres Shops unterstützt.</p>
362+
<ol>
363+
<li>Loggen Sie sich in Ihr PayPal-Konto ein.</li>
364+
<li>Klicken Sie auf den Register <b>Mein Profil</b>.</li>
365+
<li>Klicken Sie unter <b>Verkäufer/Händler</b> auf <b>API-Zugriff</b>.</li>
366+
<li>Klicken Sie auf <b>API-Berechtigung anfordern</b>.</li>
367+
<li>Wählen Sie die Option <b>Fordern Sie eine API-Signature an</b>.</li>
368+
<li>Klicken Sie auf <b>Zustimmen und senden</b>.</li>
369+
</ol>
370+
<p>Aktivieren Sie optional den PayPal-Service zum Empfang von IPN-Nachrichten (Instant Payment Notification):</p>
371+
<ol>
372+
<li>In Ihr Premier- oder Business-Konto einloggen.</li>
373+
<li>Auf den Register <b>Mein Profil</b> klicken.</li>
374+
<li>Unter <b>Sprach-Kodierung > Weitere Einstellungen</b> wählen Sie bitte UTF-8.</li>
375+
<li><b>Sofortige Zahlungsbestätigung</b> klicken.</li>
376+
<li><b>Einstellungen für sofortige Zahlungsbestätigungen wählen</b> klicken.</li>
377+
<li>Bei <b>Benachrichtigungs-URL</b> die URL Ihres IPN-Handlers (<b>https://www.yourStore.com/Plugins/SmartStore.PayPal/PayPalPlus/IPNHandler</b>) eingeben.</li>
378+
<li><b>Speichern</b> klicken. Danach sollten Sie eine Nachricht über die erfolgreiche Aktivierung von IPN erhalten.</li>
379+
</ol>]]>
380+
</Value>
381+
</LocaleResource>
382+
</Children>
383+
</LocaleResource>
384+
337385
</Language>

src/Plugins/SmartStore.PayPal/Localization/resources.en-us.xml

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,23 @@
44
<Value>PayPal Payment Methods</Value>
55
</LocaleResource>
66
<LocaleResource Name="Plugins.Description.SmartStore.PayPal" AppendRootKey="false">
7-
<Value>Provides the PayPal payment methods PayPal Express, PayPal Standard and PayPal Direct.</Value>
7+
<Value>Provides the PayPal payment methods PayPal Standard, PayPal Direct, PayPal Express and PayPal Plus.</Value>
8+
</LocaleResource>
9+
10+
<LocaleResource Name="ConfigGroups">
11+
<Value>API access;Data exchange;Miscellaneous</Value>
12+
</LocaleResource>
13+
<LocaleResource Name="ModeAuth">
14+
<Value>Authorize immediately, debit later</Value>
15+
</LocaleResource>
16+
<LocaleResource Name="ModeAuthAndCapture">
17+
<Value>Immediately debit</Value>
18+
</LocaleResource>
19+
<LocaleResource Name="ShowButtonInMiniShoppingCart">
20+
<Value>Show button in mini shopping cart</Value>
21+
</LocaleResource>
22+
<LocaleResource Name="ShowButtonInMiniShoppingCart.Hint">
23+
<Value>Soecifies to show the checkout button in the mini shopping cart.</Value>
824
</LocaleResource>
925

1026
<LocaleResource Name="Plugins.Payments.PayPal" AppendRootKey="false">
@@ -334,4 +350,37 @@ Payment fee: {10}]]>
334350
</LocaleResource>
335351
</Children>
336352
</LocaleResource>
353+
354+
<LocaleResource Name="Plugins.FriendlyName.Payments.PayPalPlus" AppendRootKey="false">
355+
<Value>PayPal Plus</Value>
356+
</LocaleResource>
357+
<LocaleResource Name="Plugins.Payments.PayPalPlus" AppendRootKey="false">
358+
<Children>
359+
<LocaleResource Name="AdminInstruction">
360+
<Value>
361+
<![CDATA[
362+
<p>If you're using PayPal ensure that your primary store currency is supported by Paypal.</p>
363+
<ol>
364+
<li>Log into your PayPal account.</li>
365+
<li>Click on <b>Profile</b> from the Home Menu.</li>
366+
<li>Under <b>Account Information</b> choose <b>API Access</b>.</li>
367+
<li>Choose <b>Request API credentials</b>.</li>
368+
<li>Choose <b>API Signature</b> as the credential type.</li>
369+
<li>Enable the checkbox and agree to the license <b>Terms-I agree to the API Certificate Terms of Use and terms incorporated therein</b> and press the Submit button.</li>
370+
</ol>
371+
<p>Before being able to receive IPN (Instant Payment Notification) messages (optional), you'll need to activate this service; follow these steps:</p>
372+
<ol>
373+
<li>Log in to your Premier or Business account.</li>
374+
<li>Click the Profile subtab.</li>
375+
<li>Click <b>Language Encoding</b> and <b>More options</b> and select UTF-8.</li>
376+
<li>Click <b>Instant Payment Notification</b> in the Selling Preferences column.</li>
377+
<li>Click the <b>Edit IPN Settings</b> button to update your settings.</li>
378+
<li>Select <b>Receive IPN messages</b> (enabled) and enter the URL of your IPN handler (<b>https://www.yourStore.com/Plugins/SmartStore.PayPal/PayPalPlus/IPNHandler</b>).</li>
379+
<li>Click <b>Save</b>, and you should get a message that you have successfully activated IPN.</li>
380+
</ol>]]>
381+
</Value>
382+
</LocaleResource>
383+
</Children>
384+
</LocaleResource>
385+
337386
</Language>

src/Plugins/SmartStore.PayPal/Models/ApiConfigurationModels.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,41 @@ public void Copy(PayPalExpressPaymentSettings settings, bool fromSettings)
130130
}
131131
}
132132
}
133+
134+
135+
public class PayPalPlusConfigurationModel : ApiConfigurationModel
136+
{
137+
[SmartResourceDisplayName("Plugins.SmartStore.PayPal.ShowButtonInMiniShoppingCart")]
138+
public bool ShowButtonInMiniShoppingCart { get; set; }
139+
140+
public void Copy(PayPalPlusPaymentSettings settings, bool fromSettings)
141+
{
142+
if (fromSettings)
143+
{
144+
SecurityProtocol = settings.SecurityProtocol;
145+
UseSandbox = settings.UseSandbox;
146+
IpnChangesPaymentStatus = settings.IpnChangesPaymentStatus;
147+
TransactMode = Convert.ToInt32(settings.TransactMode);
148+
ApiAccountName = settings.ApiAccountName;
149+
ApiAccountPassword = settings.ApiAccountPassword;
150+
Signature = settings.Signature;
151+
AdditionalFee = settings.AdditionalFee;
152+
AdditionalFeePercentage = settings.AdditionalFeePercentage;
153+
ShowButtonInMiniShoppingCart = settings.ShowButtonInMiniShoppingCart;
154+
}
155+
else
156+
{
157+
settings.SecurityProtocol = SecurityProtocol;
158+
settings.UseSandbox = UseSandbox;
159+
settings.IpnChangesPaymentStatus = IpnChangesPaymentStatus;
160+
settings.TransactMode = (TransactMode)TransactMode;
161+
settings.ApiAccountName = ApiAccountName;
162+
settings.ApiAccountPassword = ApiAccountPassword;
163+
settings.Signature = Signature;
164+
settings.AdditionalFee = AdditionalFee;
165+
settings.AdditionalFeePercentage = AdditionalFeePercentage;
166+
settings.ShowButtonInMiniShoppingCart = ShowButtonInMiniShoppingCart;
167+
}
168+
}
169+
}
133170
}

src/Plugins/SmartStore.PayPal/Plugin.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public override void Install()
2828
_settingService.SaveSetting<PayPalExpressPaymentSettings>(new PayPalExpressPaymentSettings());
2929
_settingService.SaveSetting<PayPalDirectPaymentSettings>(new PayPalDirectPaymentSettings());
3030
_settingService.SaveSetting<PayPalStandardPaymentSettings>(new PayPalStandardPaymentSettings());
31+
_settingService.SaveSetting<PayPalPlusPaymentSettings>(new PayPalPlusPaymentSettings());
3132

3233
_localizationService.ImportPluginResourcesFromXml(this.PluginDescriptor);
3334

@@ -39,6 +40,7 @@ public override void Uninstall()
3940
_settingService.DeleteSetting<PayPalExpressPaymentSettings>();
4041
_settingService.DeleteSetting<PayPalDirectPaymentSettings>();
4142
_settingService.DeleteSetting<PayPalStandardPaymentSettings>();
43+
_settingService.DeleteSetting<PayPalPlusPaymentSettings>();
4244

4345
_localizationService.DeleteLocaleStringResources(PluginDescriptor.ResourceRootKey);
4446

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
using System;
2+
using SmartStore.Core.Domain.Payments;
3+
using SmartStore.Core.Plugins;
4+
using SmartStore.PayPal.Controllers;
5+
using SmartStore.PayPal.Settings;
6+
using SmartStore.Services.Payments;
7+
8+
namespace SmartStore.PayPal
9+
{
10+
[SystemName("Payments.PayPalPlus")]
11+
[FriendlyName("PayPal Plus")]
12+
[DisplayOrder(1)]
13+
public partial class PayPalPlusProvider : PayPalProviderBase<PayPalPlusPaymentSettings>
14+
{
15+
public PayPalPlusProvider()
16+
{
17+
}
18+
19+
public static string SystemName
20+
{
21+
get { return "Payments.PayPalPlus"; }
22+
}
23+
24+
public override PaymentMethodType PaymentMethodType
25+
{
26+
get
27+
{
28+
return PaymentMethodType.StandardAndRedirection;
29+
}
30+
}
31+
32+
protected override string GetResourceRootKey()
33+
{
34+
return "Plugins.Payments.PayPalPlus";
35+
}
36+
37+
protected override string GetControllerName()
38+
{
39+
return "PayPalPlus";
40+
}
41+
42+
/// <summary>
43+
/// Process a payment
44+
/// </summary>
45+
/// <param name="processPaymentRequest">Payment info required for an order processing</param>
46+
/// <returns>Process payment result</returns>
47+
public override ProcessPaymentResult ProcessPayment(ProcessPaymentRequest processPaymentRequest)
48+
{
49+
var result = new ProcessPaymentResult
50+
{
51+
NewPaymentStatus = PaymentStatus.Pending
52+
};
53+
54+
return result;
55+
}
56+
57+
public override Type GetControllerType()
58+
{
59+
return typeof(PayPalPlusController);
60+
}
61+
}
62+
}

0 commit comments

Comments
 (0)