Skip to content

Commit 427b9ad

Browse files
authored
Merge pull request #537 from maxmind/wstorey/eng-2869-eventparty-and-paymentmethod-minfraud-inputs-are-supported
Add /event/party, /payment/method, and new /event/type values
2 parents 8ea63b6 + d9d9886 commit 427b9ad

File tree

9 files changed

+166
-0
lines changed

9 files changed

+166
-0
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ CHANGELOG
1414
`FactorsResponse.getSubscores()` method. Use `getRiskScoreReasons()`
1515
instead.
1616
* BREAKING: Java 17 is now required (previously Java 11).
17+
* Added `CREDIT_APPLICATION` and `FUND_TRANSFER` to the `Event.Type` enum.
18+
* Added the input `/event/party`. This is the party submitting the
19+
transaction. You may provide this using the `party` method on
20+
`Event.Builder`.
21+
* Added the input `/payment/method`. This is the payment method associated
22+
with the transaction. You may provide this using the `method` method on
23+
`Payment.Builder`.
1724

1825
3.9.0
1926
------------------

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ Transaction request = new Transaction.Builder(
179179
.build()
180180
).event(
181181
new Event.Builder()
182+
.party(Event.Party.CUSTOMER)
182183
.shopId("2432")
183184
.time(new Date())
184185
.transactionId("tr1242")
@@ -196,6 +197,7 @@ Transaction request = new Transaction.Builder(
196197
).payment(
197198
new Payment.Builder()
198199
.declineCode("invalid")
200+
.method(Payment.Method.CARD)
199201
.processor(Payment.Processor.ADYEN)
200202
.wasAuthorized(false)
201203
.build()

src/main/java/com/maxmind/minfraud/request/Event.java

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@
1212
*/
1313
public final class Event extends AbstractModel {
1414

15+
private final Party party;
1516
private final String transactionId;
1617
private final String shopId;
1718
private final ZonedDateTime time;
1819
private final Type type;
1920

2021
private Event(Event.Builder builder) {
22+
party = builder.party;
2123
transactionId = builder.transactionId;
2224
shopId = builder.shopId;
2325
time = builder.time;
@@ -28,11 +30,21 @@ private Event(Event.Builder builder) {
2830
* {@code Builder} creates instances of {@code Event} from values set by the builder's methods.
2931
*/
3032
public static final class Builder {
33+
Party party;
3134
String transactionId;
3235
String shopId;
3336
ZonedDateTime time;
3437
Type type;
3538

39+
/**
40+
* @param party The party submitting the transaction.
41+
* @return The builder object.
42+
*/
43+
public Event.Builder party(Party party) {
44+
this.party = party;
45+
return this;
46+
}
47+
3648
/**
3749
* @param id Your internal ID for the transaction. We can use this to locate a specific
3850
* transaction in our logs, and it will also show up in email alerts and
@@ -90,6 +102,14 @@ public Event build() {
90102
}
91103
}
92104

105+
/**
106+
* @return The party submitting the transaction.
107+
*/
108+
@JsonProperty("party")
109+
public Party getParty() {
110+
return party;
111+
}
112+
93113
/**
94114
* @return The transaction ID.
95115
*/
@@ -142,10 +162,18 @@ public enum Type {
142162
* The account was logged into
143163
*/
144164
ACCOUNT_LOGIN,
165+
/**
166+
* A credit application was submitted
167+
*/
168+
CREDIT_APPLICATION,
145169
/**
146170
* The account email was changed
147171
*/
148172
EMAIL_CHANGE,
173+
/**
174+
* A fund transfer was initiated
175+
*/
176+
FUND_TRANSFER,
149177
/**
150178
* The account password was reset
151179
*/
@@ -178,4 +206,25 @@ public String toString() {
178206
return this.name().toLowerCase();
179207
}
180208
}
209+
210+
/**
211+
* The enumerated event party types.
212+
*/
213+
public enum Party {
214+
/**
215+
* An agent is submitting the transaction
216+
*/
217+
AGENT,
218+
/**
219+
* A customer is submitting the transaction
220+
*/
221+
CUSTOMER;
222+
223+
/**
224+
* @return a string representation of the object.
225+
*/
226+
public String toString() {
227+
return this.name().toLowerCase();
228+
}
229+
}
181230
}

src/main/java/com/maxmind/minfraud/request/Payment.java

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
* The payment information for the transaction.
88
*/
99
public final class Payment extends AbstractModel {
10+
private final Method method;
1011
private final Processor processor;
1112
private final Boolean wasAuthorized;
1213
private final String declineCode;
1314

1415
private Payment(Payment.Builder builder) {
16+
method = builder.method;
1517
processor = builder.processor;
1618
wasAuthorized = builder.wasAuthorized;
1719
declineCode = builder.declineCode;
@@ -22,10 +24,20 @@ private Payment(Payment.Builder builder) {
2224
* methods.
2325
*/
2426
public static final class Builder {
27+
Method method;
2528
Processor processor;
2629
Boolean wasAuthorized;
2730
String declineCode;
2831

32+
/**
33+
* @param method The payment method used for the transaction.
34+
* @return The builder object.
35+
*/
36+
public Payment.Builder method(Method method) {
37+
this.method = method;
38+
return this;
39+
}
40+
2941
/**
3042
* @param processor The payment processor used for the transaction.
3143
* @return The builder object.
@@ -64,6 +76,14 @@ public Payment build() {
6476
}
6577
}
6678

79+
/**
80+
* @return The payment method.
81+
*/
82+
@JsonProperty("method")
83+
public Method getMethod() {
84+
return method;
85+
}
86+
6787
/**
6888
* @return The payment processor.
6989
*/
@@ -262,4 +282,57 @@ public String toString() {
262282
return this.name().toLowerCase();
263283
}
264284
}
285+
286+
/**
287+
* Enumeration of payment methods
288+
*/
289+
public enum Method {
290+
/**
291+
* Bank debit payment
292+
*/
293+
BANK_DEBIT,
294+
/**
295+
* Bank redirect payment
296+
*/
297+
BANK_REDIRECT,
298+
/**
299+
* Bank transfer payment
300+
*/
301+
BANK_TRANSFER,
302+
/**
303+
* Buy now, pay later payment
304+
*/
305+
BUY_NOW_PAY_LATER,
306+
/**
307+
* Card payment
308+
*/
309+
CARD,
310+
/**
311+
* Cryptocurrency payment
312+
*/
313+
CRYPTO,
314+
/**
315+
* Digital wallet payment
316+
*/
317+
DIGITAL_WALLET,
318+
/**
319+
* Gift card payment
320+
*/
321+
GIFT_CARD,
322+
/**
323+
* Real time payment
324+
*/
325+
REAL_TIME_PAYMENT,
326+
/**
327+
* Rewards payment
328+
*/
329+
REWARDS;
330+
331+
/**
332+
* @return a string representation of the object.
333+
*/
334+
public String toString() {
335+
return this.name().toLowerCase();
336+
}
337+
}
265338
}

src/test/java/com/maxmind/minfraud/request/EventTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,23 @@
33
import static org.junit.jupiter.api.Assertions.assertEquals;
44

55
import com.maxmind.minfraud.request.Event.Builder;
6+
import com.maxmind.minfraud.request.Event.Party;
67
import com.maxmind.minfraud.request.Event.Type;
78
import java.time.ZonedDateTime;
89
import java.util.Date;
910
import org.junit.jupiter.api.Test;
1011

1112
public class EventTest {
1213

14+
@Test
15+
public void testParty() {
16+
Event event = new Builder().party(Party.AGENT).build();
17+
assertEquals(Party.AGENT, event.getParty());
18+
19+
event = new Builder().party(Party.CUSTOMER).build();
20+
assertEquals(Party.CUSTOMER, event.getParty());
21+
}
22+
1323
@Test
1424
public void testTransactionId() {
1525
Event event = new Builder().transactionId("t12").build();
@@ -43,5 +53,11 @@ public void testType() {
4353

4454
event = new Builder().type(Type.PAYOUT_CHANGE).build();
4555
assertEquals(Type.PAYOUT_CHANGE, event.getType());
56+
57+
event = new Builder().type(Type.CREDIT_APPLICATION).build();
58+
assertEquals(Type.CREDIT_APPLICATION, event.getType());
59+
60+
event = new Builder().type(Type.FUND_TRANSFER).build();
61+
assertEquals(Type.FUND_TRANSFER, event.getType());
4662
}
4763
}

src/test/java/com/maxmind/minfraud/request/PaymentTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,24 @@
44
import static org.junit.jupiter.api.Assertions.assertTrue;
55

66
import com.maxmind.minfraud.request.Payment.Builder;
7+
import com.maxmind.minfraud.request.Payment.Method;
78
import com.maxmind.minfraud.request.Payment.Processor;
89
import org.junit.jupiter.api.Test;
910

1011
public class PaymentTest {
1112

13+
@Test
14+
public void testMethod() {
15+
Payment payment = new Builder().method(Method.CARD).build();
16+
assertEquals(Method.CARD, payment.getMethod());
17+
18+
payment = new Builder().method(Method.DIGITAL_WALLET).build();
19+
assertEquals(Method.DIGITAL_WALLET, payment.getMethod());
20+
21+
payment = new Builder().method(Method.BUY_NOW_PAY_LATER).build();
22+
assertEquals(Method.BUY_NOW_PAY_LATER, payment.getMethod());
23+
}
24+
1225
@Test
1326
public void testProcessor() {
1427
Payment payment = new Builder().processor(Processor.ADYEN).build();

src/test/java/com/maxmind/minfraud/request/RequestTestHelper.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ private static Transaction makeTransaction(Email e) throws Exception {
5858
.event(
5959
new Event
6060
.Builder()
61+
.party(Event.Party.CUSTOMER)
6162
.transactionId("txn3134133")
6263
.shopId("s2123")
6364
.time(ZonedDateTime.parse("2012-04-12T23:20:50.52Z"))
@@ -102,6 +103,7 @@ private static Transaction makeTransaction(Email e) throws Exception {
102103
.build()
103104
).payment(
104105
new Payment.Builder()
106+
.method(Payment.Method.CARD)
105107
.processor(Payment.Processor.STRIPE)
106108
.wasAuthorized(false)
107109
.declineCode("invalid number")

src/test/resources/test-data/full-request-email-md5.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"event": {
3+
"party": "customer",
34
"transaction_id": "txn3134133",
45
"shop_id": "s2123",
56
"time": "2012-04-12T23:20:50.52Z",
@@ -41,6 +42,7 @@
4142
"delivery_speed": "same_day"
4243
},
4344
"payment": {
45+
"method": "card",
4446
"processor": "stripe",
4547
"was_authorized": false,
4648
"decline_code": "invalid number"

src/test/resources/test-data/full-request.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"event": {
3+
"party": "customer",
34
"transaction_id": "txn3134133",
45
"shop_id": "s2123",
56
"time": "2012-04-12T23:20:50.52Z",
@@ -41,6 +42,7 @@
4142
"delivery_speed": "same_day"
4243
},
4344
"payment": {
45+
"method": "card",
4446
"processor": "stripe",
4547
"was_authorized": false,
4648
"decline_code": "invalid number"

0 commit comments

Comments
 (0)