(CustomerPortal.Customers)
- Get - Get Customer
- Update - Update Customer
- GetPaymentMethods - Get Customer Payment Methods
- AddPaymentMethod - Add Customer Payment Method
- DeletePaymentMethod - Delete Customer Payment Method
Get authenticated customer.
Scopes: customer_portal:read
customer_portal:write
package main
import(
"context"
polargo "github.com/polarsource/polar-go"
"os"
"github.com/polarsource/polar-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := polargo.New()
res, err := s.CustomerPortal.Customers.Get(ctx, operations.CustomerPortalCustomersGetSecurity{
CustomerSession: os.Getenv("POLAR_CUSTOMER_SESSION"),
})
if err != nil {
log.Fatal(err)
}
if res.CustomerPortalCustomer != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
security |
operations.CustomerPortalCustomersGetSecurity | ✔️ | The security requirements to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.CustomerPortalCustomersGetResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.APIError | 4XX, 5XX | */* |
Update authenticated customer.
Scopes: customer_portal:write
package main
import(
"context"
polargo "github.com/polarsource/polar-go"
"github.com/polarsource/polar-go/models/components"
"os"
"github.com/polarsource/polar-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := polargo.New()
res, err := s.CustomerPortal.Customers.Update(ctx, components.CustomerPortalCustomerUpdate{}, operations.CustomerPortalCustomersUpdateSecurity{
CustomerSession: os.Getenv("POLAR_CUSTOMER_SESSION"),
})
if err != nil {
log.Fatal(err)
}
if res.CustomerPortalCustomer != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
components.CustomerPortalCustomerUpdate | ✔️ | The request object to use for the request. |
security |
operations.CustomerPortalCustomersUpdateSecurity | ✔️ | The security requirements to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.CustomerPortalCustomersUpdateResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.HTTPValidationError | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |
Get saved payment methods of the authenticated customer.
Scopes: customer_portal:read
customer_portal:write
package main
import(
"context"
polargo "github.com/polarsource/polar-go"
"os"
"github.com/polarsource/polar-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := polargo.New()
res, err := s.CustomerPortal.Customers.GetPaymentMethods(ctx, operations.CustomerPortalCustomersGetPaymentMethodsSecurity{
CustomerSession: os.Getenv("POLAR_CUSTOMER_SESSION"),
}, nil, nil)
if err != nil {
log.Fatal(err)
}
if res.ListResourceUnionPaymentMethodCardPaymentMethodGeneric != 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. |
security |
operations.CustomerPortalCustomersGetPaymentMethodsSecurity | ✔️ | The security requirements to use for the request. |
page |
*int64 | ➖ | Page number, defaults to 1. |
limit |
*int64 | ➖ | Size of a page, defaults to 10. Maximum is 100. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.CustomerPortalCustomersGetPaymentMethodsResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.HTTPValidationError | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |
Add a payment method to the authenticated customer.
Scopes: customer_portal:read
customer_portal:write
package main
import(
"context"
polargo "github.com/polarsource/polar-go"
"github.com/polarsource/polar-go/models/components"
"os"
"github.com/polarsource/polar-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := polargo.New()
res, err := s.CustomerPortal.Customers.AddPaymentMethod(ctx, components.CustomerPaymentMethodCreate{
ConfirmationTokenID: "<id>",
SetDefault: false,
ReturnURL: "https://slight-digestive.info",
}, operations.CustomerPortalCustomersAddPaymentMethodSecurity{
CustomerSession: os.Getenv("POLAR_CUSTOMER_SESSION"),
})
if err != nil {
log.Fatal(err)
}
if res.ResponseCustomerPortalCustomersAddPaymentMethod != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
components.CustomerPaymentMethodCreate | ✔️ | The request object to use for the request. |
security |
operations.CustomerPortalCustomersAddPaymentMethodSecurity | ✔️ | The security requirements to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.CustomerPortalCustomersAddPaymentMethodResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.HTTPValidationError | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |
Delete a payment method from the authenticated customer.
Scopes: customer_portal:read
customer_portal:write
package main
import(
"context"
polargo "github.com/polarsource/polar-go"
"os"
"github.com/polarsource/polar-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := polargo.New()
res, err := s.CustomerPortal.Customers.DeletePaymentMethod(ctx, operations.CustomerPortalCustomersDeletePaymentMethodSecurity{
CustomerSession: os.Getenv("POLAR_CUSTOMER_SESSION"),
}, "<id>")
if err != nil {
log.Fatal(err)
}
if res != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
security |
operations.CustomerPortalCustomersDeletePaymentMethodSecurity | ✔️ | The security requirements to use for the request. |
id |
string | ✔️ | N/A |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.CustomerPortalCustomersDeletePaymentMethodResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.ResourceNotFound | 404 | application/json |
apierrors.HTTPValidationError | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |