🛂 Add new yearly plans and graduated pricing

BREAKING CHANGE: Stripe environment variables have changed. New ones are required. Check out the new Stripe configuration in the
docs.

Closes #457
This commit is contained in:
Baptiste Arnaud
2023-04-13 11:39:10 +02:00
parent 39d0dba18c
commit 2cbf8348c3
33 changed files with 1257 additions and 1399 deletions

View File

@@ -201,15 +201,26 @@ The related environment variables are listed here but you are probably not inter
<details><summary><h4>Stripe</h4></summary>
<p>
| Parameter | Default | Description |
| ---------------------------------- | ------- | --------------------------- |
| NEXT_PUBLIC_STRIPE_PUBLIC_KEY | | Stripe public key |
| STRIPE_SECRET_KEY | | Stripe secret key |
| STRIPE_PRO_PRICE_ID | | Pro plan price id |
| STRIPE_STARTER_PRICE_ID | | Starter plan price id |
| STRIPE_ADDITIONAL_CHATS_PRICE_ID | | Additional chats price id |
| STRIPE_ADDITIONAL_STORAGE_PRICE_ID | | Additional storage price id |
| STRIPE_WEBHOOK_SECRET | | Stripe Webhook secret |
| Parameter | Default | Description |
| --------------------------------------- | ------- | ------------------------------------------- |
| NEXT_PUBLIC_STRIPE_PUBLIC_KEY | | Stripe public key |
| STRIPE_SECRET_KEY | | Stripe secret key |
| STRIPE_STARTER_PRODUCT_ID | | Starter plan product ID |
| STRIPE_STARTER_MONTHLY_PRICE_ID | | Starter monthly plan price id |
| STRIPE_STARTER_YEARLY_PRICE_ID | | Starter yearly plan price id |
| STRIPE_PRO_PRODUCT_ID | | Pro plan product ID |
| STRIPE_PRO_MONTHLY_PRICE_ID | | Pro monthly plan price id |
| STRIPE_PRO_YEARLY_PRICE_ID | | Pro yearly plan price id |
| STRIPE_STARTER_CHATS_MONTHLY_PRICE_ID | | Starter Additional chats monthly price id |
| STRIPE_STARTER_CHATS_YEARLY_PRICE_ID | | Starter Additional chats yearly price id |
| STRIPE_PRO_CHATS_MONTHLY_PRICE_ID | | Pro Additional chats monthly price id |
| STRIPE_PRO_CHATS_YEARLY_PRICE_ID | | Pro Additional chats yearly price id |
| STRIPE_STARTER_STORAGE_MONTHLY_PRICE_ID | | Starter Additional storage monthly price id |
| STRIPE_STARTER_STORAGE_YEARLY_PRICE_ID | | Starter Additional storage yearly price id |
| STRIPE_PRO_STORAGE_MONTHLY_PRICE_ID | | Pro Additional storage monthly price id |
| STRIPE_PRO_STORAGE_YEARLY_PRICE_ID | | Pro Additional storage yearly price id |
| STRIPE_ADDITIONAL_STORAGE_PRICE_ID | | Additional storage price id |
| STRIPE_WEBHOOK_SECRET | | Stripe Webhook secret |
</p></details>

View File

