Skip to content

Commit

Permalink
⚡ (payment) Add description option on Stripe input
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Mar 29, 2023
1 parent 50db998 commit bb45b33
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,68 +28,74 @@ export const PaymentSettings = ({ options, onOptionsChange }: Props) => {
const { workspace } = useWorkspace()
const { isOpen, onOpen, onClose } = useDisclosure()

const handleProviderChange = (provider: PaymentProvider) => {
const updateProvider = (provider: PaymentProvider) => {
onOptionsChange({
...options,
provider,
})
}

const handleCredentialsSelect = (credentialsId?: string) => {
const updateCredentials = (credentialsId?: string) => {
onOptionsChange({
...options,
credentialsId,
})
}

const handleAmountChange = (amount?: string) =>
const updateAmount = (amount?: string) =>
onOptionsChange({
...options,
amount,
})

const handleCurrencyChange = (e: ChangeEvent<HTMLSelectElement>) =>
const updateCurrency = (e: ChangeEvent<HTMLSelectElement>) =>
onOptionsChange({
...options,
currency: e.target.value,
})

const handleNameChange = (name: string) =>
const updateName = (name: string) =>
onOptionsChange({
...options,
additionalInformation: { ...options.additionalInformation, name },
})

const handleEmailChange = (email: string) =>
const updateEmail = (email: string) =>
onOptionsChange({
...options,
additionalInformation: { ...options.additionalInformation, email },
})

const handlePhoneNumberChange = (phoneNumber: string) =>
const updatePhoneNumber = (phoneNumber: string) =>
onOptionsChange({
...options,
additionalInformation: { ...options.additionalInformation, phoneNumber },
})

const handleButtonLabelChange = (button: string) =>
const updateButtonLabel = (button: string) =>
onOptionsChange({
...options,
labels: { ...options.labels, button },
})

const handleSuccessLabelChange = (success: string) =>
const updateSuccessLabel = (success: string) =>
onOptionsChange({
...options,
labels: { ...options.labels, success },
})

const updateDescription = (description: string) =>
onOptionsChange({
...options,
additionalInformation: { ...options.additionalInformation, description },
})

return (
<Stack spacing={4}>
<Stack>
<Text>Provider:</Text>
<DropdownList
onItemSelect={handleProviderChange}
onItemSelect={updateProvider}
items={Object.values(PaymentProvider)}
currentItem={options.provider}
/>
Expand All @@ -101,15 +107,15 @@ export const PaymentSettings = ({ options, onOptionsChange }: Props) => {
type="stripe"
workspaceId={workspace.id}
currentCredentialsId={options.credentialsId}
onCredentialsSelect={handleCredentialsSelect}
onCredentialsSelect={updateCredentials}
onCreateNewClick={onOpen}
/>
)}
</Stack>
<HStack>
<TextInput
label="Price amount:"
onChange={handleAmountChange}
onChange={updateAmount}
defaultValue={options.amount ?? ''}
placeholder="30.00"
/>
Expand All @@ -118,7 +124,7 @@ export const PaymentSettings = ({ options, onOptionsChange }: Props) => {
<Select
placeholder="Select option"
value={options.currency}
onChange={handleCurrencyChange}
onChange={updateCurrency}
>
{currencies.map((currency) => (
<option value={currency.code} key={currency.code}>
Expand All @@ -130,13 +136,13 @@ export const PaymentSettings = ({ options, onOptionsChange }: Props) => {
</HStack>
<TextInput
label="Button label:"
onChange={handleButtonLabelChange}
onChange={updateButtonLabel}
defaultValue={options.labels.button}
placeholder="Pay"
/>
<TextInput
label="Success message:"
onChange={handleSuccessLabelChange}
onChange={updateSuccessLabel}
defaultValue={options.labels.success ?? 'Success'}
placeholder="Success"
/>
Expand All @@ -147,22 +153,28 @@ export const PaymentSettings = ({ options, onOptionsChange }: Props) => {
<AccordionIcon />
</AccordionButton>
<AccordionPanel pb={4} as={Stack} spacing="6">
<TextInput
label="Description:"
defaultValue={options.additionalInformation?.description ?? ''}
onChange={updateDescription}
placeholder="A digital product"
/>
<TextInput
label="Name:"
defaultValue={options.additionalInformation?.name ?? ''}
onChange={handleNameChange}
onChange={updateName}
placeholder="John Smith"
/>
<TextInput
label="Email:"
defaultValue={options.additionalInformation?.email ?? ''}
onChange={handleEmailChange}
onChange={updateEmail}
placeholder="john@gmail.com"
/>
<TextInput
label="Phone number:"
defaultValue={options.additionalInformation?.phoneNumber ?? ''}
onChange={handlePhoneNumberChange}
onChange={updatePhoneNumber}
placeholder="+33XXXXXXXXX"
/>
</AccordionPanel>
Expand All @@ -172,7 +184,7 @@ export const PaymentSettings = ({ options, onOptionsChange }: Props) => {
<StripeConfigModal
isOpen={isOpen}
onClose={onClose}
onNewCredentials={handleCredentialsSelect}
onNewCredentials={updateCredentials}
/>
</Stack>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const createStripePaymentIntent =
amount,
currency: options.currency,
receipt_email: receiptEmail === '' ? undefined : receiptEmail,
description: options.additionalInformation?.description,
automatic_payment_methods: {
enabled: true,
},
Expand Down
1 change: 1 addition & 0 deletions packages/schemas/features/blocks/inputs/payment/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const paymentInputOptionsSchema = optionBaseSchema.merge(
}),
additionalInformation: z
.object({
description: z.string().optional(),
name: z.string().optional(),
email: z.string().optional(),
phoneNumber: z.string().optional(),
Expand Down

4 comments on commit bb45b33

@vercel
Copy link

@vercel vercel bot commented on bb45b33 Mar 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on bb45b33 Mar 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

docs – ./apps/docs

docs-git-main-typebot-io.vercel.app
docs.typebot.io
docs-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on bb45b33 Mar 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

viewer-v2 – ./apps/viewer

1stop.au
yobot.me
klujo.com
me.cr8.ai
247987.com
8jours.top
aginap.com
ai.mprs.in
bee.cr8.ai
bot.aws.bj
bot.bbc.bj
cat.cr8.ai
finplex.be
nepkit.com
pig.cr8.ai
sat.cr8.ai
bot.aipr.kr
bot.joof.it
bull.cr8.ai
docs.cr8.ai
minipost.uk
mole.cr8.ai
team.cr8.ai
wolf.cr8.ai
ai.meant.com
bot.grace.bj
cinecorn.com
help.taxt.co
kusamint.com
rhino.cr8.ai
sheep.cr8.ai
snake.cr8.ai
svhm.mprs.in
tiger.cr8.ai
video.cr8.ai
yoda.riku.ai
zebra.cr8.ai
bergamo.store
bot.krdfy.com
bot.tvbeat.it
cgcassets.com
cnvhub.com.br
facelabko.com
filmylogy.com
goldorayo.com
rabbit.cr8.ai
clo.closeer.work
cockroach.cr8.ai
faqs.nigerias.io
form.syncwin.com
haymanevents.com
kw.wpwakanda.com
myrentalhost.com
stan.vselise.com
start.taxtree.io
typebot.aloe.bot
voicehelp.cr8.ai
zap.fundviser.in
app.bouclidom.com
app.chatforms.net
bot.seidinembroseanchetu.it
chat.semanalimpanome.com.br
designguide.techyscouts.com
liveconvert2.kandalearn.com
presente.empresarias.com.mx
register.algorithmpress.com
sell.sellthemotorhome.co.uk
anamnese.odontopavani.com.br
austin.channelautomation.com
bot.marketingplusmindset.com
bot.seidibergamoseanchetu.it
desabafe.sergiolimajr.com.br
download.venturemarketing.in
piazzatorre.barrettamario.it
type.cookieacademyonline.com
upload.atlasoutfittersk9.com
bot.brigadeirosemdrama.com.br
forms.escoladeautomacao.com.br
onboarding.libertydreamcare.ie
type.talitasouzamarques.com.br
agendamento.sergiolimajr.com.br
anamnese.clinicamegasjdr.com.br
bookings.littlepartymonkeys.com
bot.comercializadoraomicron.com
elevateyourmind.groovepages.com
viewer-v2-typebot-io.vercel.app
yourfeedback.comebackreward.com
bot.cabin-rentals-of-georgia.net
gerador.verificadordehospedes.com
personal-trainer.barrettamario.it
preagendamento.sergiolimajr.com.br
studiotecnicoimmobiliaremerelli.it
download.thailandmicespecialist.com
register.thailandmicespecialist.com
bot.studiotecnicoimmobiliaremerelli.it
pesquisa.escolamodacomproposito.com.br
anamnese.clinicaramosodontologia.com.br
chrome-os-inquiry-system.itschromeos.com
viewer-v2-git-main-typebot-io.vercel.app
main-menu-for-itschromeos.itschromeos.com

@vercel
Copy link

@vercel vercel bot commented on bb45b33 Mar 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

builder-v2-typebot-io.vercel.app
builder-v2-git-main-typebot-io.vercel.app
app.typebot.io

Please sign in to comment.