File

apps/recallassess/recallassess-api/src/api/shared/stripe/dto/payment.dto.ts

Description

Checkout session response

Index

Properties

Properties

publishable_key
Type : string
Decorators :
@Expose()
session_id
Type : string
Decorators :
@Expose()
session_url
Type : string
Decorators :
@Expose()
import { Exclude, Expose, Type } from "class-transformer";
import { IsEmail, IsNumber, IsOptional, IsString, Min } from "class-validator";

/**
 * Create checkout session request
 */
@Exclude()
export class CreateCheckoutSessionDto {
  @Expose()
  @IsNumber()
  company_id!: number;

  @Expose()
  @IsNumber()
  invoice_id!: number;

  @Expose()
  @IsNumber()
  @Min(50) // Minimum $0.50
  amount!: number; // Amount in cents

  @Expose()
  @IsString()
  @IsOptional()
  currency?: string = "usd";

  @Expose()
  @IsEmail()
  @IsOptional()
  customer_email?: string;

  @Expose()
  @IsString()
  @IsOptional()
  participant_id?: string;

  @Expose()
  @IsString()
  @IsOptional()
  success_url?: string;

  @Expose()
  @IsString()
  @IsOptional()
  cancel_url?: string;
}

/**
 * Checkout session response
 */
@Exclude()
export class CheckoutSessionResponseDto {
  @Expose()
  session_id!: string;

  @Expose()
  session_url!: string;

  @Expose()
  publishable_key!: string;
}

/**
 * Get Stripe publishable key
 */
@Exclude()
export class StripePublishableKeyDto {
  @Expose()
  publishable_key!: string;
}

/**
 * Create payment intent request (for embedded card form)
 */
@Exclude()
export class CreatePaymentIntentDto {
  @Expose()
  @IsNumber()
  @IsOptional()
  company_id?: number;

  @Expose()
  @IsNumber()
  @IsOptional()
  invoice_id?: number;

  @Expose()
  @Type(() => Number)
  @IsOptional()
  amount?: number; // Amount in cents (>= 0, validated in service)

  @Expose()
  @IsString()
  @IsOptional()
  currency?: string = "usd";

  @Expose()
  @IsEmail()
  @IsOptional()
  customer_email?: string;

  @Expose()
  @IsString()
  @IsOptional()
  customer_name?: string;
}

/**
 * Payment intent response (contains client_secret for frontend)
 * For $0 amounts, this will contain a setup_intent_id instead of payment_intent_id
 */
@Exclude()
export class PaymentIntentResponseDto {
  @Expose()
  client_secret!: string;

  @Expose()
  payment_intent_id?: string; // Only present for paid amounts

  @Expose()
  setup_intent_id?: string; // Only present for $0 amounts (trial packages)

  @Expose()
  publishable_key!: string;

  @Expose()
  stripe_customer_id!: string;

  @Expose()
  is_setup_intent?: boolean; // Flag to indicate if this is a setup intent
}

/**
 * Confirm payment (after card element submission)
 */
@Exclude()
export class ConfirmPaymentDto {
  @Expose()
  @IsString()
  payment_intent_id!: string;

  @Expose()
  @IsNumber()
  invoice_id!: number;
}

results matching ""

    No results matching ""