Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Untabify

  • Loading branch information...
commit f9d307c4518c2dcf19038b852e263d40e2ad11a7 1 parent 5862285
@abh abh authored
Showing with 69 additions and 69 deletions.
  1. +20 −20 lib/main.js
  2. +49 −49 test/charges.js
View
40 lib/main.js
@@ -90,26 +90,26 @@ module.exports = function (api_key, options) {
}
return {
- charges: {
- create: function (data, cb) {
- post("/v1/charges", data, cb);
- },
- retrieve: function(charge_id, cb) {
- if(!(charge_id && typeof charge_id === 'string')) {
- cb("charge_id required");
- }
- get("/v1/charges/" + charge_id, {}, cb);
- },
- refund: function(charge_id, amount, cb) {
- if(!(charge_id && typeof charge_id === 'string')) {
- cb("charge_id required");
- }
- post("/v1/charges/" + charge_id + "/refund", { amount: amount }, cb);
- },
- list: function(data, cb) {
- get("/v1/charges", data, cb);
- },
- },
+ charges: {
+ create: function (data, cb) {
+ post("/v1/charges", data, cb);
+ },
+ retrieve: function(charge_id, cb) {
+ if(!(charge_id && typeof charge_id === 'string')) {
+ cb("charge_id required");
+ }
+ get("/v1/charges/" + charge_id, {}, cb);
+ },
+ refund: function(charge_id, amount, cb) {
+ if(!(charge_id && typeof charge_id === 'string')) {
+ cb("charge_id required");
+ }
+ post("/v1/charges/" + charge_id + "/refund", { amount: amount }, cb);
+ },
+ list: function(data, cb) {
+ get("/v1/charges", data, cb);
+ },
+ },
customers: {
create: function (data, cb) {
post("/v1/customers", data, cb);
View
98 test/charges.js
@@ -12,53 +12,53 @@ if (!api_key) {
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);
- },
- }
+ '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});
Please sign in to comment.
Something went wrong with that request. Please try again.