Skip to content

Commit be2b497

Browse files
committed
Added AmazonPay payment plugin to core
1 parent 834d981 commit be2b497

52 files changed

Lines changed: 5410 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<configuration>
3+
<system.webServer>
4+
<handlers accessPolicy="Script,Read">
5+
<!-- iis7 - for any request to a file exists on disk, return it via native http module. accessPolicy 'Script' is to allow for a managed 404 page. -->
6+
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />
7+
</handlers>
8+
</system.webServer>
9+
</configuration>
4.44 KB
Loading
4.3 KB
Loading
981 Bytes
Loading
4.44 KB
Loading
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.config-logo {
2+
width: 339px;
3+
height: 74px;
4+
}
5+
6+
.amazon-pay-button .selection-text {
7+
text-align: right;
8+
font-weight: bold;
9+
padding: 12px 15px 5px 0;
10+
}
11+
12+
.amazon-pay-button .button-container {
13+
text-align: right;
14+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using System.Web.Mvc;
2+
using SmartStore.AmazonPay.Services;
3+
4+
namespace SmartStore.AmazonPay.Controllers
5+
{
6+
public class AmazonPayCheckoutController : AmazonPayControllerBase
7+
{
8+
private readonly IAmazonPayService _apiService;
9+
10+
public AmazonPayCheckoutController(IAmazonPayService apiService)
11+
{
12+
_apiService = apiService;
13+
}
14+
15+
public ActionResult BillingAddress()
16+
{
17+
return RedirectToAction("ShippingAddress", "Checkout", new { area = "" });
18+
}
19+
20+
public ActionResult ShippingAddress()
21+
{
22+
var model = _apiService.ProcessPluginRequest(AmazonPayRequestType.Address, TempData);
23+
24+
return GetActionResult(model);
25+
}
26+
27+
public ActionResult PaymentMethod()
28+
{
29+
var model = _apiService.ProcessPluginRequest(AmazonPayRequestType.Payment, TempData);
30+
31+
return GetActionResult(model);
32+
}
33+
34+
[HttpPost]
35+
public ActionResult PaymentMethod(bool? UseRewardPoints)
36+
{
37+
_apiService.ApplyRewardPoints(UseRewardPoints ?? false);
38+
39+
return RedirectToAction("Confirm", "Checkout", new { area = "" });
40+
}
41+
42+
public ActionResult PaymentInfo()
43+
{
44+
return RedirectToAction("PaymentMethod", "Checkout", new { area = "" });
45+
}
46+
}
47+
}
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.Web.Mvc;
3+
using SmartStore.AmazonPay.Services;
4+
using SmartStore.AmazonPay.Models;
5+
using SmartStore.AmazonPay.Settings;
6+
using SmartStore.Services.Configuration;
7+
using SmartStore.Services.Payments;
8+
using SmartStore.Services;
9+
using SmartStore.Services.Stores;
10+
using SmartStore.Web.Framework.Controllers;
11+
using SmartStore.Web.Framework.Settings;
12+
using SmartStore.Web.Framework.Security;
13+
14+
namespace SmartStore.AmazonPay.Controllers
15+
{
16+
public class AmazonPayController : PaymentControllerBase
17+
{
18+
private readonly IAmazonPayService _apiService;
19+
private readonly ISettingService _settingService;
20+
private readonly ICommonServices _services;
21+
private readonly IStoreService _storeService;
22+
23+
public AmazonPayController(
24+
IAmazonPayService apiService,
25+
ISettingService settingService,
26+
ICommonServices services,
27+
IStoreService storeService)
28+
{
29+
_apiService = apiService;
30+
_settingService = settingService;
31+
_services = services;
32+
_storeService = storeService;
33+
}
34+
35+
[NonAction]
36+
public override IList<string> ValidatePaymentForm(FormCollection form)
37+
{
38+
var warnings = new List<string>();
39+
return warnings;
40+
}
41+
42+
[NonAction]
43+
public override ProcessPaymentRequest GetPaymentInfo(FormCollection form)
44+
{
45+
var paymentInfo = new ProcessPaymentRequest();
46+
return paymentInfo;
47+
}
48+
49+
[AdminAuthorize]
50+
public ActionResult Configure()
51+
{
52+
var model = new ConfigurationModel();
53+
int storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _services.WorkContext);
54+
var settings = _settingService.LoadSetting<AmazonPaySettings>(storeScope);
55+
56+
model.Copy(settings, true);
57+
58+
_apiService.SetupConfiguration(model);
59+
60+
var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData);
61+
storeDependingSettingHelper.GetOverrideKeys(settings, model, storeScope, _settingService);
62+
63+
return View(model);
64+
}
65+
66+
[HttpPost, AdminAuthorize]
67+
public ActionResult Configure(ConfigurationModel model, FormCollection form)
68+
{
69+
if (!ModelState.IsValid)
70+
return Configure();
71+
72+
var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData);
73+
int storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _services.WorkContext);
74+
var settings = _settingService.LoadSetting<AmazonPaySettings>(storeScope);
75+
76+
model.Copy(settings, false);
77+
78+
storeDependingSettingHelper.UpdateSettings(settings, form, storeScope, _settingService);
79+
_settingService.ClearCache();
80+
81+
_apiService.DataPollingTaskUpdate(settings.DataFetching == AmazonPayDataFetchingType.Polling, model.PollingTaskMinutes * 60);
82+
83+
NotifySuccess(_services.Localization.GetResource("Plugins.Payments.AmazonPay.ConfigSaveNote"));
84+
85+
return Configure();
86+
}
87+
88+
[HttpPost]
89+
[ValidateInput(false)]
90+
[RequireHttpsByConfigAttribute(SslRequirement.Yes)]
91+
public ActionResult IPNHandler()
92+
{
93+
_apiService.ProcessIpn(Request);
94+
return Content("OK");
95+
}
96+
}
97+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System.Web.Mvc;
2+
using SmartStore.AmazonPay.Models;
3+
using SmartStore.AmazonPay.Services;
4+
using SmartStore.Web.Framework.Controllers;
5+
6+
namespace SmartStore.AmazonPay.Controllers
7+
{
8+
public abstract partial class AmazonPayControllerBase : PublicControllerBase
9+
{
10+
protected ActionResult GetActionResult(AmazonPayViewModel model)
11+
{
12+
switch (model.Result)
13+
{
14+
case AmazonPayResultType.None:
15+
return new EmptyResult();
16+
17+
case AmazonPayResultType.PluginView:
18+
return View(model);
19+
20+
case AmazonPayResultType.Unauthorized:
21+
return new HttpUnauthorizedResult();
22+
23+
case AmazonPayResultType.Redirect:
24+
default:
25+
return RedirectToAction(model.RedirectAction, model.RedirectController, new { area = "" });
26+
}
27+
}
28+
}
29+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
using System.Web.Mvc;
2+
using SmartStore.AmazonPay.Services;
3+
4+
namespace SmartStore.AmazonPay.Controllers
5+
{
6+
public class AmazonPayShoppingCartController : AmazonPayControllerBase
7+
{
8+
private readonly IAmazonPayService _apiService;
9+
10+
public AmazonPayShoppingCartController(IAmazonPayService apiService)
11+
{
12+
_apiService = apiService;
13+
}
14+
15+
public ActionResult LoginHandler(string orderReferenceId)
16+
{
17+
var model = _apiService.ProcessPluginRequest(AmazonPayRequestType.LoginHandler, TempData, orderReferenceId);
18+
19+
return GetActionResult(model);
20+
}
21+
22+
[ChildActionOnly]
23+
public ActionResult ShoppingCart()
24+
{
25+
if (ControllerContext.ParentActionViewContext.RequestContext.RouteData.IsRouteEqual("ShoppingCart", "Cart"))
26+
{
27+
var model = _apiService.ProcessPluginRequest(AmazonPayRequestType.ShoppingCart, TempData);
28+
29+
return GetActionResult(model);
30+
}
31+
return new EmptyResult();
32+
}
33+
34+
[ChildActionOnly]
35+
public ActionResult OrderReviewData(bool renderAmazonPayView)
36+
{
37+
if (renderAmazonPayView)
38+
{
39+
var model = _apiService.ProcessPluginRequest(AmazonPayRequestType.OrderReviewData, TempData);
40+
41+
return View(model);
42+
}
43+
return new EmptyResult();
44+
}
45+
46+
[ChildActionOnly]
47+
public ActionResult MiniShoppingCart(bool renderAmazonPayView)
48+
{
49+
if (renderAmazonPayView)
50+
{
51+
var model = _apiService.ProcessPluginRequest(AmazonPayRequestType.MiniShoppingCart, TempData);
52+
53+
return GetActionResult(model);
54+
}
55+
return new EmptyResult();
56+
}
57+
58+
[ChildActionOnly]
59+
public ActionResult WidgetLibrary()
60+
{
61+
// not possible to load it asynchronously cause of document.write inside
62+
string widgetUrl = _apiService.GetWidgetUrl();
63+
64+
if (widgetUrl.HasValue())
65+
{
66+
return this.Content("<script src=\"{0}\" type=\"text/javascript\"></script>".FormatWith(widgetUrl));
67+
}
68+
return new EmptyResult();
69+
}
70+
}
71+
}

0 commit comments

Comments
 (0)