Skip to content

Commit e6102b4

Browse files
horghclaude
andcommitted
Add event party field to support agent and customer transactions
Add EventParty enum with Agent and Customer values. Update Event class to include party field as the first property per requirements. Updated tests and documentation to demonstrate usage. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent d37ab8b commit e6102b4

File tree

5 files changed

+33
-3
lines changed

5 files changed

+33
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ CHANGELOG
66

77
* Added `Securepay` to the `Processor` enum.
88
* 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`.
911

1012
8.1.0 (2025-05-23)
1113
------------------

README.md

Lines changed: 1 addition & 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',

src/constants.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
export enum EventParty {
2+
Agent = 'agent',
3+
Customer = 'customer',
4+
}
5+
16
export enum EventType {
27
AccountCreation = 'account_creation',
38
AccountLogin = 'account_login',

src/request/event.spec.ts

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

44
describe('Event()', () => {
55
it('sets `time` to now by default', () => {
@@ -31,4 +31,20 @@ describe('Event()', () => {
3131

3232
expect(event.type).toEqual(EventType.FundTransfer);
3333
});
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+
});
3450
});

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) {

0 commit comments

Comments
 (0)