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

`client.Payments.New(ctx, body) (*Payment, error)`

**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.

### Parameters

- `body PaymentNewParams`

  - `AmountCents param.Field[int64]`

  - `Currency param.Field[string]`

  - `Handle param.Field[string]`

    Customer phone (E.164) or email.

  - `Description param.Field[string]`

  - `Merchant param.Field[PaymentNewParamsMerchant]`

    - `Name string`

    - `URL string`

  - `Metadata param.Field[map[string, string]]`

### Returns

- `type Payment struct{…}`

  - `ID string`

  - `AmountCents int64`

  - `ApprovalURL string`

    Present when the customer must approve with a passkey.

  - `AttachURL string`

    Present when the customer must attach a card.

  - `Currency string`

  - `Description string`

  - `Handle string`

  - `Status PaymentStatus`

    - `const PaymentStatusNeedsConnection PaymentStatus = "needs_connection"`

    - `const PaymentStatusConnecting PaymentStatus = "connecting"`

    - `const PaymentStatusAwaitingUserAction PaymentStatus = "awaiting_user_action"`

    - `const PaymentStatusReady PaymentStatus = "ready"`

    - `const PaymentStatusAuthorized PaymentStatus = "authorized"`

    - `const PaymentStatusSucceeded PaymentStatus = "succeeded"`

    - `const PaymentStatusDeclined PaymentStatus = "declined"`

    - `const PaymentStatusCanceled PaymentStatus = "canceled"`

    - `const PaymentStatusExpired PaymentStatus = "expired"`

### 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"),
  )
  payment, err := client.Payments.New(context.TODO(), linqgo.PaymentNewParams{
    AmountCents: 2500,
    Currency: "usd",
    Handle: "+14155550123",
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", payment.ID)
}
```

#### 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"
}
```
