universo-platform-3d

Форк
0
/
purchase-option.subdocument.schema.ts 
114 строк · 3.8 Кб
1
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
2
import { ApiProperty } from '@nestjs/swagger'
3
import * as mongoose from 'mongoose'
4
import { LICENSE_TYPE } from './license.subdocument.schema'
5

6
export enum CURRENCY_FOR_PURCHASE_OPTION {
7
  USD = 'usd'
8
  // EUR = 'eur' // commented out for now
9
}
10
/**
11
 * @description MIRROR_REV_SHARE is for the Mirror Premium Access subscription, similar to Spotify, where the PLAYER pays TM a monthly fee and then TM gives the creator a cut if the user uses that.
12
 * @date 2023-07-09 17:49
13
 */
14
export enum PURCHASE_OPTION_TYPE {
15
  ONE_TIME = 'ONE_TIME',
16
  ONE_TIME_OPTIONAL_DONATION = 'ONE_TIME_OPTIONAL_DONATION',
17
  /**
18
   * IMPORTANT:
19
   * Spotify model: Charge the players, empower the creators (i.e. we don't charge the creators). Asset creators get paid monthly based on how much their assets are used.
20
   * Player: When a PLAYER has a Mirror Premium subscription, they can access games that use RevShare assets. The creators (both of the game and the assets) are paid monthly out of the pool of Mirror Premium subscription revenue.
21
   * Creator: no change, they can use these assets for FREE. They are paid monthly out of the pool of Mirror Premium subscription revenue when paying players play games that have these assets.
22
   * (Note: If a Space has no RevShare assets, then players can play the game without a premium subscription. If a Space has RevShare assets, then players must have a Mirror Premium subscription to play the game (OR they're shown ads or something else. This is to be determined)
23
   */
24
  MIRROR_REV_SHARE = 'MIRROR_REV_SHARE',
25

26
  SUBSCRIPTION_MONTHLY = 'SUBSCRIPTION_MONTHLY' // the creator is paid monthly. The Mirror takes a cut. We're not doing this right away.
27
}
28

29
/**
30
 * This replaces AssetListing
31
 */
32
export type PurchaseOptionDocument = PurchaseOption & Document
33

34
/**
35
 * This replaces AssetListing and should only be used a SUBdocument ARRAY of something that can be sold, e.g. asset.purchaseOptions?: PurchaseOption[]
36
 */
37
@Schema({
38
  timestamps: true,
39
  toJSON: {
40
    virtuals: true
41
  }
42
})
43
export class PurchaseOption {
44
  /**
45
   * Required fields
46
   */
47
  @Prop({ required: true, default: false, type: Boolean })
48
  @ApiProperty({
49
    required: true,
50
    default: false,
51
    description: 'Whether this purchase option is active',
52
    type: Boolean
53
  })
54
  enabled: boolean
55

56
  @Prop({ required: false, type: Number })
57
  @ApiProperty({
58
    required: true,
59
    description:
60
      'The price in the currency specified in the SMALLEST unit, e.g. cents for USD. See https://stripe.com/docs/currencies',
61
    type: Number
62
  })
63
  price: number
64

65
  @Prop({ required: false, type: String, enum: CURRENCY_FOR_PURCHASE_OPTION })
66
  @ApiProperty({
67
    enum: CURRENCY_FOR_PURCHASE_OPTION,
68
    description: 'The currency used for the Stripe flow',
69
    type: String
70
  })
71
  currency: string
72

73
  @Prop({ required: true, type: 'string', enum: PURCHASE_OPTION_TYPE })
74
  @ApiProperty({
75
    enum: PURCHASE_OPTION_TYPE,
76
    description:
77
      'One-time purchase, subscription, available with Mirror RevShare, etc.',
78
    type: String
79
  })
80
  type: string
81

82
  @Prop({ required: true, type: 'string', enum: LICENSE_TYPE })
83
  @ApiProperty({
84
    enum: LICENSE_TYPE,
85
    description:
86
      'The license for the purchase: Standard, Mirror RevShare subscription, CC0, etc. Note that on entities like Asset, this is the same enum as asset.license.licenseType',
87
    type: String
88
  })
89
  licenseType: string
90

91
  /**
92
   * Optional fields
93
   */
94
  @Prop({
95
    required: false
96
  })
97
  @ApiProperty({ required: false, type: String })
98
  description: string
99

100
  @Prop({ required: false, type: Date })
101
  @ApiProperty({ required: false })
102
  startDate: Date
103

104
  @Prop({ required: false, type: Date })
105
  @ApiProperty({ required: false })
106
  endDate: Date
107

108
  _id: mongoose.Types.ObjectId
109
}
110

111
/**
112
 * This replaces AssetListing
113
 */
114
export const PurchaseOptionSchema = SchemaFactory.createForClass(PurchaseOption)
115

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.