2
0

feat(editor): Payment input

This commit is contained in:
Baptiste Arnaud
2022-05-24 14:25:15 -07:00
parent 91ea637a08
commit 3a6ca3dbde
35 changed files with 1516 additions and 52 deletions

View File

@ -1,12 +1,16 @@
import { Credentials as CredentialsFromPrisma } from 'db'
export type Credentials = SmtpCredentials | GoogleSheetsCredentials
export type Credentials =
| SmtpCredentials
| GoogleSheetsCredentials
| StripeCredentials
export type CredentialsBase = Omit<CredentialsFromPrisma, 'data' | 'type'>
export enum CredentialsType {
GOOGLE_SHEETS = 'google sheets',
SMTP = 'smtp',
STRIPE = 'stripe',
}
export type SmtpCredentials = CredentialsBase & {
@ -19,6 +23,11 @@ export type GoogleSheetsCredentials = CredentialsBase & {
data: GoogleSheetsCredentialsData
}
export type StripeCredentials = CredentialsBase & {
type: CredentialsType.STRIPE
data: StripeCredentialsData
}
export type GoogleSheetsCredentialsData = {
refresh_token?: string | null
expiry_date?: number | null
@ -36,3 +45,14 @@ export type SmtpCredentialsData = {
port: number
from: { email?: string; name?: string }
}
export type StripeCredentialsData = {
live: {
secretKey: string
publicKey: string
}
test?: {
secretKey?: string
publicKey?: string
}
}

View File

@ -9,6 +9,7 @@ export type InputStep =
| DateInputStep
| PhoneNumberInputStep
| ChoiceInputStep
| PaymentInputStep
export enum InputStepType {
TEXT = 'text input',
@ -18,6 +19,7 @@ export enum InputStepType {
DATE = 'date input',
PHONE = 'phone number input',
CHOICE = 'choice input',
PAYMENT = 'payment input',
}
export type InputStepOptions =
@ -28,6 +30,7 @@ export type InputStepOptions =
| UrlInputOptions
| PhoneNumberInputOptions
| ChoiceInputOptions
| PaymentInputOptions
export type TextInputStep = StepBase & {
type: InputStepType.TEXT
@ -70,6 +73,18 @@ export type ButtonItem = ItemBase & {
content?: string
}
export type PaymentInputStep = StepBase & {
type: InputStepType.PAYMENT
options: PaymentInputOptions
}
export type CreditCardDetails = {
number: string
exp_month: string
exp_year: string
cvc: string
}
type OptionBase = { variableId?: string }
type InputTextOptionsBase = {
@ -115,6 +130,23 @@ export type NumberInputOptions = OptionBase &
step?: number
}
export enum PaymentProvider {
STRIPE = 'Stripe',
}
export type PaymentInputOptions = OptionBase & {
provider: PaymentProvider
amount?: string
currency: string
credentialsId?: string
additionalInformation?: {
name?: string
email?: string
phoneNumber?: string
}
labels: { button: string }
}
const defaultButtonLabel = 'Send'
export const defaultTextInputOptions: TextInputOptions = {
@ -163,3 +195,9 @@ export const defaultChoiceInputOptions: ChoiceInputOptions = {
buttonLabel: defaultButtonLabel,
isMultipleChoice: false,
}
export const defaultPaymentInputOptions: PaymentInputOptions = {
provider: PaymentProvider.STRIPE,
labels: { button: 'Pay' },
currency: 'USD',
}