739ef153f6
* docs: improve English naturalness in API v2 documentation - Fix awkward API summary 'Find out when is an event type ready to be booked' to 'Get available time slots for an event type' - Correct 'setup' vs 'set up' usage throughout documentation - Fix OAuth capitalization consistency - Improve 'api' to 'API' capitalization in v2 docs - Enhance readability while preserving technical accuracy Fixes unnatural English phrasing in titles, headers, descriptions, and summaries across API v2 documentation files. Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * docs: add missing articles 'the' in API v2 documentation - Fix 'How to Set Up API' to 'How to Set Up the API' in titles - Add 'the' before 'API' in descriptions and summaries - Fix grammar error 'all you need to is' to 'all you need to do is' - Improve naturalness while maintaining technical accuracy Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * docs: fix unnatural English in API v2 @ApiOperation summaries - Fix grammatically incorrect 'conferencing apps oauths callback' to 'Conferencing app OAuth callback' - Replace 'ooo' with 'out-of-office' in user-facing summaries for clarity - Ensure consistent sentence case capitalization (only first letter capitalized) - Remove trailing periods from summaries for consistency - Fix awkward phrasing like 'Get by attribute id all of...' to more natural English - Revert 'Introduction to the API v2' back to 'Introduction to API v2' - Improve naturalness while maintaining technical accuracy Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * Update apps/api/v2/src/modules/slots/slots-2024-09-04/controllers/slots.controller.ts * Update docs/api-reference/v2/openapi.json * docs: fix setup/set up usage - use 'backend setup' (noun) not 'backend set up' (verb) Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * docs: fix setup/set up verb usage - use 'set up' (verb) not 'setup' (verb) - Fix 'You have to setup' → 'You have to set up' in quickstart.mdx - Fix 'Setup environment variables' → 'Set up environment variables' - Fix 'Setup root of your app' → 'Set up root of your app' - Fix 'prompted to setup' → 'prompted to set up' in setup.mdx Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * Ran v2 locally to regen the doc json files --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
140 lines
5.4 KiB
Plaintext
140 lines
5.4 KiB
Plaintext
---
|
|
title: "Payment form"
|
|
---
|
|
|
|
The Payment form atom is a streamlined interface that integrates with Stripe to facilitate secure payment processing for bookings. It allows users to easily enter their payment information, ensuring a smooth and efficient transaction experience at the time of booking.
|
|
|
|
Below code snippet can be used to render the Payment form atom
|
|
|
|
```js
|
|
import { PaymentForm } from "@calcom/atoms";
|
|
|
|
export default function StripePaymentForm(uid: string) {
|
|
return (
|
|
<>
|
|
<PaymentForm paymentUid={uid} />
|
|
</>
|
|
);
|
|
}
|
|
```
|
|
|
|
For a demonstration of the Payment form, please refer to the video below.
|
|
|
|
<p></p>
|
|
|
|
<iframe
|
|
height="315"
|
|
style={{ width: "100%", maxWidth: "560px" }}
|
|
src="https://www.loom.com/embed/13cf66446b554d5c9405f9d4fef53f47?sid=d2994785-027e-4de7-937a-3b90fc357182"
|
|
frameborder="0"
|
|
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
|
allowfullscreen="true"
|
|
></iframe>
|
|
|
|
<p></p>
|
|
|
|
Below is a list of props that can be passed to the Payment form.
|
|
|
|
<p></p>
|
|
|
|
| Name | Required | Description |
|
|
| :-------------------- | :------- | :----------------------------------------------------------------------- |
|
|
| paymentUid | Yes | The uid of the payment |
|
|
| onPaymentSuccess | No | Callback function to be executed upon successful payment processing |
|
|
| onPaymentCancellation | No | Callback function to be executed upon payment processing failure |
|
|
| onEventTypePaymentInfoSuccess | No | Callback function to be executed when payment information is successfully processed. |
|
|
| onEventTypePaymentInfoFailure | No | Callback function to be executed upon payment information processing failure. |
|
|
|
|
## Combining payment form with event types atom
|
|
|
|
The Payment form atom works best when combined with the event types atom to provide a seamless payment experience. In order to combine payment and event types atom, here are the steps we recommend:
|
|
|
|
<Steps>
|
|
<Step title="Setup stripe in event types atom">
|
|
The event types atom has a payments tab which you can use to connect your stripe account and set up payments info (price, currency, etc.)
|
|
|
|
Below code snippet can be used to setup the event types atom
|
|
|
|
```js
|
|
import { EventTypeSettings } from "@calcom/atoms";
|
|
|
|
export default function EventType(id: number) {
|
|
return (
|
|
<>
|
|
<EventTypeSettings id={id} allowDelete={true} />
|
|
</>
|
|
);
|
|
}
|
|
```
|
|
With this you're all set to accept payments for your bookings.
|
|
</Step>
|
|
<Step title="Use booker atom to access payment uid">
|
|
The booker atom has a prop called `onCreateBookingSuccess` which is a callback function that gets called at the time of a successful booking creation. This function takes a parameter called `data` which contains the payment uid and another property called paymentRequired which can be used to detect if the booking requires payment or not. You can use the payment uid to access the payment form atom.
|
|
|
|
Either store the payment uid in your database, a local state variable or pass it into another page as query parameters.
|
|
|
|
Below code snippet can be used to obtain the payment uid from the booker atom
|
|
|
|
```js
|
|
import { Booker } from "@calcom/atoms";
|
|
|
|
export default function Booker( props : BookerProps ) {
|
|
return (
|
|
<>
|
|
<Booker
|
|
eventSlug={props.eventTypeSlug}
|
|
username={props.calUsername}
|
|
onCreateBookingSuccess={(data) => {
|
|
if (data.data.paymentRequired) {
|
|
// assuming you have set up a separate page for payment with the same path
|
|
// if using nextjs, better to use next/router
|
|
window.location.href = `/payment/${data.data.paymentUid}`;
|
|
}
|
|
}}
|
|
/>
|
|
</>
|
|
)
|
|
}
|
|
```
|
|
</Step>
|
|
<Step title="Set up a page for payments">
|
|
We recommend setting up a separate page for the payment form for the sake of a smooth and streamlined flow, but you can also do it in the same page.
|
|
From the previous step, you get redirected to the payment page when the booking is created. You can now access the payment uid present in the query parameters and render the payment form atom.
|
|
|
|
Below code snippet can be used to obtain the payment uid and pass it to payment form atom.
|
|
|
|
```js
|
|
import { PaymentForm } from "@calcom/atoms";
|
|
|
|
export default function StripePaymentForm() {
|
|
// if using nextjs, better to use the usePathname hook
|
|
const pathname = window.location.pathname;
|
|
const uid = pathname.split("/").pop();
|
|
|
|
return (
|
|
<>
|
|
<PaymentForm paymentUid={uid} />
|
|
</>
|
|
);
|
|
}
|
|
```
|
|
</Step>
|
|
</Steps>
|
|
|
|
Below video shows a demonstration of how we combined the event types atom and payment form in one of our of our example app to create a seamless payment experience.
|
|
|
|
<p></p>
|
|
|
|
<iframe
|
|
height="315"
|
|
style={{ width: "100%", maxWidth: "560px" }}
|
|
src="https://www.loom.com/embed/0c1bc59da8c34d83b8dfcbd7557f7eaa?sid=058cf5df-1e3a-4fe3-b721-8c5a9eac4f24"
|
|
frameborder="0"
|
|
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
|
allowfullscreen="true"
|
|
></iframe>
|
|
|
|
<p></p>
|
|
|
|
<Info>Link to the example app can be found [here](https://github.com/calcom/cal.com/tree/main/packages/platform/examples/base)</Info>
|