-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathPaymentIn.cs
More file actions
162 lines (135 loc) · 5.68 KB
/
PaymentIn.cs
File metadata and controls
162 lines (135 loc) · 5.68 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
152
153
154
155
156
157
158
159
160
161
162
using System;
using System.Collections.Generic;
using System.Linq;
using VirtoCommerce.CoreModule.Core.Common;
using VirtoCommerce.CoreModule.Core.Tax;
using VirtoCommerce.PaymentModule.Core.Model;
using VirtoCommerce.PaymentModule.Model.Requests;
using VirtoCommerce.Platform.Core.Common;
namespace VirtoCommerce.OrdersModule.Core.Model
{
public class PaymentIn : OrderOperation, IHasTaxDetalization, ITaxable, IHasDiscounts, ICloneable, IHasFeesDetalization
{
public string OrderId { get; set; }
[Auditable]
public string Purpose { get; set; }
/// <summary>
/// Payment method (gateway) code
/// </summary>
[Auditable]
public string GatewayCode { get; set; }
/// <summary>
/// Payment method contains additional payment method information
/// </summary>
public PaymentMethod PaymentMethod { get; set; }
public string OrganizationId { get; set; }
public string OrganizationName { get; set; }
public string CustomerId { get; set; }
public string CustomerName { get; set; }
[Auditable]
public DateTime? IncomingDate { get; set; }
public Address BillingAddress { get; set; }
[Auditable]
public PaymentStatus PaymentStatus { get; set; }
[Auditable]
public DateTime? AuthorizedDate { get; set; }
[Auditable]
public DateTime? CapturedDate { get; set; }
[Auditable]
public DateTime? VoidedDate { get; set; }
public ProcessPaymentRequestResult ProcessPaymentResult { get; set; }
//the self cost of the payment method
public virtual decimal Price { get; set; }
public virtual decimal PriceWithTax { get; set; }
[Auditable]
public virtual decimal Total { get; set; }
public virtual decimal TotalWithTax { get; set; }
[Auditable]
public virtual decimal DiscountAmount { get; set; }
public virtual decimal DiscountAmountWithTax { get; set; }
public override string ObjectType { get; set; } = typeof(PaymentIn).FullName;
public ICollection<FeeDetail> FeeDetails { get; set; }
public string VendorId { get; set; }
#region ITaxable Members
/// <summary>
/// Tax category or type
/// </summary>
[Auditable]
public string TaxType { get; set; }
[Auditable]
public decimal TaxTotal { get; set; }
[Auditable]
public decimal TaxPercentRate { get; set; }
#endregion
#region ITaxDetailSupport Members
public ICollection<TaxDetail> TaxDetails { get; set; }
#endregion
#region IHasDiscounts
public ICollection<Discount> Discounts { get; set; }
#endregion
public ICollection<PaymentGatewayTransaction> Transactions { get; set; }
public ICollection<Refund> Refunds { get; set; }
public ICollection<Capture> Captures { get; set; }
public virtual void ReduceDetails(string responseGroup)
{
//Reduce details according to response group
var orderResponseGroup = EnumUtility.SafeParseFlags(responseGroup, CustomerOrderResponseGroup.Full);
if (!orderResponseGroup.HasFlag(CustomerOrderResponseGroup.WithAddresses))
{
BillingAddress = null;
}
if (!orderResponseGroup.HasFlag(CustomerOrderResponseGroup.WithDiscounts))
{
Discounts = null;
}
if (!orderResponseGroup.HasFlag(CustomerOrderResponseGroup.WithRefunds))
{
Refunds = null;
}
if (!orderResponseGroup.HasFlag(CustomerOrderResponseGroup.WithCaptures))
{
Captures = null;
}
if (!orderResponseGroup.HasFlag(CustomerOrderResponseGroup.WithPrices))
{
Price = 0m;
PriceWithTax = 0m;
DiscountAmount = 0m;
DiscountAmountWithTax = 0m;
Total = 0m;
TotalWithTax = 0m;
TaxTotal = 0m;
TaxPercentRate = 0m;
Sum = 0m;
}
}
public virtual void RestoreDetails(PaymentIn payment)
{
Price = payment.Price;
PriceWithTax = payment.PriceWithTax;
DiscountAmount = payment.DiscountAmount;
DiscountAmountWithTax = payment.DiscountAmountWithTax;
Total = payment.Total;
TotalWithTax = payment.TotalWithTax;
TaxTotal = payment.TaxTotal;
TaxPercentRate = payment.TaxPercentRate;
Sum = payment.Sum;
}
#region ICloneable members
public override object Clone()
{
var result = base.Clone() as PaymentIn;
result.PaymentMethod = PaymentMethod?.Clone() as PaymentMethod;
result.BillingAddress = BillingAddress?.Clone() as Address;
result.ProcessPaymentResult = ProcessPaymentResult?.Clone() as ProcessPaymentRequestResult;
result.Transactions = Transactions?.Select(x => x.Clone()).OfType<PaymentGatewayTransaction>().ToList();
result.Discounts = Discounts?.Select(x => x.Clone()).OfType<Discount>().ToList();
result.TaxDetails = TaxDetails?.Select(x => x.Clone()).OfType<TaxDetail>().ToList();
result.FeeDetails = FeeDetails?.Select(x => x.Clone()).OfType<FeeDetail>().ToList();
result.Refunds = Refunds?.Select(x => x.Clone()).OfType<Refund>().ToList();
result.Captures = Captures?.Select(x => x.Clone()).OfType<Capture>().ToList();
return result;
}
#endregion
}
}