New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

stripe

Package Overview
Dependencies
Maintainers
4
Versions
671
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stripe - npm Package Compare versions

Comparing version 2.1.0-rc1 to 2.1.0-rc2

41

lib/StripeMethod.basic.js

@@ -35,7 +35,19 @@ 'use strict';

setMetadata: function(id, key, value, cb) {
setMetadata: function(id, key, value, auth, cb) {
var self = this;
var data = key;
var isObject = utils.isObject(key);
var data = key;
// We assume null for an empty object
var isNull = data === null || (isObject && !Object.keys(data).length);
// Allow optional passing of auth & cb:
if ((isNull || isObject) && typeof value == 'string') auth = value;
else if (typeof auth != 'string') {
if (!cb && typeof auth == 'function') {
cb = auth;
}
auth = null;
}
var urlData = this.createUrlData();

@@ -45,5 +57,5 @@ var deferred = this.createDeferred(cb);

if (data === null || (isObject && !Object.keys(data).length)) {
if (isNull) {
// Reset metadata:
sendMetadata(null);
sendMetadata(null, auth);
} else if (!isObject) {

@@ -53,3 +65,3 @@ // Set individual metadata property:

metadata[key] = value;
sendMetadata(metadata);
sendMetadata(metadata, auth);
} else {

@@ -59,12 +71,12 @@ // Set entire metadata object after resetting it:

metadata: null
}, function(err, response) {
}, auth, function(err, response) {
if (err) return deferred.reject(err);
sendMetadata(data);
sendMetadata(data, auth);
});
}
function sendMetadata(metadata) {
function sendMetadata(metadata, auth) {
self._request('POST', path, {
metadata: metadata
}, function(err, response) {
}, auth, function(err, response) {
if (err) deferred.reject(err);

@@ -79,4 +91,9 @@ else deferred.resolve(response.metadata);

getMetadata: function(id, key, cb) {
getMetadata: function(id, auth, cb) {
if (!cb && typeof auth == 'function') {
cb = auth;
auth = null;
}
var urlData = this.createUrlData();

@@ -86,6 +103,6 @@ var deferred = this.createDeferred(cb);

this._request('GET', path, {}, function(err, response) {
this._request('GET', path, {}, auth, function(err, response) {
if (err) deferred.reject(err);
else deferred.resolve(
key ? response.metadata[key] : response.metadata
response.metadata
);

@@ -92,0 +109,0 @@ });

@@ -29,2 +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 data = utils.isObject(args[args.length - 1]) ? args.pop() : {};

@@ -45,3 +46,3 @@ var urlData = this.createUrlData();

self._request(requestMethod, requestPath, data, function(err, response) {
self._request(requestMethod, requestPath, data, auth, function(err, response) {
if (err) {

@@ -48,0 +49,0 @@ deferred.reject(err);

@@ -83,3 +83,3 @@ 'use strict';

_request: function(method, path, data, callback) {
_request: function(method, path, data, auth, callback) {

@@ -91,3 +91,6 @@ var requestData = utils.stringifyRequestData(data || {});

var headers = {
'Authorization': this._stripe.getApiField('auth'),
// Use specified auth token or use default from this stripe instance:
'Authorization': auth ?
'Basic ' + new Buffer(auth + ':').toString('base64') :
this._stripe.getApiField('auth'),
'Accept': 'application/json',

@@ -94,0 +97,0 @@ 'Content-Type': 'application/x-www-form-urlencoded',

{
"name": "stripe",
"version": "2.1.0-rc1",
"version": "2.1.0-rc2",
"description": "Stripe API wrapper",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/stripe/stripe-node",

@@ -13,3 +13,3 @@ # Stripe node.js bindings

**Documentation is forthcoming** and will eventually be available at https://stripe.com/docs/api/node.
Documentation is available at https://stripe.com/docs/api/node.

@@ -70,9 +70,10 @@ ## API Overview

* [`retrieve(chargeId)`](https://stripe.com/docs/api/node#retrieve_charge)
* [`capture(chargeId)`](https://stripe.com/docs/api/node#charge_capture)
* [`refund(chargeId)`](https://stripe.com/docs/api/node#refund_charge)
* [`capture(chargeId[, params])`](https://stripe.com/docs/api/node#charge_capture)
* [`refund(chargeId[, params])`](https://stripe.com/docs/api/node#refund_charge)
* [`update(chargeId[, params])`](https://stripe.com/docs/api/node#update_charge)
* [`updateDispute(chargeId[, params])`](https://stripe.com/docs/api/node#update_dispute)
* [`closeDispute(chargeId[, params])`](https://stripe.com/docs/api/node#close_dispute)
* `setMetadata(chargeId[, params])` ([metadata info](https://stripe.com/docs/api/node#metadata))
* `getMetadata(chargeId[, params])` ([metadata info](https://stripe.com/docs/api/node#metadata))
* `setMetadata(chargeId, metadataObject)` ([metadata info](https://stripe.com/docs/api/node#metadata))
* `setMetadata(chargeId, key, value)`
* `getMetadata(chargeId)`
* coupons

@@ -89,4 +90,5 @@ * [`create(params)`](https://stripe.com/docs/api/node#create_coupon)

* [`del(customerId)`](https://stripe.com/docs/api/node#delete_customer)
* `setMetadata(customerId[, params])` ([metadata info](https://stripe.com/docs/api/node#metadata))
* `getMetadata(customerId[, params])` ([metadata info](https://stripe.com/docs/api/node#metadata))
* `setMetadata(customerId, metadataObject)` ([metadata info](https://stripe.com/docs/api/node#metadata))
* `setMetadata(customerId, key, value)`
* `getMetadata(customerId)`
* [`updateSubscription(customerId[, params])`](https://stripe.com/docs/api/node#update_subscription)

@@ -129,4 +131,5 @@ * [`cancelSubscription(customerId)`](https://stripe.com/docs/api/node#cancel_subscription)

* [`del(recipientId)`](https://stripe.com/docs/api/node#delete_recipient)
* `setMetadata(recipientId[, params])` ([metadata info](https://stripe.com/docs/api/node#metadata))
* `getMetadata(recipientId[, params])` ([metadata info](https://stripe.com/docs/api/node#metadata))
* `setMetadata(recipientId, metadataObject)` ([metadata info](https://stripe.com/docs/api/node#metadata))
* `setMetadata(recipientId, key, value)`
* `getMetadata(recipientId)`
* tokens

@@ -141,4 +144,5 @@ * [`create(params)`](https://stripe.com/docs/api/node#create_card_token)

* [`cancel(transferId)`](https://stripe.com/docs/api/node#cancel_transfer)
* `setMetadata(transferId[, params])` ([metadata info](https://stripe.com/docs/api/node#metadata))
* `getMetadata(transferId[, params])` ([metadata info](https://stripe.com/docs/api/node#metadata))
* `setMetadata(transferId, metadataObject)` ([metadata info](https://stripe.com/docs/api/node#metadata))
* `setMetadata(transferId, key, value)`
* `getMetadata(transferId)`

@@ -145,0 +149,0 @@ ## Development

@@ -200,4 +200,5 @@ 'use strict';

});
it('Can get individual metadata keys', function() {
it('Can set individual key/value pairs [with per request token]', function() {
var customer;
var authToken = testUtils.getUserStripeKey();
return expect(

@@ -210,8 +211,22 @@ stripe.customers.create(CUSTOMER_DETAILS)

.then(function() {
return stripe.customers.setMetadata(customer.id, 'baz', '444');
return stripe.customers.setMetadata(customer.id, {'baz': 456}, authToken);
})
.then(function() {
return stripe.customers.getMetadata(customer.id, 'baz');
return stripe.customers.setMetadata(customer.id, '_other_', 999, authToken);
})
).to.eventually.become('444');
.then(function() {
return stripe.customers.setMetadata(customer.id, 'foo', 123, authToken);
})
.then(function() {
// Change foo
return stripe.customers.setMetadata(customer.id, 'foo', 222, authToken);
})
.then(function() {
// Delete baz
return stripe.customers.setMetadata(customer.id, 'baz', null, authToken);
})
.then(function() {
return stripe.customers.getMetadata(customer.id, authToken);
})
).to.eventually.deep.equal({ _other_: "999", foo: "222" });
});

@@ -243,4 +258,9 @@ });

});
it('Allows me to do so with specified auth key', function() {
return expect(
stripe.balance.retrieve(testUtils.getUserStripeKey())
).to.eventually.have.property('object', 'balance');
});
});
});

@@ -21,2 +21,14 @@ 'use strict';

it('Sends the correct request [with specified auth]', function() {
stripe.balance.retrieve('auth38838111');
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/balance',
data: {},
auth: 'auth38838111'
});
});
});

@@ -37,2 +49,14 @@

it('Sends the correct request [with specified auth]', function() {
stripe.balance.listTransactions('auth4733234');
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/balance/history',
data: {},
auth: 'auth4733234'
});
});
});

@@ -53,4 +77,16 @@

it('Sends the correct request [with specified auth]', function() {
stripe.balance.retrieveTransaction('transactionIdFoo', 'auth9132432424');
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/balance/history/transactionIdFoo',
data: {},
auth: 'auth9132432424'
});
});
});
});

@@ -59,7 +59,7 @@ 'use strict';

stripe.charges.capture('chargeIdExample3242');
stripe.charges.capture('chargeIdExample3242', { amount: 23 });
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'POST',
url: '/v1/charges/chargeIdExample3242/capture',
data: {}
data: { amount: 23 }
});

@@ -90,7 +90,7 @@

stripe.charges.refund('chargeIdExample3242');
stripe.charges.refund('chargeIdExample3242', { amount: 23 });
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'POST',
url: '/v1/charges/chargeIdExample3242/refund',
data: {}
data: { amount: 23 }
});

@@ -97,0 +97,0 @@

@@ -22,2 +22,14 @@ 'use strict';

it('Sends the correct request [with specified auth]', function() {
stripe.customers.retrieve('cus_2dkAb792h1mfa4', 'Auth482');
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/customers/cus_2dkAb792h1mfa4',
data: {},
auth: 'Auth482'
});
});
});

@@ -38,2 +50,14 @@

it('Sends the correct request [with specified auth]', function() {
stripe.customers.create({ description: 'Some customer' }, 'Auth324');
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'POST',
url: '/v1/customers',
data: { description: 'Some customer' },
auth: 'Auth324'
});
});
});

@@ -86,2 +110,14 @@

it('Sends the correct request [with specified auth]', function() {
stripe.customers.list('Auth842');
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/customers',
data: {},
auth: 'Auth842'
});
});
});

@@ -106,2 +142,16 @@

it('Sends the correct request [with specified auth]', function() {
stripe.customers.updateSubscription('customerIdFoo321', {
plan: 'fooPlan'
}, 'auth981');
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'POST',
url: '/v1/customers/customerIdFoo321/subscription',
data: { plan: 'fooPlan' },
auth: 'auth981'
});
});
});

@@ -205,2 +255,34 @@

describe('When setting with an auth key', function() {
it('Sends the correct request, including the specified auth key', function() {
stripe.customers.setMetadata('customerIdFoo321', null, 'authKey133');
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'POST',
url: '/v1/customers/customerIdFoo321',
data: {
metadata: null
},
auth: 'authKey133'
});
stripe.customers.setMetadata('customerIdFoo321', 'a', '1234', 'authKey133');
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'POST',
url: '/v1/customers/customerIdFoo321',
data: {
metadata: { a: '1234' }
},
auth: 'authKey133'
});
stripe.customers.setMetadata('customerIdFoo321', 'a', null, 'authKey133');
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'POST',
url: '/v1/customers/customerIdFoo321',
data: {
metadata: { a: null }
},
auth: 'authKey133'
});
});
});
});

@@ -225,2 +307,14 @@

it('Sends the correct request [with specified auth]', function() {
stripe.customers.retrieveCard('customerIdFoo321', 'cardIdFoo456', 'auth123');
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/customers/customerIdFoo321/cards/cardIdFoo456',
data: {},
auth: 'auth123'
});
});
});

@@ -243,2 +337,16 @@

it('Sends the correct request [with specified auth]', function() {
stripe.customers.createCard('customerIdFoo321', {
number: '123456', exp_month: '12'
}, 'auth555');
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'POST',
url: '/v1/customers/customerIdFoo321/cards',
data: { number: '123456', exp_month: '12' },
auth: 'auth555'
});
});
});

@@ -276,2 +384,14 @@

it('Sends the correct request [with specified auth]', function() {
stripe.customers.deleteCard('customerIdFoo321', 'cardIdFoo456', 'auth921');
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'DELETE',
url: '/v1/customers/customerIdFoo321/cards/cardIdFoo456',
data: {},
auth: 'auth921'
});
});
});

@@ -292,2 +412,14 @@

it('Sends the correct request [with specified auth]', function() {
stripe.customers.listCards('customerIdFoo321', 'auth771');
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/customers/customerIdFoo321/cards',
data: {},
auth: 'auth771'
});
});
});

@@ -294,0 +426,0 @@

@@ -42,10 +42,10 @@ 'use strict';

// REQUESTS and LAST_REQUEST):
stripeInstance[i]._request = function(method, url, data, cb) {
stripeInstance.REQUESTS.push(
stripeInstance.LAST_REQUEST = {
method: method,
url: url,
data: data
}
);
stripeInstance[i]._request = function(method, url, data, auth, cb) {
var req = stripeInstance.LAST_REQUEST = {
method: method,
url: url,
data: data
};
if (auth) req.auth = auth;
stripeInstance.REQUESTS.push(req);
cb.call(this, null, {});

@@ -52,0 +52,0 @@ };

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc