Skip to main content
GET
/
v1
/
customer-portal
/
customers
/
me
/
payment-methods
Go (SDK)
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.ListPaymentMethods(ctx, operations.CustomerPortalCustomersListPaymentMethodsSecurity{
        CustomerSession: polargo.Pointer(os.Getenv("POLAR_CUSTOMER_SESSION")),
    }, polargo.Pointer[int64](1), polargo.Pointer[int64](10))
    if err != nil {
        log.Fatal(err)
    }
    if res.ListResourceCustomerPaymentMethod != nil {
        for {
            // handle items

            res, err = res.Next()

            if err != nil {
                // handle error
            }

            if res == nil {
                break
            }
        }
    }
}
{
  "items": [
    {
      "id": "<string>",
      "created_at": "2023-11-07T05:31:56Z",
      "modified_at": "2023-11-07T05:31:56Z",
      "customer_id": "<string>",
      "type": "<string>",
      "method_metadata": {
        "brand": "<string>",
        "last4": "<string>",
        "exp_month": 123,
        "exp_year": 123,
        "wallet": "<string>"
      }
    }
  ],
  "pagination": {
    "total_count": 123,
    "max_page": 123
  }
}

Documentation Index

Fetch the complete documentation index at: https://polar.sh/docs/llms.txt

Use this file to discover all available pages before exploring further.

To change the default payment method, call the PATCH /v1/customer-portal/customers/me endpoint with the desired default_payment_method_id.

Authorizations

Authorization
string
header
required

Customer session tokens are specific tokens that are used to authenticate customers on your organization. You can create those sessions programmatically using the Create Customer Session endpoint.

Query Parameters

page
integer
default:1

Page number, defaults to 1.

limit
integer
default:10

Size of a page, defaults to 10. Maximum is 100.

Response

Successful Response

items
(PaymentMethodCard · object | PaymentMethodGeneric · object)[]
required
pagination
Pagination · object
required