Skip to content

Commit f9ef897

Browse files
oschwaldclaude
andcommitted
Update PHP examples to use named parameters style
Change minFraud PHP code samples to use PHP 8.1+ named parameters (e.g., `->withDevice(ipAddress: '...')`) instead of array syntax (e.g., `->withDevice(['ip_address' => '...'])`). This matches the style used in the official minfraud-api-php README. Also update the composer version requirement from ~1.0 to ~3.0. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 715b67e commit f9ef897

File tree

2 files changed

+118
-119
lines changed

2 files changed

+118
-119
lines changed

content/minfraud/evaluate-a-transaction.md

Lines changed: 108 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ yarn add @maxmind/minfraud-api-node
8888

8989
```php
9090
# Install via Composer
91-
composer require maxmind/minfraud:~1.0
91+
composer require maxmind/minfraud:~3.0
9292
```
9393

9494
```python
@@ -301,38 +301,38 @@ try {
301301
```
302302

303303
```php
304-
$request = $client->withDevice([
305-
'ip_address' => '1.1.1.1',
306-
])->withBilling([
307-
'first_name' => 'First',
308-
'last_name' => 'Last',
309-
'company' => 'Company',
310-
'address' => '1 Billing Address St.',
311-
'address_2' => 'Unit 1',
312-
'city' => 'Waltham',
313-
'region' => 'MA',
314-
'country' => 'US',
315-
'postal' => '02451',
316-
'phone_number' => '555-555-5555',
317-
'phone_country_code' => '1',
318-
])->withCreditCard([
319-
'issuer_id_number' => '411111',
320-
])->withEmail([
321-
'address' => '[email protected]',
322-
'domain' => 'maxmind.com',
323-
])->withShipping([
324-
'first_name' => 'First',
325-
'last_name' => 'Last',
326-
'company' => 'Company',
327-
'address' => '1 Shipping Address St.',
328-
'address_2' => 'Unit 1',
329-
'city' => 'Waltham',
330-
'region' => 'MA',
331-
'country' => 'US',
332-
'postal' => '02451',
333-
'phone_number' => '555-555-5555',
334-
'phone_country_code' => '1',
335-
]);
304+
$request = $client->withDevice(
305+
ipAddress: '1.1.1.1'
306+
)->withBilling(
307+
firstName: 'First',
308+
lastName: 'Last',
309+
company: 'Company',
310+
address: '1 Billing Address St.',
311+
address2: 'Unit 1',
312+
city: 'Waltham',
313+
region: 'MA',
314+
country: 'US',
315+
postal: '02451',
316+
phoneNumber: '555-555-5555',
317+
phoneCountryCode: '1'
318+
)->withCreditCard(
319+
issuerIdNumber: '411111'
320+
)->withEmail(
321+
address: '[email protected]',
322+
domain: 'maxmind.com'
323+
)->withShipping(
324+
firstName: 'First',
325+
lastName: 'Last',
326+
company: 'Company',
327+
address: '1 Shipping Address St.',
328+
address2: 'Unit 1',
329+
city: 'Waltham',
330+
region: 'MA',
331+
country: 'US',
332+
postal: '02451',
333+
phoneNumber: '555-555-5555',
334+
phoneCountryCode: '1'
335+
);
336336
```
337337

