Skip to content

Latest commit

 

History

History
409 lines (304 loc) · 20.2 KB

README.md

File metadata and controls

409 lines (304 loc) · 20.2 KB

Custom

(Checkouts.Custom)

Overview

Available Operations

  • 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

List checkout sessions.

Example Usage

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.Custom.List(ctx, operations.CheckoutsCustomListRequest{})
    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
            }
        }
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.CheckoutsCustomListRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.CheckoutsCustomListResponse, error

Errors

Error Type Status Code Content Type
apierrors.HTTPValidationError 422 application/json
apierrors.APIError 4XX, 5XX */*

Create

Create a checkout session.

Example Usage

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.Custom.Create(ctx, components.CreateCheckoutCreateCheckoutProductCreate(
        components.CheckoutProductCreate{
            ProductID: "<value>",
        },
    ))
    if err != nil {
        log.Fatal(err)
    }
    if res.Checkout != nil {
        // handle response
    }
}

Parameters

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.

Response

*operations.CheckoutsCustomCreateResponse, error

Errors

Error Type Status Code Content Type
apierrors.HTTPValidationError 422 application/json
apierrors.APIError 4XX, 5XX */*

Get

Get a checkout session by ID.

Example Usage

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.Custom.Get(ctx, "<value>")
    if err != nil {
        log.Fatal(err)
    }
    if res.Checkout != nil {
        // handle response
    }
}

Parameters

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.

Response

*operations.CheckoutsCustomGetResponse, error

Errors

Error Type Status Code Content Type
apierrors.ResourceNotFound 404 application/json
apierrors.HTTPValidationError 422 application/json
apierrors.APIError 4XX, 5XX */*

Update

Update a checkout session.

Example Usage

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.Custom.Update(ctx, "<value>", components.CheckoutUpdate{})
    if err != nil {
        log.Fatal(err)
    }
    if res.Checkout != nil {
        // handle response
    }
}

Parameters

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.

Response

*operations.CheckoutsCustomUpdateResponse, error

Errors

Error Type Status Code Content Type
apierrors.ResourceNotFound 404 application/json
apierrors.HTTPValidationError 422 application/json
apierrors.APIError 4XX, 5XX */*

ClientGet

Get a checkout session by client secret.

Example Usage

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.Custom.ClientGet(ctx, "<value>")
    if err != nil {
        log.Fatal(err)
    }
    if res.CheckoutPublic != nil {
        // handle response
    }
}

Parameters

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.

Response

*operations.CheckoutsCustomClientGetResponse, error

Errors

Error Type Status Code Content Type
apierrors.ResourceNotFound 404 application/json
apierrors.HTTPValidationError 422 application/json
apierrors.APIError 4XX, 5XX */*

ClientUpdate

Update a checkout session by client secret.

Example Usage

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.Custom.ClientUpdate(ctx, "<value>", components.CheckoutUpdatePublic{})
    if err != nil {
        log.Fatal(err)
    }
    if res.CheckoutPublic != nil {
        // handle response
    }
}

Parameters

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.

Response

*operations.CheckoutsCustomClientUpdateResponse, error

Errors

Error Type Status Code Content Type
apierrors.ResourceNotFound 404 application/json
apierrors.HTTPValidationError 422 application/json
apierrors.APIError 4XX, 5XX */*

ClientConfirm

Confirm a checkout session by client secret.

Orders and subscriptions will be processed.

Example Usage

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.Custom.ClientConfirm(ctx, "<value>", components.CheckoutConfirmStripe{})
    if err != nil {
        log.Fatal(err)
    }
    if res.CheckoutPublicConfirmed != nil {
        // handle response
    }
}

Parameters

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.

Response

*operations.CheckoutsCustomClientConfirmResponse, error

Errors

Error Type Status Code Content Type
apierrors.ResourceNotFound 404 application/json
apierrors.HTTPValidationError 422 application/json
apierrors.APIError 4XX, 5XX */*