Ghost/ghost/donations/src/DonationPaymentEvent.ts
Simon Backx 841e52ccfe
Added donations API (#17495)
refs https://github.com/TryGhost/Product/issues/3648

- Refactored Members API RouterController.createCheckoutSession: Split the method into smaller parts so we can reuse individual parts for the upcoming donation checkout session.
- Wired up donation checkout creation
- Added donation events
2023-07-31 16:00:52 +00:00

40 lines
1.2 KiB
TypeScript

export class DonationPaymentEvent {
timestamp: Date;
name: string | null;
email: string;
memberId: string | null;
amount: number;
currency: string;
attributionId: string | null;
attributionUrl: string | null;
attributionType: string | null;
referrerSource: string | null;
referrerMedium: string | null;
referrerUrl: string | null;
constructor(data: Omit<DonationPaymentEvent, 'timestamp'>, timestamp: Date) {
this.timestamp = timestamp;
this.name = data.name;
this.email = data.email;
this.memberId = data.memberId;
this.amount = data.amount;
this.currency = data.currency;
this.attributionId = data.attributionId;
this.attributionUrl = data.attributionUrl;
this.attributionType = data.attributionType;
this.referrerSource = data.referrerSource;
this.referrerMedium = data.referrerMedium;
this.referrerUrl = data.referrerUrl;
}
static create(data: Omit<DonationPaymentEvent, 'timestamp'>, timestamp?: Date) {
return new DonationPaymentEvent(
data,
timestamp ?? new Date()
);
}
}