(Checkouts)
- List - List Checkout Sessions
- Create - Create Checkout Session
- Get - Get Checkout Session
- Update - Update Checkout Session
- ClientGet - Get Checkout Session from Client
- ClientUpdate - Update Checkout Session from Client
- ClientConfirm - Confirm Checkout Session from Client
List checkout sessions.
Scopes: checkouts:read
checkouts:write
package main
import(
"context"
"os"
polargo "github.com/polarsource/polar-go"
"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.Checkouts.List(ctx, operations.CheckoutsListRequest{
OrganizationID: polargo.Pointer(operations.CreateCheckoutsListQueryParamOrganizationIDFilterArrayOfStr(
[]string{
"1dbfc517-0bbf-4301-9ba8-555ca42b9737",
},
)),
})
if err != nil {
log.Fatal(err)
}
if res.ListResourceCheckout != nil {
for {
// handle items
res, err = res.Next()
if err != nil {
// handle error
}
if res == nil {
break
}
}
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.CheckoutsListRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.CheckoutsListResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.HTTPValidationError | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |
Create a checkout session.
Scopes: checkouts:write
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.CreateCheckoutCreateCheckoutPriceCreate(
components.CheckoutPriceCreate{
CustomerBillingAddress: &components.Address{
Country: "SE",
},
SuccessURL: polargo.String("https://probable-heating.com/"),
ProductPriceID: "<value>",
},
))
if err != nil {
log.Fatal(err)
}
if res.Checkout != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
components.CheckoutCreate | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.CheckoutsCreateResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.HTTPValidationError | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |
Get a checkout session by ID.
Scopes: checkouts:read
checkouts:write
package main
import(
"context"
"os"
polargo "github.com/polarsource/polar-go"
"log"
)
func main() {
ctx := context.Background()
s := polargo.New(
polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
)
res, err := s.Checkouts.Get(ctx, "<id>")
if err != nil {
log.Fatal(err)
}
if res.Checkout != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
id |
string | ✔️ | The checkout session ID. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.CheckoutsGetResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.ResourceNotFound | 404 | application/json |
apierrors.HTTPValidationError | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |
Update a checkout session.
Scopes: checkouts:write
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.Update(ctx, "<value>", components.CheckoutUpdate{})
if err != nil {
log.Fatal(err)
}
if res.Checkout != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
id |
string | ✔️ | The checkout session ID. |
checkoutUpdate |
components.CheckoutUpdate | ✔️ | N/A |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.CheckoutsUpdateResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.CheckoutForbiddenError | 403 | application/json |
apierrors.ResourceNotFound | 404 | application/json |
apierrors.HTTPValidationError | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |
Get a checkout session by client secret.
package main
import(
"context"
polargo "github.com/polarsource/polar-go"
"log"
)
func main() {
ctx := context.Background()
s := polargo.New()
res, err := s.Checkouts.ClientGet(ctx, "<value>")
if err != nil {
log.Fatal(err)
}
if res.CheckoutPublic != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
clientSecret |
string | ✔️ | The checkout session client secret. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.CheckoutsClientGetResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.ResourceNotFound | 404 | application/json |
apierrors.HTTPValidationError | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |
Update a checkout session by client secret.
package main
import(
"context"
polargo "github.com/polarsource/polar-go"
"github.com/polarsource/polar-go/models/components"
"log"
)
func main() {
ctx := context.Background()
s := polargo.New()
res, err := s.Checkouts.ClientUpdate(ctx, "<value>", components.CheckoutUpdatePublic{})
if err != nil {
log.Fatal(err)
}
if res.CheckoutPublic != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
clientSecret |
string | ✔️ | The checkout session client secret. |
checkoutUpdatePublic |
components.CheckoutUpdatePublic | ✔️ | N/A |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.CheckoutsClientUpdateResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.CheckoutForbiddenError | 403 | application/json |
apierrors.ResourceNotFound | 404 | application/json |
apierrors.HTTPValidationError | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |
Confirm a checkout session by client secret.
Orders and subscriptions will be processed.
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.ClientConfirm(ctx, "<value>", components.CheckoutConfirmStripe{})
if err != nil {
log.Fatal(err)
}
if res.CheckoutPublicConfirmed != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
clientSecret |
string | ✔️ | The checkout session client secret. |
checkoutConfirmStripe |
components.CheckoutConfirmStripe | ✔️ | N/A |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.CheckoutsClientConfirmResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.PaymentError | 400 | application/json |
apierrors.CheckoutForbiddenError | 403 | application/json |
apierrors.ResourceNotFound | 404 | application/json |
apierrors.HTTPValidationError | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |