Skip to content

Commit e4ea47b

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 a0c9919 commit e4ea47b

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
@@ -297,38 +297,38 @@ try {
297297
```
298298

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

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

979-
print($factorsResponse->subscores->email . "\n");
978+
print($factorsResponse->subscores->emailAddress . "\n");
980979

981980
# To get the minFraud Insights response model, use ->insights():
982981
$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)