Skip to content

Commit 2f78cf0

Browse files
Payment plugin Purchase Order Number was included in Offline Payment Plugin
1 parent 72f2e7b commit 2f78cf0

14 files changed

Lines changed: 210 additions & 9 deletions

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* #733 Option to set a display order for homepage products
1818
* #607 HTML capable full description for payment methods displayed in checkout
1919
* #732 Product list: Option to display the pre-selected price instead of the lowest price
20+
* New payment provider for Offline Payment Plugin: Purchase Order Number
2021

2122
### Improvements
2223
* (Perf) Implemented static caches for URL aliases and localized properties. Increases app startup and request speed by up to 30%.

src/Libraries/SmartStore.Data/Migrations/201410091620122_NewRes.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,23 +91,23 @@ public void MigrateLocaleResources(LocaleResourcesBuilder builder)
9191
"Gültig bis");
9292

9393
builder.Update("Plugins.Payment.CashOnDelivery.PaymentInfoDescription")
94-
.Value("en", "Once your order is placed, you will be contacted by our stuff to confirm the order.")
94+
.Value("en", "Once your order is placed, you will be contacted by our staff to confirm the order.")
9595
.Value("de", "Sobald Ihre Bestellung abgeschloßen ist, werden Sie persönlich von einem unserer Mitarbeiter kontaktiert, um die Bestellung zu bestätigen.");
9696

9797
builder.Update("Plugins.Payment.Invoice.PaymentInfoDescription")
98-
.Value("en", "Once your order is placed, you will be contacted by our stuff to confirm the order.")
98+
.Value("en", "Once your order is placed, you will be contacted by our staff to confirm the order.")
9999
.Value("de", "Sobald Ihre Bestellung abgeschloßen ist, werden Sie persönlich von einem unserer Mitarbeiter kontaktiert, um die Bestellung zu bestätigen.");
100100

101101
builder.Update("Plugins.Payment.DirectDebit.PaymentInfoDescription")
102-
.Value("en", "Once your order is placed, you will be contacted by our stuff to confirm the order.")
102+
.Value("en", "Once your order is placed, you will be contacted by our staff to confirm the order.")
103103
.Value("de", "Sobald Ihre Bestellung abgeschloßen ist, werden Sie persönlich von einem unserer Mitarbeiter kontaktiert, um die Bestellung zu bestätigen.");
104104

105105
builder.Update("Plugins.Payment.PayInStore.PaymentInfoDescription")
106106
.Value("en", "Reserve items at your local store, and pay in store when you pick up your order.")
107107
.Value("de", "Reservieren Sie Produkte und zahlen Sie an der Kasse in unserem Ladenlokal.");
108108

109109
builder.Update("Plugins.Payment.Prepayment.PaymentInfoDescription")
110-
.Value("en", "Once your order is placed, you will be contacted by our stuff to confirm the order.")
110+
.Value("en", "Once your order is placed, you will be contacted by our staff to confirm the order.")
111111
.Value("de", "Sobald Ihre Bestellung abgeschloßen ist, werden Sie persönlich von einem unserer Mitarbeiter kontaktiert, um die Bestellung zu bestätigen.");
112112

113113
}

src/Plugins/SmartStore.OfflinePayment/Controllers/OfflinePaymentController.cs

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@ public override ProcessPaymentRequest GetPaymentInfo(FormCollection form)
191191
paymentInfo.DirectDebitCountry = form["DirectDebitCountry"];
192192
paymentInfo.DirectDebitIban = form["DirectDebitIban"];
193193
}
194+
else if (type == "PurchaseOrderNumber")
195+
{
196+
paymentInfo.PurchaseOrderNumber = form["PurchaseOrderNumber"];
197+
}
194198
}
195199

196200
return paymentInfo;
@@ -229,6 +233,10 @@ public override string GetPaymentSummary(FormCollection form)
229233
return number.Mask(8);
230234
}
231235
}
236+
else if (type == "PurchaseOrderNumber")
237+
{
238+
return form["PurchaseOrderNumber"];
239+
}
232240
}
233241

234242
return null;
@@ -495,5 +503,38 @@ public ActionResult ManualPaymentInfo()
495503

496504
#endregion
497505

