-
Notifications
You must be signed in to change notification settings - Fork 5
/
VippsPaymentMethod.cs
69 lines (58 loc) · 2.43 KB
/
VippsPaymentMethod.cs
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
using System.ComponentModel;
using EPiServer.Commerce.Order;
using EPiServer.Framework.Localization;
using EPiServer.Reference.Commerce.Site.Features.Cart.Services;
using EPiServer.Reference.Commerce.Site.Features.Market.Services;
using EPiServer.Reference.Commerce.Site.Features.Payment.Services;
using EPiServer.ServiceLocation;
using EPiServer.Web;
using Mediachase.Commerce;
using Mediachase.Commerce.Orders;
using Vipps;
namespace EPiServer.Reference.Commerce.Site.Features.Payment.PaymentMethods
{
[ServiceConfiguration(typeof(IPaymentMethod), Lifecycle = ServiceInstanceScope.Hybrid)]
public class VippsPaymentMethod : PaymentMethodBase, IDataErrorInfo
{
private readonly IOrderGroupFactory _orderGroupFactory;
public override string SystemKeyword => VippsConstants.VippsSystemKeyword;
public VippsPaymentMethod()
: this(
LocalizationService.Current,
ServiceLocator.Current.GetInstance<IOrderGroupFactory>(),
ServiceLocator.Current.GetInstance<LanguageService>(),
ServiceLocator.Current.GetInstance<IPaymentManagerFacade>())
{
}
public VippsPaymentMethod(
LocalizationService localizationService,
IOrderGroupFactory orderGroupFactory,
LanguageService languageService,
IPaymentManagerFacade paymentManager)
: base(localizationService, orderGroupFactory, languageService, paymentManager)
{
_orderGroupFactory = orderGroupFactory;
}
public override IPayment CreatePayment(decimal amount, IOrderGroup orderGroup)
{
var payment = orderGroup.CreatePayment(_orderGroupFactory);
payment.PaymentType = PaymentType.Other;
payment.PaymentMethodId = PaymentMethodId;
payment.PaymentMethodName = VippsConstants.VippsSystemKeyword;
payment.Amount = amount;
payment.Status = PaymentStatus.Pending.ToString();
payment.TransactionType = TransactionType.Authorization.ToString();
return payment;
}
public void PostProcess(IPayment payment)
{
payment.Status = PaymentStatus.Processed.ToString();
}
public override bool ValidateData()
{
return true;
}
public string this[string columnName] => string.Empty;
public string Error { get; }
}
}