- HERENCIA-SIMCO.md actualizado con directivas v3.7 y v3.8 - Actualizaciones de configuracion Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
53 lines
2.9 KiB
TypeScript
53 lines
2.9 KiB
TypeScript
import { OnModuleInit } from '@nestjs/common';
|
|
import { ConfigService } from '@nestjs/config';
|
|
import { Repository } from 'typeorm';
|
|
import Stripe from 'stripe';
|
|
import { Subscription } from '../entities/subscription.entity';
|
|
import { Invoice } from '../entities/invoice.entity';
|
|
import { PaymentMethod } from '../entities/payment-method.entity';
|
|
import { CreateStripeCustomerDto, CreateStripeSubscriptionDto, CreateCheckoutSessionDto, CreateBillingPortalSessionDto } from '../dto/stripe-webhook.dto';
|
|
export declare class StripeService implements OnModuleInit {
|
|
private readonly configService;
|
|
private readonly subscriptionRepo;
|
|
private readonly invoiceRepo;
|
|
private readonly paymentMethodRepo;
|
|
private stripe;
|
|
private readonly logger;
|
|
constructor(configService: ConfigService, subscriptionRepo: Repository<Subscription>, invoiceRepo: Repository<Invoice>, paymentMethodRepo: Repository<PaymentMethod>);
|
|
onModuleInit(): void;
|
|
private ensureStripeConfigured;
|
|
createCustomer(dto: CreateStripeCustomerDto): Promise<Stripe.Customer>;
|
|
getCustomer(customerId: string): Promise<Stripe.Customer | null>;
|
|
findCustomerByTenantId(tenantId: string): Promise<Stripe.Customer | null>;
|
|
updateCustomer(customerId: string, data: Partial<{
|
|
email: string;
|
|
name: string;
|
|
metadata: Record<string, string>;
|
|
}>): Promise<Stripe.Customer>;
|
|
createSubscription(dto: CreateStripeSubscriptionDto): Promise<Stripe.Subscription>;
|
|
getStripeSubscription(subscriptionId: string): Promise<Stripe.Subscription | null>;
|
|
cancelStripeSubscription(subscriptionId: string, options?: {
|
|
immediately?: boolean;
|
|
}): Promise<Stripe.Subscription>;
|
|
updateStripeSubscription(subscriptionId: string, priceId: string): Promise<Stripe.Subscription>;
|
|
createCheckoutSession(dto: CreateCheckoutSessionDto): Promise<Stripe.Checkout.Session>;
|
|
createBillingPortalSession(dto: CreateBillingPortalSessionDto): Promise<Stripe.BillingPortal.Session>;
|
|
attachPaymentMethod(paymentMethodId: string, customerId: string): Promise<Stripe.PaymentMethod>;
|
|
detachPaymentMethod(paymentMethodId: string): Promise<Stripe.PaymentMethod>;
|
|
listPaymentMethods(customerId: string): Promise<Stripe.PaymentMethod[]>;
|
|
setDefaultPaymentMethod(customerId: string, paymentMethodId: string): Promise<Stripe.Customer>;
|
|
constructWebhookEvent(payload: Buffer, signature: string): Stripe.Event;
|
|
handleWebhookEvent(event: Stripe.Event): Promise<void>;
|
|
private syncSubscription;
|
|
private handleSubscriptionDeleted;
|
|
private handleInvoicePaid;
|
|
private handleInvoicePaymentFailed;
|
|
private syncPaymentMethod;
|
|
private handlePaymentMethodDetached;
|
|
private handleCheckoutCompleted;
|
|
private mapStripeStatus;
|
|
listPrices(productId?: string): Promise<Stripe.Price[]>;
|
|
getPrice(priceId: string): Promise<Stripe.Price | null>;
|
|
createSetupIntent(customerId: string): Promise<Stripe.SetupIntent>;
|
|
}
|