mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-18 21:45:31 +09:00
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
import type {DonationCurrency} from '@fluxer/schema/src/domains/donation/DonationSchemas';
|
|
import type {IDonationService} from './IDonationService';
|
|
import type {DonationCheckoutService} from './services/DonationCheckoutService';
|
|
import type {DonationMagicLinkService} from './services/DonationMagicLinkService';
|
|
|
|
export class DonationService implements IDonationService {
|
|
constructor(
|
|
private magicLinkService: DonationMagicLinkService,
|
|
private checkoutService: DonationCheckoutService,
|
|
) {}
|
|
|
|
async requestMagicLink(email: string): Promise<void> {
|
|
return this.magicLinkService.sendMagicLink(email);
|
|
}
|
|
|
|
async validateMagicLinkToken(token: string): Promise<{
|
|
email: string;
|
|
stripeCustomerId: string | null;
|
|
}> {
|
|
return this.magicLinkService.validateToken(token);
|
|
}
|
|
|
|
async createDonationCheckout(params: {
|
|
email: string;
|
|
amountCents: number;
|
|
currency: DonationCurrency;
|
|
interval: 'month' | 'year' | null;
|
|
isBusiness?: boolean;
|
|
}): Promise<string> {
|
|
return this.checkoutService.createCheckout(params);
|
|
}
|
|
|
|
async createDonorPortalSession(stripeCustomerId: string): Promise<string> {
|
|
return this.checkoutService.createPortalSession(stripeCustomerId);
|
|
}
|
|
}
|