Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make IP address optional when reporting transactions #175

Merged
merged 4 commits into from
Jun 6, 2024

Conversation

ugexe
Copy link
Contributor

@ugexe ugexe commented May 24, 2024

No description provided.

@ugexe ugexe force-pushed the nlogan/no-ip-report branch 3 times, most recently from bce855a to 033e93c Compare May 28, 2024 14:24
@ugexe ugexe force-pushed the nlogan/no-ip-report branch from 033e93c to a0f49df Compare May 28, 2024 14:28
CHANGELOG.md Outdated
Comment on lines 9 to 10
parameters must be supplied: `ip_address`, `maxmind_id`, `minfraud_id`,
`transaction_id`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
parameters must be supplied: `ip_address`, `maxmind_id`, `minfraud_id`,
`transaction_id`.
parameters must be supplied: `ipAddress`, `maxmindId`, `minfraudId`,
`transactionId`.

README.md Outdated
Comment on lines 285 to 287
called with invalid input data or when the required fields are missing. The
required fields are `tag` and one or more of the following: `ip_address`,
`maxmind_id`, `minfraud_id`, or `transaction_id`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
called with invalid input data or when the required fields are missing. The
required fields are `tag` and one or more of the following: `ip_address`,
`maxmind_id`, `minfraud_id`, or `transaction_id`.
called with invalid input data or when the required arguments are null. The
required arguments are `tag` and one or more of the following: `ipAddress`,
`maxmindId`, `minfraudId`, or `transactionId`.

This one is my fault. I should have updated this when I switched to named arguments as the preferred method.

* order. This should be passed as a string like
* "44.55.66.77" or "2001:db8::2:1".
* "44.55.66.77" or "2001:db8::2:1". This field is not
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also on me, but these "field" uses probably should all be "argument". It might be better for us to just do that in a separate PR though as I suspect it is endemic.

* minFraud. This field is not required if you provide at
* least one of the transaction's ipAddress, maxmindId, or
* minfraudId. You are encouraged to provide it or the
* transaction's maxmind_id or minfraud_id.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* transaction's maxmind_id or minfraud_id.
* transaction's maxmindId or minfraudId.

I suppose we could put backticks around all of these, but that is preexisting.

* the request was made to one of these services.
* not required if you provide at least one of the transaction's
* ipAddress, maxmindId, or transactionId. You are encouraged to
* provide it the request was made to one of these services.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* provide it the request was made to one of these services.
* provide it if the request was made to one of these services.

@@ -116,18 +121,27 @@ public function report(
$this->verifyEmpty($values);
}

if ($ipAddress === null
&& $minfraudId === null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that we are not validating that this is a valid UUID, maybe w should at least check that it is not the mepty string.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$minfraudId is validated as a UUID a little later in the validation process

if ($minfraudId !== null) {
if (!preg_match(
'/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i',
$minfraudId,
)) {
$this->maybeThrowInvalidInputException("$minfraudId must be a valid minFraud ID");
}
$values['minfraud_id'] = $minfraudId;
}

That being said, $maxmindId is also validated to ensure it is 8 characters so I don't think we need the check for $maxmindId === ''. It might also make sense to put this "one of these fields" check after the aforementioned individual field validation has occurred.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually we might still need to check for the empty string, since the validation calls to maybeThrowInvalidInputException won't throw an exception if validateInput is false.

ugexe added 3 commits May 30, 2024 14:13
In most situations the individual field validation ensures these
fields aren't empty strings. However when validation is disabled
it is possible for empty strings to reach this conditional.
@oschwald oschwald merged commit d206df3 into main Jun 6, 2024
20 checks passed
@oschwald oschwald deleted the nlogan/no-ip-report branch June 6, 2024 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants