# 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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://petercheng7788.gitbook.io/developer-note/backend/payment.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
