Skip to content

Latest commit

 

History

History
121 lines (88 loc) · 5.63 KB

README.md

File metadata and controls

121 lines (88 loc) · 5.63 KB

Checkouts

(Checkouts)

Overview

Available Operations

  • Create - Create Checkout ⚠️ Deprecated Use Create instead.
  • Get - Get Checkout ⚠️ Deprecated

Create

Create a checkout session.

⚠️ DEPRECATED: This API is deprecated. We recommend you to use the new custom checkout API, which is more flexible and powerful. Please refer to the documentation for more information.. Use Create instead.

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.Create(ctx, components.CheckoutLegacyCreate{
        ProductPriceID: "<value>",
        SuccessURL: "https://probable-heating.com/",
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.CheckoutLegacy != nil {
        // handle response
    }
}

Parameters

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

Response

*operations.CheckoutsCreateResponse, error

Errors

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

Get

Get an active checkout session by ID.

⚠️ DEPRECATED: This API is deprecated. We recommend you to use the new custom checkout API, which is more flexible and powerful. Please refer to the documentation for more information..

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

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
id string ✔️ N/A
opts []operations.Option The options for this request.

Response

*operations.CheckoutsGetResponse, error

Errors

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