forked from smartstore/SmartStoreNET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlugin.cs
More file actions
151 lines (123 loc) · 4.11 KB
/
Copy pathPlugin.cs
File metadata and controls
151 lines (123 loc) · 4.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
using System;
using System.Collections.Generic;
using System.Web.Routing;
using SmartStore.AmazonPay.Controllers;
using SmartStore.AmazonPay.Services;
using SmartStore.AmazonPay.Settings;
using SmartStore.Core.Domain.Orders;
using SmartStore.Core.Plugins;
using SmartStore.Services;
using SmartStore.Services.Orders;
using SmartStore.Services.Payments;
namespace SmartStore.AmazonPay
{
[DependentWidgets("Widgets.AmazonPay")]
public class Plugin : PaymentPluginBase, IConfigurable
{
private readonly IAmazonPayService _apiService;
private readonly IOrderTotalCalculationService _orderTotalCalculationService;
private readonly ICommonServices _services;
public Plugin(
IAmazonPayService apiService,
IOrderTotalCalculationService orderTotalCalculationService,
ICommonServices services)
{
_apiService = apiService;
_orderTotalCalculationService = orderTotalCalculationService;
_services = services;
}
public override void Install()
{
_services.Settings.SaveSetting<AmazonPaySettings>(new AmazonPaySettings());
_services.Localization.ImportPluginResourcesFromXml(this.PluginDescriptor);
_apiService.DataPollingTaskInit();
base.Install();
}
public override void Uninstall()
{
_apiService.DataPollingTaskDelete();
_services.Settings.DeleteSetting<AmazonPaySettings>();
_services.Localization.DeleteLocaleStringResources(this.PluginDescriptor.ResourceRootKey);
base.Uninstall();
}
public override PreProcessPaymentResult PreProcessPayment(ProcessPaymentRequest processPaymentRequest)
{
var result = _apiService.PreProcessPayment(processPaymentRequest);
return result;
}
public override ProcessPaymentResult ProcessPayment(ProcessPaymentRequest processPaymentRequest)
{
var result = _apiService.ProcessPayment(processPaymentRequest);
return result;
}
public override void PostProcessPayment(PostProcessPaymentRequest postProcessPaymentRequest)
{
_apiService.PostProcessPayment(postProcessPaymentRequest);
}
public override decimal GetAdditionalHandlingFee(IList<OrganizedShoppingCartItem> cart)
{
var result = decimal.Zero;
try
{
var settings = _services.Settings.LoadSetting<AmazonPaySettings>(_services.StoreContext.CurrentStore.Id);
result = this.CalculateAdditionalFee(_orderTotalCalculationService, cart, settings.AdditionalFee, settings.AdditionalFeePercentage);
}
catch (Exception exc)
{
_apiService.LogError(exc);
}
return result;
}
public override CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
{
var result = _apiService.Capture(capturePaymentRequest);
return result;
}
public override RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
{
var result = _apiService.Refund(refundPaymentRequest);
return result;
}
public override VoidPaymentResult Void(VoidPaymentRequest voidPaymentRequest)
{
var result = _apiService.Void(voidPaymentRequest);
return result;
}
public override void GetConfigurationRoute(out string actionName, out string controllerName, out RouteValueDictionary routeValues)
{
actionName = "Configure";
controllerName = "AmazonPay";
routeValues = new RouteValueDictionary() { { "Namespaces", "SmartStore.AmazonPay.Controllers" }, { "area", AmazonPayCore.SystemName } };
}
public override void GetPaymentInfoRoute(out string actionName, out string controllerName, out RouteValueDictionary routeValues)
{
actionName = "ShoppingCart";
controllerName = "AmazonPayShoppingCart";
routeValues = new RouteValueDictionary() { { "Namespaces", "SmartStore.AmazonPay.Controllers" }, { "area", AmazonPayCore.SystemName } };
}
public override Type GetControllerType()
{
return typeof(AmazonPayController);
}
public override bool SupportCapture
{
get { return true; }
}
public override bool SupportPartiallyRefund
{
get { return true; }
}
public override bool SupportRefund
{
get { return true; }
}
public override bool SupportVoid
{
get { return true; }
}
public override PaymentMethodType PaymentMethodType
{
get { return PaymentMethodType.StandardAndButton; }
}
}
}