Skip to content
Linq Copy agent prompt

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.

ParametersExpand Collapse
body PaymentNewParams
AmountCents param.Field[int64]
formatint64
Currency param.Field[string]
Handle param.Field[string]

Customer phone (E.164) or email.

Description param.Field[string]Optional
Merchant param.Field[PaymentNewParamsMerchant]Optional
Name stringOptional
URL stringOptional
Metadata param.Field[map[string, string]]Optional
ReturnsExpand Collapse
type Payment struct{…}
ID stringOptional
AmountCents int64Optional
formatint64
ApprovalURL stringOptional

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 stringOptional

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 stringOptional
Description stringOptional
Handle stringOptional
Merchant PaymentMerchantOptional

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

Name stringOptional
URL stringOptional
Metadata map[string, string]Optional

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

Status PaymentStatusOptional
One of the following:
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"

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

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)
}
{
  "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"
}
{
  "error": {
    "status": 401,
    "code": 2004,
    "message": "Unauthorized - missing or invalid authentication token",
    "doc_url": "https://docs.linqapp.com/channel/imessage/error/codes/2xxx/2004/"
  },
  "success": false
}
{
  "error": {
    "status": 403,
    "code": 2005,
    "message": "Access denied - insufficient permissions for this resource",
    "doc_url": "https://docs.linqapp.com/channel/imessage/error/codes/2xxx/2005/"
  },
  "success": false
}
{
  "error": {
    "status": 404,
    "code": 2001,
    "message": "Resource not found",
    "doc_url": "https://docs.linqapp.com/channel/imessage/error/codes/2xxx/2001/"
  },
  "success": false
}
{
  "error": {
    "status": 500,
    "code": 3006,
    "message": "Internal server error",
    "doc_url": "https://docs.linqapp.com/channel/imessage/error/codes/3xxx/3006/"
  },
  "success": false
}
Returns Examples
{
  "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"
}
{
  "error": {
    "status": 401,
    "code": 2004,
    "message": "Unauthorized - missing or invalid authentication token",
    "doc_url": "https://docs.linqapp.com/channel/imessage/error/codes/2xxx/2004/"
  },
  "success": false
}
{
  "error": {
    "status": 403,
    "code": 2005,
    "message": "Access denied - insufficient permissions for this resource",
    "doc_url": "https://docs.linqapp.com/channel/imessage/error/codes/2xxx/2005/"
  },
  "success": false
}
{
  "error": {
    "status": 404,
    "code": 2001,
    "message": "Resource not found",
    "doc_url": "https://docs.linqapp.com/channel/imessage/error/codes/2xxx/2001/"
  },
  "success": false
}
{
  "error": {
    "status": 500,
    "code": 3006,
    "message": "Internal server error",
    "doc_url": "https://docs.linqapp.com/channel/imessage/error/codes/3xxx/3006/"
  },
  "success": false
}