Skip to content

Commit 9c960d9

Browse files
horghclaude
andcommitted
Add payment method field with 10 valid values
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 14ea30e commit 9c960d9

5 files changed

Lines changed: 78 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ CHANGELOG
88
* Added `credit_application` and `fund_transfer` to event type validation.
99
* Added the input `/event/party`. This is the party submitting the
1010
transaction.
11+
* Added the input `/payment/method`. This is the payment method associated
12+
with the transaction.
1113

1214
3.3.0 (2025-05-23)
1315
------------------

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ $request = $mf->withDevice(
191191
phoneCountryCode: '1',
192192
deliverySpeed: 'same_day'
193193
)->withPayment(
194+
method: 'card',
194195
processor: 'stripe',
195196
wasAuthorized: false,
196197
declineCode: 'invalid number'

src/MinFraud.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,18 @@ public function withShipping(
770770
* @param bool|null $wasAuthorized The authorization outcome from the payment
771771
* processor. If the transaction has not yet been
772772
* approved or denied, do not include this field.
773+
* @param string|null $method The payment method associated with the transaction.
774+
* The valid values are:
775+
* - `bank_debit`
776+
* - `bank_redirect`
777+
* - `bank_transfer`
778+
* - `buy_now_pay_later`
779+
* - `card`
780+
* - `crypto`
781+
* - `digital_wallet`
782+
* - `gift_card`
783+
* - `real_time_payment`
784+
* - `rewards`
773785
*
774786
* @return MinFraud A new immutable MinFraud object. This object is
775787
* a clone of the original with additional data.
@@ -779,6 +791,7 @@ public function withPayment(
779791
?string $declineCode = null,
780792
?string $processor = null,
781793
?bool $wasAuthorized = null,
794+
?string $method = null,
782795
): self {
783796
if (\count($values) !== 0) {
784797
if (\func_num_args() !== 1) {
@@ -788,6 +801,7 @@ public function withPayment(
788801
}
789802

790803
$declineCode = $this->remove($values, 'decline_code');
804+
$method = $this->remove($values, 'method');
791805
$processor = $this->remove($values, 'processor');
792806
$wasAuthorized = $this->remove($values, 'was_authorized', ['boolean']);
793807

@@ -798,6 +812,24 @@ public function withPayment(
798812
$values['decline_code'] = $declineCode;
799813
}
800814

815+
if ($method !== null) {
816+
if (!\in_array($method, [
817+
'bank_debit',
818+
'bank_redirect',
819+
'bank_transfer',
820+
'buy_now_pay_later',
821+
'card',
822+
'crypto',
823+
'digital_wallet',
824+
'gift_card',
825+
'real_time_payment',
826+
'rewards',
827+
], true)) {
828+
$this->maybeThrowInvalidInputException("$method is not a valid payment method");
829+
}
830+
$values['method'] = $method;
831+
}
832+
801833
if ($processor !== null) {
802834
if (!\in_array($processor, [
803835
'adyen',

tests/MaxMind/Test/MinFraudTest.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ public function testFullInsightsRequestUsingNamedArgs(string $class, string $ser
153153
referrerUri: 'http://www.amazon.com/'
154154
)
155155
->withPayment(
156+
method: 'card',
156157
processor: 'stripe',
157158
wasAuthorized: false,
158159
declineCode: 'invalid number'
@@ -1222,6 +1223,47 @@ public function testBadPaymentProcessor(): void
12221223
)->withPayment(['processor' => 'unknown']);
12231224
}
12241225

1226+
/**
1227+
* @dataProvider goodPaymentMethods
1228+
*/
1229+
public function testGoodPaymentMethod(string $good): void
1230+
{
1231+
$this->createMinFraudRequestWithFullResponse(
1232+
'insights',
1233+
0
1234+
)->withPayment(['method' => $good]);
1235+
}
1236+
1237+
/**
1238+
* @return array<list<string>>
1239+
*/
1240+
public static function goodPaymentMethods(): array
1241+
{
1242+
return [
1243+
['bank_debit'],
1244+
['bank_redirect'],
1245+
['bank_transfer'],
1246+
['buy_now_pay_later'],
1247+
['card'],
1248+
['crypto'],
1249+
['digital_wallet'],
1250+
['gift_card'],
1251+
['real_time_payment'],
1252+
['rewards'],
1253+
];
1254+
}
1255+
1256+
public function testBadPaymentMethod(): void
1257+
{
1258+
$this->expectException(InvalidInputException::class);
1259+
$this->expectExceptionMessage('valid payment method');
1260+
1261+
$this->createMinFraudRequestWithFullResponse(
1262+
'insights',
1263+
0
1264+
)->withPayment(['method' => 'unknown']);
1265+
}
1266+
12251267
/**
12261268
* @dataProvider validAmounts
12271269
*/

tests/data/minfraud/full-request.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"delivery_speed": "same_day"
4343
},
4444
"payment": {
45+
"method": "card",
4546
"processor": "stripe",
4647
"was_authorized": false,
4748
"decline_code": "invalid number"

0 commit comments

Comments
 (0)