> ## Documentation Index
> Fetch the complete documentation index at: https://developer.transactbridge.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Payment link

One-Time Payment Link Flow

You can generate a unique payment link for a customer using the Create Order / Payment API. This works similarly to payment link providers like Cashfree, where a secure checkout URL is generated and shared with the customer.

## Workflow

1. The merchant creates a session by calling the [**Create Session API**](https://docs.transactbridge.com/#d4607171-457b-4d24-8277-6d9a79a997dd) from the backend.

2. Create Session API in return gives a **unique session ID** and a **redirect URL**.

3. The merchant uses the returned **redirect URL** to redirect the user to the payment page. Or can use the same **redirect url as the Payment Link** and shares it with the customer through email, SMS, WhatsApp, or any other communication channel.

4. The customer lands to  **Transact Bridge hosted checkout page**, where the customer enters their payment details and completes the payment.

5. Once the payment is completed, Transact Bridge processes the payment and updates the session and transaction status.

6. Customer is redirected to the **return url** provided in the create session API call. The return URL can be a success page or a failure page based on the payment status.

7. If the payment is successful and the invoice is generated, the session moves to **CLOSED** state.

8. If the payment/transaction is unsuccessful, the session remains in **STARTED** state.

9. Transact Bridge triggers a [**Webhook**](https://docs.transactbridge.com/#5ff84b04-3f5d-4e85-a7c8-2c07e1e65536) to the server URL configured by the merchant. The webhook contains the relevant session and payment event information.

10. For the successfull transactions an **invoice is generated** by Transact Bridge and sent to the customer.

<Note>
  * In case the payment fails, TB does not mark the session as FAILED OR CLOSED and allows **multiple transactions** until there is a successful transaction on that session. The customer can retry the transaction within the **same session**.
</Note>

<Note>
  * In case the payment fails, the customer can retry the payment from the **same checkout session/payment link**, subject to the configured session and payment validity.
  * The merchant should always verify the final payment status through the **webhook** before fulfilling the order or providing the purchased service.
  * The payment link should be treated as a secure checkout URL and should be shared only with the intended customer.
</Note>

## Payment Flow

```mermaid theme={null}
sequenceDiagram
    autonumber

    actor User
    participant A as Merchant Website
    participant B as Merchant Server
    participant C as TB Server
    participant D as TB Hosted Checkout

    User->>A: Clicks on payment button

    A->>B: Request payment/order creation
    B->>C: Create order / payment request
    C-->>B: Returns Order ID and payment URL
    B-->>A: Returns payment URL

    A->>D: Redirects to TB Hosted Checkout

    User->>D: Enters payment details
    User->>D: Attempts payment

    Note over C,D: TB processes the payment

    C-->>B: Sends payment webhook
    D-->>A: Redirects to return URL

    B->>B: Updates order/payment status
```
