Skip to content

Instantly share code, notes, and snippets.

@dyrkow
Last active April 4, 2023 08:11
Show Gist options
  • Save dyrkow/1adbd764e3fe42a50a4a90c5e0e38d4c to your computer and use it in GitHub Desktop.
Save dyrkow/1adbd764e3fe42a50a4a90c5e0e38d4c to your computer and use it in GitHub Desktop.
export enum PaymentMethod {
CASH = 'cash', // hardware
CARD = 'card', // hardware, external
ONLINE = 'online', // shop, external
BONUS = 'bonus', // loyalty
SBP = 'sbp', // payment_service, external
}
export enum PaymentProvider {
HARDWARE = 'hardware', // Оплата производится с помощью втроенного оборудования
SHOP = 'shop', // Оплата произошла на стороне магазина
LOYALTY = 'loyalty', // Оплата бонусами
PAYMENT_SERVICE = 'payment_service', // Оплата через payment service
EXTERNAL = 'external', // Стороннний провайдер, мы проводим операции, но ничего не делаем
}
export enum PaymentStatus {
COMPLETED = 'completed',
CANCELED = 'canceled',
DRAFT = 'draft' // Оплата не произведена, это просто информация на перед
}
export type PaymentCashOptions = { received: Money };
export type PaymentCashlessOptions = { id: string };
export type Payment = {
method: PaymentMethod;
status: PaymentStatus;
provider: PaymentProvider;
value: Money;
}
export type CashPayment = Payment & { options: PaymentCashOptions }
export type CashlessPayment = Payment & { options: PaymentCashlessOptions }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment