Skip to content
This repository has been archived by the owner. It is now read-only.
a simple Credit Card processing library for Go using the Stripe API
Branch: master
Clone or download
Latest commit 832208e Oct 10, 2014
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples Added examples for using go.stripe with Stripe.js and Stripe Checkout. Sep 30, 2013
.gitignore updated failing unit test due to stripe api removal of token currency Oct 10, 2012
LICENSE.txt Update LICENSE.txt Nov 7, 2012
README.md Fixed issue with get URL Oct 10, 2014
card.go added card creation Oct 26, 2013
card_test.go Refactored LuhnValid to IsLuhnValid Jun 4, 2012
charge.go Added statement description to charge object Jun 10, 2014
charge_test.go updated to newest API, modified structs to reflect new API and adjust… Oct 12, 2013
coupon.go Refactoring errors and adding codes/types provided by Stripe + go fmt Nov 25, 2013
coupon_test.go Refactoring errors and adding codes/types provided by Stripe + go fmt Nov 25, 2013
customer.go added a couple more fields to customer. also updated card to allow cr… Oct 20, 2013
customer_test.go updated to newest API, modified structs to reflect new API and adjust… Oct 12, 2013
error.go Refactoring errors and adding codes/types provided by Stripe + go fmt Nov 25, 2013
error_test.go Tests for good and bad cards from Stripe Nov 25, 2013
invoice.go Fixed typo in invoice object. Customer was set to Jan 7, 2014
invoice_item.go Refactoring errors and adding codes/types provided by Stripe + go fmt Nov 25, 2013
plan.go updated to newest API, modified structs to reflect new API and adjust… Oct 12, 2013
plan_test.go fixing plan_test.go invalid currency lowercase Jul 23, 2014
stripe.go Refactoring errors and adding codes/types provided by Stripe + go fmt Nov 25, 2013
subscription.go Refactoring errors and adding codes/types provided by Stripe + go fmt Nov 25, 2013
subscription_test.go updated to newest API, modified structs to reflect new API and adjust… Oct 12, 2013
token.go updated to newest API, modified structs to reflect new API and adjust… Oct 12, 2013
token_test.go updated failing unit test due to stripe api removal of token currency Oct 10, 2012
util.go ran gofmt Jun 4, 2012

README.md

go.stripe

a simple Credit Card processing library for Go using the Stripe API

go get github.com/drone/go.stripe

Examples

In order to use the go.stripe API you will need to create an account with stripe.com, and obtain an Secret Key. You must set this key by invoking the following function:

stripe.SetKey("vtUQeOtUnYr7PGCLQ96Ul4zqpDUO4sOE")

Or you can specify your Secret Key in environment variable STRIPE_API_KEY, and then invoke the following function:

stripe.SetKeyEnv()

Create Customer

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

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

Charge Card

params := stripe.ChargeParams{
	Desc:     "Calzone",
	Amount:   400,
	Currency: "usd",
	Card:     &stripe.CardParams {
		Name     : "George Costanza",
		Number   : "4242424242424242",
		ExpYear  : 2012,
		ExpMonth : 5,
		CVC      : "26726",
	},
}

charge, err := stripe.Charges.Create(&params)

Note: the amount charged is $4.00, but is specified in cents (400 cents == $4)

Documentation

You can also have a look at the Godocs.

Unit Tests

In order to run the unit tests, you must have a Stripe account and a Test Secret Key. The Test Secret Key must be set in environment variable STRIPE_API_KEY:

export STRIPE_API_KEY="vtUQeOtUnYr7PGCLQ96Ul4zqpDUO4sOE"
go test -v

The unit tests attempt to cleanup after themselves whenever possible. You can manually clear all test data from the Stripe console by navigating to: Your Account » Account Settings » Test Data. Then click the "Remove All Test Data" button.

You can’t perform that action at this time.