-
Notifications
You must be signed in to change notification settings - Fork 1
/
Garantipay.cs
566 lines (565 loc) · 27.6 KB
/
Garantipay.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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
using System.Reflection;
using System.Security.Cryptography;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Xml;
using System.Xml.Serialization;
namespace Garantipay {
public enum MODE {
Test,
Prod
}
public class Garantipay {
public string Mode { get; set; }
public string Endpoint { get; set; }
private string TerminalId { get; set; }
private string MerchantId { get; set; }
private string Username { get; set; }
private string Password { get; set; }
private string StoreKey { get; set; }
public void SetTerminalId(string terminalid) {
TerminalId = terminalid;
}
public void SetMerchantId(string merchantid) {
MerchantId = merchantid;
}
public void SetUsername(string username) {
Username = username;
}
public void SetPassword(string password) {
Password = password;
}
public void SetStoreKey(string storekey) {
StoreKey = storekey;
}
public Garantipay(MODE mode) {
Mode = mode switch {
MODE.Test => "TEST",
MODE.Prod => "PROD",
_ => null
};
Endpoint = mode switch {
MODE.Test => "https://sanalposprovtest.garanti.com.tr",
MODE.Prod => "https://sanalposprov.garanti.com.tr",
_ => null
};
}
[XmlRoot("GVPSRequest")]
public class GVPSRequest {
[FormElement("mode")]
[XmlElement("Mode", IsNullable = false)]
public string Mode { get; set; }
[FormElement("apiversion")]
[XmlElement("Version", IsNullable = false)]
public string Version { get; set; }
[XmlElement("ChannelCode", IsNullable = false)]
public string ChannelCode { get; set; }
[XmlElement("Terminal", IsNullable = false)]
public Terminal Terminal { get; set; }
[XmlElement("Customer", IsNullable = false)]
public Customer Customer { get; set; }
[XmlElement("Card", IsNullable = false)]
public Card Card { get; set; }
[XmlElement("Order", IsNullable = false)]
public Order Order { get; set; }
[XmlElement("Transaction", IsNullable = false)]
public Transaction Transaction { get; set; }
[FormElement("companyname")]
[XmlIgnore]
public string CompanyName { get; set; }
[FormElement("refreshtime")]
[XmlIgnore]
public string RefreshTime { get; set; }
[FormElement("lang")]
[XmlIgnore]
public string Lang { get; set; }
public GVPSRequest() {
Version = "v1.0";
Terminal = new Terminal();
Customer = new Customer();
Card = new Card();
Order = new Order();
Transaction = new Transaction();
}
}
public class Terminal {
[FormElement("terminalmerchantid")]
[XmlElement("MerchantID", IsNullable = false)]
public string MerchantId { get; set; }
[FormElement("terminalprovuserid")]
[XmlElement("ProvUserID", IsNullable = false)]
public string ProvUserId { get; set; }
[FormElement("terminaluserid")]
[XmlElement("UserID", IsNullable = false)]
public string UserId { get; set; }
[FormElement("terminalid")]
[XmlElement("ID", IsNullable = false)]
public string Id { get; set; }
[FormElement("secure3dhash")]
[XmlElement("HashData", IsNullable = false)]
public string HashData { get; set; }
[FormElement("secure3dsecuritylevel")]
[XmlIgnore]
public string Level { get; set; }
}
public class Card {
[FormElement("cardnumber")]
[XmlElement("Number", IsNullable = false)]
public string Number { get; set; }
[XmlElement("ExpireDate", IsNullable = false)]
public string Expiry { get; set; }
[FormElement("cardexpiredatemonth")]
[XmlIgnore]
public string CardMonth { get; set; }
[FormElement("cardexpiredateyear")]
[XmlIgnore]
public string CardYear { get; set; }
[FormElement("cardcvv2")]
[XmlElement("CVV2", IsNullable = false)]
public string Code { get; set; }
public void SetCardNumber(string cardnumber) {
Number = cardnumber;
}
public void SetCardExpiry(string cardmonth, string cardyear) {
Expiry = cardmonth + cardyear;
CardMonth = cardmonth;
CardYear = cardyear;
}
public void SetCardCode(string cardcode) {
Code = cardcode;
}
}
public class Customer {
[FormElement("customeripaddress")]
[XmlElement("IPAddress", IsNullable = false)]
public string IPv4 { get; set; }
[FormElement("customeremailaddress")]
[XmlElement("EmailAddress", IsNullable = false)]
public string Email { get; set; }
public void SetIPv4(string ipv4) {
IPv4 = ipv4;
}
public void SetEmail(string email) {
Email = email;
}
}
public class Transaction {
[FormElement("txntype")]
[XmlElement("Type", IsNullable = false)]
public string Type { get; set; }
[FormElement("txnsubtype")]
[XmlElement("SubType", IsNullable = false)]
public string SubType { get; set; }
[XmlElement("FirmCardNo", IsNullable = false)]
public string FirmCardNo { get; set; }
[FormElement("txninstallmentcount")]
[XmlElement("InstallmentCnt", IsNullable = false)]
public string Installment { get; set; }
[FormElement("txnamount")]
[XmlElement("Amount", IsNullable = false)]
public string Amount { get; set; }
[FormElement("txncurrencycode")]
[XmlElement("CurrencyCode", IsNullable = false)]
public string Currency { get; set; }
[XmlElement("CardholderPresentCode", IsNullable = false)]
public string CardholderPresentCode { get; set; }
[FormElement("txnmotoind")]
[XmlElement("MotoInd", IsNullable = false)]
public string MotoInd { get; set; }
[XmlElement("AuthCode", IsNullable = false)]
public string AuthCode { get; set; }
[XmlElement("RetrefNum", IsNullable = false)]
public string RetrefNum { get; set; }
[XmlElement("BatchNum", IsNullable = false)]
public string BatchNum { get; set; }
[XmlElement("SequenceNum", IsNullable = false)]
public string SequenceNum { get; set; }
[XmlElement("ProvDate", IsNullable = false)]
public string ProvDate { get; set; }
[XmlElement("CardNumberMasked", IsNullable = false)]
public string CardNumberMasked { get; set; }
[XmlElement("CardHolderName", IsNullable = false)]
public string CardHolderName { get; set; }
[XmlElement("CardType", IsNullable = false)]
public string CardType { get; set; }
[XmlElement("HashData", IsNullable = false)]
public string HashData { get; set; }
[XmlElement("Description", IsNullable = false)]
public string Description { get; set; }
[XmlElement("Secure3D", IsNullable = false)]
public Secure3D Secure3D { get; set; }
[XmlElement("Response", IsNullable = false)]
public Response Response { get; set; }
[FormElement("txntimestamp")]
[XmlIgnore]
public string Timestamp { get; set; }
[FormElement("successurl")]
[XmlIgnore]
public string SuccessUrl { get; set; }
[FormElement("errorurl")]
[XmlIgnore]
public string ErrorUrl { get; set; }
public void SetAmount(string amount, string currency) {
Amount = amount.Replace(".", "");
Currency = currency switch {
"TRY" => "949",
"YTL" => "949",
"TRL" => "949",
"TL" => "949",
"USD" => "840",
"EUR" => "978",
"GBP" => "826",
"JPY" => "392",
_ => currency
};
}
public void SetInstallment(string installment) {
Installment = installment;
}
}
public class Secure3D {
[XmlElement("AuthenticationCode", IsNullable = false)]
public string AuthenticationCode { get; set; }
[XmlElement("SecurityLevel", IsNullable = false)]
public string SecurityLevel { get; set; }
[XmlElement("TxnID", IsNullable = false)]
public string TxnId { get; set; }
[XmlElement("Md", IsNullable = false)]
public string Md { get; set; }
}
public class Order {
[FormElement("orderid")]
[XmlElement("OrderID", IsNullable = false)]
public string OrderId { get; set; }
[FormElement("groupid")]
[XmlElement("GroupID", IsNullable = false)]
public string GroupId { get; set; }
[XmlElement("AddressList", IsNullable = false)]
public AddressList AddressList { get; set; }
public void SetOrderId(string orderid) {
OrderId = orderid;
}
}
public class AddressList {
[XmlElement("Address", IsNullable = false)]
public Address Address { get; set; }
}
public class Address {
[XmlElement("Type", IsNullable = false)]
public string Type { get; set; }
[XmlElement("Name", IsNullable = false)]
public string Name { get; set; }
[XmlElement("LastName", IsNullable = false)]
public string LastName { get; set; }
[FormElement("cardholder")]
[XmlElement("Company", IsNullable = false)]
public string Company { get; set; }
[XmlElement("Text", IsNullable = false)]
public string Text { get; set; }
[XmlElement("Country", IsNullable = false)]
public string Country { get; set; }
[XmlElement("City", IsNullable = false)]
public string City { get; set; }
[XmlElement("District", IsNullable = false)]
public string District { get; set; }
[XmlElement("PostalCode", IsNullable = false)]
public string PostalCode { get; set; }
[FormElement("phone")]
[XmlElement("PhoneNumber", IsNullable = false)]
public string PhoneNumber { get; set; }
[XmlElement("GsmNumber", IsNullable = false)]
public string GsmNumber { get; set; }
[XmlElement("FaxNumber", IsNullable = false)]
public string FaxNumber { get; set; }
}
public class Response {
[XmlElement("Source", IsNullable = false)]
public string Source { get; set; }
[XmlElement("Code", IsNullable = false)]
public string Code { get; set; }
[XmlElement("ReasonCode", IsNullable = false)]
public string ReasonCode { get; set; }
[XmlElement("Message", IsNullable = false)]
public string Message { get; set; }
[XmlElement("ErrorMsg", IsNullable = false)]
public string ErrorMsg { get; set; }
[XmlElement("SysErrMsg", IsNullable = false)]
public string SysErrMsg { get; set; }
}
[XmlRoot("GVPSResponse")]
public class GVPSResponse {
[XmlElement("Terminal", IsNullable = false)]
public Terminal Terminal { init; get; }
[XmlElement("Customer", IsNullable = false)]
public Customer Customer { init; get; }
[XmlElement("Card", IsNullable = false)]
public Card Card { init; get; }
[XmlElement("Order", IsNullable = false)]
public Order Order { init; get; }
[XmlElement("Transaction", IsNullable = false)]
public Transaction Transaction { init; get; }
}
public class FormElementAttribute : Attribute {
public string Key { get; }
public FormElementAttribute(string key) {
Key = key;
}
}
public class Writer : StringWriter {
public override Encoding Encoding => Encoding.UTF8;
}
public static string Json<T>(T data) where T : class {
return JsonSerializer.Serialize(data, new JsonSerializerOptions { DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, WriteIndented = true });
}
public static byte[] Byte(string data) {
return Encoding.UTF8.GetBytes(data);
}
public static string Hex(byte[] data) {
return BitConverter.ToString(data).Replace("-", "").ToUpperInvariant();
}
public static string Hash(string data) {
return Hex(SHA1.Create().ComputeHash(Byte(data)));
}
public GVPSResponse PreAuth(GVPSRequest data) {
data.Mode = Mode;
data.Terminal.Id = TerminalId;
data.Terminal.MerchantId = MerchantId;
data.Terminal.UserId = Username;
data.Terminal.ProvUserId = Username;
data.Transaction.Type = "preauth";
data.Terminal.HashData = Hash(data.Order.OrderId + data.Terminal.Id + data.Card.Number + data.Transaction.Amount + Hash(Password + data.Terminal.Id.PadLeft(9, '0')));
return _Transaction(data);
}
public GVPSResponse PostAuth(GVPSRequest data) {
data.Mode = Mode;
data.Terminal.Id = TerminalId;
data.Terminal.MerchantId = MerchantId;
data.Terminal.UserId = Username;
data.Terminal.ProvUserId = Username;
data.Transaction.Type = "postauth";
data.Terminal.HashData = Hash(data.Order.OrderId + data.Terminal.Id + data.Card.Number + data.Transaction.Amount + Hash(Password + data.Terminal.Id.PadLeft(9, '0')));
return _Transaction(data);
}
public GVPSResponse Auth(GVPSRequest data) {
data.Mode = Mode;
data.Terminal.Id = TerminalId;
data.Terminal.MerchantId = MerchantId;
data.Terminal.UserId = Username;
data.Terminal.ProvUserId = Username;
data.Transaction.Type = "sales";
data.Terminal.HashData = Hash(data.Order.OrderId + data.Terminal.Id + data.Card.Number + data.Transaction.Amount + Hash(Password + data.Terminal.Id.PadLeft(9, '0')));
return _Transaction(data);
}
public GVPSResponse Refund(GVPSRequest data) {
data.Mode = Mode;
data.Terminal.Id = TerminalId;
data.Terminal.MerchantId = MerchantId;
data.Terminal.UserId = Username;
data.Terminal.ProvUserId = Username;
data.Transaction.Type = "refund";
data.Terminal.HashData = Hash(data.Order.OrderId + data.Terminal.Id + data.Card.Number + data.Transaction.Amount + Hash(Password + data.Terminal.Id.PadLeft(9, '0')));
data.Card = null;
return _Transaction(data);
}
public GVPSResponse Cancel(GVPSRequest data) {
data.Mode = Mode;
data.Terminal.Id = TerminalId;
data.Terminal.MerchantId = MerchantId;
data.Terminal.UserId = Username;
data.Terminal.ProvUserId = Username;
data.Transaction.Type = "void";
data.Terminal.HashData = Hash(data.Order.OrderId + data.Terminal.Id + data.Card.Number + data.Transaction.Amount + Hash(Password + data.Terminal.Id.PadLeft(9, '0')));
data.Card = null;
return _Transaction(data);
}
public GVPSResponse PreAuth3d(GVPSRequest data) {
data.Mode = Mode;
data.Terminal.Id = TerminalId;
data.Terminal.MerchantId = MerchantId;
data.Terminal.UserId = Username;
data.Terminal.ProvUserId = Username;
data.Transaction.Type = "preauth";
data.Terminal.HashData = Hash(data.Order.OrderId + data.Terminal.Id + data.Card.Number + data.Transaction.Amount + Hash(Password + data.Terminal.Id.PadLeft(9, '0')));
return _Transaction(data);
}
public GVPSResponse Auth3d(GVPSRequest data) {
data.Mode = Mode;
data.Terminal.Id = TerminalId;
data.Terminal.MerchantId = MerchantId;
data.Terminal.UserId = Username;
data.Terminal.ProvUserId = Username;
data.Transaction.Type = "sales";
data.Terminal.HashData = Hash(data.Order.OrderId + data.Terminal.Id + data.Card.Number + data.Transaction.Amount + Hash(Password + data.Terminal.Id.PadLeft(9, '0')));
return _Transaction(data);
}
public Dictionary<string, string> PreAuth3dForm(GVPSRequest data) {
data.RefreshTime = "0";
data.Mode = Mode;
data.Terminal.Id = TerminalId;
data.Terminal.MerchantId = MerchantId;
data.Terminal.UserId = Username;
data.Terminal.ProvUserId = Username;
data.Terminal.Level = "3D";
data.Transaction.Type = "preauth";
data.Transaction.MotoInd = "N";
data.Transaction.Timestamp = DateTimeOffset.Now.ToUnixTimeSeconds().ToString();
data.Terminal.HashData = Hash(data.Terminal.Id + data.Order.OrderId + data.Transaction.Amount + data.Transaction.SuccessUrl + data.Transaction.ErrorUrl + data.Transaction.Type + data.Transaction.Installment + Hex(Byte(StoreKey)).ToLowerInvariant() + Hash(Password + data.Terminal.Id.PadLeft(9, '0')));
var form = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
var elements = data.GetType().GetProperties().Where(x => x.GetCustomAttribute<FormElementAttribute>() != null);
foreach (var element in elements) {
var key = element.GetCustomAttribute<FormElementAttribute>().Key;
var value = element.GetValue(data)?.ToString();
if (!string.IsNullOrEmpty(value)) {
form.Add(key, value);
}
}
if (data.Terminal != null) {
var terminal_elements = data.Terminal.GetType().GetProperties().Where(x => x.GetCustomAttribute<FormElementAttribute>() != null);
foreach (var element in terminal_elements) {
var key = element.GetCustomAttribute<FormElementAttribute>().Key;
var value = element.GetValue(data.Terminal)?.ToString();
if (!string.IsNullOrEmpty(value)) {
form.Add(key, value);
}
}
}
if (data.Order != null) {
var order_elements = data.Order.GetType().GetProperties().Where(x => x.GetCustomAttribute<FormElementAttribute>() != null);
foreach (var element in order_elements) {
var key = element.GetCustomAttribute<FormElementAttribute>().Key;
var value = element.GetValue(data.Order)?.ToString();
if (!string.IsNullOrEmpty(value)) {
form.Add(key, value);
}
}
}
if (data.Transaction != null) {
var transaction_elements = data.Transaction.GetType().GetProperties().Where(x => x.GetCustomAttribute<FormElementAttribute>() != null);
foreach (var element in transaction_elements) {
var key = element.GetCustomAttribute<FormElementAttribute>().Key;
var value = element.GetValue(data.Transaction)?.ToString();
if (!string.IsNullOrEmpty(value)) {
form.Add(key, value);
}
}
}
if (data.Card != null) {
var card_elements = data.Card.GetType().GetProperties().Where(x => x.GetCustomAttribute<FormElementAttribute>() != null);
foreach (var element in card_elements) {
var key = element.GetCustomAttribute<FormElementAttribute>().Key;
var value = element.GetValue(data.Card)?.ToString();
if (!string.IsNullOrEmpty(value)) {
form.Add(key, value);
}
}
}
if (data.Customer != null) {
var customer_elements = data.Customer.GetType().GetProperties().Where(x => x.GetCustomAttribute<FormElementAttribute>() != null);
foreach (var element in customer_elements) {
var key = element.GetCustomAttribute<FormElementAttribute>().Key;
var value = element.GetValue(data.Customer)?.ToString();
if (!string.IsNullOrEmpty(value)) {
form.Add(key, value);
}
}
}
return form.OrderBy(key => key.Key, StringComparer.InvariantCultureIgnoreCase).ToDictionary(x => x.Key, x => x.Value);
}
public Dictionary<string, string> Auth3dForm(GVPSRequest data) {
data.RefreshTime = "0";
data.Mode = Mode;
data.Terminal.Id = TerminalId;
data.Terminal.MerchantId = MerchantId;
data.Terminal.UserId = Username;
data.Terminal.ProvUserId = Username;
data.Terminal.Level = "3D";
data.Transaction.Type = "sales";
data.Transaction.MotoInd = "N";
data.Transaction.Timestamp = DateTimeOffset.Now.ToUnixTimeSeconds().ToString();
data.Terminal.HashData = Hash(data.Terminal.Id + data.Order.OrderId + data.Transaction.Amount + data.Transaction.SuccessUrl + data.Transaction.ErrorUrl + data.Transaction.Type + data.Transaction.Installment + Hex(Byte(StoreKey)).ToLowerInvariant() + Hash(Password + data.Terminal.Id.PadLeft(9, '0')));
var form = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
var elements = data.GetType().GetProperties().Where(x => x.GetCustomAttribute<FormElementAttribute>() != null);
foreach (var element in elements) {
var key = element.GetCustomAttribute<FormElementAttribute>().Key;
var value = element.GetValue(data)?.ToString();
if (!string.IsNullOrEmpty(value)) {
form.Add(key, value);
}
}
if (data.Terminal != null) {
var terminal_elements = data.Terminal.GetType().GetProperties().Where(x => x.GetCustomAttribute<FormElementAttribute>() != null);
foreach (var element in terminal_elements) {
var key = element.GetCustomAttribute<FormElementAttribute>().Key;
var value = element.GetValue(data.Terminal)?.ToString();
if (!string.IsNullOrEmpty(value)) {
form.Add(key, value);
}
}
}
if (data.Order != null) {
var order_elements = data.Order.GetType().GetProperties().Where(x => x.GetCustomAttribute<FormElementAttribute>() != null);
foreach (var element in order_elements) {
var key = element.GetCustomAttribute<FormElementAttribute>().Key;
var value = element.GetValue(data.Order)?.ToString();
if (!string.IsNullOrEmpty(value)) {
form.Add(key, value);
}
}
}
if (data.Transaction != null) {
var transaction_elements = data.Transaction.GetType().GetProperties().Where(x => x.GetCustomAttribute<FormElementAttribute>() != null);
foreach (var element in transaction_elements) {
var key = element.GetCustomAttribute<FormElementAttribute>().Key;
var value = element.GetValue(data.Transaction)?.ToString();
if (!string.IsNullOrEmpty(value)) {
form.Add(key, value);
}
}
}
if (data.Card != null) {
var card_elements = data.Card.GetType().GetProperties().Where(x => x.GetCustomAttribute<FormElementAttribute>() != null);
foreach (var element in card_elements) {
var key = element.GetCustomAttribute<FormElementAttribute>().Key;
var value = element.GetValue(data.Card)?.ToString();
if (!string.IsNullOrEmpty(value)) {
form.Add(key, value);
}
}
}
if (data.Customer != null) {
var customer_elements = data.Customer.GetType().GetProperties().Where(x => x.GetCustomAttribute<FormElementAttribute>() != null);
foreach (var element in customer_elements) {
var key = element.GetCustomAttribute<FormElementAttribute>().Key;
var value = element.GetValue(data.Customer)?.ToString();
if (!string.IsNullOrEmpty(value)) {
form.Add(key, value);
}
}
}
return form.OrderBy(key => key.Key, StringComparer.InvariantCultureIgnoreCase).ToDictionary(x => x.Key, x => x.Value);
}
private GVPSResponse _Transaction(GVPSRequest data) {
var gvpsrequest = new XmlSerializer(typeof(GVPSRequest));
var gvpsresponse = new XmlSerializer(typeof(GVPSResponse));
using var writer = new Writer();
var ns = new XmlSerializerNamespaces();
ns.Add(string.Empty, string.Empty);
gvpsrequest.Serialize(writer, data, ns);
try {
using var http = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Post, Endpoint + "/VPServlet") { Content = new StringContent(writer.ToString(), Encoding.UTF8, "text/xml") };
using var response = http.Send(request);
var result = (GVPSResponse)gvpsresponse.Deserialize(response.Content.ReadAsStream());
return result;
} catch (Exception err) {
if (err.InnerException != null) {
Console.WriteLine(err.InnerException.Message);
} else {
Console.WriteLine(err.Message);
}
}
return null;
}
}
}