# Payment Handles

## Connect a customer handle

`client.PaymentHandles.Connect(ctx, handle) (*PaymentHandleConnection, error)`

**post** `/v3/payments/handles/{handle}/connect`

Starts connecting a customer (by phone/email) so an agent can pay on
their behalf. Linq drives the OTP + consent ceremony through the
messaging channel; this returns `pending` and a `connection.created`
webhook fires once the customer completes it.

### Parameters

- `handle string`

### Returns

- `type PaymentHandleConnection struct{…}`

  - `ConnectID string`

    Returned only by `connect`, and only while the ceremony is pending.
    Nothing on our side persists it — it comes back from the provider and
    is required again to verify — so hold it until you submit the code.

  - `Handle string`

  - `Status PaymentHandleConnectionStatus`

    - `const PaymentHandleConnectionStatusNotConnected PaymentHandleConnectionStatus = "not_connected"`

    - `const PaymentHandleConnectionStatusPending PaymentHandleConnectionStatus = "pending"`

    - `const PaymentHandleConnectionStatusConnected PaymentHandleConnectionStatus = "connected"`

    - `const PaymentHandleConnectionStatusRevoked PaymentHandleConnectionStatus = "revoked"`

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/linq-team/linq-go"
  "github.com/linq-team/linq-go/option"
)

func main() {
  client := linqgo.NewClient(
    option.WithAPIKey("My API Key"),
  )
  paymentHandleConnection, err := client.PaymentHandles.Connect(context.TODO(), "handle")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", paymentHandleConnection.ConnectID)
}
```

#### Response

```json
{
  "connect_id": "cs_01HZY8",
  "handle": "+14155550123",
  "status": "connected"
}
```

## Submit a customer's one-time code

`client.PaymentHandles.Verify(ctx, handle, body) (*PaymentHandleConnection, error)`

**post** `/v3/payments/handles/{handle}/verify`

Completes the ceremony `connect` started: verifies the code, records the
customer's consent, and stores the connection. Returns `connected` on
success, after which payments for this handle no longer need the
customer present.

The code reaches you however your channel works — typically the customer
replies with it in the thread. Codes are single-use and short-lived; if
one has expired, call `connect` again for a fresh `connect_id`.

### Parameters

- `handle string`

- `body PaymentHandleVerifyParams`

  - `Code param.Field[string]`

    The one-time code the customer received.

  - `ConnectID param.Field[string]`

    The id returned by `connect`.

### Returns

- `type PaymentHandleConnection struct{…}`

  - `ConnectID string`

    Returned only by `connect`, and only while the ceremony is pending.
    Nothing on our side persists it — it comes back from the provider and
    is required again to verify — so hold it until you submit the code.

  - `Handle string`

  - `Status PaymentHandleConnectionStatus`

    - `const PaymentHandleConnectionStatusNotConnected PaymentHandleConnectionStatus = "not_connected"`

    - `const PaymentHandleConnectionStatusPending PaymentHandleConnectionStatus = "pending"`

    - `const PaymentHandleConnectionStatusConnected PaymentHandleConnectionStatus = "connected"`

    - `const PaymentHandleConnectionStatusRevoked PaymentHandleConnectionStatus = "revoked"`

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/linq-team/linq-go"
  "github.com/linq-team/linq-go/option"
)

func main() {
  client := linqgo.NewClient(
    option.WithAPIKey("My API Key"),
  )
  paymentHandleConnection, err := client.PaymentHandles.Verify(
    context.TODO(),
    "handle",
    linqgo.PaymentHandleVerifyParams{
      Code: "482913",
      ConnectID: "cs_01HZY8",
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", paymentHandleConnection.ConnectID)
}
```

#### Response

```json
{
  "connect_id": "cs_01HZY8",
  "handle": "+14155550123",
  "status": "connected"
}
```

## Get a handle's connection status

`client.PaymentHandles.Connection(ctx, handle) (*PaymentHandleConnection, error)`

**get** `/v3/payments/handles/{handle}/connection`

Get a handle's connection status

### Parameters

- `handle string`

### Returns

- `type PaymentHandleConnection struct{…}`

  - `ConnectID string`

    Returned only by `connect`, and only while the ceremony is pending.
    Nothing on our side persists it — it comes back from the provider and
    is required again to verify — so hold it until you submit the code.

  - `Handle string`

  - `Status PaymentHandleConnectionStatus`

    - `const PaymentHandleConnectionStatusNotConnected PaymentHandleConnectionStatus = "not_connected"`

    - `const PaymentHandleConnectionStatusPending PaymentHandleConnectionStatus = "pending"`

    - `const PaymentHandleConnectionStatusConnected PaymentHandleConnectionStatus = "connected"`

    - `const PaymentHandleConnectionStatusRevoked PaymentHandleConnectionStatus = "revoked"`

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/linq-team/linq-go"
  "github.com/linq-team/linq-go/option"
)

func main() {
  client := linqgo.NewClient(
    option.WithAPIKey("My API Key"),
  )
  paymentHandleConnection, err := client.PaymentHandles.Connection(context.TODO(), "handle")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", paymentHandleConnection.ConnectID)
}
```

#### Response

```json
{
  "connect_id": "cs_01HZY8",
  "handle": "+14155550123",
  "status": "connected"
}
```

## Revoke a handle's connection

`client.PaymentHandles.Revoke(ctx, handle) (*PaymentHandleConnection, error)`

**delete** `/v3/payments/handles/{handle}/connection`

Revokes this partner's grant for the customer. Only your grant is
removed; the customer's wallet at the provider is untouched.

### Parameters

- `handle string`

### Returns

- `type PaymentHandleConnection struct{…}`

  - `ConnectID string`

    Returned only by `connect`, and only while the ceremony is pending.
    Nothing on our side persists it — it comes back from the provider and
    is required again to verify — so hold it until you submit the code.

  - `Handle string`

  - `Status PaymentHandleConnectionStatus`

    - `const PaymentHandleConnectionStatusNotConnected PaymentHandleConnectionStatus = "not_connected"`

    - `const PaymentHandleConnectionStatusPending PaymentHandleConnectionStatus = "pending"`

    - `const PaymentHandleConnectionStatusConnected PaymentHandleConnectionStatus = "connected"`

    - `const PaymentHandleConnectionStatusRevoked PaymentHandleConnectionStatus = "revoked"`

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/linq-team/linq-go"
  "github.com/linq-team/linq-go/option"
)

func main() {
  client := linqgo.NewClient(
    option.WithAPIKey("My API Key"),
  )
  paymentHandleConnection, err := client.PaymentHandles.Revoke(context.TODO(), "handle")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", paymentHandleConnection.ConnectID)
}
```

#### Response

```json
{
  "connect_id": "cs_01HZY8",
  "handle": "+14155550123",
  "status": "connected"
}
```

## Domain Types

### Payment Handle Connection

- `type PaymentHandleConnection struct{…}`

  - `ConnectID string`

    Returned only by `connect`, and only while the ceremony is pending.
    Nothing on our side persists it — it comes back from the provider and
    is required again to verify — so hold it until you submit the code.

  - `Handle string`

  - `Status PaymentHandleConnectionStatus`

    - `const PaymentHandleConnectionStatusNotConnected PaymentHandleConnectionStatus = "not_connected"`

    - `const PaymentHandleConnectionStatusPending PaymentHandleConnectionStatus = "pending"`

    - `const PaymentHandleConnectionStatusConnected PaymentHandleConnectionStatus = "connected"`

    - `const PaymentHandleConnectionStatusRevoked PaymentHandleConnectionStatus = "revoked"`