498-
}
506+
#region PurchaseOrderNumber
507+
508+
[AdminAuthorize]
509+
[ChildActionOnly]
510+
public ActionResult PurchaseOrderNumberConfigure()
511+
{
512+
var model = ConfigureGet<PurchaseOrderNumberConfigurationModel, PurchaseOrderNumberPaymentSettings>();
513+
514+
return View("GenericConfigure", model);
515+
}
516+
517+
[HttpPost, AdminAuthorize, ChildActionOnly, ValidateInput(false)]
518+
public ActionResult PurchaseOrderNumberConfigure(PurchaseOrderNumberConfigurationModel model, FormCollection form)
519+
{
520+
if (!ModelState.IsValid)
521+
return InvoiceConfigure();
522+
523+
ConfigurePost<PurchaseOrderNumberConfigurationModel, InvoicePaymentSettings>(model, form);
524+
525+
return PurchaseOrderNumberConfigure();
526+
}
527+
528+
public ActionResult PurchaseOrderNumberPaymentInfo()
529+
{
530+
var model = PaymentInfoGet<PurchaseOrderNumberPaymentInfoModel, InvoicePaymentSettings>();
531+
532+
var form = this.GetPaymentData();
533+
model.PurchaseOrderNumber = form["PurchaseOrderNumber"];
534+
535+
return PartialView("PurchaseOrderNumberPaymentInfo", model);
536+
}
537+
538+
#endregion
539+
}
499540
}

src/Plugins/SmartStore.OfflinePayment/Description.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Description: Contains common offline payment methods like Direct Debit, Invoice, Prepayment etc.
33
Group: Payment
44
SystemName: SmartStore.OfflinePayment
5-
Version: 2.2.0
5+
Version: 2.2.2.1
66
MinAppVersion: 2.2.0
77
DisplayOrder: 0
88
FileName: SmartStore.OfflinePayment.dll

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,5 +211,21 @@
211211
</Children>
212212
</LocaleResource>
213213

214+
<!-- PuchaseOrderNumber -->
215+
<LocaleResource Name="Plugins.FriendlyName.Payments.PuchaseOrder" AppendRootKey="false">
216+
<Value>Bestellnummer</Value>
217+
</LocaleResource>
218+
<LocaleResource Name="Plugins.Payments.PuchaseOrder" AppendRootKey="false">
219+
<Children>
220+
<LocaleResource Name="AdminInstruction">
221+
<Value>
222+
<![CDATA[ ]]>
223+
</Value>
224+
</LocaleResource>
225+
<LocaleResource Name="PurchaseOrderNumber">
226+
<Value>Bestellnummer</Value>
227+
</LocaleResource>
228+
</Children>
229+
</LocaleResource>
214230

215231
</Language>

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

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<LocaleResource Name="PaymentInfoDescription">
3434
<Value>
3535
<![CDATA[
36-
Once your order is placed, you will be contacted by our stuff to confirm the order.
36+
Once your order is placed, you will be contacted by our staff to confirm the order.
3737
]]>
3838
</Value>
3939
</LocaleResource>
@@ -96,7 +96,7 @@
9696
<LocaleResource Name="PaymentInfoDescription">
9797
<Value>
9898
<![CDATA[
99-
Once your order is placed, you will be contacted by our stuff to confirm the order.
99+
Once your order is placed, you will be contacted by our staff to confirm the order.
100100
]]>
101101
</Value>
102102
</LocaleResource>
@@ -137,7 +137,7 @@
137137
<LocaleResource Name="PaymentInfoDescription">
138138
<Value>
139139
<![CDATA[
140-
Once your order is placed, you will be contacted by our stuff to confirm the order.
140+
Once your order is placed, you will be contacted by our staff to confirm the order.
141141
]]>
142142
</Value>
143143
</LocaleResource>
@@ -207,5 +207,21 @@
207207
</Children>
208208
</LocaleResource>
209209

210+
<!-- PuchaseOrderNumber -->
211+
<LocaleResource Name="Plugins.FriendlyName.Payments.PuchaseOrder" AppendRootKey="false">
212+
<Value>Purchase order</Value>
213+
</LocaleResource>
214+
<LocaleResource Name="Plugins.Payments.PuchaseOrder" AppendRootKey="false">
215+
<Children>
216+
<LocaleResource Name="AdminInstruction">
217+
<Value>
218+
<![CDATA[ ]]>
219+
</Value>
220+
</LocaleResource>
221+
<LocaleResource Name="PurchaseOrderNumber">
222+
<Value>PO Number</Value>
223+
</LocaleResource>
224+
</Children>
225+
</LocaleResource>
210226

