2025-05-14 21:45:16 +02:00

206 lines
5.8 KiB
TypeScript

import { registerEnumType, ObjectType, Field, InputType, Int } from 'type-graphql';
import { StripePaymentIntentData } from './stripe.components';
import { BillingAddressComponent } from './components';
/*
███████╗███╗ ██╗██╗ ██╗███╗ ███╗
██╔════╝████╗ ██║██║ ██║████╗ ████║
█████╗ ██╔██╗ ██║██║ ██║██╔████╔██║
██╔══╝ ██║╚██╗██║██║ ██║██║╚██╔╝██║
███████╗██║ ╚████║╚██████╔╝██║ ╚═╝ ██║
╚══════╝╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝
*/
export enum cardTypeEnum {
'alipay' = 'alipay',
'au_becs_debit' = 'au_becs_debit',
'bacs_debit' = 'bacs_debit',
'bancontact' = 'bancontact',
'card' = 'card',
'eps' = 'eps',
'fpx' = 'fpx',
'giropay' = 'giropay',
'ideal' = 'ideal',
'p24' = 'p24',
'sepa_debit' = 'sepa_debit',
'sofort' = 'sofort',
}
registerEnumType(cardTypeEnum, {
name: 'cardTypeEnum',
});
export enum cardBrandEnum {
amex = 'amex',
diners = 'diners',
discover = 'discover',
jcb = 'jcb',
mastercard = 'mastercard',
unionpay = 'unionpay',
visa = 'visa',
unknown = 'unknown',
}
registerEnumType(cardBrandEnum, {
name: 'cardBrandEnum',
});
export enum PaymentStatusEnum {
pending = 'pending',
actionNeeded = 'actionNeeded',
paid = 'paid',
free = 'free',
}
registerEnumType(PaymentStatusEnum, {
name: 'PaymentStatusEnum',
});
export enum PaymentProvider {
free = 'free',
stripe = 'stripe',
bancontact = 'bancontact',
bankWire = 'bankWire',
}
registerEnumType(PaymentProvider, {
name: 'PaymentProvider',
});
export enum CurrencyEnum {
eur = 'eur',
usd = 'usd',
}
registerEnumType(CurrencyEnum, {
name: 'CurrencyEnum',
});
export enum InvoicingProvider {
directInvoice = 'directInvoice',
}
registerEnumType(InvoicingProvider, {
name: 'InvoicingProvider',
});
/*
██████╗ ██████╗ ███╗ ███╗██████╗ ██████╗ ███╗ ██╗███████╗███╗ ██╗████████╗███████╗
██╔════╝██╔═══██╗████╗ ████║██╔══██╗██╔═══██╗████╗ ██║██╔════╝████╗ ██║╚══██╔══╝██╔════╝
██║ ██║ ██║██╔████╔██║██████╔╝██║ ██║██╔██╗ ██║█████╗ ██╔██╗ ██║ ██║ ███████╗
██║ ██║ ██║██║╚██╔╝██║██╔═══╝ ██║ ██║██║╚██╗██║██╔══╝ ██║╚██╗██║ ██║ ╚════██║
╚██████╗╚██████╔╝██║ ╚═╝ ██║██║ ╚██████╔╝██║ ╚████║███████╗██║ ╚████║ ██║ ███████║
╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝╚═╝ ╚═══╝ ╚═╝ ╚══════╝
*/
@ObjectType()
export class StripeInfo {
@Field()
customerId: string;
}
@ObjectType()
export class StripePayoutInfo {
@Field()
accountId: string;
@Field()
chargesEnabled: boolean;
@Field()
payoutsEnabled: boolean;
@Field()
detailsSubmitted: boolean;
}
@ObjectType()
export class CardInfo {
@Field(() => cardBrandEnum)
brand: cardBrandEnum;
@Field()
country: string;
@Field(() => Int)
exp_month: number;
@Field(() => Int)
exp_year: number;
@Field()
last4: string;
}
@ObjectType()
export class PaymentMethodDetail {
@Field()
_id: string;
@Field()
sPayMethodId: string;
@Field()
default: boolean;
@Field()
nameOnCard: string;
@Field(() => cardTypeEnum)
type: cardTypeEnum;
@Field(() => CardInfo, { nullable: true })
cardInfo?: CardInfo;
}
@InputType()
export class PaymentMethodInput {
@Field()
sPayMethodId: string;
@Field()
nameOnCard: string;
@Field({ nullable: true })
default: boolean;
}
@ObjectType()
export class AccountPaymentInfo {
@Field(() => StripeInfo, { nullable: true })
stripeInfo?: StripeInfo;
@Field(() => [PaymentMethodDetail], { nullable: true })
paymentMethods?: PaymentMethodDetail[];
@Field(() => [BillingAddressComponent], { nullable: true })
billingInfos?: BillingAddressComponent[];
}
@ObjectType()
export class AccountPayoutInfo {
@Field(() => StripePayoutInfo, { nullable: true })
stripeInfo?: StripePayoutInfo;
}
@ObjectType()
export class PaymentInfo {
@Field(() => PaymentProvider)
provider: PaymentProvider;
@Field()
transactionId: string;
}
@ObjectType()
export class PaymentIntentInfo {
@Field(() => PaymentProvider)
provider: PaymentProvider;
@Field(() => StripePaymentIntentData)
stripePaymentIntentData?: StripePaymentIntentData;
}
@ObjectType()
export class InvoiceInfo {
@Field(() => InvoicingProvider)
provider: InvoicingProvider;
@Field()
invoiceId: string;
@Field(() => Number)
invoiceNumber: number;
}