Skip to content

Commit

Permalink
Merge pull request #169 from maxmind/greg/no-respect-validation
Browse files Browse the repository at this point in the history
Move off of Respect\Validation
  • Loading branch information
ugexe authored Apr 12, 2024
2 parents 4b8250c + b7c7b85 commit f44064f
Show file tree
Hide file tree
Showing 36 changed files with 1,628 additions and 1,201 deletions.
57 changes: 31 additions & 26 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,47 @@
CHANGELOG
=========

2.1.0
3.0.0
------------------

* This library no longer uses `Respect\Validation`.
* The `with*` methods can now be used with named arguments instead of
an array. This provides better editor completion, type checking,
and documentation.
* Email normalization has been improved:
* Equivalent domain names are now normalized when `hashEmail` is used.
For example, `googlemail.com` will become `gmail.com`.
* Periods are now removed from `gmail.com` email address local parts when
`hashEmail` is used. For example, `[email protected]` will become
`[email protected]`.
* Fastmail alias subdomain email addresses are now normalized when
`hashEmail` is used. For example, `[email protected]` will become
`[email protected]`.
* Additional `yahoo.com` email addresses now have aliases removed from
their local part when `hashEmail` is used. For example,
`[email protected]` will become `[email protected]` for additional
`yahoo.com` domains.
* Duplicate `.com`s are now removed from email domain names when
`hashEmail` is used. For example, `example.com.com` will become
`example.com`.
* Certain TLD typos are now normalized when `hashEmail` is used. For
example, `example.comcom` will become `example.com`.
* Additional `gmail.com` domain names with leading digits are now
normalized when `hashEmail` is used. For example, `100gmail.com` will
become `gmail.com`.
* Additional `gmail.com` typos are now normalized when `hashEmail` is used.
For example, `gmali.com` will become `gmail.com`.
* When `hashEmail` is used, the local part of an email address is now
normalized to NFC.
* Added `pxp_financial` and `trustpay` to the payment processor validation.
* Equivalent domain names are now normalized when `hashEmail` is used.
For example, `googlemail.com` will become `gmail.com`.
* Periods are now removed from `gmail.com` email address local parts when
`hashEmail` is used. For example, `[email protected]` will become
`[email protected]`.
* Fastmail alias subdomain email addresses are now normalized when
`hashEmail` is used. For example, `[email protected]` will become
`[email protected]`.
* Additional `yahoo.com` email addresses now have aliases removed from
their local part when `hashEmail` is used. For example,
`[email protected]` will become `[email protected]` for additional
`yahoo.com` domains.
* Duplicate `.com`s are now removed from email domain names when
`hashEmail` is used. For example, `example.com.com` will become
`example.com`.
* Certain TLD typos are now normalized when `hashEmail` is used. For
example, `example.comcom` will become `example.com`.
* Additional `gmail.com` domain names with leading digits are now
normalized when `hashEmail` is used. For example, `100gmail.com` will
become `gmail.com`.
* Additional `gmail.com` typos are now normalized when `hashEmail` is used.
For example, `gmali.com` will become `gmail.com`.
* When `hashEmail` is used, the local part of an email address is now
normalized to NFC.

2.0.0 (2023-12-04)
------------------

