(CustomerPortal.Subscriptions)
- List - List Subscriptions
- Get - Get Subscription
- Update - Update Subscription
- Cancel - Cancel Subscription
List subscriptions of the authenticated customer or user.
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.CustomerPortal.Subscriptions.List(ctx, operations.CustomerPortalSubscriptionsListRequest{})
if err != nil {
log.Fatal(err)
}
if res.ListResourceCustomerSubscription != 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.CustomerPortalSubscriptionsListRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.CustomerPortalSubscriptionsListResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.HTTPValidationError | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |
Get a subscription for the authenticated customer or user.
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.CustomerPortal.Subscriptions.Get(ctx, "<value>")
if err != nil {
log.Fatal(err)
}
if res.CustomerSubscription != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
id |
string | ✔️ | Customer subscription ID. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.CustomerPortalSubscriptionsGetResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.ResourceNotFound | 404 | application/json |
apierrors.HTTPValidationError | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |
Update a subscription of the authenticated customer or user.
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.CustomerPortal.Subscriptions.Update(ctx, "<value>", components.CreateCustomerSubscriptionUpdateCustomerSubscriptionUpdatePrice(
components.CustomerSubscriptionUpdatePrice{
ProductPriceID: "<value>",
},
))
if err != nil {
log.Fatal(err)
}
if res.CustomerSubscription != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
id |
string | ✔️ | Customer subscription ID. |
customerSubscriptionUpdate |
components.CustomerSubscriptionUpdate | ✔️ | N/A |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.CustomerPortalSubscriptionsUpdateResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.AlreadyCanceledSubscription | 403 | application/json |
apierrors.ResourceNotFound | 404 | application/json |
apierrors.HTTPValidationError | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |
Cancel a subscription of the authenticated customer or user.
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.CustomerPortal.Subscriptions.Cancel(ctx, "<value>")
if err != nil {
log.Fatal(err)
}
if res.CustomerSubscription != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
id |
string | ✔️ | Customer subscription ID. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.CustomerPortalSubscriptionsCancelResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.AlreadyCanceledSubscription | 403 | application/json |
apierrors.ResourceNotFound | 404 | application/json |
apierrors.HTTPValidationError | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |