# Payments

## Create a payment (agent pays on a customer's behalf)

**post** `/v3/payments`

Advances the pay flow for a connected customer handle and returns a
`status` describing where it is (`needs_connection`, `awaiting_user_action`,
`ready`, ...). A payment `id` appears once a card is minted. Idempotent on
the `Idempotency-Key` header.

### Body Parameters

- `amount_cents: number`

- `currency: string`

- `handle: string`

  Customer phone (E.164) or email.

- `description: optional string`

- `merchant: optional object { name, url }`

  - `name: optional string`

  - `url: optional string`

- `metadata: optional map[string]`

### Returns

- `Payment object { id, amount_cents, approval_url, 5 more }`

  - `id: optional string`

  - `amount_cents: optional number`

  - `approval_url: optional string`

    Present when the customer must approve with a passkey.

  - `attach_url: optional string`

    Present when the customer must attach a card.

  - `currency: optional string`

  - `description: optional string`

  - `handle: optional string`

  - `status: optional "needs_connection" or "connecting" or "awaiting_user_action" or 6 more`

    - `"needs_connection"`

    - `"connecting"`

    - `"awaiting_user_action"`

    - `"ready"`

    - `"authorized"`

    - `"succeeded"`

    - `"declined"`

    - `"canceled"`

    - `"expired"`

### Example

```http
curl https://api.linqapp.com/api/partner/v3/payments \
    -H 'Content-Type: application/json' \
    -H "Authorization: Bearer $LINQ_API_V3_API_KEY" \
    -d '{
          "amount_cents": 2500,
          "currency": "usd",
          "handle": "+14155550123",
          "description": "Burger order"
        }'
```

#### Response

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "amount_cents": 2500,
  "approval_url": "approval_url",
  "attach_url": "attach_url",
  "currency": "usd",
  "description": "description",
  "handle": "+14155550123",
  "status": "ready"
}
```

## Get a payment

**get** `/v3/payments/{paymentId}`

Get a payment

### Path Parameters

- `paymentId: string`

### Returns

- `Payment object { id, amount_cents, approval_url, 5 more }`

  - `id: optional string`

  - `amount_cents: optional number`

  - `approval_url: optional string`

    Present when the customer must approve with a passkey.

  - `attach_url: optional string`

    Present when the customer must attach a card.

  - `currency: optional string`

  - `description: optional string`

  - `handle: optional string`

  - `status: optional "needs_connection" or "connecting" or "awaiting_user_action" or 6 more`

    - `"needs_connection"`

    - `"connecting"`

    - `"awaiting_user_action"`

    - `"ready"`

    - `"authorized"`

    - `"succeeded"`

    - `"declined"`

    - `"canceled"`

    - `"expired"`

### Example

```http
curl https://api.linqapp.com/api/partner/v3/payments/$PAYMENT_ID \
    -H "Authorization: Bearer $LINQ_API_V3_API_KEY"
```

#### Response

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "amount_cents": 2500,
  "approval_url": "approval_url",
  "attach_url": "attach_url",
  "currency": "usd",
  "description": "description",
  "handle": "+14155550123",
  "status": "ready"
}
```

## Cancel a payment

**post** `/v3/payments/{paymentId}/cancel`

Closes the virtual card and cancels the payment.

### Path Parameters

- `paymentId: string`

### Returns

- `Payment object { id, amount_cents, approval_url, 5 more }`

  - `id: optional string`

  - `amount_cents: optional number`

  - `approval_url: optional string`

    Present when the customer must approve with a passkey.

  - `attach_url: optional string`

    Present when the customer must attach a card.

  - `currency: optional string`

  - `description: optional string`

  - `handle: optional string`

  - `status: optional "needs_connection" or "connecting" or "awaiting_user_action" or 6 more`

    - `"needs_connection"`

    - `"connecting"`

    - `"awaiting_user_action"`

    - `"ready"`

    - `"authorized"`

    - `"succeeded"`

    - `"declined"`

    - `"canceled"`

    - `"expired"`

### Example

```http
curl https://api.linqapp.com/api/partner/v3/payments/$PAYMENT_ID/cancel \
    -X POST \
    -H "Authorization: Bearer $LINQ_API_V3_API_KEY"
```

#### Response

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "amount_cents": 2500,
  "approval_url": "approval_url",
  "attach_url": "attach_url",
  "currency": "usd",
  "description": "description",
  "handle": "+14155550123",
  "status": "ready"
}
```

## Get a payment's card-reveal handoff

**get** `/v3/payments/{paymentId}/credentials`

Returns a short-lived handoff for a `ready` payment. Fetch the card
credentials **directly from the provider** with the returned `user_token`
at `fetch_url` — the card number never passes through Linq. Do not persist
PAN/CVC.

### Path Parameters

- `paymentId: string`

### Returns

- `handoff: optional object { card_ref, fetch_url, provider, user_token }`

  Fetch the card directly from the provider with these — never through Linq.

  - `card_ref: optional string`

  - `fetch_url: optional string`

  - `provider: optional string`

  - `user_token: optional string`

    Short-lived bearer to fetch the card from the provider.

### Example

```http
curl https://api.linqapp.com/api/partner/v3/payments/$PAYMENT_ID/credentials \
    -H "Authorization: Bearer $LINQ_API_V3_API_KEY"
```

#### Response

```json
{
  "handoff": {
    "card_ref": "card_7h2k",
    "fetch_url": "https://api.agentcard.sh/api/v2/cards/card_7h2k",
    "provider": "agentcard",
    "user_token": "user_token"
  }
}
```

## Domain Types

### Payment

- `Payment object { id, amount_cents, approval_url, 5 more }`

  - `id: optional string`

  - `amount_cents: optional number`

  - `approval_url: optional string`

    Present when the customer must approve with a passkey.

  - `attach_url: optional string`

    Present when the customer must attach a card.

  - `currency: optional string`

  - `description: optional string`

  - `handle: optional string`

  - `status: optional "needs_connection" or "connecting" or "awaiting_user_action" or 6 more`

    - `"needs_connection"`

    - `"connecting"`

    - `"awaiting_user_action"`

    - `"ready"`

    - `"authorized"`

    - `"succeeded"`

    - `"declined"`

    - `"canceled"`

    - `"expired"`

### Payment Credentials Response

- `PaymentCredentialsResponse object { handoff }`

  - `handoff: optional object { card_ref, fetch_url, provider, user_token }`

    Fetch the card directly from the provider with these — never through Linq.

    - `card_ref: optional string`

    - `fetch_url: optional string`

    - `provider: optional string`

    - `user_token: optional string`

      Short-lived bearer to fetch the card from the provider.
