Comparing version 2.4.4 to 2.4.5
var stripe = require('./lib/stripe')('sk_test_uGCobEeYAQPjGYlGuZORD5PV') | ||
stripe.setHost('127.0.0.1', 15003, 'http'); | ||
stripe.plans.retrieve('foo').then(console.log, console.error) | ||
stripe.charges.refund('id1233', 123, function() {}); |
'use strict'; | ||
var StripeResource = require('../StripeResource'); | ||
var utils = require('../utils'); | ||
var stripeMethod = StripeResource.method; | ||
@@ -70,3 +71,4 @@ | ||
// This is a hack, but it lets us maximize our overloading. | ||
if (typeof subscriptionId == 'string' && subscriptionId.substring(0, 2) != 'sk') { | ||
// Precarious assumption: If it's not an auth key it _could_ be a sub id: | ||
if (typeof subscriptionId == 'string' && !utils.isAuthKey(subscriptionId)) { | ||
return this._newstyleCancelSubscription.apply(this, arguments); | ||
@@ -73,0 +75,0 @@ } else { |
@@ -7,5 +7,5 @@ 'use strict'; | ||
/** | ||
* CustomerCard is a unique resource in that, upon instantiation, | ||
* CustomerSubscription is a unique resource in that, upon instantiation, | ||
* requires a customerId, and therefore each of its methods only | ||
* require the cardId argument. | ||
* require the subscriptionId argument. | ||
* | ||
@@ -12,0 +12,0 @@ * This streamlines the API specifically for the case of accessing cards |
@@ -29,3 +29,3 @@ 'use strict'; | ||
var callback = typeof args[args.length - 1] == 'function' && args.pop(); | ||
var auth = args.length > urlParams.length && typeof args[args.length - 1] == 'string' ? args.pop() : null; | ||
var auth = args.length > urlParams.length && utils.isAuthKey(args[args.length - 1]) ? args.pop() : null; | ||
var data = utils.isObject(args[args.length - 1]) ? args.pop() : {}; | ||
@@ -44,2 +44,9 @@ var urlData = this.createUrlData(); | ||
if (args.length) { | ||
throw new Error( | ||
'Stripe: Unknown arguments (' + args + '). Did you mean to pass an options object? ' + | ||
'See https://github.com/stripe/stripe-node/wiki/Passing-Options.' | ||
); | ||
} | ||
var requestPath = this.createFullPath(commandPath, urlData); | ||
@@ -46,0 +53,0 @@ |
@@ -12,2 +12,6 @@ 'use strict'; | ||
isAuthKey: function (key) { | ||
return typeof key == 'string' && /^(?:[a-z]{2}_)?[A-z0-9]{32}$/.test(key); | ||
}, | ||
isObject: function(o) { | ||
@@ -14,0 +18,0 @@ return toString.call(o) === '[object Object]'; |
{ | ||
"name": "stripe", | ||
"version": "2.4.4", | ||
"version": "2.4.5", | ||
"description": "Stripe API wrapper", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/stripe/stripe-node", |
@@ -91,4 +91,4 @@ # Stripe node.js bindings [![Build Status](https://travis-ci.org/stripe/stripe-node.png?branch=master)](https://travis-ci.org/stripe/stripe-node) | ||
* `getMetadata(customerId)` | ||
* [`updateSubscription(customerId[, params])`](https://stripe.com/docs/api/node#update_subscription) | ||
* [`cancelSubscription(customerId[, params])`](https://stripe.com/docs/api/node#cancel_subscription) | ||
* [`updateSubscription(customerId, subscriptionId, [, params])`](https://stripe.com/docs/api/node#update_subscription) | ||
* [`cancelSubscription(customerId, subscriptionId, [, params])`](https://stripe.com/docs/api/node#cancel_subscription) | ||
* [`createCard(customerId[, params])`](https://stripe.com/docs/api/node#create_card) | ||
@@ -95,0 +95,0 @@ * [`listCards(customerId)`](https://stripe.com/docs/api/node#list_cards) |
@@ -23,3 +23,3 @@ 'use strict'; | ||
stripe.balance.retrieve('auth38838111'); | ||
stripe.balance.retrieve('aGN0bIwXnHdw5645VABjPdSn8nWY7G11'); | ||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
@@ -29,3 +29,3 @@ method: 'GET', | ||
data: {}, | ||
auth: 'auth38838111' | ||
auth: 'aGN0bIwXnHdw5645VABjPdSn8nWY7G11' | ||
}); | ||
@@ -52,3 +52,3 @@ | ||
stripe.balance.listTransactions('auth4733234'); | ||
stripe.balance.listTransactions('aGN0bIwXnHdw5645VABjPdSn8nWY7G11'); | ||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
@@ -58,3 +58,3 @@ method: 'GET', | ||
data: {}, | ||
auth: 'auth4733234' | ||
auth: 'aGN0bIwXnHdw5645VABjPdSn8nWY7G11' | ||
}); | ||
@@ -81,3 +81,3 @@ | ||
stripe.balance.retrieveTransaction('transactionIdFoo', 'auth9132432424'); | ||
stripe.balance.retrieveTransaction('transactionIdFoo', 'aGN0bIwXnHdw5645VABjPdSn8nWY7G11'); | ||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
@@ -87,3 +87,3 @@ method: 'GET', | ||
data: {}, | ||
auth: 'auth9132432424' | ||
auth: 'aGN0bIwXnHdw5645VABjPdSn8nWY7G11' | ||
}); | ||
@@ -90,0 +90,0 @@ |
@@ -98,2 +98,8 @@ 'use strict'; | ||
it('Throws an error on incorrect arguments', function() { | ||
expect(function() { | ||
stripe.charges.refund('chargeIdExample123', 39392); | ||
}).to.throw(/unknown arguments/i); | ||
}); | ||
}); | ||
@@ -100,0 +106,0 @@ |
@@ -7,2 +7,4 @@ 'use strict'; | ||
var TEST_AUTH_KEY = 'aGN0bIwXnHdw5645VABjPdSn8nWY7G11'; | ||
describe('Customers Resource', function() { | ||
@@ -25,3 +27,3 @@ | ||
stripe.customers.retrieve('cus_2dkAb792h1mfa4', 'Auth482'); | ||
stripe.customers.retrieve('cus_2dkAb792h1mfa4', TEST_AUTH_KEY); | ||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
@@ -31,3 +33,3 @@ method: 'GET', | ||
data: {}, | ||
auth: 'Auth482' | ||
auth: TEST_AUTH_KEY | ||
}); | ||
@@ -54,3 +56,3 @@ | ||
stripe.customers.create({ description: 'Some customer' }, 'Auth324'); | ||
stripe.customers.create({ description: 'Some customer' }, TEST_AUTH_KEY); | ||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
@@ -60,3 +62,3 @@ method: 'POST', | ||
data: { description: 'Some customer' }, | ||
auth: 'Auth324' | ||
auth: TEST_AUTH_KEY | ||
}); | ||
@@ -115,3 +117,3 @@ | ||
stripe.customers.list('Auth842'); | ||
stripe.customers.list(TEST_AUTH_KEY); | ||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
@@ -121,3 +123,3 @@ method: 'GET', | ||
data: {}, | ||
auth: 'Auth842' | ||
auth: TEST_AUTH_KEY | ||
}); | ||
@@ -150,3 +152,3 @@ | ||
plan: 'fooPlan' | ||
}, 'auth981'); | ||
}, TEST_AUTH_KEY); | ||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
@@ -156,3 +158,3 @@ method: 'POST', | ||
data: { plan: 'fooPlan' }, | ||
auth: 'auth981' | ||
auth: TEST_AUTH_KEY | ||
}); | ||
@@ -179,3 +181,3 @@ | ||
stripe.customers.cancelSubscription('customerIdFoo321', 'sk_foo'); | ||
stripe.customers.cancelSubscription('customerIdFoo321', TEST_AUTH_KEY); | ||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
@@ -185,3 +187,3 @@ method: 'DELETE', | ||
data: { }, | ||
auth: 'sk_foo' | ||
auth: TEST_AUTH_KEY | ||
}); | ||
@@ -207,3 +209,3 @@ | ||
stripe.customers.cancelSubscription('customerIdFoo321', {at_period_end: true}, 'sk_foo'); | ||
stripe.customers.cancelSubscription('customerIdFoo321', {at_period_end: true}, TEST_AUTH_KEY); | ||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
@@ -213,3 +215,3 @@ method: 'DELETE', | ||
data: { at_period_end: true }, | ||
auth: 'sk_foo' | ||
auth: TEST_AUTH_KEY | ||
}); | ||
@@ -320,3 +322,3 @@ | ||
it('Sends the correct request, including the specified auth key', function() { | ||
stripe.customers.setMetadata('customerIdFoo321', null, 'authKey133'); | ||
stripe.customers.setMetadata('customerIdFoo321', null, TEST_AUTH_KEY); | ||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
@@ -328,5 +330,5 @@ method: 'POST', | ||
}, | ||
auth: 'authKey133' | ||
auth: TEST_AUTH_KEY | ||
}); | ||
stripe.customers.setMetadata('customerIdFoo321', 'a', '1234', 'authKey133'); | ||
stripe.customers.setMetadata('customerIdFoo321', 'a', '1234', TEST_AUTH_KEY); | ||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
@@ -338,5 +340,5 @@ method: 'POST', | ||
}, | ||
auth: 'authKey133' | ||
auth: TEST_AUTH_KEY | ||
}); | ||
stripe.customers.setMetadata('customerIdFoo321', 'a', null, 'authKey133'); | ||
stripe.customers.setMetadata('customerIdFoo321', 'a', null, TEST_AUTH_KEY); | ||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
@@ -348,3 +350,3 @@ method: 'POST', | ||
}, | ||
auth: 'authKey133' | ||
auth: TEST_AUTH_KEY | ||
}); | ||
@@ -375,3 +377,3 @@ }); | ||
stripe.customers.retrieveCard('customerIdFoo321', 'cardIdFoo456', 'auth123'); | ||
stripe.customers.retrieveCard('customerIdFoo321', 'cardIdFoo456', TEST_AUTH_KEY); | ||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
@@ -381,3 +383,3 @@ method: 'GET', | ||
data: {}, | ||
auth: 'auth123' | ||
auth: TEST_AUTH_KEY | ||
}); | ||
@@ -408,3 +410,3 @@ | ||
number: '123456', exp_month: '12' | ||
}, 'auth555'); | ||
}, TEST_AUTH_KEY); | ||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
@@ -414,3 +416,3 @@ method: 'POST', | ||
data: { number: '123456', exp_month: '12' }, | ||
auth: 'auth555' | ||
auth: TEST_AUTH_KEY | ||
}); | ||
@@ -454,3 +456,3 @@ | ||
stripe.customers.deleteCard('customerIdFoo321', 'cardIdFoo456', 'auth921'); | ||
stripe.customers.deleteCard('customerIdFoo321', 'cardIdFoo456', TEST_AUTH_KEY); | ||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
@@ -460,3 +462,3 @@ method: 'DELETE', | ||
data: {}, | ||
auth: 'auth921' | ||
auth: TEST_AUTH_KEY | ||
}); | ||
@@ -483,3 +485,3 @@ | ||
stripe.customers.listCards('customerIdFoo321', 'auth771'); | ||
stripe.customers.listCards('customerIdFoo321', TEST_AUTH_KEY); | ||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
@@ -489,3 +491,3 @@ method: 'GET', | ||
data: {}, | ||
auth: 'auth771' | ||
auth: TEST_AUTH_KEY | ||
}); | ||
@@ -516,3 +518,3 @@ | ||
stripe.customers.retrieveSubscription('customerIdFoo321', 'subscriptionIdFoo456', 'auth123'); | ||
stripe.customers.retrieveSubscription('customerIdFoo321', 'subscriptionIdFoo456', TEST_AUTH_KEY); | ||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
@@ -522,3 +524,3 @@ method: 'GET', | ||
data: {}, | ||
auth: 'auth123' | ||
auth: TEST_AUTH_KEY | ||
}); | ||
@@ -549,3 +551,3 @@ | ||
plan: 'gold', quantity: '12' | ||
}, 'auth555'); | ||
}, TEST_AUTH_KEY); | ||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
@@ -555,3 +557,3 @@ method: 'POST', | ||
data: { plan: 'gold', quantity: '12' }, | ||
auth: 'auth555' | ||
auth: TEST_AUTH_KEY | ||
}); | ||
@@ -582,3 +584,3 @@ | ||
quantity: '2' | ||
}, 'sk_foo'); | ||
}, TEST_AUTH_KEY); | ||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
@@ -588,3 +590,3 @@ method: 'POST', | ||
data: { quantity: '2' }, | ||
auth: 'sk_foo' | ||
auth: TEST_AUTH_KEY | ||
}); | ||
@@ -611,3 +613,3 @@ | ||
stripe.customers.cancelSubscription('customerIdFoo321', 'subscriptionIdFoo456', 'auth921'); | ||
stripe.customers.cancelSubscription('customerIdFoo321', 'subscriptionIdFoo456', TEST_AUTH_KEY); | ||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
@@ -617,3 +619,3 @@ method: 'DELETE', | ||
data: {}, | ||
auth: 'auth921' | ||
auth: TEST_AUTH_KEY | ||
}); | ||
@@ -639,3 +641,3 @@ | ||
stripe.customers.cancelSubscription('customerIdFoo321', 'subscriptionIdFoo456', {at_period_end: true}, 'sk_foo'); | ||
stripe.customers.cancelSubscription('customerIdFoo321', 'subscriptionIdFoo456', {at_period_end: true}, TEST_AUTH_KEY); | ||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
@@ -645,3 +647,3 @@ method: 'DELETE', | ||
data: { at_period_end: true }, | ||
auth: 'sk_foo' | ||
auth: TEST_AUTH_KEY | ||
}); | ||
@@ -669,3 +671,3 @@ | ||
stripe.customers.listSubscriptions('customerIdFoo321', 'auth771'); | ||
stripe.customers.listSubscriptions('customerIdFoo321', TEST_AUTH_KEY); | ||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
@@ -675,3 +677,3 @@ method: 'GET', | ||
data: {}, | ||
auth: 'auth771' | ||
auth: TEST_AUTH_KEY | ||
}); | ||
@@ -678,0 +680,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
105568
2778