> ## 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

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

## Subscription Payment link Flow

1. The merchant creates a subscription by calling the [**Create Subscription API**](https://docs.transactbridge.com/#307dc665-ae10-4e43-8853-5b7f04961825) from the backend.

2. Create subs API in return gives a **unique subscription 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 subscription and transaction status.

6. Customer is redirected to the **return url** provided in the create subscription 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:
   * The subscription moves to **ACTIVE** state.
   * The customer gets access to the subscribed service according to the subscription configuration.

8. If the payment is unsuccessful, the subscription/payment remains unsuccessful and the appropriate payment status is returned.

9. Transact Bridge triggers a [**Webhook**](https://docs.transactbridge.com/#9d2ada6b-d973-4ec6-8552-bc3da0a5cef7) to the server URL configured by the merchant. The webhook contains the relevant subscription and payment event information.

10. Based on the subscription configuration, an **invoice is generated** by Transact Bridge and sent to the customer.

<Note>
  * In case the payment fails, TB does not mark the subscription as inactive and allows **multiple transactions** until there is a successful transaction on that session. The customer can retry the transaction within the **same session**.
</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 order creation
   B->>C: Create order / payment request
   C-->>B: Returns payment URL
   B-->>A: Returns payment URL
  

   A->>D: Redirects to TB Hosted checkout
 

   User->>D: Attempts payment
   
   Note over B,C: TB processes the payment

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

```
