Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

Customers

Ashwin Purohit edited this page Aug 22, 2014 · 7 revisions

Create a new customer

stripe.SetKey("vtUQeOtUnYr7PGCLQ96Ul4zqpDUO4sOE")

params := stripe.CustomerParams{
	Email:  "george.costanza@mail.com",
	Desc:   "short, bald",
	Card:   &stripe.CardParams {
		Name     : "George Costanza",
		Number   : "4242424242424242",
		ExpYear  : 2014,
		ExpMonth : 12,
	},
}

customer, err := stripe.Customers.Create(&params)

Create a new customer object with an active credit card, using a Token.

stripe.SetKey("vtUQeOtUnYr7PGCLQ96Ul4zqpDUO4sOE")

params := stripe.CustomerParams{
	Email:  "george.costanza@mail.com",
	Desc:   "short, bald",
	Token:  "tok_jOq0M8vJprCUUU",
}

customer, err := stripe.Customers.Create(&params)

List of parameters for Creating a Customer:
http://godoc.org/github.com/drone/go.stripe#CustomerParams

Official Stripe Documentation:
https://stripe.com/docs/api#create_customer

Retrieve an existing customer

stripe.SetKey("vtUQeOtUnYr7PGCLQ96Ul4zqpDUO4sOE")

customer, err := stripe.Customers.Retrieve("cus_Lt6VFhU30fptWh")

Update a customer

stripe.SetKey("vtUQeOtUnYr7PGCLQ96Ul4zqpDUO4sOE")

params := stripe.CustomerParams{
	Desc: "Customer for site@stripe.com" }

customer, err := stripe.Customers.Update("cus_Lt6VFhU30fptWh", &params)

Delete a customer

stripe.SetKey("vtUQeOtUnYr7PGCLQ96Ul4zqpDUO4sOE")

_, err := stripe.Customers.Delete("cus_Lt6VFhU30fptWh")

List all customers

customers, err := stripe.Customers.List()

List a range of customers:

// get a list of 10 customers, starting at position 40 in the list of customers
customers, err := stripe.Customers.ListN(10, 40)