> For the complete documentation index, see [llms.txt](https://petercheng7788.gitbook.io/developer-note/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://petercheng7788.gitbook.io/developer-note/backend/payment.md).

# Payment

## General Flow

![](https://1374779285-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFW3x2aqEO8GF2kr3VU%2Fuploads%2FrHjYEIvxgV8XyoRCrLOX%2Fscreenshot-www.udemy.com-2022.11.13-15_42_05.png?alt=media\&token=bfe1f9e8-b789-4561-9bc3-f6eea95a5e12)

* In general, we can obtain user payment information by user input on client-side
* However, validate the card information and charging requires heavy-work, it will be handled by payment gateway of third party
* Finally, third-party return the success/error status, it is times to take the follow-up action

## Stripe Flow

* At the beginning, the session id or client id will be generated from server by using stripe API based on the the items selected , to make sure this transaction is only be charged once
* After received session id or client id, this will be passed by client-side to stripe with payment information that user enter in order to perform validation and charging
* After finished, get back the payment status from stripe to do follow-up action

## Checkout Flow Type

* There are 2 types  - prebuilt flow and custom flow
* Prebuilt - The payment form is built by stripe
* Custom - Our customized payment form
