This project is now deprecated in favor of the official Stripe library, which you can see at https://github.com/stripe/stripe-go
You can sign up for a stripe account at https://stripe.com
This library pins the Stripe API Version. To see the current version, view
andrewpthorp/stripe.go
. You can view more about Stripes API versioning at the
stripe documentation.
Import the library:
import "github.com/andrewpthorp/stripe-go/stripe"
package main
import (
"fmt"
"github.com/andrewpthorp/stripe-go/stripe"
)
func main() {
// use the DefaultClient
client := stripe.NewClient(nil, "sk_your_secret_key")
params := stripe.CustomerParams{
Email: "[email protected]",
CardParams: &stripe.CardParams{
Name: "4242424242424242",
ExpMonth: 01,
ExpYear: 2020,
CVC: "111",
},
Metadata: stripe.Metadata{
"twitter": "@andrewpthorp"
},
}
customer, err := client.Customers.Create(¶ms)
if err != nil {
fmt.Println("Error creating customer: ", err)
} else {
fmt.Println("Created customer: ", customer.id)
}
}
Tests are all stubbed out. You can view the fixture responses in fixtures/
.
Ideally, tests will never actually hit the Stripe API. To run the tests:
Install Dependencies
script/bootstrap
Run Tests
script/test
stripe-go is released under the MIT license. See LICENSE.