Skip to main content
POST
/
v1
/
checkouts
/
Go (SDK)
package main

import(
	"context"
	"os"
	polargo "github.com/polarsource/polar-go"
	"github.com/polarsource/polar-go/models/components"
	"log"
)

func main() {
    ctx := context.Background()

    s := polargo.New(
        polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
    )

    res, err := s.Checkouts.Create(ctx, components.CheckoutCreate{
        CustomerName: polargo.Pointer("John Doe"),
        CustomerBillingAddress: &components.AddressInput{
            Country: components.CountryAlpha2InputUs,
        },
        Products: []string{
            "<value 1>",
            "<value 2>",
            "<value 3>",
        },
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.Checkout != nil {
        // handle response
    }
}
{
  "id": "<string>",
  "created_at": "2023-11-07T05:31:56Z",
  "modified_at": "2023-11-07T05:31:56Z",
  "custom_field_data": {},
  "payment_processor": "stripe",
  "status": "open",
  "client_secret": "<string>",
  "url": "<string>",
  "expires_at": "2023-11-07T05:31:56Z",
  "success_url": "<string>",
  "return_url": "<string>",
  "embed_origin": "<string>",
  "amount": 123,
  "seats": 123,
  "price_per_seat": 123,
  "discount_amount": 123,
  "net_amount": 123,
  "tax_amount": 123,
  "total_amount": 123,
  "currency": "<string>",
  "allow_trial": true,
  "active_trial_interval": "day",
  "active_trial_interval_count": 123,
  "trial_end": "2023-11-07T05:31:56Z",
  "organization_id": "<string>",
  "product_id": "<string>",
  "product_price_id": "<string>",
  "discount_id": "<string>",
  "allow_discount_codes": true,
  "require_billing_address": true,
  "is_discount_applicable": true,
  "is_free_product_price": true,
  "is_payment_required": true,
  "is_payment_setup_required": true,
  "is_payment_form_required": true,
  "customer_id": "<string>",
  "is_business_customer": true,
  "customer_name": "<string>",
  "customer_email": "<string>",
  "customer_ip_address": "<string>",
  "customer_billing_name": "<string>",
  "customer_billing_address": {
    "line1": "<string>",
    "line2": "<string>",
    "postal_code": "<string>",
    "city": "<string>",
    "state": "<string>",
    "country": "US"
  },
  "customer_tax_id": "<string>",
  "payment_processor_metadata": {},
  "billing_address_fields": {
    "country": "required",
    "state": "required",
    "city": "required",
    "postal_code": "required",
    "line1": "required",
    "line2": "required"
  },
  "trial_interval": "day",
  "trial_interval_count": 123,
  "metadata": {},
  "external_customer_id": "<string>",
  "customer_external_id": "<string>",
  "products": [
    {
      "id": "<string>",
      "created_at": "2023-11-07T05:31:56Z",
      "modified_at": "2023-11-07T05:31:56Z",
      "trial_interval": "day",
      "trial_interval_count": 123,
      "name": "<string>",
      "description": "<string>",
      "recurring_interval": "day",
      "recurring_interval_count": 123,
      "is_recurring": true,
      "is_archived": true,
      "organization_id": "<string>",
      "prices": [
        {
          "created_at": "2023-11-07T05:31:56Z",
          "modified_at": "2023-11-07T05:31:56Z",
          "id": "<string>",
          "source": "catalog",
          "amount_type": "<string>",
          "is_archived": true,
          "product_id": "<string>",
          "type": "<string>",
          "recurring_interval": "day",
          "price_currency": "<string>",
          "price_amount": 123,
          "legacy": true
        }
      ],
      "benefits": [
        {
          "id": "<string>",
          "created_at": "2023-11-07T05:31:56Z",
          "modified_at": "2023-11-07T05:31:56Z",
          "type": "custom",
          "description": "<string>",
          "selectable": true,
          "deletable": true,
          "organization_id": "<string>"
        }
      ],
      "medias": [
        {
          "id": "<string>",
          "organization_id": "<string>",
          "name": "<string>",
          "path": "<string>",
          "mime_type": "<string>",
          "size": 123,
          "storage_version": "<string>",
          "checksum_etag": "<string>",
          "checksum_sha256_base64": "<string>",
          "checksum_sha256_hex": "<string>",
          "last_modified_at": "2023-11-07T05:31:56Z",
          "version": "<string>",
          "service": "<string>",
          "is_uploaded": true,
          "created_at": "2023-11-07T05:31:56Z",
          "size_readable": "<string>",
          "public_url": "<string>"
        }
      ]
    }
  ],
  "product": {
    "id": "<string>",
    "created_at": "2023-11-07T05:31:56Z",
    "modified_at": "2023-11-07T05:31:56Z",
    "trial_interval": "day",
    "trial_interval_count": 123,
    "name": "<string>",
    "description": "<string>",
    "recurring_interval": "day",
    "recurring_interval_count": 123,
    "is_recurring": true,
    "is_archived": true,
    "organization_id": "<string>",
    "prices": [
      {
        "created_at": "2023-11-07T05:31:56Z",
        "modified_at": "2023-11-07T05:31:56Z",
        "id": "<string>",
        "source": "catalog",
        "amount_type": "<string>",
        "is_archived": true,
        "product_id": "<string>",
        "type": "<string>",
        "recurring_interval": "day",
        "price_currency": "<string>",
        "price_amount": 123,
        "legacy": true
      }
    ],
    "benefits": [
      {
        "id": "<string>",
        "created_at": "2023-11-07T05:31:56Z",
        "modified_at": "2023-11-07T05:31:56Z",
        "type": "custom",
        "description": "<string>",
        "selectable": true,
        "deletable": true,
        "organization_id": "<string>"
      }
    ],
    "medias": [
      {
        "id": "<string>",
        "organization_id": "<string>",
        "name": "<string>",
        "path": "<string>",
        "mime_type": "<string>",
        "size": 123,
        "storage_version": "<string>",
        "checksum_etag": "<string>",
        "checksum_sha256_base64": "<string>",
        "checksum_sha256_hex": "<string>",
        "last_modified_at": "2023-11-07T05:31:56Z",
        "version": "<string>",
        "service": "<string>",
        "is_uploaded": true,
        "created_at": "2023-11-07T05:31:56Z",
        "size_readable": "<string>",
        "public_url": "<string>"
      }
    ]
  },
  "product_price": {
    "created_at": "2023-11-07T05:31:56Z",
    "modified_at": "2023-11-07T05:31:56Z",
    "id": "<string>",
    "source": "catalog",
    "amount_type": "<string>",
    "is_archived": true,
    "product_id": "<string>",
    "type": "<string>",
    "recurring_interval": "day",
    "price_currency": "<string>",
    "price_amount": 123,
    "legacy": true
  },
  "prices": {},
  "discount": {
    "duration": "once",
    "type": "fixed",
    "amount": 1000,
    "currency": "usd",
    "id": "<string>",
    "name": "<string>",
    "code": "<string>"
  },
  "subscription_id": "<string>",
  "attached_custom_fields": [
    {
      "custom_field_id": "<string>",
      "custom_field": {
        "created_at": "2023-11-07T05:31:56Z",
        "modified_at": "2023-11-07T05:31:56Z",
        "id": "<string>",
        "metadata": {},
        "type": "<string>",
        "slug": "<string>",
        "name": "<string>",
        "organization_id": "1dbfc517-0bbf-4301-9ba8-555ca42b9737",
        "properties": {
          "form_label": "<string>",
          "form_help_text": "<string>",
          "form_placeholder": "<string>",
          "textarea": true,
          "min_length": 1,
          "max_length": 1
        }
      },
      "order": 123,
      "required": true
    }
  ],
  "customer_metadata": {}
}

Authorizations

Authorization
string
header
required

Body

application/json
products
string<uuid4>[]
required
Minimum length: 1
trial_interval
enum<string> | null
Available options:
day,
week,
month,
year
trial_interval_count
integer | null
Required range: 1 <= x <= 1000
metadata
object
custom_field_data
object
discount_id
string<uuid4> | null
allow_discount_codes
boolean
default:true
require_billing_address
boolean
default:false
amount
integer | null
Required range: 50 <= x <= 99999999
seats
integer | null
Required range: 1 <= x <= 1000
allow_trial
boolean
default:true
customer_id
string<uuid4> | null
is_business_customer
boolean
default:false
external_customer_id
string | null
customer_name
string | null
Maximum length: 256
Examples:
customer_email
string<email> | null
customer_ip_address
string<ipvanyaddress> | null
customer_billing_name
string | null
customer_billing_address
object | null
customer_tax_id
string | null
customer_metadata
object
subscription_id
string<uuid4> | null
success_url
string<uri> | null
Required string length: 1 - 2083
return_url
string<uri> | null
Required string length: 1 - 2083
embed_origin
string | null
prices
object | null

Response

id
string<uuid4>
required
created_at
string<date-time>
required
modified_at
string<date-time> | null
required
payment_processor
enum<string>
required
Available options:
stripe
status
enum<string>
required
Available options:
open,
expired,
confirmed,
succeeded,
failed
client_secret
string
required
url
string
required
expires_at
string<date-time>
required
success_url
string
required
return_url
string | null
required
embed_origin
string | null
required
amount
integer
required
discount_amount
integer
required
net_amount
integer
required
tax_amount
integer | null
required
total_amount
integer
required
currency
string
required
allow_trial
boolean | null
required
active_trial_interval
enum<string> | null
required
Available options:
day,
week,
month,
year
active_trial_interval_count
integer | null
required
trial_end
string<date-time> | null
required
organization_id
string<uuid4>
required
product_id
string<uuid4> | null
required
product_price_id
string<uuid4> | null
required
deprecated
discount_id
string<uuid4> | null
required
allow_discount_codes
boolean
required
require_billing_address
boolean
required
is_discount_applicable
boolean
required
is_free_product_price
boolean
required
is_payment_required
boolean
required
is_payment_setup_required
boolean
required
is_payment_form_required
boolean
required
customer_id
string<uuid4> | null
required
is_business_customer
boolean
required
customer_name
string | null
required
customer_email
string | null
required
customer_ip_address
string<ipvanyaddress> | null
required
customer_billing_name
string | null
required
customer_billing_address
object | null
required
customer_tax_id
string | null
required
payment_processor_metadata
object
required
billing_address_fields
object
required
trial_interval
enum<string> | null
required
Available options:
day,
week,
month,
year
trial_interval_count
integer | null
required
metadata
object
required
external_customer_id
string | null
required
customer_external_id
string | null
required
deprecated
products
CheckoutProduct · object[]
required
product
object | null
required
product_price
object | null
required
deprecated
  • LegacyRecurringProductPriceFixed
  • LegacyRecurringProductPriceCustom
  • LegacyRecurringProductPriceFree
  • ProductPriceFixed
  • ProductPriceCustom
  • ProductPriceFree
  • ProductPriceSeatBased
  • ProductPriceMeteredUnit
prices
object | null
required
discount
object | null
required
  • CheckoutDiscountFixedOnceForeverDuration
  • CheckoutDiscountFixedRepeatDuration
  • CheckoutDiscountPercentageOnceForeverDuration
  • CheckoutDiscountPercentageRepeatDuration
subscription_id
string<uuid4> | null
required
attached_custom_fields
AttachedCustomField · object[] | null
required
customer_metadata
object
required
custom_field_data
object
seats
integer | null
price_per_seat
integer | null