Skip to content

Commit 715b67e

Browse files
oschwaldclaude
andcommitted
Update C# examples to use object initializer syntax
Change minFraud C# code samples to use object initializer syntax (e.g., `new Transaction { Device = ... }`) instead of constructor syntax with named parameters. This matches the style used in the official minfraud-api-dotnet README and is more idiomatic modern C#. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 47fdeec commit 715b67e

File tree

2 files changed

+153
-143
lines changed

2 files changed

+153
-143
lines changed

content/minfraud/evaluate-a-transaction.md

Lines changed: 143 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -163,46 +163,50 @@ submit:
163163
{{< codeset >}}
164164

165165
```csharp
166-
var transaction = new Transaction(
167-
device: new Device(System.Net.IPAddress.Parse("1.1.1.1")),
168-
email:
169-
new Email(
170-
address: "[email protected]",
171-
domain: "maxmind.com"
172-
),
173-
billing:
174-
new Billing(
175-
address: "1 Billing Address St.",
176-
firstName: "First",
177-
lastName: "Last",
178-
company: "Company, Inc.",
179-
address2: "Unit 1",
180-
city: "Waltham",
181-
region: "MA",
182-
country: "US",
183-
postal: "02451",
184-
phoneNumber: "555-555-5555",
185-
phoneCountryCode: "1"
186-
),
187-
creditCard:
188-
new CreditCard(
189-
issuerIdNumber: "411111",
190-
),
191-
shipping:
192-
new Shipping(
193-
firstName: "First",
194-
lastName: "Last",
195-
company: "Company Inc.",
196-
address: "1 Shipping Address St.",
197-
address2: "Unit 1",
198-
city: "Waltham",
199-
region: "MA",
200-
country: "US",
201-
postal: "02451",
202-
phoneNumber: "555-555-5555",
203-
phoneCountryCode: "1",
204-
)
205-
);
166+
var transaction = new Transaction
167+
{
168+
Device = new Device
169+
{
170+
IPAddress = System.Net.IPAddress.Parse("1.1.1.1")
171+
},
172+
Email = new Email
173+
{
174+
Address = "[email protected]",
175+
Domain = "maxmind.com"
176+
},
177+
Billing = new Billing
178+
{
179+
FirstName = "First",
180+
LastName = "Last",
181+
Company = "Company, Inc.",
182+
Address = "1 Billing Address St.",
183+
Address2 = "Unit 1",
184+
City = "Waltham",
185+
Region = "MA",
186+
Country = "US",
187+
Postal = "02451",
188+
PhoneNumber = "555-555-5555",
189+
PhoneCountryCode = "1"
190+
},
191+
CreditCard = new CreditCard
192+
{
193+
IssuerIdNumber = "411111"
194+
},
195+
Shipping = new Shipping
196+
{
197+
FirstName = "First",
198+
LastName = "Last",
199+
Company = "Company Inc.",
200+
Address = "1 Shipping Address St.",
201+
Address2 = "Unit 1",
202+
City = "Waltham",
203+
Region = "MA",
204+
Country = "US",
205+
Postal = "02451",
206+
PhoneNumber = "555-555-5555",
207+
PhoneCountryCode = "1"
208+
}
209+
};
206210
```
207211

