· 6 years ago · Jun 14, 2019, 04:19 AM
1{
2 "PaymentObject": {
3 "Id": 0,
4 "IdCarnet": 0,
5 "IdTransaction": 0,
6 "SeedNumber": 706428,
7 "DigitableLine": "",
8 "Barcode": "",
9 "File": null,
10 "AmountPayment": 0.0,
11 "DueDate": "2019-06-10T16:11:59.337",
12 "Instruction": "",
13 "Message": [
14 "Test 1",
15 "Test 2",
16 "Test 3"
17 ],
18 "PenaltyRate": 0.0,
19 "InterestRate": 0.0,
20 "BankSplipUrl": null,
21 "CancelAfterDue": false,
22 "IsEnablePartialPayment": false,
23 "DaysBeforeCancel": 0
24 },
25 "Id": 449449,
26 "PaymentMethod": {
27 "Id": 1,
28 "Code": "1",
29 "Name": "Boleto"
30 },
31 "TransactionStatus": {
32 "Id": 1,
33 "Code": "1",
34 "Name": "Pendente"
35 },
36 "Gateway": {
37 "Id": 7,
38 "Code": "7",
39 "Name": "Sicredi",
40 "ReleaseDays": 0
41 },
42 "Merchant": {
43 "Id": 15,
44 "IdMerchantRoot": 0,
45 "MerchantType": null,
46 "Name": null,
47 "CommercialName": null,
48 "Identity": null,
49 "ResponsibleName": null,
50 "ResponsibleIdentity": null,
51 "Email": null,
52 "TechName": null,
53 "TechIdentity": null,
54 "TechEmail": null,
55 "Token": null,
56 "SecretKey": null,
57 "TokenSandbox": null,
58 "SecretKeySandbox": null,
59 "BankData": null,
60 "Address": null,
61 "Configuration": null,
62 "MerchantSplit": null,
63 "IsRemoved": false
64 },
65 "TaxType": {
66 "Id": 2,
67 "Code": "2",
68 "Name": "Valor"
69 },
70 "Customer": {
71 "Id": ,
72 "Merchant": null,
73 "Name": "",
74 "Identity": "",
75 "Phone": "",
76 "Email": "",
77 "Address": {
78 "Id": 475929,
79 "Street": "",
80 "Number": "",
81 "District": "",
82 "ZipCode": "",
83 "Complement": "",
84 "CityName": null,
85 "StateInitials": null,
86 "CountryName": null,
87 "City": {
88 "Id": 0,
89 "IdState": 0,
90 "CodeIBGE": null,
91 "Name": "Porto Alegre"
92 },
93 "State": {
94 "Id": 0,
95 "IdCountry": 0,
96 "Initials": "RS",
97 "Name": null
98 },
99 "Country": null
100 }
101 },
102 "Amount": 19.94,
103 "TaxValue": 0.0,
104 "Currency": null,
105 "Application": "Test",
106 "Reference": "",
107 "NegotiationTax": 1.6,
108 "AcquirerTax": 0.0,
109 "DiscountAmount": 0.0,
110 "Vendor": "Felipe",
111 "CallbackUrl": "",
112 "IsExcluded": false,
113 "PaymentDate": "0001-01-01T00:00:00",
114 "CreatedDate": "2019-06-10T13:12:05.793",
115 "Splits": null,
116 "NetValue": 0.0,
117 "IsSandbox": false,
118 "Products": [
119 {
120 "IdTransaction": 0,
121 "Id": 455265,
122 "Code": "001",
123 "Description": "Teste 1",
124 "Quantity": 1.0,
125 "UnitPrice": 1.99
126 },
127 {
128 "IdTransaction": 0,
129 "Id": 455267,
130 "Code": "003",
131 "Description": "Teste 3",
132 "Quantity": 3.0,
133 "UnitPrice": 3.99
134 }
135 ],
136 "IdSubscription": 0,
137 "PaymentInfo": null,
138 "CardBrand": null,
139 "ApiVersion": 2
140}
141
142public string Post(string url, object data) =>
143 _client.PostAsJsonAsync(url, data).Result.Content.ReadAsStringAsync().Result;
144
145public static object Credit(object data)
146{
147 var response = _client.Post("Payment", data);
148
149 var responseContent = JsonConvert.DeserializeObject<Response>(response);
150 if (responseContent.HasError) throw new Exception(responseContent.Error);
151
152 var result = JObject.Parse(response);
153 var idTransaction = result["ResponseDetail"].Value<string>();
154 return idTransaction;
155}
156
157public void Credit()
158{
159 var transaction = new Transaction<Credit>
160 {
161 PaymentMethod = new PaymentMethod {Code = "1"},
162 Application = "Tests",
163 Vendor = "Felipe",
164 Customer = new Customer
165 {
166 //Customer data goes here...
167 },
168 Products = new List<TransactionProduct>
169 {
170 //Product data goes here...
171 }
172 };
173
174 var test = Payment.Credit(transaction);
175 Console.WriteLine(test);
176}
177
178var result = query as Transaction<object>;
179Console.WriteLine(result.Id);