# Payment Providers

## Start payment-provider onboarding

`client.PaymentProviders.Connect(ctx, provider, body) (*PaymentProviderConnectResponse, error)`

**post** `/v3/payments/providers/{provider}/connect`

Begins connecting your organization to a payment provider (e.g.
`agentcard`). Returns a hosted URL where an admin authorizes the
connection; on completion the provider redirects back and Linq stores
your connected credentials.

### Parameters

- `provider string`

- `body PaymentProviderConnectParams`

  - `ReturnURL param.Field[string]`

    Where to send the admin after they authorize the connection.

### Returns

- `type PaymentProviderConnectResponse struct{…}`

  - `HostedURL string`

    Send the admin here to authorize the connection.

  - `SessionID string`

  - `Status string`

### 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"),
  )
  response, err := client.PaymentProviders.Connect(
    context.TODO(),
    "provider",
    linqgo.PaymentProviderConnectParams{
      ReturnURL: "https://partner.example/settings/payments",
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.SessionID)
}
```

#### Response

```json
{
  "hosted_url": "https://app.agentcard.sh/connect-platform/tok_abc",
  "session_id": "pcs_9f2a",
  "status": "pending"
}
```

## Get payment-provider status

`client.PaymentProviders.Get(ctx, provider) (*PaymentProvider, error)`

**get** `/v3/payments/providers/{provider}`

Returns your organization's onboarding status for a payment provider.

### Parameters

- `provider string`

### Returns

- `type PaymentProvider struct{…}`

  - `Provider string`

  - `Status PaymentProviderStatus`

    - `const PaymentProviderStatusOnboarding PaymentProviderStatus = "onboarding"`

    - `const PaymentProviderStatusReady PaymentProviderStatus = "ready"`

    - `const PaymentProviderStatusDisabled PaymentProviderStatus = "disabled"`

### 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"),
  )
  paymentProvider, err := client.PaymentProviders.Get(context.TODO(), "provider")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", paymentProvider.Provider)
}
```

#### Response

```json
{
  "provider": "agentcard",
  "status": "ready"
}
```

## Domain Types

### Payment Provider

- `type PaymentProvider struct{…}`

  - `Provider string`

  - `Status PaymentProviderStatus`

    - `const PaymentProviderStatusOnboarding PaymentProviderStatus = "onboarding"`

    - `const PaymentProviderStatusReady PaymentProviderStatus = "ready"`

    - `const PaymentProviderStatusDisabled PaymentProviderStatus = "disabled"`
