feat: license payment

This commit is contained in:
Tristan Yang
2022-09-22 11:41:28 +08:00
parent 953095e5ce
commit 6e0dfc7e3a
12 changed files with 301 additions and 119 deletions
+24
View File
@@ -3,6 +3,30 @@
const BASE_URL = process.env.REACT_APP_RELEASE
? `${location.origin}/api`
: `https://dev.voce.chat/api`;
export const LicensePriceList = [
{
title: "VoceChat Pro",
limit: 100,
pid: "price_1LkICIGGoUDRyc3jqrdPEnkY",
desc: "User Limit: 100"
},
{
title: "VoceChat Supreme",
limit: 99999,
pid: "price_1LkKqdGGoUDRyc3jnpZvXhzx",
desc: "User Limit: No Limit"
}
// {
// title: "VoceChat Enterprise",
// limit: 500,
// // pid: "price_1LkJNsGGoUDRyc3jkVNf4VPE",
// pid: "price_1LkQGpGGoUDRyc3jGTh3GYHw",
// desc: "User Limit: 500"
// }
];
export const PAYMENT_URL_PREFIX = process.env.REACT_APP_RELEASE
? `https://vera.nicegoodthings.com`
: `http://localhost:4000`;
export const CACHE_VERSION = `0.3.1`;
export const GuestRoutes = ["/", "/chat", "/chat/channel/:channel_id"];
export const ContentTypes = {
+19 -3
View File
@@ -1,5 +1,5 @@
import { createApi } from "@reduxjs/toolkit/query/react";
import BASE_URL from "../config";
import BASE_URL, { PAYMENT_URL_PREFIX } from "../config";
import { updateInfo } from "../slices/server";
import baseQuery from "./base.query";
import { RootState } from "../store";
@@ -14,7 +14,9 @@ import {
SMTPConfig,
AgoraConfig,
GithubAuthConfig,
LicenseResponse
LicenseResponse,
RenewLicense,
RenewLicenseResponse
} from "../../types/server";
const defaultExpireDuration = 7 * 24 * 60 * 60;
@@ -195,6 +197,18 @@ export const serverApi = createApi({
})
}),
getLicensePaymentUrl: builder.mutation<RenewLicenseResponse, RenewLicense>({
query: (data) => ({
url: `${PAYMENT_URL_PREFIX}/vocechat/payment/create`,
method: "POST",
body: data
})
}),
getGeneratedLicense: builder.query<{ license: string }, string>({
query: (session_id) => ({
url: `${PAYMENT_URL_PREFIX}/vocechat/licenses/${session_id}`
})
}),
checkLicense: builder.mutation<LicenseResponse, string>({
query: (license) => ({
url: "/license/check",
@@ -241,5 +255,7 @@ export const {
useCreateAdminMutation,
useUpsertLicenseMutation,
useCheckLicenseMutation,
useGetLicenseQuery
useGetLicenseQuery,
useGetLicensePaymentUrlMutation,
useLazyGetGeneratedLicenseQuery
} = serverApi;