## Cancel a payment

`client.Payments.Cancel(ctx, paymentID) (*Payment, error)`

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

Closes the virtual card and cancels the payment.

### Parameters

- `paymentID string`

### Returns

- `type Payment struct{…}`

  - `ID string`

  - `AmountCents int64`

  - `ApprovalURL string`

    Present on `awaiting_user_action` once a card is on file and the
    charge needs the customer's passkey. Re-send the create request with
    the same `Idempotency-Key` to collect the payment after they approve.

  - `AttachURL string`

    Present on `awaiting_user_action` when the customer has no card on
    file yet. A hosted page — open it for them; it stays valid for about
    48 hours. Not returned on `needs_connection`: connect the handle first.

  - `Currency string`

  - `Description string`

  - `Handle string`

  - `Merchant PaymentMerchant`

    The merchant the card is minted against, echoed from the request.

    - `Name string`

    - `URL string`

  - `Metadata map[string, string]`

    Your own key/values, echoed back from the request.

  - `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.Cancel(context.TODO(), "paymentId")
  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": "https://app.agentcard.sh/attach/eyJhbGciOi...",
  "currency": "usd",
  "description": "description",
  "handle": "+14155550123",
  "merchant": {
    "name": "DoorDash",
    "url": "doordash.com"
  },
  "metadata": {
    "foo": "string"
  },
  "status": "ready"
}
```