* IMPORTANT: PHP 8.1 or greater is now required.
* BREAKING: Read-only properties are now used for the model class rather than
magic methods.
* BREAKING: The `rawResponse` property on model classess has been removed. Use
* BREAKING: The `rawResponse` property on model classes has been removed. Use
the `jsonSerialize` method instead.
* BREAKING: The inheritance hierarchy on model classes has changed.
* Updated `geoip2/geoip2` to version that includes the `isAnycast` property on
Expand Down
177 changes: 88 additions & 89 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,86 +147,85 @@ $mf = new MinFraud(1, 'ABCD567890');
# Note that each ->with*() call returns a new immutable object. This means
# that if you separate the calls into separate statements without chaining,
# you should assign the return value to a variable each time.
$request = $mf->withDevice([
'ip_address' => '152.216.7.110',
'session_age' => 3600.5,
'session_id' => 'foobar',
'user_agent' =>
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.89 Safari/537.36',
'accept_language' => 'en-US,en;q=0.8',
])->withEvent([
'transaction_id' => 'txn3134133',
'shop_id' => 's2123',
'time' => '2012-04-12T23:20:50+00:00',
'type' => 'purchase',
])->withAccount([
'user_id' => 3132,
'username_md5' => '4f9726678c438914fa04bdb8c1a24088',
])->withEmail([
'address' => '[email protected]',
'domain' => 'maxmind.com',
])->withBilling([
'first_name' => 'First',
'last_name' => 'Last',
'company' => 'Company',
'address' => '101 Address Rd.',
'address_2' => 'Unit 5',
'city' => 'New Haven',
'region' => 'CT',
'country' => 'US',
'postal' => '06510',
'phone_number' => '123-456-7890',
'phone_country_code' => '1',
])->withShipping([
'first_name' => 'ShipFirst',
'last_name' => 'ShipLast',
'company' => 'ShipCo',
'address' => '322 Ship Addr. Ln.',
'address_2' => 'St. 43',
'city' => 'Nowhere',
'region' => 'OK',
'country' => 'US',
'postal' => '73003',
'phone_number' => '123-456-0000',
'phone_country_code' => '1',
'delivery_speed' => 'same_day',
])->withPayment([
'processor' => 'stripe',
'was_authorized' => false,
'decline_code' => 'invalid number',
])->withCreditCard([
'issuer_id_number' => '411111',
'last_digits' => '7643',
'bank_name' => 'Bank of No Hope',
'bank_phone_country_code' => '1',
'bank_phone_number' => '123-456-1234',
'avs_result' => 'Y',
'cvv_result' => 'N',
'was_3d_secure_successful' => true,
])->withOrder([
'amount' => 323.21,
'currency' => 'USD',
'discount_code' => 'FIRST',
'is_gift' => true,
'has_gift_message' => false,
'affiliate_id' => 'af12',
'subaffiliate_id' => 'saf42',
'referrer_uri' => 'http://www.amazon.com/',
])->withShoppingCartItem([
'category' => 'pets',
'item_id' => 'leash-0231',
'quantity' => 2,
'price' => 20.43,
])->withShoppingCartItem([
'category' => 'beauty',
'item_id' => 'msc-1232',
'quantity' => 1,
'price' => 100.00,
])->withCustomInputs([
'section' => 'news',
'previous_purchases' => 19,
'discount' => 3.2,
'previous_user' => true,
$request = $mf->withDevice(
ipAddress: '152.216.7.110',
sessionAge: 3600.5,
sessionId: 'foobar',
userAgent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.89 Safari/537.36',
acceptLanguage: 'en-US,en;q=0.8'
)->withEvent(
transactionId: 'txn3134133',
shopId: 's2123',
time: '2012-04-12T23:20:50+00:00',
type: 'purchase'
)->withAccount(
userId: 3132,
usernameMd5: '4f9726678c438914fa04bdb8c1a24088'
)->withEmail(
address: '[email protected]',
domain: 'maxmind.com'
)->withBilling(
firstName: 'First',
lastName: 'Last',
company: 'Company',
address: '101 Address Rd.',
address2: 'Unit 5',
city: 'New Haven',
region: 'CT',
country: 'US',
postal: '06510',
phoneNumber: '123-456-7890',
phoneCountryCode: '1'
)->withShipping(
firstName: 'ShipFirst',
lastName: 'ShipLast',
company: 'ShipCo',
address: '322 Ship Addr. Ln.',
address2: 'St. 43',
city: 'Nowhere',
region: 'OK',
country: 'US',
postal: '73003',
phoneNumber: '123-456-0000',
phoneCountryCode: '1',
deliverySpeed: 'same_day'
)->withPayment(
processor: 'stripe',
wasAuthorized: false,
declineCode: 'invalid number'
)->withCreditCard(
issuerIdNumber: '411111',
lastDigits: '7643',
bankName: 'Bank of No Hope',
bankPhoneCountryCode: '1',
bankPhoneNumber: '123-456-1234',
avsResult: 'Y',
cvvResult: 'N',
was3dSecureSuccessful: true
)->withOrder(
amount: 323.21,
currency: 'USD',
discountCode: 'FIRST',
isGift: true,
hasGiftMessage: false,
affiliateId: 'af12',
subaffiliateId: 'saf42',
referrerUri: 'http://www.amazon.com/'
)->withShoppingCartItem(
category: 'pets',
itemId: 'leash-0231',
quantity: 2,
price: 20.43
)->withShoppingCartItem(
category: 'beauty',
itemId: 'msc-1232',
quantity: 1,
price: 100.00
)->withCustomInputs([
'section' => 'news',
'previous_purchases' => 19,
'discount' => 3.2,
'previous_user' => true,
]);

# To get the minFraud Factors response model, use ->factors():
Expand Down Expand Up @@ -309,15 +308,15 @@ use MaxMind\MinFraud\ReportTransaction;
# and optionally an array of options.
$rt = new ReportTransaction(1, 'ABCD567890');

$rt->report([
'ip_address' => '152.216.7.110',
'tag' => 'chargeback',
'chargeback_code' => 'UA02',
'minfraud_id' => '26ae87e4-5112-4f76-b0f7-4132d45d72b2',
'maxmind_id' => 'aBcDeFgH',
'notes' => 'Found due to non-existent shipping address',
'transaction_id' => 'cart123456789',
]);
$rt->report(
ipAddress: '152.216.7.110',
tag: 'chargeback',
chargebackCode: 'UA02',
minfraudId: '26ae87e4-5112-4f76-b0f7-4132d45d72b2',
maxmindId: 'aBcDeFgH',
notes: 'Found due to non-existent shipping address',
transactionId: 'cart123456789'
);
```

## Support ##
Expand Down
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
"php": ">=8.1",
"ext-json": "*",
"geoip2/geoip2": "^v3.0.0",
"maxmind/web-service-common": "^0.9.0",
"respect/validation": "^2.3.1"
"maxmind/web-service-common": "^0.9.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "3.*",
Expand Down
2 changes: 1 addition & 1 deletion dev-bin/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ php box.phar compile

phar_test=$(./dev-bin/phar-test.php)
if [[ -n $phar_test ]]; then
echo "Phar test outputed non-empty string: $phar_test"
echo "Phar test outputted non-empty string: $phar_test"
exit 1
fi

Expand Down
Loading

0 comments on commit f44064f

Please sign in to comment.