@@ -4382,10 +4382,10 @@
}
}
},
"/billing/subscription": {
"delete": {
"operationId": "mutation.billing.cancelSubscription",
"summary": "Cancel current subscription",
"/billing/subscription/checkout": {
"post": {
"operationId": "mutation.billing.createCheckoutSession",
"summary": "Create checkout session to create a new subscription",
"tags": [
"Billing"
],
@@ -4394,16 +4394,85 @@
"Authorization": []
}
],
"parameters": [
{
"name": "workspaceId",
"in": "query",
"required": true,
"schema": {
"type": "string"
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"email": {
"type": "string"
},
"company": {
"type": "string"
},
"workspaceId": {
"type": "string"
},
"prefilledEmail": {
"type": "string"
},
"currency": {
"type": "string",
"enum": [
"usd",
"eur"
]
},
"plan": {
"type": "string",
"enum": [
"STARTER",
"PRO"
]
},
"returnUrl": {
"type": "string"
},
"additionalChats": {
"type": "number"
},
"additionalStorage": {
"type": "number"
},
"vat": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"value": {
"type": "string"
}
},
"required": [
"type",
"value"
],
"additionalProperties": false
},
"isYearly": {
"type": "boolean"
}
},
"required": [
"email",
"company",
"workspaceId",
"currency",
"plan",
"returnUrl",
"additionalChats",
"additionalStorage",
"isYearly"
],
"additionalProperties": false
}
}
}
],
},
"parameters": [],
"responses": {
"200": {
"description": "Successful response",
@@ -4412,15 +4481,12 @@
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string",
"enum": [
"success"
]
"checkoutUrl": {
"type": "string"
}
},
"required": [
"message"
"checkoutUrl"
],
"additionalProperties": false
}
@@ -4431,7 +4497,9 @@
"$ref": "#/components/responses/error"
}
}
},
}
},
"/billing/subscription": {
"patch": {
"operationId": "mutation.billing.updateSubscription",
"summary": "Update subscription",
@@ -4472,6 +4540,9 @@
"usd",
"eur"
]
},
"isYearly": {
"type": "boolean"
}
},
"required": [
@@ -4479,7 +4550,8 @@
"plan",
"additionalChats",
"additionalStorage",
"currency"
"currency",
"isYearly"
],
"additionalProperties": false
}
@@ -4635,28 +4707,38 @@
"type": "object",
"properties": {
"subscription": {
"type": "object",
"properties": {
"additionalChatsIndex": {
"type": "number"
"anyOf": [
{
"type": "object",
"properties": {
"isYearly": {
"type": "boolean"
},
"currency": {
"type": "string",
"enum": [
"eur",
"usd"
]
},
"cancelDate": {
"type": "string",
"format": "date-time"
}
},
"required": [
"isYearly",
"currency"
],
"additionalProperties": false
},
"additionalStorageIndex": {
"type": "number"
},
"currency": {
"type": "string",
{
"enum": [
"eur",
"usd"
]
"null"
],
"nullable": true
}
},
"required": [
"additionalChatsIndex",
"additionalStorageIndex",
"currency"
],
"additionalProperties": false
]
}
},
"required": [
@@ -4673,119 +4755,6 @@
}
}
},
"/billing/subscription/checkout": {
"post": {
"operationId": "mutation.billing.createCheckoutSession",
"summary": "Create checkout session to create a new subscription",
"tags": [
"Billing"
],
"security": [
{
"Authorization": []
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"email": {
"type": "string"
},
"company": {
"type": "string"
},
"workspaceId": {
"type": "string"
},
"prefilledEmail": {
"type": "string"
},
"currency": {
"type": "string",
"enum": [
"usd",
"eur"
]
},
"plan": {
"type": "string",
"enum": [
"STARTER",
"PRO"
]
},
"returnUrl": {
"type": "string"
},
"additionalChats": {
"type": "number"
},
"additionalStorage": {
"type": "number"
},
"vat": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"value": {
"type": "string"
}
},
"required": [
"type",
"value"
],
"additionalProperties": false
}
},
"required": [
"email",
"company",
"workspaceId",
"currency",
"plan",
"returnUrl",
"additionalChats",
"additionalStorage"
],
"additionalProperties": false
}
}
}
},
"parameters": [],
"responses": {
"200": {
"description": "Successful response",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"checkoutUrl": {
"type": "string"
}
},
"required": [
"checkoutUrl"
],
"additionalProperties": false
}
}
}
},
"default": {
"$ref": "#/components/responses/error"
}
}
}
},
"/billing/usage": {
"get": {
"operationId": "query.billing.getUsage",