Skip to main content
GET
/
v1
/
orders
/
{id}
Go (SDK)
package main

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

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

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

    res, err := s.Orders.Get(ctx, "<value>")
    if err != nil {
        log.Fatal(err)
    }
    if res.Order != nil {
        switch res.Order.Discount.Type {
            case components.OrderDiscountTypeDiscountFixedOnceForeverDurationBase:
                // res.Order.Discount.DiscountFixedOnceForeverDurationBase is populated
            case components.OrderDiscountTypeDiscountFixedRepeatDurationBase:
                // res.Order.Discount.DiscountFixedRepeatDurationBase is populated
            case components.OrderDiscountTypeDiscountPercentageOnceForeverDurationBase:
                // res.Order.Discount.DiscountPercentageOnceForeverDurationBase is populated
            case components.OrderDiscountTypeDiscountPercentageRepeatDurationBase:
                // res.Order.Discount.DiscountPercentageRepeatDurationBase is populated
        }

    }
}
{
  "id": "<string>",
  "created_at": "2023-11-07T05:31:56Z",
  "modified_at": "2023-11-07T05:31:56Z",
  "status": "pending",
  "paid": true,
  "subtotal_amount": 123,
  "discount_amount": 123,
  "net_amount": 123,
  "tax_amount": 123,
  "total_amount": 123,
  "applied_balance_amount": 123,
  "due_amount": 123,
  "refunded_amount": 123,
  "refunded_tax_amount": 123,
  "currency": "<string>",
  "billing_reason": "purchase",
  "billing_name": "<string>",
  "billing_address": {
    "country": "AD",
    "line1": "<string>",
    "line2": "<string>",
    "postal_code": "<string>",
    "city": "<string>",
    "state": "<string>"
  },
  "invoice_number": "<string>",
  "is_invoice_generated": true,
  "customer_id": "<string>",
  "product_id": "<string>",
  "discount_id": "<string>",
  "subscription_id": "<string>",
  "checkout_id": "<string>",
  "metadata": {},
  "platform_fee_amount": 123,
  "platform_fee_currency": "usd",
  "customer": {
    "id": "<string>",
    "created_at": "2023-11-07T05:31:56Z",
    "modified_at": "2023-11-07T05:31:56Z",
    "metadata": {},
    "email_verified": true,
    "type": "individual",
    "name": "John Doe",
    "billing_address": {
      "country": "AD",
      "line1": "<string>",
      "line2": "<string>",
      "postal_code": "<string>",
      "city": "<string>",
      "state": "<string>"
    },
    "tax_id": {
      "[0]": "<string>"
    },
    "organization_id": "<string>",
    "deleted_at": "2023-11-07T05:31:56Z",
    "avatar_url": "<string>",
    "external_id": "usr_1337",
    "email": "customer@example.com",
    "locale": "<string>"
  },
  "product": {
    "metadata": {},
    "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>",
    "visibility": "draft",
    "recurring_interval": "day",
    "recurring_interval_count": 123,
    "is_recurring": true,
    "is_archived": true,
    "organization_id": "<string>"
  },
  "discount": {
    "duration": "once",
    "type": "fixed",
    "amount": 123,
    "currency": "<string>",
    "amounts": {},
    "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>"
  },
  "subscription": {
    "metadata": {},
    "created_at": "2023-11-07T05:31:56Z",
    "modified_at": "2023-11-07T05:31:56Z",
    "id": "<string>",
    "amount": 123,
    "currency": "<string>",
    "recurring_interval": "day",
    "recurring_interval_count": 123,
    "status": "incomplete",
    "current_period_start": "2023-11-07T05:31:56Z",
    "current_period_end": "2023-11-07T05:31:56Z",
    "trial_start": "2023-11-07T05:31:56Z",
    "trial_end": "2023-11-07T05:31:56Z",
    "cancel_at_period_end": true,
    "canceled_at": "2023-11-07T05:31:56Z",
    "started_at": "2023-11-07T05:31:56Z",
    "ends_at": "2023-11-07T05:31:56Z",
    "ended_at": "2023-11-07T05:31:56Z",
    "customer_id": "<string>",
    "product_id": "<string>",
    "discount_id": "<string>",
    "checkout_id": "<string>",
    "customer_cancellation_reason": "customer_service",
    "customer_cancellation_comment": "<string>",
    "seats": 123
  },
  "items": [
    {
      "created_at": "2023-11-07T05:31:56Z",
      "modified_at": "2023-11-07T05:31:56Z",
      "id": "<string>",
      "label": "<string>",
      "amount": 123,
      "tax_amount": 123,
      "proration": true,
      "product_price_id": "<string>"
    }
  ],
  "description": "<string>",
  "seats": 123,
  "custom_field_data": {}
}

Documentation Index

Fetch the complete documentation index at: https://polar.sh/docs/llms.txt

Use this file to discover all available pages before exploring further.

Authorizations

Authorization
string
header
required

You can generate an Organization Access Token from your organization's settings.

Path Parameters

id
string<uuid4>
required

The order ID.

Response

Successful Response

id
string<uuid4>
required

The ID of the object.

created_at
string<date-time>
required

Creation timestamp of the object.

modified_at
string<date-time> | null
required

Last modification timestamp of the object.

status
enum<string>
required
Available options:
pending,
paid,
refunded,
partially_refunded,
void
Example:

"paid"

paid
boolean
required

Whether the order has been paid for.

Example:

true

subtotal_amount
integer
required

Amount in cents, before discounts and taxes.

Example:

10000

discount_amount
integer
required

Discount amount in cents.

Example:

1000

net_amount
integer
required

Amount in cents, after discounts but before taxes.

Example:

9000

tax_amount
integer
required

Sales tax amount in cents.

Example:

720

total_amount
integer
required

Amount in cents, after discounts and taxes.

Example:

9720

applied_balance_amount
integer
required

Customer's balance amount applied to this invoice. Can increase the total amount paid, if the customer has a negative balance, or decrease it, if the customer has a positive balance.Amount in cents.

Example:

0

due_amount
integer
required

Amount in cents that is due for this order.

Example:

0

refunded_amount
integer
required

Amount refunded in cents.

Example:

0

refunded_tax_amount
integer
required

Sales tax refunded in cents.

Example:

0

currency
string
required
Example:

"usd"

billing_reason
enum<string>
required
Available options:
purchase,
subscription_create,
subscription_cycle,
subscription_update
billing_name
string | null
required

The name of the customer that should appear on the invoice.

billing_address
Address · object
required
invoice_number
string
required

The invoice number associated with this order.

is_invoice_generated
boolean
required

Whether an invoice has been generated for this order.

customer_id
string<uuid4>
required
product_id
string<uuid4> | null
required
discount_id
string<uuid4> | null
required
subscription_id
string<uuid4> | null
required
checkout_id
string<uuid4> | null
required
metadata
object
required
platform_fee_amount
integer
required

Platform fee amount in cents.

Example:

500

platform_fee_currency
string | null
required

Currency of the platform fee.

Example:

"usd"

customer
OrderCustomer · object
required
product
OrderProduct · object
required
discount
DiscountFixedOnceForeverDurationBase · object
required
subscription
OrderSubscription · object
required
items
OrderItemSchema · object[]
required

Line items composing the order.

description
string
required

A summary description of the order.

Example:

"Pro Plan"

seats
integer | null

Number of seats purchased (for seat-based one-time orders).

custom_field_data
Custom Field Data · object

Key-value object storing custom field values.