208212
```java
@@ -523,6 +527,7 @@ using MaxMind.MinFraud;
523527
using MaxMind.MinFraud.Request;
524528
using System;
525529
using System.Collections.Generic;
530+
using System.Net;
526531
using System.Threading.Tasks;
527532

528533
public class MinFraudExample
@@ -534,109 +539,112 @@ public class MinFraudExample
534539

535540
static public async Task MinFraudAsync()
536541
{
537-
var transaction = new Transaction(
538-
device: new Device(System.Net.IPAddress.Parse("1.1.1.1"),
539-
userAgent:
540-
"Mozilla/5.0 (X11; Linux x86_64)",
541-
acceptLanguage: "en-US,en;q=0.8",
542-
sessionAge: 3600,
543-
sessionId: "a333a4e127f880d8820e56a66f40717c"
544-
),
545-
userEvent:
546-
new Event
547-
(
548-
transactionId: "txn3134133",
549-
shopId: "s2123",
550-
time: new DateTimeOffset(2014, 4, 12, 23, 20, 50, 52, new TimeSpan(0)),
551-
type: EventType.Purchase
552-
),
553-
account:
554-
new Account(
555-
userId: "3132",
556-
username: "fred"
557-
),
558-
email:
559-
new Email(
560-
address: "[email protected]",
561-
domain: "maxmind.com"
562-
),
563-
billing:
564-
new Billing(
565-
address: "1 Billing Address St.",
566-
firstName: "First",
567-
lastName: "Last",
568-
company: "Company, Inc.",
569-
address2: "Unit 1",
570-
city: "Waltham",
571-
region: "MA",
572-
country: "US",
573-
postal: "02451",
574-
phoneNumber: "555-555-5555",
575-
phoneCountryCode: "1"
576-
),
577-
shipping:
578-
new Shipping(
579-
firstName: "First",
580-
lastName: "Last",
581-
company: "Company Inc.",
582-
address: "1 Shipping Address St.",
583-
address2: "Unit 1",
584-
city: "Waltham",
585-
region: "MA",
586-
country: "US",
587-
postal: "02451",
588-
phoneNumber: "555-555-5555",
589-
phoneCountryCode: "1",
590-
deliverySpeed: ShippingDeliverySpeed.SameDay
591-
),
592-
payment:
593-
new Payment(
594-
processor: PaymentProcessor.Stripe,
595-
wasAuthorized: false,
596-
declineCode: "invalid number"
597-
),
598-
creditCard:
599-
new CreditCard(
600-
issuerIdNumber: "411111",
601-
bankName: "Test Bank",
602-
bankPhoneCountryCode: "1",
603-
bankPhoneNumber: "555-555-5555",
604-
avsResult: 'Y',
605-
cvvResult: 'N',
606-
last4Digits: "1234"
607-
),
608-
order:
609-
new Order(
610-
amount: 323.21m,
611-
currency: "USD",
612-
discountCode: "FIRST",
613-
affiliateId: "af12",
614-
subaffiliateId: "saf42",
615-
referrerUri: new Uri("http://www.amazon.com/")
616-
),
617-
shoppingCart: new List<ShoppingCartItem>
542+
var transaction = new Transaction
543+
{
544+
Device = new Device
545+
{
546+
IPAddress = IPAddress.Parse("1.1.1.1"),
547+
UserAgent = "Mozilla/5.0 (X11; Linux x86_64)",
548+
AcceptLanguage = "en-US,en;q=0.8",
549+
SessionAge = 3600,
550+
SessionId = "a333a4e127f880d8820e56a66f40717c"
551+
},
552+
Event = new Event
553+
{
554+
TransactionId = "txn3134133",
555+
ShopId = "s2123",
556+
Time = new DateTimeOffset(2014, 4, 12, 23, 20, 50, 52, new TimeSpan(0)),
557+
Type = EventType.Purchase
558+
},
559+
Account = new Account
560+
{
561+
UserId = "3132",
562+
Username = "fred"
563+
},
564+
Email = new Email
565+
{
566+
Address = "[email protected]",
567+
Domain = "maxmind.com"
568+
},
569+
Billing = new Billing
570+
{
571+
FirstName = "First",
572+
LastName = "Last",
573+
Company = "Company, Inc.",
574+
Address = "1 Billing Address St.",
575+
Address2 = "Unit 1",
576+
City = "Waltham",
577+
Region = "MA",
578+
Country = "US",
579+
Postal = "02451",
580+
PhoneNumber = "555-555-5555",
581+
PhoneCountryCode = "1"
582+
},
583+
Shipping = new Shipping
584+
{
585+
FirstName = "First",
586+
LastName = "Last",
587+
Company = "Company Inc.",
588+
Address = "1 Shipping Address St.",
589+
Address2 = "Unit 1",
590+
City = "Waltham",
591+
Region = "MA",
592+
Country = "US",
593+
Postal = "02451",
594+
PhoneNumber = "555-555-5555",
595+
PhoneCountryCode = "1",
596+
DeliverySpeed = ShippingDeliverySpeed.SameDay
597+
},
598+
Payment = new Payment
599+
{
600+
Processor = PaymentProcessor.Stripe,
601+
WasAuthorized = false,
602+
DeclineCode = "invalid number"
603+
},
604+
CreditCard = new CreditCard
605+
{
606+
IssuerIdNumber = "411111",
607+
BankName = "Test Bank",
608+
BankPhoneCountryCode = "1",
609+
BankPhoneNumber = "555-555-5555",
610+
AvsResult = 'Y',
611+
CvvResult = 'N',
612+
Last4Digits = "1234"
613+
},
614+
Order = new Order
615+
{
616+
Amount = 323.21m,
617+
Currency = "USD",
618+
DiscountCode = "FIRST",
619+
AffiliateId = "af12",
620+
SubaffiliateId = "saf42",
621+
ReferrerUri = new Uri("http://www.amazon.com/")
622+
},
623+
ShoppingCart = new List<ShoppingCartItem>
618624
{
619-
new ShoppingCartItem(
620-
category: "pets",
621-
itemId: "ad23232",
622-
quantity: 2,
623-
price: 20.43m
624-
),
625-
new ShoppingCartItem(
626-
category: "beauty",
627-
itemId: "bst112",
628-
quantity: 1,
629-
price: 100.00m
630-
)
625+
new ShoppingCartItem
626+
{
627+
Category = "pets",
628+
ItemId = "ad23232",
629+
Quantity = 2,
630+
Price = 20.43m
631+
},
632+
new ShoppingCartItem
633+
{
634+
Category = "beauty",
635+
ItemId = "bst112",
636+
Quantity = 1,
637+
Price = 100.00m
638+
}
631639
},
632-
customInputs: new CustomInputs.Builder
640+
CustomInputs = new CustomInputs.Builder
633641
{
634642
{ "float_input", 12.1d},
635643
{ "integer_input", 3123},
636644
{ "string_input", "This is a string input."},
637645
{ "boolean_input", true},
638646
}.Build()
639-
);
647+
};
640648

641649
// If you are making multiple requests, a single WebServiceClient
642650
// should be shared across requests to allow connection reuse. The

content/minfraud/report-a-transaction.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,18 @@ help us understand context are extremely helpful.
108108
```csharp
109109
var client = new WebServiceClient(10, "LICENSEKEY");
110110

111-
var report = new TransactionReport(
112-
ipAddress: IPAddress.Parse("1.1.1.1"),
113-
tag: TransactionReportTag.Chargeback,
111+
var report = new TransactionReport
112+
{
113+
IPAddress = IPAddress.Parse("1.1.1.1"),
114+
Tag = TransactionReportTag.Chargeback,
114115

115116
// The following key/values are not mandatory but are encouraged
116-
maxmindId: "abcd1234",
117-
minfraudId: new Guid("01c25cb0-f067-4e02-8ed0-a094c580f5e4"),
118-
transactionId: "txn123",
119-
chargebackCode: "BL",
120-
notes: "Suspicious account behavior");
117+
MaxMindId = "abcd1234",
118+
MinFraudId = new Guid("01c25cb0-f067-4e02-8ed0-a094c580f5e4"),
119+
TransactionId = "txn123",
120+
ChargebackCode = "BL",
121+
Notes = "Suspicious account behavior"
122+
};
121123

122124
await client.ReportAsync(report);
123125
```

0 commit comments

Comments
 (0)