Skip to content

Commit 25b5f55

Browse files
authored
Merge pull request #1747 from maxmind/wstorey/eng-2874-eventparty-and-paymentmethod-minfraud-inputs-are-supported
Add /event/party, /payment/method, and new /event/type values
2 parents 1a349a2 + 940840e commit 25b5f55

File tree

7 files changed

+101
-3
lines changed

7 files changed

+101
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ CHANGELOG
55
------------------
66

77
* Added `Securepay` to the `Processor` enum.
8+
* Added `CreditApplication` and `FundTransfer` to the `EventType` enum.
9+
* Added the input `/event/party`. This is the party submitting the
10+
transaction. You may provide this by providing `party` to `Event`.
11+
* Added the input `/payment/method`. This is the payment method associated
12+
with the transaction. You may provide this by providing `method` to
13+
`Payment`.
814

915
8.1.0 (2025-05-23)
1016
------------------

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ try {
181181
ipAddress: "81.2.69.160",
182182
}),
183183
event: new minFraud.Event({
184+
party: minFraud.Constants.EventParty.Customer,
184185
shopId: 'shop',
185186
time: new Date(Date.now()),
186187
transactionId: 'txn1234',
@@ -223,6 +224,7 @@ try {
223224
}),
224225
payment: new minFraud.Payment({
225226
declineCode: 'A',
227+
method: minFraud.Constants.PaymentMethod.Card,
226228
processor: minFraud.Constants.Processor.ConceptPayments,
227229
wasAuthorized: true,
228230
}),

src/constants.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1+
export enum EventParty {
2+
Agent = 'agent',
3+
Customer = 'customer',
4+
}
5+
16
export enum EventType {
27
AccountCreation = 'account_creation',
38
AccountLogin = 'account_login',
9+
CreditApplication = 'credit_application',
410
EmailChange = 'email_change',
11+
FundTransfer = 'fund_transfer',
512
PasswordReset = 'password_reset',
613
PayoutChange = 'payout_change',
714
Purchase = 'purchase',
@@ -17,6 +24,19 @@ export enum DeliverySpeed {
1724
Standard = 'standard',
1825
}
1926

27+
export enum PaymentMethod {
28+
BankDebit = 'bank_debit',
29+
BankRedirect = 'bank_redirect',
30+
BankTransfer = 'bank_transfer',
31+
BuyNowPayLater = 'buy_now_pay_later',
32+
Card = 'card',
33+
Crypto = 'crypto',
34+
DigitalWallet = 'digital_wallet',
35+
GiftCard = 'gift_card',
36+
RealTimePayment = 'real_time_payment',
37+
Rewards = 'rewards',
38+
}
39+
2040
export enum Processor {
2141
Adyen = 'adyen',
2242
Affirm = 'affirm',

src/request/event.spec.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Event from './event';
2+
import { EventParty, EventType } from '../constants';
23

34
describe('Event()', () => {
45
it('sets `time` to now by default', () => {
@@ -14,4 +15,36 @@ describe('Event()', () => {
1415

1516
expect(event.time).toEqual(mockDate);
1617
});
18+
19+
it('accepts credit_application event type', () => {
20+
const event = new Event({
21+
type: EventType.CreditApplication,
22+
});
23+
24+
expect(event.type).toEqual(EventType.CreditApplication);
25+
});
26+
27+
it('accepts fund_transfer event type', () => {
28+
const event = new Event({
29+
type: EventType.FundTransfer,
30+
});
31+
32+
expect(event.type).toEqual(EventType.FundTransfer);
33+
});
34+
35+
it('accepts agent party', () => {
36+
const event = new Event({
37+
party: EventParty.Agent,
38+
});
39+
40+
expect(event.party).toEqual(EventParty.Agent);
41+
});
42+
43+
it('accepts customer party', () => {
44+
const event = new Event({
45+
party: EventParty.Customer,
46+
});
47+
48+
expect(event.party).toEqual(EventParty.Customer);
49+
});
1750
});

src/request/event.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
import { EventType } from '../constants';
1+
import { EventParty, EventType } from '../constants';
22

33
interface EventProps {
4+
/**
5+
* The party submitting the transaction.
6+
*/
7+
party?: EventParty;
48
/**
59
* Your internal ID for the transaction. We can use this to locate a specific
610
* transaction in our logs, and it will also show up in email alerts and
@@ -27,13 +31,15 @@ interface EventProps {
2731
* Event information for the transaction being sent to the web service.
2832
*/
2933
export default class Event implements EventProps {
34+
/** @inheritDoc EventProps.party */
35+
public party?: EventParty;
3036
/** @inheritDoc EventProps.transactionId */
3137
public transactionId?: string;
3238
/** @inheritDoc EventProps.shopId */
3339
public shopId?: string;
3440
/** @inheritDoc EventProps.time */
3541
public time?: Date;
36-
/** @inheritDoc EventProps.EventType */
42+
/** @inheritDoc EventProps.type */
3743
public type?: EventType;
3844

3945
public constructor(minfraudEvent: EventProps) {

src/request/payment.spec.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Payment from './payment';
2+
import { PaymentMethod } from '../constants';
23

34
describe('Payment()', () => {
45
it('constructs', () => {
@@ -8,4 +9,28 @@ describe('Payment()', () => {
89
});
910
}).not.toThrow();
1011
});
12+
13+
it('accepts card payment method', () => {
14+
const payment = new Payment({
15+
method: PaymentMethod.Card,
16+
});
17+
18+
expect(payment.method).toEqual(PaymentMethod.Card);
19+
});
20+
21+
it('accepts crypto payment method', () => {
22+
const payment = new Payment({
23+
method: PaymentMethod.Crypto,
24+
});
25+
26+
expect(payment.method).toEqual(PaymentMethod.Crypto);
27+
});
28+
29+
it('accepts digital_wallet payment method', () => {
30+
const payment = new Payment({
31+
method: PaymentMethod.DigitalWallet,
32+
});
33+
34+
expect(payment.method).toEqual(PaymentMethod.DigitalWallet);
35+
});
1136
});

src/request/payment.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
import { Processor } from '../constants';
1+
import { PaymentMethod, Processor } from '../constants';
22

33
interface PaymentProps {
4+
/**
5+
* The payment method associated with the transaction.
6+
*/
7+
method?: PaymentMethod;
48
/**
59
* The payment processor used for the transaction.
610
*/
@@ -21,6 +25,8 @@ interface PaymentProps {
2125
* The payment information for the transaction being sent to the web service.
2226
*/
2327
export default class Payment implements PaymentProps {
28+
/** @inheritDoc PaymentProps.method */
29+
public method?: PaymentMethod;
2430
/** @inheritDoc PaymentProps.processor */
2531
public processor?: Processor;
2632
/** @inheritDoc PaymentProps.wasAuthorized */

0 commit comments

Comments
 (0)