-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathCheckoutProfile.cs
192 lines (190 loc) · 8.51 KB
/
CheckoutProfile.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
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
using System;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using IMLokesh.Extensions;
namespace Better_Nike_Bot
{
// Token: 0x02000008 RID: 8
public partial class CheckoutProfile : Form
{
// Token: 0x06000033 RID: 51 RVA: 0x00004C8C File Offset: 0x00002E8C
public CheckoutProfile(CreditCardProfile c = null)
{
this.InitializeComponent();
base.CenterToParent();
this.comboBoxBillingState.SelectedIndex = 0;
this.comboBoxShippingState.SelectedIndex = 0;
this.comboBoxBillingStateJP.SelectedIndex = 0;
this.comboBoxShippingStateJP.SelectedIndex = 0;
if (c.IsNull())
{
return;
}
this.label26.Visible = true;
this.textBoxProfileName.Text = c.Name;
this.textBoxBillingFirstName.Text = c.BillingFirstName;
this.textBoxBillingLastName.Text = c.BillingLastName;
this.textBoxBillingAddress1.Text = c.BillingAddress1;
this.textBoxBillingZipCode.Text = c.BillingZipCode;
this.textBoxBillingCity.Text = c.BillingCity;
this.textBoxBillingPhone.Text = c.BillingPhone;
if (!c.BillingState.IsNullOrWhiteSpace())
{
this.comboBoxBillingState.SelectedItem = this.comboBoxBillingState.Items.Cast<string>().FirstOrDefault((string i) => i.EndsWith(c.BillingState));
}
if (!c.ShippingState.IsNullOrWhiteSpace())
{
this.comboBoxShippingState.SelectedItem = this.comboBoxShippingState.Items.Cast<string>().FirstOrDefault((string i) => i.EndsWith(c.ShippingState));
}
if (!c.BillingStateJP.IsNullOrWhiteSpace())
{
this.comboBoxBillingStateJP.SelectedItem = this.comboBoxBillingStateJP.Items.Cast<string>().FirstOrDefault((string i) => i.EndsWith(c.BillingStateJP));
}
if (!c.ShippingStateJP.IsNullOrWhiteSpace())
{
this.comboBoxShippingStateJP.SelectedItem = this.comboBoxShippingStateJP.Items.Cast<string>().FirstOrDefault((string i) => i.EndsWith(c.ShippingStateJP));
}
this.textBoxShippingFirst.Text = c.ShippingFirstName;
this.textBoxShippingPhone.Text = c.ShippingPhone;
this.textBoxShippingLast.Text = c.ShippingLastName;
this.textBoxShippingAddress1.Text = c.ShippingAddress1;
this.textBoxShippingCity.Text = c.ShippingCity;
this.textBoxShippingPostalCode.Text = c.ShippingZipCode;
this.comboBoxCardType.SelectedItem = c.CreditCardType;
this.textBoxCardNumber.Text = c.CreditCardNumber;
this.comboBoxExpirationMonth.SelectedItem = c.CreditCardExpiryMonth;
this.comboBoxExpirationYear.SelectedItem = c.CreditCardExpiryYear;
this.textBoxCvv.Text = c.CreditCardCvv;
this.textBoxMaxCheckouts.Text = c.MaxCheckouts.ToString();
this.textBoxBillingAddress2.Text = c.BillingAddress2;
this.textBoxShippingAddress2.Text = c.ShippingAddress2;
this.textBoxBillingAddress3.Text = c.BillingAddress3;
this.textBoxShippingAddress3.Text = c.ShippingAddress3;
}
// Token: 0x06000034 RID: 52 RVA: 0x0000503C File Offset: 0x0000323C
private void buttonSave_Click(object sender, EventArgs e)
{
if (this.checkBoxShippingSame.Checked)
{
this.comboBoxShippingState.SelectedItem = this.comboBoxBillingState.SelectedItem;
this.comboBoxShippingStateJP.SelectedItem = this.comboBoxBillingStateJP.SelectedItem;
this.textBoxShippingAddress1.Text = this.textBoxBillingAddress1.Text;
this.textBoxShippingAddress2.Text = this.textBoxBillingAddress2.Text;
this.textBoxShippingAddress3.Text = this.textBoxBillingAddress3.Text;
this.textBoxShippingCity.Text = this.textBoxBillingCity.Text;
this.textBoxShippingFirst.Text = this.textBoxBillingFirstName.Text;
this.textBoxShippingLast.Text = this.textBoxBillingLastName.Text;
this.textBoxShippingPhone.Text = this.textBoxBillingPhone.Text;
this.textBoxShippingPostalCode.Text = this.textBoxBillingZipCode.Text;
}
try
{
string[] source = new string[]
{
this.textBoxProfileName.Text,
this.textBoxBillingFirstName.Text,
this.textBoxBillingLastName.Text,
this.textBoxBillingAddress1.Text,
this.textBoxBillingZipCode.Text,
this.textBoxBillingCity.Text,
this.textBoxBillingPhone.Text,
this.textBoxShippingFirst.Text,
this.textBoxShippingPhone.Text,
this.textBoxShippingLast.Text,
this.textBoxShippingAddress1.Text,
this.textBoxShippingCity.Text,
this.textBoxShippingPostalCode.Text,
this.comboBoxCardType.SelectedItem.IsNull() ? "" : this.comboBoxCardType.SelectedItem.ToString(),
this.textBoxCardNumber.Text,
this.comboBoxExpirationMonth.SelectedItem.IsNull() ? "" : this.comboBoxExpirationMonth.SelectedItem.ToString(),
this.comboBoxExpirationYear.SelectedItem.IsNull() ? "" : this.comboBoxExpirationYear.SelectedItem.ToString(),
this.textBoxCvv.Text,
this.textBoxMaxCheckouts.Text
};
if (source.Any((string s) => s.IsNullOrWhiteSpace()))
{
throw new Exception("A required value is missing. Make sure you fill all details.");
}
if (new string[]
{
this.textBoxShippingPhone.Text,
this.textBoxBillingPhone.Text
}.Any((string s) => !s.RegexIsMatch("^[0-9]{10,}$")))
{
throw new Exception("Please enter a valid 10 digit phone number.");
}
if (new string[]
{
this.textBoxCardNumber.Text,
this.textBoxCvv.Text
}.Any((string s) => !s.RegexIsMatch("^[0-9]+$")))
{
throw new Exception("Please enter valid card details. Remove any blank spaces.");
}
if (this.comboBoxBillingStateJP.SelectedIndex != 0 && this.textBoxBillingAddress3.Text.IsNullOrWhiteSpace())
{
"Please also enter 町域 (Town Area) for running for Japan.".Show(MessageBoxIcon.Asterisk, "", MessageBoxButtons.OK);
}
CreditCardProfile creditCardProfile = new CreditCardProfile
{
Name = this.textBoxProfileName.Text,
BillingFirstName = this.textBoxBillingFirstName.Text,
BillingLastName = this.textBoxBillingLastName.Text,
BillingAddress1 = this.textBoxBillingAddress1.Text,
BillingAddress2 = this.textBoxBillingAddress2.Text,
BillingAddress3 = this.textBoxBillingAddress3.Text,
BillingZipCode = this.textBoxBillingZipCode.Text,
BillingCity = this.textBoxBillingCity.Text,
BillingPhone = this.textBoxBillingPhone.Text,
BillingState = ((this.comboBoxBillingState.SelectedIndex == 0) ? "" : this.comboBoxBillingState.SelectedItem.ToString().Split(new string[]
{
" - "
}, StringSplitOptions.None).Last<string>()),
ShippingState = ((this.comboBoxShippingState.SelectedIndex == 0) ? "" : this.comboBoxShippingState.SelectedItem.ToString().Split(new string[]
{
" - "
}, StringSplitOptions.None).Last<string>()),
BillingStateJP = ((this.comboBoxBillingStateJP.SelectedIndex == 0) ? "" : this.comboBoxBillingStateJP.SelectedItem.ToString().Split(new string[]
{
" - "
}, StringSplitOptions.None).Last<string>()),
ShippingStateJP = ((this.comboBoxShippingStateJP.SelectedIndex == 0) ? "" : this.comboBoxShippingStateJP.SelectedItem.ToString().Split(new string[]
{
" - "
}, StringSplitOptions.None).Last<string>()),
ShippingFirstName = this.textBoxShippingFirst.Text,
ShippingPhone = this.textBoxShippingPhone.Text,
ShippingLastName = this.textBoxShippingLast.Text,
ShippingAddress1 = this.textBoxShippingAddress1.Text,
ShippingAddress2 = this.textBoxShippingAddress2.Text,
ShippingAddress3 = this.textBoxShippingAddress3.Text,
ShippingCity = this.textBoxShippingCity.Text,
ShippingZipCode = this.textBoxShippingPostalCode.Text,
CreditCardType = this.comboBoxCardType.SelectedItem.ToString(),
CreditCardNumber = this.textBoxCardNumber.Text,
CreditCardExpiryMonth = this.comboBoxExpirationMonth.SelectedItem.ToString(),
CreditCardExpiryYear = this.comboBoxExpirationYear.SelectedItem.ToString(),
CreditCardCvv = this.textBoxCvv.Text,
MaxCheckouts = this.textBoxMaxCheckouts.Text.ParseToInt()
};
if (Form1.CreditCardProfiles.Any((CreditCardProfile c) => c.Name == this.textBoxProfileName.Text))
{
int index = Form1.CreditCardProfiles.IndexOf(Form1.CreditCardProfiles.First((CreditCardProfile c) => c.Name == this.textBoxProfileName.Text));
Form1.CreditCardProfiles[index] = creditCardProfile;
}
else
{
Form1.CreditCardProfiles.Add(creditCardProfile);
}
Form1.DefaultForm.SaveSettings();
base.DialogResult = DialogResult.OK;
}
catch (Exception ex)
{
ex.Message.Show(MessageBoxIcon.Hand, "", MessageBoxButtons.OK);
}
}
}
}