Core API
- Checkout
- Checkout Links
- Custom Checkout Fields
- Customers
- Subscriptions
- Orders
- Discounts
- Refunds
- Products
- Benefits
- License Keys
- Files
- Organizations
- Metrics
Customer Portal API
- GETGet Customer
- GETGet Organization
- Sessions
- Subscriptions
- Orders
- License Keys
- File Downloads
Webhook Events
- Billing Events
- Organization Events
OAuth 2.0 API
- Connect
- Clients
Create Checkout Link
Create a checkout link.
package main
import(
"context"
"os"
polargo "github.com/polarsource/polar-go"
"github.com/polarsource/polar-go/models/components"
"github.com/polarsource/polar-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := polargo.New(
polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
)
res, err := s.CheckoutLinks.Create(ctx, operations.CreateCheckoutLinksCreateCheckoutLinkCreateCheckoutLinkCreateProduct(
components.CheckoutLinkCreateProduct{
ProductID: "<value>",
},
))
if err != nil {
log.Fatal(err)
}
if res.CheckoutLink != nil {
// handle response
}
}
{
"created_at": "2023-11-07T05:31:56Z",
"modified_at": "2023-11-07T05:31:56Z",
"id": "<string>",
"metadata": {},
"payment_processor": "stripe",
"client_secret": "<string>",
"success_url": "<string>",
"label": "<string>",
"allow_discount_codes": true,
"discount_id": "<string>",
"organization_id": "<string>",
"products": [
{
"created_at": "2023-11-07T05:31:56Z",
"modified_at": "2023-11-07T05:31:56Z",
"id": "<string>",
"name": "<string>",
"description": "<string>",
"recurring_interval": "month",
"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>",
"amount_type": "<string>",
"is_archived": true,
"product_id": "<string>",
"type": "<string>",
"recurring_interval": "month",
"price_currency": "<string>",
"price_amount": 123,
"legacy": true
}
],
"benefits": [
{
"created_at": "2023-11-07T05:31:56Z",
"modified_at": "2023-11-07T05:31:56Z",
"id": "<string>",
"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>"
}
]
}
],
"discount": {
"duration": "once",
"type": "fixed",
"amount": 123,
"currency": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"modified_at": "2023-11-07T05:31:56Z",
"id": "<string>",
"metadata": {},
"name": "<string>",
"code": "<string>",
"starts_at": "2023-11-07T05:31:56Z",
"ends_at": "2023-11-07T05:31:56Z",
"max_redemptions": 123,
"redemptions_count": 123,
"organization_id": "<string>"
},
"product_id": "<string>",
"product_price_id": "<string>",
"product": {
"created_at": "2023-11-07T05:31:56Z",
"modified_at": "2023-11-07T05:31:56Z",
"id": "<string>",
"name": "<string>",
"description": "<string>",
"recurring_interval": "month",
"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>",
"amount_type": "<string>",
"is_archived": true,
"product_id": "<string>",
"type": "<string>",
"recurring_interval": "month",
"price_currency": "<string>",
"price_amount": 123,
"legacy": true
}
],
"benefits": [
{
"created_at": "2023-11-07T05:31:56Z",
"modified_at": "2023-11-07T05:31:56Z",
"id": "<string>",
"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>",
"amount_type": "<string>",
"is_archived": true,
"product_id": "<string>",
"type": "<string>",
"recurring_interval": "month",
"price_currency": "<string>",
"price_amount": 123,
"legacy": true
},
"url": "<string>"
}
Looking to create a single use checkout session? Checkout Links are probably not what you’re looking for.
Checkout Links are shareable links that generate checkout sessions when opened. They are very handy to start a purchase from your website or social media.
However, if you want to start a checkout for one of your user inside your product, you should use the Checkout Sessions API.
Authorizations
Bearer authentication header of the form Bearer <token>
, where <token>
is your auth token.
Body
Schema to create a new checkout link from a a single product price.
Deprecated: Use CheckoutLinkCreateProducts
instead.
Payment processor to use. Currently only Stripe is supported.
"stripe"
Key-value object allowing you to store additional information.
The key must be a string with a maximum length of 40 characters. The value must be either:
- A string with a maximum length of 500 characters
- An integer
- A boolean
You can store up to 50 key-value pairs.
1 - 500
Optional label to distinguish links internally
Whether to allow the customer to apply discount codes. If you apply a discount through discount_id
, it'll still be applied, but the customer won't be able to change it.
ID of the discount to apply to the checkout. If the discount is not applicable anymore when opening the checkout link, it'll be ignored.
URL where the customer will be redirected after a successful payment.You can add the checkout_id={CHECKOUT_ID}
query parameter to retrieve the checkout session id.
1 - 2083
Response
Checkout link data.
Creation timestamp of the object.
Last modification timestamp of the object.
The ID of the object.
Payment processor used.
stripe
Client secret used to access the checkout link.
URL where the customer will be redirected after a successful payment.
Optional label to distinguish links internally
Whether to allow the customer to apply discount codes. If you apply a discount through discount_id
, it'll still be applied, but the customer won't be able to change it.
ID of the discount to apply to the checkout. If the discount is not applicable anymore when opening the checkout link, it'll be ignored.
The organization ID.
Creation timestamp of the object.
Last modification timestamp of the object.
The ID of the product.
The name of the product.
The description of the product.
The recurring interval of the product. If None
, the product is a one-time purchase.
month
, year
Whether the product is a subscription.
Whether the product is archived and no longer available.
The ID of the organization owning the product.
List of prices for this product.
Creation timestamp of the object.
Last modification timestamp of the object.
The ID of the price.
"fixed"
Whether the price is archived and no longer available.
The ID of the product owning the price.
The type of the price.
"recurring"
The recurring interval of the price.
month
, year
The currency.
The price in cents.
List of benefits granted by the product.
Creation timestamp of the object.
Last modification timestamp of the object.
The ID of the benefit.
The type of the benefit.
custom
, ads
, discord
, github_repository
, downloadables
, license_keys
The description of the benefit.
Whether the benefit is selectable when creating a product.
Whether the benefit is deletable.
The ID of the organization owning the benefit.
List of medias associated to the product.
The ID of the object.
"product_media"
once
, forever
, repeating
fixed
, percentage
Creation timestamp of the object.
Last modification timestamp of the object.
The ID of the object.
Name of the discount. Will be displayed to the customer when the discount is applied.
Code customers can use to apply the discount during checkout.
Timestamp after which the discount is redeemable.
Timestamp after which the discount is no longer redeemable.
Maximum number of times the discount can be redeemed.
Number of times the discount has been redeemed.
The organization ID.
Product data for a checkout link.
Creation timestamp of the object.
Last modification timestamp of the object.
The ID of the product.
The name of the product.
The description of the product.
The recurring interval of the product. If None
, the product is a one-time purchase.
month
, year
Whether the product is a subscription.
Whether the product is archived and no longer available.
The ID of the organization owning the product.
List of prices for this product.
Creation timestamp of the object.
Last modification timestamp of the object.
The ID of the price.
"fixed"
Whether the price is archived and no longer available.
The ID of the product owning the price.
The type of the price.
"recurring"
The recurring interval of the price.
month
, year
The currency.
The price in cents.
List of benefits granted by the product.
Creation timestamp of the object.
Last modification timestamp of the object.
The ID of the benefit.
The type of the benefit.
custom
, ads
, discord
, github_repository
, downloadables
, license_keys
The description of the benefit.
Whether the benefit is selectable when creating a product.
Whether the benefit is deletable.
The ID of the organization owning the benefit.
List of medias associated to the product.
The ID of the object.
"product_media"
A recurring price for a product, i.e. a subscription.
Deprecated: The recurring interval should be set on the product itself.
Creation timestamp of the object.
Last modification timestamp of the object.
The ID of the price.
"fixed"
Whether the price is archived and no longer available.
The ID of the product owning the price.
The type of the price.
"recurring"
The recurring interval of the price.
month
, year
The currency.
The price in cents.
Was this page helpful?
package main
import(
"context"
"os"
polargo "github.com/polarsource/polar-go"
"github.com/polarsource/polar-go/models/components"
"github.com/polarsource/polar-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := polargo.New(
polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
)
res, err := s.CheckoutLinks.Create(ctx, operations.CreateCheckoutLinksCreateCheckoutLinkCreateCheckoutLinkCreateProduct(
components.CheckoutLinkCreateProduct{
ProductID: "<value>",
},
))
if err != nil {
log.Fatal(err)
}
if res.CheckoutLink != nil {
// handle response
}
}
{
"created_at": "2023-11-07T05:31:56Z",
"modified_at": "2023-11-07T05:31:56Z",
"id": "<string>",
"metadata": {},
"payment_processor": "stripe",
"client_secret": "<string>",
"success_url": "<string>",
"label": "<string>",
"allow_discount_codes": true,
"discount_id": "<string>",
"organization_id": "<string>",
"products": [
{
"created_at": "2023-11-07T05:31:56Z",
"modified_at": "2023-11-07T05:31:56Z",
"id": "<string>",
"name": "<string>",
"description": "<string>",
"recurring_interval": "month",
"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>",
"amount_type": "<string>",
"is_archived": true,
"product_id": "<string>",
"type": "<string>",
"recurring_interval": "month",
"price_currency": "<string>",
"price_amount": 123,
"legacy": true
}
],
"benefits": [
{
"created_at": "2023-11-07T05:31:56Z",
"modified_at": "2023-11-07T05:31:56Z",
"id": "<string>",
"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>"
}
]
}
],
"discount": {
"duration": "once",
"type": "fixed",
"amount": 123,
"currency": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"modified_at": "2023-11-07T05:31:56Z",
"id": "<string>",
"metadata": {},
"name": "<string>",
"code": "<string>",
"starts_at": "2023-11-07T05:31:56Z",
"ends_at": "2023-11-07T05:31:56Z",
"max_redemptions": 123,
"redemptions_count": 123,
"organization_id": "<string>"
},
"product_id": "<string>",
"product_price_id": "<string>",
"product": {
"created_at": "2023-11-07T05:31:56Z",
"modified_at": "2023-11-07T05:31:56Z",
"id": "<string>",
"name": "<string>",
"description": "<string>",
"recurring_interval": "month",
"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>",
"amount_type": "<string>",
"is_archived": true,
"product_id": "<string>",
"type": "<string>",
"recurring_interval": "month",
"price_currency": "<string>",
"price_amount": 123,
"legacy": true
}
],
"benefits": [
{
"created_at": "2023-11-07T05:31:56Z",
"modified_at": "2023-11-07T05:31:56Z",
"id": "<string>",
"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>",
"amount_type": "<string>",
"is_archived": true,
"product_id": "<string>",
"type": "<string>",
"recurring_interval": "month",
"price_currency": "<string>",
"price_amount": 123,
"legacy": true
},
"url": "<string>"
}