338338
```python
@@ -896,81 +896,80 @@ $mf = new MinFraud(1, 'ABCD567890');
896896
# Note that each ->with*() call returns a new immutable object. This means
897897
# that if you separate the calls into separate statements without chaining,
898898
# you should assign the return value to a variable each time.
899-
$request = $mf->withDevice([
900-
'ip_address' => '1.1.1.1',
901-
'session_age' => 3600.5,
902-
'session_id' => 'foobar',
903-
'user_agent' =>
904-
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.89 Safari/537.36',
905-
'accept_language' => 'en-US,en;q=0.8',
906-
])->withEvent([
907-
'transaction_id' => 'txn3134133',
908-
'shop_id' => 's2123',
909-
'time' => '2012-04-12T23:20:50+00:00',
910-
'type' => 'purchase',
911-
])->withAccount([
912-
'user_id' => 3132,
913-
'username_md5' => '4f9726678c438914fa04bdb8c1a24088',
914-
])->withEmail([
915-
'address' => '[email protected]',
916-
'domain' => 'maxmind.com',
917-
])->withBilling([
918-
'first_name' => 'First',
919-
'last_name' => 'Last',
920-
'company' => 'Company',
921-
'address' => '1 Billing Address St.',
922-
'address_2' => 'Unit 1',
923-
'city' => 'Waltham',
924-
'region' => 'MA',
925-
'country' => 'US',
926-
'postal' => '02451',
927-
'phone_number' => '555-555-5555',
928-
'phone_country_code' => '1',
929-
])->withShipping([
930-
'first_name' => 'First',
931-
'last_name' => 'Last',
932-
'company' => 'Company',
933-
'address' => '1 Shipping Address St.',
934-
'address_2' => 'Unit 1',
935-
'city' => 'Waltham',
936-
'region' => 'MA',
937-
'country' => 'US',
938-
'postal' => '02451',
939-
'phone_number' => '555-555-5555',
940-
'phone_country_code' => '1',
941-
'delivery_speed' => 'same_day',
942-
])->withPayment([
943-
'processor' => 'stripe',
944-
'was_authorized' => false,
945-
'decline_code' => 'invalid number',
946-
])->withCreditCard([
947-
'issuer_id_number' => '411111',
948-
'last_digits' => '1234',
949-
'bank_name' => 'Test Bank',
950-
'bank_phone_country_code' => '1',
951-
'bank_phone_number' => '555-555-5555',
952-
'avs_result' => 'Y',
953-
'cvv_result' => 'N',
954-
])->withOrder([
955-
'amount' => 323.21,
956-
'currency' => 'USD',
957-
'discount_code' => 'FIRST',
958-
'is_gift' => true,
959-
'has_gift_message' => false,
960-
'affiliate_id' => 'af12',
961-
'subaffiliate_id' => 'saf42',
962-
'referrer_uri' => 'http://www.amazon.com/',
963-
])->withShoppingCartItem([
964-
'category' => 'pets',
965-
'item_id' => 'leash-0231',
966-
'quantity' => 2,
967-
'price' => 20.43,
968-
])->withShoppingCartItem([
969-
'category' => 'beauty',
970-
'item_id' => 'msc-1232',
971-
'quantity' => 1,
972-
'price' => 100.00,
973-
])->withCustomInputs([
899+
$request = $mf->withDevice(
900+
ipAddress: '1.1.1.1',
901+
sessionAge: 3600.5,
902+
sessionId: 'foobar',
903+
userAgent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.89 Safari/537.36',
904+
acceptLanguage: 'en-US,en;q=0.8'
905+
)->withEvent(
906+
transactionId: 'txn3134133',
907+
shopId: 's2123',
908+
time: '2012-04-12T23:20:50+00:00',
909+
type: 'purchase'
910+
)->withAccount(
911+
userId: 3132,
912+
usernameMd5: '4f9726678c438914fa04bdb8c1a24088'
913+
)->withEmail(
914+
address: '[email protected]',
915+
domain: 'maxmind.com'
916+
)->withBilling(
917+
firstName: 'First',
918+
lastName: 'Last',
919+
company: 'Company',
920+
address: '1 Billing Address St.',
921+
address2: 'Unit 1',
922+
city: 'Waltham',
923+
region: 'MA',
924+
country: 'US',
925+
postal: '02451',
926+
phoneNumber: '555-555-5555',
927+
phoneCountryCode: '1'
928+
)->withShipping(
929+
firstName: 'First',
930+
lastName: 'Last',
931+
company: 'Company',
932+
address: '1 Shipping Address St.',
933+
address2: 'Unit 1',
934+
city: 'Waltham',
935+
region: 'MA',
936+
country: 'US',
937+
postal: '02451',
938+
phoneNumber: '555-555-5555',
939+
phoneCountryCode: '1',
940+
deliverySpeed: 'same_day'
941+
)->withPayment(
942+
processor: 'stripe',
943+
wasAuthorized: false,
944+
declineCode: 'invalid number'
945+
)->withCreditCard(
946+
issuerIdNumber: '411111',
947+
lastDigits: '1234',
948+
bankName: 'Test Bank',
949+
bankPhoneCountryCode: '1',
950+
bankPhoneNumber: '555-555-5555',
951+
avsResult: 'Y',
952+
cvvResult: 'N'
953+
)->withOrder(
954+
amount: 323.21,
955+
currency: 'USD',
956+
discountCode: 'FIRST',
957+
isGift: true,
958+
hasGiftMessage: false,
959+
affiliateId: 'af12',
960+
subaffiliateId: 'saf42',
961+
referrerUri: 'http://www.amazon.com/'
962+
)->withShoppingCartItem(
963+
category: 'pets',
964+
itemId: 'leash-0231',
965+
quantity: 2,
966+
price: 20.43
967+
)->withShoppingCartItem(
968+
category: 'beauty',
969+
itemId: 'msc-1232',
970+
quantity: 1,
971+
price: 100.00
972+
)->withCustomInputs([
974973
'section' => 'news',
975974
'previous_purchases' => 19,
976975
'discount' => 3.2,
@@ -980,7 +979,7 @@ $request = $mf->withDevice([
980979
# To get the minFraud Factors response model, use ->factors():
981980
$factorsResponse = $request->factors();
982981

983-
print($factorsResponse->subscores->email . "\n");
982+
print($factorsResponse->subscores->emailAddress . "\n");
984983

985984
# To get the minFraud Insights response model, use ->insights():
986985
$insightsResponse = $request->insights();

content/minfraud/report-a-transaction.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ yarn add @maxmind/minfraud-api-node
6262

6363
```php
6464
# Install via Composer
65-
composer require maxmind/minfraud:~1.0
65+
composer require maxmind/minfraud:~3.0
6666
```
6767

6868
```python
@@ -165,16 +165,16 @@ use MaxMind\MinFraud\ReportTransaction;
165165

166166
$rt = new ReportTransaction(10, 'LICENSEKEY');
167167

168-
$rt->report([
169-
'ip_address' => '1.1.1.1',
170-
'tag' => 'chargeback',
168+
$rt->report(
169+
ipAddress: '1.1.1.1',
170+
tag: 'chargeback',
171171
// The following key/values are not mandatory but are encouraged
172-
'maxmind_id' => 'abcd1234',
173-
'minfraud_id' => '01c25cb0-f067-4e02-8ed0-a094c580f5e4',
174-
'transaction_id' => 'txn123',
175-
'chargeback_code' => 'BL',
176-
'notes' => 'Suspicious account behavior',
177-
]);
172+
maxmindId: 'abcd1234',
173+
minfraudId: '01c25cb0-f067-4e02-8ed0-a094c580f5e4',
174+
transactionId: 'txn123',
175+
chargebackCode: 'BL',
176+
notes: 'Suspicious account behavior'
177+
);
178178
```
179179

180180
```python

0 commit comments

Comments
 (0)