Skip to content

Commit 253d5d1

Browse files
horghclaude
andcommitted
Add /payment/method input
Added new method field to specify the payment method associated with the transaction. The method field accepts values like CARD, DIGITAL_WALLET, BUY_NOW_PAY_LATER, CRYPTO, and others, serialized as lowercase with underscores in JSON requests. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 08571ff commit 253d5d1

4 files changed

Lines changed: 90 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ CHANGELOG
1818
* Added the input `/event/party`. This is the party submitting the
1919
transaction. You may provide this using the `party` method on
2020
`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`.
2124

2225
3.9.0
2326
------------------

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ Transaction request = new Transaction.Builder(
197197
).payment(
198198
new Payment.Builder()
199199
.declineCode("invalid")
200+
.method(Payment.Method.CARD)
200201
.processor(Payment.Processor.ADYEN)
201202
.wasAuthorized(false)
202203
.build()

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/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();

0 commit comments

Comments
 (0)