211227
</Language>

src/Plugins/SmartStore.OfflinePayment/Models/ConfigurationModel.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,8 @@ public class PayInStoreConfigurationModel : ConfigurationModelBase
4545
public class PrepaymentConfigurationModel : ConfigurationModelBase
4646
{
4747
}
48+
49+
public class PurchaseOrderNumberConfigurationModel : ConfigurationModelBase
50+
{
51+
}
4852
}

src/Plugins/SmartStore.OfflinePayment/Models/PaymentInfoModel.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,10 @@ public class PrepaymentPaymentInfoModel : PaymentInfoModelBase
9797
{
9898
}
9999

100+
public class PurchaseOrderNumberPaymentInfoModel : PaymentInfoModelBase
101+
{
102+
[SmartResourceDisplayName("Plugins.Payment.PurchaseOrder.PurchaseOrderNumber")]
103+
[AllowHtml]
104+
public string PurchaseOrderNumber { get; set; }
105+
}
100106
}

src/Plugins/SmartStore.OfflinePayment/Plugin.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,18 @@ public override void Install()
4141
});
4242
settings.SaveSetting(new ManualPaymentSettings
4343
{
44+
DescriptionText = "@Plugins.Payments.Manual.PaymentInfoDescription",
4445
TransactMode = TransactMode.Pending
4546
});
4647
settings.SaveSetting(new DirectDebitPaymentSettings
4748
{
4849
DescriptionText = "@Plugins.Payments.DirectDebit.PaymentInfoDescription"
4950
});
51+
settings.SaveSetting(new PurchaseOrderNumberPaymentSettings
52+
{
53+
DescriptionText = "@Plugins.Payments.PurchaseOrderNumber.PaymentInfoDescription",
54+
TransactMode = TransactMode.Pending
55+
});
5056

5157
// add resources
5258
loc.ImportPluginResourcesFromXml(this.PluginDescriptor);
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Web.Routing;
4+
using SmartStore.Core.Domain.Orders;
5+
using SmartStore.Core.Domain.Payments;
6+
using SmartStore.Core.Plugins;
7+
using SmartStore.OfflinePayment.Settings;
8+
using SmartStore.Services.Configuration;
9+
using SmartStore.Services.Localization;
10+
using SmartStore.Services.Payments;
11+
12+
namespace SmartStore.OfflinePayment
13+
{
14+
[SystemName("SmartStore.PurchaseOrderNumber")]
15+
[FriendlyName("Purchase Order Number")]
16+
[DisplayOrder(10)]
17+
public class PurchaseOrderNumberProvider : OfflinePaymentProviderBase<PurchaseOrderNumberPaymentSettings>, IConfigurable
18+
{
19+
private readonly ISettingService _settingService;
20+
private readonly ILocalizationService _localizationService;
21+
22+
public PurchaseOrderNumberProvider(ISettingService settingService, ILocalizationService localizationService)
23+
{
24+
_settingService = settingService;
25+
_localizationService = localizationService;
26+
}
27+
28+
public override ProcessPaymentResult ProcessPayment(ProcessPaymentRequest processPaymentRequest)
29+
{
30+
var result = new ProcessPaymentResult();
31+
var settings = CommonServices.Settings.LoadSetting<ManualPaymentSettings>(processPaymentRequest.StoreId);
32+
33+
result.AllowStoringCreditCardNumber = true;
34+
switch (settings.TransactMode)
35+
{
36+
case TransactMode.Pending:
37+
result.NewPaymentStatus = PaymentStatus.Pending;
38+
break;
39+
case TransactMode.Authorize:
40+
result.NewPaymentStatus = PaymentStatus.Authorized;
41+
break;
42+
case TransactMode.AuthorizeAndCapture:
43+
result.NewPaymentStatus = PaymentStatus.Paid;
44+
break;
45+
default:
46+
{
47+
result.AddError(T("Common.Payment.TranactionTypeNotSupported"));
48+
return result;
49+
}
50+
}
51+
52+
return result;
53+
}
54+
55+
public override bool RequiresInteraction
56+
{
57+
get
58+
{
59+
return true;
60+
}
61+
}
62+
63+
protected override string GetActionPrefix()
64+
{
65+
return "PurchaseOrderNumber";
66+
}
67+
68+
}
69+
}

0 commit comments

Comments
 (0)