Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

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

branch: master

This branch is 0 commits ahead and 0 commits behind master

Octocat-spinner-32 .gitignore updated failing unit test due to stripe api removal of token currency October 09, 2012
Octocat-spinner-32 LICENSE.txt Update LICENSE.txt November 07, 2012
Octocat-spinner-32 README.md Added build badge October 09, 2012
Octocat-spinner-32 card.go added comments to CardParams June 05, 2012
Octocat-spinner-32 card_test.go Refactored LuhnValid to IsLuhnValid June 04, 2012
Octocat-spinner-32 charge.go Ability to Create a customer using Card Token, Issue #1 June 05, 2012
Octocat-spinner-32 charge_test.go updated failing unit test due to stripe api removal of token currency October 09, 2012
Octocat-spinner-32 coupon.go ran gofmt and added comments June 05, 2012
Octocat-spinner-32 coupon_test.go added bool return for Delete Coupon, Issue #4 June 05, 2012
Octocat-spinner-32 customer.go Return bool for Customer & Invoice Item Deletion, Issue #4 June 05, 2012
Octocat-spinner-32 customer_test.go Return bool for Customer & Invoice Item Deletion, Issue #4 June 05, 2012
Octocat-spinner-32 invoice.go gofmt and commented invoice & invoice items June 05, 2012
Octocat-spinner-32 invoice_item.go Return bool for Customer & Invoice Item Deletion, Issue #4 June 05, 2012
Octocat-spinner-32 plan.go ran gofmt and added comments June 05, 2012
Octocat-spinner-32 plan_test.go fixed failing unit test due to modified stripe error message May 28, 2013
Octocat-spinner-32 stripe.go added request / response logging for debugging purposes June 05, 2012
Octocat-spinner-32 subscription.go Merge remote-tracking branch 'upstream/master' May 28, 2013
Octocat-spinner-32 subscription_test.go Merge remote-tracking branch 'upstream/master' May 28, 2013
Octocat-spinner-32 token.go updated failing unit test due to stripe api removal of token currency October 09, 2012
Octocat-spinner-32 token_test.go updated failing unit test due to stripe api removal of token currency October 09, 2012
Octocat-spinner-32 util.go ran gofmt June 04, 2012
README.md

go.stripe

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

go get https://github.com/bradrydzewski/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.

Something went wrong with that request. Please try again.