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

# Hosted payin

> The customer is redirected to the LigdiCash payment page. The simplest method to integrate, compatible with all supported operators.

Hosted payin is the fastest integration method. You create an invoice via the API, retrieve a payment link, and redirect your customer to the page hosted by LigdiCash. The customer chooses their operator, completes their payment, and is sent back to your site. You do not have to manage the payment interface.

This method works on the web as well as in **native mobile applications**: the payment link opens in a WebView, and you detect the customer's return by listening to URL changes.

## How it works

<Steps>
  <Step title="Create the invoice">
    You call `POST /pay/v01/redirect/checkout-invoice/create` with the order details. LigdiCash returns a `token` and a payment link in `response_text`.
  </Step>

  <Step title="Redirect the customer">
    You open the payment link in the same tab, a new tab, or a popup. The customer lands on the LigdiCash payment page where they choose their mobile money operator.
  </Step>

  <Step title="The customer pays">
    The customer enters their number and validates the payment following their operator's instructions. LigdiCash fully handles this step.
  </Step>

  <Step title="Notification and redirect">
    LigdiCash sends a callback to your `callback_url` and redirects the customer to your `return_url` (success) or `cancel_url` (cancellation).
  </Step>
</Steps>

```mermaid theme={null}
sequenceDiagram
    actor Customer
    participant Frontend as Your frontend
    participant Backend as Your backend
    participant LC as LigdiCash

    Customer->>Frontend: Triggers a payment
    Frontend->>Backend: POST /api/payment/initiate
    Backend->>LC: POST /checkout-invoice/create
    LC-->>Backend: token + pay_url
    Backend->>Backend: Store the token in DB
    Backend-->>Frontend: pay_url
    Frontend->>Customer: Opens pay_url

    Note over Customer,LC: The customer chooses their operator and pays on the LigdiCash page

    par Simultaneously
        LC-->>Customer: Redirects to return_url
    and
        LC->>Backend: POST /callback_url
    end
    Backend->>LC: GET /confirm/?invoiceToken={stored_token}
    LC-->>Backend: status
    Backend->>Backend: Updates the order
```

## Important constraints

<Warning>
  Iframes are blocked by LigdiCash. The payment link must open in the same tab, a new tab, a popup, or a native WebView on mobile — never in an iframe.
</Warning>

<Warning>
  The `customer` field must remain empty (`""`). If you fill it with a phone number, LigdiCash filters the payment page to only show operators matching that number, hiding the others.
</Warning>

## In this section

<CardGroup cols={2}>
  <Card title="Create an invoice" icon="file-invoice" href="/en/payment-api/hosted-payin/create-invoice">
    Parameters, full payload, and response of the create endpoint
  </Card>

  <Card title="Redirect the customer" icon="arrow-up-right" href="/en/payment-api/hosted-payin/redirect-customer">
    Opening the payment link: same tab, popup, WebView
  </Card>

  <Card title="Verify the status" icon="circle-check" href="/en/payment-api/hosted-payin/verify-status">
    Call the confirm endpoint with the creation token
  </Card>

  <Card title="Mobile integration" icon="mobile" href="/en/payment-api/hosted-payin/mobile-integration">
    Open the link in a native WebView and detect the return
  </Card>

  <Card title="Common pitfalls" icon="triangle-exclamation" href="/en/payment-api/hosted-payin/common-pitfalls">
    Iframe, empty customer, popup blocking — the frequent errors
  </Card>
</CardGroup>
