export type StripeRedirectStatus = 'succeeded' | 'failed' | 'processing' | 'requires_action' | string;

export function mapStripeErrorMessage(error: { type?: string; message?: string } | null | undefined): string {
  if (!error?.message) {
    return 'Payment failed';
  }

  if (error.type === 'card_error' || error.type === 'validation_error') {
    return error.message;
  }

  return error.message;
}

export function isPaymentComplete(status?: StripeRedirectStatus | null): boolean {
  return status === 'succeeded';
}

export function isPaymentPending(status?: StripeRedirectStatus | null): boolean {
  return status === 'processing' || status === 'requires_action';
}
