-
Notifications
You must be signed in to change notification settings - Fork 0
/
PayooPaymentMethod.cs
57 lines (47 loc) · 1.91 KB
/
PayooPaymentMethod.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
using System;
using System.Linq;
using EPiServer.Commerce.Order;
using EPiServer.ServiceLocation;
using Mediachase.Commerce.Orders;
using Mediachase.Commerce.Orders.Dto;
namespace Foundation.Commerce.Payment.Payoo
{
[ServiceConfiguration(typeof(IPaymentMethod))]
public class PayooPaymentMethod : IPaymentMethod
{
private readonly IOrderGroupFactory _orderGroupFactory;
private readonly PaymentMethodDto.PaymentMethodRow _paymentMethod;
public Guid PaymentMethodId { get; }
public string SystemKeyword { get; }
public string Name { get; }
public string Description { get; }
public PayooPaymentMethod() : this(ServiceLocator.Current.GetInstance<IOrderGroupFactory>())
{
}
public PayooPaymentMethod(IOrderGroupFactory orderGroupFactory)
{
_orderGroupFactory = orderGroupFactory;
var paymentMethodDto = PayooConfiguration.GetPayooPaymentMethod();
_paymentMethod = paymentMethodDto?.PaymentMethod?.FirstOrDefault();
if (_paymentMethod == null)
{
return;
}
PaymentMethodId = _paymentMethod.PaymentMethodId;
SystemKeyword = _paymentMethod.SystemKeyword;
Name = _paymentMethod.Name;
Description = _paymentMethod.Description;
}
public bool ValidateData() => true;
public IPayment CreatePayment(decimal amount, IOrderGroup orderGroup)
{
var payment = orderGroup.CreatePayment(_orderGroupFactory, typeof(PayooPayment));
payment.PaymentMethodId = _paymentMethod.PaymentMethodId;
payment.PaymentMethodName = _paymentMethod.Name;
payment.Amount = amount;
payment.Status = PaymentStatus.Pending.ToString();
payment.TransactionType = TransactionType.Authorization.ToString();
return payment;
}
}
}