-
Notifications
You must be signed in to change notification settings - Fork 728
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #1
- Loading branch information
Showing
3 changed files
with
89 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,11 @@ Access to the [Stripe](https://stripe.com/) [API](http:https://stripe.com/api). | |
All methods takes a callback as their last parameter. The callback is | ||
called with an error code (if any) and then the response. | ||
|
||
* `stripe.charges` - create, retrieve, refund and list charges | ||
* `.create(charge) - create a charge | ||
* `.retrieve(charge_id) - retrieve a charge by charge id | ||
* `.refund(charge_id, amount) - refund a given charge, amount in cents | ||
* `.list(data) - [List charges](https://stripe.com/api/docs#list_charges) | ||
* `stripe.customers` - create, retrieve, update and delete customers | ||
* `.create(customer)` - create a customer, takes the data as an object | ||
* `.retrieve(customer_id)` - retrieve a customer by customer id. | ||
|
@@ -54,7 +59,6 @@ To run the tests, install vows with `npm install vows` and then run | |
|
||
Ask Bjørn Hansen ([email protected]). Development was sponsored by [YellowBot](http:https://www.yellowbot.com/). | ||
|
||
|
||
## License | ||
|
||
Copyright (C) 2011 Ask Bjørn Hansen | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
var vows = require('vows'), | ||
assert = require('assert'), | ||
sys = require('sys'); | ||
|
||
var api_key = process.env.STRIPE_API; | ||
|
||
if (!api_key) { | ||
sys.puts('To run vows, you must have a STRIPE_API environment variable with a test api key'); | ||
process.exit(2) | ||
} | ||
|
||
var stripe = require('./../lib/main.js')(api_key); | ||
|
||
vows.describe("Charges API").addBatch({ | ||
'Create charge' : { | ||
topic: function() { | ||
stripe.charges.create({ | ||
amount: "50", | ||
currency: "usd", | ||
card: { number: "4242424242424242", | ||
exp_month: 12, | ||
exp_year: 2020, | ||
name: "T. Ester", | ||
} | ||
}, this.callback); | ||
}, | ||
'returns a charge' : function(err, response) { | ||
assert.isNull(err); | ||
console.log("response", response); | ||
assert.isDefined(response); | ||
assert.equal(response.object, 'charge'); | ||
assert.isDefined(response.id); | ||
}, | ||
'Retrieve a charge' : { | ||
topic: function(create_err, charge) { | ||
stripe.charges.retrieve(charge.id, this.callback); | ||
}, | ||
'Got a charge' : function(err, response) { | ||
assert.isNull(err); | ||
assert.isDefined(response); | ||
assert.equal(response.object, 'charge'); | ||
assert.isDefined(response.id); | ||
}, | ||
}, | ||
'Refund a charge' : { | ||
topic: function(create_err, charge) { | ||
stripe.charges.refund(charge.id, 50, this.callback); | ||
}, | ||
'Got a refund' : function(err, response) { | ||
assert.isNull(err); | ||
assert.isDefined(response); | ||
assert.isTrue(response.refunded); | ||
}, | ||
}, | ||
}, | ||
'Charge list' : { | ||
topic: function() { | ||
stripe.charges.list({}, this.callback); | ||
}, | ||
'Got count': function(err, response) { | ||
assert.isNumber(response.count); | ||
}, | ||
} | ||
}).export(module, {error: false}); |