<!-- ZenPays documentation · https://docs.zenpayz.com/docs/rest-api/endpoints/billing/payment-links/pay-payment-link -->

# Pay Payment Link

Initiate payment for a payment link. Creates a payment intent that the customer can use to complete the payment.

:::note
This is a **public endpoint** — no authentication headers are required.
:::

<EndpointHeader verb="POST" path="/merchant/api/v1/payment-links/:linkId/pay" />

## Request

### Path Parameters

<ParamTable
  rows={[
    { name: "linkId", type: "string", required: true, desc: "The payment link ID (e.g. `pl_a1b2c3d4e5f6g7h8`)" },
  ]}
/>

### Body Parameters

<ParamTable
  rows={[
    { name: "customerEmail", type: "string", desc: "Customer email address" },
  ]}
/>

## Response

### Success (200 OK)

```json
{
  "success": true,
  "data": {
    "linkId": "pl_a1b2c3d4e5f6g7h8",
    "paymentIntentId": "pi_x1y2z3w4v5u6t7s8",
    "amount": 4999,
    "currency": "INR",
    "checkoutUrl": "https://checkout.zenpayz.com/pay/pi_x1y2z3w4v5u6t7s8"
  },
  "message": "Payment initiated successfully",
  "error": null,
  "meta": {
    "request_id": "req_xxxxx",
    "timestamp": "2024-01-15T10:30:00.000Z",
    "processing_time_ms": 130,
    "api_version": "v1",
    "endpoint": "POST /payment-links/:linkId/pay",
    "user_type": "merchant"
  }
}
```

### Error Responses

<ErrorTable
  rows={[
    { code: "PAYMENT_LINK_NOT_FOUND", status: "404", message: "Payment link does not exist" },
    { code: "PAYMENT_LINK_EXPIRED", status: "410", message: "Payment link has expired" },
    { code: "PAYMENT_LINK_INACTIVE", status: "410", message: "Payment link is inactive" },
    { code: "PAYMENT_LINK_MAX_USES_REACHED", status: "409", message: "Payment link has reached its maximum number of uses" },
  ]}
/>

<CodeRail>

## Examples

<Tabs groupId="language">
  <TabItem value="curl" label="cURL" default>

```bash
curl -X POST https://api.zenpayz.com/merchant/api/v1/payment-links/pl_a1b2c3d4e5f6g7h8/pay \
  -H "Content-Type: application/json" \
  -d '{
    "customerEmail": "john@example.com"
  }'
```

  </TabItem>
  <TabItem value="javascript" label="JavaScript">

```javascript
const response = await fetch('https://api.zenpayz.com/merchant/api/v1/payment-links/pl_a1b2c3d4e5f6g7h8/pay', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    customerEmail: 'john@example.com',
  }),
});

const result = await response.json();
console.log(result.data.checkoutUrl); // Redirect customer to this URL
```

  </TabItem>
  <TabItem value="sdk" label="SDK">

```javascript
const payment = await zenpays.paymentLinks.pay('pl_a1b2c3d4e5f6g7h8', {
  customerEmail: 'john@example.com',
});

console.log(payment.checkoutUrl); // Redirect customer to this URL
```

  </TabItem>
</Tabs>

</CodeRail>

## Related Endpoints

- [Resolve Short Code](/docs/rest-api/endpoints/billing/payment-links/resolve-short-code)
- [Get Payment Link](/docs/rest-api/endpoints/billing/payment-links/get-payment-link)
- [Create Payment Link](/docs/rest-api/endpoints/billing/payment-links/create-payment-link)
