Skip to content

Commit

Permalink
Merge pull request #116 from maxmind/label-test-3ds
Browse files Browse the repository at this point in the history
Add custom rule label and 3DS result input
  • Loading branch information
kevcenteno authored Aug 25, 2021
2 parents bdeac7a + 1b4febc commit 1a2f36b
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ CHANGELOG
-------------------

* Added `datacap` to the payment processor validation.
* Added `ruleLabel` to minFraud output `Disposition`.
* Added `was_3d_secure_successful` to `/credit_card` validation.

1.18.0 (2021-06-07)
-------------------
Expand Down
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,14 @@ $request = $mf->withDevice([
'was_authorized' => false,
'decline_code' => 'invalid number',
])->withCreditCard([
'issuer_id_number' => '411111',
'last_4_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',
'issuer_id_number' => '411111',
'last_4_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',
Expand Down
16 changes: 14 additions & 2 deletions src/MinFraud/Model/Disposition.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@
*
* @property-read string|null $action The action to take on the transaction as
* defined by your custom rules. The current set of values are "accept",
* "manual_review", and "reject". If you do not have custom rules set up,
* `null` will be returned.
* "manual_review", "reject", and "test". If you do not have custom rules set
* up, `null` will be returned.
* @property-read string|null $reason The reason for the action. The current
* possible values are "custom_rule", "block_list", and "default". If you do
* not have custom rules set up, `null` will be returned.
* @property-read string|null $ruleLabel The label of the custom rule that was
* triggered. If you do not have custom rules set up, the triggered custom rule
* does not have a label, or no custom rule was triggered, `null` will be
* returned.
*/
class Disposition extends AbstractModel
{
Expand All @@ -33,10 +37,18 @@ class Disposition extends AbstractModel
*/
protected $reason;

/**
* @internal
*
* @var string|null
*/
protected $ruleLabel;

public function __construct(?array $response, array $locales = ['en'])
{
parent::__construct($response, $locales);
$this->action = $this->safeArrayLookup($response['action']);
$this->reason = $this->safeArrayLookup($response['reason']);
$this->ruleLabel = $this->safeArrayLookup($response['rule_label']);
}
}
3 changes: 2 additions & 1 deletion src/MinFraud/Validation/Rules/CreditCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public function __construct()
v::key('cvv_result', v::stringType()->length(1, 1), false),
v::key('issuer_id_number', v::regex('/^[0-9]{6}$/'), false),
v::key('last_4_digits', v::regex('/^[0-9]{4}$/'), false),
v::key('token', v::regex('/^[\x21-\x7E]{1,255}$/')->not(v::regex('/^[0-9]{1,19}$/')), false)
v::key('token', v::regex('/^[\x21-\x7E]{1,255}$/')->not(v::regex('/^[0-9]{1,19}$/')), false),
v::key('was_3d_secure_successful', v::boolVal(), false),
));
}
}
7 changes: 7 additions & 0 deletions tests/MaxMind/Test/MinFraud/Model/DispositionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function testDisposition(): void
$array = [
'action' => 'manual_review',
'reason' => 'custom_rule',
'rule_label' => 'custom rule label',
];
$disposition = new Disposition($array);

Expand All @@ -34,6 +35,12 @@ public function testDisposition(): void
'reason'
);

$this->assertSame(
$array['rule_label'],
$disposition->ruleLabel,
'ruleLabel'
);

$this->assertSame(
$array,
$disposition->jsonSerialize(),
Expand Down
3 changes: 2 additions & 1 deletion tests/data/minfraud/full-request.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
"bank_phone_number": "123-456-1234",
"avs_result": "Y",
"cvv_result": "N",
"token": "123456abc1234"
"token": "123456abc1234",
"was_3d_secure_successful": true
},
"custom_inputs": {
"float_input": 12.1,
Expand Down

0 comments on commit 1a2f36b

Please sign in to comment.