> For the complete documentation index, see [llms.txt](https://docs.physiqo.in/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.physiqo.in/04-product/prd-3.md).

# Payment

## Payment Module

***

## 1. Purpose

The Payment Module manages the complete payment lifecycle for appointments booked through PhysiQo.

The objective is to ensure secure, reliable and transparent payment processing before physiotherapist assignment.

***

## 2. Business Objectives

The Payment Module shall:

* Collect online payments securely.
* Prevent fake bookings.
* Verify payment automatically.
* Generate invoices.
* Trigger automatic physiotherapist assignment.
* Maintain payment history.
* Support refunds according to platform policy.

***

## 3. Supported Payment Methods

Current

* UPI
* Debit Card
* Credit Card
* Net Banking
* Wallets

Payment Gateway

* Razorpay

Future

* EMI
* International Payments
* Insurance-based Payments

***

## 4. Payment Workflow

1. Booking Details Submitted
2. Payment Link Generated
3. Redirect to Razorpay
4. User Completes Payment
5. Payment Verification
6. Invoice Generation
7. Booking Confirmation
8. Auto Assignment Triggered
9. WhatsApp Confirmation Sent

```mermaid
flowchart TD

A[Booking Created]

A --> B[Generate Razorpay Order]

B --> C[Payment Page]

C --> D{Payment Successful?}

D -->|Yes| E[Verify Signature]

E --> F[Generate Invoice]

F --> G[Trigger Auto Assignment]

G --> H[WhatsApp Confirmation]

D -->|No| I[Payment Failed]
```

***

## 5. Payment Status

Each payment shall have one of the following statuses.

* Created
* Pending
* Successful
* Failed
* Cancelled
* Refunded
* Partially Refunded

***

## 6. Validation Rules

Before accepting payment the platform shall validate:

* Valid Booking
* Valid Amount
* Active User
* Payment Gateway Response
* Duplicate Payment Prevention

***

## 7. Refund Rules

Refunds shall be processed according to the official Refund Policy.

Eligible refund scenarios include:

* Eligible patient cancellation.
* Duplicate payment.
* Payment processing error.
* Platform unable to assign a physiotherapist.

Refund requests shall be recorded and tracked until completion.

***

## 8. Invoice Rules

After successful payment the platform shall automatically generate an invoice.

The invoice shall include:

* Invoice Number
* Booking ID
* Patient Details
* PhysiQo Details
* Payment Amount
* Taxes (if applicable)
* Date & Time

***

## 9. Security Requirements

The Payment Module shall:

* Never store card information.
* Verify payment signatures.
* Maintain encrypted communication.
* Log payment events.
* Prevent duplicate transactions.

***

## 10. Backend Mapping

Controller

* PaymentController

Services

* PaymentService
* InvoiceService
* BookingService

Repositories

* PaymentRepository
* BookingRepository

Entities

* Payment
* Booking
* Invoice

***

## 11. Related Documents

* Booking PRD
* Auto Assignment PRD
* Business Rules
* Refund Policy
* User Journey

***

Status

Draft


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.physiqo.in/04-product/prd-3.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
