From 23e3821e242ed63f8817417f098dc86ce72a67f0 Mon Sep 17 00:00:00 2001 From: Scott Erickson <sderickson@gmail.com> Date: Wed, 9 Dec 2015 14:27:10 -0800 Subject: [PATCH] Switch from jasmine-node to jasmine, run server tests on a single process This collapses the difference between master and single-process-server-tests, to remove some larger fixtures files that were in that feature branch. --- .travis.yml | 3 +- package.json | 4 +- server.coffee | 4 +- server/commons/database.coffee | 11 +- server/lib/apple_utils.coffee | 6 + server/payments/payment_handler.coffee | 5 +- server/prepaids/prepaid_handler.coffee | 2 +- server/routes/auth.coffee | 6 + server/users/User.coffee | 2 +- server_config.coffee | 2 +- spec/fixtures/db-discount-handler-test-1.json | 13 + spec/fixtures/db-discount-handler-test-2.json | 11 + spec/fixtures/db-discount-handler-test-3.json | 11 + spec/fixtures/db-discount-handler-test-4.json | 1 + spec/fixtures/db-discount-handler-test-5.json | 11 + spec/fixtures/db-discount-handler-test-6.json | 99 + spec/fixtures/db-discount-handler-test-7.json | 127 + spec/fixtures/db-discount-handler-test-8.json | 61 + spec/fixtures/db-discount-handler-test-9.json | 127 + spec/fixtures/db-payment-apple-test-1.json | 24 + spec/fixtures/db-payment-apple-test-2.json | 24 + spec/fixtures/db-payment-apple-test-3.json | 24 + spec/fixtures/db-payment-apple-test-4.json | 24 + ...-payment-check-stripe-charges-test-01.json | 133 + .../db-payment-custom-stripe-test-01.json | 104 + .../db-payment-custom-stripe-test-02.json | 95 + .../db-payment-custom-stripe-test-03.json | 89 + spec/fixtures/db-payment-stripe-test-01.json | 104 + spec/fixtures/db-payment-stripe-test-02.json | 42 + spec/fixtures/db-payment-stripe-test-03.json | 55 + spec/fixtures/db-payment-stripe-test-04.json | 170 + spec/fixtures/db-payment-stripe-test-05.json | 168 + spec/fixtures/db-payment-stripe-test-06.json | 91 + spec/fixtures/db-payment-stripe-test-07.json | 66 + spec/fixtures/db-payment-stripe-test-08.json | 84 + spec/fixtures/db-payment-stripe-test-09.json | 102 + spec/fixtures/db-payment-stripe-test-10.json | 120 + .../db-prepaid-purchase-course-test-1.json | 15 + .../db-prepaid-purchase-course-test-2.json | 95 + .../db-prepaid-purchase-course-test-3.json | 67 + .../db-prepaid-purchase-term-sub-test-1.json | 15 + .../db-prepaid-purchase-term-sub-test-2.json | 15 + .../db-prepaid-purchase-term-sub-test-3.json | 15 + .../db-prepaid-purchase-term-sub-test-4.json | 15 + .../db-prepaid-purchase-term-sub-test-5.json | 15 + .../db-prepaid-purchase-term-sub-test-6.json | 15 + .../db-prepaid-purchase-term-sub-test-7.json | 15 + .../db-prepaid-purchase-term-sub-test-8.json | 265 ++ spec/fixtures/db-sub-redeem-test-1.json | 157 + spec/fixtures/db-sub-redeem-test-2.json | 96 + spec/fixtures/db-user-sub-test-1.json | 26 + spec/fixtures/db-user-sub-test-2.json | 64 + spec/fixtures/db-user-sub-test-3.json | 116 + spec/fixtures/db-user-sub-test-4.json | 68 + spec/fixtures/db-user-sub-test-5.json | 115 + spec/fixtures/db-user-sub-test-6.json | 97 + spec/fixtures/db-user-sub-test-7.json | 68 + spec/fixtures/db-user-sub-test-8.json | 248 ++ spec/fixtures/sub-test-01.json | 92 + spec/fixtures/sub-test-02.json | 196 ++ spec/fixtures/sub-test-03.json | 314 ++ spec/fixtures/sub-test-04.json | 388 +++ spec/fixtures/sub-test-05.json | 264 ++ spec/fixtures/sub-test-06.json | 430 +++ spec/fixtures/sub-test-07.json | 246 ++ spec/fixtures/sub-test-08.json | 188 ++ spec/fixtures/sub-test-09.json | 240 ++ spec/fixtures/sub-test-10.json | 52 + spec/fixtures/sub-test-11.json | 24 + spec/fixtures/sub-test-12.json | 24 + spec/fixtures/sub-test-13.json | 572 ++++ spec/fixtures/sub-test-14.json | 649 ++++ spec/fixtures/sub-test-15.json | 960 ++++++ spec/fixtures/sub-test-16.json | 993 ++++++ spec/fixtures/sub-test-17.json | 731 +++++ spec/fixtures/sub-test-18.json | 1306 ++++++++ spec/fixtures/sub-test-19.json | 1291 ++++++++ spec/fixtures/sub-test-20.json | 120 + spec/fixtures/sub-test-21.json | 1014 ++++++ spec/fixtures/sub-test-22.json | 1151 +++++++ spec/fixtures/sub-test-23.json | 564 ++++ spec/fixtures/sub-test-24.json | 545 ++++ spec/fixtures/sub-test-25.json | 572 ++++ spec/fixtures/sub-test-26.json | 2713 ++++++++++++++++ spec/fixtures/sub-test-27.json | 1340 ++++++++ spec/fixtures/sub-test-28.json | 120 + spec/fixtures/sub-test-29.json | 736 +++++ spec/fixtures/sub-test-30.json | 256 ++ spec/fixtures/sub-test-31.json | 842 +++++ spec/fixtures/sub-test-32.json | 1836 +++++++++++ spec/fixtures/sub-test-33.json | 2811 +++++++++++++++++ spec/fixtures/sub-test-35.json | 94 + spec/fixtures/sub-test-36.json | 94 + spec/fixtures/sub-test-37.json | 94 + spec/fixtures/sub-test-38.json | 94 + spec/fixtures/sub-test-39.json | 359 +++ spec/fixtures/sub-test-40.json | 15 + spec/helpers/helper.js | 71 + {test => spec}/server/common.coffee | 27 +- .../server/functional/achievement.spec.coffee | 38 +- .../server/functional/admin.spec.coffee | 0 .../server/functional/article.spec.coffee | 0 .../server/functional/auth.spec.coffee | 0 .../functional/campaign_handler.spec.coffee | 0 .../server/functional/clan.spec.coffee | 0 .../server/functional/classrooms.spec.coffee | 0 .../functional/course_instance.spec.coffee | 32 +- .../functional/db-id-version.spec.coffee | 0 .../functional/discount_handler.spec.coffee | 134 + .../server/functional/file.spec.coffee | 0 .../server/functional/folder.spec.coffee | 0 .../server/functional/languages.spec.coffee | 0 .../server/functional/level.spec.coffee | 0 .../functional/level_component.spec.coffee | 5 - .../functional/level_feedback.spec.coffee | 0 .../functional/level_session.spec.coffee | 0 .../functional/level_system.spec.coffee | 0 .../level_thang_component.spec.coffee | 0 .../functional/level_thang_type.spec.coffee | 0 .../server/functional/mail.spec.coffee | 0 spec/server/functional/nocked.spec.coffee | 29 + .../server/functional/patch.spec.coffee | 0 spec/server/functional/payment.spec.coffee | 483 +++ .../server/functional/prepaid.spec.coffee | 483 +-- .../server/functional/queue.spec.coffee | 0 .../functional/subscription.spec.coffee | 940 +++--- .../functional/trial_request.spec.coffee | 0 .../server/functional/user.spec.coffee | 15 +- {test => spec}/server/init.coffee | 0 .../integration/models/Level.spec.coffee | 0 .../models/LevelComponent.spec.coffee | 0 .../models/LevelSession.spec.coffee | 0 .../models/LevelSystem.spec.coffee | 0 .../models/LevelThangType.spec.coffee | 0 .../integration/models/article.spec.coffee | 0 .../integration/models/plugins.spec.coffee | 0 spec/server/nock-utils.coffee | 78 + .../server/unit/analytics.spec.coffee | 0 {test => spec}/server/unit/patch.spec.coffee | 0 {test => spec}/server/unit/user.spec.coffee | 0 spec/support/jasmine.json | 10 + .../functional/discount_handler.spec.coffee | 114 - test/server/functional/payment.spec.coffee | 437 --- 143 files changed, 29579 insertions(+), 1274 deletions(-) create mode 100644 server/lib/apple_utils.coffee create mode 100644 spec/fixtures/db-discount-handler-test-1.json create mode 100644 spec/fixtures/db-discount-handler-test-2.json create mode 100644 spec/fixtures/db-discount-handler-test-3.json create mode 100644 spec/fixtures/db-discount-handler-test-4.json create mode 100644 spec/fixtures/db-discount-handler-test-5.json create mode 100644 spec/fixtures/db-discount-handler-test-6.json create mode 100644 spec/fixtures/db-discount-handler-test-7.json create mode 100644 spec/fixtures/db-discount-handler-test-8.json create mode 100644 spec/fixtures/db-discount-handler-test-9.json create mode 100644 spec/fixtures/db-payment-apple-test-1.json create mode 100644 spec/fixtures/db-payment-apple-test-2.json create mode 100644 spec/fixtures/db-payment-apple-test-3.json create mode 100644 spec/fixtures/db-payment-apple-test-4.json create mode 100644 spec/fixtures/db-payment-check-stripe-charges-test-01.json create mode 100644 spec/fixtures/db-payment-custom-stripe-test-01.json create mode 100644 spec/fixtures/db-payment-custom-stripe-test-02.json create mode 100644 spec/fixtures/db-payment-custom-stripe-test-03.json create mode 100644 spec/fixtures/db-payment-stripe-test-01.json create mode 100644 spec/fixtures/db-payment-stripe-test-02.json create mode 100644 spec/fixtures/db-payment-stripe-test-03.json create mode 100644 spec/fixtures/db-payment-stripe-test-04.json create mode 100644 spec/fixtures/db-payment-stripe-test-05.json create mode 100644 spec/fixtures/db-payment-stripe-test-06.json create mode 100644 spec/fixtures/db-payment-stripe-test-07.json create mode 100644 spec/fixtures/db-payment-stripe-test-08.json create mode 100644 spec/fixtures/db-payment-stripe-test-09.json create mode 100644 spec/fixtures/db-payment-stripe-test-10.json create mode 100644 spec/fixtures/db-prepaid-purchase-course-test-1.json create mode 100644 spec/fixtures/db-prepaid-purchase-course-test-2.json create mode 100644 spec/fixtures/db-prepaid-purchase-course-test-3.json create mode 100644 spec/fixtures/db-prepaid-purchase-term-sub-test-1.json create mode 100644 spec/fixtures/db-prepaid-purchase-term-sub-test-2.json create mode 100644 spec/fixtures/db-prepaid-purchase-term-sub-test-3.json create mode 100644 spec/fixtures/db-prepaid-purchase-term-sub-test-4.json create mode 100644 spec/fixtures/db-prepaid-purchase-term-sub-test-5.json create mode 100644 spec/fixtures/db-prepaid-purchase-term-sub-test-6.json create mode 100644 spec/fixtures/db-prepaid-purchase-term-sub-test-7.json create mode 100644 spec/fixtures/db-prepaid-purchase-term-sub-test-8.json create mode 100644 spec/fixtures/db-sub-redeem-test-1.json create mode 100644 spec/fixtures/db-sub-redeem-test-2.json create mode 100644 spec/fixtures/db-user-sub-test-1.json create mode 100644 spec/fixtures/db-user-sub-test-2.json create mode 100644 spec/fixtures/db-user-sub-test-3.json create mode 100644 spec/fixtures/db-user-sub-test-4.json create mode 100644 spec/fixtures/db-user-sub-test-5.json create mode 100644 spec/fixtures/db-user-sub-test-6.json create mode 100644 spec/fixtures/db-user-sub-test-7.json create mode 100644 spec/fixtures/db-user-sub-test-8.json create mode 100644 spec/fixtures/sub-test-01.json create mode 100644 spec/fixtures/sub-test-02.json create mode 100644 spec/fixtures/sub-test-03.json create mode 100644 spec/fixtures/sub-test-04.json create mode 100644 spec/fixtures/sub-test-05.json create mode 100644 spec/fixtures/sub-test-06.json create mode 100644 spec/fixtures/sub-test-07.json create mode 100644 spec/fixtures/sub-test-08.json create mode 100644 spec/fixtures/sub-test-09.json create mode 100644 spec/fixtures/sub-test-10.json create mode 100644 spec/fixtures/sub-test-11.json create mode 100644 spec/fixtures/sub-test-12.json create mode 100644 spec/fixtures/sub-test-13.json create mode 100644 spec/fixtures/sub-test-14.json create mode 100644 spec/fixtures/sub-test-15.json create mode 100644 spec/fixtures/sub-test-16.json create mode 100644 spec/fixtures/sub-test-17.json create mode 100644 spec/fixtures/sub-test-18.json create mode 100644 spec/fixtures/sub-test-19.json create mode 100644 spec/fixtures/sub-test-20.json create mode 100644 spec/fixtures/sub-test-21.json create mode 100644 spec/fixtures/sub-test-22.json create mode 100644 spec/fixtures/sub-test-23.json create mode 100644 spec/fixtures/sub-test-24.json create mode 100644 spec/fixtures/sub-test-25.json create mode 100644 spec/fixtures/sub-test-26.json create mode 100644 spec/fixtures/sub-test-27.json create mode 100644 spec/fixtures/sub-test-28.json create mode 100644 spec/fixtures/sub-test-29.json create mode 100644 spec/fixtures/sub-test-30.json create mode 100644 spec/fixtures/sub-test-31.json create mode 100644 spec/fixtures/sub-test-32.json create mode 100644 spec/fixtures/sub-test-33.json create mode 100644 spec/fixtures/sub-test-35.json create mode 100644 spec/fixtures/sub-test-36.json create mode 100644 spec/fixtures/sub-test-37.json create mode 100644 spec/fixtures/sub-test-38.json create mode 100644 spec/fixtures/sub-test-39.json create mode 100644 spec/fixtures/sub-test-40.json create mode 100644 spec/helpers/helper.js rename {test => spec}/server/common.coffee (91%) rename {test => spec}/server/functional/achievement.spec.coffee (91%) rename {test => spec}/server/functional/admin.spec.coffee (100%) rename {test => spec}/server/functional/article.spec.coffee (100%) rename {test => spec}/server/functional/auth.spec.coffee (100%) rename {test => spec}/server/functional/campaign_handler.spec.coffee (100%) rename {test => spec}/server/functional/clan.spec.coffee (100%) rename {test => spec}/server/functional/classrooms.spec.coffee (100%) rename {test => spec}/server/functional/course_instance.spec.coffee (98%) rename {test => spec}/server/functional/db-id-version.spec.coffee (100%) create mode 100644 spec/server/functional/discount_handler.spec.coffee rename {test => spec}/server/functional/file.spec.coffee (100%) rename {test => spec}/server/functional/folder.spec.coffee (100%) rename {test => spec}/server/functional/languages.spec.coffee (100%) rename {test => spec}/server/functional/level.spec.coffee (100%) rename {test => spec}/server/functional/level_component.spec.coffee (96%) rename {test => spec}/server/functional/level_feedback.spec.coffee (100%) rename {test => spec}/server/functional/level_session.spec.coffee (100%) rename {test => spec}/server/functional/level_system.spec.coffee (100%) rename {test => spec}/server/functional/level_thang_component.spec.coffee (100%) rename {test => spec}/server/functional/level_thang_type.spec.coffee (100%) rename {test => spec}/server/functional/mail.spec.coffee (100%) create mode 100644 spec/server/functional/nocked.spec.coffee rename {test => spec}/server/functional/patch.spec.coffee (100%) create mode 100644 spec/server/functional/payment.spec.coffee rename {test => spec}/server/functional/prepaid.spec.coffee (61%) rename {test => spec}/server/functional/queue.spec.coffee (100%) rename {test => spec}/server/functional/subscription.spec.coffee (70%) rename {test => spec}/server/functional/trial_request.spec.coffee (100%) rename {test => spec}/server/functional/user.spec.coffee (98%) rename {test => spec}/server/init.coffee (100%) rename {test => spec}/server/integration/models/Level.spec.coffee (100%) rename {test => spec}/server/integration/models/LevelComponent.spec.coffee (100%) rename {test => spec}/server/integration/models/LevelSession.spec.coffee (100%) rename {test => spec}/server/integration/models/LevelSystem.spec.coffee (100%) rename {test => spec}/server/integration/models/LevelThangType.spec.coffee (100%) rename {test => spec}/server/integration/models/article.spec.coffee (100%) rename {test => spec}/server/integration/models/plugins.spec.coffee (100%) create mode 100644 spec/server/nock-utils.coffee rename {test => spec}/server/unit/analytics.spec.coffee (100%) rename {test => spec}/server/unit/patch.spec.coffee (100%) rename {test => spec}/server/unit/user.spec.coffee (100%) create mode 100644 spec/support/jasmine.json delete mode 100644 test/server/functional/discount_handler.spec.coffee delete mode 100644 test/server/functional/payment.spec.coffee diff --git a/.travis.yml b/.travis.yml index 1be94f5ab..e2fe43667 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,6 @@ cache: - bower_components before_install: - - "gem install sass" - export COCO_TRAVIS_TEST=1 - npm install -g npm@latest @@ -29,5 +28,5 @@ before_script: - "sleep 10" # to give node a chance to start script: - - "./node_modules/jasmine-node/bin/jasmine-node test/server/ --coffee --captureExceptions" - "./node_modules/karma/bin/karma start --browsers Firefox --single-run --reporters progress" + - "npm run jasmine" diff --git a/package.json b/package.json index 6064390c6..9f8a487af 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "nodemon": "nodemon", "jasmine-node": "jasmine-node", "multicore": "coffee multicore.coffee", - "nodemon": "nodemon" + "jasmine": "jasmine" }, "main": "index.js", "keywords": [ @@ -98,6 +98,7 @@ "css-brunch": "^1.7.0", "fs-extra": "^0.26.2", "jade-brunch": "1.7.5", + "jasmine": "^2.3.2", "jasmine-node": "1.13.x", "jasmine-spec-reporter": "~0.3.0", "javascript-brunch": "> 1.0 < 1.8", @@ -112,6 +113,7 @@ "karma-requirejs": "~0.2.1", "karma-script-launcher": "~0.1.0", "marked": "0.2.x", + "nock": "^2.17.0", "nodemon": "1.6.1", "requirejs": "~2.1.10", "sass-brunch": "https://github.com/basicer/sass-brunch-bleeding/archive/1.9.1-bleeding.tar.gz", diff --git a/server.coffee b/server.coffee index 74e791e84..320bdfbd5 100644 --- a/server.coffee +++ b/server.coffee @@ -10,9 +10,9 @@ http = require 'http' log = require 'winston' serverSetup = require './server_setup' -module.exports.startServer = -> +module.exports.startServer = (done) -> app = createAndConfigureApp() - http.createServer(app).listen(app.get('port')) + http.createServer(app).listen app.get('port'), -> done?() log.info('Express SSL server listening on port ' + app.get('port')) app diff --git a/server/commons/database.coffee b/server/commons/database.coffee index eb531e101..5de8db577 100644 --- a/server/commons/database.coffee +++ b/server/commons/database.coffee @@ -4,9 +4,6 @@ mongoose = require 'mongoose' Grid = require 'gridfs-stream' mongooseCache = require 'mongoose-cache' -global.testing = testing = '--unittest' in process.argv - - module.exports.connect = () -> address = module.exports.generateMongoConnectionString() winston.info "Connecting to Mongo with connection string #{address}" @@ -22,15 +19,15 @@ module.exports.connect = () -> mongooseCache.install(mongoose, {max: 1000, maxAge: maxAge, debug: false}, Aggregate) module.exports.generateMongoConnectionString = -> - if not testing and config.tokyo + if not global.testing and config.tokyo address = config.mongo.mongoose_tokyo_replica_string - else if not testing and config.saoPaulo + else if not global.testing and config.saoPaulo address = config.mongo.mongoose_saoPaulo_replica_string - else if not testing and config.mongo.mongoose_replica_string + else if not global.testing and config.mongo.mongoose_replica_string address = config.mongo.mongoose_replica_string else dbName = config.mongo.db - dbName += '_unittest' if testing + dbName += '_unittest' if global.testing address = config.mongo.host + ':' + config.mongo.port if config.mongo.username and config.mongo.password address = config.mongo.username + ':' + config.mongo.password + '@' + address diff --git a/server/lib/apple_utils.coffee b/server/lib/apple_utils.coffee new file mode 100644 index 000000000..50d5f504f --- /dev/null +++ b/server/lib/apple_utils.coffee @@ -0,0 +1,6 @@ +config = require '../../server_config' + +module.exports.verifyReceipt = (receipt, done) -> + formFields = { 'receipt-data': receipt } + request.post {url: config.apple.verifyURL, json: formFields}, (err, res, body) -> + done(err, body) diff --git a/server/payments/payment_handler.coffee b/server/payments/payment_handler.coffee index 516a82b59..a70f0c630 100644 --- a/server/payments/payment_handler.coffee +++ b/server/payments/payment_handler.coffee @@ -9,6 +9,7 @@ hipchat = require '../hipchat' config = require '../../server_config' request = require 'request' async = require 'async' +apple_utils = require '../lib/apple_utils' products = { 'gems_5': { @@ -99,11 +100,9 @@ PaymentHandler = class PaymentHandler extends Handler #- Apple payments handleApplePaymentPost: (req, res, receipt, transactionID, localPrice) -> - formFields = { 'receipt-data': receipt } - #- verify receipt with Apple - verifyReq = request.post({url: config.apple.verifyURL, json: formFields}, (err, verifyRes, body) => + apple_utils.verifyReceipt(receipt, (err, body) => if err or not body?.receipt?.in_app or (not body?.bundle_id is 'com.codecombat.CodeCombat') console.warn 'apple receipt error?', err, body @logPaymentError(req, 'Unable to verify apple receipt') diff --git a/server/prepaids/prepaid_handler.coffee b/server/prepaids/prepaid_handler.coffee index 6896d4dcf..0b5e8e984 100644 --- a/server/prepaids/prepaid_handler.coffee +++ b/server/prepaids/prepaid_handler.coffee @@ -80,8 +80,8 @@ PrepaidHandler = class PrepaidHandler extends Handler User.findById(req.body.userID).exec (err, user) => return @sendDatabaseError(res, err) if err return @sendNotFoundError(res, 'User for given ID not found') if not user - userID = user.get('_id') return @sendSuccess(res, @formatEntity(req, prepaid)) if user.get('coursePrepaidID') + userID = user.get('_id') query = _id: prepaid.get('_id') diff --git a/server/routes/auth.coffee b/server/routes/auth.coffee index 0ea0b61e5..d70090c45 100644 --- a/server/routes/auth.coffee +++ b/server/routes/auth.coffee @@ -197,8 +197,14 @@ module.exports.loginUser = loginUser = (req, res, user, send=true, next=null) -> ) ) +module.exports.idCounter = 0 + module.exports.makeNewUser = makeNewUser = (req) -> user = new User({anonymous: true}) + if global.testing + # allows tests some control over user id creation + newID = _.pad((module.exports.idCounter++).toString(16), 24, '0') + user.set('_id', newID) user.set 'testGroupNumber', Math.floor(Math.random() * 256) # also in app/core/auth lang = languages.languageCodeFromAcceptedLanguages req.acceptedLanguages user.set 'preferredLanguage', lang if lang[...2] isnt 'en' diff --git a/server/users/User.coffee b/server/users/User.coffee index 10622d8db..c5b46dcf1 100644 --- a/server/users/User.coffee +++ b/server/users/User.coffee @@ -149,7 +149,7 @@ UserSchema.statics.updateServiceSettings = (doc, callback) -> doc.updatedMailChimp = true callback?() - mc?.lists.subscribe params, onSuccess, onFailure unless config.unittest + mc?.lists.subscribe params, onSuccess, onFailure UserSchema.statics.statsMapping = edits: diff --git a/server_config.coffee b/server_config.coffee index b8468f4c9..0f21219bf 100644 --- a/server_config.coffee +++ b/server_config.coffee @@ -1,6 +1,6 @@ config = {} -config.unittest = process.argv.indexOf('--unittest') > -1 +config.unittest = global.testing config.tokyo = process.env.TOKYO or false config.saoPaulo = process.env.SAOPAULO or false diff --git a/spec/fixtures/db-discount-handler-test-1.json b/spec/fixtures/db-discount-handler-test-1.json new file mode 100644 index 000000000..cac40a560 --- /dev/null +++ b/spec/fixtures/db-discount-handler-test-1.json @@ -0,0 +1,13 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/coupons/DNE", + "status": 404, + "response": { + "error": { + "type": "invalid_request_error" + } + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-discount-handler-test-2.json b/spec/fixtures/db-discount-handler-test-2.json new file mode 100644 index 000000000..7b33cd8f7 --- /dev/null +++ b/spec/fixtures/db-discount-handler-test-2.json @@ -0,0 +1,11 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/coupons/20pct", + "status": 200, + "response": { + "id": "20pct" + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-discount-handler-test-3.json b/spec/fixtures/db-discount-handler-test-3.json new file mode 100644 index 000000000..294b572f0 --- /dev/null +++ b/spec/fixtures/db-discount-handler-test-3.json @@ -0,0 +1,11 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/coupons/500off", + "status": 200, + "response": { + "id": "500off" + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-discount-handler-test-4.json b/spec/fixtures/db-discount-handler-test-4.json new file mode 100644 index 000000000..0637a088a --- /dev/null +++ b/spec/fixtures/db-discount-handler-test-4.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/spec/fixtures/db-discount-handler-test-5.json b/spec/fixtures/db-discount-handler-test-5.json new file mode 100644 index 000000000..294b572f0 --- /dev/null +++ b/spec/fixtures/db-discount-handler-test-5.json @@ -0,0 +1,11 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/coupons/500off", + "status": 200, + "response": { + "id": "500off" + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-discount-handler-test-6.json b/spec/fixtures/db-discount-handler-test-6.json new file mode 100644 index 000000000..3249a2bc5 --- /dev/null +++ b/spec/fixtures/db-discount-handler-test-6.json @@ -0,0 +1,99 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCUnKaReE7xLUdVx6ixF1h", + "card": { + "id": "card_17GCUnKaReE7xLUdZ8FpRcR5" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VCuNWxO5eWsQG", + "alipay_accounts": { + "has_more": false + }, + "email": "normal@jo.com", + "metadata": { + "id": "00000000000000000000005d" + }, + "sources": { + "data": [ + { + "id": "card_17GCUnKaReE7xLUdZ8FpRcR5", + "customer": "cus_7VCuNWxO5eWsQG" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VCuNWxO5eWsQG/subscriptions", + "status": 200, + "response": { + "id": "sub_7VCuZWrSt0bF8c", + "cancel_at_period_end": false, + "current_period_end": 1452363418, + "current_period_start": 1449685018, + "customer": "cus_7VCuNWxO5eWsQG", + "discount": { + "coupon": { + "id": "500off" + }, + "customer": "cus_7VCuNWxO5eWsQG", + "subscription": "sub_7VCuZWrSt0bF8c" + }, + "metadata": { + "id": "00000000000000000000005d" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VCuNWxO5eWsQG/subscriptions/sub_7VCuZWrSt0bF8c", + "status": 200, + "response": { + "id": "sub_7VCuZWrSt0bF8c", + "cancel_at_period_end": false, + "current_period_end": 1452363418, + "current_period_start": 1449685018, + "customer": "cus_7VCuNWxO5eWsQG", + "discount": { + "coupon": { + "id": "500off" + }, + "customer": "cus_7VCuNWxO5eWsQG", + "subscription": "sub_7VCuZWrSt0bF8c" + }, + "metadata": { + "id": "00000000000000000000005d" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-discount-handler-test-7.json b/spec/fixtures/db-discount-handler-test-7.json new file mode 100644 index 000000000..bcc286b7d --- /dev/null +++ b/spec/fixtures/db-discount-handler-test-7.json @@ -0,0 +1,127 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/coupons/20pct", + "status": 200, + "response": { + "id": "20pct" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VCuNWxO5eWsQG", + "status": 200, + "response": { + "id": "cus_7VCuNWxO5eWsQG", + "alipay_accounts": { + "has_more": false + }, + "discount": { + "coupon": { + "id": "20pct" + }, + "customer": "cus_7VCuNWxO5eWsQG" + }, + "email": "normal@jo.com", + "metadata": { + "id": "00000000000000000000005d" + }, + "sources": { + "data": [ + { + "id": "card_17GCUnKaReE7xLUdZ8FpRcR5", + "customer": "cus_7VCuNWxO5eWsQG" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VCuZWrSt0bF8c", + "cancel_at_period_end": false, + "current_period_end": 1452363418, + "current_period_start": 1449685018, + "customer": "cus_7VCuNWxO5eWsQG", + "discount": { + "coupon": { + "id": "500off" + }, + "customer": "cus_7VCuNWxO5eWsQG", + "subscription": "sub_7VCuZWrSt0bF8c" + }, + "metadata": { + "id": "00000000000000000000005d" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VCuNWxO5eWsQG", + "status": 200, + "response": { + "id": "cus_7VCuNWxO5eWsQG", + "alipay_accounts": { + "has_more": false + }, + "discount": { + "coupon": { + "id": "20pct" + }, + "customer": "cus_7VCuNWxO5eWsQG" + }, + "email": "normal@jo.com", + "metadata": { + "id": "00000000000000000000005d" + }, + "sources": { + "data": [ + { + "id": "card_17GCUnKaReE7xLUdZ8FpRcR5", + "customer": "cus_7VCuNWxO5eWsQG" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VCuZWrSt0bF8c", + "cancel_at_period_end": false, + "current_period_end": 1452363418, + "current_period_start": 1449685018, + "customer": "cus_7VCuNWxO5eWsQG", + "discount": { + "coupon": { + "id": "500off" + }, + "customer": "cus_7VCuNWxO5eWsQG", + "subscription": "sub_7VCuZWrSt0bF8c" + }, + "metadata": { + "id": "00000000000000000000005d" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-discount-handler-test-8.json b/spec/fixtures/db-discount-handler-test-8.json new file mode 100644 index 000000000..8a20e77c2 --- /dev/null +++ b/spec/fixtures/db-discount-handler-test-8.json @@ -0,0 +1,61 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "DELETE", + "path": "/v1/customers/cus_7VCuNWxO5eWsQG/discount", + "status": 200, + "response": {} + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VCuNWxO5eWsQG", + "status": 200, + "response": { + "id": "cus_7VCuNWxO5eWsQG", + "alipay_accounts": { + "has_more": false + }, + "email": "normal@jo.com", + "metadata": { + "id": "00000000000000000000005d" + }, + "sources": { + "data": [ + { + "id": "card_17GCUnKaReE7xLUdZ8FpRcR5", + "customer": "cus_7VCuNWxO5eWsQG" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VCuZWrSt0bF8c", + "cancel_at_period_end": false, + "current_period_end": 1452363418, + "current_period_start": 1449685018, + "customer": "cus_7VCuNWxO5eWsQG", + "discount": { + "coupon": { + "id": "500off" + }, + "customer": "cus_7VCuNWxO5eWsQG", + "subscription": "sub_7VCuZWrSt0bF8c" + }, + "metadata": { + "id": "00000000000000000000005d" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-discount-handler-test-9.json b/spec/fixtures/db-discount-handler-test-9.json new file mode 100644 index 000000000..bcc286b7d --- /dev/null +++ b/spec/fixtures/db-discount-handler-test-9.json @@ -0,0 +1,127 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/coupons/20pct", + "status": 200, + "response": { + "id": "20pct" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VCuNWxO5eWsQG", + "status": 200, + "response": { + "id": "cus_7VCuNWxO5eWsQG", + "alipay_accounts": { + "has_more": false + }, + "discount": { + "coupon": { + "id": "20pct" + }, + "customer": "cus_7VCuNWxO5eWsQG" + }, + "email": "normal@jo.com", + "metadata": { + "id": "00000000000000000000005d" + }, + "sources": { + "data": [ + { + "id": "card_17GCUnKaReE7xLUdZ8FpRcR5", + "customer": "cus_7VCuNWxO5eWsQG" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VCuZWrSt0bF8c", + "cancel_at_period_end": false, + "current_period_end": 1452363418, + "current_period_start": 1449685018, + "customer": "cus_7VCuNWxO5eWsQG", + "discount": { + "coupon": { + "id": "500off" + }, + "customer": "cus_7VCuNWxO5eWsQG", + "subscription": "sub_7VCuZWrSt0bF8c" + }, + "metadata": { + "id": "00000000000000000000005d" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VCuNWxO5eWsQG", + "status": 200, + "response": { + "id": "cus_7VCuNWxO5eWsQG", + "alipay_accounts": { + "has_more": false + }, + "discount": { + "coupon": { + "id": "20pct" + }, + "customer": "cus_7VCuNWxO5eWsQG" + }, + "email": "normal@jo.com", + "metadata": { + "id": "00000000000000000000005d" + }, + "sources": { + "data": [ + { + "id": "card_17GCUnKaReE7xLUdZ8FpRcR5", + "customer": "cus_7VCuNWxO5eWsQG" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VCuZWrSt0bF8c", + "cancel_at_period_end": false, + "current_period_end": 1452363418, + "current_period_start": 1449685018, + "customer": "cus_7VCuNWxO5eWsQG", + "discount": { + "coupon": { + "id": "500off" + }, + "customer": "cus_7VCuNWxO5eWsQG", + "subscription": "sub_7VCuZWrSt0bF8c" + }, + "metadata": { + "id": "00000000000000000000005d" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-payment-apple-test-1.json b/spec/fixtures/db-payment-apple-test-1.json new file mode 100644 index 000000000..053bcb5e4 --- /dev/null +++ b/spec/fixtures/db-payment-apple-test-1.json @@ -0,0 +1,24 @@ +[ + { + "scope": "https://sandbox.itunes.apple.com:443", + "method": "POST", + "path": "/verifyReceipt", + "status": 200, + "response": { + "receipt": { + "in_app": [ + { + "quantity": "1", + "product_id": "gems_5", + "transaction_id": "1000000131274439" + }, + { + "quantity": "1", + "product_id": "gems_10", + "transaction_id": "1000000131283608" + } + ] + } + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-payment-apple-test-2.json b/spec/fixtures/db-payment-apple-test-2.json new file mode 100644 index 000000000..053bcb5e4 --- /dev/null +++ b/spec/fixtures/db-payment-apple-test-2.json @@ -0,0 +1,24 @@ +[ + { + "scope": "https://sandbox.itunes.apple.com:443", + "method": "POST", + "path": "/verifyReceipt", + "status": 200, + "response": { + "receipt": { + "in_app": [ + { + "quantity": "1", + "product_id": "gems_5", + "transaction_id": "1000000131274439" + }, + { + "quantity": "1", + "product_id": "gems_10", + "transaction_id": "1000000131283608" + } + ] + } + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-payment-apple-test-3.json b/spec/fixtures/db-payment-apple-test-3.json new file mode 100644 index 000000000..053bcb5e4 --- /dev/null +++ b/spec/fixtures/db-payment-apple-test-3.json @@ -0,0 +1,24 @@ +[ + { + "scope": "https://sandbox.itunes.apple.com:443", + "method": "POST", + "path": "/verifyReceipt", + "status": 200, + "response": { + "receipt": { + "in_app": [ + { + "quantity": "1", + "product_id": "gems_5", + "transaction_id": "1000000131274439" + }, + { + "quantity": "1", + "product_id": "gems_10", + "transaction_id": "1000000131283608" + } + ] + } + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-payment-apple-test-4.json b/spec/fixtures/db-payment-apple-test-4.json new file mode 100644 index 000000000..053bcb5e4 --- /dev/null +++ b/spec/fixtures/db-payment-apple-test-4.json @@ -0,0 +1,24 @@ +[ + { + "scope": "https://sandbox.itunes.apple.com:443", + "method": "POST", + "path": "/verifyReceipt", + "status": 200, + "response": { + "receipt": { + "in_app": [ + { + "quantity": "1", + "product_id": "gems_5", + "transaction_id": "1000000131274439" + }, + { + "quantity": "1", + "product_id": "gems_10", + "transaction_id": "1000000131283608" + } + ] + } + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-payment-check-stripe-charges-test-01.json b/spec/fixtures/db-payment-check-stripe-charges-test-01.json new file mode 100644 index 000000000..468582df7 --- /dev/null +++ b/spec/fixtures/db-payment-check-stripe-charges-test-01.json @@ -0,0 +1,133 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCVJKaReE7xLUdzpXOGZ9v", + "card": { + "id": "card_17GCVJKaReE7xLUdKOWpllRX" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VCvE20H99SoVJ", + "alipay_accounts": { + "has_more": false + }, + "email": "normal@jo.com", + "metadata": { + "id": "00000000000000000000006a" + }, + "sources": { + "data": [ + { + "id": "card_17GCVJKaReE7xLUdKOWpllRX", + "customer": "cus_7VCvE20H99SoVJ" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/charges", + "status": 200, + "response": { + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VCvE20H99SoVJ", + "status": 200, + "response": { + "id": "cus_7VCvE20H99SoVJ", + "alipay_accounts": { + "has_more": false + }, + "email": "normal@jo.com", + "metadata": { + "id": "00000000000000000000006a" + }, + "sources": { + "data": [ + { + "id": "card_17GCVJKaReE7xLUdKOWpllRX", + "customer": "cus_7VCvE20H99SoVJ" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/charges", + "status": 200, + "response": { + "id": "ch_17GCVLKaReE7xLUdb9DcZ4om", + "amount": 499, + "customer": "cus_7VCvE20H99SoVJ", + "metadata": { + "productID": "gems_5", + "gems": "5000", + "timestamp": "1449685049575" + }, + "paid": true, + "refunds": { + "has_more": false + }, + "source": { + "id": "card_17GCVJKaReE7xLUdKOWpllRX", + "customer": "cus_7VCvE20H99SoVJ" + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/charges", + "status": 200, + "response": { + "data": [ + { + "id": "ch_17GCVLKaReE7xLUdb9DcZ4om", + "amount": 499, + "customer": "cus_7VCvE20H99SoVJ", + "metadata": { + "productID": "gems_5", + "gems": "5000", + "timestamp": "1449685049575" + }, + "paid": true, + "refunds": { + "has_more": false + }, + "source": { + "id": "card_17GCVJKaReE7xLUdKOWpllRX", + "customer": "cus_7VCvE20H99SoVJ" + } + } + ], + "has_more": false + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-payment-custom-stripe-test-01.json b/spec/fixtures/db-payment-custom-stripe-test-01.json new file mode 100644 index 000000000..38acb11c3 --- /dev/null +++ b/spec/fixtures/db-payment-custom-stripe-test-01.json @@ -0,0 +1,104 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCVNKaReE7xLUd2tmSQ1KH", + "card": { + "id": "card_17GCVMKaReE7xLUdZVTFHMmq" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VCvZ7KBrJ8csQ", + "alipay_accounts": { + "has_more": false + }, + "email": "normal@jo.com", + "metadata": { + "id": "00000000000000000000006b" + }, + "sources": { + "data": [ + { + "id": "card_17GCVMKaReE7xLUdZVTFHMmq", + "customer": "cus_7VCvZ7KBrJ8csQ" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/charges", + "status": 200, + "response": { + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VCvZ7KBrJ8csQ", + "status": 200, + "response": { + "id": "cus_7VCvZ7KBrJ8csQ", + "alipay_accounts": { + "has_more": false + }, + "email": "normal@jo.com", + "metadata": { + "id": "00000000000000000000006b" + }, + "sources": { + "data": [ + { + "id": "card_17GCVMKaReE7xLUdZVTFHMmq", + "customer": "cus_7VCvZ7KBrJ8csQ" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/charges", + "status": 200, + "response": { + "id": "ch_17GCVOKaReE7xLUd1ZQVMJKB", + "amount": 5000, + "customer": "cus_7VCvZ7KBrJ8csQ", + "metadata": { + "productID": "custom", + "timestamp": "1447445242091", + "description": "A sweet Coco t-shirt" + }, + "paid": true, + "refunds": { + "has_more": false + }, + "source": { + "id": "card_17GCVMKaReE7xLUdZVTFHMmq", + "customer": "cus_7VCvZ7KBrJ8csQ" + } + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-payment-custom-stripe-test-02.json b/spec/fixtures/db-payment-custom-stripe-test-02.json new file mode 100644 index 000000000..c3c2b6946 --- /dev/null +++ b/spec/fixtures/db-payment-custom-stripe-test-02.json @@ -0,0 +1,95 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCVPKaReE7xLUdJcZimvbF", + "card": { + "id": "card_17GCVPKaReE7xLUdRwBCjoW4" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VCvZ7KBrJ8csQ", + "status": 200, + "response": { + "id": "cus_7VCvZ7KBrJ8csQ", + "alipay_accounts": { + "has_more": false + }, + "email": "normal@jo.com", + "metadata": { + "id": "00000000000000000000006b" + }, + "sources": { + "data": [ + { + "id": "card_17GCVPKaReE7xLUdRwBCjoW4", + "customer": "cus_7VCvZ7KBrJ8csQ" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/charges", + "status": 200, + "response": { + "data": [ + { + "id": "ch_17GCVOKaReE7xLUd1ZQVMJKB", + "amount": 5000, + "customer": "cus_7VCvZ7KBrJ8csQ", + "metadata": { + "productID": "custom", + "timestamp": "1447445242091", + "description": "A sweet Coco t-shirt" + }, + "paid": true, + "refunds": { + "has_more": false + }, + "source": { + "id": "card_17GCVMKaReE7xLUdZVTFHMmq", + "customer": "cus_7VCvZ7KBrJ8csQ" + } + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/charges", + "status": 200, + "response": { + "id": "ch_17GCVSKaReE7xLUdd5E7dowz", + "amount": 73000, + "customer": "cus_7VCvZ7KBrJ8csQ", + "metadata": { + "productID": "custom", + "timestamp": "1447445242092" + }, + "paid": true, + "refunds": { + "has_more": false + }, + "source": { + "id": "card_17GCVPKaReE7xLUdRwBCjoW4", + "customer": "cus_7VCvZ7KBrJ8csQ" + } + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-payment-custom-stripe-test-03.json b/spec/fixtures/db-payment-custom-stripe-test-03.json new file mode 100644 index 000000000..2e22ae9e4 --- /dev/null +++ b/spec/fixtures/db-payment-custom-stripe-test-03.json @@ -0,0 +1,89 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCVTKaReE7xLUdOnqynJY7", + "card": { + "id": "card_17GCVSKaReE7xLUdjh0HgmFn" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VCvZ7KBrJ8csQ", + "status": 200, + "response": { + "id": "cus_7VCvZ7KBrJ8csQ", + "alipay_accounts": { + "has_more": false + }, + "email": "normal@jo.com", + "metadata": { + "id": "00000000000000000000006b" + }, + "sources": { + "data": [ + { + "id": "card_17GCVSKaReE7xLUdjh0HgmFn", + "customer": "cus_7VCvZ7KBrJ8csQ" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/charges", + "status": 200, + "response": { + "data": [ + { + "id": "ch_17GCVSKaReE7xLUdd5E7dowz", + "amount": 73000, + "customer": "cus_7VCvZ7KBrJ8csQ", + "metadata": { + "productID": "custom", + "timestamp": "1447445242092" + }, + "paid": true, + "refunds": { + "has_more": false + }, + "source": { + "id": "card_17GCVPKaReE7xLUdRwBCjoW4", + "customer": "cus_7VCvZ7KBrJ8csQ" + } + }, + { + "id": "ch_17GCVOKaReE7xLUd1ZQVMJKB", + "amount": 5000, + "customer": "cus_7VCvZ7KBrJ8csQ", + "metadata": { + "productID": "custom", + "timestamp": "1447445242091", + "description": "A sweet Coco t-shirt" + }, + "paid": true, + "refunds": { + "has_more": false + }, + "source": { + "id": "card_17GCVMKaReE7xLUdZVTFHMmq", + "customer": "cus_7VCvZ7KBrJ8csQ" + } + } + ], + "has_more": false + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-payment-stripe-test-01.json b/spec/fixtures/db-payment-stripe-test-01.json new file mode 100644 index 000000000..af554345d --- /dev/null +++ b/spec/fixtures/db-payment-stripe-test-01.json @@ -0,0 +1,104 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCUvKaReE7xLUdo7q79Zbp", + "card": { + "id": "card_17GCUvKaReE7xLUdBp1HF9sT" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VCubHuvGFt4nH", + "alipay_accounts": { + "has_more": false + }, + "email": "normal@jo.com", + "metadata": { + "id": "000000000000000000000067" + }, + "sources": { + "data": [ + { + "id": "card_17GCUvKaReE7xLUdBp1HF9sT", + "customer": "cus_7VCubHuvGFt4nH" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/charges", + "status": 200, + "response": { + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VCubHuvGFt4nH", + "status": 200, + "response": { + "id": "cus_7VCubHuvGFt4nH", + "alipay_accounts": { + "has_more": false + }, + "email": "normal@jo.com", + "metadata": { + "id": "000000000000000000000067" + }, + "sources": { + "data": [ + { + "id": "card_17GCUvKaReE7xLUdBp1HF9sT", + "customer": "cus_7VCubHuvGFt4nH" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/charges", + "status": 200, + "response": { + "id": "ch_17GCUxKaReE7xLUddy1fN9Nl", + "amount": 499, + "customer": "cus_7VCubHuvGFt4nH", + "metadata": { + "productID": "gems_5", + "gems": "5000", + "timestamp": "1447443579286" + }, + "paid": true, + "refunds": { + "has_more": false + }, + "source": { + "id": "card_17GCUvKaReE7xLUdBp1HF9sT", + "customer": "cus_7VCubHuvGFt4nH" + } + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-payment-stripe-test-02.json b/spec/fixtures/db-payment-stripe-test-02.json new file mode 100644 index 000000000..459f59788 --- /dev/null +++ b/spec/fixtures/db-payment-stripe-test-02.json @@ -0,0 +1,42 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VCubHuvGFt4nH", + "status": 400, + "response": { + "error": { + "type": "invalid_request_error" + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/charges", + "status": 200, + "response": { + "data": [ + { + "id": "ch_17GCUxKaReE7xLUddy1fN9Nl", + "amount": 499, + "customer": "cus_7VCubHuvGFt4nH", + "metadata": { + "productID": "gems_5", + "gems": "5000", + "timestamp": "1447443579286" + }, + "paid": true, + "refunds": { + "has_more": false + }, + "source": { + "id": "card_17GCUvKaReE7xLUdBp1HF9sT", + "customer": "cus_7VCubHuvGFt4nH" + } + } + ], + "has_more": false + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-payment-stripe-test-03.json b/spec/fixtures/db-payment-stripe-test-03.json new file mode 100644 index 000000000..5b0e1a3e6 --- /dev/null +++ b/spec/fixtures/db-payment-stripe-test-03.json @@ -0,0 +1,55 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/charges", + "status": 200, + "response": { + "data": [ + { + "id": "ch_17GCUxKaReE7xLUddy1fN9Nl", + "amount": 499, + "customer": "cus_7VCubHuvGFt4nH", + "metadata": { + "productID": "gems_5", + "gems": "5000", + "timestamp": "1447443579286" + }, + "paid": true, + "refunds": { + "has_more": false + }, + "source": { + "id": "card_17GCUvKaReE7xLUdBp1HF9sT", + "customer": "cus_7VCubHuvGFt4nH" + } + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/charges", + "status": 200, + "response": { + "id": "ch_17GCUzKaReE7xLUdviRu5P6Z", + "amount": 499, + "customer": "cus_7VCubHuvGFt4nH", + "metadata": { + "productID": "gems_5", + "gems": "5000", + "timestamp": "1449685028592" + }, + "paid": true, + "refunds": { + "has_more": false + }, + "source": { + "id": "card_17GCUvKaReE7xLUdBp1HF9sT", + "customer": "cus_7VCubHuvGFt4nH" + } + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-payment-stripe-test-04.json b/spec/fixtures/db-payment-stripe-test-04.json new file mode 100644 index 000000000..f4b4106bd --- /dev/null +++ b/spec/fixtures/db-payment-stripe-test-04.json @@ -0,0 +1,170 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VCubHuvGFt4nH", + "status": 200, + "response": { + "id": "cus_7VCubHuvGFt4nH", + "alipay_accounts": { + "has_more": false + }, + "email": "normal@jo.com", + "metadata": { + "id": "000000000000000000000067" + }, + "sources": { + "data": [ + { + "id": "card_17GCUvKaReE7xLUdBp1HF9sT", + "customer": "cus_7VCubHuvGFt4nH" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCV0KaReE7xLUd6riHo5io", + "card": { + "id": "card_17GCV0KaReE7xLUdA7hdLMnV" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VCubHuvGFt4nH", + "status": 200, + "response": { + "id": "cus_7VCubHuvGFt4nH", + "alipay_accounts": { + "has_more": false + }, + "email": "normal@jo.com", + "metadata": { + "id": "000000000000000000000067" + }, + "sources": { + "data": [ + { + "id": "card_17GCV0KaReE7xLUdA7hdLMnV", + "customer": "cus_7VCubHuvGFt4nH" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/charges", + "status": 200, + "response": { + "data": [ + { + "id": "ch_17GCUzKaReE7xLUdviRu5P6Z", + "amount": 499, + "customer": "cus_7VCubHuvGFt4nH", + "metadata": { + "productID": "gems_5", + "gems": "5000", + "timestamp": "1449685028592" + }, + "paid": true, + "refunds": { + "has_more": false + }, + "source": { + "id": "card_17GCUvKaReE7xLUdBp1HF9sT", + "customer": "cus_7VCubHuvGFt4nH" + } + }, + { + "id": "ch_17GCUxKaReE7xLUddy1fN9Nl", + "amount": 499, + "customer": "cus_7VCubHuvGFt4nH", + "metadata": { + "productID": "gems_5", + "gems": "5000", + "timestamp": "1447443579286" + }, + "paid": true, + "refunds": { + "has_more": false + }, + "source": { + "id": "card_17GCUvKaReE7xLUdBp1HF9sT", + "customer": "cus_7VCubHuvGFt4nH" + } + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/charges", + "status": 200, + "response": { + "id": "ch_17GCV2KaReE7xLUdffVpUhFO", + "amount": 499, + "customer": "cus_7VCubHuvGFt4nH", + "metadata": { + "productID": "gems_5", + "gems": "5000", + "timestamp": "1449685031026" + }, + "paid": true, + "refunds": { + "has_more": false + }, + "source": { + "id": "card_17GCV0KaReE7xLUdA7hdLMnV", + "customer": "cus_7VCubHuvGFt4nH" + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VCubHuvGFt4nH", + "status": 200, + "response": { + "id": "cus_7VCubHuvGFt4nH", + "alipay_accounts": { + "has_more": false + }, + "email": "normal@jo.com", + "metadata": { + "id": "000000000000000000000067" + }, + "sources": { + "data": [ + { + "id": "card_17GCV0KaReE7xLUdA7hdLMnV", + "customer": "cus_7VCubHuvGFt4nH" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-payment-stripe-test-05.json b/spec/fixtures/db-payment-stripe-test-05.json new file mode 100644 index 000000000..9a8f1f1c5 --- /dev/null +++ b/spec/fixtures/db-payment-stripe-test-05.json @@ -0,0 +1,168 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCV3KaReE7xLUdLcKedDEd", + "card": { + "id": "card_17GCV3KaReE7xLUdFUXfU85r" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VCuAQ6nYInY8z", + "alipay_accounts": { + "has_more": false + }, + "email": "normal@jo.com", + "metadata": { + "id": "000000000000000000000068" + }, + "sources": { + "data": [ + { + "id": "card_17GCV3KaReE7xLUdFUXfU85r", + "customer": "cus_7VCuAQ6nYInY8z" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/charges", + "status": 200, + "response": { + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VCuAQ6nYInY8z", + "status": 200, + "response": { + "id": "cus_7VCuAQ6nYInY8z", + "alipay_accounts": { + "has_more": false + }, + "email": "normal@jo.com", + "metadata": { + "id": "000000000000000000000068" + }, + "sources": { + "data": [ + { + "id": "card_17GCV3KaReE7xLUdFUXfU85r", + "customer": "cus_7VCuAQ6nYInY8z" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/charges", + "status": 200, + "response": { + "id": "ch_17GCV5KaReE7xLUd0amzDJs7", + "amount": 499, + "customer": "cus_7VCuAQ6nYInY8z", + "metadata": { + "productID": "gems_5", + "gems": "5000", + "timestamp": "1447443579286" + }, + "paid": true, + "refunds": { + "has_more": false + }, + "source": { + "id": "card_17GCV3KaReE7xLUdFUXfU85r", + "customer": "cus_7VCuAQ6nYInY8z" + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VCuAQ6nYInY8z", + "status": 400, + "response": { + "error": { + "type": "invalid_request_error" + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/charges", + "status": 200, + "response": { + "data": [ + { + "id": "ch_17GCV5KaReE7xLUd0amzDJs7", + "amount": 499, + "customer": "cus_7VCuAQ6nYInY8z", + "metadata": { + "productID": "gems_5", + "gems": "5000", + "timestamp": "1447443579286" + }, + "paid": true, + "refunds": { + "has_more": false + }, + "source": { + "id": "card_17GCV3KaReE7xLUdFUXfU85r", + "customer": "cus_7VCuAQ6nYInY8z" + } + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/charges", + "status": 200, + "response": { + "id": "ch_17GCV6KaReE7xLUdiTvUGa07", + "amount": 499, + "customer": "cus_7VCuAQ6nYInY8z", + "metadata": { + "productID": "gems_5", + "gems": "5000", + "timestamp": "1447443579286" + }, + "paid": true, + "refunds": { + "has_more": false + }, + "source": { + "id": "card_17GCV3KaReE7xLUdFUXfU85r", + "customer": "cus_7VCuAQ6nYInY8z" + } + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-payment-stripe-test-06.json b/spec/fixtures/db-payment-stripe-test-06.json new file mode 100644 index 000000000..c0a98e4f2 --- /dev/null +++ b/spec/fixtures/db-payment-stripe-test-06.json @@ -0,0 +1,91 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCV7KaReE7xLUd3gnnjv7x", + "card": { + "id": "card_17GCV7KaReE7xLUdiPjgEUMd" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VCuzP303kt1eU", + "alipay_accounts": { + "has_more": false + }, + "email": "normal@jo.com", + "metadata": { + "id": "000000000000000000000069" + }, + "sources": { + "data": [ + { + "id": "card_17GCV7KaReE7xLUdiPjgEUMd", + "customer": "cus_7VCuzP303kt1eU" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/charges", + "status": 200, + "response": { + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VCuzP303kt1eU", + "status": 200, + "response": { + "id": "cus_7VCuzP303kt1eU", + "alipay_accounts": { + "has_more": false + }, + "email": "normal@jo.com", + "metadata": { + "id": "000000000000000000000069" + }, + "sources": { + "data": [ + { + "id": "card_17GCV7KaReE7xLUdiPjgEUMd", + "customer": "cus_7VCuzP303kt1eU" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/charges", + "status": 402, + "response": { + "error": { + "type": "card_error" + } + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-payment-stripe-test-07.json b/spec/fixtures/db-payment-stripe-test-07.json new file mode 100644 index 000000000..9a7cab4b2 --- /dev/null +++ b/spec/fixtures/db-payment-stripe-test-07.json @@ -0,0 +1,66 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCV9KaReE7xLUdelU9sCaA", + "card": { + "id": "card_17GCV9KaReE7xLUd5uODONlo" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VCuzP303kt1eU", + "status": 402, + "response": { + "error": { + "type": "card_error" + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/charges", + "status": 200, + "response": { + "data": [ + { + "id": "ch_17GCV9KaReE7xLUduvVirhN5", + "amount": 499, + "customer": "cus_7VCuzP303kt1eU", + "metadata": { + "productID": "gems_5", + "gems": "5000", + "timestamp": "1449685037831" + }, + "paid": false, + "refunds": { + "has_more": false + }, + "source": { + "id": "card_17GCV7KaReE7xLUdiPjgEUMd", + "customer": "cus_7VCuzP303kt1eU" + } + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/charges", + "status": 402, + "response": { + "error": { + "type": "card_error" + } + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-payment-stripe-test-08.json b/spec/fixtures/db-payment-stripe-test-08.json new file mode 100644 index 000000000..3befce952 --- /dev/null +++ b/spec/fixtures/db-payment-stripe-test-08.json @@ -0,0 +1,84 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCVCKaReE7xLUdWbFQacYN", + "card": { + "id": "card_17GCVCKaReE7xLUdjoXBJKqC" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VCuzP303kt1eU", + "status": 402, + "response": { + "error": { + "type": "card_error" + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/charges", + "status": 200, + "response": { + "data": [ + { + "id": "ch_17GCVBKaReE7xLUduQybm6xT", + "amount": 499, + "customer": "cus_7VCuzP303kt1eU", + "metadata": { + "productID": "gems_5", + "gems": "5000", + "timestamp": "1449685040285" + }, + "paid": false, + "refunds": { + "has_more": false + }, + "source": { + "id": "card_17GCV7KaReE7xLUdiPjgEUMd", + "customer": "cus_7VCuzP303kt1eU" + } + }, + { + "id": "ch_17GCV9KaReE7xLUduvVirhN5", + "amount": 499, + "customer": "cus_7VCuzP303kt1eU", + "metadata": { + "productID": "gems_5", + "gems": "5000", + "timestamp": "1449685037831" + }, + "paid": false, + "refunds": { + "has_more": false + }, + "source": { + "id": "card_17GCV7KaReE7xLUdiPjgEUMd", + "customer": "cus_7VCuzP303kt1eU" + } + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/charges", + "status": 402, + "response": { + "error": { + "type": "card_error" + } + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-payment-stripe-test-09.json b/spec/fixtures/db-payment-stripe-test-09.json new file mode 100644 index 000000000..bd02c1026 --- /dev/null +++ b/spec/fixtures/db-payment-stripe-test-09.json @@ -0,0 +1,102 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCVEKaReE7xLUdByVccSzA", + "card": { + "id": "card_17GCVEKaReE7xLUdRUCeIUtP" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VCuzP303kt1eU", + "status": 402, + "response": { + "error": { + "type": "card_error" + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/charges", + "status": 200, + "response": { + "data": [ + { + "id": "ch_17GCVDKaReE7xLUdyZAPbXCM", + "amount": 499, + "customer": "cus_7VCuzP303kt1eU", + "metadata": { + "productID": "gems_5", + "gems": "5000", + "timestamp": "1449685042746" + }, + "paid": false, + "refunds": { + "has_more": false + }, + "source": { + "id": "card_17GCV7KaReE7xLUdiPjgEUMd", + "customer": "cus_7VCuzP303kt1eU" + } + }, + { + "id": "ch_17GCVBKaReE7xLUduQybm6xT", + "amount": 499, + "customer": "cus_7VCuzP303kt1eU", + "metadata": { + "productID": "gems_5", + "gems": "5000", + "timestamp": "1449685040285" + }, + "paid": false, + "refunds": { + "has_more": false + }, + "source": { + "id": "card_17GCV7KaReE7xLUdiPjgEUMd", + "customer": "cus_7VCuzP303kt1eU" + } + }, + { + "id": "ch_17GCV9KaReE7xLUduvVirhN5", + "amount": 499, + "customer": "cus_7VCuzP303kt1eU", + "metadata": { + "productID": "gems_5", + "gems": "5000", + "timestamp": "1449685037831" + }, + "paid": false, + "refunds": { + "has_more": false + }, + "source": { + "id": "card_17GCV7KaReE7xLUdiPjgEUMd", + "customer": "cus_7VCuzP303kt1eU" + } + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/charges", + "status": 402, + "response": { + "error": { + "type": "card_error" + } + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-payment-stripe-test-10.json b/spec/fixtures/db-payment-stripe-test-10.json new file mode 100644 index 000000000..1f7a23c02 --- /dev/null +++ b/spec/fixtures/db-payment-stripe-test-10.json @@ -0,0 +1,120 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCVHKaReE7xLUdB9odSMB6", + "card": { + "id": "card_17GCVHKaReE7xLUdAYwa1Wkj" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VCuzP303kt1eU", + "status": 402, + "response": { + "error": { + "type": "card_error" + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/charges", + "status": 200, + "response": { + "data": [ + { + "id": "ch_17GCVGKaReE7xLUdu3HU9wB5", + "amount": 499, + "customer": "cus_7VCuzP303kt1eU", + "metadata": { + "productID": "gems_5", + "gems": "5000", + "timestamp": "1449685044928" + }, + "paid": false, + "refunds": { + "has_more": false + }, + "source": { + "id": "card_17GCV7KaReE7xLUdiPjgEUMd", + "customer": "cus_7VCuzP303kt1eU" + } + }, + { + "id": "ch_17GCVDKaReE7xLUdyZAPbXCM", + "amount": 499, + "customer": "cus_7VCuzP303kt1eU", + "metadata": { + "productID": "gems_5", + "gems": "5000", + "timestamp": "1449685042746" + }, + "paid": false, + "refunds": { + "has_more": false + }, + "source": { + "id": "card_17GCV7KaReE7xLUdiPjgEUMd", + "customer": "cus_7VCuzP303kt1eU" + } + }, + { + "id": "ch_17GCVBKaReE7xLUduQybm6xT", + "amount": 499, + "customer": "cus_7VCuzP303kt1eU", + "metadata": { + "productID": "gems_5", + "gems": "5000", + "timestamp": "1449685040285" + }, + "paid": false, + "refunds": { + "has_more": false + }, + "source": { + "id": "card_17GCV7KaReE7xLUdiPjgEUMd", + "customer": "cus_7VCuzP303kt1eU" + } + }, + { + "id": "ch_17GCV9KaReE7xLUduvVirhN5", + "amount": 499, + "customer": "cus_7VCuzP303kt1eU", + "metadata": { + "productID": "gems_5", + "gems": "5000", + "timestamp": "1449685037831" + }, + "paid": false, + "refunds": { + "has_more": false + }, + "source": { + "id": "card_17GCV7KaReE7xLUdiPjgEUMd", + "customer": "cus_7VCuzP303kt1eU" + } + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/charges", + "status": 402, + "response": { + "error": { + "type": "card_error" + } + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-prepaid-purchase-course-test-1.json b/spec/fixtures/db-prepaid-purchase-course-test-1.json new file mode 100644 index 000000000..be2af91f9 --- /dev/null +++ b/spec/fixtures/db-prepaid-purchase-course-test-1.json @@ -0,0 +1,15 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCVVKaReE7xLUd9mYY9N7i", + "card": { + "id": "card_17GCVVKaReE7xLUdlhNMXbGd" + }, + "type": "card" + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-prepaid-purchase-course-test-2.json b/spec/fixtures/db-prepaid-purchase-course-test-2.json new file mode 100644 index 000000000..0c947bcf1 --- /dev/null +++ b/spec/fixtures/db-prepaid-purchase-course-test-2.json @@ -0,0 +1,95 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCVVKaReE7xLUdNnWusa8M", + "card": { + "id": "card_17GCVVKaReE7xLUdNzakl6za" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VCvt7iNlagXQA", + "alipay_accounts": { + "has_more": false + }, + "email": "user88@me.com", + "metadata": { + "id": "000000000000000000000080" + }, + "sources": { + "data": [ + { + "id": "card_17GCVVKaReE7xLUdNzakl6za", + "customer": "cus_7VCvt7iNlagXQA" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VCvt7iNlagXQA", + "status": 200, + "response": { + "id": "cus_7VCvt7iNlagXQA", + "alipay_accounts": { + "has_more": false + }, + "email": "user88@me.com", + "metadata": { + "id": "000000000000000000000080" + }, + "sources": { + "data": [ + { + "id": "card_17GCVVKaReE7xLUdNzakl6za", + "customer": "cus_7VCvt7iNlagXQA" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/charges", + "status": 200, + "response": { + "id": "ch_17GCVWKaReE7xLUdZLmqWCt6", + "amount": 400, + "customer": "cus_7VCvt7iNlagXQA", + "metadata": { + "type": "course", + "timestamp": "1449685061856", + "productID": "prepaid course" + }, + "paid": true, + "refunds": { + "has_more": false + }, + "source": { + "id": "card_17GCVVKaReE7xLUdNzakl6za", + "customer": "cus_7VCvt7iNlagXQA" + } + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-prepaid-purchase-course-test-3.json b/spec/fixtures/db-prepaid-purchase-course-test-3.json new file mode 100644 index 000000000..8fa107d42 --- /dev/null +++ b/spec/fixtures/db-prepaid-purchase-course-test-3.json @@ -0,0 +1,67 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCVXKaReE7xLUdOVrQZisx", + "card": { + "id": "card_17GCVXKaReE7xLUdFEluXOeu" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VCvUi50nXhjWn", + "alipay_accounts": { + "has_more": false + }, + "email": "user89@me.com", + "metadata": { + "id": "000000000000000000000081" + }, + "sources": { + "data": [ + { + "id": "card_17GCVXKaReE7xLUdFEluXOeu", + "customer": "cus_7VCvUi50nXhjWn" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/charges", + "status": 200, + "response": { + "id": "ch_17GCVYKaReE7xLUdstf63Kol", + "amount": 1200, + "customer": "cus_7VCvUi50nXhjWn", + "metadata": { + "type": "course", + "timestamp": "1449685063457", + "productID": "prepaid course" + }, + "paid": true, + "refunds": { + "has_more": false + }, + "source": { + "id": "card_17GCVXKaReE7xLUdFEluXOeu", + "customer": "cus_7VCvUi50nXhjWn" + } + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-prepaid-purchase-term-sub-test-1.json b/spec/fixtures/db-prepaid-purchase-term-sub-test-1.json new file mode 100644 index 000000000..9b4e85537 --- /dev/null +++ b/spec/fixtures/db-prepaid-purchase-term-sub-test-1.json @@ -0,0 +1,15 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCVZKaReE7xLUdc2sd97Kh", + "card": { + "id": "card_17GCVZKaReE7xLUdAQ3WCuCA" + }, + "type": "card" + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-prepaid-purchase-term-sub-test-2.json b/spec/fixtures/db-prepaid-purchase-term-sub-test-2.json new file mode 100644 index 000000000..aa3b517a8 --- /dev/null +++ b/spec/fixtures/db-prepaid-purchase-term-sub-test-2.json @@ -0,0 +1,15 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCVZKaReE7xLUdLm4xB9Q4", + "card": { + "id": "card_17GCVZKaReE7xLUdfv42GBHU" + }, + "type": "card" + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-prepaid-purchase-term-sub-test-3.json b/spec/fixtures/db-prepaid-purchase-term-sub-test-3.json new file mode 100644 index 000000000..f05b47fd1 --- /dev/null +++ b/spec/fixtures/db-prepaid-purchase-term-sub-test-3.json @@ -0,0 +1,15 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCVaKaReE7xLUdQP3U2KmC", + "card": { + "id": "card_17GCVaKaReE7xLUdCItK5QND" + }, + "type": "card" + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-prepaid-purchase-term-sub-test-4.json b/spec/fixtures/db-prepaid-purchase-term-sub-test-4.json new file mode 100644 index 000000000..9f1f67f9b --- /dev/null +++ b/spec/fixtures/db-prepaid-purchase-term-sub-test-4.json @@ -0,0 +1,15 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCVaKaReE7xLUdfcArqe1K", + "card": { + "id": "card_17GCVaKaReE7xLUdQXuE34GK" + }, + "type": "card" + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-prepaid-purchase-term-sub-test-5.json b/spec/fixtures/db-prepaid-purchase-term-sub-test-5.json new file mode 100644 index 000000000..bfd65c37e --- /dev/null +++ b/spec/fixtures/db-prepaid-purchase-term-sub-test-5.json @@ -0,0 +1,15 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCVaKaReE7xLUdZqrHnDcB", + "card": { + "id": "card_17GCVaKaReE7xLUdu0XGOs3Q" + }, + "type": "card" + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-prepaid-purchase-term-sub-test-6.json b/spec/fixtures/db-prepaid-purchase-term-sub-test-6.json new file mode 100644 index 000000000..5fe21d5cb --- /dev/null +++ b/spec/fixtures/db-prepaid-purchase-term-sub-test-6.json @@ -0,0 +1,15 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCVbKaReE7xLUdZSSwB8CG", + "card": { + "id": "card_17GCVbKaReE7xLUdsdKXR63y" + }, + "type": "card" + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-prepaid-purchase-term-sub-test-7.json b/spec/fixtures/db-prepaid-purchase-term-sub-test-7.json new file mode 100644 index 000000000..958b2e9af --- /dev/null +++ b/spec/fixtures/db-prepaid-purchase-term-sub-test-7.json @@ -0,0 +1,15 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCVbKaReE7xLUdswrosKLO", + "card": { + "id": "card_17GCVbKaReE7xLUdiINiC8ab" + }, + "type": "card" + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-prepaid-purchase-term-sub-test-8.json b/spec/fixtures/db-prepaid-purchase-term-sub-test-8.json new file mode 100644 index 000000000..d7bbd80d9 --- /dev/null +++ b/spec/fixtures/db-prepaid-purchase-term-sub-test-8.json @@ -0,0 +1,265 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCVcKaReE7xLUdB5HnT2wI", + "card": { + "id": "card_17GCVcKaReE7xLUd7R94nEhN" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VCvcfu4XzeCbM", + "alipay_accounts": { + "has_more": false + }, + "email": "normal@jo.com", + "metadata": { + "id": "000000000000000000000088" + }, + "sources": { + "data": [ + { + "id": "card_17GCVcKaReE7xLUd7R94nEhN", + "customer": "cus_7VCvcfu4XzeCbM" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VCvcfu4XzeCbM", + "status": 200, + "response": { + "id": "cus_7VCvcfu4XzeCbM", + "alipay_accounts": { + "has_more": false + }, + "email": "normal@jo.com", + "metadata": { + "id": "000000000000000000000088" + }, + "sources": { + "data": [ + { + "id": "card_17GCVcKaReE7xLUd7R94nEhN", + "customer": "cus_7VCvcfu4XzeCbM" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VCvcfu4XzeCbM/subscriptions", + "status": 200, + "response": { + "id": "sub_7VCvEG141oJimL", + "cancel_at_period_end": false, + "current_period_end": 1452363470, + "current_period_start": 1449685070, + "customer": "cus_7VCvcfu4XzeCbM", + "metadata": { + "id": "000000000000000000000088" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCVfKaReE7xLUdIvigMi5U", + "card": { + "id": "card_17GCVfKaReE7xLUdks8zeqw5" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VCvcfu4XzeCbM", + "status": 200, + "response": { + "id": "cus_7VCvcfu4XzeCbM", + "alipay_accounts": { + "has_more": false + }, + "email": "normal@jo.com", + "metadata": { + "id": "000000000000000000000088" + }, + "sources": { + "data": [ + { + "id": "card_17GCVcKaReE7xLUd7R94nEhN", + "customer": "cus_7VCvcfu4XzeCbM" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VCvEG141oJimL", + "cancel_at_period_end": false, + "current_period_end": 1452363470, + "current_period_start": 1449685070, + "customer": "cus_7VCvcfu4XzeCbM", + "metadata": { + "id": "000000000000000000000088" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VCvcfu4XzeCbM", + "status": 200, + "response": { + "id": "cus_7VCvcfu4XzeCbM", + "alipay_accounts": { + "has_more": false + }, + "email": "normal@jo.com", + "metadata": { + "id": "000000000000000000000088" + }, + "sources": { + "data": [ + { + "id": "card_17GCVfKaReE7xLUdks8zeqw5", + "customer": "cus_7VCvcfu4XzeCbM" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VCvEG141oJimL", + "cancel_at_period_end": false, + "current_period_end": 1452363470, + "current_period_start": 1449685070, + "customer": "cus_7VCvcfu4XzeCbM", + "metadata": { + "id": "000000000000000000000088" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VCvcfu4XzeCbM", + "status": 200, + "response": { + "id": "cus_7VCvcfu4XzeCbM", + "alipay_accounts": { + "has_more": false + }, + "email": "normal@jo.com", + "metadata": { + "id": "000000000000000000000088" + }, + "sources": { + "data": [ + { + "id": "card_17GCVfKaReE7xLUdks8zeqw5", + "customer": "cus_7VCvcfu4XzeCbM" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VCvEG141oJimL", + "cancel_at_period_end": false, + "current_period_end": 1452363470, + "current_period_start": 1449685070, + "customer": "cus_7VCvcfu4XzeCbM", + "metadata": { + "id": "000000000000000000000088" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/charges", + "status": 200, + "response": { + "id": "ch_17GCVgKaReE7xLUdTqpuyEWR", + "amount": 8991, + "customer": "cus_7VCvcfu4XzeCbM", + "metadata": { + "type": "terminal_subscription", + "timestamp": "1449685071367", + "months": "3", + "productID": "prepaid terminal_subscription" + }, + "paid": true, + "refunds": { + "has_more": false + }, + "source": { + "id": "card_17GCVfKaReE7xLUdks8zeqw5", + "customer": "cus_7VCvcfu4XzeCbM" + } + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-sub-redeem-test-1.json b/spec/fixtures/db-sub-redeem-test-1.json new file mode 100644 index 000000000..d61ffe024 --- /dev/null +++ b/spec/fixtures/db-sub-redeem-test-1.json @@ -0,0 +1,157 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VCvcfu4XzeCbM", + "status": 200, + "response": { + "id": "cus_7VCvcfu4XzeCbM", + "alipay_accounts": { + "has_more": false + }, + "email": "normal@jo.com", + "metadata": { + "id": "000000000000000000000088" + }, + "sources": { + "data": [ + { + "id": "card_17GCVfKaReE7xLUdks8zeqw5", + "customer": "cus_7VCvcfu4XzeCbM" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VCvEG141oJimL", + "cancel_at_period_end": false, + "current_period_end": 1452363470, + "current_period_start": 1449685070, + "customer": "cus_7VCvcfu4XzeCbM", + "metadata": { + "id": "000000000000000000000088" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VCvcfu4XzeCbM/subscriptions", + "status": 200, + "response": { + "data": [ + { + "id": "sub_7VCvEG141oJimL", + "cancel_at_period_end": false, + "current_period_end": 1452363470, + "current_period_start": 1449685070, + "customer": "cus_7VCvcfu4XzeCbM", + "metadata": { + "id": "000000000000000000000088" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VCvcfu4XzeCbM/subscriptions", + "status": 200, + "response": { + "data": [ + { + "id": "sub_7VCvEG141oJimL", + "cancel_at_period_end": false, + "current_period_end": 1452363470, + "current_period_start": 1449685070, + "customer": "cus_7VCvcfu4XzeCbM", + "metadata": { + "id": "000000000000000000000088" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "DELETE", + "path": "/v1/customers/cus_7VCvcfu4XzeCbM/subscriptions/sub_7VCvEG141oJimL", + "status": 200, + "response": { + "id": "sub_7VCvEG141oJimL", + "cancel_at_period_end": false, + "current_period_end": 1452363470, + "current_period_start": 1449685070, + "customer": "cus_7VCvcfu4XzeCbM", + "metadata": { + "id": "000000000000000000000088" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VCvcfu4XzeCbM", + "status": 200, + "response": { + "id": "cus_7VCvcfu4XzeCbM", + "alipay_accounts": { + "has_more": false + }, + "email": "normal@jo.com", + "metadata": { + "id": "000000000000000000000088" + }, + "sources": { + "data": [ + { + "id": "card_17GCVfKaReE7xLUdks8zeqw5", + "customer": "cus_7VCvcfu4XzeCbM" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VCvcfu4XzeCbM/subscriptions", + "status": 200, + "response": { + "has_more": false + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-sub-redeem-test-2.json b/spec/fixtures/db-sub-redeem-test-2.json new file mode 100644 index 000000000..de39900a8 --- /dev/null +++ b/spec/fixtures/db-sub-redeem-test-2.json @@ -0,0 +1,96 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCVlKaReE7xLUdrgB5G5sg", + "card": { + "id": "card_17GCVkKaReE7xLUdhnarn1rx" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VCvhVTldJ0ArC", + "alipay_accounts": { + "has_more": false + }, + "email": "user98@me.com", + "metadata": { + "id": "00000000000000000000008c" + }, + "sources": { + "data": [ + { + "id": "card_17GCVkKaReE7xLUdhnarn1rx", + "customer": "cus_7VCvhVTldJ0ArC" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VCvhVTldJ0ArC", + "status": 200, + "response": { + "id": "cus_7VCvhVTldJ0ArC", + "alipay_accounts": { + "has_more": false + }, + "email": "user98@me.com", + "metadata": { + "id": "00000000000000000000008c" + }, + "sources": { + "data": [ + { + "id": "card_17GCVkKaReE7xLUdhnarn1rx", + "customer": "cus_7VCvhVTldJ0ArC" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/charges", + "status": 200, + "response": { + "id": "ch_17GCVlKaReE7xLUd5D6k1v4E", + "amount": 2997, + "customer": "cus_7VCvhVTldJ0ArC", + "metadata": { + "type": "terminal_subscription", + "timestamp": "1449685077119", + "months": "1", + "productID": "prepaid terminal_subscription" + }, + "paid": true, + "refunds": { + "has_more": false + }, + "source": { + "id": "card_17GCVkKaReE7xLUdhnarn1rx", + "customer": "cus_7VCvhVTldJ0ArC" + } + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-user-sub-test-1.json b/spec/fixtures/db-user-sub-test-1.json new file mode 100644 index 000000000..edb31a159 --- /dev/null +++ b/spec/fixtures/db-user-sub-test-1.json @@ -0,0 +1,26 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCVmKaReE7xLUd3TTueitH", + "card": { + "id": "card_17GCVmKaReE7xLUdErwdQ45K" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 402, + "response": { + "error": { + "type": "card_error" + } + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-user-sub-test-2.json b/spec/fixtures/db-user-sub-test-2.json new file mode 100644 index 000000000..ae4fe47b2 --- /dev/null +++ b/spec/fixtures/db-user-sub-test-2.json @@ -0,0 +1,64 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCVoKaReE7xLUdWKRMzFDb", + "card": { + "id": "card_17GCVoKaReE7xLUdpf0crA0p" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VCvUEDSyqS8aN", + "alipay_accounts": { + "has_more": false + }, + "email": "normal@jo.com", + "metadata": { + "id": "0000000000000000000186a1" + }, + "sources": { + "data": [ + { + "id": "card_17GCVoKaReE7xLUdpf0crA0p", + "customer": "cus_7VCvUEDSyqS8aN" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VCvUEDSyqS8aN/subscriptions", + "status": 200, + "response": { + "id": "sub_7VCvXO37PhGOUY", + "cancel_at_period_end": false, + "current_period_end": 1452363481, + "current_period_start": 1449685081, + "customer": "cus_7VCvUEDSyqS8aN", + "metadata": { + "id": "0000000000000000000186a1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-user-sub-test-3.json b/spec/fixtures/db-user-sub-test-3.json new file mode 100644 index 000000000..938f5bfe2 --- /dev/null +++ b/spec/fixtures/db-user-sub-test-3.json @@ -0,0 +1,116 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices", + "status": 200, + "response": { + "data": [ + { + "id": "in_17GCVpKaReE7xLUdPDEmVDeD", + "customer": "cus_7VCvUEDSyqS8aN", + "lines": { + "data": [ + { + "id": "sub_7VCvXO37PhGOUY", + "amount": 999, + "metadata": { + "id": "0000000000000000000186a1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VCvXO37PhGOUY", + "total": 999 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCVpKaReE7xLUdPDEmVDeD", + "status": 200, + "response": { + "id": "in_17GCVpKaReE7xLUdPDEmVDeD", + "customer": "cus_7VCvUEDSyqS8aN", + "lines": { + "data": [ + { + "id": "sub_7VCvXO37PhGOUY", + "amount": 999, + "metadata": { + "id": "0000000000000000000186a1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VCvXO37PhGOUY", + "total": 999 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VCvUEDSyqS8aN", + "status": 200, + "response": { + "id": "cus_7VCvUEDSyqS8aN", + "alipay_accounts": { + "has_more": false + }, + "email": "normal@jo.com", + "metadata": { + "id": "0000000000000000000186a1" + }, + "sources": { + "data": [ + { + "id": "card_17GCVoKaReE7xLUdpf0crA0p", + "customer": "cus_7VCvUEDSyqS8aN" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VCvXO37PhGOUY", + "cancel_at_period_end": false, + "current_period_end": 1452363481, + "current_period_start": 1449685081, + "customer": "cus_7VCvUEDSyqS8aN", + "metadata": { + "id": "0000000000000000000186a1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-user-sub-test-4.json b/spec/fixtures/db-user-sub-test-4.json new file mode 100644 index 000000000..92340912b --- /dev/null +++ b/spec/fixtures/db-user-sub-test-4.json @@ -0,0 +1,68 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "DELETE", + "path": "/v1/customers/cus_7VCvUEDSyqS8aN/subscriptions/sub_7VCvXO37PhGOUY", + "status": 200, + "response": { + "id": "sub_7VCvXO37PhGOUY", + "cancel_at_period_end": true, + "current_period_end": 1452363481, + "current_period_start": 1449685081, + "customer": "cus_7VCvUEDSyqS8aN", + "metadata": { + "id": "0000000000000000000186a1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VCvUEDSyqS8aN", + "status": 200, + "response": { + "id": "cus_7VCvUEDSyqS8aN", + "alipay_accounts": { + "has_more": false + }, + "email": "normal@jo.com", + "metadata": { + "id": "0000000000000000000186a1" + }, + "sources": { + "data": [ + { + "id": "card_17GCVoKaReE7xLUdpf0crA0p", + "customer": "cus_7VCvUEDSyqS8aN" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VCvXO37PhGOUY", + "cancel_at_period_end": true, + "current_period_end": 1452363481, + "current_period_start": 1449685081, + "customer": "cus_7VCvUEDSyqS8aN", + "metadata": { + "id": "0000000000000000000186a1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-user-sub-test-5.json b/spec/fixtures/db-user-sub-test-5.json new file mode 100644 index 000000000..90b5c999d --- /dev/null +++ b/spec/fixtures/db-user-sub-test-5.json @@ -0,0 +1,115 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VCvUEDSyqS8aN", + "status": 200, + "response": { + "id": "cus_7VCvUEDSyqS8aN", + "alipay_accounts": { + "has_more": false + }, + "email": "normal@jo.com", + "metadata": { + "id": "0000000000000000000186a1" + }, + "sources": { + "data": [ + { + "id": "card_17GCVoKaReE7xLUdpf0crA0p", + "customer": "cus_7VCvUEDSyqS8aN" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VCvXO37PhGOUY", + "cancel_at_period_end": true, + "current_period_end": 1452363481, + "current_period_start": 1449685081, + "customer": "cus_7VCvUEDSyqS8aN", + "metadata": { + "id": "0000000000000000000186a1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VCvUEDSyqS8aN/subscriptions", + "status": 200, + "response": { + "data": [ + { + "id": "sub_7VCvXO37PhGOUY", + "cancel_at_period_end": true, + "current_period_end": 1452363481, + "current_period_start": 1449685081, + "customer": "cus_7VCvUEDSyqS8aN", + "metadata": { + "id": "0000000000000000000186a1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "DELETE", + "path": "/v1/customers/cus_7VCvUEDSyqS8aN/subscriptions/sub_7VCvXO37PhGOUY", + "status": 200, + "response": { + "id": "sub_7VCvXO37PhGOUY", + "cancel_at_period_end": true, + "current_period_end": 1452363481, + "current_period_start": 1449685081, + "customer": "cus_7VCvUEDSyqS8aN", + "metadata": { + "id": "0000000000000000000186a1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VCvUEDSyqS8aN/subscriptions", + "status": 200, + "response": { + "id": "sub_7VCv1YWFAmGmed", + "cancel_at_period_end": false, + "current_period_end": 1452363481, + "current_period_start": 1449685087, + "customer": "cus_7VCvUEDSyqS8aN", + "metadata": { + "id": "0000000000000000000186a1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-user-sub-test-6.json b/spec/fixtures/db-user-sub-test-6.json new file mode 100644 index 000000000..2751212d6 --- /dev/null +++ b/spec/fixtures/db-user-sub-test-6.json @@ -0,0 +1,97 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices", + "status": 200, + "response": { + "data": [ + { + "id": "in_17GCVvKaReE7xLUdPf2zkiYX", + "customer": "cus_7VCvUEDSyqS8aN", + "lines": { + "data": [ + { + "id": "sub_7VCv1YWFAmGmed", + "amount": 0, + "metadata": { + "id": "0000000000000000000186a1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VCv1YWFAmGmed", + "total": 0 + }, + { + "id": "in_17GCVpKaReE7xLUdPDEmVDeD", + "customer": "cus_7VCvUEDSyqS8aN", + "lines": { + "data": [ + { + "id": "sub_7VCvXO37PhGOUY", + "amount": 999, + "metadata": { + "id": "0000000000000000000186a1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VCvXO37PhGOUY", + "total": 999 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCVvKaReE7xLUdPf2zkiYX", + "status": 200, + "response": { + "id": "in_17GCVvKaReE7xLUdPf2zkiYX", + "customer": "cus_7VCvUEDSyqS8aN", + "lines": { + "data": [ + { + "id": "sub_7VCv1YWFAmGmed", + "amount": 0, + "metadata": { + "id": "0000000000000000000186a1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VCv1YWFAmGmed", + "total": 0 + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-user-sub-test-7.json b/spec/fixtures/db-user-sub-test-7.json new file mode 100644 index 000000000..1bd00595d --- /dev/null +++ b/spec/fixtures/db-user-sub-test-7.json @@ -0,0 +1,68 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VCvUEDSyqS8aN/subscriptions/sub_7VCv1YWFAmGmed", + "status": 200, + "response": { + "id": "sub_7VCv1YWFAmGmed", + "cancel_at_period_end": false, + "current_period_end": 1452363481, + "current_period_start": 1449685087, + "customer": "cus_7VCvUEDSyqS8aN", + "metadata": { + "id": "0000000000000000000186a1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VCvUEDSyqS8aN", + "status": 200, + "response": { + "id": "cus_7VCvUEDSyqS8aN", + "alipay_accounts": { + "has_more": false + }, + "email": "normal@jo.com", + "metadata": { + "id": "0000000000000000000186a1" + }, + "sources": { + "data": [ + { + "id": "card_17GCVoKaReE7xLUdpf0crA0p", + "customer": "cus_7VCvUEDSyqS8aN" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VCv1YWFAmGmed", + "cancel_at_period_end": false, + "current_period_end": 1452363481, + "current_period_start": 1449685087, + "customer": "cus_7VCvUEDSyqS8aN", + "metadata": { + "id": "0000000000000000000186a1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + } +] \ No newline at end of file diff --git a/spec/fixtures/db-user-sub-test-8.json b/spec/fixtures/db-user-sub-test-8.json new file mode 100644 index 000000000..4385f4a9d --- /dev/null +++ b/spec/fixtures/db-user-sub-test-8.json @@ -0,0 +1,248 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VCvUEDSyqS8aN", + "status": 200, + "response": { + "id": "cus_7VCvUEDSyqS8aN", + "alipay_accounts": { + "has_more": false + }, + "email": "normal@jo.com", + "metadata": { + "id": "0000000000000000000186a1" + }, + "sources": { + "data": [ + { + "id": "card_17GCVoKaReE7xLUdpf0crA0p", + "customer": "cus_7VCvUEDSyqS8aN" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VCv1YWFAmGmed", + "cancel_at_period_end": false, + "current_period_end": 1452363481, + "current_period_start": 1449685087, + "customer": "cus_7VCvUEDSyqS8aN", + "metadata": { + "id": "0000000000000000000186a1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VCvUEDSyqS8aN/subscriptions", + "status": 200, + "response": { + "id": "sub_7VCvB079Vlyv2a", + "cancel_at_period_end": false, + "current_period_end": 1452363490, + "current_period_start": 1449685090, + "customer": "cus_7VCvUEDSyqS8aN", + "metadata": { + "id": "0000000000000000000186a1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VCvUEDSyqS8aN", + "status": 200, + "response": { + "id": "cus_7VCvUEDSyqS8aN", + "alipay_accounts": { + "has_more": false + }, + "email": "newEmail@gmail.com", + "metadata": { + "id": "0000000000000000000186a1" + }, + "sources": { + "data": [ + { + "id": "card_17GCVoKaReE7xLUdpf0crA0p", + "customer": "cus_7VCvUEDSyqS8aN" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VCvB079Vlyv2a", + "cancel_at_period_end": false, + "current_period_end": 1452363490, + "current_period_start": 1449685090, + "customer": "cus_7VCvUEDSyqS8aN", + "metadata": { + "id": "0000000000000000000186a1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VCv1YWFAmGmed", + "cancel_at_period_end": false, + "current_period_end": 1452363481, + "current_period_start": 1449685087, + "customer": "cus_7VCvUEDSyqS8aN", + "metadata": { + "id": "0000000000000000000186a1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VCvUEDSyqS8aN", + "status": 200, + "response": { + "id": "cus_7VCvUEDSyqS8aN", + "alipay_accounts": { + "has_more": false + }, + "email": "newEmail@gmail.com", + "metadata": { + "id": "0000000000000000000186a1" + }, + "sources": { + "data": [ + { + "id": "card_17GCVoKaReE7xLUdpf0crA0p", + "customer": "cus_7VCvUEDSyqS8aN" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VCvB079Vlyv2a", + "cancel_at_period_end": false, + "current_period_end": 1452363490, + "current_period_start": 1449685090, + "customer": "cus_7VCvUEDSyqS8aN", + "metadata": { + "id": "0000000000000000000186a1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VCv1YWFAmGmed", + "cancel_at_period_end": false, + "current_period_end": 1452363481, + "current_period_start": 1449685087, + "customer": "cus_7VCvUEDSyqS8aN", + "metadata": { + "id": "0000000000000000000186a1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VCvUEDSyqS8aN", + "status": 200, + "response": { + "id": "cus_7VCvUEDSyqS8aN", + "alipay_accounts": { + "has_more": false + }, + "email": "newEmail@gmail.com", + "metadata": { + "id": "0000000000000000000186a1" + }, + "sources": { + "data": [ + { + "id": "card_17GCVoKaReE7xLUdpf0crA0p", + "customer": "cus_7VCvUEDSyqS8aN" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VCvB079Vlyv2a", + "cancel_at_period_end": false, + "current_period_end": 1452363490, + "current_period_start": 1449685090, + "customer": "cus_7VCvUEDSyqS8aN", + "metadata": { + "id": "0000000000000000000186a1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VCv1YWFAmGmed", + "cancel_at_period_end": false, + "current_period_end": 1452363481, + "current_period_start": 1449685087, + "customer": "cus_7VCvUEDSyqS8aN", + "metadata": { + "id": "0000000000000000000186a1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + } +] \ No newline at end of file diff --git a/spec/fixtures/sub-test-01.json b/spec/fixtures/sub-test-01.json new file mode 100644 index 000000000..4c834a172 --- /dev/null +++ b/spec/fixtures/sub-test-01.json @@ -0,0 +1,92 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCvTKaReE7xLUdvh4VgxLe", + "card": { + "id": "card_17GCvTKaReE7xLUdfBe38ijD" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDMXnBgJmAcyq", + "alipay_accounts": { + "has_more": false + }, + "email": "user100@me.com", + "metadata": { + "id": "0000000000000000000186a2" + }, + "sources": { + "data": [ + { + "id": "card_17GCvTKaReE7xLUdfBe38ijD", + "customer": "cus_7VDMXnBgJmAcyq" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDMXnBgJmAcyq", + "status": 200, + "response": { + "id": "cus_7VDMXnBgJmAcyq", + "alipay_accounts": { + "has_more": false + }, + "email": "user100@me.com", + "metadata": { + "id": "0000000000000000000186a2" + }, + "sources": { + "data": [ + { + "id": "card_17GCvTKaReE7xLUdfBe38ijD", + "customer": "cus_7VDMXnBgJmAcyq" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDMXnBgJmAcyq/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDMPjS8P0Au1a", + "cancel_at_period_end": false, + "current_period_end": 1452365072, + "current_period_start": 1449686672, + "customer": "cus_7VDMXnBgJmAcyq", + "metadata": { + "id": "0000000000000000000186a2" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + } +] \ No newline at end of file diff --git a/spec/fixtures/sub-test-02.json b/spec/fixtures/sub-test-02.json new file mode 100644 index 000000000..d60bb4008 --- /dev/null +++ b/spec/fixtures/sub-test-02.json @@ -0,0 +1,196 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCvVKaReE7xLUdWKG9Sa0e", + "card": { + "id": "card_17GCvVKaReE7xLUdcFaT6hqy" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDMJJrLqZe8Wi", + "alipay_accounts": { + "has_more": false + }, + "email": "user101@me.com", + "metadata": { + "id": "0000000000000000000186a3" + }, + "sources": { + "data": [ + { + "id": "card_17GCvVKaReE7xLUdcFaT6hqy", + "customer": "cus_7VDMJJrLqZe8Wi" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDMJJrLqZe8Wi/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDMlTOqYJPAT3", + "cancel_at_period_end": false, + "current_period_end": 1452365074, + "current_period_start": 1449686674, + "customer": "cus_7VDMJJrLqZe8Wi", + "metadata": { + "id": "0000000000000000000186a3" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDMJJrLqZe8Wi", + "status": 200, + "response": { + "id": "cus_7VDMJJrLqZe8Wi", + "alipay_accounts": { + "has_more": false + }, + "email": "user101@me.com", + "metadata": { + "id": "0000000000000000000186a3" + }, + "sources": { + "data": [ + { + "id": "card_17GCvVKaReE7xLUdcFaT6hqy", + "customer": "cus_7VDMJJrLqZe8Wi" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDMlTOqYJPAT3", + "cancel_at_period_end": false, + "current_period_end": 1452365074, + "current_period_start": 1449686674, + "customer": "cus_7VDMJJrLqZe8Wi", + "metadata": { + "id": "0000000000000000000186a3" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "DELETE", + "path": "/v1/customers/cus_7VDMJJrLqZe8Wi/subscriptions/sub_7VDMlTOqYJPAT3", + "status": 200, + "response": { + "id": "sub_7VDMlTOqYJPAT3", + "cancel_at_period_end": true, + "current_period_end": 1452365074, + "current_period_start": 1449686674, + "customer": "cus_7VDMJJrLqZe8Wi", + "metadata": { + "id": "0000000000000000000186a3" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDMJJrLqZe8Wi", + "status": 200, + "response": { + "id": "cus_7VDMJJrLqZe8Wi", + "alipay_accounts": { + "has_more": false + }, + "email": "user101@me.com", + "metadata": { + "id": "0000000000000000000186a3" + }, + "sources": { + "data": [ + { + "id": "card_17GCvVKaReE7xLUdcFaT6hqy", + "customer": "cus_7VDMJJrLqZe8Wi" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDMlTOqYJPAT3", + "cancel_at_period_end": true, + "current_period_end": 1452365074, + "current_period_start": 1449686674, + "customer": "cus_7VDMJJrLqZe8Wi", + "metadata": { + "id": "0000000000000000000186a3" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDMJJrLqZe8Wi/subscriptions/sub_7VDMlTOqYJPAT3", + "status": 200, + "response": { + "id": "sub_7VDMlTOqYJPAT3", + "cancel_at_period_end": true, + "current_period_end": 1452365074, + "current_period_start": 1449686674, + "customer": "cus_7VDMJJrLqZe8Wi", + "metadata": { + "id": "0000000000000000000186a3" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + } +] \ No newline at end of file diff --git a/spec/fixtures/sub-test-03.json b/spec/fixtures/sub-test-03.json new file mode 100644 index 000000000..6cb01f957 --- /dev/null +++ b/spec/fixtures/sub-test-03.json @@ -0,0 +1,314 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCvZKaReE7xLUdypujc0WH", + "card": { + "id": "card_17GCvZKaReE7xLUdwixI8vqT" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDMp8mEu4xG73", + "alipay_accounts": { + "has_more": false + }, + "email": "user102@me.com", + "metadata": { + "id": "0000000000000000000186a4" + }, + "sources": { + "data": [ + { + "id": "card_17GCvZKaReE7xLUdwixI8vqT", + "customer": "cus_7VDMp8mEu4xG73" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDMp8mEu4xG73", + "status": 200, + "response": { + "id": "cus_7VDMp8mEu4xG73", + "alipay_accounts": { + "has_more": false + }, + "email": "user102@me.com", + "metadata": { + "id": "0000000000000000000186a4" + }, + "sources": { + "data": [ + { + "id": "card_17GCvZKaReE7xLUdwixI8vqT", + "customer": "cus_7VDMp8mEu4xG73" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDMp8mEu4xG73/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDMsEr2xRuaqt", + "cancel_at_period_end": false, + "current_period_end": 1452365079, + "current_period_start": 1449686679, + "customer": "cus_7VDMp8mEu4xG73", + "metadata": { + "id": "0000000000000000000186a4" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDMp8mEu4xG73/subscriptions/sub_7VDMsEr2xRuaqt", + "status": 200, + "response": { + "id": "sub_7VDMsEr2xRuaqt", + "cancel_at_period_end": false, + "current_period_end": 1452365079, + "current_period_start": 1449686679, + "customer": "cus_7VDMp8mEu4xG73", + "metadata": { + "id": "0000000000000000000186a4" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDMp8mEu4xG73", + "status": 200, + "response": { + "id": "cus_7VDMp8mEu4xG73", + "alipay_accounts": { + "has_more": false + }, + "email": "user102@me.com", + "metadata": { + "id": "0000000000000000000186a4" + }, + "sources": { + "data": [ + { + "id": "card_17GCvZKaReE7xLUdwixI8vqT", + "customer": "cus_7VDMp8mEu4xG73" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDMsEr2xRuaqt", + "cancel_at_period_end": false, + "current_period_end": 1452365079, + "current_period_start": 1449686679, + "customer": "cus_7VDMp8mEu4xG73", + "metadata": { + "id": "0000000000000000000186a4" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "DELETE", + "path": "/v1/customers/cus_7VDMp8mEu4xG73/subscriptions/sub_7VDMsEr2xRuaqt", + "status": 200, + "response": { + "id": "sub_7VDMsEr2xRuaqt", + "cancel_at_period_end": true, + "current_period_end": 1452365079, + "current_period_start": 1449686679, + "customer": "cus_7VDMp8mEu4xG73", + "metadata": { + "id": "0000000000000000000186a4" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDMp8mEu4xG73", + "status": 200, + "response": { + "id": "cus_7VDMp8mEu4xG73", + "alipay_accounts": { + "has_more": false + }, + "email": "user102@me.com", + "metadata": { + "id": "0000000000000000000186a4" + }, + "sources": { + "data": [ + { + "id": "card_17GCvZKaReE7xLUdwixI8vqT", + "customer": "cus_7VDMp8mEu4xG73" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDMsEr2xRuaqt", + "cancel_at_period_end": true, + "current_period_end": 1452365079, + "current_period_start": 1449686679, + "customer": "cus_7VDMp8mEu4xG73", + "metadata": { + "id": "0000000000000000000186a4" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDMp8mEu4xG73", + "status": 200, + "response": { + "id": "cus_7VDMp8mEu4xG73", + "alipay_accounts": { + "has_more": false + }, + "email": "user102@me.com", + "metadata": { + "id": "0000000000000000000186a4" + }, + "sources": { + "data": [ + { + "id": "card_17GCvZKaReE7xLUdwixI8vqT", + "customer": "cus_7VDMp8mEu4xG73" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDMsEr2xRuaqt", + "cancel_at_period_end": true, + "current_period_end": 1452365079, + "current_period_start": 1449686679, + "customer": "cus_7VDMp8mEu4xG73", + "metadata": { + "id": "0000000000000000000186a4" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDMp8mEu4xG73", + "status": 200, + "response": { + "id": "cus_7VDMp8mEu4xG73", + "alipay_accounts": { + "has_more": false + }, + "email": "user102@me.com", + "metadata": { + "id": "0000000000000000000186a4" + }, + "sources": { + "data": [ + { + "id": "card_17GCvZKaReE7xLUdwixI8vqT", + "customer": "cus_7VDMp8mEu4xG73" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDMsEr2xRuaqt", + "cancel_at_period_end": true, + "current_period_end": 1452365079, + "current_period_start": 1449686679, + "customer": "cus_7VDMp8mEu4xG73", + "metadata": { + "id": "0000000000000000000186a4" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + } +] \ No newline at end of file diff --git a/spec/fixtures/sub-test-04.json b/spec/fixtures/sub-test-04.json new file mode 100644 index 000000000..ba64fb66a --- /dev/null +++ b/spec/fixtures/sub-test-04.json @@ -0,0 +1,388 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDMrdFayaY59E", + "alipay_accounts": { + "has_more": false + }, + "email": "user103@me.com", + "metadata": { + "id": "0000000000000000000186a5" + }, + "sources": { + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDMrdFayaY59E", + "status": 200, + "response": { + "id": "cus_7VDMrdFayaY59E", + "alipay_accounts": { + "has_more": false + }, + "email": "user103@me.com", + "metadata": { + "id": "0000000000000000000186a5" + }, + "sources": { + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDMrdFayaY59E/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDMXEkJJaHxwy", + "cancel_at_period_end": false, + "current_period_end": 1452365082, + "current_period_start": 1449686682, + "customer": "cus_7VDMrdFayaY59E", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDMrdFayaY59E", + "subscription": "sub_7VDMXEkJJaHxwy" + }, + "metadata": { + "id": "0000000000000000000186a5" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDMrdFayaY59E", + "status": 200, + "response": { + "id": "cus_7VDMrdFayaY59E", + "alipay_accounts": { + "has_more": false + }, + "email": "user103@me.com", + "metadata": { + "id": "0000000000000000000186a5" + }, + "sources": { + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDMXEkJJaHxwy", + "cancel_at_period_end": false, + "current_period_end": 1452365082, + "current_period_start": 1449686682, + "customer": "cus_7VDMrdFayaY59E", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDMrdFayaY59E", + "subscription": "sub_7VDMXEkJJaHxwy" + }, + "metadata": { + "id": "0000000000000000000186a5" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDMrdFayaY59E", + "status": 200, + "response": { + "id": "cus_7VDMrdFayaY59E", + "alipay_accounts": { + "has_more": false + }, + "email": "user103@me.com", + "metadata": { + "id": "0000000000000000000186a5" + }, + "sources": { + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDMXEkJJaHxwy", + "cancel_at_period_end": true, + "current_period_end": 1452365082, + "current_period_start": 1449686682, + "customer": "cus_7VDMrdFayaY59E", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDMrdFayaY59E", + "subscription": "sub_7VDMXEkJJaHxwy" + }, + "metadata": { + "id": "0000000000000000000186a5" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "DELETE", + "path": "/v1/customers/cus_7VDMrdFayaY59E/subscriptions/sub_7VDMXEkJJaHxwy", + "status": 200, + "response": { + "id": "sub_7VDMXEkJJaHxwy", + "cancel_at_period_end": true, + "current_period_end": 1452365082, + "current_period_start": 1449686682, + "customer": "cus_7VDMrdFayaY59E", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDMrdFayaY59E", + "subscription": "sub_7VDMXEkJJaHxwy" + }, + "metadata": { + "id": "0000000000000000000186a5" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDMrdFayaY59E/subscriptions/sub_7VDMXEkJJaHxwy", + "status": 200, + "response": { + "id": "sub_7VDMXEkJJaHxwy", + "cancel_at_period_end": true, + "current_period_end": 1452365082, + "current_period_start": 1449686682, + "customer": "cus_7VDMrdFayaY59E", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDMrdFayaY59E", + "subscription": "sub_7VDMXEkJJaHxwy" + }, + "metadata": { + "id": "0000000000000000000186a5" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDMrdFayaY59E/subscriptions/sub_7VDMXEkJJaHxwy", + "status": 200, + "response": { + "id": "sub_7VDMXEkJJaHxwy", + "cancel_at_period_end": true, + "current_period_end": 1452365082, + "current_period_start": 1449686682, + "customer": "cus_7VDMrdFayaY59E", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDMrdFayaY59E", + "subscription": "sub_7VDMXEkJJaHxwy" + }, + "metadata": { + "id": "0000000000000000000186a5" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDMrdFayaY59E", + "status": 200, + "response": { + "id": "cus_7VDMrdFayaY59E", + "alipay_accounts": { + "has_more": false + }, + "email": "user103@me.com", + "metadata": { + "id": "0000000000000000000186a5" + }, + "sources": { + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDMXEkJJaHxwy", + "cancel_at_period_end": true, + "current_period_end": 1452365082, + "current_period_start": 1449686682, + "customer": "cus_7VDMrdFayaY59E", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDMrdFayaY59E", + "subscription": "sub_7VDMXEkJJaHxwy" + }, + "metadata": { + "id": "0000000000000000000186a5" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDMrdFayaY59E", + "status": 200, + "response": { + "id": "cus_7VDMrdFayaY59E", + "alipay_accounts": { + "has_more": false + }, + "email": "user103@me.com", + "metadata": { + "id": "0000000000000000000186a5" + }, + "sources": { + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDMXEkJJaHxwy", + "cancel_at_period_end": true, + "current_period_end": 1452365082, + "current_period_start": 1449686682, + "customer": "cus_7VDMrdFayaY59E", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDMrdFayaY59E", + "subscription": "sub_7VDMXEkJJaHxwy" + }, + "metadata": { + "id": "0000000000000000000186a5" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDMrdFayaY59E", + "status": 200, + "response": { + "id": "cus_7VDMrdFayaY59E", + "alipay_accounts": { + "has_more": false + }, + "email": "user103@me.com", + "metadata": { + "id": "0000000000000000000186a5" + }, + "sources": { + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDMXEkJJaHxwy", + "cancel_at_period_end": true, + "current_period_end": 1452365082, + "current_period_start": 1449686682, + "customer": "cus_7VDMrdFayaY59E", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDMrdFayaY59E", + "subscription": "sub_7VDMXEkJJaHxwy" + }, + "metadata": { + "id": "0000000000000000000186a5" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + } +] \ No newline at end of file diff --git a/spec/fixtures/sub-test-05.json b/spec/fixtures/sub-test-05.json new file mode 100644 index 000000000..2c419c466 --- /dev/null +++ b/spec/fixtures/sub-test-05.json @@ -0,0 +1,264 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCviKaReE7xLUdllfxgDvw", + "card": { + "id": "card_17GCviKaReE7xLUdGzwk7E0z" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDM2IPe2orhRh", + "alipay_accounts": { + "has_more": false + }, + "email": "user104@me.com", + "metadata": { + "id": "0000000000000000000186a6" + }, + "sources": { + "data": [ + { + "id": "card_17GCviKaReE7xLUdGzwk7E0z", + "customer": "cus_7VDM2IPe2orhRh" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDM2IPe2orhRh", + "status": 200, + "response": { + "id": "cus_7VDM2IPe2orhRh", + "alipay_accounts": { + "has_more": false + }, + "email": "user104@me.com", + "metadata": { + "id": "0000000000000000000186a6" + }, + "sources": { + "data": [ + { + "id": "card_17GCviKaReE7xLUdGzwk7E0z", + "customer": "cus_7VDM2IPe2orhRh" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDM2IPe2orhRh/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDMhuoq3WA88F", + "cancel_at_period_end": false, + "current_period_end": 1452365087, + "current_period_start": 1449686687, + "customer": "cus_7VDM2IPe2orhRh", + "metadata": { + "id": "0000000000000000000186a6" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDM2IPe2orhRh", + "status": 200, + "response": { + "id": "cus_7VDM2IPe2orhRh", + "alipay_accounts": { + "has_more": false + }, + "email": "user104@me.com", + "metadata": { + "id": "0000000000000000000186a6" + }, + "sources": { + "data": [ + { + "id": "card_17GCviKaReE7xLUdGzwk7E0z", + "customer": "cus_7VDM2IPe2orhRh" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDMhuoq3WA88F", + "cancel_at_period_end": false, + "current_period_end": 1452365087, + "current_period_start": 1449686687, + "customer": "cus_7VDM2IPe2orhRh", + "metadata": { + "id": "0000000000000000000186a6" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDM2IPe2orhRh", + "status": 200, + "response": { + "id": "cus_7VDM2IPe2orhRh", + "alipay_accounts": { + "has_more": false + }, + "email": "user104@me.com", + "metadata": { + "id": "0000000000000000000186a6" + }, + "sources": { + "data": [ + { + "id": "card_17GCviKaReE7xLUdGzwk7E0z", + "customer": "cus_7VDM2IPe2orhRh" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDMhuoq3WA88F", + "cancel_at_period_end": false, + "current_period_end": 1452365087, + "current_period_start": 1449686687, + "customer": "cus_7VDM2IPe2orhRh", + "metadata": { + "id": "0000000000000000000186a6" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDM2IPe2orhRh/subscriptions", + "status": 200, + "response": { + "data": [ + { + "id": "sub_7VDMhuoq3WA88F", + "cancel_at_period_end": false, + "current_period_end": 1452365087, + "current_period_start": 1449686687, + "customer": "cus_7VDM2IPe2orhRh", + "metadata": { + "id": "0000000000000000000186a6" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDM2IPe2orhRh/subscriptions/sub_7VDMhuoq3WA88F", + "status": 200, + "response": { + "id": "sub_7VDMhuoq3WA88F", + "cancel_at_period_end": false, + "current_period_end": 1452365087, + "current_period_start": 1449686687, + "customer": "cus_7VDM2IPe2orhRh", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDM2IPe2orhRh", + "subscription": "sub_7VDMhuoq3WA88F" + }, + "metadata": { + "id": "0000000000000000000186a6" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDM2IPe2orhRh/subscriptions/sub_7VDMhuoq3WA88F", + "status": 200, + "response": { + "id": "sub_7VDMhuoq3WA88F", + "cancel_at_period_end": false, + "current_period_end": 1452365087, + "current_period_start": 1449686687, + "customer": "cus_7VDM2IPe2orhRh", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDM2IPe2orhRh", + "subscription": "sub_7VDMhuoq3WA88F" + }, + "metadata": { + "id": "0000000000000000000186a6" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + } +] \ No newline at end of file diff --git a/spec/fixtures/sub-test-06.json b/spec/fixtures/sub-test-06.json new file mode 100644 index 000000000..2238f90ea --- /dev/null +++ b/spec/fixtures/sub-test-06.json @@ -0,0 +1,430 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCvmKaReE7xLUdhtUTyZlL", + "card": { + "id": "card_17GCvmKaReE7xLUdt7Yh7qGx" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDMN7D1kvr7Lg", + "alipay_accounts": { + "has_more": false + }, + "email": "user105@me.com", + "metadata": { + "id": "0000000000000000000186a7" + }, + "sources": { + "data": [ + { + "id": "card_17GCvmKaReE7xLUdt7Yh7qGx", + "customer": "cus_7VDMN7D1kvr7Lg" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDMN7D1kvr7Lg/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDMS0xOsHmoQm", + "cancel_at_period_end": false, + "current_period_end": 1452365091, + "current_period_start": 1449686691, + "customer": "cus_7VDMN7D1kvr7Lg", + "metadata": { + "id": "0000000000000000000186a7" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDMN7D1kvr7Lg", + "status": 200, + "response": { + "id": "cus_7VDMN7D1kvr7Lg", + "alipay_accounts": { + "has_more": false + }, + "email": "user105@me.com", + "metadata": { + "id": "0000000000000000000186a7" + }, + "sources": { + "data": [ + { + "id": "card_17GCvmKaReE7xLUdt7Yh7qGx", + "customer": "cus_7VDMN7D1kvr7Lg" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDMS0xOsHmoQm", + "cancel_at_period_end": false, + "current_period_end": 1452365091, + "current_period_start": 1449686691, + "customer": "cus_7VDMN7D1kvr7Lg", + "metadata": { + "id": "0000000000000000000186a7" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDMN7D1kvr7Lg", + "status": 200, + "response": { + "id": "cus_7VDMN7D1kvr7Lg", + "alipay_accounts": { + "has_more": false + }, + "email": "user105@me.com", + "metadata": { + "id": "0000000000000000000186a7" + }, + "sources": { + "data": [ + { + "id": "card_17GCvmKaReE7xLUdt7Yh7qGx", + "customer": "cus_7VDMN7D1kvr7Lg" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDMS0xOsHmoQm", + "cancel_at_period_end": false, + "current_period_end": 1452365091, + "current_period_start": 1449686691, + "customer": "cus_7VDMN7D1kvr7Lg", + "metadata": { + "id": "0000000000000000000186a7" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDMN7D1kvr7Lg", + "status": 200, + "response": { + "id": "cus_7VDMN7D1kvr7Lg", + "alipay_accounts": { + "has_more": false + }, + "email": "user105@me.com", + "metadata": { + "id": "0000000000000000000186a7" + }, + "sources": { + "data": [ + { + "id": "card_17GCvmKaReE7xLUdt7Yh7qGx", + "customer": "cus_7VDMN7D1kvr7Lg" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDMS0xOsHmoQm", + "cancel_at_period_end": false, + "current_period_end": 1452365091, + "current_period_start": 1449686691, + "customer": "cus_7VDMN7D1kvr7Lg", + "metadata": { + "id": "0000000000000000000186a7" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDMN7D1kvr7Lg", + "status": 200, + "response": { + "id": "cus_7VDMN7D1kvr7Lg", + "alipay_accounts": { + "has_more": false + }, + "email": "user105@me.com", + "metadata": { + "id": "0000000000000000000186a7" + }, + "sources": { + "data": [ + { + "id": "card_17GCvmKaReE7xLUdt7Yh7qGx", + "customer": "cus_7VDMN7D1kvr7Lg" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDMS0xOsHmoQm", + "cancel_at_period_end": false, + "current_period_end": 1452365091, + "current_period_start": 1449686691, + "customer": "cus_7VDMN7D1kvr7Lg", + "metadata": { + "id": "0000000000000000000186a7" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDMN7D1kvr7Lg/subscriptions", + "status": 200, + "response": { + "data": [ + { + "id": "sub_7VDMS0xOsHmoQm", + "cancel_at_period_end": false, + "current_period_end": 1452365091, + "current_period_start": 1449686691, + "customer": "cus_7VDMN7D1kvr7Lg", + "metadata": { + "id": "0000000000000000000186a7" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDMN7D1kvr7Lg/subscriptions/sub_7VDMS0xOsHmoQm", + "status": 200, + "response": { + "id": "sub_7VDMS0xOsHmoQm", + "cancel_at_period_end": false, + "current_period_end": 1452365091, + "current_period_start": 1449686691, + "customer": "cus_7VDMN7D1kvr7Lg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDMN7D1kvr7Lg", + "subscription": "sub_7VDMS0xOsHmoQm" + }, + "metadata": { + "id": "0000000000000000000186a7" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDMN7D1kvr7Lg", + "status": 200, + "response": { + "id": "cus_7VDMN7D1kvr7Lg", + "alipay_accounts": { + "has_more": false + }, + "email": "user105@me.com", + "metadata": { + "id": "0000000000000000000186a7" + }, + "sources": { + "data": [ + { + "id": "card_17GCvmKaReE7xLUdt7Yh7qGx", + "customer": "cus_7VDMN7D1kvr7Lg" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDMS0xOsHmoQm", + "cancel_at_period_end": false, + "current_period_end": 1452365091, + "current_period_start": 1449686691, + "customer": "cus_7VDMN7D1kvr7Lg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDMN7D1kvr7Lg", + "subscription": "sub_7VDMS0xOsHmoQm" + }, + "metadata": { + "id": "0000000000000000000186a7" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDMN7D1kvr7Lg", + "status": 200, + "response": { + "id": "cus_7VDMN7D1kvr7Lg", + "alipay_accounts": { + "has_more": false + }, + "email": "user105@me.com", + "metadata": { + "id": "0000000000000000000186a7" + }, + "sources": { + "data": [ + { + "id": "card_17GCvmKaReE7xLUdt7Yh7qGx", + "customer": "cus_7VDMN7D1kvr7Lg" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDMS0xOsHmoQm", + "cancel_at_period_end": false, + "current_period_end": 1452365091, + "current_period_start": 1449686691, + "customer": "cus_7VDMN7D1kvr7Lg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDMN7D1kvr7Lg", + "subscription": "sub_7VDMS0xOsHmoQm" + }, + "metadata": { + "id": "0000000000000000000186a7" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDMN7D1kvr7Lg/subscriptions/sub_7VDMS0xOsHmoQm", + "status": 200, + "response": { + "id": "sub_7VDMS0xOsHmoQm", + "cancel_at_period_end": false, + "current_period_end": 1452365091, + "current_period_start": 1449686691, + "customer": "cus_7VDMN7D1kvr7Lg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDMN7D1kvr7Lg", + "subscription": "sub_7VDMS0xOsHmoQm" + }, + "metadata": { + "id": "0000000000000000000186a7" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + } +] \ No newline at end of file diff --git a/spec/fixtures/sub-test-07.json b/spec/fixtures/sub-test-07.json new file mode 100644 index 000000000..84f1d802e --- /dev/null +++ b/spec/fixtures/sub-test-07.json @@ -0,0 +1,246 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDM1shFX6QRWx", + "alipay_accounts": { + "has_more": false + }, + "email": "user106@me.com", + "metadata": { + "id": "0000000000000000000186a8" + }, + "sources": { + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDM1shFX6QRWx/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDMq59qAI6tOe", + "cancel_at_period_end": false, + "current_period_end": 1452365098, + "current_period_start": 1449686698, + "customer": "cus_7VDM1shFX6QRWx", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDM1shFX6QRWx", + "subscription": "sub_7VDMq59qAI6tOe" + }, + "metadata": { + "id": "0000000000000000000186a8" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDM1shFX6QRWx", + "status": 200, + "response": { + "id": "cus_7VDM1shFX6QRWx", + "alipay_accounts": { + "has_more": false + }, + "email": "user106@me.com", + "metadata": { + "id": "0000000000000000000186a8" + }, + "sources": { + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDMq59qAI6tOe", + "cancel_at_period_end": false, + "current_period_end": 1452365098, + "current_period_start": 1449686698, + "customer": "cus_7VDM1shFX6QRWx", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDM1shFX6QRWx", + "subscription": "sub_7VDMq59qAI6tOe" + }, + "metadata": { + "id": "0000000000000000000186a8" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "DELETE", + "path": "/v1/customers/cus_7VDM1shFX6QRWx/subscriptions/sub_7VDMq59qAI6tOe", + "status": 200, + "response": { + "id": "sub_7VDMq59qAI6tOe", + "cancel_at_period_end": true, + "current_period_end": 1452365098, + "current_period_start": 1449686698, + "customer": "cus_7VDM1shFX6QRWx", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDM1shFX6QRWx", + "subscription": "sub_7VDMq59qAI6tOe" + }, + "metadata": { + "id": "0000000000000000000186a8" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDM1shFX6QRWx", + "status": 200, + "response": { + "id": "cus_7VDM1shFX6QRWx", + "alipay_accounts": { + "has_more": false + }, + "email": "user106@me.com", + "metadata": { + "id": "0000000000000000000186a8" + }, + "sources": { + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDMq59qAI6tOe", + "cancel_at_period_end": true, + "current_period_end": 1452365098, + "current_period_start": 1449686698, + "customer": "cus_7VDM1shFX6QRWx", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDM1shFX6QRWx", + "subscription": "sub_7VDMq59qAI6tOe" + }, + "metadata": { + "id": "0000000000000000000186a8" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDM1shFX6QRWx", + "status": 200, + "response": { + "id": "cus_7VDM1shFX6QRWx", + "alipay_accounts": { + "has_more": false + }, + "email": "user106@me.com", + "metadata": { + "id": "0000000000000000000186a8" + }, + "sources": { + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDMq59qAI6tOe", + "cancel_at_period_end": true, + "current_period_end": 1452365098, + "current_period_start": 1449686698, + "customer": "cus_7VDM1shFX6QRWx", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDM1shFX6QRWx", + "subscription": "sub_7VDMq59qAI6tOe" + }, + "metadata": { + "id": "0000000000000000000186a8" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDM1shFX6QRWx/subscriptions/sub_7VDMq59qAI6tOe", + "status": 200, + "response": { + "id": "sub_7VDMq59qAI6tOe", + "cancel_at_period_end": true, + "current_period_end": 1452365098, + "current_period_start": 1449686698, + "customer": "cus_7VDM1shFX6QRWx", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDM1shFX6QRWx", + "subscription": "sub_7VDMq59qAI6tOe" + }, + "metadata": { + "id": "0000000000000000000186a8" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + } +] \ No newline at end of file diff --git a/spec/fixtures/sub-test-08.json b/spec/fixtures/sub-test-08.json new file mode 100644 index 000000000..7b90cb777 --- /dev/null +++ b/spec/fixtures/sub-test-08.json @@ -0,0 +1,188 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDMimrBc0mZ90", + "alipay_accounts": { + "has_more": false + }, + "email": "user107@me.com", + "metadata": { + "id": "0000000000000000000186a9" + }, + "sources": { + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDMimrBc0mZ90", + "status": 200, + "response": { + "id": "cus_7VDMimrBc0mZ90", + "alipay_accounts": { + "has_more": false + }, + "email": "user107@me.com", + "metadata": { + "id": "0000000000000000000186a9" + }, + "sources": { + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDMimrBc0mZ90/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDMdpg82cq4wP", + "cancel_at_period_end": false, + "current_period_end": 1452365101, + "current_period_start": 1449686701, + "customer": "cus_7VDMimrBc0mZ90", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDMimrBc0mZ90", + "subscription": "sub_7VDMdpg82cq4wP" + }, + "metadata": { + "id": "0000000000000000000186a9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDMimrBc0mZ90", + "status": 200, + "response": { + "id": "cus_7VDMimrBc0mZ90", + "alipay_accounts": { + "has_more": false + }, + "email": "user107@me.com", + "metadata": { + "id": "0000000000000000000186a9" + }, + "sources": { + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDMdpg82cq4wP", + "cancel_at_period_end": false, + "current_period_end": 1452365101, + "current_period_start": 1449686701, + "customer": "cus_7VDMimrBc0mZ90", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDMimrBc0mZ90", + "subscription": "sub_7VDMdpg82cq4wP" + }, + "metadata": { + "id": "0000000000000000000186a9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDMALAaCBewXK", + "alipay_accounts": { + "has_more": false + }, + "email": "user108@me.com", + "metadata": { + "id": "0000000000000000000186aa" + }, + "sources": { + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDMimrBc0mZ90", + "status": 200, + "response": { + "id": "cus_7VDMimrBc0mZ90", + "alipay_accounts": { + "has_more": false + }, + "email": "user107@me.com", + "metadata": { + "id": "0000000000000000000186a9" + }, + "sources": { + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDMdpg82cq4wP", + "cancel_at_period_end": false, + "current_period_end": 1452365101, + "current_period_start": 1449686701, + "customer": "cus_7VDMimrBc0mZ90", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDMimrBc0mZ90", + "subscription": "sub_7VDMdpg82cq4wP" + }, + "metadata": { + "id": "0000000000000000000186a9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + } +] \ No newline at end of file diff --git a/spec/fixtures/sub-test-09.json b/spec/fixtures/sub-test-09.json new file mode 100644 index 000000000..7eb96cb71 --- /dev/null +++ b/spec/fixtures/sub-test-09.json @@ -0,0 +1,240 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDMFarU7W8Gmy", + "alipay_accounts": { + "has_more": false + }, + "email": "user109@me.com", + "metadata": { + "id": "0000000000000000000186ab" + }, + "sources": { + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDMFarU7W8Gmy/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDMw3MAJ41tta", + "cancel_at_period_end": false, + "current_period_end": 1452365105, + "current_period_start": 1449686705, + "customer": "cus_7VDMFarU7W8Gmy", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDMFarU7W8Gmy", + "subscription": "sub_7VDMw3MAJ41tta" + }, + "metadata": { + "id": "0000000000000000000186ab" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDMJCH5sXus78", + "alipay_accounts": { + "has_more": false + }, + "email": "user110@me.com", + "metadata": { + "id": "0000000000000000000186ac" + }, + "sources": { + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDMFarU7W8Gmy", + "status": 200, + "response": { + "id": "cus_7VDMFarU7W8Gmy", + "alipay_accounts": { + "has_more": false + }, + "email": "user109@me.com", + "metadata": { + "id": "0000000000000000000186ab" + }, + "sources": { + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDMw3MAJ41tta", + "cancel_at_period_end": false, + "current_period_end": 1452365105, + "current_period_start": 1449686705, + "customer": "cus_7VDMFarU7W8Gmy", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDMFarU7W8Gmy", + "subscription": "sub_7VDMw3MAJ41tta" + }, + "metadata": { + "id": "0000000000000000000186ab" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDMFarU7W8Gmy", + "status": 200, + "response": { + "id": "cus_7VDMFarU7W8Gmy", + "alipay_accounts": { + "has_more": false + }, + "email": "user109@me.com", + "metadata": { + "id": "0000000000000000000186ab" + }, + "sources": { + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDMw3MAJ41tta", + "cancel_at_period_end": false, + "current_period_end": 1452365105, + "current_period_start": 1449686705, + "customer": "cus_7VDMFarU7W8Gmy", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDMFarU7W8Gmy", + "subscription": "sub_7VDMw3MAJ41tta" + }, + "metadata": { + "id": "0000000000000000000186ab" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDMFarU7W8Gmy", + "status": 200, + "response": { + "id": "cus_7VDMFarU7W8Gmy", + "alipay_accounts": { + "has_more": false + }, + "email": "user109@me.com", + "metadata": { + "id": "0000000000000000000186ab" + }, + "sources": { + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDMw3MAJ41tta", + "cancel_at_period_end": false, + "current_period_end": 1452365105, + "current_period_start": 1449686705, + "customer": "cus_7VDMFarU7W8Gmy", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDMFarU7W8Gmy", + "subscription": "sub_7VDMw3MAJ41tta" + }, + "metadata": { + "id": "0000000000000000000186ab" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDMJCH5sXus78/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDMnCRwJSWFrg", + "cancel_at_period_end": false, + "current_period_end": 1452365106, + "current_period_start": 1449686706, + "customer": "cus_7VDMJCH5sXus78", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDMJCH5sXus78", + "subscription": "sub_7VDMnCRwJSWFrg" + }, + "metadata": { + "id": "0000000000000000000186ac" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + } +] \ No newline at end of file diff --git a/spec/fixtures/sub-test-10.json b/spec/fixtures/sub-test-10.json new file mode 100644 index 000000000..dac8db8fb --- /dev/null +++ b/spec/fixtures/sub-test-10.json @@ -0,0 +1,52 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDMJaKYQsFp2d", + "alipay_accounts": { + "has_more": false + }, + "email": "user111@me.com", + "metadata": { + "id": "0000000000000000000186ad" + }, + "sources": { + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDMJaKYQsFp2d/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDMFO6EovmOwR", + "cancel_at_period_end": false, + "current_period_end": 1452365109, + "current_period_start": 1449686709, + "customer": "cus_7VDMJaKYQsFp2d", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDMJaKYQsFp2d", + "subscription": "sub_7VDMFO6EovmOwR" + }, + "metadata": { + "id": "0000000000000000000186ad" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + } +] \ No newline at end of file diff --git a/spec/fixtures/sub-test-11.json b/spec/fixtures/sub-test-11.json new file mode 100644 index 000000000..09692ef95 --- /dev/null +++ b/spec/fixtures/sub-test-11.json @@ -0,0 +1,24 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDM4y30udBZ6y", + "alipay_accounts": { + "has_more": false + }, + "email": "user112@me.com", + "metadata": { + "id": "0000000000000000000186ae" + }, + "sources": { + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + } +] \ No newline at end of file diff --git a/spec/fixtures/sub-test-12.json b/spec/fixtures/sub-test-12.json new file mode 100644 index 000000000..d9afaa36f --- /dev/null +++ b/spec/fixtures/sub-test-12.json @@ -0,0 +1,24 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDMGD6KRcGwXR", + "alipay_accounts": { + "has_more": false + }, + "email": "user113@me.com", + "metadata": { + "id": "0000000000000000000186af" + }, + "sources": { + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + } +] \ No newline at end of file diff --git a/spec/fixtures/sub-test-13.json b/spec/fixtures/sub-test-13.json new file mode 100644 index 000000000..928be0505 --- /dev/null +++ b/spec/fixtures/sub-test-13.json @@ -0,0 +1,572 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCw8KaReE7xLUdthO4orSb", + "card": { + "id": "card_17GCw8KaReE7xLUdOPWS15Bv" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDMmrioYAeVKO", + "alipay_accounts": { + "has_more": false + }, + "email": "user115@me.com", + "metadata": { + "id": "0000000000000000000186b1" + }, + "sources": { + "data": [ + { + "id": "card_17GCw8KaReE7xLUdOPWS15Bv", + "customer": "cus_7VDMmrioYAeVKO" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDMmrioYAeVKO", + "status": 200, + "response": { + "id": "cus_7VDMmrioYAeVKO", + "alipay_accounts": { + "has_more": false + }, + "email": "user115@me.com", + "metadata": { + "id": "0000000000000000000186b1" + }, + "sources": { + "data": [ + { + "id": "card_17GCw8KaReE7xLUdOPWS15Bv", + "customer": "cus_7VDMmrioYAeVKO" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDMmrioYAeVKO/subscriptions", + "status": 200, + "response": { + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDMmrioYAeVKO/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDM9eY05oeOyv", + "cancel_at_period_end": false, + "current_period_end": 1452365114, + "current_period_start": 1449686714, + "customer": "cus_7VDMmrioYAeVKO", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDMmrioYAeVKO", + "subscription": "sub_7VDM9eY05oeOyv" + }, + "metadata": { + "id": "0000000000000000000186b0" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDMmrioYAeVKO", + "status": 200, + "response": { + "id": "cus_7VDMmrioYAeVKO", + "alipay_accounts": { + "has_more": false + }, + "email": "user115@me.com", + "metadata": { + "id": "0000000000000000000186b1" + }, + "sources": { + "data": [ + { + "id": "card_17GCw8KaReE7xLUdOPWS15Bv", + "customer": "cus_7VDMmrioYAeVKO" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDM9eY05oeOyv", + "cancel_at_period_end": false, + "current_period_end": 1452365114, + "current_period_start": 1449686714, + "customer": "cus_7VDMmrioYAeVKO", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDMmrioYAeVKO", + "subscription": "sub_7VDM9eY05oeOyv" + }, + "metadata": { + "id": "0000000000000000000186b0" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDMmrioYAeVKO/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDMu0KhU3xUUv", + "cancel_at_period_end": false, + "current_period_end": 1452365116, + "current_period_start": 1449686716, + "customer": "cus_7VDMmrioYAeVKO", + "metadata": { + "id": "0000000000000000000186b1" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices", + "status": 200, + "response": { + "data": [ + { + "id": "in_17GCwCKaReE7xLUdrx4hkf0a", + "customer": "cus_7VDMmrioYAeVKO", + "lines": { + "data": [ + { + "id": "sub_7VDMu0KhU3xUUv", + "amount": 999, + "metadata": { + "id": "0000000000000000000186b1" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 999, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDMu0KhU3xUUv", + "total": 999 + }, + { + "id": "in_17GCwAKaReE7xLUdx4nsrGJo", + "customer": "cus_7VDMmrioYAeVKO", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDMmrioYAeVKO", + "subscription": "sub_7VDM9eY05oeOyv" + }, + "lines": { + "data": [ + { + "id": "sub_7VDM9eY05oeOyv", + "amount": 999, + "metadata": { + "id": "0000000000000000000186b0" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDM9eY05oeOyv", + "total": 0 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDMmrioYAeVKO", + "status": 200, + "response": { + "id": "cus_7VDMmrioYAeVKO", + "alipay_accounts": { + "has_more": false + }, + "email": "user115@me.com", + "metadata": { + "id": "0000000000000000000186b1" + }, + "sources": { + "data": [ + { + "id": "card_17GCw8KaReE7xLUdOPWS15Bv", + "customer": "cus_7VDMmrioYAeVKO" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDMu0KhU3xUUv", + "cancel_at_period_end": false, + "current_period_end": 1452365116, + "current_period_start": 1449686716, + "customer": "cus_7VDMmrioYAeVKO", + "metadata": { + "id": "0000000000000000000186b1" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDM9eY05oeOyv", + "cancel_at_period_end": false, + "current_period_end": 1452365114, + "current_period_start": 1449686714, + "customer": "cus_7VDMmrioYAeVKO", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDMmrioYAeVKO", + "subscription": "sub_7VDM9eY05oeOyv" + }, + "metadata": { + "id": "0000000000000000000186b0" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCwCKaReE7xLUdrx4hkf0a", + "status": 200, + "response": { + "id": "in_17GCwCKaReE7xLUdrx4hkf0a", + "customer": "cus_7VDMmrioYAeVKO", + "lines": { + "data": [ + { + "id": "sub_7VDMu0KhU3xUUv", + "amount": 999, + "metadata": { + "id": "0000000000000000000186b1" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 999, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDMu0KhU3xUUv", + "total": 999 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDMmrioYAeVKO", + "status": 200, + "response": { + "id": "cus_7VDMmrioYAeVKO", + "alipay_accounts": { + "has_more": false + }, + "email": "user115@me.com", + "metadata": { + "id": "0000000000000000000186b1" + }, + "sources": { + "data": [ + { + "id": "card_17GCw8KaReE7xLUdOPWS15Bv", + "customer": "cus_7VDMmrioYAeVKO" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDMu0KhU3xUUv", + "cancel_at_period_end": false, + "current_period_end": 1452365116, + "current_period_start": 1449686716, + "customer": "cus_7VDMmrioYAeVKO", + "metadata": { + "id": "0000000000000000000186b1" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDM9eY05oeOyv", + "cancel_at_period_end": false, + "current_period_end": 1452365114, + "current_period_start": 1449686714, + "customer": "cus_7VDMmrioYAeVKO", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDMmrioYAeVKO", + "subscription": "sub_7VDM9eY05oeOyv" + }, + "metadata": { + "id": "0000000000000000000186b0" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDMmrioYAeVKO", + "status": 200, + "response": { + "id": "cus_7VDMmrioYAeVKO", + "alipay_accounts": { + "has_more": false + }, + "email": "user115@me.com", + "metadata": { + "id": "0000000000000000000186b1" + }, + "sources": { + "data": [ + { + "id": "card_17GCw8KaReE7xLUdOPWS15Bv", + "customer": "cus_7VDMmrioYAeVKO" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDMu0KhU3xUUv", + "cancel_at_period_end": false, + "current_period_end": 1452365116, + "current_period_start": 1449686716, + "customer": "cus_7VDMmrioYAeVKO", + "metadata": { + "id": "0000000000000000000186b1" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDM9eY05oeOyv", + "cancel_at_period_end": false, + "current_period_end": 1452365114, + "current_period_start": 1449686714, + "customer": "cus_7VDMmrioYAeVKO", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDMmrioYAeVKO", + "subscription": "sub_7VDM9eY05oeOyv" + }, + "metadata": { + "id": "0000000000000000000186b0" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCwAKaReE7xLUdx4nsrGJo", + "status": 200, + "response": { + "id": "in_17GCwAKaReE7xLUdx4nsrGJo", + "customer": "cus_7VDMmrioYAeVKO", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDMmrioYAeVKO", + "subscription": "sub_7VDM9eY05oeOyv" + }, + "lines": { + "data": [ + { + "id": "sub_7VDM9eY05oeOyv", + "amount": 999, + "metadata": { + "id": "0000000000000000000186b0" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDM9eY05oeOyv", + "total": 0 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDMmrioYAeVKO/subscriptions/sub_7VDMu0KhU3xUUv", + "status": 200, + "response": { + "id": "sub_7VDMu0KhU3xUUv", + "cancel_at_period_end": false, + "current_period_end": 1452365116, + "current_period_start": 1449686716, + "customer": "cus_7VDMmrioYAeVKO", + "metadata": { + "id": "0000000000000000000186b1" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDMmrioYAeVKO/subscriptions/sub_7VDM9eY05oeOyv", + "status": 200, + "response": { + "id": "sub_7VDM9eY05oeOyv", + "cancel_at_period_end": false, + "current_period_end": 1452365114, + "current_period_start": 1449686714, + "customer": "cus_7VDMmrioYAeVKO", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDMmrioYAeVKO", + "subscription": "sub_7VDM9eY05oeOyv" + }, + "metadata": { + "id": "0000000000000000000186b0" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + } +] \ No newline at end of file diff --git a/spec/fixtures/sub-test-14.json b/spec/fixtures/sub-test-14.json new file mode 100644 index 000000000..8bc2f444f --- /dev/null +++ b/spec/fixtures/sub-test-14.json @@ -0,0 +1,649 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCwFKaReE7xLUdWI6KM2oH", + "card": { + "id": "card_17GCwFKaReE7xLUdKzBLn7i7" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDM4cabFTvRKN", + "alipay_accounts": { + "has_more": false + }, + "email": "user117@me.com", + "metadata": { + "id": "0000000000000000000186b3" + }, + "sources": { + "data": [ + { + "id": "card_17GCwFKaReE7xLUdKzBLn7i7", + "customer": "cus_7VDM4cabFTvRKN" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDM4cabFTvRKN", + "status": 200, + "response": { + "id": "cus_7VDM4cabFTvRKN", + "alipay_accounts": { + "has_more": false + }, + "email": "user117@me.com", + "metadata": { + "id": "0000000000000000000186b3" + }, + "sources": { + "data": [ + { + "id": "card_17GCwFKaReE7xLUdKzBLn7i7", + "customer": "cus_7VDM4cabFTvRKN" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDM4cabFTvRKN/subscriptions", + "status": 200, + "response": { + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDM4cabFTvRKN/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDNm23D4Adhbm", + "cancel_at_period_end": false, + "current_period_end": 1452365121, + "current_period_start": 1449686721, + "customer": "cus_7VDM4cabFTvRKN", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDM4cabFTvRKN", + "subscription": "sub_7VDNm23D4Adhbm" + }, + "metadata": { + "id": "0000000000000000000186b2" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDM4cabFTvRKN", + "status": 200, + "response": { + "id": "cus_7VDM4cabFTvRKN", + "alipay_accounts": { + "has_more": false + }, + "email": "user117@me.com", + "metadata": { + "id": "0000000000000000000186b3" + }, + "sources": { + "data": [ + { + "id": "card_17GCwFKaReE7xLUdKzBLn7i7", + "customer": "cus_7VDM4cabFTvRKN" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDNm23D4Adhbm", + "cancel_at_period_end": false, + "current_period_end": 1452365121, + "current_period_start": 1449686721, + "customer": "cus_7VDM4cabFTvRKN", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDM4cabFTvRKN", + "subscription": "sub_7VDNm23D4Adhbm" + }, + "metadata": { + "id": "0000000000000000000186b2" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDM4cabFTvRKN/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDNwy2CROZ8Th", + "cancel_at_period_end": false, + "current_period_end": 1452365122, + "current_period_start": 1449686722, + "customer": "cus_7VDM4cabFTvRKN", + "metadata": { + "id": "0000000000000000000186b3" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices", + "status": 200, + "response": { + "data": [ + { + "id": "in_17GCwIKaReE7xLUdvxGcczE4", + "customer": "cus_7VDM4cabFTvRKN", + "lines": { + "data": [ + { + "id": "sub_7VDNwy2CROZ8Th", + "amount": 999, + "metadata": { + "id": "0000000000000000000186b3" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 999, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDNwy2CROZ8Th", + "total": 999 + }, + { + "id": "in_17GCwHKaReE7xLUd4Ju1asAT", + "customer": "cus_7VDM4cabFTvRKN", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDM4cabFTvRKN", + "subscription": "sub_7VDNm23D4Adhbm" + }, + "lines": { + "data": [ + { + "id": "sub_7VDNm23D4Adhbm", + "amount": 999, + "metadata": { + "id": "0000000000000000000186b2" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDNm23D4Adhbm", + "total": 0 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDM4cabFTvRKN", + "status": 200, + "response": { + "id": "cus_7VDM4cabFTvRKN", + "alipay_accounts": { + "has_more": false + }, + "email": "user117@me.com", + "metadata": { + "id": "0000000000000000000186b3" + }, + "sources": { + "data": [ + { + "id": "card_17GCwFKaReE7xLUdKzBLn7i7", + "customer": "cus_7VDM4cabFTvRKN" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDNwy2CROZ8Th", + "cancel_at_period_end": false, + "current_period_end": 1452365122, + "current_period_start": 1449686722, + "customer": "cus_7VDM4cabFTvRKN", + "metadata": { + "id": "0000000000000000000186b3" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDNm23D4Adhbm", + "cancel_at_period_end": false, + "current_period_end": 1452365121, + "current_period_start": 1449686721, + "customer": "cus_7VDM4cabFTvRKN", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDM4cabFTvRKN", + "subscription": "sub_7VDNm23D4Adhbm" + }, + "metadata": { + "id": "0000000000000000000186b2" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCwIKaReE7xLUdvxGcczE4", + "status": 200, + "response": { + "id": "in_17GCwIKaReE7xLUdvxGcczE4", + "customer": "cus_7VDM4cabFTvRKN", + "lines": { + "data": [ + { + "id": "sub_7VDNwy2CROZ8Th", + "amount": 999, + "metadata": { + "id": "0000000000000000000186b3" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 999, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDNwy2CROZ8Th", + "total": 999 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDM4cabFTvRKN", + "status": 200, + "response": { + "id": "cus_7VDM4cabFTvRKN", + "alipay_accounts": { + "has_more": false + }, + "email": "user117@me.com", + "metadata": { + "id": "0000000000000000000186b3" + }, + "sources": { + "data": [ + { + "id": "card_17GCwFKaReE7xLUdKzBLn7i7", + "customer": "cus_7VDM4cabFTvRKN" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDNwy2CROZ8Th", + "cancel_at_period_end": false, + "current_period_end": 1452365122, + "current_period_start": 1449686722, + "customer": "cus_7VDM4cabFTvRKN", + "metadata": { + "id": "0000000000000000000186b3" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDNm23D4Adhbm", + "cancel_at_period_end": false, + "current_period_end": 1452365121, + "current_period_start": 1449686721, + "customer": "cus_7VDM4cabFTvRKN", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDM4cabFTvRKN", + "subscription": "sub_7VDNm23D4Adhbm" + }, + "metadata": { + "id": "0000000000000000000186b2" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDM4cabFTvRKN", + "status": 200, + "response": { + "id": "cus_7VDM4cabFTvRKN", + "alipay_accounts": { + "has_more": false + }, + "email": "user117@me.com", + "metadata": { + "id": "0000000000000000000186b3" + }, + "sources": { + "data": [ + { + "id": "card_17GCwFKaReE7xLUdKzBLn7i7", + "customer": "cus_7VDM4cabFTvRKN" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDNwy2CROZ8Th", + "cancel_at_period_end": false, + "current_period_end": 1452365122, + "current_period_start": 1449686722, + "customer": "cus_7VDM4cabFTvRKN", + "metadata": { + "id": "0000000000000000000186b3" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDNm23D4Adhbm", + "cancel_at_period_end": false, + "current_period_end": 1452365121, + "current_period_start": 1449686721, + "customer": "cus_7VDM4cabFTvRKN", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDM4cabFTvRKN", + "subscription": "sub_7VDNm23D4Adhbm" + }, + "metadata": { + "id": "0000000000000000000186b2" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCwHKaReE7xLUd4Ju1asAT", + "status": 200, + "response": { + "id": "in_17GCwHKaReE7xLUd4Ju1asAT", + "customer": "cus_7VDM4cabFTvRKN", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDM4cabFTvRKN", + "subscription": "sub_7VDNm23D4Adhbm" + }, + "lines": { + "data": [ + { + "id": "sub_7VDNm23D4Adhbm", + "amount": 999, + "metadata": { + "id": "0000000000000000000186b2" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDNm23D4Adhbm", + "total": 0 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "DELETE", + "path": "/v1/customers/cus_7VDM4cabFTvRKN/subscriptions/sub_7VDNm23D4Adhbm", + "status": 200, + "response": { + "id": "sub_7VDNm23D4Adhbm", + "cancel_at_period_end": false, + "current_period_end": 1452365121, + "current_period_start": 1449686721, + "customer": "cus_7VDM4cabFTvRKN", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDM4cabFTvRKN", + "subscription": "sub_7VDNm23D4Adhbm" + }, + "metadata": { + "id": "0000000000000000000186b2" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDM4cabFTvRKN/subscriptions/sub_7VDNwy2CROZ8Th", + "status": 200, + "response": { + "id": "sub_7VDNwy2CROZ8Th", + "cancel_at_period_end": false, + "current_period_end": 1452365122, + "current_period_start": 1449686722, + "customer": "cus_7VDM4cabFTvRKN", + "metadata": { + "id": "0000000000000000000186b3" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 0 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDM4cabFTvRKN/subscriptions/sub_7VDNm23D4Adhbm", + "status": 404, + "response": { + "error": { + "type": "invalid_request_error" + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDM4cabFTvRKN", + "status": 200, + "response": { + "id": "cus_7VDM4cabFTvRKN", + "alipay_accounts": { + "has_more": false + }, + "email": "user117@me.com", + "metadata": { + "id": "0000000000000000000186b3" + }, + "sources": { + "data": [ + { + "id": "card_17GCwFKaReE7xLUdKzBLn7i7", + "customer": "cus_7VDM4cabFTvRKN" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDNwy2CROZ8Th", + "cancel_at_period_end": false, + "current_period_end": 1452365122, + "current_period_start": 1449686722, + "customer": "cus_7VDM4cabFTvRKN", + "metadata": { + "id": "0000000000000000000186b3" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 0 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDM4cabFTvRKN/subscriptions/sub_7VDNwy2CROZ8Th", + "status": 200, + "response": { + "id": "sub_7VDNwy2CROZ8Th", + "cancel_at_period_end": false, + "current_period_end": 1452365122, + "current_period_start": 1449686722, + "customer": "cus_7VDM4cabFTvRKN", + "metadata": { + "id": "0000000000000000000186b3" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 0 + } + } +] \ No newline at end of file diff --git a/spec/fixtures/sub-test-15.json b/spec/fixtures/sub-test-15.json new file mode 100644 index 000000000..08360efe7 --- /dev/null +++ b/spec/fixtures/sub-test-15.json @@ -0,0 +1,960 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCwOKaReE7xLUdUD4Nkjd7", + "card": { + "id": "card_17GCwOKaReE7xLUd3yZTswdV" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDN2KNqruyD9I", + "alipay_accounts": { + "has_more": false + }, + "email": "user119@me.com", + "metadata": { + "id": "0000000000000000000186b5" + }, + "sources": { + "data": [ + { + "id": "card_17GCwOKaReE7xLUd3yZTswdV", + "customer": "cus_7VDN2KNqruyD9I" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDN2KNqruyD9I", + "status": 200, + "response": { + "id": "cus_7VDN2KNqruyD9I", + "alipay_accounts": { + "has_more": false + }, + "email": "user119@me.com", + "metadata": { + "id": "0000000000000000000186b5" + }, + "sources": { + "data": [ + { + "id": "card_17GCwOKaReE7xLUd3yZTswdV", + "customer": "cus_7VDN2KNqruyD9I" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDN2KNqruyD9I/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDNPD9TIPgfsG", + "cancel_at_period_end": false, + "current_period_end": 1452365130, + "current_period_start": 1449686730, + "customer": "cus_7VDN2KNqruyD9I", + "metadata": { + "id": "0000000000000000000186b5" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDN2KNqruyD9I", + "status": 200, + "response": { + "id": "cus_7VDN2KNqruyD9I", + "alipay_accounts": { + "has_more": false + }, + "email": "user119@me.com", + "metadata": { + "id": "0000000000000000000186b5" + }, + "sources": { + "data": [ + { + "id": "card_17GCwOKaReE7xLUd3yZTswdV", + "customer": "cus_7VDN2KNqruyD9I" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDNPD9TIPgfsG", + "cancel_at_period_end": false, + "current_period_end": 1452365130, + "current_period_start": 1449686730, + "customer": "cus_7VDN2KNqruyD9I", + "metadata": { + "id": "0000000000000000000186b5" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDN2KNqruyD9I", + "status": 200, + "response": { + "id": "cus_7VDN2KNqruyD9I", + "alipay_accounts": { + "has_more": false + }, + "email": "user119@me.com", + "metadata": { + "id": "0000000000000000000186b5" + }, + "sources": { + "data": [ + { + "id": "card_17GCwOKaReE7xLUd3yZTswdV", + "customer": "cus_7VDN2KNqruyD9I" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDNPD9TIPgfsG", + "cancel_at_period_end": false, + "current_period_end": 1452365130, + "current_period_start": 1449686730, + "customer": "cus_7VDN2KNqruyD9I", + "metadata": { + "id": "0000000000000000000186b5" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDN2KNqruyD9I", + "status": 200, + "response": { + "id": "cus_7VDN2KNqruyD9I", + "alipay_accounts": { + "has_more": false + }, + "email": "user119@me.com", + "metadata": { + "id": "0000000000000000000186b5" + }, + "sources": { + "data": [ + { + "id": "card_17GCwOKaReE7xLUd3yZTswdV", + "customer": "cus_7VDN2KNqruyD9I" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDNPD9TIPgfsG", + "cancel_at_period_end": false, + "current_period_end": 1452365130, + "current_period_start": 1449686730, + "customer": "cus_7VDN2KNqruyD9I", + "metadata": { + "id": "0000000000000000000186b5" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDN2KNqruyD9I/subscriptions", + "status": 200, + "response": { + "data": [ + { + "id": "sub_7VDNPD9TIPgfsG", + "cancel_at_period_end": false, + "current_period_end": 1452365130, + "current_period_start": 1449686730, + "customer": "cus_7VDN2KNqruyD9I", + "metadata": { + "id": "0000000000000000000186b5" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDN2KNqruyD9I/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDNwjyGqYhYMg", + "cancel_at_period_end": false, + "current_period_end": 1452365133, + "current_period_start": 1449686733, + "customer": "cus_7VDN2KNqruyD9I", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDN2KNqruyD9I", + "subscription": "sub_7VDNwjyGqYhYMg" + }, + "metadata": { + "id": "0000000000000000000186b4" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDN2KNqruyD9I/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDNirCm8gp2m7", + "cancel_at_period_end": false, + "current_period_end": 1452365135, + "current_period_start": 1449686735, + "customer": "cus_7VDN2KNqruyD9I", + "metadata": { + "id": "0000000000000000000186b5" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 799 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices", + "status": 200, + "response": { + "data": [ + { + "id": "in_17GCwVKaReE7xLUdNP0m26Nw", + "customer": "cus_7VDN2KNqruyD9I", + "lines": { + "data": [ + { + "id": "sub_7VDNirCm8gp2m7", + "amount": 799, + "metadata": { + "id": "0000000000000000000186b5" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 799, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDNirCm8gp2m7", + "total": 799 + }, + { + "id": "in_17GCwTKaReE7xLUdM7EWTJ09", + "customer": "cus_7VDN2KNqruyD9I", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDN2KNqruyD9I", + "subscription": "sub_7VDNwjyGqYhYMg" + }, + "lines": { + "data": [ + { + "id": "sub_7VDNwjyGqYhYMg", + "amount": 999, + "metadata": { + "id": "0000000000000000000186b4" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDNwjyGqYhYMg", + "total": 0 + }, + { + "id": "in_17GCwQKaReE7xLUdqSluEgSu", + "customer": "cus_7VDN2KNqruyD9I", + "lines": { + "data": [ + { + "id": "sub_7VDNPD9TIPgfsG", + "amount": 999, + "metadata": { + "id": "0000000000000000000186b5" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDNPD9TIPgfsG", + "total": 999 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDN2KNqruyD9I", + "status": 200, + "response": { + "id": "cus_7VDN2KNqruyD9I", + "alipay_accounts": { + "has_more": false + }, + "email": "user119@me.com", + "metadata": { + "id": "0000000000000000000186b5" + }, + "sources": { + "data": [ + { + "id": "card_17GCwOKaReE7xLUd3yZTswdV", + "customer": "cus_7VDN2KNqruyD9I" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDNirCm8gp2m7", + "cancel_at_period_end": false, + "current_period_end": 1452365135, + "current_period_start": 1449686735, + "customer": "cus_7VDN2KNqruyD9I", + "metadata": { + "id": "0000000000000000000186b5" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 799 + }, + { + "id": "sub_7VDNwjyGqYhYMg", + "cancel_at_period_end": false, + "current_period_end": 1452365133, + "current_period_start": 1449686733, + "customer": "cus_7VDN2KNqruyD9I", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDN2KNqruyD9I", + "subscription": "sub_7VDNwjyGqYhYMg" + }, + "metadata": { + "id": "0000000000000000000186b4" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDNPD9TIPgfsG", + "cancel_at_period_end": false, + "current_period_end": 1452365130, + "current_period_start": 1449686730, + "customer": "cus_7VDN2KNqruyD9I", + "metadata": { + "id": "0000000000000000000186b5" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDN2KNqruyD9I", + "status": 200, + "response": { + "id": "cus_7VDN2KNqruyD9I", + "alipay_accounts": { + "has_more": false + }, + "email": "user119@me.com", + "metadata": { + "id": "0000000000000000000186b5" + }, + "sources": { + "data": [ + { + "id": "card_17GCwOKaReE7xLUd3yZTswdV", + "customer": "cus_7VDN2KNqruyD9I" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDNirCm8gp2m7", + "cancel_at_period_end": false, + "current_period_end": 1452365135, + "current_period_start": 1449686735, + "customer": "cus_7VDN2KNqruyD9I", + "metadata": { + "id": "0000000000000000000186b5" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 799 + }, + { + "id": "sub_7VDNwjyGqYhYMg", + "cancel_at_period_end": false, + "current_period_end": 1452365133, + "current_period_start": 1449686733, + "customer": "cus_7VDN2KNqruyD9I", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDN2KNqruyD9I", + "subscription": "sub_7VDNwjyGqYhYMg" + }, + "metadata": { + "id": "0000000000000000000186b4" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDNPD9TIPgfsG", + "cancel_at_period_end": false, + "current_period_end": 1452365130, + "current_period_start": 1449686730, + "customer": "cus_7VDN2KNqruyD9I", + "metadata": { + "id": "0000000000000000000186b5" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDN2KNqruyD9I", + "status": 200, + "response": { + "id": "cus_7VDN2KNqruyD9I", + "alipay_accounts": { + "has_more": false + }, + "email": "user119@me.com", + "metadata": { + "id": "0000000000000000000186b5" + }, + "sources": { + "data": [ + { + "id": "card_17GCwOKaReE7xLUd3yZTswdV", + "customer": "cus_7VDN2KNqruyD9I" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDNirCm8gp2m7", + "cancel_at_period_end": false, + "current_period_end": 1452365135, + "current_period_start": 1449686735, + "customer": "cus_7VDN2KNqruyD9I", + "metadata": { + "id": "0000000000000000000186b5" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 799 + }, + { + "id": "sub_7VDNwjyGqYhYMg", + "cancel_at_period_end": false, + "current_period_end": 1452365133, + "current_period_start": 1449686733, + "customer": "cus_7VDN2KNqruyD9I", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDN2KNqruyD9I", + "subscription": "sub_7VDNwjyGqYhYMg" + }, + "metadata": { + "id": "0000000000000000000186b4" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDNPD9TIPgfsG", + "cancel_at_period_end": false, + "current_period_end": 1452365130, + "current_period_start": 1449686730, + "customer": "cus_7VDN2KNqruyD9I", + "metadata": { + "id": "0000000000000000000186b5" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCwVKaReE7xLUdNP0m26Nw", + "status": 200, + "response": { + "id": "in_17GCwVKaReE7xLUdNP0m26Nw", + "customer": "cus_7VDN2KNqruyD9I", + "lines": { + "data": [ + { + "id": "sub_7VDNirCm8gp2m7", + "amount": 799, + "metadata": { + "id": "0000000000000000000186b5" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 799, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDNirCm8gp2m7", + "total": 799 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDN2KNqruyD9I", + "status": 200, + "response": { + "id": "cus_7VDN2KNqruyD9I", + "alipay_accounts": { + "has_more": false + }, + "email": "user119@me.com", + "metadata": { + "id": "0000000000000000000186b5" + }, + "sources": { + "data": [ + { + "id": "card_17GCwOKaReE7xLUd3yZTswdV", + "customer": "cus_7VDN2KNqruyD9I" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDNirCm8gp2m7", + "cancel_at_period_end": false, + "current_period_end": 1452365135, + "current_period_start": 1449686735, + "customer": "cus_7VDN2KNqruyD9I", + "metadata": { + "id": "0000000000000000000186b5" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 799 + }, + { + "id": "sub_7VDNwjyGqYhYMg", + "cancel_at_period_end": false, + "current_period_end": 1452365133, + "current_period_start": 1449686733, + "customer": "cus_7VDN2KNqruyD9I", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDN2KNqruyD9I", + "subscription": "sub_7VDNwjyGqYhYMg" + }, + "metadata": { + "id": "0000000000000000000186b4" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDNPD9TIPgfsG", + "cancel_at_period_end": false, + "current_period_end": 1452365130, + "current_period_start": 1449686730, + "customer": "cus_7VDN2KNqruyD9I", + "metadata": { + "id": "0000000000000000000186b5" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCwTKaReE7xLUdM7EWTJ09", + "status": 200, + "response": { + "id": "in_17GCwTKaReE7xLUdM7EWTJ09", + "customer": "cus_7VDN2KNqruyD9I", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDN2KNqruyD9I", + "subscription": "sub_7VDNwjyGqYhYMg" + }, + "lines": { + "data": [ + { + "id": "sub_7VDNwjyGqYhYMg", + "amount": 999, + "metadata": { + "id": "0000000000000000000186b4" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDNwjyGqYhYMg", + "total": 0 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCwQKaReE7xLUdqSluEgSu", + "status": 200, + "response": { + "id": "in_17GCwQKaReE7xLUdqSluEgSu", + "customer": "cus_7VDN2KNqruyD9I", + "lines": { + "data": [ + { + "id": "sub_7VDNPD9TIPgfsG", + "amount": 999, + "metadata": { + "id": "0000000000000000000186b5" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDNPD9TIPgfsG", + "total": 999 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDN2KNqruyD9I/subscriptions/sub_7VDNirCm8gp2m7", + "status": 200, + "response": { + "id": "sub_7VDNirCm8gp2m7", + "cancel_at_period_end": false, + "current_period_end": 1452365135, + "current_period_start": 1449686735, + "customer": "cus_7VDN2KNqruyD9I", + "metadata": { + "id": "0000000000000000000186b5" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 799 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDN2KNqruyD9I", + "status": 200, + "response": { + "id": "cus_7VDN2KNqruyD9I", + "alipay_accounts": { + "has_more": false + }, + "email": "user119@me.com", + "metadata": { + "id": "0000000000000000000186b5" + }, + "sources": { + "data": [ + { + "id": "card_17GCwOKaReE7xLUd3yZTswdV", + "customer": "cus_7VDN2KNqruyD9I" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDNirCm8gp2m7", + "cancel_at_period_end": false, + "current_period_end": 1452365135, + "current_period_start": 1449686735, + "customer": "cus_7VDN2KNqruyD9I", + "metadata": { + "id": "0000000000000000000186b5" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 799 + }, + { + "id": "sub_7VDNwjyGqYhYMg", + "cancel_at_period_end": false, + "current_period_end": 1452365133, + "current_period_start": 1449686733, + "customer": "cus_7VDN2KNqruyD9I", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDN2KNqruyD9I", + "subscription": "sub_7VDNwjyGqYhYMg" + }, + "metadata": { + "id": "0000000000000000000186b4" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDNPD9TIPgfsG", + "cancel_at_period_end": false, + "current_period_end": 1452365130, + "current_period_start": 1449686730, + "customer": "cus_7VDN2KNqruyD9I", + "metadata": { + "id": "0000000000000000000186b5" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDN2KNqruyD9I/subscriptions/sub_7VDNwjyGqYhYMg", + "status": 200, + "response": { + "id": "sub_7VDNwjyGqYhYMg", + "cancel_at_period_end": false, + "current_period_end": 1452365133, + "current_period_start": 1449686733, + "customer": "cus_7VDN2KNqruyD9I", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDN2KNqruyD9I", + "subscription": "sub_7VDNwjyGqYhYMg" + }, + "metadata": { + "id": "0000000000000000000186b4" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + } +] \ No newline at end of file diff --git a/spec/fixtures/sub-test-16.json b/spec/fixtures/sub-test-16.json new file mode 100644 index 000000000..4395309c2 --- /dev/null +++ b/spec/fixtures/sub-test-16.json @@ -0,0 +1,993 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCwbKaReE7xLUdaT8CuSIS", + "card": { + "id": "card_17GCwbKaReE7xLUd5IJIFWBp" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDNPC9EZ6JGhE", + "alipay_accounts": { + "has_more": false + }, + "email": "user121@me.com", + "metadata": { + "id": "0000000000000000000186b7" + }, + "sources": { + "data": [ + { + "id": "card_17GCwbKaReE7xLUd5IJIFWBp", + "customer": "cus_7VDNPC9EZ6JGhE" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDNPC9EZ6JGhE", + "status": 200, + "response": { + "id": "cus_7VDNPC9EZ6JGhE", + "alipay_accounts": { + "has_more": false + }, + "email": "user121@me.com", + "metadata": { + "id": "0000000000000000000186b7" + }, + "sources": { + "data": [ + { + "id": "card_17GCwbKaReE7xLUd5IJIFWBp", + "customer": "cus_7VDNPC9EZ6JGhE" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDNPC9EZ6JGhE/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDNR05m6WWAeS", + "cancel_at_period_end": false, + "current_period_end": 1452365143, + "current_period_start": 1449686743, + "customer": "cus_7VDNPC9EZ6JGhE", + "metadata": { + "id": "0000000000000000000186b7" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDNPC9EZ6JGhE", + "status": 200, + "response": { + "id": "cus_7VDNPC9EZ6JGhE", + "alipay_accounts": { + "has_more": false + }, + "email": "user121@me.com", + "metadata": { + "id": "0000000000000000000186b7" + }, + "sources": { + "data": [ + { + "id": "card_17GCwbKaReE7xLUd5IJIFWBp", + "customer": "cus_7VDNPC9EZ6JGhE" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDNR05m6WWAeS", + "cancel_at_period_end": false, + "current_period_end": 1452365143, + "current_period_start": 1449686743, + "customer": "cus_7VDNPC9EZ6JGhE", + "metadata": { + "id": "0000000000000000000186b7" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDNPC9EZ6JGhE", + "status": 200, + "response": { + "id": "cus_7VDNPC9EZ6JGhE", + "alipay_accounts": { + "has_more": false + }, + "email": "user121@me.com", + "metadata": { + "id": "0000000000000000000186b7" + }, + "sources": { + "data": [ + { + "id": "card_17GCwbKaReE7xLUd5IJIFWBp", + "customer": "cus_7VDNPC9EZ6JGhE" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDNR05m6WWAeS", + "cancel_at_period_end": false, + "current_period_end": 1452365143, + "current_period_start": 1449686743, + "customer": "cus_7VDNPC9EZ6JGhE", + "metadata": { + "id": "0000000000000000000186b7" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDNPC9EZ6JGhE", + "status": 200, + "response": { + "id": "cus_7VDNPC9EZ6JGhE", + "alipay_accounts": { + "has_more": false + }, + "email": "user121@me.com", + "metadata": { + "id": "0000000000000000000186b7" + }, + "sources": { + "data": [ + { + "id": "card_17GCwbKaReE7xLUd5IJIFWBp", + "customer": "cus_7VDNPC9EZ6JGhE" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDNR05m6WWAeS", + "cancel_at_period_end": false, + "current_period_end": 1452365143, + "current_period_start": 1449686743, + "customer": "cus_7VDNPC9EZ6JGhE", + "metadata": { + "id": "0000000000000000000186b7" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDNPC9EZ6JGhE/subscriptions", + "status": 200, + "response": { + "data": [ + { + "id": "sub_7VDNR05m6WWAeS", + "cancel_at_period_end": false, + "current_period_end": 1452365143, + "current_period_start": 1449686743, + "customer": "cus_7VDNPC9EZ6JGhE", + "metadata": { + "id": "0000000000000000000186b7" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDNPC9EZ6JGhE/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDNS5E09bpvSk", + "cancel_at_period_end": false, + "current_period_end": 1452365146, + "current_period_start": 1449686746, + "customer": "cus_7VDNPC9EZ6JGhE", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNPC9EZ6JGhE", + "subscription": "sub_7VDNS5E09bpvSk" + }, + "metadata": { + "id": "0000000000000000000186b6" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDNPC9EZ6JGhE", + "status": 200, + "response": { + "id": "cus_7VDNPC9EZ6JGhE", + "alipay_accounts": { + "has_more": false + }, + "email": "user121@me.com", + "metadata": { + "id": "0000000000000000000186b7" + }, + "sources": { + "data": [ + { + "id": "card_17GCwbKaReE7xLUd5IJIFWBp", + "customer": "cus_7VDNPC9EZ6JGhE" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDNS5E09bpvSk", + "cancel_at_period_end": false, + "current_period_end": 1452365146, + "current_period_start": 1449686746, + "customer": "cus_7VDNPC9EZ6JGhE", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNPC9EZ6JGhE", + "subscription": "sub_7VDNS5E09bpvSk" + }, + "metadata": { + "id": "0000000000000000000186b6" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDNR05m6WWAeS", + "cancel_at_period_end": false, + "current_period_end": 1452365143, + "current_period_start": 1449686743, + "customer": "cus_7VDNPC9EZ6JGhE", + "metadata": { + "id": "0000000000000000000186b7" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDNPC9EZ6JGhE/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDNHF276hw9Ic", + "cancel_at_period_end": false, + "current_period_end": 1452365147, + "current_period_start": 1449686747, + "customer": "cus_7VDNPC9EZ6JGhE", + "metadata": { + "id": "0000000000000000000186b7" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 799 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices", + "status": 200, + "response": { + "data": [ + { + "id": "in_17GCwhKaReE7xLUdCY899Ga9", + "customer": "cus_7VDNPC9EZ6JGhE", + "lines": { + "data": [ + { + "id": "sub_7VDNHF276hw9Ic", + "amount": 799, + "metadata": { + "id": "0000000000000000000186b7" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 799, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDNHF276hw9Ic", + "total": 799 + }, + { + "id": "in_17GCwgKaReE7xLUdQgRhKcNI", + "customer": "cus_7VDNPC9EZ6JGhE", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNPC9EZ6JGhE", + "subscription": "sub_7VDNS5E09bpvSk" + }, + "lines": { + "data": [ + { + "id": "sub_7VDNS5E09bpvSk", + "amount": 999, + "metadata": { + "id": "0000000000000000000186b6" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDNS5E09bpvSk", + "total": 0 + }, + { + "id": "in_17GCwdKaReE7xLUdRLGvAqaG", + "customer": "cus_7VDNPC9EZ6JGhE", + "lines": { + "data": [ + { + "id": "sub_7VDNR05m6WWAeS", + "amount": 999, + "metadata": { + "id": "0000000000000000000186b7" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDNR05m6WWAeS", + "total": 999 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDNPC9EZ6JGhE", + "status": 200, + "response": { + "id": "cus_7VDNPC9EZ6JGhE", + "alipay_accounts": { + "has_more": false + }, + "email": "user121@me.com", + "metadata": { + "id": "0000000000000000000186b7" + }, + "sources": { + "data": [ + { + "id": "card_17GCwbKaReE7xLUd5IJIFWBp", + "customer": "cus_7VDNPC9EZ6JGhE" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDNHF276hw9Ic", + "cancel_at_period_end": false, + "current_period_end": 1452365147, + "current_period_start": 1449686747, + "customer": "cus_7VDNPC9EZ6JGhE", + "metadata": { + "id": "0000000000000000000186b7" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 799 + }, + { + "id": "sub_7VDNS5E09bpvSk", + "cancel_at_period_end": false, + "current_period_end": 1452365146, + "current_period_start": 1449686746, + "customer": "cus_7VDNPC9EZ6JGhE", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNPC9EZ6JGhE", + "subscription": "sub_7VDNS5E09bpvSk" + }, + "metadata": { + "id": "0000000000000000000186b6" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDNR05m6WWAeS", + "cancel_at_period_end": false, + "current_period_end": 1452365143, + "current_period_start": 1449686743, + "customer": "cus_7VDNPC9EZ6JGhE", + "metadata": { + "id": "0000000000000000000186b7" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCwhKaReE7xLUdCY899Ga9", + "status": 200, + "response": { + "id": "in_17GCwhKaReE7xLUdCY899Ga9", + "customer": "cus_7VDNPC9EZ6JGhE", + "lines": { + "data": [ + { + "id": "sub_7VDNHF276hw9Ic", + "amount": 799, + "metadata": { + "id": "0000000000000000000186b7" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 799, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDNHF276hw9Ic", + "total": 799 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDNPC9EZ6JGhE", + "status": 200, + "response": { + "id": "cus_7VDNPC9EZ6JGhE", + "alipay_accounts": { + "has_more": false + }, + "email": "user121@me.com", + "metadata": { + "id": "0000000000000000000186b7" + }, + "sources": { + "data": [ + { + "id": "card_17GCwbKaReE7xLUd5IJIFWBp", + "customer": "cus_7VDNPC9EZ6JGhE" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDNHF276hw9Ic", + "cancel_at_period_end": false, + "current_period_end": 1452365147, + "current_period_start": 1449686747, + "customer": "cus_7VDNPC9EZ6JGhE", + "metadata": { + "id": "0000000000000000000186b7" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 799 + }, + { + "id": "sub_7VDNS5E09bpvSk", + "cancel_at_period_end": false, + "current_period_end": 1452365146, + "current_period_start": 1449686746, + "customer": "cus_7VDNPC9EZ6JGhE", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNPC9EZ6JGhE", + "subscription": "sub_7VDNS5E09bpvSk" + }, + "metadata": { + "id": "0000000000000000000186b6" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDNR05m6WWAeS", + "cancel_at_period_end": false, + "current_period_end": 1452365143, + "current_period_start": 1449686743, + "customer": "cus_7VDNPC9EZ6JGhE", + "metadata": { + "id": "0000000000000000000186b7" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDNPC9EZ6JGhE", + "status": 200, + "response": { + "id": "cus_7VDNPC9EZ6JGhE", + "alipay_accounts": { + "has_more": false + }, + "email": "user121@me.com", + "metadata": { + "id": "0000000000000000000186b7" + }, + "sources": { + "data": [ + { + "id": "card_17GCwbKaReE7xLUd5IJIFWBp", + "customer": "cus_7VDNPC9EZ6JGhE" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDNHF276hw9Ic", + "cancel_at_period_end": false, + "current_period_end": 1452365147, + "current_period_start": 1449686747, + "customer": "cus_7VDNPC9EZ6JGhE", + "metadata": { + "id": "0000000000000000000186b7" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 799 + }, + { + "id": "sub_7VDNS5E09bpvSk", + "cancel_at_period_end": false, + "current_period_end": 1452365146, + "current_period_start": 1449686746, + "customer": "cus_7VDNPC9EZ6JGhE", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNPC9EZ6JGhE", + "subscription": "sub_7VDNS5E09bpvSk" + }, + "metadata": { + "id": "0000000000000000000186b6" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDNR05m6WWAeS", + "cancel_at_period_end": false, + "current_period_end": 1452365143, + "current_period_start": 1449686743, + "customer": "cus_7VDNPC9EZ6JGhE", + "metadata": { + "id": "0000000000000000000186b7" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCwgKaReE7xLUdQgRhKcNI", + "status": 200, + "response": { + "id": "in_17GCwgKaReE7xLUdQgRhKcNI", + "customer": "cus_7VDNPC9EZ6JGhE", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNPC9EZ6JGhE", + "subscription": "sub_7VDNS5E09bpvSk" + }, + "lines": { + "data": [ + { + "id": "sub_7VDNS5E09bpvSk", + "amount": 999, + "metadata": { + "id": "0000000000000000000186b6" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDNS5E09bpvSk", + "total": 0 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCwdKaReE7xLUdRLGvAqaG", + "status": 200, + "response": { + "id": "in_17GCwdKaReE7xLUdRLGvAqaG", + "customer": "cus_7VDNPC9EZ6JGhE", + "lines": { + "data": [ + { + "id": "sub_7VDNR05m6WWAeS", + "amount": 999, + "metadata": { + "id": "0000000000000000000186b7" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDNR05m6WWAeS", + "total": 999 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDNPC9EZ6JGhE/subscriptions/sub_7VDNS5E09bpvSk", + "status": 200, + "response": { + "id": "sub_7VDNS5E09bpvSk", + "cancel_at_period_end": false, + "current_period_end": 1452365146, + "current_period_start": 1449686746, + "customer": "cus_7VDNPC9EZ6JGhE", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNPC9EZ6JGhE", + "subscription": "sub_7VDNS5E09bpvSk" + }, + "metadata": { + "id": "0000000000000000000186b6" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDNPC9EZ6JGhE", + "status": 200, + "response": { + "id": "cus_7VDNPC9EZ6JGhE", + "alipay_accounts": { + "has_more": false + }, + "email": "user121@me.com", + "metadata": { + "id": "0000000000000000000186b7" + }, + "sources": { + "data": [ + { + "id": "card_17GCwbKaReE7xLUd5IJIFWBp", + "customer": "cus_7VDNPC9EZ6JGhE" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDNHF276hw9Ic", + "cancel_at_period_end": false, + "current_period_end": 1452365147, + "current_period_start": 1449686747, + "customer": "cus_7VDNPC9EZ6JGhE", + "metadata": { + "id": "0000000000000000000186b7" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 799 + }, + { + "id": "sub_7VDNS5E09bpvSk", + "cancel_at_period_end": false, + "current_period_end": 1452365146, + "current_period_start": 1449686746, + "customer": "cus_7VDNPC9EZ6JGhE", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNPC9EZ6JGhE", + "subscription": "sub_7VDNS5E09bpvSk" + }, + "metadata": { + "id": "0000000000000000000186b6" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDNR05m6WWAeS", + "cancel_at_period_end": false, + "current_period_end": 1452365143, + "current_period_start": 1449686743, + "customer": "cus_7VDNPC9EZ6JGhE", + "metadata": { + "id": "0000000000000000000186b7" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "DELETE", + "path": "/v1/customers/cus_7VDNPC9EZ6JGhE/subscriptions/sub_7VDNS5E09bpvSk", + "status": 200, + "response": { + "id": "sub_7VDNS5E09bpvSk", + "cancel_at_period_end": false, + "current_period_end": 1452365146, + "current_period_start": 1449686746, + "customer": "cus_7VDNPC9EZ6JGhE", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNPC9EZ6JGhE", + "subscription": "sub_7VDNS5E09bpvSk" + }, + "metadata": { + "id": "0000000000000000000186b6" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDNPC9EZ6JGhE/subscriptions", + "status": 200, + "response": { + "data": [ + { + "id": "sub_7VDNHF276hw9Ic", + "cancel_at_period_end": false, + "current_period_end": 1452365147, + "current_period_start": 1449686747, + "customer": "cus_7VDNPC9EZ6JGhE", + "metadata": { + "id": "0000000000000000000186b7" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 799 + }, + { + "id": "sub_7VDNR05m6WWAeS", + "cancel_at_period_end": false, + "current_period_end": 1452365143, + "current_period_start": 1449686743, + "customer": "cus_7VDNPC9EZ6JGhE", + "metadata": { + "id": "0000000000000000000186b7" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } +] \ No newline at end of file diff --git a/spec/fixtures/sub-test-17.json b/spec/fixtures/sub-test-17.json new file mode 100644 index 000000000..e180e0f2e --- /dev/null +++ b/spec/fixtures/sub-test-17.json @@ -0,0 +1,731 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCwmKaReE7xLUdpl5Q3yOw", + "card": { + "id": "card_17GCwmKaReE7xLUd3sr8m76Y" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDNJTygSygz49", + "alipay_accounts": { + "has_more": false + }, + "email": "user123@me.com", + "metadata": { + "id": "0000000000000000000186b9" + }, + "sources": { + "data": [ + { + "id": "card_17GCwmKaReE7xLUd3sr8m76Y", + "customer": "cus_7VDNJTygSygz49" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDNJTygSygz49/subscriptions", + "status": 200, + "response": { + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDNJTygSygz49", + "status": 200, + "response": { + "id": "cus_7VDNJTygSygz49", + "alipay_accounts": { + "has_more": false + }, + "email": "user123@me.com", + "metadata": { + "id": "0000000000000000000186b9" + }, + "sources": { + "data": [ + { + "id": "card_17GCwmKaReE7xLUd3sr8m76Y", + "customer": "cus_7VDNJTygSygz49" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDNJTygSygz49/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDNbSQlfeeWHJ", + "cancel_at_period_end": false, + "current_period_end": 1452365155, + "current_period_start": 1449686755, + "customer": "cus_7VDNJTygSygz49", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNJTygSygz49", + "subscription": "sub_7VDNbSQlfeeWHJ" + }, + "metadata": { + "id": "0000000000000000000186b8" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDNJTygSygz49/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDNDyYKMgd89h", + "cancel_at_period_end": false, + "current_period_end": 1452365156, + "current_period_start": 1449686756, + "customer": "cus_7VDNJTygSygz49", + "metadata": { + "id": "0000000000000000000186b9" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices", + "status": 200, + "response": { + "data": [ + { + "id": "in_17GCwqKaReE7xLUdkrPY6enO", + "customer": "cus_7VDNJTygSygz49", + "lines": { + "data": [ + { + "id": "sub_7VDNDyYKMgd89h", + "amount": 999, + "metadata": { + "id": "0000000000000000000186b9" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 999, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDNDyYKMgd89h", + "total": 999 + }, + { + "id": "in_17GCwpKaReE7xLUdsuaebpGq", + "customer": "cus_7VDNJTygSygz49", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNJTygSygz49", + "subscription": "sub_7VDNbSQlfeeWHJ" + }, + "lines": { + "data": [ + { + "id": "sub_7VDNbSQlfeeWHJ", + "amount": 999, + "metadata": { + "id": "0000000000000000000186b8" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDNbSQlfeeWHJ", + "total": 0 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDNJTygSygz49", + "status": 200, + "response": { + "id": "cus_7VDNJTygSygz49", + "alipay_accounts": { + "has_more": false + }, + "email": "user123@me.com", + "metadata": { + "id": "0000000000000000000186b9" + }, + "sources": { + "data": [ + { + "id": "card_17GCwmKaReE7xLUd3sr8m76Y", + "customer": "cus_7VDNJTygSygz49" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDNDyYKMgd89h", + "cancel_at_period_end": false, + "current_period_end": 1452365156, + "current_period_start": 1449686756, + "customer": "cus_7VDNJTygSygz49", + "metadata": { + "id": "0000000000000000000186b9" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDNbSQlfeeWHJ", + "cancel_at_period_end": false, + "current_period_end": 1452365155, + "current_period_start": 1449686755, + "customer": "cus_7VDNJTygSygz49", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNJTygSygz49", + "subscription": "sub_7VDNbSQlfeeWHJ" + }, + "metadata": { + "id": "0000000000000000000186b8" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDNJTygSygz49", + "status": 200, + "response": { + "id": "cus_7VDNJTygSygz49", + "alipay_accounts": { + "has_more": false + }, + "email": "user123@me.com", + "metadata": { + "id": "0000000000000000000186b9" + }, + "sources": { + "data": [ + { + "id": "card_17GCwmKaReE7xLUd3sr8m76Y", + "customer": "cus_7VDNJTygSygz49" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDNDyYKMgd89h", + "cancel_at_period_end": false, + "current_period_end": 1452365156, + "current_period_start": 1449686756, + "customer": "cus_7VDNJTygSygz49", + "metadata": { + "id": "0000000000000000000186b9" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDNbSQlfeeWHJ", + "cancel_at_period_end": false, + "current_period_end": 1452365155, + "current_period_start": 1449686755, + "customer": "cus_7VDNJTygSygz49", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNJTygSygz49", + "subscription": "sub_7VDNbSQlfeeWHJ" + }, + "metadata": { + "id": "0000000000000000000186b8" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCwqKaReE7xLUdkrPY6enO", + "status": 200, + "response": { + "id": "in_17GCwqKaReE7xLUdkrPY6enO", + "customer": "cus_7VDNJTygSygz49", + "lines": { + "data": [ + { + "id": "sub_7VDNDyYKMgd89h", + "amount": 999, + "metadata": { + "id": "0000000000000000000186b9" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 999, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDNDyYKMgd89h", + "total": 999 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDNJTygSygz49", + "status": 200, + "response": { + "id": "cus_7VDNJTygSygz49", + "alipay_accounts": { + "has_more": false + }, + "email": "user123@me.com", + "metadata": { + "id": "0000000000000000000186b9" + }, + "sources": { + "data": [ + { + "id": "card_17GCwmKaReE7xLUd3sr8m76Y", + "customer": "cus_7VDNJTygSygz49" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDNDyYKMgd89h", + "cancel_at_period_end": false, + "current_period_end": 1452365156, + "current_period_start": 1449686756, + "customer": "cus_7VDNJTygSygz49", + "metadata": { + "id": "0000000000000000000186b9" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDNbSQlfeeWHJ", + "cancel_at_period_end": false, + "current_period_end": 1452365155, + "current_period_start": 1449686755, + "customer": "cus_7VDNJTygSygz49", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNJTygSygz49", + "subscription": "sub_7VDNbSQlfeeWHJ" + }, + "metadata": { + "id": "0000000000000000000186b8" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDNJTygSygz49", + "status": 200, + "response": { + "id": "cus_7VDNJTygSygz49", + "alipay_accounts": { + "has_more": false + }, + "email": "user123@me.com", + "metadata": { + "id": "0000000000000000000186b9" + }, + "sources": { + "data": [ + { + "id": "card_17GCwmKaReE7xLUd3sr8m76Y", + "customer": "cus_7VDNJTygSygz49" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDNDyYKMgd89h", + "cancel_at_period_end": false, + "current_period_end": 1452365156, + "current_period_start": 1449686756, + "customer": "cus_7VDNJTygSygz49", + "metadata": { + "id": "0000000000000000000186b9" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDNbSQlfeeWHJ", + "cancel_at_period_end": false, + "current_period_end": 1452365155, + "current_period_start": 1449686755, + "customer": "cus_7VDNJTygSygz49", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNJTygSygz49", + "subscription": "sub_7VDNbSQlfeeWHJ" + }, + "metadata": { + "id": "0000000000000000000186b8" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCwpKaReE7xLUdsuaebpGq", + "status": 200, + "response": { + "id": "in_17GCwpKaReE7xLUdsuaebpGq", + "customer": "cus_7VDNJTygSygz49", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNJTygSygz49", + "subscription": "sub_7VDNbSQlfeeWHJ" + }, + "lines": { + "data": [ + { + "id": "sub_7VDNbSQlfeeWHJ", + "amount": 999, + "metadata": { + "id": "0000000000000000000186b8" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDNbSQlfeeWHJ", + "total": 0 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDNJTygSygz49/subscriptions/sub_7VDNbSQlfeeWHJ", + "status": 200, + "response": { + "id": "sub_7VDNbSQlfeeWHJ", + "cancel_at_period_end": false, + "current_period_end": 1452365155, + "current_period_start": 1449686755, + "customer": "cus_7VDNJTygSygz49", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNJTygSygz49", + "subscription": "sub_7VDNbSQlfeeWHJ" + }, + "metadata": { + "id": "0000000000000000000186b8" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "DELETE", + "path": "/v1/customers/cus_7VDNJTygSygz49/subscriptions/sub_7VDNbSQlfeeWHJ", + "status": 200, + "response": { + "id": "sub_7VDNbSQlfeeWHJ", + "cancel_at_period_end": false, + "current_period_end": 1452365155, + "current_period_start": 1449686755, + "customer": "cus_7VDNJTygSygz49", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNJTygSygz49", + "subscription": "sub_7VDNbSQlfeeWHJ" + }, + "metadata": { + "id": "0000000000000000000186b8" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDNJTygSygz49", + "status": 200, + "response": { + "id": "cus_7VDNJTygSygz49", + "alipay_accounts": { + "has_more": false + }, + "email": "user123@me.com", + "metadata": { + "id": "0000000000000000000186b9" + }, + "sources": { + "data": [ + { + "id": "card_17GCwmKaReE7xLUd3sr8m76Y", + "customer": "cus_7VDNJTygSygz49" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDNDyYKMgd89h", + "cancel_at_period_end": false, + "current_period_end": 1452365156, + "current_period_start": 1449686756, + "customer": "cus_7VDNJTygSygz49", + "metadata": { + "id": "0000000000000000000186b9" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDNJTygSygz49/subscriptions/sub_7VDNDyYKMgd89h", + "status": 200, + "response": { + "id": "sub_7VDNDyYKMgd89h", + "cancel_at_period_end": false, + "current_period_end": 1452365156, + "current_period_start": 1449686756, + "customer": "cus_7VDNJTygSygz49", + "metadata": { + "id": "0000000000000000000186b9" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 0 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDNJTygSygz49", + "status": 200, + "response": { + "id": "cus_7VDNJTygSygz49", + "alipay_accounts": { + "has_more": false + }, + "email": "user123@me.com", + "metadata": { + "id": "0000000000000000000186b9" + }, + "sources": { + "data": [ + { + "id": "card_17GCwmKaReE7xLUd3sr8m76Y", + "customer": "cus_7VDNJTygSygz49" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDNDyYKMgd89h", + "cancel_at_period_end": false, + "current_period_end": 1452365156, + "current_period_start": 1449686756, + "customer": "cus_7VDNJTygSygz49", + "metadata": { + "id": "0000000000000000000186b9" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 0 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDNJTygSygz49/subscriptions", + "status": 200, + "response": { + "data": [ + { + "id": "sub_7VDNDyYKMgd89h", + "cancel_at_period_end": false, + "current_period_end": 1452365156, + "current_period_start": 1449686756, + "customer": "cus_7VDNJTygSygz49", + "metadata": { + "id": "0000000000000000000186b9" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 0 + } + ], + "has_more": false + } + } +] \ No newline at end of file diff --git a/spec/fixtures/sub-test-18.json b/spec/fixtures/sub-test-18.json new file mode 100644 index 000000000..12a5b75c9 --- /dev/null +++ b/spec/fixtures/sub-test-18.json @@ -0,0 +1,1306 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCwwKaReE7xLUdykvY9I8c", + "card": { + "id": "card_17GCwwKaReE7xLUdbt92OyM5" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDNEbpCO5sH6A", + "alipay_accounts": { + "has_more": false + }, + "email": "user125@me.com", + "metadata": { + "id": "0000000000000000000186bb" + }, + "sources": { + "data": [ + { + "id": "card_17GCwwKaReE7xLUdbt92OyM5", + "customer": "cus_7VDNEbpCO5sH6A" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDNEbpCO5sH6A", + "status": 200, + "response": { + "id": "cus_7VDNEbpCO5sH6A", + "alipay_accounts": { + "has_more": false + }, + "email": "user125@me.com", + "metadata": { + "id": "0000000000000000000186bb" + }, + "sources": { + "data": [ + { + "id": "card_17GCwwKaReE7xLUdbt92OyM5", + "customer": "cus_7VDNEbpCO5sH6A" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDNEbpCO5sH6A/subscriptions", + "status": 200, + "response": { + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDNEbpCO5sH6A/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDNj1BJ6IyEzR", + "cancel_at_period_end": false, + "current_period_end": 1452365164, + "current_period_start": 1449686764, + "customer": "cus_7VDNEbpCO5sH6A", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNEbpCO5sH6A", + "subscription": "sub_7VDNj1BJ6IyEzR" + }, + "metadata": { + "id": "0000000000000000000186ba" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDNEbpCO5sH6A", + "status": 200, + "response": { + "id": "cus_7VDNEbpCO5sH6A", + "alipay_accounts": { + "has_more": false + }, + "email": "user125@me.com", + "metadata": { + "id": "0000000000000000000186bb" + }, + "sources": { + "data": [ + { + "id": "card_17GCwwKaReE7xLUdbt92OyM5", + "customer": "cus_7VDNEbpCO5sH6A" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDNj1BJ6IyEzR", + "cancel_at_period_end": false, + "current_period_end": 1452365164, + "current_period_start": 1449686764, + "customer": "cus_7VDNEbpCO5sH6A", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNEbpCO5sH6A", + "subscription": "sub_7VDNj1BJ6IyEzR" + }, + "metadata": { + "id": "0000000000000000000186ba" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDNEbpCO5sH6A/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDNqiPOSQDgH4", + "cancel_at_period_end": false, + "current_period_end": 1452365165, + "current_period_start": 1449686765, + "customer": "cus_7VDNEbpCO5sH6A", + "metadata": { + "id": "0000000000000000000186bb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices", + "status": 200, + "response": { + "data": [ + { + "id": "in_17GCwzKaReE7xLUdpyCrFPH1", + "customer": "cus_7VDNEbpCO5sH6A", + "lines": { + "data": [ + { + "id": "sub_7VDNqiPOSQDgH4", + "amount": 999, + "metadata": { + "id": "0000000000000000000186bb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 999, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDNqiPOSQDgH4", + "total": 999 + }, + { + "id": "in_17GCwyKaReE7xLUdtCFo3S04", + "customer": "cus_7VDNEbpCO5sH6A", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNEbpCO5sH6A", + "subscription": "sub_7VDNj1BJ6IyEzR" + }, + "lines": { + "data": [ + { + "id": "sub_7VDNj1BJ6IyEzR", + "amount": 999, + "metadata": { + "id": "0000000000000000000186ba" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDNj1BJ6IyEzR", + "total": 0 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDNEbpCO5sH6A", + "status": 200, + "response": { + "id": "cus_7VDNEbpCO5sH6A", + "alipay_accounts": { + "has_more": false + }, + "email": "user125@me.com", + "metadata": { + "id": "0000000000000000000186bb" + }, + "sources": { + "data": [ + { + "id": "card_17GCwwKaReE7xLUdbt92OyM5", + "customer": "cus_7VDNEbpCO5sH6A" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDNqiPOSQDgH4", + "cancel_at_period_end": false, + "current_period_end": 1452365165, + "current_period_start": 1449686765, + "customer": "cus_7VDNEbpCO5sH6A", + "metadata": { + "id": "0000000000000000000186bb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDNj1BJ6IyEzR", + "cancel_at_period_end": false, + "current_period_end": 1452365164, + "current_period_start": 1449686764, + "customer": "cus_7VDNEbpCO5sH6A", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNEbpCO5sH6A", + "subscription": "sub_7VDNj1BJ6IyEzR" + }, + "metadata": { + "id": "0000000000000000000186ba" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCwzKaReE7xLUdpyCrFPH1", + "status": 200, + "response": { + "id": "in_17GCwzKaReE7xLUdpyCrFPH1", + "customer": "cus_7VDNEbpCO5sH6A", + "lines": { + "data": [ + { + "id": "sub_7VDNqiPOSQDgH4", + "amount": 999, + "metadata": { + "id": "0000000000000000000186bb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 999, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDNqiPOSQDgH4", + "total": 999 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDNEbpCO5sH6A", + "status": 200, + "response": { + "id": "cus_7VDNEbpCO5sH6A", + "alipay_accounts": { + "has_more": false + }, + "email": "user125@me.com", + "metadata": { + "id": "0000000000000000000186bb" + }, + "sources": { + "data": [ + { + "id": "card_17GCwwKaReE7xLUdbt92OyM5", + "customer": "cus_7VDNEbpCO5sH6A" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDNqiPOSQDgH4", + "cancel_at_period_end": false, + "current_period_end": 1452365165, + "current_period_start": 1449686765, + "customer": "cus_7VDNEbpCO5sH6A", + "metadata": { + "id": "0000000000000000000186bb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDNj1BJ6IyEzR", + "cancel_at_period_end": false, + "current_period_end": 1452365164, + "current_period_start": 1449686764, + "customer": "cus_7VDNEbpCO5sH6A", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNEbpCO5sH6A", + "subscription": "sub_7VDNj1BJ6IyEzR" + }, + "metadata": { + "id": "0000000000000000000186ba" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDNEbpCO5sH6A", + "status": 200, + "response": { + "id": "cus_7VDNEbpCO5sH6A", + "alipay_accounts": { + "has_more": false + }, + "email": "user125@me.com", + "metadata": { + "id": "0000000000000000000186bb" + }, + "sources": { + "data": [ + { + "id": "card_17GCwwKaReE7xLUdbt92OyM5", + "customer": "cus_7VDNEbpCO5sH6A" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDNqiPOSQDgH4", + "cancel_at_period_end": false, + "current_period_end": 1452365165, + "current_period_start": 1449686765, + "customer": "cus_7VDNEbpCO5sH6A", + "metadata": { + "id": "0000000000000000000186bb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDNj1BJ6IyEzR", + "cancel_at_period_end": false, + "current_period_end": 1452365164, + "current_period_start": 1449686764, + "customer": "cus_7VDNEbpCO5sH6A", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNEbpCO5sH6A", + "subscription": "sub_7VDNj1BJ6IyEzR" + }, + "metadata": { + "id": "0000000000000000000186ba" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCwyKaReE7xLUdtCFo3S04", + "status": 200, + "response": { + "id": "in_17GCwyKaReE7xLUdtCFo3S04", + "customer": "cus_7VDNEbpCO5sH6A", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNEbpCO5sH6A", + "subscription": "sub_7VDNj1BJ6IyEzR" + }, + "lines": { + "data": [ + { + "id": "sub_7VDNj1BJ6IyEzR", + "amount": 999, + "metadata": { + "id": "0000000000000000000186ba" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDNj1BJ6IyEzR", + "total": 0 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDNEbpCO5sH6A/subscriptions/sub_7VDNj1BJ6IyEzR", + "status": 200, + "response": { + "id": "sub_7VDNj1BJ6IyEzR", + "cancel_at_period_end": false, + "current_period_end": 1452365164, + "current_period_start": 1449686764, + "customer": "cus_7VDNEbpCO5sH6A", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNEbpCO5sH6A", + "subscription": "sub_7VDNj1BJ6IyEzR" + }, + "metadata": { + "id": "0000000000000000000186ba" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "DELETE", + "path": "/v1/customers/cus_7VDNEbpCO5sH6A/subscriptions/sub_7VDNj1BJ6IyEzR", + "status": 200, + "response": { + "id": "sub_7VDNj1BJ6IyEzR", + "cancel_at_period_end": false, + "current_period_end": 1452365164, + "current_period_start": 1449686764, + "customer": "cus_7VDNEbpCO5sH6A", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNEbpCO5sH6A", + "subscription": "sub_7VDNj1BJ6IyEzR" + }, + "metadata": { + "id": "0000000000000000000186ba" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDNEbpCO5sH6A", + "status": 200, + "response": { + "id": "cus_7VDNEbpCO5sH6A", + "alipay_accounts": { + "has_more": false + }, + "email": "user125@me.com", + "metadata": { + "id": "0000000000000000000186bb" + }, + "sources": { + "data": [ + { + "id": "card_17GCwwKaReE7xLUdbt92OyM5", + "customer": "cus_7VDNEbpCO5sH6A" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDNqiPOSQDgH4", + "cancel_at_period_end": false, + "current_period_end": 1452365165, + "current_period_start": 1449686765, + "customer": "cus_7VDNEbpCO5sH6A", + "metadata": { + "id": "0000000000000000000186bb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDNEbpCO5sH6A/subscriptions/sub_7VDNqiPOSQDgH4", + "status": 200, + "response": { + "id": "sub_7VDNqiPOSQDgH4", + "cancel_at_period_end": false, + "current_period_end": 1452365165, + "current_period_start": 1449686765, + "customer": "cus_7VDNEbpCO5sH6A", + "metadata": { + "id": "0000000000000000000186bb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 0 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDNEbpCO5sH6A", + "status": 200, + "response": { + "id": "cus_7VDNEbpCO5sH6A", + "alipay_accounts": { + "has_more": false + }, + "email": "user125@me.com", + "metadata": { + "id": "0000000000000000000186bb" + }, + "sources": { + "data": [ + { + "id": "card_17GCwwKaReE7xLUdbt92OyM5", + "customer": "cus_7VDNEbpCO5sH6A" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDNqiPOSQDgH4", + "cancel_at_period_end": false, + "current_period_end": 1452365165, + "current_period_start": 1449686765, + "customer": "cus_7VDNEbpCO5sH6A", + "metadata": { + "id": "0000000000000000000186bb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 0 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDNEbpCO5sH6A", + "status": 200, + "response": { + "id": "cus_7VDNEbpCO5sH6A", + "alipay_accounts": { + "has_more": false + }, + "email": "user125@me.com", + "metadata": { + "id": "0000000000000000000186bb" + }, + "sources": { + "data": [ + { + "id": "card_17GCwwKaReE7xLUdbt92OyM5", + "customer": "cus_7VDNEbpCO5sH6A" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDNqiPOSQDgH4", + "cancel_at_period_end": false, + "current_period_end": 1452365165, + "current_period_start": 1449686765, + "customer": "cus_7VDNEbpCO5sH6A", + "metadata": { + "id": "0000000000000000000186bb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 0 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDNEbpCO5sH6A/subscriptions", + "status": 200, + "response": { + "data": [ + { + "id": "sub_7VDNqiPOSQDgH4", + "cancel_at_period_end": false, + "current_period_end": 1452365165, + "current_period_start": 1449686765, + "customer": "cus_7VDNEbpCO5sH6A", + "metadata": { + "id": "0000000000000000000186bb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 0 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDNEbpCO5sH6A/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDNQ6oukVnouu", + "cancel_at_period_end": false, + "current_period_end": 1452365172, + "current_period_start": 1449686772, + "customer": "cus_7VDNEbpCO5sH6A", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNEbpCO5sH6A", + "subscription": "sub_7VDNQ6oukVnouu" + }, + "metadata": { + "id": "0000000000000000000186ba" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDNEbpCO5sH6A/subscriptions", + "status": 200, + "response": { + "data": [ + { + "id": "sub_7VDNQ6oukVnouu", + "cancel_at_period_end": false, + "current_period_end": 1452365172, + "current_period_start": 1449686772, + "customer": "cus_7VDNEbpCO5sH6A", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNEbpCO5sH6A", + "subscription": "sub_7VDNQ6oukVnouu" + }, + "metadata": { + "id": "0000000000000000000186ba" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDNqiPOSQDgH4", + "cancel_at_period_end": false, + "current_period_end": 1452365165, + "current_period_start": 1449686765, + "customer": "cus_7VDNEbpCO5sH6A", + "metadata": { + "id": "0000000000000000000186bb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 0 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDNEbpCO5sH6A", + "status": 200, + "response": { + "id": "cus_7VDNEbpCO5sH6A", + "alipay_accounts": { + "has_more": false + }, + "email": "user125@me.com", + "metadata": { + "id": "0000000000000000000186bb" + }, + "sources": { + "data": [ + { + "id": "card_17GCwwKaReE7xLUdbt92OyM5", + "customer": "cus_7VDNEbpCO5sH6A" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDNQ6oukVnouu", + "cancel_at_period_end": false, + "current_period_end": 1452365172, + "current_period_start": 1449686772, + "customer": "cus_7VDNEbpCO5sH6A", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNEbpCO5sH6A", + "subscription": "sub_7VDNQ6oukVnouu" + }, + "metadata": { + "id": "0000000000000000000186ba" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDNqiPOSQDgH4", + "cancel_at_period_end": false, + "current_period_end": 1452365165, + "current_period_start": 1449686765, + "customer": "cus_7VDNEbpCO5sH6A", + "metadata": { + "id": "0000000000000000000186bb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 0 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDNEbpCO5sH6A/subscriptions/sub_7VDNqiPOSQDgH4", + "status": 200, + "response": { + "id": "sub_7VDNqiPOSQDgH4", + "cancel_at_period_end": false, + "current_period_end": 1452365165, + "current_period_start": 1449686765, + "customer": "cus_7VDNEbpCO5sH6A", + "metadata": { + "id": "0000000000000000000186bb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/invoices", + "status": 200, + "response": { + "id": "in_17GCx9KaReE7xLUdnX0p490o", + "customer": "cus_7VDNEbpCO5sH6A", + "lines": { + "data": [ + { + "id": "ii_17GCx8KaReE7xLUdNnsvlikN", + "amount": 999, + "description": "Remaining time on 999 x Incremental after 09 Dec 2015", + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": true, + "quantity": 999, + "subscription": "sub_7VDNqiPOSQDgH4", + "type": "invoiceitem" + }, + { + "id": "ii_17GCx5KaReE7xLUdfkXDiRI5", + "amount": -999, + "description": "Unused time on 999 x Incremental after 09 Dec 2015", + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": true, + "quantity": 999, + "subscription": "sub_7VDNqiPOSQDgH4", + "type": "invoiceitem" + } + ], + "has_more": false + }, + "paid": false, + "total": 0 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices", + "status": 200, + "response": { + "data": [ + { + "id": "in_17GCx9KaReE7xLUdnX0p490o", + "customer": "cus_7VDNEbpCO5sH6A", + "lines": { + "data": [ + { + "id": "ii_17GCx8KaReE7xLUdNnsvlikN", + "amount": 999, + "description": "Remaining time on 999 x Incremental after 09 Dec 2015", + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": true, + "quantity": 999, + "subscription": "sub_7VDNqiPOSQDgH4", + "type": "invoiceitem" + }, + { + "id": "ii_17GCx5KaReE7xLUdfkXDiRI5", + "amount": -999, + "description": "Unused time on 999 x Incremental after 09 Dec 2015", + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": true, + "quantity": 999, + "subscription": "sub_7VDNqiPOSQDgH4", + "type": "invoiceitem" + } + ], + "has_more": false + }, + "paid": false, + "total": 0 + }, + { + "id": "in_17GCx6KaReE7xLUd9o45iCRw", + "customer": "cus_7VDNEbpCO5sH6A", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNEbpCO5sH6A", + "subscription": "sub_7VDNQ6oukVnouu" + }, + "lines": { + "data": [ + { + "id": "sub_7VDNQ6oukVnouu", + "amount": 999, + "metadata": { + "id": "0000000000000000000186ba" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDNQ6oukVnouu", + "total": 0 + }, + { + "id": "in_17GCwzKaReE7xLUdpyCrFPH1", + "customer": "cus_7VDNEbpCO5sH6A", + "lines": { + "data": [ + { + "id": "sub_7VDNqiPOSQDgH4", + "amount": 999, + "metadata": { + "id": "0000000000000000000186bb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 999, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDNqiPOSQDgH4", + "total": 999 + }, + { + "id": "in_17GCwyKaReE7xLUdtCFo3S04", + "customer": "cus_7VDNEbpCO5sH6A", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNEbpCO5sH6A", + "subscription": "sub_7VDNj1BJ6IyEzR" + }, + "lines": { + "data": [ + { + "id": "sub_7VDNj1BJ6IyEzR", + "amount": 999, + "metadata": { + "id": "0000000000000000000186ba" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDNj1BJ6IyEzR", + "total": 0 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDNEbpCO5sH6A", + "status": 200, + "response": { + "id": "cus_7VDNEbpCO5sH6A", + "alipay_accounts": { + "has_more": false + }, + "email": "user125@me.com", + "metadata": { + "id": "0000000000000000000186bb" + }, + "sources": { + "data": [ + { + "id": "card_17GCwwKaReE7xLUdbt92OyM5", + "customer": "cus_7VDNEbpCO5sH6A" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDNqiPOSQDgH4", + "cancel_at_period_end": false, + "current_period_end": 1452365165, + "current_period_start": 1449686765, + "customer": "cus_7VDNEbpCO5sH6A", + "metadata": { + "id": "0000000000000000000186bb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDNQ6oukVnouu", + "cancel_at_period_end": false, + "current_period_end": 1452365172, + "current_period_start": 1449686772, + "customer": "cus_7VDNEbpCO5sH6A", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNEbpCO5sH6A", + "subscription": "sub_7VDNQ6oukVnouu" + }, + "metadata": { + "id": "0000000000000000000186ba" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCx9KaReE7xLUdnX0p490o", + "status": 200, + "response": { + "id": "in_17GCx9KaReE7xLUdnX0p490o", + "customer": "cus_7VDNEbpCO5sH6A", + "lines": { + "data": [ + { + "id": "ii_17GCx8KaReE7xLUdNnsvlikN", + "amount": 999, + "description": "Remaining time on 999 x Incremental after 09 Dec 2015", + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": true, + "quantity": 999, + "subscription": "sub_7VDNqiPOSQDgH4", + "type": "invoiceitem" + }, + { + "id": "ii_17GCx5KaReE7xLUdfkXDiRI5", + "amount": -999, + "description": "Unused time on 999 x Incremental after 09 Dec 2015", + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": true, + "quantity": 999, + "subscription": "sub_7VDNqiPOSQDgH4", + "type": "invoiceitem" + } + ], + "has_more": false + }, + "paid": false, + "total": 0 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCx6KaReE7xLUd9o45iCRw", + "status": 200, + "response": { + "id": "in_17GCx6KaReE7xLUd9o45iCRw", + "customer": "cus_7VDNEbpCO5sH6A", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNEbpCO5sH6A", + "subscription": "sub_7VDNQ6oukVnouu" + }, + "lines": { + "data": [ + { + "id": "sub_7VDNQ6oukVnouu", + "amount": 999, + "metadata": { + "id": "0000000000000000000186ba" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDNQ6oukVnouu", + "total": 0 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDNEbpCO5sH6A/subscriptions/sub_7VDNqiPOSQDgH4", + "status": 200, + "response": { + "id": "sub_7VDNqiPOSQDgH4", + "cancel_at_period_end": false, + "current_period_end": 1452365165, + "current_period_start": 1449686765, + "customer": "cus_7VDNEbpCO5sH6A", + "metadata": { + "id": "0000000000000000000186bb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDNEbpCO5sH6A/subscriptions/sub_7VDNQ6oukVnouu", + "status": 200, + "response": { + "id": "sub_7VDNQ6oukVnouu", + "cancel_at_period_end": false, + "current_period_end": 1452365172, + "current_period_start": 1449686772, + "customer": "cus_7VDNEbpCO5sH6A", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNEbpCO5sH6A", + "subscription": "sub_7VDNQ6oukVnouu" + }, + "metadata": { + "id": "0000000000000000000186ba" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + } +] \ No newline at end of file diff --git a/spec/fixtures/sub-test-19.json b/spec/fixtures/sub-test-19.json new file mode 100644 index 000000000..77170deb1 --- /dev/null +++ b/spec/fixtures/sub-test-19.json @@ -0,0 +1,1291 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCxCKaReE7xLUdQSKb76Nv", + "card": { + "id": "card_17GCxCKaReE7xLUdtvT6QfQs" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDNSO9XbQEgBe", + "alipay_accounts": { + "has_more": false + }, + "email": "user127@me.com", + "metadata": { + "id": "0000000000000000000186bd" + }, + "sources": { + "data": [ + { + "id": "card_17GCxCKaReE7xLUdtvT6QfQs", + "customer": "cus_7VDNSO9XbQEgBe" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDNSO9XbQEgBe/subscriptions", + "status": 200, + "response": { + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDNSO9XbQEgBe", + "status": 200, + "response": { + "id": "cus_7VDNSO9XbQEgBe", + "alipay_accounts": { + "has_more": false + }, + "email": "user127@me.com", + "metadata": { + "id": "0000000000000000000186bd" + }, + "sources": { + "data": [ + { + "id": "card_17GCxCKaReE7xLUdtvT6QfQs", + "customer": "cus_7VDNSO9XbQEgBe" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDNSO9XbQEgBe/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDNFSXQ9g4sml", + "cancel_at_period_end": false, + "current_period_end": 1452365179, + "current_period_start": 1449686779, + "customer": "cus_7VDNSO9XbQEgBe", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNSO9XbQEgBe", + "subscription": "sub_7VDNFSXQ9g4sml" + }, + "metadata": { + "id": "0000000000000000000186bc" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDNSO9XbQEgBe", + "status": 200, + "response": { + "id": "cus_7VDNSO9XbQEgBe", + "alipay_accounts": { + "has_more": false + }, + "email": "user127@me.com", + "metadata": { + "id": "0000000000000000000186bd" + }, + "sources": { + "data": [ + { + "id": "card_17GCxCKaReE7xLUdtvT6QfQs", + "customer": "cus_7VDNSO9XbQEgBe" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDNFSXQ9g4sml", + "cancel_at_period_end": false, + "current_period_end": 1452365179, + "current_period_start": 1449686779, + "customer": "cus_7VDNSO9XbQEgBe", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNSO9XbQEgBe", + "subscription": "sub_7VDNFSXQ9g4sml" + }, + "metadata": { + "id": "0000000000000000000186bc" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDNSO9XbQEgBe/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDONaO5dMKvmZ", + "cancel_at_period_end": false, + "current_period_end": 1452365181, + "current_period_start": 1449686781, + "customer": "cus_7VDNSO9XbQEgBe", + "metadata": { + "id": "0000000000000000000186bd" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices", + "status": 200, + "response": { + "data": [ + { + "id": "in_17GCxFKaReE7xLUdAib5kobP", + "customer": "cus_7VDNSO9XbQEgBe", + "lines": { + "data": [ + { + "id": "sub_7VDONaO5dMKvmZ", + "amount": 999, + "metadata": { + "id": "0000000000000000000186bd" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 999, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDONaO5dMKvmZ", + "total": 999 + }, + { + "id": "in_17GCxDKaReE7xLUd6vwhouH3", + "customer": "cus_7VDNSO9XbQEgBe", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNSO9XbQEgBe", + "subscription": "sub_7VDNFSXQ9g4sml" + }, + "lines": { + "data": [ + { + "id": "sub_7VDNFSXQ9g4sml", + "amount": 999, + "metadata": { + "id": "0000000000000000000186bc" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDNFSXQ9g4sml", + "total": 0 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDNSO9XbQEgBe", + "status": 200, + "response": { + "id": "cus_7VDNSO9XbQEgBe", + "alipay_accounts": { + "has_more": false + }, + "email": "user127@me.com", + "metadata": { + "id": "0000000000000000000186bd" + }, + "sources": { + "data": [ + { + "id": "card_17GCxCKaReE7xLUdtvT6QfQs", + "customer": "cus_7VDNSO9XbQEgBe" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDONaO5dMKvmZ", + "cancel_at_period_end": false, + "current_period_end": 1452365181, + "current_period_start": 1449686781, + "customer": "cus_7VDNSO9XbQEgBe", + "metadata": { + "id": "0000000000000000000186bd" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDNFSXQ9g4sml", + "cancel_at_period_end": false, + "current_period_end": 1452365179, + "current_period_start": 1449686779, + "customer": "cus_7VDNSO9XbQEgBe", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNSO9XbQEgBe", + "subscription": "sub_7VDNFSXQ9g4sml" + }, + "metadata": { + "id": "0000000000000000000186bc" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCxFKaReE7xLUdAib5kobP", + "status": 200, + "response": { + "id": "in_17GCxFKaReE7xLUdAib5kobP", + "customer": "cus_7VDNSO9XbQEgBe", + "lines": { + "data": [ + { + "id": "sub_7VDONaO5dMKvmZ", + "amount": 999, + "metadata": { + "id": "0000000000000000000186bd" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 999, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDONaO5dMKvmZ", + "total": 999 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDNSO9XbQEgBe", + "status": 200, + "response": { + "id": "cus_7VDNSO9XbQEgBe", + "alipay_accounts": { + "has_more": false + }, + "email": "user127@me.com", + "metadata": { + "id": "0000000000000000000186bd" + }, + "sources": { + "data": [ + { + "id": "card_17GCxCKaReE7xLUdtvT6QfQs", + "customer": "cus_7VDNSO9XbQEgBe" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDONaO5dMKvmZ", + "cancel_at_period_end": false, + "current_period_end": 1452365181, + "current_period_start": 1449686781, + "customer": "cus_7VDNSO9XbQEgBe", + "metadata": { + "id": "0000000000000000000186bd" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDNFSXQ9g4sml", + "cancel_at_period_end": false, + "current_period_end": 1452365179, + "current_period_start": 1449686779, + "customer": "cus_7VDNSO9XbQEgBe", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNSO9XbQEgBe", + "subscription": "sub_7VDNFSXQ9g4sml" + }, + "metadata": { + "id": "0000000000000000000186bc" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDNSO9XbQEgBe", + "status": 200, + "response": { + "id": "cus_7VDNSO9XbQEgBe", + "alipay_accounts": { + "has_more": false + }, + "email": "user127@me.com", + "metadata": { + "id": "0000000000000000000186bd" + }, + "sources": { + "data": [ + { + "id": "card_17GCxCKaReE7xLUdtvT6QfQs", + "customer": "cus_7VDNSO9XbQEgBe" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDONaO5dMKvmZ", + "cancel_at_period_end": false, + "current_period_end": 1452365181, + "current_period_start": 1449686781, + "customer": "cus_7VDNSO9XbQEgBe", + "metadata": { + "id": "0000000000000000000186bd" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDNFSXQ9g4sml", + "cancel_at_period_end": false, + "current_period_end": 1452365179, + "current_period_start": 1449686779, + "customer": "cus_7VDNSO9XbQEgBe", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNSO9XbQEgBe", + "subscription": "sub_7VDNFSXQ9g4sml" + }, + "metadata": { + "id": "0000000000000000000186bc" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCxDKaReE7xLUd6vwhouH3", + "status": 200, + "response": { + "id": "in_17GCxDKaReE7xLUd6vwhouH3", + "customer": "cus_7VDNSO9XbQEgBe", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNSO9XbQEgBe", + "subscription": "sub_7VDNFSXQ9g4sml" + }, + "lines": { + "data": [ + { + "id": "sub_7VDNFSXQ9g4sml", + "amount": 999, + "metadata": { + "id": "0000000000000000000186bc" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDNFSXQ9g4sml", + "total": 0 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCxIKaReE7xLUdDzODKROr", + "card": { + "id": "card_17GCxIKaReE7xLUdoGw57NP6" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDOogGF1eEXu2", + "alipay_accounts": { + "has_more": false + }, + "email": "user126@foo.bar", + "metadata": { + "id": "0000000000000000000186bc" + }, + "sources": { + "data": [ + { + "id": "card_17GCxIKaReE7xLUdoGw57NP6", + "customer": "cus_7VDOogGF1eEXu2" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDOogGF1eEXu2/subscriptions", + "status": 200, + "response": { + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDOogGF1eEXu2", + "status": 200, + "response": { + "id": "cus_7VDOogGF1eEXu2", + "alipay_accounts": { + "has_more": false + }, + "email": "user126@foo.bar", + "metadata": { + "id": "0000000000000000000186bc" + }, + "sources": { + "data": [ + { + "id": "card_17GCxIKaReE7xLUdoGw57NP6", + "customer": "cus_7VDOogGF1eEXu2" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDOogGF1eEXu2/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDOtfIZw7GnCq", + "cancel_at_period_end": false, + "current_period_end": 1452365185, + "current_period_start": 1449686785, + "customer": "cus_7VDOogGF1eEXu2", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDOogGF1eEXu2", + "subscription": "sub_7VDOtfIZw7GnCq" + }, + "metadata": { + "id": "0000000000000000000186bd" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDNSO9XbQEgBe", + "status": 200, + "response": { + "id": "cus_7VDNSO9XbQEgBe", + "alipay_accounts": { + "has_more": false + }, + "email": "user127@me.com", + "metadata": { + "id": "0000000000000000000186bd" + }, + "sources": { + "data": [ + { + "id": "card_17GCxCKaReE7xLUdtvT6QfQs", + "customer": "cus_7VDNSO9XbQEgBe" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDONaO5dMKvmZ", + "cancel_at_period_end": false, + "current_period_end": 1452365181, + "current_period_start": 1449686781, + "customer": "cus_7VDNSO9XbQEgBe", + "metadata": { + "id": "0000000000000000000186bd" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDNFSXQ9g4sml", + "cancel_at_period_end": false, + "current_period_end": 1452365179, + "current_period_start": 1449686779, + "customer": "cus_7VDNSO9XbQEgBe", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNSO9XbQEgBe", + "subscription": "sub_7VDNFSXQ9g4sml" + }, + "metadata": { + "id": "0000000000000000000186bc" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDOogGF1eEXu2/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDOrzrCjmPlCD", + "cancel_at_period_end": false, + "current_period_end": 1452365186, + "current_period_start": 1449686786, + "customer": "cus_7VDOogGF1eEXu2", + "metadata": { + "id": "0000000000000000000186bc" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices", + "status": 200, + "response": { + "data": [ + { + "id": "in_17GCxKKaReE7xLUdTEFrlGVR", + "customer": "cus_7VDOogGF1eEXu2", + "lines": { + "data": [ + { + "id": "sub_7VDOrzrCjmPlCD", + "amount": 999, + "metadata": { + "id": "0000000000000000000186bc" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 999, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDOrzrCjmPlCD", + "total": 999 + }, + { + "id": "in_17GCxJKaReE7xLUdD1pIcGP4", + "customer": "cus_7VDOogGF1eEXu2", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDOogGF1eEXu2", + "subscription": "sub_7VDOtfIZw7GnCq" + }, + "lines": { + "data": [ + { + "id": "sub_7VDOtfIZw7GnCq", + "amount": 999, + "metadata": { + "id": "0000000000000000000186bd" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDOtfIZw7GnCq", + "total": 0 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDOogGF1eEXu2", + "status": 200, + "response": { + "id": "cus_7VDOogGF1eEXu2", + "alipay_accounts": { + "has_more": false + }, + "email": "user126@foo.bar", + "metadata": { + "id": "0000000000000000000186bc" + }, + "sources": { + "data": [ + { + "id": "card_17GCxIKaReE7xLUdoGw57NP6", + "customer": "cus_7VDOogGF1eEXu2" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDOrzrCjmPlCD", + "cancel_at_period_end": false, + "current_period_end": 1452365186, + "current_period_start": 1449686786, + "customer": "cus_7VDOogGF1eEXu2", + "metadata": { + "id": "0000000000000000000186bc" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDOtfIZw7GnCq", + "cancel_at_period_end": false, + "current_period_end": 1452365185, + "current_period_start": 1449686785, + "customer": "cus_7VDOogGF1eEXu2", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDOogGF1eEXu2", + "subscription": "sub_7VDOtfIZw7GnCq" + }, + "metadata": { + "id": "0000000000000000000186bd" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDOogGF1eEXu2", + "status": 200, + "response": { + "id": "cus_7VDOogGF1eEXu2", + "alipay_accounts": { + "has_more": false + }, + "email": "user126@foo.bar", + "metadata": { + "id": "0000000000000000000186bc" + }, + "sources": { + "data": [ + { + "id": "card_17GCxIKaReE7xLUdoGw57NP6", + "customer": "cus_7VDOogGF1eEXu2" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDOrzrCjmPlCD", + "cancel_at_period_end": false, + "current_period_end": 1452365186, + "current_period_start": 1449686786, + "customer": "cus_7VDOogGF1eEXu2", + "metadata": { + "id": "0000000000000000000186bc" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDOtfIZw7GnCq", + "cancel_at_period_end": false, + "current_period_end": 1452365185, + "current_period_start": 1449686785, + "customer": "cus_7VDOogGF1eEXu2", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDOogGF1eEXu2", + "subscription": "sub_7VDOtfIZw7GnCq" + }, + "metadata": { + "id": "0000000000000000000186bd" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDOogGF1eEXu2", + "status": 200, + "response": { + "id": "cus_7VDOogGF1eEXu2", + "alipay_accounts": { + "has_more": false + }, + "email": "user126@foo.bar", + "metadata": { + "id": "0000000000000000000186bc" + }, + "sources": { + "data": [ + { + "id": "card_17GCxIKaReE7xLUdoGw57NP6", + "customer": "cus_7VDOogGF1eEXu2" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDOrzrCjmPlCD", + "cancel_at_period_end": false, + "current_period_end": 1452365186, + "current_period_start": 1449686786, + "customer": "cus_7VDOogGF1eEXu2", + "metadata": { + "id": "0000000000000000000186bc" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDOtfIZw7GnCq", + "cancel_at_period_end": false, + "current_period_end": 1452365185, + "current_period_start": 1449686785, + "customer": "cus_7VDOogGF1eEXu2", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDOogGF1eEXu2", + "subscription": "sub_7VDOtfIZw7GnCq" + }, + "metadata": { + "id": "0000000000000000000186bd" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCxKKaReE7xLUdTEFrlGVR", + "status": 200, + "response": { + "id": "in_17GCxKKaReE7xLUdTEFrlGVR", + "customer": "cus_7VDOogGF1eEXu2", + "lines": { + "data": [ + { + "id": "sub_7VDOrzrCjmPlCD", + "amount": 999, + "metadata": { + "id": "0000000000000000000186bc" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 999, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDOrzrCjmPlCD", + "total": 999 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDOogGF1eEXu2", + "status": 200, + "response": { + "id": "cus_7VDOogGF1eEXu2", + "alipay_accounts": { + "has_more": false + }, + "email": "user126@foo.bar", + "metadata": { + "id": "0000000000000000000186bc" + }, + "sources": { + "data": [ + { + "id": "card_17GCxIKaReE7xLUdoGw57NP6", + "customer": "cus_7VDOogGF1eEXu2" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDOrzrCjmPlCD", + "cancel_at_period_end": false, + "current_period_end": 1452365186, + "current_period_start": 1449686786, + "customer": "cus_7VDOogGF1eEXu2", + "metadata": { + "id": "0000000000000000000186bc" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDOtfIZw7GnCq", + "cancel_at_period_end": false, + "current_period_end": 1452365185, + "current_period_start": 1449686785, + "customer": "cus_7VDOogGF1eEXu2", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDOogGF1eEXu2", + "subscription": "sub_7VDOtfIZw7GnCq" + }, + "metadata": { + "id": "0000000000000000000186bd" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCxJKaReE7xLUdD1pIcGP4", + "status": 200, + "response": { + "id": "in_17GCxJKaReE7xLUdD1pIcGP4", + "customer": "cus_7VDOogGF1eEXu2", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDOogGF1eEXu2", + "subscription": "sub_7VDOtfIZw7GnCq" + }, + "lines": { + "data": [ + { + "id": "sub_7VDOtfIZw7GnCq", + "amount": 999, + "metadata": { + "id": "0000000000000000000186bd" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDOtfIZw7GnCq", + "total": 0 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDNSO9XbQEgBe/subscriptions/sub_7VDONaO5dMKvmZ", + "status": 200, + "response": { + "id": "sub_7VDONaO5dMKvmZ", + "cancel_at_period_end": false, + "current_period_end": 1452365181, + "current_period_start": 1449686781, + "customer": "cus_7VDNSO9XbQEgBe", + "metadata": { + "id": "0000000000000000000186bd" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDNSO9XbQEgBe", + "status": 200, + "response": { + "id": "cus_7VDNSO9XbQEgBe", + "alipay_accounts": { + "has_more": false + }, + "email": "user127@me.com", + "metadata": { + "id": "0000000000000000000186bd" + }, + "sources": { + "data": [ + { + "id": "card_17GCxCKaReE7xLUdtvT6QfQs", + "customer": "cus_7VDNSO9XbQEgBe" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDONaO5dMKvmZ", + "cancel_at_period_end": false, + "current_period_end": 1452365181, + "current_period_start": 1449686781, + "customer": "cus_7VDNSO9XbQEgBe", + "metadata": { + "id": "0000000000000000000186bd" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDNFSXQ9g4sml", + "cancel_at_period_end": false, + "current_period_end": 1452365179, + "current_period_start": 1449686779, + "customer": "cus_7VDNSO9XbQEgBe", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNSO9XbQEgBe", + "subscription": "sub_7VDNFSXQ9g4sml" + }, + "metadata": { + "id": "0000000000000000000186bc" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDNSO9XbQEgBe/subscriptions/sub_7VDNFSXQ9g4sml", + "status": 200, + "response": { + "id": "sub_7VDNFSXQ9g4sml", + "cancel_at_period_end": false, + "current_period_end": 1452365179, + "current_period_start": 1449686779, + "customer": "cus_7VDNSO9XbQEgBe", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDNSO9XbQEgBe", + "subscription": "sub_7VDNFSXQ9g4sml" + }, + "metadata": { + "id": "0000000000000000000186bc" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDOogGF1eEXu2/subscriptions/sub_7VDOrzrCjmPlCD", + "status": 200, + "response": { + "id": "sub_7VDOrzrCjmPlCD", + "cancel_at_period_end": false, + "current_period_end": 1452365186, + "current_period_start": 1449686786, + "customer": "cus_7VDOogGF1eEXu2", + "metadata": { + "id": "0000000000000000000186bc" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDOogGF1eEXu2/subscriptions/sub_7VDOtfIZw7GnCq", + "status": 200, + "response": { + "id": "sub_7VDOtfIZw7GnCq", + "cancel_at_period_end": false, + "current_period_end": 1452365185, + "current_period_start": 1449686785, + "customer": "cus_7VDOogGF1eEXu2", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDOogGF1eEXu2", + "subscription": "sub_7VDOtfIZw7GnCq" + }, + "metadata": { + "id": "0000000000000000000186bd" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + } +] \ No newline at end of file diff --git a/spec/fixtures/sub-test-20.json b/spec/fixtures/sub-test-20.json new file mode 100644 index 000000000..d26971d96 --- /dev/null +++ b/spec/fixtures/sub-test-20.json @@ -0,0 +1,120 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCxPKaReE7xLUdw5hQd1LV", + "card": { + "id": "card_17GCxPKaReE7xLUdYtxlCRp7" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDO9FZp6WdhaH", + "alipay_accounts": { + "has_more": false + }, + "email": "user128@me.com", + "metadata": { + "id": "0000000000000000000186be" + }, + "sources": { + "data": [ + { + "id": "card_17GCxPKaReE7xLUdYtxlCRp7", + "customer": "cus_7VDO9FZp6WdhaH" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDO9FZp6WdhaH", + "status": 200, + "response": { + "id": "cus_7VDO9FZp6WdhaH", + "alipay_accounts": { + "has_more": false + }, + "email": "user128@me.com", + "metadata": { + "id": "0000000000000000000186be" + }, + "sources": { + "data": [ + { + "id": "card_17GCxPKaReE7xLUdYtxlCRp7", + "customer": "cus_7VDO9FZp6WdhaH" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDO9FZp6WdhaH", + "status": 200, + "response": { + "id": "cus_7VDO9FZp6WdhaH", + "alipay_accounts": { + "has_more": false + }, + "email": "user128@me.com", + "metadata": { + "id": "0000000000000000000186be" + }, + "sources": { + "data": [ + { + "id": "card_17GCxPKaReE7xLUdYtxlCRp7", + "customer": "cus_7VDO9FZp6WdhaH" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDO9FZp6WdhaH/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDO0MXZq3cp9c", + "cancel_at_period_end": false, + "current_period_end": 1452365193, + "current_period_start": 1449686793, + "customer": "cus_7VDO9FZp6WdhaH", + "metadata": { + "id": "0000000000000000000186be" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 0 + } + } +] \ No newline at end of file diff --git a/spec/fixtures/sub-test-21.json b/spec/fixtures/sub-test-21.json new file mode 100644 index 000000000..a5dd462eb --- /dev/null +++ b/spec/fixtures/sub-test-21.json @@ -0,0 +1,1014 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCxSKaReE7xLUdaKID0NbQ", + "card": { + "id": "card_17GCxSKaReE7xLUdTQRuQx6H" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDOSnaw20wvA3", + "alipay_accounts": { + "has_more": false + }, + "email": "user130@me.com", + "metadata": { + "id": "0000000000000000000186c0" + }, + "sources": { + "data": [ + { + "id": "card_17GCxSKaReE7xLUdTQRuQx6H", + "customer": "cus_7VDOSnaw20wvA3" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDOSnaw20wvA3", + "status": 200, + "response": { + "id": "cus_7VDOSnaw20wvA3", + "alipay_accounts": { + "has_more": false + }, + "email": "user130@me.com", + "metadata": { + "id": "0000000000000000000186c0" + }, + "sources": { + "data": [ + { + "id": "card_17GCxSKaReE7xLUdTQRuQx6H", + "customer": "cus_7VDOSnaw20wvA3" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDOSnaw20wvA3/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDOrDIjWzpnYf", + "cancel_at_period_end": false, + "current_period_end": 1452365196, + "current_period_start": 1449686796, + "customer": "cus_7VDOSnaw20wvA3", + "metadata": { + "id": "0000000000000000000186c0" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDOSnaw20wvA3", + "status": 200, + "response": { + "id": "cus_7VDOSnaw20wvA3", + "alipay_accounts": { + "has_more": false + }, + "email": "user130@me.com", + "metadata": { + "id": "0000000000000000000186c0" + }, + "sources": { + "data": [ + { + "id": "card_17GCxSKaReE7xLUdTQRuQx6H", + "customer": "cus_7VDOSnaw20wvA3" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDOrDIjWzpnYf", + "cancel_at_period_end": false, + "current_period_end": 1452365196, + "current_period_start": 1449686796, + "customer": "cus_7VDOSnaw20wvA3", + "metadata": { + "id": "0000000000000000000186c0" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDOSnaw20wvA3", + "status": 200, + "response": { + "id": "cus_7VDOSnaw20wvA3", + "alipay_accounts": { + "has_more": false + }, + "email": "user130@me.com", + "metadata": { + "id": "0000000000000000000186c0" + }, + "sources": { + "data": [ + { + "id": "card_17GCxSKaReE7xLUdTQRuQx6H", + "customer": "cus_7VDOSnaw20wvA3" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDOrDIjWzpnYf", + "cancel_at_period_end": false, + "current_period_end": 1452365196, + "current_period_start": 1449686796, + "customer": "cus_7VDOSnaw20wvA3", + "metadata": { + "id": "0000000000000000000186c0" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDOSnaw20wvA3", + "status": 200, + "response": { + "id": "cus_7VDOSnaw20wvA3", + "alipay_accounts": { + "has_more": false + }, + "email": "user130@me.com", + "metadata": { + "id": "0000000000000000000186c0" + }, + "sources": { + "data": [ + { + "id": "card_17GCxSKaReE7xLUdTQRuQx6H", + "customer": "cus_7VDOSnaw20wvA3" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDOrDIjWzpnYf", + "cancel_at_period_end": false, + "current_period_end": 1452365196, + "current_period_start": 1449686796, + "customer": "cus_7VDOSnaw20wvA3", + "metadata": { + "id": "0000000000000000000186c0" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDOSnaw20wvA3/subscriptions", + "status": 200, + "response": { + "data": [ + { + "id": "sub_7VDOrDIjWzpnYf", + "cancel_at_period_end": false, + "current_period_end": 1452365196, + "current_period_start": 1449686796, + "customer": "cus_7VDOSnaw20wvA3", + "metadata": { + "id": "0000000000000000000186c0" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDOSnaw20wvA3/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDObbSKrP0na6", + "cancel_at_period_end": false, + "current_period_end": 1452365198, + "current_period_start": 1449686798, + "customer": "cus_7VDOSnaw20wvA3", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDOSnaw20wvA3", + "subscription": "sub_7VDObbSKrP0na6" + }, + "metadata": { + "id": "0000000000000000000186bf" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDOSnaw20wvA3", + "status": 200, + "response": { + "id": "cus_7VDOSnaw20wvA3", + "alipay_accounts": { + "has_more": false + }, + "email": "user130@me.com", + "metadata": { + "id": "0000000000000000000186c0" + }, + "sources": { + "data": [ + { + "id": "card_17GCxSKaReE7xLUdTQRuQx6H", + "customer": "cus_7VDOSnaw20wvA3" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDObbSKrP0na6", + "cancel_at_period_end": false, + "current_period_end": 1452365198, + "current_period_start": 1449686798, + "customer": "cus_7VDOSnaw20wvA3", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDOSnaw20wvA3", + "subscription": "sub_7VDObbSKrP0na6" + }, + "metadata": { + "id": "0000000000000000000186bf" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDOrDIjWzpnYf", + "cancel_at_period_end": false, + "current_period_end": 1452365196, + "current_period_start": 1449686796, + "customer": "cus_7VDOSnaw20wvA3", + "metadata": { + "id": "0000000000000000000186c0" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDOSnaw20wvA3/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDOg6XvP1MgHW", + "cancel_at_period_end": false, + "current_period_end": 1452365200, + "current_period_start": 1449686800, + "customer": "cus_7VDOSnaw20wvA3", + "metadata": { + "id": "0000000000000000000186c0" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 799 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices", + "status": 200, + "response": { + "data": [ + { + "id": "in_17GCxYKaReE7xLUd5CrgBAiB", + "customer": "cus_7VDOSnaw20wvA3", + "lines": { + "data": [ + { + "id": "sub_7VDOg6XvP1MgHW", + "amount": 799, + "metadata": { + "id": "0000000000000000000186c0" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 799, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDOg6XvP1MgHW", + "total": 799 + }, + { + "id": "in_17GCxWKaReE7xLUdNJVTUklc", + "customer": "cus_7VDOSnaw20wvA3", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDOSnaw20wvA3", + "subscription": "sub_7VDObbSKrP0na6" + }, + "lines": { + "data": [ + { + "id": "sub_7VDObbSKrP0na6", + "amount": 999, + "metadata": { + "id": "0000000000000000000186bf" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDObbSKrP0na6", + "total": 0 + }, + { + "id": "in_17GCxUKaReE7xLUdYb801cDu", + "customer": "cus_7VDOSnaw20wvA3", + "lines": { + "data": [ + { + "id": "sub_7VDOrDIjWzpnYf", + "amount": 999, + "metadata": { + "id": "0000000000000000000186c0" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDOrDIjWzpnYf", + "total": 999 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDOSnaw20wvA3", + "status": 200, + "response": { + "id": "cus_7VDOSnaw20wvA3", + "alipay_accounts": { + "has_more": false + }, + "email": "user130@me.com", + "metadata": { + "id": "0000000000000000000186c0" + }, + "sources": { + "data": [ + { + "id": "card_17GCxSKaReE7xLUdTQRuQx6H", + "customer": "cus_7VDOSnaw20wvA3" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDOg6XvP1MgHW", + "cancel_at_period_end": false, + "current_period_end": 1452365200, + "current_period_start": 1449686800, + "customer": "cus_7VDOSnaw20wvA3", + "metadata": { + "id": "0000000000000000000186c0" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 799 + }, + { + "id": "sub_7VDObbSKrP0na6", + "cancel_at_period_end": false, + "current_period_end": 1452365198, + "current_period_start": 1449686798, + "customer": "cus_7VDOSnaw20wvA3", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDOSnaw20wvA3", + "subscription": "sub_7VDObbSKrP0na6" + }, + "metadata": { + "id": "0000000000000000000186bf" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDOrDIjWzpnYf", + "cancel_at_period_end": false, + "current_period_end": 1452365196, + "current_period_start": 1449686796, + "customer": "cus_7VDOSnaw20wvA3", + "metadata": { + "id": "0000000000000000000186c0" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDOSnaw20wvA3", + "status": 200, + "response": { + "id": "cus_7VDOSnaw20wvA3", + "alipay_accounts": { + "has_more": false + }, + "email": "user130@me.com", + "metadata": { + "id": "0000000000000000000186c0" + }, + "sources": { + "data": [ + { + "id": "card_17GCxSKaReE7xLUdTQRuQx6H", + "customer": "cus_7VDOSnaw20wvA3" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDOg6XvP1MgHW", + "cancel_at_period_end": false, + "current_period_end": 1452365200, + "current_period_start": 1449686800, + "customer": "cus_7VDOSnaw20wvA3", + "metadata": { + "id": "0000000000000000000186c0" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 799 + }, + { + "id": "sub_7VDObbSKrP0na6", + "cancel_at_period_end": false, + "current_period_end": 1452365198, + "current_period_start": 1449686798, + "customer": "cus_7VDOSnaw20wvA3", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDOSnaw20wvA3", + "subscription": "sub_7VDObbSKrP0na6" + }, + "metadata": { + "id": "0000000000000000000186bf" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDOrDIjWzpnYf", + "cancel_at_period_end": false, + "current_period_end": 1452365196, + "current_period_start": 1449686796, + "customer": "cus_7VDOSnaw20wvA3", + "metadata": { + "id": "0000000000000000000186c0" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCxYKaReE7xLUd5CrgBAiB", + "status": 200, + "response": { + "id": "in_17GCxYKaReE7xLUd5CrgBAiB", + "customer": "cus_7VDOSnaw20wvA3", + "lines": { + "data": [ + { + "id": "sub_7VDOg6XvP1MgHW", + "amount": 799, + "metadata": { + "id": "0000000000000000000186c0" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 799, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDOg6XvP1MgHW", + "total": 799 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDOSnaw20wvA3", + "status": 200, + "response": { + "id": "cus_7VDOSnaw20wvA3", + "alipay_accounts": { + "has_more": false + }, + "email": "user130@me.com", + "metadata": { + "id": "0000000000000000000186c0" + }, + "sources": { + "data": [ + { + "id": "card_17GCxSKaReE7xLUdTQRuQx6H", + "customer": "cus_7VDOSnaw20wvA3" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDOg6XvP1MgHW", + "cancel_at_period_end": false, + "current_period_end": 1452365200, + "current_period_start": 1449686800, + "customer": "cus_7VDOSnaw20wvA3", + "metadata": { + "id": "0000000000000000000186c0" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 799 + }, + { + "id": "sub_7VDObbSKrP0na6", + "cancel_at_period_end": false, + "current_period_end": 1452365198, + "current_period_start": 1449686798, + "customer": "cus_7VDOSnaw20wvA3", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDOSnaw20wvA3", + "subscription": "sub_7VDObbSKrP0na6" + }, + "metadata": { + "id": "0000000000000000000186bf" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDOrDIjWzpnYf", + "cancel_at_period_end": false, + "current_period_end": 1452365196, + "current_period_start": 1449686796, + "customer": "cus_7VDOSnaw20wvA3", + "metadata": { + "id": "0000000000000000000186c0" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCxWKaReE7xLUdNJVTUklc", + "status": 200, + "response": { + "id": "in_17GCxWKaReE7xLUdNJVTUklc", + "customer": "cus_7VDOSnaw20wvA3", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDOSnaw20wvA3", + "subscription": "sub_7VDObbSKrP0na6" + }, + "lines": { + "data": [ + { + "id": "sub_7VDObbSKrP0na6", + "amount": 999, + "metadata": { + "id": "0000000000000000000186bf" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDObbSKrP0na6", + "total": 0 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCxUKaReE7xLUdYb801cDu", + "status": 200, + "response": { + "id": "in_17GCxUKaReE7xLUdYb801cDu", + "customer": "cus_7VDOSnaw20wvA3", + "lines": { + "data": [ + { + "id": "sub_7VDOrDIjWzpnYf", + "amount": 999, + "metadata": { + "id": "0000000000000000000186c0" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDOrDIjWzpnYf", + "total": 999 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDOSnaw20wvA3/subscriptions/sub_7VDObbSKrP0na6", + "status": 200, + "response": { + "id": "sub_7VDObbSKrP0na6", + "cancel_at_period_end": false, + "current_period_end": 1452365198, + "current_period_start": 1449686798, + "customer": "cus_7VDOSnaw20wvA3", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDOSnaw20wvA3", + "subscription": "sub_7VDObbSKrP0na6" + }, + "metadata": { + "id": "0000000000000000000186bf" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDOSnaw20wvA3", + "status": 200, + "response": { + "id": "cus_7VDOSnaw20wvA3", + "alipay_accounts": { + "has_more": false + }, + "email": "user130@me.com", + "metadata": { + "id": "0000000000000000000186c0" + }, + "sources": { + "data": [ + { + "id": "card_17GCxSKaReE7xLUdTQRuQx6H", + "customer": "cus_7VDOSnaw20wvA3" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDOg6XvP1MgHW", + "cancel_at_period_end": false, + "current_period_end": 1452365200, + "current_period_start": 1449686800, + "customer": "cus_7VDOSnaw20wvA3", + "metadata": { + "id": "0000000000000000000186c0" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 799 + }, + { + "id": "sub_7VDObbSKrP0na6", + "cancel_at_period_end": false, + "current_period_end": 1452365198, + "current_period_start": 1449686798, + "customer": "cus_7VDOSnaw20wvA3", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDOSnaw20wvA3", + "subscription": "sub_7VDObbSKrP0na6" + }, + "metadata": { + "id": "0000000000000000000186bf" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDOrDIjWzpnYf", + "cancel_at_period_end": false, + "current_period_end": 1452365196, + "current_period_start": 1449686796, + "customer": "cus_7VDOSnaw20wvA3", + "metadata": { + "id": "0000000000000000000186c0" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "DELETE", + "path": "/v1/customers/cus_7VDOSnaw20wvA3/subscriptions/sub_7VDObbSKrP0na6", + "status": 200, + "response": { + "id": "sub_7VDObbSKrP0na6", + "cancel_at_period_end": false, + "current_period_end": 1452365198, + "current_period_start": 1449686798, + "customer": "cus_7VDOSnaw20wvA3", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDOSnaw20wvA3", + "subscription": "sub_7VDObbSKrP0na6" + }, + "metadata": { + "id": "0000000000000000000186bf" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDOSnaw20wvA3/subscriptions/sub_7VDOg6XvP1MgHW", + "status": 200, + "response": { + "id": "sub_7VDOg6XvP1MgHW", + "cancel_at_period_end": false, + "current_period_end": 1452365200, + "current_period_start": 1449686800, + "customer": "cus_7VDOSnaw20wvA3", + "metadata": { + "id": "0000000000000000000186c0" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 0 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDOSnaw20wvA3/subscriptions", + "status": 200, + "response": { + "data": [ + { + "id": "sub_7VDOg6XvP1MgHW", + "cancel_at_period_end": false, + "current_period_end": 1452365200, + "current_period_start": 1449686800, + "customer": "cus_7VDOSnaw20wvA3", + "metadata": { + "id": "0000000000000000000186c0" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 0 + }, + { + "id": "sub_7VDOrDIjWzpnYf", + "cancel_at_period_end": false, + "current_period_end": 1452365196, + "current_period_start": 1449686796, + "customer": "cus_7VDOSnaw20wvA3", + "metadata": { + "id": "0000000000000000000186c0" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } +] \ No newline at end of file diff --git a/spec/fixtures/sub-test-22.json b/spec/fixtures/sub-test-22.json new file mode 100644 index 000000000..db4b28bae --- /dev/null +++ b/spec/fixtures/sub-test-22.json @@ -0,0 +1,1151 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCxgKaReE7xLUdej24ioXL", + "card": { + "id": "card_17GCxgKaReE7xLUdKVqLosSk" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDO6Xjdz3Jc8z", + "alipay_accounts": { + "has_more": false + }, + "email": "user132@me.com", + "metadata": { + "id": "0000000000000000000186c2" + }, + "sources": { + "data": [ + { + "id": "card_17GCxgKaReE7xLUdKVqLosSk", + "customer": "cus_7VDO6Xjdz3Jc8z" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDO6Xjdz3Jc8z", + "status": 200, + "response": { + "id": "cus_7VDO6Xjdz3Jc8z", + "alipay_accounts": { + "has_more": false + }, + "email": "user132@me.com", + "metadata": { + "id": "0000000000000000000186c2" + }, + "sources": { + "data": [ + { + "id": "card_17GCxgKaReE7xLUdKVqLosSk", + "customer": "cus_7VDO6Xjdz3Jc8z" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDO6Xjdz3Jc8z/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDOvquFDIoefy", + "cancel_at_period_end": false, + "current_period_end": 1452365209, + "current_period_start": 1449686809, + "customer": "cus_7VDO6Xjdz3Jc8z", + "metadata": { + "id": "0000000000000000000186c2" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDO6Xjdz3Jc8z", + "status": 200, + "response": { + "id": "cus_7VDO6Xjdz3Jc8z", + "alipay_accounts": { + "has_more": false + }, + "email": "user132@me.com", + "metadata": { + "id": "0000000000000000000186c2" + }, + "sources": { + "data": [ + { + "id": "card_17GCxgKaReE7xLUdKVqLosSk", + "customer": "cus_7VDO6Xjdz3Jc8z" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDOvquFDIoefy", + "cancel_at_period_end": false, + "current_period_end": 1452365209, + "current_period_start": 1449686809, + "customer": "cus_7VDO6Xjdz3Jc8z", + "metadata": { + "id": "0000000000000000000186c2" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDO6Xjdz3Jc8z", + "status": 200, + "response": { + "id": "cus_7VDO6Xjdz3Jc8z", + "alipay_accounts": { + "has_more": false + }, + "email": "user132@me.com", + "metadata": { + "id": "0000000000000000000186c2" + }, + "sources": { + "data": [ + { + "id": "card_17GCxgKaReE7xLUdKVqLosSk", + "customer": "cus_7VDO6Xjdz3Jc8z" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDOvquFDIoefy", + "cancel_at_period_end": false, + "current_period_end": 1452365209, + "current_period_start": 1449686809, + "customer": "cus_7VDO6Xjdz3Jc8z", + "metadata": { + "id": "0000000000000000000186c2" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDO6Xjdz3Jc8z/subscriptions", + "status": 200, + "response": { + "data": [ + { + "id": "sub_7VDOvquFDIoefy", + "cancel_at_period_end": false, + "current_period_end": 1452365209, + "current_period_start": 1449686809, + "customer": "cus_7VDO6Xjdz3Jc8z", + "metadata": { + "id": "0000000000000000000186c2" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDO6Xjdz3Jc8z", + "status": 200, + "response": { + "id": "cus_7VDO6Xjdz3Jc8z", + "alipay_accounts": { + "has_more": false + }, + "email": "user132@me.com", + "metadata": { + "id": "0000000000000000000186c2" + }, + "sources": { + "data": [ + { + "id": "card_17GCxgKaReE7xLUdKVqLosSk", + "customer": "cus_7VDO6Xjdz3Jc8z" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDOvquFDIoefy", + "cancel_at_period_end": false, + "current_period_end": 1452365209, + "current_period_start": 1449686809, + "customer": "cus_7VDO6Xjdz3Jc8z", + "metadata": { + "id": "0000000000000000000186c2" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDO6Xjdz3Jc8z/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDOhgNQVi8nqk", + "cancel_at_period_end": false, + "current_period_end": 1452365211, + "current_period_start": 1449686811, + "customer": "cus_7VDO6Xjdz3Jc8z", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDO6Xjdz3Jc8z", + "subscription": "sub_7VDOhgNQVi8nqk" + }, + "metadata": { + "id": "0000000000000000000186c1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDO6Xjdz3Jc8z/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDOtuoXfZjxqR", + "cancel_at_period_end": false, + "current_period_end": 1452365213, + "current_period_start": 1449686813, + "customer": "cus_7VDO6Xjdz3Jc8z", + "metadata": { + "id": "0000000000000000000186c2" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 799 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices", + "status": 200, + "response": { + "data": [ + { + "id": "in_17GCxlKaReE7xLUdw3fG5lv1", + "customer": "cus_7VDO6Xjdz3Jc8z", + "lines": { + "data": [ + { + "id": "sub_7VDOtuoXfZjxqR", + "amount": 799, + "metadata": { + "id": "0000000000000000000186c2" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 799, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDOtuoXfZjxqR", + "total": 799 + }, + { + "id": "in_17GCxjKaReE7xLUdGGPyBy7K", + "customer": "cus_7VDO6Xjdz3Jc8z", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDO6Xjdz3Jc8z", + "subscription": "sub_7VDOhgNQVi8nqk" + }, + "lines": { + "data": [ + { + "id": "sub_7VDOhgNQVi8nqk", + "amount": 999, + "metadata": { + "id": "0000000000000000000186c1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDOhgNQVi8nqk", + "total": 0 + }, + { + "id": "in_17GCxhKaReE7xLUdldrUK2ns", + "customer": "cus_7VDO6Xjdz3Jc8z", + "lines": { + "data": [ + { + "id": "sub_7VDOvquFDIoefy", + "amount": 999, + "metadata": { + "id": "0000000000000000000186c2" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDOvquFDIoefy", + "total": 999 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDO6Xjdz3Jc8z", + "status": 200, + "response": { + "id": "cus_7VDO6Xjdz3Jc8z", + "alipay_accounts": { + "has_more": false + }, + "email": "user132@me.com", + "metadata": { + "id": "0000000000000000000186c2" + }, + "sources": { + "data": [ + { + "id": "card_17GCxgKaReE7xLUdKVqLosSk", + "customer": "cus_7VDO6Xjdz3Jc8z" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDOtuoXfZjxqR", + "cancel_at_period_end": false, + "current_period_end": 1452365213, + "current_period_start": 1449686813, + "customer": "cus_7VDO6Xjdz3Jc8z", + "metadata": { + "id": "0000000000000000000186c2" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 799 + }, + { + "id": "sub_7VDOhgNQVi8nqk", + "cancel_at_period_end": false, + "current_period_end": 1452365211, + "current_period_start": 1449686811, + "customer": "cus_7VDO6Xjdz3Jc8z", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDO6Xjdz3Jc8z", + "subscription": "sub_7VDOhgNQVi8nqk" + }, + "metadata": { + "id": "0000000000000000000186c1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDOvquFDIoefy", + "cancel_at_period_end": false, + "current_period_end": 1452365209, + "current_period_start": 1449686809, + "customer": "cus_7VDO6Xjdz3Jc8z", + "metadata": { + "id": "0000000000000000000186c2" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCxlKaReE7xLUdw3fG5lv1", + "status": 200, + "response": { + "id": "in_17GCxlKaReE7xLUdw3fG5lv1", + "customer": "cus_7VDO6Xjdz3Jc8z", + "lines": { + "data": [ + { + "id": "sub_7VDOtuoXfZjxqR", + "amount": 799, + "metadata": { + "id": "0000000000000000000186c2" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 799, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDOtuoXfZjxqR", + "total": 799 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDO6Xjdz3Jc8z", + "status": 200, + "response": { + "id": "cus_7VDO6Xjdz3Jc8z", + "alipay_accounts": { + "has_more": false + }, + "email": "user132@me.com", + "metadata": { + "id": "0000000000000000000186c2" + }, + "sources": { + "data": [ + { + "id": "card_17GCxgKaReE7xLUdKVqLosSk", + "customer": "cus_7VDO6Xjdz3Jc8z" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDOtuoXfZjxqR", + "cancel_at_period_end": false, + "current_period_end": 1452365213, + "current_period_start": 1449686813, + "customer": "cus_7VDO6Xjdz3Jc8z", + "metadata": { + "id": "0000000000000000000186c2" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 799 + }, + { + "id": "sub_7VDOhgNQVi8nqk", + "cancel_at_period_end": false, + "current_period_end": 1452365211, + "current_period_start": 1449686811, + "customer": "cus_7VDO6Xjdz3Jc8z", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDO6Xjdz3Jc8z", + "subscription": "sub_7VDOhgNQVi8nqk" + }, + "metadata": { + "id": "0000000000000000000186c1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDOvquFDIoefy", + "cancel_at_period_end": false, + "current_period_end": 1452365209, + "current_period_start": 1449686809, + "customer": "cus_7VDO6Xjdz3Jc8z", + "metadata": { + "id": "0000000000000000000186c2" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDO6Xjdz3Jc8z", + "status": 200, + "response": { + "id": "cus_7VDO6Xjdz3Jc8z", + "alipay_accounts": { + "has_more": false + }, + "email": "user132@me.com", + "metadata": { + "id": "0000000000000000000186c2" + }, + "sources": { + "data": [ + { + "id": "card_17GCxgKaReE7xLUdKVqLosSk", + "customer": "cus_7VDO6Xjdz3Jc8z" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDOtuoXfZjxqR", + "cancel_at_period_end": false, + "current_period_end": 1452365213, + "current_period_start": 1449686813, + "customer": "cus_7VDO6Xjdz3Jc8z", + "metadata": { + "id": "0000000000000000000186c2" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 799 + }, + { + "id": "sub_7VDOhgNQVi8nqk", + "cancel_at_period_end": false, + "current_period_end": 1452365211, + "current_period_start": 1449686811, + "customer": "cus_7VDO6Xjdz3Jc8z", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDO6Xjdz3Jc8z", + "subscription": "sub_7VDOhgNQVi8nqk" + }, + "metadata": { + "id": "0000000000000000000186c1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDOvquFDIoefy", + "cancel_at_period_end": false, + "current_period_end": 1452365209, + "current_period_start": 1449686809, + "customer": "cus_7VDO6Xjdz3Jc8z", + "metadata": { + "id": "0000000000000000000186c2" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCxjKaReE7xLUdGGPyBy7K", + "status": 200, + "response": { + "id": "in_17GCxjKaReE7xLUdGGPyBy7K", + "customer": "cus_7VDO6Xjdz3Jc8z", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDO6Xjdz3Jc8z", + "subscription": "sub_7VDOhgNQVi8nqk" + }, + "lines": { + "data": [ + { + "id": "sub_7VDOhgNQVi8nqk", + "amount": 999, + "metadata": { + "id": "0000000000000000000186c1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDOhgNQVi8nqk", + "total": 0 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCxhKaReE7xLUdldrUK2ns", + "status": 200, + "response": { + "id": "in_17GCxhKaReE7xLUdldrUK2ns", + "customer": "cus_7VDO6Xjdz3Jc8z", + "lines": { + "data": [ + { + "id": "sub_7VDOvquFDIoefy", + "amount": 999, + "metadata": { + "id": "0000000000000000000186c2" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDOvquFDIoefy", + "total": 999 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDO6Xjdz3Jc8z", + "status": 200, + "response": { + "id": "cus_7VDO6Xjdz3Jc8z", + "alipay_accounts": { + "has_more": false + }, + "email": "user132@me.com", + "metadata": { + "id": "0000000000000000000186c2" + }, + "sources": { + "data": [ + { + "id": "card_17GCxgKaReE7xLUdKVqLosSk", + "customer": "cus_7VDO6Xjdz3Jc8z" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDOtuoXfZjxqR", + "cancel_at_period_end": false, + "current_period_end": 1452365213, + "current_period_start": 1449686813, + "customer": "cus_7VDO6Xjdz3Jc8z", + "metadata": { + "id": "0000000000000000000186c2" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 799 + }, + { + "id": "sub_7VDOhgNQVi8nqk", + "cancel_at_period_end": false, + "current_period_end": 1452365211, + "current_period_start": 1449686811, + "customer": "cus_7VDO6Xjdz3Jc8z", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDO6Xjdz3Jc8z", + "subscription": "sub_7VDOhgNQVi8nqk" + }, + "metadata": { + "id": "0000000000000000000186c1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDOvquFDIoefy", + "cancel_at_period_end": false, + "current_period_end": 1452365209, + "current_period_start": 1449686809, + "customer": "cus_7VDO6Xjdz3Jc8z", + "metadata": { + "id": "0000000000000000000186c2" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDO6Xjdz3Jc8z", + "status": 200, + "response": { + "id": "cus_7VDO6Xjdz3Jc8z", + "alipay_accounts": { + "has_more": false + }, + "email": "user132@me.com", + "metadata": { + "id": "0000000000000000000186c2" + }, + "sources": { + "data": [ + { + "id": "card_17GCxgKaReE7xLUdKVqLosSk", + "customer": "cus_7VDO6Xjdz3Jc8z" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDOhgNQVi8nqk", + "cancel_at_period_end": false, + "current_period_end": 1452365211, + "current_period_start": 1449686811, + "customer": "cus_7VDO6Xjdz3Jc8z", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDO6Xjdz3Jc8z", + "subscription": "sub_7VDOhgNQVi8nqk" + }, + "metadata": { + "id": "0000000000000000000186c1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDOvquFDIoefy", + "cancel_at_period_end": false, + "current_period_end": 1452365209, + "current_period_start": 1449686809, + "customer": "cus_7VDO6Xjdz3Jc8z", + "metadata": { + "id": "0000000000000000000186c2" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "DELETE", + "path": "/v1/customers/cus_7VDO6Xjdz3Jc8z/subscriptions/sub_7VDOvquFDIoefy", + "status": 200, + "response": { + "id": "sub_7VDOvquFDIoefy", + "cancel_at_period_end": true, + "current_period_end": 1452365209, + "current_period_start": 1449686809, + "customer": "cus_7VDO6Xjdz3Jc8z", + "metadata": { + "id": "0000000000000000000186c2" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDO6Xjdz3Jc8z", + "status": 200, + "response": { + "id": "cus_7VDO6Xjdz3Jc8z", + "alipay_accounts": { + "has_more": false + }, + "email": "user132@me.com", + "metadata": { + "id": "0000000000000000000186c2" + }, + "sources": { + "data": [ + { + "id": "card_17GCxgKaReE7xLUdKVqLosSk", + "customer": "cus_7VDO6Xjdz3Jc8z" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDOtuoXfZjxqR", + "cancel_at_period_end": false, + "current_period_end": 1452365213, + "current_period_start": 1449686813, + "customer": "cus_7VDO6Xjdz3Jc8z", + "metadata": { + "id": "0000000000000000000186c2" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 799 + }, + { + "id": "sub_7VDOhgNQVi8nqk", + "cancel_at_period_end": false, + "current_period_end": 1452365211, + "current_period_start": 1449686811, + "customer": "cus_7VDO6Xjdz3Jc8z", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDO6Xjdz3Jc8z", + "subscription": "sub_7VDOhgNQVi8nqk" + }, + "metadata": { + "id": "0000000000000000000186c1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDOvquFDIoefy", + "cancel_at_period_end": true, + "current_period_end": 1452365209, + "current_period_start": 1449686809, + "customer": "cus_7VDO6Xjdz3Jc8z", + "metadata": { + "id": "0000000000000000000186c2" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDO6Xjdz3Jc8z/subscriptions/sub_7VDOvquFDIoefy", + "status": 200, + "response": { + "id": "sub_7VDOvquFDIoefy", + "cancel_at_period_end": true, + "current_period_end": 1452365209, + "current_period_start": 1449686809, + "customer": "cus_7VDO6Xjdz3Jc8z", + "metadata": { + "id": "0000000000000000000186c2" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDO6Xjdz3Jc8z", + "status": 200, + "response": { + "id": "cus_7VDO6Xjdz3Jc8z", + "alipay_accounts": { + "has_more": false + }, + "email": "user132@me.com", + "metadata": { + "id": "0000000000000000000186c2" + }, + "sources": { + "data": [ + { + "id": "card_17GCxgKaReE7xLUdKVqLosSk", + "customer": "cus_7VDO6Xjdz3Jc8z" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDOtuoXfZjxqR", + "cancel_at_period_end": false, + "current_period_end": 1452365213, + "current_period_start": 1449686813, + "customer": "cus_7VDO6Xjdz3Jc8z", + "metadata": { + "id": "0000000000000000000186c2" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 799 + }, + { + "id": "sub_7VDOhgNQVi8nqk", + "cancel_at_period_end": false, + "current_period_end": 1452365211, + "current_period_start": 1449686811, + "customer": "cus_7VDO6Xjdz3Jc8z", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDO6Xjdz3Jc8z", + "subscription": "sub_7VDOhgNQVi8nqk" + }, + "metadata": { + "id": "0000000000000000000186c1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDOvquFDIoefy", + "cancel_at_period_end": true, + "current_period_end": 1452365209, + "current_period_start": 1449686809, + "customer": "cus_7VDO6Xjdz3Jc8z", + "metadata": { + "id": "0000000000000000000186c2" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDO6Xjdz3Jc8z/subscriptions/sub_7VDOtuoXfZjxqR", + "status": 200, + "response": { + "id": "sub_7VDOtuoXfZjxqR", + "cancel_at_period_end": false, + "current_period_end": 1452365213, + "current_period_start": 1449686813, + "customer": "cus_7VDO6Xjdz3Jc8z", + "metadata": { + "id": "0000000000000000000186c2" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 799 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDO6Xjdz3Jc8z/subscriptions/sub_7VDOhgNQVi8nqk", + "status": 200, + "response": { + "id": "sub_7VDOhgNQVi8nqk", + "cancel_at_period_end": false, + "current_period_end": 1452365211, + "current_period_start": 1449686811, + "customer": "cus_7VDO6Xjdz3Jc8z", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDO6Xjdz3Jc8z", + "subscription": "sub_7VDOhgNQVi8nqk" + }, + "metadata": { + "id": "0000000000000000000186c1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + } +] \ No newline at end of file diff --git a/spec/fixtures/sub-test-23.json b/spec/fixtures/sub-test-23.json new file mode 100644 index 000000000..63f01eb05 --- /dev/null +++ b/spec/fixtures/sub-test-23.json @@ -0,0 +1,564 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCxvKaReE7xLUdEV9eAvts", + "card": { + "id": "card_17GCxvKaReE7xLUd6Z6925wK" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDOpSn6vZJJy5", + "alipay_accounts": { + "has_more": false + }, + "email": "user134@me.com", + "metadata": { + "id": "0000000000000000000186c4" + }, + "sources": { + "data": [ + { + "id": "card_17GCxvKaReE7xLUd6Z6925wK", + "customer": "cus_7VDOpSn6vZJJy5" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDOpSn6vZJJy5", + "status": 200, + "response": { + "id": "cus_7VDOpSn6vZJJy5", + "alipay_accounts": { + "has_more": false + }, + "email": "user134@me.com", + "metadata": { + "id": "0000000000000000000186c4" + }, + "sources": { + "data": [ + { + "id": "card_17GCxvKaReE7xLUd6Z6925wK", + "customer": "cus_7VDOpSn6vZJJy5" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDOpSn6vZJJy5/subscriptions", + "status": 200, + "response": { + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDOpSn6vZJJy5/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDOz93nZ10dgt", + "cancel_at_period_end": false, + "current_period_end": 1452365225, + "current_period_start": 1449686825, + "customer": "cus_7VDOpSn6vZJJy5", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDOpSn6vZJJy5", + "subscription": "sub_7VDOz93nZ10dgt" + }, + "metadata": { + "id": "0000000000000000000186c3" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDOpSn6vZJJy5", + "status": 200, + "response": { + "id": "cus_7VDOpSn6vZJJy5", + "alipay_accounts": { + "has_more": false + }, + "email": "user134@me.com", + "metadata": { + "id": "0000000000000000000186c4" + }, + "sources": { + "data": [ + { + "id": "card_17GCxvKaReE7xLUd6Z6925wK", + "customer": "cus_7VDOpSn6vZJJy5" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDOz93nZ10dgt", + "cancel_at_period_end": false, + "current_period_end": 1452365225, + "current_period_start": 1449686825, + "customer": "cus_7VDOpSn6vZJJy5", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDOpSn6vZJJy5", + "subscription": "sub_7VDOz93nZ10dgt" + }, + "metadata": { + "id": "0000000000000000000186c3" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDOpSn6vZJJy5/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDOnhT4PweQKC", + "cancel_at_period_end": false, + "current_period_end": 1452365227, + "current_period_start": 1449686827, + "customer": "cus_7VDOpSn6vZJJy5", + "metadata": { + "id": "0000000000000000000186c4" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices", + "status": 200, + "response": { + "data": [ + { + "id": "in_17GCxzKaReE7xLUdRK7KpPjM", + "customer": "cus_7VDOpSn6vZJJy5", + "lines": { + "data": [ + { + "id": "sub_7VDOnhT4PweQKC", + "amount": 999, + "metadata": { + "id": "0000000000000000000186c4" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 999, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDOnhT4PweQKC", + "total": 999 + }, + { + "id": "in_17GCxxKaReE7xLUdo8Qz7BPX", + "customer": "cus_7VDOpSn6vZJJy5", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDOpSn6vZJJy5", + "subscription": "sub_7VDOz93nZ10dgt" + }, + "lines": { + "data": [ + { + "id": "sub_7VDOz93nZ10dgt", + "amount": 999, + "metadata": { + "id": "0000000000000000000186c3" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDOz93nZ10dgt", + "total": 0 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDOpSn6vZJJy5", + "status": 200, + "response": { + "id": "cus_7VDOpSn6vZJJy5", + "alipay_accounts": { + "has_more": false + }, + "email": "user134@me.com", + "metadata": { + "id": "0000000000000000000186c4" + }, + "sources": { + "data": [ + { + "id": "card_17GCxvKaReE7xLUd6Z6925wK", + "customer": "cus_7VDOpSn6vZJJy5" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDOnhT4PweQKC", + "cancel_at_period_end": false, + "current_period_end": 1452365227, + "current_period_start": 1449686827, + "customer": "cus_7VDOpSn6vZJJy5", + "metadata": { + "id": "0000000000000000000186c4" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDOz93nZ10dgt", + "cancel_at_period_end": false, + "current_period_end": 1452365225, + "current_period_start": 1449686825, + "customer": "cus_7VDOpSn6vZJJy5", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDOpSn6vZJJy5", + "subscription": "sub_7VDOz93nZ10dgt" + }, + "metadata": { + "id": "0000000000000000000186c3" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDOpSn6vZJJy5", + "status": 200, + "response": { + "id": "cus_7VDOpSn6vZJJy5", + "alipay_accounts": { + "has_more": false + }, + "email": "user134@me.com", + "metadata": { + "id": "0000000000000000000186c4" + }, + "sources": { + "data": [ + { + "id": "card_17GCxvKaReE7xLUd6Z6925wK", + "customer": "cus_7VDOpSn6vZJJy5" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDOnhT4PweQKC", + "cancel_at_period_end": false, + "current_period_end": 1452365227, + "current_period_start": 1449686827, + "customer": "cus_7VDOpSn6vZJJy5", + "metadata": { + "id": "0000000000000000000186c4" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDOz93nZ10dgt", + "cancel_at_period_end": false, + "current_period_end": 1452365225, + "current_period_start": 1449686825, + "customer": "cus_7VDOpSn6vZJJy5", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDOpSn6vZJJy5", + "subscription": "sub_7VDOz93nZ10dgt" + }, + "metadata": { + "id": "0000000000000000000186c3" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCxzKaReE7xLUdRK7KpPjM", + "status": 200, + "response": { + "id": "in_17GCxzKaReE7xLUdRK7KpPjM", + "customer": "cus_7VDOpSn6vZJJy5", + "lines": { + "data": [ + { + "id": "sub_7VDOnhT4PweQKC", + "amount": 999, + "metadata": { + "id": "0000000000000000000186c4" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 999, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDOnhT4PweQKC", + "total": 999 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDOpSn6vZJJy5", + "status": 200, + "response": { + "id": "cus_7VDOpSn6vZJJy5", + "alipay_accounts": { + "has_more": false + }, + "email": "user134@me.com", + "metadata": { + "id": "0000000000000000000186c4" + }, + "sources": { + "data": [ + { + "id": "card_17GCxvKaReE7xLUd6Z6925wK", + "customer": "cus_7VDOpSn6vZJJy5" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDOnhT4PweQKC", + "cancel_at_period_end": false, + "current_period_end": 1452365227, + "current_period_start": 1449686827, + "customer": "cus_7VDOpSn6vZJJy5", + "metadata": { + "id": "0000000000000000000186c4" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDOz93nZ10dgt", + "cancel_at_period_end": false, + "current_period_end": 1452365225, + "current_period_start": 1449686825, + "customer": "cus_7VDOpSn6vZJJy5", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDOpSn6vZJJy5", + "subscription": "sub_7VDOz93nZ10dgt" + }, + "metadata": { + "id": "0000000000000000000186c3" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCxxKaReE7xLUdo8Qz7BPX", + "status": 200, + "response": { + "id": "in_17GCxxKaReE7xLUdo8Qz7BPX", + "customer": "cus_7VDOpSn6vZJJy5", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDOpSn6vZJJy5", + "subscription": "sub_7VDOz93nZ10dgt" + }, + "lines": { + "data": [ + { + "id": "sub_7VDOz93nZ10dgt", + "amount": 999, + "metadata": { + "id": "0000000000000000000186c3" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDOz93nZ10dgt", + "total": 0 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCy2KaReE7xLUdOlFDclfi", + "card": { + "id": "card_17GCy2KaReE7xLUdn5BsBWRl" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDObWSh1dlYh7", + "alipay_accounts": { + "has_more": false + }, + "email": "user133@foo.bar", + "metadata": { + "id": "0000000000000000000186c3" + }, + "sources": { + "data": [ + { + "id": "card_17GCy2KaReE7xLUdn5BsBWRl", + "customer": "cus_7VDObWSh1dlYh7" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + } +] \ No newline at end of file diff --git a/spec/fixtures/sub-test-24.json b/spec/fixtures/sub-test-24.json new file mode 100644 index 000000000..65b84a11b --- /dev/null +++ b/spec/fixtures/sub-test-24.json @@ -0,0 +1,545 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCy3KaReE7xLUdtYb2OjrY", + "card": { + "id": "card_17GCy3KaReE7xLUd3P9sxPX6" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDO2rAKGoRyuV", + "alipay_accounts": { + "has_more": false + }, + "email": "user136@me.com", + "metadata": { + "id": "0000000000000000000186c6" + }, + "sources": { + "data": [ + { + "id": "card_17GCy3KaReE7xLUd3P9sxPX6", + "customer": "cus_7VDO2rAKGoRyuV" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDO2rAKGoRyuV", + "status": 200, + "response": { + "id": "cus_7VDO2rAKGoRyuV", + "alipay_accounts": { + "has_more": false + }, + "email": "user136@me.com", + "metadata": { + "id": "0000000000000000000186c6" + }, + "sources": { + "data": [ + { + "id": "card_17GCy3KaReE7xLUd3P9sxPX6", + "customer": "cus_7VDO2rAKGoRyuV" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDO2rAKGoRyuV/subscriptions", + "status": 200, + "response": { + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDO2rAKGoRyuV/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDOI7IgrnOnfU", + "cancel_at_period_end": false, + "current_period_end": 1452365233, + "current_period_start": 1449686833, + "customer": "cus_7VDO2rAKGoRyuV", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDO2rAKGoRyuV", + "subscription": "sub_7VDOI7IgrnOnfU" + }, + "metadata": { + "id": "0000000000000000000186c5" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDO2rAKGoRyuV", + "status": 200, + "response": { + "id": "cus_7VDO2rAKGoRyuV", + "alipay_accounts": { + "has_more": false + }, + "email": "user136@me.com", + "metadata": { + "id": "0000000000000000000186c6" + }, + "sources": { + "data": [ + { + "id": "card_17GCy3KaReE7xLUd3P9sxPX6", + "customer": "cus_7VDO2rAKGoRyuV" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDOI7IgrnOnfU", + "cancel_at_period_end": false, + "current_period_end": 1452365233, + "current_period_start": 1449686833, + "customer": "cus_7VDO2rAKGoRyuV", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDO2rAKGoRyuV", + "subscription": "sub_7VDOI7IgrnOnfU" + }, + "metadata": { + "id": "0000000000000000000186c5" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDO2rAKGoRyuV/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDOArVVxBdO8Z", + "cancel_at_period_end": false, + "current_period_end": 1452365235, + "current_period_start": 1449686835, + "customer": "cus_7VDO2rAKGoRyuV", + "metadata": { + "id": "0000000000000000000186c6" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDO2rAKGoRyuV", + "status": 200, + "response": { + "id": "cus_7VDO2rAKGoRyuV", + "alipay_accounts": { + "has_more": false + }, + "email": "user136@me.com", + "metadata": { + "id": "0000000000000000000186c6" + }, + "sources": { + "data": [ + { + "id": "card_17GCy3KaReE7xLUd3P9sxPX6", + "customer": "cus_7VDO2rAKGoRyuV" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDOArVVxBdO8Z", + "cancel_at_period_end": false, + "current_period_end": 1452365235, + "current_period_start": 1449686835, + "customer": "cus_7VDO2rAKGoRyuV", + "metadata": { + "id": "0000000000000000000186c6" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDOI7IgrnOnfU", + "cancel_at_period_end": false, + "current_period_end": 1452365233, + "current_period_start": 1449686833, + "customer": "cus_7VDO2rAKGoRyuV", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDO2rAKGoRyuV", + "subscription": "sub_7VDOI7IgrnOnfU" + }, + "metadata": { + "id": "0000000000000000000186c5" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices", + "status": 200, + "response": { + "data": [ + { + "id": "in_17GCy7KaReE7xLUdan3pUgPg", + "customer": "cus_7VDO2rAKGoRyuV", + "lines": { + "data": [ + { + "id": "sub_7VDOArVVxBdO8Z", + "amount": 999, + "metadata": { + "id": "0000000000000000000186c6" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 999, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDOArVVxBdO8Z", + "total": 999 + }, + { + "id": "in_17GCy5KaReE7xLUdWfZT15jA", + "customer": "cus_7VDO2rAKGoRyuV", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDO2rAKGoRyuV", + "subscription": "sub_7VDOI7IgrnOnfU" + }, + "lines": { + "data": [ + { + "id": "sub_7VDOI7IgrnOnfU", + "amount": 999, + "metadata": { + "id": "0000000000000000000186c5" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDOI7IgrnOnfU", + "total": 0 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDO2rAKGoRyuV", + "status": 200, + "response": { + "id": "cus_7VDO2rAKGoRyuV", + "alipay_accounts": { + "has_more": false + }, + "email": "user136@me.com", + "metadata": { + "id": "0000000000000000000186c6" + }, + "sources": { + "data": [ + { + "id": "card_17GCy3KaReE7xLUd3P9sxPX6", + "customer": "cus_7VDO2rAKGoRyuV" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDOArVVxBdO8Z", + "cancel_at_period_end": false, + "current_period_end": 1452365235, + "current_period_start": 1449686835, + "customer": "cus_7VDO2rAKGoRyuV", + "metadata": { + "id": "0000000000000000000186c6" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDOI7IgrnOnfU", + "cancel_at_period_end": false, + "current_period_end": 1452365233, + "current_period_start": 1449686833, + "customer": "cus_7VDO2rAKGoRyuV", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDO2rAKGoRyuV", + "subscription": "sub_7VDOI7IgrnOnfU" + }, + "metadata": { + "id": "0000000000000000000186c5" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCy7KaReE7xLUdan3pUgPg", + "status": 200, + "response": { + "id": "in_17GCy7KaReE7xLUdan3pUgPg", + "customer": "cus_7VDO2rAKGoRyuV", + "lines": { + "data": [ + { + "id": "sub_7VDOArVVxBdO8Z", + "amount": 999, + "metadata": { + "id": "0000000000000000000186c6" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 999, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDOArVVxBdO8Z", + "total": 999 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDO2rAKGoRyuV", + "status": 200, + "response": { + "id": "cus_7VDO2rAKGoRyuV", + "alipay_accounts": { + "has_more": false + }, + "email": "user136@me.com", + "metadata": { + "id": "0000000000000000000186c6" + }, + "sources": { + "data": [ + { + "id": "card_17GCy3KaReE7xLUd3P9sxPX6", + "customer": "cus_7VDO2rAKGoRyuV" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDOArVVxBdO8Z", + "cancel_at_period_end": false, + "current_period_end": 1452365235, + "current_period_start": 1449686835, + "customer": "cus_7VDO2rAKGoRyuV", + "metadata": { + "id": "0000000000000000000186c6" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDOI7IgrnOnfU", + "cancel_at_period_end": false, + "current_period_end": 1452365233, + "current_period_start": 1449686833, + "customer": "cus_7VDO2rAKGoRyuV", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDO2rAKGoRyuV", + "subscription": "sub_7VDOI7IgrnOnfU" + }, + "metadata": { + "id": "0000000000000000000186c5" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCy5KaReE7xLUdWfZT15jA", + "status": 200, + "response": { + "id": "in_17GCy5KaReE7xLUdWfZT15jA", + "customer": "cus_7VDO2rAKGoRyuV", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDO2rAKGoRyuV", + "subscription": "sub_7VDOI7IgrnOnfU" + }, + "lines": { + "data": [ + { + "id": "sub_7VDOI7IgrnOnfU", + "amount": 999, + "metadata": { + "id": "0000000000000000000186c5" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDOI7IgrnOnfU", + "total": 0 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDOv27KBKz3BU", + "alipay_accounts": { + "has_more": false + }, + "email": "user135@foo.bar", + "metadata": { + "id": "0000000000000000000186c5" + }, + "sources": { + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + } +] \ No newline at end of file diff --git a/spec/fixtures/sub-test-25.json b/spec/fixtures/sub-test-25.json new file mode 100644 index 000000000..82bded541 --- /dev/null +++ b/spec/fixtures/sub-test-25.json @@ -0,0 +1,572 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCyBKaReE7xLUd9G37bRkd", + "card": { + "id": "card_17GCyBKaReE7xLUdDzcyOMq0" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDPUcT1ISx3qE", + "alipay_accounts": { + "has_more": false + }, + "email": "user138@me.com", + "metadata": { + "id": "0000000000000000000186c8" + }, + "sources": { + "data": [ + { + "id": "card_17GCyBKaReE7xLUdDzcyOMq0", + "customer": "cus_7VDPUcT1ISx3qE" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPUcT1ISx3qE", + "status": 200, + "response": { + "id": "cus_7VDPUcT1ISx3qE", + "alipay_accounts": { + "has_more": false + }, + "email": "user138@me.com", + "metadata": { + "id": "0000000000000000000186c8" + }, + "sources": { + "data": [ + { + "id": "card_17GCyBKaReE7xLUdDzcyOMq0", + "customer": "cus_7VDPUcT1ISx3qE" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDPUcT1ISx3qE/subscriptions", + "status": 200, + "response": { + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPUcT1ISx3qE/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDPRTLVZfr2xD", + "cancel_at_period_end": false, + "current_period_end": 1452365241, + "current_period_start": 1449686841, + "customer": "cus_7VDPUcT1ISx3qE", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPUcT1ISx3qE", + "subscription": "sub_7VDPRTLVZfr2xD" + }, + "metadata": { + "id": "0000000000000000000186c7" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPUcT1ISx3qE", + "status": 200, + "response": { + "id": "cus_7VDPUcT1ISx3qE", + "alipay_accounts": { + "has_more": false + }, + "email": "user138@me.com", + "metadata": { + "id": "0000000000000000000186c8" + }, + "sources": { + "data": [ + { + "id": "card_17GCyBKaReE7xLUdDzcyOMq0", + "customer": "cus_7VDPUcT1ISx3qE" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDPRTLVZfr2xD", + "cancel_at_period_end": false, + "current_period_end": 1452365241, + "current_period_start": 1449686841, + "customer": "cus_7VDPUcT1ISx3qE", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPUcT1ISx3qE", + "subscription": "sub_7VDPRTLVZfr2xD" + }, + "metadata": { + "id": "0000000000000000000186c7" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPUcT1ISx3qE/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDPKfPdazIoWu", + "cancel_at_period_end": false, + "current_period_end": 1452365243, + "current_period_start": 1449686843, + "customer": "cus_7VDPUcT1ISx3qE", + "metadata": { + "id": "0000000000000000000186c8" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices", + "status": 200, + "response": { + "data": [ + { + "id": "in_17GCyFKaReE7xLUdq9pABNeA", + "customer": "cus_7VDPUcT1ISx3qE", + "lines": { + "data": [ + { + "id": "sub_7VDPKfPdazIoWu", + "amount": 999, + "metadata": { + "id": "0000000000000000000186c8" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 999, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDPKfPdazIoWu", + "total": 999 + }, + { + "id": "in_17GCyDKaReE7xLUdyDnGhQKL", + "customer": "cus_7VDPUcT1ISx3qE", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPUcT1ISx3qE", + "subscription": "sub_7VDPRTLVZfr2xD" + }, + "lines": { + "data": [ + { + "id": "sub_7VDPRTLVZfr2xD", + "amount": 999, + "metadata": { + "id": "0000000000000000000186c7" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDPRTLVZfr2xD", + "total": 0 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCyFKaReE7xLUdq9pABNeA", + "status": 200, + "response": { + "id": "in_17GCyFKaReE7xLUdq9pABNeA", + "customer": "cus_7VDPUcT1ISx3qE", + "lines": { + "data": [ + { + "id": "sub_7VDPKfPdazIoWu", + "amount": 999, + "metadata": { + "id": "0000000000000000000186c8" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 999, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDPKfPdazIoWu", + "total": 999 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPUcT1ISx3qE", + "status": 200, + "response": { + "id": "cus_7VDPUcT1ISx3qE", + "alipay_accounts": { + "has_more": false + }, + "email": "user138@me.com", + "metadata": { + "id": "0000000000000000000186c8" + }, + "sources": { + "data": [ + { + "id": "card_17GCyBKaReE7xLUdDzcyOMq0", + "customer": "cus_7VDPUcT1ISx3qE" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDPKfPdazIoWu", + "cancel_at_period_end": false, + "current_period_end": 1452365243, + "current_period_start": 1449686843, + "customer": "cus_7VDPUcT1ISx3qE", + "metadata": { + "id": "0000000000000000000186c8" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDPRTLVZfr2xD", + "cancel_at_period_end": false, + "current_period_end": 1452365241, + "current_period_start": 1449686841, + "customer": "cus_7VDPUcT1ISx3qE", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPUcT1ISx3qE", + "subscription": "sub_7VDPRTLVZfr2xD" + }, + "metadata": { + "id": "0000000000000000000186c7" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDPUcT1ISx3qE", + "status": 200, + "response": { + "id": "cus_7VDPUcT1ISx3qE", + "alipay_accounts": { + "has_more": false + }, + "email": "user138@me.com", + "metadata": { + "id": "0000000000000000000186c8" + }, + "sources": { + "data": [ + { + "id": "card_17GCyBKaReE7xLUdDzcyOMq0", + "customer": "cus_7VDPUcT1ISx3qE" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDPKfPdazIoWu", + "cancel_at_period_end": false, + "current_period_end": 1452365243, + "current_period_start": 1449686843, + "customer": "cus_7VDPUcT1ISx3qE", + "metadata": { + "id": "0000000000000000000186c8" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDPRTLVZfr2xD", + "cancel_at_period_end": false, + "current_period_end": 1452365241, + "current_period_start": 1449686841, + "customer": "cus_7VDPUcT1ISx3qE", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPUcT1ISx3qE", + "subscription": "sub_7VDPRTLVZfr2xD" + }, + "metadata": { + "id": "0000000000000000000186c7" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPUcT1ISx3qE", + "status": 200, + "response": { + "id": "cus_7VDPUcT1ISx3qE", + "alipay_accounts": { + "has_more": false + }, + "email": "user138@me.com", + "metadata": { + "id": "0000000000000000000186c8" + }, + "sources": { + "data": [ + { + "id": "card_17GCyBKaReE7xLUdDzcyOMq0", + "customer": "cus_7VDPUcT1ISx3qE" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDPKfPdazIoWu", + "cancel_at_period_end": false, + "current_period_end": 1452365243, + "current_period_start": 1449686843, + "customer": "cus_7VDPUcT1ISx3qE", + "metadata": { + "id": "0000000000000000000186c8" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDPRTLVZfr2xD", + "cancel_at_period_end": false, + "current_period_end": 1452365241, + "current_period_start": 1449686841, + "customer": "cus_7VDPUcT1ISx3qE", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPUcT1ISx3qE", + "subscription": "sub_7VDPRTLVZfr2xD" + }, + "metadata": { + "id": "0000000000000000000186c7" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCyDKaReE7xLUdyDnGhQKL", + "status": 200, + "response": { + "id": "in_17GCyDKaReE7xLUdyDnGhQKL", + "customer": "cus_7VDPUcT1ISx3qE", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPUcT1ISx3qE", + "subscription": "sub_7VDPRTLVZfr2xD" + }, + "lines": { + "data": [ + { + "id": "sub_7VDPRTLVZfr2xD", + "amount": 999, + "metadata": { + "id": "0000000000000000000186c7" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDPRTLVZfr2xD", + "total": 0 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDPUcT1ISx3qE/subscriptions/sub_7VDPKfPdazIoWu", + "status": 200, + "response": { + "id": "sub_7VDPKfPdazIoWu", + "cancel_at_period_end": false, + "current_period_end": 1452365243, + "current_period_start": 1449686843, + "customer": "cus_7VDPUcT1ISx3qE", + "metadata": { + "id": "0000000000000000000186c8" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDPUcT1ISx3qE/subscriptions/sub_7VDPRTLVZfr2xD", + "status": 200, + "response": { + "id": "sub_7VDPRTLVZfr2xD", + "cancel_at_period_end": false, + "current_period_end": 1452365241, + "current_period_start": 1449686841, + "customer": "cus_7VDPUcT1ISx3qE", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPUcT1ISx3qE", + "subscription": "sub_7VDPRTLVZfr2xD" + }, + "metadata": { + "id": "0000000000000000000186c7" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + } +] \ No newline at end of file diff --git a/spec/fixtures/sub-test-26.json b/spec/fixtures/sub-test-26.json new file mode 100644 index 000000000..ba6471698 --- /dev/null +++ b/spec/fixtures/sub-test-26.json @@ -0,0 +1,2713 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCyJKaReE7xLUdejgGY4Xu", + "card": { + "id": "card_17GCyJKaReE7xLUdBO7GL3HP" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDPTpDHVQmPes", + "alipay_accounts": { + "has_more": false + }, + "email": "user141@me.com", + "metadata": { + "id": "0000000000000000000186cb" + }, + "sources": { + "data": [ + { + "id": "card_17GCyJKaReE7xLUdBO7GL3HP", + "customer": "cus_7VDPTpDHVQmPes" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDPTpDHVQmPes/subscriptions", + "status": 200, + "response": { + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPTpDHVQmPes", + "status": 200, + "response": { + "id": "cus_7VDPTpDHVQmPes", + "alipay_accounts": { + "has_more": false + }, + "email": "user141@me.com", + "metadata": { + "id": "0000000000000000000186cb" + }, + "sources": { + "data": [ + { + "id": "card_17GCyJKaReE7xLUdBO7GL3HP", + "customer": "cus_7VDPTpDHVQmPes" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPTpDHVQmPes/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDPlVfpIKvKXW", + "cancel_at_period_end": false, + "current_period_end": 1452365248, + "current_period_start": 1449686848, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDPlVfpIKvKXW" + }, + "metadata": { + "id": "0000000000000000000186c9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDPTpDHVQmPes/subscriptions", + "status": 200, + "response": { + "data": [ + { + "id": "sub_7VDPlVfpIKvKXW", + "cancel_at_period_end": false, + "current_period_end": 1452365248, + "current_period_start": 1449686848, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDPlVfpIKvKXW" + }, + "metadata": { + "id": "0000000000000000000186c9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPTpDHVQmPes/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDP8DUlXwzxqe", + "cancel_at_period_end": false, + "current_period_end": 1452365250, + "current_period_start": 1449686850, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDP8DUlXwzxqe" + }, + "metadata": { + "id": "0000000000000000000186ca" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPTpDHVQmPes", + "status": 200, + "response": { + "id": "cus_7VDPTpDHVQmPes", + "alipay_accounts": { + "has_more": false + }, + "email": "user141@me.com", + "metadata": { + "id": "0000000000000000000186cb" + }, + "sources": { + "data": [ + { + "id": "card_17GCyJKaReE7xLUdBO7GL3HP", + "customer": "cus_7VDPTpDHVQmPes" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDP8DUlXwzxqe", + "cancel_at_period_end": false, + "current_period_end": 1452365250, + "current_period_start": 1449686850, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDP8DUlXwzxqe" + }, + "metadata": { + "id": "0000000000000000000186ca" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDPlVfpIKvKXW", + "cancel_at_period_end": false, + "current_period_end": 1452365248, + "current_period_start": 1449686848, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDPlVfpIKvKXW" + }, + "metadata": { + "id": "0000000000000000000186c9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPTpDHVQmPes/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDPXNbIbAwIo7", + "cancel_at_period_end": false, + "current_period_end": 1452365253, + "current_period_start": 1449686853, + "customer": "cus_7VDPTpDHVQmPes", + "metadata": { + "id": "0000000000000000000186cb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 1798 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPTpDHVQmPes", + "status": 200, + "response": { + "id": "cus_7VDPTpDHVQmPes", + "alipay_accounts": { + "has_more": false + }, + "email": "user141@me.com", + "metadata": { + "id": "0000000000000000000186cb" + }, + "sources": { + "data": [ + { + "id": "card_17GCyJKaReE7xLUdBO7GL3HP", + "customer": "cus_7VDPTpDHVQmPes" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDPXNbIbAwIo7", + "cancel_at_period_end": false, + "current_period_end": 1452365253, + "current_period_start": 1449686853, + "customer": "cus_7VDPTpDHVQmPes", + "metadata": { + "id": "0000000000000000000186cb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 1798 + }, + { + "id": "sub_7VDP8DUlXwzxqe", + "cancel_at_period_end": false, + "current_period_end": 1452365250, + "current_period_start": 1449686850, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDP8DUlXwzxqe" + }, + "metadata": { + "id": "0000000000000000000186ca" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDPlVfpIKvKXW", + "cancel_at_period_end": false, + "current_period_end": 1452365248, + "current_period_start": 1449686848, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDPlVfpIKvKXW" + }, + "metadata": { + "id": "0000000000000000000186c9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices", + "status": 200, + "response": { + "data": [ + { + "id": "in_17GCyPKaReE7xLUdug9wmkcE", + "customer": "cus_7VDPTpDHVQmPes", + "lines": { + "data": [ + { + "id": "sub_7VDPXNbIbAwIo7", + "amount": 1798, + "metadata": { + "id": "0000000000000000000186cb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 1798, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDPXNbIbAwIo7", + "total": 1798 + }, + { + "id": "in_17GCyMKaReE7xLUdIgGA1rVx", + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDP8DUlXwzxqe" + }, + "lines": { + "data": [ + { + "id": "sub_7VDP8DUlXwzxqe", + "amount": 999, + "metadata": { + "id": "0000000000000000000186ca" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDP8DUlXwzxqe", + "total": 0 + }, + { + "id": "in_17GCyKKaReE7xLUdIWQvRDZ0", + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDPlVfpIKvKXW" + }, + "lines": { + "data": [ + { + "id": "sub_7VDPlVfpIKvKXW", + "amount": 999, + "metadata": { + "id": "0000000000000000000186c9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDPlVfpIKvKXW", + "total": 0 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPTpDHVQmPes", + "status": 200, + "response": { + "id": "cus_7VDPTpDHVQmPes", + "alipay_accounts": { + "has_more": false + }, + "email": "user141@me.com", + "metadata": { + "id": "0000000000000000000186cb" + }, + "sources": { + "data": [ + { + "id": "card_17GCyJKaReE7xLUdBO7GL3HP", + "customer": "cus_7VDPTpDHVQmPes" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDPXNbIbAwIo7", + "cancel_at_period_end": false, + "current_period_end": 1452365253, + "current_period_start": 1449686853, + "customer": "cus_7VDPTpDHVQmPes", + "metadata": { + "id": "0000000000000000000186cb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 1798 + }, + { + "id": "sub_7VDP8DUlXwzxqe", + "cancel_at_period_end": false, + "current_period_end": 1452365250, + "current_period_start": 1449686850, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDP8DUlXwzxqe" + }, + "metadata": { + "id": "0000000000000000000186ca" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDPlVfpIKvKXW", + "cancel_at_period_end": false, + "current_period_end": 1452365248, + "current_period_start": 1449686848, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDPlVfpIKvKXW" + }, + "metadata": { + "id": "0000000000000000000186c9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCyPKaReE7xLUdug9wmkcE", + "status": 200, + "response": { + "id": "in_17GCyPKaReE7xLUdug9wmkcE", + "customer": "cus_7VDPTpDHVQmPes", + "lines": { + "data": [ + { + "id": "sub_7VDPXNbIbAwIo7", + "amount": 1798, + "metadata": { + "id": "0000000000000000000186cb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 1798, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDPXNbIbAwIo7", + "total": 1798 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDPTpDHVQmPes", + "status": 200, + "response": { + "id": "cus_7VDPTpDHVQmPes", + "alipay_accounts": { + "has_more": false + }, + "email": "user141@me.com", + "metadata": { + "id": "0000000000000000000186cb" + }, + "sources": { + "data": [ + { + "id": "card_17GCyJKaReE7xLUdBO7GL3HP", + "customer": "cus_7VDPTpDHVQmPes" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDPXNbIbAwIo7", + "cancel_at_period_end": false, + "current_period_end": 1452365253, + "current_period_start": 1449686853, + "customer": "cus_7VDPTpDHVQmPes", + "metadata": { + "id": "0000000000000000000186cb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 1798 + }, + { + "id": "sub_7VDP8DUlXwzxqe", + "cancel_at_period_end": false, + "current_period_end": 1452365250, + "current_period_start": 1449686850, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDP8DUlXwzxqe" + }, + "metadata": { + "id": "0000000000000000000186ca" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDPlVfpIKvKXW", + "cancel_at_period_end": false, + "current_period_end": 1452365248, + "current_period_start": 1449686848, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDPlVfpIKvKXW" + }, + "metadata": { + "id": "0000000000000000000186c9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCyMKaReE7xLUdIgGA1rVx", + "status": 200, + "response": { + "id": "in_17GCyMKaReE7xLUdIgGA1rVx", + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDP8DUlXwzxqe" + }, + "lines": { + "data": [ + { + "id": "sub_7VDP8DUlXwzxqe", + "amount": 999, + "metadata": { + "id": "0000000000000000000186ca" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDP8DUlXwzxqe", + "total": 0 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCyKKaReE7xLUdIWQvRDZ0", + "status": 200, + "response": { + "id": "in_17GCyKKaReE7xLUdIWQvRDZ0", + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDPlVfpIKvKXW" + }, + "lines": { + "data": [ + { + "id": "sub_7VDPlVfpIKvKXW", + "amount": 999, + "metadata": { + "id": "0000000000000000000186c9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDPlVfpIKvKXW", + "total": 0 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDPTpDHVQmPes/subscriptions/sub_7VDPXNbIbAwIo7", + "status": 200, + "response": { + "id": "sub_7VDPXNbIbAwIo7", + "cancel_at_period_end": false, + "current_period_end": 1452365253, + "current_period_start": 1449686853, + "customer": "cus_7VDPTpDHVQmPes", + "metadata": { + "id": "0000000000000000000186cb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 1798 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "DELETE", + "path": "/v1/customers/cus_7VDPTpDHVQmPes/subscriptions/sub_7VDPXNbIbAwIo7", + "status": 200, + "response": { + "id": "sub_7VDPXNbIbAwIo7", + "cancel_at_period_end": false, + "current_period_end": 1452365253, + "current_period_start": 1449686853, + "customer": "cus_7VDPTpDHVQmPes", + "metadata": { + "id": "0000000000000000000186cb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 1798 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDPTpDHVQmPes", + "status": 200, + "response": { + "id": "cus_7VDPTpDHVQmPes", + "alipay_accounts": { + "has_more": false + }, + "email": "user141@me.com", + "metadata": { + "id": "0000000000000000000186cb" + }, + "sources": { + "data": [ + { + "id": "card_17GCyJKaReE7xLUdBO7GL3HP", + "customer": "cus_7VDPTpDHVQmPes" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDP8DUlXwzxqe", + "cancel_at_period_end": false, + "current_period_end": 1452365250, + "current_period_start": 1449686850, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDP8DUlXwzxqe" + }, + "metadata": { + "id": "0000000000000000000186ca" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDPlVfpIKvKXW", + "cancel_at_period_end": false, + "current_period_end": 1452365248, + "current_period_start": 1449686848, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDPlVfpIKvKXW" + }, + "metadata": { + "id": "0000000000000000000186c9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "DELETE", + "path": "/v1/customers/cus_7VDPTpDHVQmPes/subscriptions/sub_7VDPlVfpIKvKXW", + "status": 200, + "response": { + "id": "sub_7VDPlVfpIKvKXW", + "cancel_at_period_end": true, + "current_period_end": 1452365248, + "current_period_start": 1449686848, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDPlVfpIKvKXW" + }, + "metadata": { + "id": "0000000000000000000186c9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "DELETE", + "path": "/v1/customers/cus_7VDPTpDHVQmPes/subscriptions/sub_7VDP8DUlXwzxqe", + "status": 200, + "response": { + "id": "sub_7VDP8DUlXwzxqe", + "cancel_at_period_end": true, + "current_period_end": 1452365250, + "current_period_start": 1449686850, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDP8DUlXwzxqe" + }, + "metadata": { + "id": "0000000000000000000186ca" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDPTpDHVQmPes/subscriptions", + "status": 200, + "response": { + "data": [ + { + "id": "sub_7VDP8DUlXwzxqe", + "cancel_at_period_end": true, + "current_period_end": 1452365250, + "current_period_start": 1449686850, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDP8DUlXwzxqe" + }, + "metadata": { + "id": "0000000000000000000186ca" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDPlVfpIKvKXW", + "cancel_at_period_end": true, + "current_period_end": 1452365248, + "current_period_start": 1449686848, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDPlVfpIKvKXW" + }, + "metadata": { + "id": "0000000000000000000186c9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPTpDHVQmPes", + "status": 200, + "response": { + "id": "cus_7VDPTpDHVQmPes", + "alipay_accounts": { + "has_more": false + }, + "email": "user141@me.com", + "metadata": { + "id": "0000000000000000000186cb" + }, + "sources": { + "data": [ + { + "id": "card_17GCyJKaReE7xLUdBO7GL3HP", + "customer": "cus_7VDPTpDHVQmPes" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDP8DUlXwzxqe", + "cancel_at_period_end": true, + "current_period_end": 1452365250, + "current_period_start": 1449686850, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDP8DUlXwzxqe" + }, + "metadata": { + "id": "0000000000000000000186ca" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDPlVfpIKvKXW", + "cancel_at_period_end": true, + "current_period_end": 1452365248, + "current_period_start": 1449686848, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDPlVfpIKvKXW" + }, + "metadata": { + "id": "0000000000000000000186c9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDPTpDHVQmPes", + "status": 200, + "response": { + "id": "cus_7VDPTpDHVQmPes", + "alipay_accounts": { + "has_more": false + }, + "email": "user141@me.com", + "metadata": { + "id": "0000000000000000000186cb" + }, + "sources": { + "data": [ + { + "id": "card_17GCyJKaReE7xLUdBO7GL3HP", + "customer": "cus_7VDPTpDHVQmPes" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDP8DUlXwzxqe", + "cancel_at_period_end": true, + "current_period_end": 1452365250, + "current_period_start": 1449686850, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDP8DUlXwzxqe" + }, + "metadata": { + "id": "0000000000000000000186ca" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDPlVfpIKvKXW", + "cancel_at_period_end": true, + "current_period_end": 1452365248, + "current_period_start": 1449686848, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDPlVfpIKvKXW" + }, + "metadata": { + "id": "0000000000000000000186c9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDPTpDHVQmPes/subscriptions", + "status": 200, + "response": { + "data": [ + { + "id": "sub_7VDP8DUlXwzxqe", + "cancel_at_period_end": true, + "current_period_end": 1452365250, + "current_period_start": 1449686850, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDP8DUlXwzxqe" + }, + "metadata": { + "id": "0000000000000000000186ca" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDPlVfpIKvKXW", + "cancel_at_period_end": true, + "current_period_end": 1452365248, + "current_period_start": 1449686848, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDPlVfpIKvKXW" + }, + "metadata": { + "id": "0000000000000000000186c9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "DELETE", + "path": "/v1/customers/cus_7VDPTpDHVQmPes/subscriptions/sub_7VDPlVfpIKvKXW", + "status": 200, + "response": { + "id": "sub_7VDPlVfpIKvKXW", + "cancel_at_period_end": true, + "current_period_end": 1452365248, + "current_period_start": 1449686848, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDPlVfpIKvKXW" + }, + "metadata": { + "id": "0000000000000000000186c9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPTpDHVQmPes/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDPn5rYllQBCH", + "cancel_at_period_end": false, + "current_period_end": 1452365248, + "current_period_start": 1449686862, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDPn5rYllQBCH" + }, + "metadata": { + "id": "0000000000000000000186c9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPTpDHVQmPes", + "status": 200, + "response": { + "id": "cus_7VDPTpDHVQmPes", + "alipay_accounts": { + "has_more": false + }, + "email": "user141@me.com", + "metadata": { + "id": "0000000000000000000186cb" + }, + "sources": { + "data": [ + { + "id": "card_17GCyJKaReE7xLUdBO7GL3HP", + "customer": "cus_7VDPTpDHVQmPes" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDPn5rYllQBCH", + "cancel_at_period_end": false, + "current_period_end": 1452365248, + "current_period_start": 1449686862, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDPn5rYllQBCH" + }, + "metadata": { + "id": "0000000000000000000186c9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDP8DUlXwzxqe", + "cancel_at_period_end": true, + "current_period_end": 1452365250, + "current_period_start": 1449686850, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDP8DUlXwzxqe" + }, + "metadata": { + "id": "0000000000000000000186ca" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPTpDHVQmPes/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDPAHKKcnA0yC", + "cancel_at_period_end": false, + "current_period_end": 1452365264, + "current_period_start": 1449686864, + "customer": "cus_7VDPTpDHVQmPes", + "metadata": { + "id": "0000000000000000000186cb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices", + "status": 200, + "response": { + "data": [ + { + "id": "in_17GCyaKaReE7xLUdzVCf5LhH", + "customer": "cus_7VDPTpDHVQmPes", + "lines": { + "data": [ + { + "id": "sub_7VDPAHKKcnA0yC", + "amount": 999, + "metadata": { + "id": "0000000000000000000186cb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 999, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDPAHKKcnA0yC", + "total": 999 + }, + { + "id": "in_17GCyYKaReE7xLUd3WGAl0cW", + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDPn5rYllQBCH" + }, + "lines": { + "data": [ + { + "id": "sub_7VDPn5rYllQBCH", + "amount": 0, + "metadata": { + "id": "0000000000000000000186c9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDPn5rYllQBCH", + "total": 0 + }, + { + "id": "in_17GCyPKaReE7xLUdug9wmkcE", + "customer": "cus_7VDPTpDHVQmPes", + "lines": { + "data": [ + { + "id": "sub_7VDPXNbIbAwIo7", + "amount": 1798, + "metadata": { + "id": "0000000000000000000186cb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 1798, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDPXNbIbAwIo7", + "total": 1798 + }, + { + "id": "in_17GCyMKaReE7xLUdIgGA1rVx", + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDP8DUlXwzxqe" + }, + "lines": { + "data": [ + { + "id": "sub_7VDP8DUlXwzxqe", + "amount": 999, + "metadata": { + "id": "0000000000000000000186ca" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDP8DUlXwzxqe", + "total": 0 + }, + { + "id": "in_17GCyKKaReE7xLUdIWQvRDZ0", + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDPlVfpIKvKXW" + }, + "lines": { + "data": [ + { + "id": "sub_7VDPlVfpIKvKXW", + "amount": 999, + "metadata": { + "id": "0000000000000000000186c9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDPlVfpIKvKXW", + "total": 0 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPTpDHVQmPes", + "status": 200, + "response": { + "id": "cus_7VDPTpDHVQmPes", + "alipay_accounts": { + "has_more": false + }, + "email": "user141@me.com", + "metadata": { + "id": "0000000000000000000186cb" + }, + "sources": { + "data": [ + { + "id": "card_17GCyJKaReE7xLUdBO7GL3HP", + "customer": "cus_7VDPTpDHVQmPes" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDPAHKKcnA0yC", + "cancel_at_period_end": false, + "current_period_end": 1452365264, + "current_period_start": 1449686864, + "customer": "cus_7VDPTpDHVQmPes", + "metadata": { + "id": "0000000000000000000186cb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDPn5rYllQBCH", + "cancel_at_period_end": false, + "current_period_end": 1452365248, + "current_period_start": 1449686862, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDPn5rYllQBCH" + }, + "metadata": { + "id": "0000000000000000000186c9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDP8DUlXwzxqe", + "cancel_at_period_end": true, + "current_period_end": 1452365250, + "current_period_start": 1449686850, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDP8DUlXwzxqe" + }, + "metadata": { + "id": "0000000000000000000186ca" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCyaKaReE7xLUdzVCf5LhH", + "status": 200, + "response": { + "id": "in_17GCyaKaReE7xLUdzVCf5LhH", + "customer": "cus_7VDPTpDHVQmPes", + "lines": { + "data": [ + { + "id": "sub_7VDPAHKKcnA0yC", + "amount": 999, + "metadata": { + "id": "0000000000000000000186cb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 999, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDPAHKKcnA0yC", + "total": 999 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPTpDHVQmPes", + "status": 200, + "response": { + "id": "cus_7VDPTpDHVQmPes", + "alipay_accounts": { + "has_more": false + }, + "email": "user141@me.com", + "metadata": { + "id": "0000000000000000000186cb" + }, + "sources": { + "data": [ + { + "id": "card_17GCyJKaReE7xLUdBO7GL3HP", + "customer": "cus_7VDPTpDHVQmPes" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDPAHKKcnA0yC", + "cancel_at_period_end": false, + "current_period_end": 1452365264, + "current_period_start": 1449686864, + "customer": "cus_7VDPTpDHVQmPes", + "metadata": { + "id": "0000000000000000000186cb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDPn5rYllQBCH", + "cancel_at_period_end": false, + "current_period_end": 1452365248, + "current_period_start": 1449686862, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDPn5rYllQBCH" + }, + "metadata": { + "id": "0000000000000000000186c9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDP8DUlXwzxqe", + "cancel_at_period_end": true, + "current_period_end": 1452365250, + "current_period_start": 1449686850, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDP8DUlXwzxqe" + }, + "metadata": { + "id": "0000000000000000000186ca" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCyYKaReE7xLUd3WGAl0cW", + "status": 200, + "response": { + "id": "in_17GCyYKaReE7xLUd3WGAl0cW", + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDPn5rYllQBCH" + }, + "lines": { + "data": [ + { + "id": "sub_7VDPn5rYllQBCH", + "amount": 0, + "metadata": { + "id": "0000000000000000000186c9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDPn5rYllQBCH", + "total": 0 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDPTpDHVQmPes/subscriptions/sub_7VDPAHKKcnA0yC", + "status": 200, + "response": { + "id": "sub_7VDPAHKKcnA0yC", + "cancel_at_period_end": false, + "current_period_end": 1452365264, + "current_period_start": 1449686864, + "customer": "cus_7VDPTpDHVQmPes", + "metadata": { + "id": "0000000000000000000186cb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDPTpDHVQmPes/subscriptions/sub_7VDPn5rYllQBCH", + "status": 200, + "response": { + "id": "sub_7VDPn5rYllQBCH", + "cancel_at_period_end": false, + "current_period_end": 1452365248, + "current_period_start": 1449686862, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDPn5rYllQBCH" + }, + "metadata": { + "id": "0000000000000000000186c9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDPTpDHVQmPes", + "status": 200, + "response": { + "id": "cus_7VDPTpDHVQmPes", + "alipay_accounts": { + "has_more": false + }, + "email": "user141@me.com", + "metadata": { + "id": "0000000000000000000186cb" + }, + "sources": { + "data": [ + { + "id": "card_17GCyJKaReE7xLUdBO7GL3HP", + "customer": "cus_7VDPTpDHVQmPes" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDPAHKKcnA0yC", + "cancel_at_period_end": false, + "current_period_end": 1452365264, + "current_period_start": 1449686864, + "customer": "cus_7VDPTpDHVQmPes", + "metadata": { + "id": "0000000000000000000186cb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDPn5rYllQBCH", + "cancel_at_period_end": false, + "current_period_end": 1452365248, + "current_period_start": 1449686862, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDPn5rYllQBCH" + }, + "metadata": { + "id": "0000000000000000000186c9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDP8DUlXwzxqe", + "cancel_at_period_end": true, + "current_period_end": 1452365250, + "current_period_start": 1449686850, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDP8DUlXwzxqe" + }, + "metadata": { + "id": "0000000000000000000186ca" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDPTpDHVQmPes/subscriptions", + "status": 200, + "response": { + "data": [ + { + "id": "sub_7VDPAHKKcnA0yC", + "cancel_at_period_end": false, + "current_period_end": 1452365264, + "current_period_start": 1449686864, + "customer": "cus_7VDPTpDHVQmPes", + "metadata": { + "id": "0000000000000000000186cb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDPn5rYllQBCH", + "cancel_at_period_end": false, + "current_period_end": 1452365248, + "current_period_start": 1449686862, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDPn5rYllQBCH" + }, + "metadata": { + "id": "0000000000000000000186c9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDP8DUlXwzxqe", + "cancel_at_period_end": true, + "current_period_end": 1452365250, + "current_period_start": 1449686850, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDP8DUlXwzxqe" + }, + "metadata": { + "id": "0000000000000000000186ca" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPTpDHVQmPes/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDPOhhwJPMC3M", + "cancel_at_period_end": false, + "current_period_end": 1452365267, + "current_period_start": 1449686867, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDPOhhwJPMC3M" + }, + "metadata": { + "id": "0000000000000000000186cc" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPTpDHVQmPes", + "status": 200, + "response": { + "id": "cus_7VDPTpDHVQmPes", + "alipay_accounts": { + "has_more": false + }, + "email": "user141@me.com", + "metadata": { + "id": "0000000000000000000186cb" + }, + "sources": { + "data": [ + { + "id": "card_17GCyJKaReE7xLUdBO7GL3HP", + "customer": "cus_7VDPTpDHVQmPes" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDPOhhwJPMC3M", + "cancel_at_period_end": false, + "current_period_end": 1452365267, + "current_period_start": 1449686867, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDPOhhwJPMC3M" + }, + "metadata": { + "id": "0000000000000000000186cc" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDPAHKKcnA0yC", + "cancel_at_period_end": false, + "current_period_end": 1452365264, + "current_period_start": 1449686864, + "customer": "cus_7VDPTpDHVQmPes", + "metadata": { + "id": "0000000000000000000186cb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDPn5rYllQBCH", + "cancel_at_period_end": false, + "current_period_end": 1452365248, + "current_period_start": 1449686862, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDPn5rYllQBCH" + }, + "metadata": { + "id": "0000000000000000000186c9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDP8DUlXwzxqe", + "cancel_at_period_end": true, + "current_period_end": 1452365250, + "current_period_start": 1449686850, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDP8DUlXwzxqe" + }, + "metadata": { + "id": "0000000000000000000186ca" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDPTpDHVQmPes/subscriptions", + "status": 200, + "response": { + "data": [ + { + "id": "sub_7VDPOhhwJPMC3M", + "cancel_at_period_end": false, + "current_period_end": 1452365267, + "current_period_start": 1449686867, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDPOhhwJPMC3M" + }, + "metadata": { + "id": "0000000000000000000186cc" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDPAHKKcnA0yC", + "cancel_at_period_end": false, + "current_period_end": 1452365264, + "current_period_start": 1449686864, + "customer": "cus_7VDPTpDHVQmPes", + "metadata": { + "id": "0000000000000000000186cb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDPn5rYllQBCH", + "cancel_at_period_end": false, + "current_period_end": 1452365248, + "current_period_start": 1449686862, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDPn5rYllQBCH" + }, + "metadata": { + "id": "0000000000000000000186c9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDP8DUlXwzxqe", + "cancel_at_period_end": true, + "current_period_end": 1452365250, + "current_period_start": 1449686850, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDP8DUlXwzxqe" + }, + "metadata": { + "id": "0000000000000000000186ca" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPTpDHVQmPes/subscriptions/sub_7VDPAHKKcnA0yC", + "status": 200, + "response": { + "id": "sub_7VDPAHKKcnA0yC", + "cancel_at_period_end": false, + "current_period_end": 1452365264, + "current_period_start": 1449686864, + "customer": "cus_7VDPTpDHVQmPes", + "metadata": { + "id": "0000000000000000000186cb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 1798 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/invoices", + "status": 200, + "response": { + "id": "in_17GCyhKaReE7xLUdIBGKICtG", + "customer": "cus_7VDPTpDHVQmPes", + "lines": { + "data": [ + { + "id": "ii_17GCygKaReE7xLUdcFdYfLUG", + "amount": -999, + "description": "Unused time on 999 x Incremental after 09 Dec 2015", + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": true, + "quantity": 999, + "subscription": "sub_7VDPAHKKcnA0yC", + "type": "invoiceitem" + }, + { + "id": "ii_17GCygKaReE7xLUdlTp9oMaD", + "amount": 1798, + "description": "Remaining time on 1798 x Incremental after 09 Dec 2015", + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": true, + "quantity": 1798, + "subscription": "sub_7VDPAHKKcnA0yC", + "type": "invoiceitem" + } + ], + "has_more": false + }, + "paid": false, + "total": 799 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices", + "status": 200, + "response": { + "data": [ + { + "id": "in_17GCyhKaReE7xLUdIBGKICtG", + "customer": "cus_7VDPTpDHVQmPes", + "lines": { + "data": [ + { + "id": "ii_17GCygKaReE7xLUdcFdYfLUG", + "amount": -999, + "description": "Unused time on 999 x Incremental after 09 Dec 2015", + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": true, + "quantity": 999, + "subscription": "sub_7VDPAHKKcnA0yC", + "type": "invoiceitem" + }, + { + "id": "ii_17GCygKaReE7xLUdlTp9oMaD", + "amount": 1798, + "description": "Remaining time on 1798 x Incremental after 09 Dec 2015", + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": true, + "quantity": 1798, + "subscription": "sub_7VDPAHKKcnA0yC", + "type": "invoiceitem" + } + ], + "has_more": false + }, + "paid": false, + "total": 799 + }, + { + "id": "in_17GCydKaReE7xLUdL6oTceIa", + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDPOhhwJPMC3M" + }, + "lines": { + "data": [ + { + "id": "sub_7VDPOhhwJPMC3M", + "amount": 999, + "metadata": { + "id": "0000000000000000000186cc" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDPOhhwJPMC3M", + "total": 0 + }, + { + "id": "in_17GCyaKaReE7xLUdzVCf5LhH", + "customer": "cus_7VDPTpDHVQmPes", + "lines": { + "data": [ + { + "id": "sub_7VDPAHKKcnA0yC", + "amount": 999, + "metadata": { + "id": "0000000000000000000186cb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 999, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDPAHKKcnA0yC", + "total": 999 + }, + { + "id": "in_17GCyYKaReE7xLUd3WGAl0cW", + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDPn5rYllQBCH" + }, + "lines": { + "data": [ + { + "id": "sub_7VDPn5rYllQBCH", + "amount": 0, + "metadata": { + "id": "0000000000000000000186c9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDPn5rYllQBCH", + "total": 0 + }, + { + "id": "in_17GCyPKaReE7xLUdug9wmkcE", + "customer": "cus_7VDPTpDHVQmPes", + "lines": { + "data": [ + { + "id": "sub_7VDPXNbIbAwIo7", + "amount": 1798, + "metadata": { + "id": "0000000000000000000186cb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 1798, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDPXNbIbAwIo7", + "total": 1798 + }, + { + "id": "in_17GCyMKaReE7xLUdIgGA1rVx", + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDP8DUlXwzxqe" + }, + "lines": { + "data": [ + { + "id": "sub_7VDP8DUlXwzxqe", + "amount": 999, + "metadata": { + "id": "0000000000000000000186ca" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDP8DUlXwzxqe", + "total": 0 + }, + { + "id": "in_17GCyKKaReE7xLUdIWQvRDZ0", + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDPlVfpIKvKXW" + }, + "lines": { + "data": [ + { + "id": "sub_7VDPlVfpIKvKXW", + "amount": 999, + "metadata": { + "id": "0000000000000000000186c9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDPlVfpIKvKXW", + "total": 0 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPTpDHVQmPes", + "status": 200, + "response": { + "id": "cus_7VDPTpDHVQmPes", + "alipay_accounts": { + "has_more": false + }, + "email": "user141@me.com", + "metadata": { + "id": "0000000000000000000186cb" + }, + "sources": { + "data": [ + { + "id": "card_17GCyJKaReE7xLUdBO7GL3HP", + "customer": "cus_7VDPTpDHVQmPes" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDPAHKKcnA0yC", + "cancel_at_period_end": false, + "current_period_end": 1452365264, + "current_period_start": 1449686864, + "customer": "cus_7VDPTpDHVQmPes", + "metadata": { + "id": "0000000000000000000186cb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 1798 + }, + { + "id": "sub_7VDPOhhwJPMC3M", + "cancel_at_period_end": false, + "current_period_end": 1452365267, + "current_period_start": 1449686867, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDPOhhwJPMC3M" + }, + "metadata": { + "id": "0000000000000000000186cc" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDPn5rYllQBCH", + "cancel_at_period_end": false, + "current_period_end": 1452365248, + "current_period_start": 1449686862, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDPn5rYllQBCH" + }, + "metadata": { + "id": "0000000000000000000186c9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDP8DUlXwzxqe", + "cancel_at_period_end": true, + "current_period_end": 1452365250, + "current_period_start": 1449686850, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDP8DUlXwzxqe" + }, + "metadata": { + "id": "0000000000000000000186ca" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCyhKaReE7xLUdIBGKICtG", + "status": 200, + "response": { + "id": "in_17GCyhKaReE7xLUdIBGKICtG", + "customer": "cus_7VDPTpDHVQmPes", + "lines": { + "data": [ + { + "id": "ii_17GCygKaReE7xLUdcFdYfLUG", + "amount": -999, + "description": "Unused time on 999 x Incremental after 09 Dec 2015", + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": true, + "quantity": 999, + "subscription": "sub_7VDPAHKKcnA0yC", + "type": "invoiceitem" + }, + { + "id": "ii_17GCygKaReE7xLUdlTp9oMaD", + "amount": 1798, + "description": "Remaining time on 1798 x Incremental after 09 Dec 2015", + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": true, + "quantity": 1798, + "subscription": "sub_7VDPAHKKcnA0yC", + "type": "invoiceitem" + } + ], + "has_more": false + }, + "paid": false, + "total": 799 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCydKaReE7xLUdL6oTceIa", + "status": 200, + "response": { + "id": "in_17GCydKaReE7xLUdL6oTceIa", + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDPOhhwJPMC3M" + }, + "lines": { + "data": [ + { + "id": "sub_7VDPOhhwJPMC3M", + "amount": 999, + "metadata": { + "id": "0000000000000000000186cc" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDPOhhwJPMC3M", + "total": 0 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDPTpDHVQmPes/subscriptions/sub_7VDPAHKKcnA0yC", + "status": 200, + "response": { + "id": "sub_7VDPAHKKcnA0yC", + "cancel_at_period_end": false, + "current_period_end": 1452365264, + "current_period_start": 1449686864, + "customer": "cus_7VDPTpDHVQmPes", + "metadata": { + "id": "0000000000000000000186cb" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 1798 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDPTpDHVQmPes/subscriptions/sub_7VDPOhhwJPMC3M", + "status": 200, + "response": { + "id": "sub_7VDPOhhwJPMC3M", + "cancel_at_period_end": false, + "current_period_end": 1452365267, + "current_period_start": 1449686867, + "customer": "cus_7VDPTpDHVQmPes", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPTpDHVQmPes", + "subscription": "sub_7VDPOhhwJPMC3M" + }, + "metadata": { + "id": "0000000000000000000186cc" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + } +] \ No newline at end of file diff --git a/spec/fixtures/sub-test-27.json b/spec/fixtures/sub-test-27.json new file mode 100644 index 000000000..781dce86a --- /dev/null +++ b/spec/fixtures/sub-test-27.json @@ -0,0 +1,1340 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCylKaReE7xLUdQxifWaYp", + "card": { + "id": "card_17GCylKaReE7xLUd4WnpSJTw" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDPUDYQvLGYc6", + "alipay_accounts": { + "has_more": false + }, + "email": "user145@me.com", + "metadata": { + "id": "0000000000000000000186cf" + }, + "sources": { + "data": [ + { + "id": "card_17GCylKaReE7xLUd4WnpSJTw", + "customer": "cus_7VDPUDYQvLGYc6" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPUDYQvLGYc6", + "status": 200, + "response": { + "id": "cus_7VDPUDYQvLGYc6", + "alipay_accounts": { + "has_more": false + }, + "email": "user145@me.com", + "metadata": { + "id": "0000000000000000000186cf" + }, + "sources": { + "data": [ + { + "id": "card_17GCylKaReE7xLUd4WnpSJTw", + "customer": "cus_7VDPUDYQvLGYc6" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDPUDYQvLGYc6/subscriptions", + "status": 200, + "response": { + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPUDYQvLGYc6/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDP47YSQKI8ud", + "cancel_at_period_end": false, + "current_period_end": 1452365277, + "current_period_start": 1449686877, + "customer": "cus_7VDPUDYQvLGYc6", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPUDYQvLGYc6", + "subscription": "sub_7VDP47YSQKI8ud" + }, + "metadata": { + "id": "0000000000000000000186ce" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPUDYQvLGYc6", + "status": 200, + "response": { + "id": "cus_7VDPUDYQvLGYc6", + "alipay_accounts": { + "has_more": false + }, + "email": "user145@me.com", + "metadata": { + "id": "0000000000000000000186cf" + }, + "sources": { + "data": [ + { + "id": "card_17GCylKaReE7xLUd4WnpSJTw", + "customer": "cus_7VDPUDYQvLGYc6" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDP47YSQKI8ud", + "cancel_at_period_end": false, + "current_period_end": 1452365277, + "current_period_start": 1449686877, + "customer": "cus_7VDPUDYQvLGYc6", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPUDYQvLGYc6", + "subscription": "sub_7VDP47YSQKI8ud" + }, + "metadata": { + "id": "0000000000000000000186ce" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPUDYQvLGYc6/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDPabDqWaXXl4", + "cancel_at_period_end": false, + "current_period_end": 1452365279, + "current_period_start": 1449686879, + "customer": "cus_7VDPUDYQvLGYc6", + "metadata": { + "id": "0000000000000000000186cf" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices", + "status": 200, + "response": { + "data": [ + { + "id": "in_17GCypKaReE7xLUd2ptZ1BhX", + "customer": "cus_7VDPUDYQvLGYc6", + "lines": { + "data": [ + { + "id": "sub_7VDPabDqWaXXl4", + "amount": 999, + "metadata": { + "id": "0000000000000000000186cf" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 999, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDPabDqWaXXl4", + "total": 999 + }, + { + "id": "in_17GCynKaReE7xLUdhjiRodmo", + "customer": "cus_7VDPUDYQvLGYc6", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPUDYQvLGYc6", + "subscription": "sub_7VDP47YSQKI8ud" + }, + "lines": { + "data": [ + { + "id": "sub_7VDP47YSQKI8ud", + "amount": 999, + "metadata": { + "id": "0000000000000000000186ce" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDP47YSQKI8ud", + "total": 0 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPUDYQvLGYc6", + "status": 200, + "response": { + "id": "cus_7VDPUDYQvLGYc6", + "alipay_accounts": { + "has_more": false + }, + "email": "user145@me.com", + "metadata": { + "id": "0000000000000000000186cf" + }, + "sources": { + "data": [ + { + "id": "card_17GCylKaReE7xLUd4WnpSJTw", + "customer": "cus_7VDPUDYQvLGYc6" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDPabDqWaXXl4", + "cancel_at_period_end": false, + "current_period_end": 1452365279, + "current_period_start": 1449686879, + "customer": "cus_7VDPUDYQvLGYc6", + "metadata": { + "id": "0000000000000000000186cf" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDP47YSQKI8ud", + "cancel_at_period_end": false, + "current_period_end": 1452365277, + "current_period_start": 1449686877, + "customer": "cus_7VDPUDYQvLGYc6", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPUDYQvLGYc6", + "subscription": "sub_7VDP47YSQKI8ud" + }, + "metadata": { + "id": "0000000000000000000186ce" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPUDYQvLGYc6", + "status": 200, + "response": { + "id": "cus_7VDPUDYQvLGYc6", + "alipay_accounts": { + "has_more": false + }, + "email": "user145@me.com", + "metadata": { + "id": "0000000000000000000186cf" + }, + "sources": { + "data": [ + { + "id": "card_17GCylKaReE7xLUd4WnpSJTw", + "customer": "cus_7VDPUDYQvLGYc6" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDPabDqWaXXl4", + "cancel_at_period_end": false, + "current_period_end": 1452365279, + "current_period_start": 1449686879, + "customer": "cus_7VDPUDYQvLGYc6", + "metadata": { + "id": "0000000000000000000186cf" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDP47YSQKI8ud", + "cancel_at_period_end": false, + "current_period_end": 1452365277, + "current_period_start": 1449686877, + "customer": "cus_7VDPUDYQvLGYc6", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPUDYQvLGYc6", + "subscription": "sub_7VDP47YSQKI8ud" + }, + "metadata": { + "id": "0000000000000000000186ce" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCypKaReE7xLUd2ptZ1BhX", + "status": 200, + "response": { + "id": "in_17GCypKaReE7xLUd2ptZ1BhX", + "customer": "cus_7VDPUDYQvLGYc6", + "lines": { + "data": [ + { + "id": "sub_7VDPabDqWaXXl4", + "amount": 999, + "metadata": { + "id": "0000000000000000000186cf" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 999, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDPabDqWaXXl4", + "total": 999 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDPUDYQvLGYc6", + "status": 200, + "response": { + "id": "cus_7VDPUDYQvLGYc6", + "alipay_accounts": { + "has_more": false + }, + "email": "user145@me.com", + "metadata": { + "id": "0000000000000000000186cf" + }, + "sources": { + "data": [ + { + "id": "card_17GCylKaReE7xLUd4WnpSJTw", + "customer": "cus_7VDPUDYQvLGYc6" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDPabDqWaXXl4", + "cancel_at_period_end": false, + "current_period_end": 1452365279, + "current_period_start": 1449686879, + "customer": "cus_7VDPUDYQvLGYc6", + "metadata": { + "id": "0000000000000000000186cf" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDP47YSQKI8ud", + "cancel_at_period_end": false, + "current_period_end": 1452365277, + "current_period_start": 1449686877, + "customer": "cus_7VDPUDYQvLGYc6", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPUDYQvLGYc6", + "subscription": "sub_7VDP47YSQKI8ud" + }, + "metadata": { + "id": "0000000000000000000186ce" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCynKaReE7xLUdhjiRodmo", + "status": 200, + "response": { + "id": "in_17GCynKaReE7xLUdhjiRodmo", + "customer": "cus_7VDPUDYQvLGYc6", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPUDYQvLGYc6", + "subscription": "sub_7VDP47YSQKI8ud" + }, + "lines": { + "data": [ + { + "id": "sub_7VDP47YSQKI8ud", + "amount": 999, + "metadata": { + "id": "0000000000000000000186ce" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDP47YSQKI8ud", + "total": 0 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDPUDYQvLGYc6", + "status": 200, + "response": { + "id": "cus_7VDPUDYQvLGYc6", + "alipay_accounts": { + "has_more": false + }, + "email": "user145@me.com", + "metadata": { + "id": "0000000000000000000186cf" + }, + "sources": { + "data": [ + { + "id": "card_17GCylKaReE7xLUd4WnpSJTw", + "customer": "cus_7VDPUDYQvLGYc6" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDPabDqWaXXl4", + "cancel_at_period_end": false, + "current_period_end": 1452365279, + "current_period_start": 1449686879, + "customer": "cus_7VDPUDYQvLGYc6", + "metadata": { + "id": "0000000000000000000186cf" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDP47YSQKI8ud", + "cancel_at_period_end": false, + "current_period_end": 1452365277, + "current_period_start": 1449686877, + "customer": "cus_7VDPUDYQvLGYc6", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPUDYQvLGYc6", + "subscription": "sub_7VDP47YSQKI8ud" + }, + "metadata": { + "id": "0000000000000000000186ce" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDPUDYQvLGYc6/subscriptions", + "status": 200, + "response": { + "data": [ + { + "id": "sub_7VDPabDqWaXXl4", + "cancel_at_period_end": false, + "current_period_end": 1452365279, + "current_period_start": 1449686879, + "customer": "cus_7VDPUDYQvLGYc6", + "metadata": { + "id": "0000000000000000000186cf" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDP47YSQKI8ud", + "cancel_at_period_end": false, + "current_period_end": 1452365277, + "current_period_start": 1449686877, + "customer": "cus_7VDPUDYQvLGYc6", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPUDYQvLGYc6", + "subscription": "sub_7VDP47YSQKI8ud" + }, + "metadata": { + "id": "0000000000000000000186ce" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPUDYQvLGYc6/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDPI1RlxQ4P8P", + "cancel_at_period_end": false, + "current_period_end": 1452365282, + "current_period_start": 1449686882, + "customer": "cus_7VDPUDYQvLGYc6", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPUDYQvLGYc6", + "subscription": "sub_7VDPI1RlxQ4P8P" + }, + "metadata": { + "id": "0000000000000000000186cd" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPUDYQvLGYc6", + "status": 200, + "response": { + "id": "cus_7VDPUDYQvLGYc6", + "alipay_accounts": { + "has_more": false + }, + "email": "user145@me.com", + "metadata": { + "id": "0000000000000000000186cf" + }, + "sources": { + "data": [ + { + "id": "card_17GCylKaReE7xLUd4WnpSJTw", + "customer": "cus_7VDPUDYQvLGYc6" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDPI1RlxQ4P8P", + "cancel_at_period_end": false, + "current_period_end": 1452365282, + "current_period_start": 1449686882, + "customer": "cus_7VDPUDYQvLGYc6", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPUDYQvLGYc6", + "subscription": "sub_7VDPI1RlxQ4P8P" + }, + "metadata": { + "id": "0000000000000000000186cd" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDPabDqWaXXl4", + "cancel_at_period_end": false, + "current_period_end": 1452365279, + "current_period_start": 1449686879, + "customer": "cus_7VDPUDYQvLGYc6", + "metadata": { + "id": "0000000000000000000186cf" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDP47YSQKI8ud", + "cancel_at_period_end": false, + "current_period_end": 1452365277, + "current_period_start": 1449686877, + "customer": "cus_7VDPUDYQvLGYc6", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPUDYQvLGYc6", + "subscription": "sub_7VDP47YSQKI8ud" + }, + "metadata": { + "id": "0000000000000000000186ce" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDPUDYQvLGYc6/subscriptions", + "status": 200, + "response": { + "data": [ + { + "id": "sub_7VDPI1RlxQ4P8P", + "cancel_at_period_end": false, + "current_period_end": 1452365282, + "current_period_start": 1449686882, + "customer": "cus_7VDPUDYQvLGYc6", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPUDYQvLGYc6", + "subscription": "sub_7VDPI1RlxQ4P8P" + }, + "metadata": { + "id": "0000000000000000000186cd" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDPabDqWaXXl4", + "cancel_at_period_end": false, + "current_period_end": 1452365279, + "current_period_start": 1449686879, + "customer": "cus_7VDPUDYQvLGYc6", + "metadata": { + "id": "0000000000000000000186cf" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDP47YSQKI8ud", + "cancel_at_period_end": false, + "current_period_end": 1452365277, + "current_period_start": 1449686877, + "customer": "cus_7VDPUDYQvLGYc6", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPUDYQvLGYc6", + "subscription": "sub_7VDP47YSQKI8ud" + }, + "metadata": { + "id": "0000000000000000000186ce" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPUDYQvLGYc6/subscriptions/sub_7VDPabDqWaXXl4", + "status": 200, + "response": { + "id": "sub_7VDPabDqWaXXl4", + "cancel_at_period_end": false, + "current_period_end": 1452365279, + "current_period_start": 1449686879, + "customer": "cus_7VDPUDYQvLGYc6", + "metadata": { + "id": "0000000000000000000186cf" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 1798 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/invoices", + "status": 200, + "response": { + "id": "in_17GCywKaReE7xLUdKZ3PKEqr", + "customer": "cus_7VDPUDYQvLGYc6", + "lines": { + "data": [ + { + "id": "ii_17GCyvKaReE7xLUd2Bcm0Z0X", + "amount": -999, + "description": "Unused time on 999 x Incremental after 09 Dec 2015", + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": true, + "quantity": 999, + "subscription": "sub_7VDPabDqWaXXl4", + "type": "invoiceitem" + }, + { + "id": "ii_17GCyvKaReE7xLUdd78npVMx", + "amount": 1798, + "description": "Remaining time on 1798 x Incremental after 09 Dec 2015", + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": true, + "quantity": 1798, + "subscription": "sub_7VDPabDqWaXXl4", + "type": "invoiceitem" + } + ], + "has_more": false + }, + "paid": false, + "total": 799 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices", + "status": 200, + "response": { + "data": [ + { + "id": "in_17GCywKaReE7xLUdKZ3PKEqr", + "customer": "cus_7VDPUDYQvLGYc6", + "lines": { + "data": [ + { + "id": "ii_17GCyvKaReE7xLUd2Bcm0Z0X", + "amount": -999, + "description": "Unused time on 999 x Incremental after 09 Dec 2015", + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": true, + "quantity": 999, + "subscription": "sub_7VDPabDqWaXXl4", + "type": "invoiceitem" + }, + { + "id": "ii_17GCyvKaReE7xLUdd78npVMx", + "amount": 1798, + "description": "Remaining time on 1798 x Incremental after 09 Dec 2015", + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": true, + "quantity": 1798, + "subscription": "sub_7VDPabDqWaXXl4", + "type": "invoiceitem" + } + ], + "has_more": false + }, + "paid": false, + "total": 799 + }, + { + "id": "in_17GCysKaReE7xLUdAVJS5v5H", + "customer": "cus_7VDPUDYQvLGYc6", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPUDYQvLGYc6", + "subscription": "sub_7VDPI1RlxQ4P8P" + }, + "lines": { + "data": [ + { + "id": "sub_7VDPI1RlxQ4P8P", + "amount": 999, + "metadata": { + "id": "0000000000000000000186cd" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDPI1RlxQ4P8P", + "total": 0 + }, + { + "id": "in_17GCypKaReE7xLUd2ptZ1BhX", + "customer": "cus_7VDPUDYQvLGYc6", + "lines": { + "data": [ + { + "id": "sub_7VDPabDqWaXXl4", + "amount": 999, + "metadata": { + "id": "0000000000000000000186cf" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 999, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDPabDqWaXXl4", + "total": 999 + }, + { + "id": "in_17GCynKaReE7xLUdhjiRodmo", + "customer": "cus_7VDPUDYQvLGYc6", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPUDYQvLGYc6", + "subscription": "sub_7VDP47YSQKI8ud" + }, + "lines": { + "data": [ + { + "id": "sub_7VDP47YSQKI8ud", + "amount": 999, + "metadata": { + "id": "0000000000000000000186ce" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDP47YSQKI8ud", + "total": 0 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPUDYQvLGYc6", + "status": 200, + "response": { + "id": "cus_7VDPUDYQvLGYc6", + "alipay_accounts": { + "has_more": false + }, + "email": "user145@me.com", + "metadata": { + "id": "0000000000000000000186cf" + }, + "sources": { + "data": [ + { + "id": "card_17GCylKaReE7xLUd4WnpSJTw", + "customer": "cus_7VDPUDYQvLGYc6" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDPabDqWaXXl4", + "cancel_at_period_end": false, + "current_period_end": 1452365279, + "current_period_start": 1449686879, + "customer": "cus_7VDPUDYQvLGYc6", + "metadata": { + "id": "0000000000000000000186cf" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 1798 + }, + { + "id": "sub_7VDPI1RlxQ4P8P", + "cancel_at_period_end": false, + "current_period_end": 1452365282, + "current_period_start": 1449686882, + "customer": "cus_7VDPUDYQvLGYc6", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPUDYQvLGYc6", + "subscription": "sub_7VDPI1RlxQ4P8P" + }, + "metadata": { + "id": "0000000000000000000186cd" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDP47YSQKI8ud", + "cancel_at_period_end": false, + "current_period_end": 1452365277, + "current_period_start": 1449686877, + "customer": "cus_7VDPUDYQvLGYc6", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPUDYQvLGYc6", + "subscription": "sub_7VDP47YSQKI8ud" + }, + "metadata": { + "id": "0000000000000000000186ce" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCywKaReE7xLUdKZ3PKEqr", + "status": 200, + "response": { + "id": "in_17GCywKaReE7xLUdKZ3PKEqr", + "customer": "cus_7VDPUDYQvLGYc6", + "lines": { + "data": [ + { + "id": "ii_17GCyvKaReE7xLUd2Bcm0Z0X", + "amount": -999, + "description": "Unused time on 999 x Incremental after 09 Dec 2015", + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": true, + "quantity": 999, + "subscription": "sub_7VDPabDqWaXXl4", + "type": "invoiceitem" + }, + { + "id": "ii_17GCyvKaReE7xLUdd78npVMx", + "amount": 1798, + "description": "Remaining time on 1798 x Incremental after 09 Dec 2015", + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": true, + "quantity": 1798, + "subscription": "sub_7VDPabDqWaXXl4", + "type": "invoiceitem" + } + ], + "has_more": false + }, + "paid": false, + "total": 799 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCysKaReE7xLUdAVJS5v5H", + "status": 200, + "response": { + "id": "in_17GCysKaReE7xLUdAVJS5v5H", + "customer": "cus_7VDPUDYQvLGYc6", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPUDYQvLGYc6", + "subscription": "sub_7VDPI1RlxQ4P8P" + }, + "lines": { + "data": [ + { + "id": "sub_7VDPI1RlxQ4P8P", + "amount": 999, + "metadata": { + "id": "0000000000000000000186cd" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDPI1RlxQ4P8P", + "total": 0 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices", + "status": 200, + "response": { + "data": [ + { + "id": "in_17GCywKaReE7xLUdKZ3PKEqr", + "customer": "cus_7VDPUDYQvLGYc6", + "lines": { + "data": [ + { + "id": "ii_17GCyvKaReE7xLUd2Bcm0Z0X", + "amount": -999, + "description": "Unused time on 999 x Incremental after 09 Dec 2015", + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": true, + "quantity": 999, + "subscription": "sub_7VDPabDqWaXXl4", + "type": "invoiceitem" + }, + { + "id": "ii_17GCyvKaReE7xLUdd78npVMx", + "amount": 1798, + "description": "Remaining time on 1798 x Incremental after 09 Dec 2015", + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": true, + "quantity": 1798, + "subscription": "sub_7VDPabDqWaXXl4", + "type": "invoiceitem" + } + ], + "has_more": false + }, + "paid": false, + "total": 799 + }, + { + "id": "in_17GCysKaReE7xLUdAVJS5v5H", + "customer": "cus_7VDPUDYQvLGYc6", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPUDYQvLGYc6", + "subscription": "sub_7VDPI1RlxQ4P8P" + }, + "lines": { + "data": [ + { + "id": "sub_7VDPI1RlxQ4P8P", + "amount": 999, + "metadata": { + "id": "0000000000000000000186cd" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDPI1RlxQ4P8P", + "total": 0 + }, + { + "id": "in_17GCypKaReE7xLUd2ptZ1BhX", + "customer": "cus_7VDPUDYQvLGYc6", + "lines": { + "data": [ + { + "id": "sub_7VDPabDqWaXXl4", + "amount": 999, + "metadata": { + "id": "0000000000000000000186cf" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 999, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDPabDqWaXXl4", + "total": 999 + }, + { + "id": "in_17GCynKaReE7xLUdhjiRodmo", + "customer": "cus_7VDPUDYQvLGYc6", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPUDYQvLGYc6", + "subscription": "sub_7VDP47YSQKI8ud" + }, + "lines": { + "data": [ + { + "id": "sub_7VDP47YSQKI8ud", + "amount": 999, + "metadata": { + "id": "0000000000000000000186ce" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDP47YSQKI8ud", + "total": 0 + } + ], + "has_more": false + } + } +] \ No newline at end of file diff --git a/spec/fixtures/sub-test-28.json b/spec/fixtures/sub-test-28.json new file mode 100644 index 000000000..548275604 --- /dev/null +++ b/spec/fixtures/sub-test-28.json @@ -0,0 +1,120 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCz0KaReE7xLUdfGmoH6iD", + "card": { + "id": "card_17GCz0KaReE7xLUdbv6dUvYF" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDPyzg6wmIScl", + "alipay_accounts": { + "has_more": false + }, + "email": "user146@me.com", + "metadata": { + "id": "0000000000000000000186d0" + }, + "sources": { + "data": [ + { + "id": "card_17GCz0KaReE7xLUdbv6dUvYF", + "customer": "cus_7VDPyzg6wmIScl" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPyzg6wmIScl", + "status": 200, + "response": { + "id": "cus_7VDPyzg6wmIScl", + "alipay_accounts": { + "has_more": false + }, + "email": "user146@me.com", + "metadata": { + "id": "0000000000000000000186d0" + }, + "sources": { + "data": [ + { + "id": "card_17GCz0KaReE7xLUdbv6dUvYF", + "customer": "cus_7VDPyzg6wmIScl" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPyzg6wmIScl", + "status": 200, + "response": { + "id": "cus_7VDPyzg6wmIScl", + "alipay_accounts": { + "has_more": false + }, + "email": "user146@me.com", + "metadata": { + "id": "0000000000000000000186d0" + }, + "sources": { + "data": [ + { + "id": "card_17GCz0KaReE7xLUdbv6dUvYF", + "customer": "cus_7VDPyzg6wmIScl" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPyzg6wmIScl/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDPCLPadwxF7P", + "cancel_at_period_end": false, + "current_period_end": 1452365292, + "current_period_start": 1449686892, + "customer": "cus_7VDPyzg6wmIScl", + "metadata": { + "id": "0000000000000000000186d0" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 0 + } + } +] \ No newline at end of file diff --git a/spec/fixtures/sub-test-29.json b/spec/fixtures/sub-test-29.json new file mode 100644 index 000000000..a08c9bf22 --- /dev/null +++ b/spec/fixtures/sub-test-29.json @@ -0,0 +1,736 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCz3KaReE7xLUd6y2AQlmf", + "card": { + "id": "card_17GCz3KaReE7xLUdormzFUHD" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDPo3YNU8ZYnv", + "alipay_accounts": { + "has_more": false + }, + "email": "user148@me.com", + "metadata": { + "id": "0000000000000000000186d2" + }, + "sources": { + "data": [ + { + "id": "card_17GCz3KaReE7xLUdormzFUHD", + "customer": "cus_7VDPo3YNU8ZYnv" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPo3YNU8ZYnv", + "status": 200, + "response": { + "id": "cus_7VDPo3YNU8ZYnv", + "alipay_accounts": { + "has_more": false + }, + "email": "user148@me.com", + "metadata": { + "id": "0000000000000000000186d2" + }, + "sources": { + "data": [ + { + "id": "card_17GCz3KaReE7xLUdormzFUHD", + "customer": "cus_7VDPo3YNU8ZYnv" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDPo3YNU8ZYnv/subscriptions", + "status": 200, + "response": { + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPo3YNU8ZYnv/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDPg3LCQ5CzTP", + "cancel_at_period_end": false, + "current_period_end": 1452365296, + "current_period_start": 1449686896, + "customer": "cus_7VDPo3YNU8ZYnv", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPo3YNU8ZYnv", + "subscription": "sub_7VDPg3LCQ5CzTP" + }, + "metadata": { + "id": "0000000000000000000186d1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPo3YNU8ZYnv", + "status": 200, + "response": { + "id": "cus_7VDPo3YNU8ZYnv", + "alipay_accounts": { + "has_more": false + }, + "email": "user148@me.com", + "metadata": { + "id": "0000000000000000000186d2" + }, + "sources": { + "data": [ + { + "id": "card_17GCz3KaReE7xLUdormzFUHD", + "customer": "cus_7VDPo3YNU8ZYnv" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDPg3LCQ5CzTP", + "cancel_at_period_end": false, + "current_period_end": 1452365296, + "current_period_start": 1449686896, + "customer": "cus_7VDPo3YNU8ZYnv", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPo3YNU8ZYnv", + "subscription": "sub_7VDPg3LCQ5CzTP" + }, + "metadata": { + "id": "0000000000000000000186d1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPo3YNU8ZYnv/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDPO0Lo0o3MoJ", + "cancel_at_period_end": false, + "current_period_end": 1452365297, + "current_period_start": 1449686897, + "customer": "cus_7VDPo3YNU8ZYnv", + "metadata": { + "id": "0000000000000000000186d2" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices", + "status": 200, + "response": { + "data": [ + { + "id": "in_17GCz7KaReE7xLUdiVEGMsR1", + "customer": "cus_7VDPo3YNU8ZYnv", + "lines": { + "data": [ + { + "id": "sub_7VDPO0Lo0o3MoJ", + "amount": 999, + "metadata": { + "id": "0000000000000000000186d2" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 999, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDPO0Lo0o3MoJ", + "total": 999 + }, + { + "id": "in_17GCz6KaReE7xLUd2J7e0xQ3", + "customer": "cus_7VDPo3YNU8ZYnv", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPo3YNU8ZYnv", + "subscription": "sub_7VDPg3LCQ5CzTP" + }, + "lines": { + "data": [ + { + "id": "sub_7VDPg3LCQ5CzTP", + "amount": 999, + "metadata": { + "id": "0000000000000000000186d1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDPg3LCQ5CzTP", + "total": 0 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPo3YNU8ZYnv", + "status": 200, + "response": { + "id": "cus_7VDPo3YNU8ZYnv", + "alipay_accounts": { + "has_more": false + }, + "email": "user148@me.com", + "metadata": { + "id": "0000000000000000000186d2" + }, + "sources": { + "data": [ + { + "id": "card_17GCz3KaReE7xLUdormzFUHD", + "customer": "cus_7VDPo3YNU8ZYnv" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDPO0Lo0o3MoJ", + "cancel_at_period_end": false, + "current_period_end": 1452365297, + "current_period_start": 1449686897, + "customer": "cus_7VDPo3YNU8ZYnv", + "metadata": { + "id": "0000000000000000000186d2" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDPg3LCQ5CzTP", + "cancel_at_period_end": false, + "current_period_end": 1452365296, + "current_period_start": 1449686896, + "customer": "cus_7VDPo3YNU8ZYnv", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPo3YNU8ZYnv", + "subscription": "sub_7VDPg3LCQ5CzTP" + }, + "metadata": { + "id": "0000000000000000000186d1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCz7KaReE7xLUdiVEGMsR1", + "status": 200, + "response": { + "id": "in_17GCz7KaReE7xLUdiVEGMsR1", + "customer": "cus_7VDPo3YNU8ZYnv", + "lines": { + "data": [ + { + "id": "sub_7VDPO0Lo0o3MoJ", + "amount": 999, + "metadata": { + "id": "0000000000000000000186d2" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 999, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDPO0Lo0o3MoJ", + "total": 999 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPo3YNU8ZYnv", + "status": 200, + "response": { + "id": "cus_7VDPo3YNU8ZYnv", + "alipay_accounts": { + "has_more": false + }, + "email": "user148@me.com", + "metadata": { + "id": "0000000000000000000186d2" + }, + "sources": { + "data": [ + { + "id": "card_17GCz3KaReE7xLUdormzFUHD", + "customer": "cus_7VDPo3YNU8ZYnv" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDPO0Lo0o3MoJ", + "cancel_at_period_end": false, + "current_period_end": 1452365297, + "current_period_start": 1449686897, + "customer": "cus_7VDPo3YNU8ZYnv", + "metadata": { + "id": "0000000000000000000186d2" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDPg3LCQ5CzTP", + "cancel_at_period_end": false, + "current_period_end": 1452365296, + "current_period_start": 1449686896, + "customer": "cus_7VDPo3YNU8ZYnv", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPo3YNU8ZYnv", + "subscription": "sub_7VDPg3LCQ5CzTP" + }, + "metadata": { + "id": "0000000000000000000186d1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDPo3YNU8ZYnv", + "status": 200, + "response": { + "id": "cus_7VDPo3YNU8ZYnv", + "alipay_accounts": { + "has_more": false + }, + "email": "user148@me.com", + "metadata": { + "id": "0000000000000000000186d2" + }, + "sources": { + "data": [ + { + "id": "card_17GCz3KaReE7xLUdormzFUHD", + "customer": "cus_7VDPo3YNU8ZYnv" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDPO0Lo0o3MoJ", + "cancel_at_period_end": false, + "current_period_end": 1452365297, + "current_period_start": 1449686897, + "customer": "cus_7VDPo3YNU8ZYnv", + "metadata": { + "id": "0000000000000000000186d2" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDPg3LCQ5CzTP", + "cancel_at_period_end": false, + "current_period_end": 1452365296, + "current_period_start": 1449686896, + "customer": "cus_7VDPo3YNU8ZYnv", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPo3YNU8ZYnv", + "subscription": "sub_7VDPg3LCQ5CzTP" + }, + "metadata": { + "id": "0000000000000000000186d1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCz6KaReE7xLUd2J7e0xQ3", + "status": 200, + "response": { + "id": "in_17GCz6KaReE7xLUd2J7e0xQ3", + "customer": "cus_7VDPo3YNU8ZYnv", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPo3YNU8ZYnv", + "subscription": "sub_7VDPg3LCQ5CzTP" + }, + "lines": { + "data": [ + { + "id": "sub_7VDPg3LCQ5CzTP", + "amount": 999, + "metadata": { + "id": "0000000000000000000186d1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDPg3LCQ5CzTP", + "total": 0 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDPo3YNU8ZYnv/subscriptions/sub_7VDPO0Lo0o3MoJ", + "status": 200, + "response": { + "id": "sub_7VDPO0Lo0o3MoJ", + "cancel_at_period_end": false, + "current_period_end": 1452365297, + "current_period_start": 1449686897, + "customer": "cus_7VDPo3YNU8ZYnv", + "metadata": { + "id": "0000000000000000000186d2" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDPo3YNU8ZYnv/subscriptions/sub_7VDPg3LCQ5CzTP", + "status": 200, + "response": { + "id": "sub_7VDPg3LCQ5CzTP", + "cancel_at_period_end": false, + "current_period_end": 1452365296, + "current_period_start": 1449686896, + "customer": "cus_7VDPo3YNU8ZYnv", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPo3YNU8ZYnv", + "subscription": "sub_7VDPg3LCQ5CzTP" + }, + "metadata": { + "id": "0000000000000000000186d1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCzBKaReE7xLUdbvnLBdzm", + "card": { + "id": "card_17GCzBKaReE7xLUdrGaHl1xn" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPo3YNU8ZYnv", + "status": 200, + "response": { + "id": "cus_7VDPo3YNU8ZYnv", + "alipay_accounts": { + "has_more": false + }, + "email": "user148@me.com", + "metadata": { + "id": "0000000000000000000186d2" + }, + "sources": { + "data": [ + { + "id": "card_17GCzBKaReE7xLUdrGaHl1xn", + "customer": "cus_7VDPo3YNU8ZYnv" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDPO0Lo0o3MoJ", + "cancel_at_period_end": false, + "current_period_end": 1452365297, + "current_period_start": 1449686897, + "customer": "cus_7VDPo3YNU8ZYnv", + "metadata": { + "id": "0000000000000000000186d2" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDPg3LCQ5CzTP", + "cancel_at_period_end": false, + "current_period_end": 1452365296, + "current_period_start": 1449686896, + "customer": "cus_7VDPo3YNU8ZYnv", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPo3YNU8ZYnv", + "subscription": "sub_7VDPg3LCQ5CzTP" + }, + "metadata": { + "id": "0000000000000000000186d1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDPo3YNU8ZYnv/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDQOwKvASnwSe", + "cancel_at_period_end": false, + "current_period_end": 1452365302, + "current_period_start": 1449686902, + "customer": "cus_7VDPo3YNU8ZYnv", + "metadata": { + "id": "0000000000000000000186d2" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDPo3YNU8ZYnv/subscriptions", + "status": 200, + "response": { + "data": [ + { + "id": "sub_7VDQOwKvASnwSe", + "cancel_at_period_end": false, + "current_period_end": 1452365302, + "current_period_start": 1449686902, + "customer": "cus_7VDPo3YNU8ZYnv", + "metadata": { + "id": "0000000000000000000186d2" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDPO0Lo0o3MoJ", + "cancel_at_period_end": false, + "current_period_end": 1452365297, + "current_period_start": 1449686897, + "customer": "cus_7VDPo3YNU8ZYnv", + "metadata": { + "id": "0000000000000000000186d2" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 999 + }, + { + "id": "sub_7VDPg3LCQ5CzTP", + "cancel_at_period_end": false, + "current_period_end": 1452365296, + "current_period_start": 1449686896, + "customer": "cus_7VDPo3YNU8ZYnv", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDPo3YNU8ZYnv", + "subscription": "sub_7VDPg3LCQ5CzTP" + }, + "metadata": { + "id": "0000000000000000000186d1" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } +] \ No newline at end of file diff --git a/spec/fixtures/sub-test-30.json b/spec/fixtures/sub-test-30.json new file mode 100644 index 000000000..222ffeb9e --- /dev/null +++ b/spec/fixtures/sub-test-30.json @@ -0,0 +1,256 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDQwLJfXCoq4W", + "alipay_accounts": { + "has_more": false + }, + "email": "user149@me.com", + "metadata": { + "id": "0000000000000000000186d3" + }, + "sources": { + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQwLJfXCoq4W", + "status": 200, + "response": { + "id": "cus_7VDQwLJfXCoq4W", + "alipay_accounts": { + "has_more": false + }, + "email": "user149@me.com", + "metadata": { + "id": "0000000000000000000186d3" + }, + "sources": { + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQwLJfXCoq4W/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDQkxjwBQw0Qx", + "cancel_at_period_end": false, + "current_period_end": 1452365304, + "current_period_start": 1449686904, + "customer": "cus_7VDQwLJfXCoq4W", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQwLJfXCoq4W", + "subscription": "sub_7VDQkxjwBQw0Qx" + }, + "metadata": { + "id": "0000000000000000000186d3" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCzFKaReE7xLUd8H2nXt45", + "card": { + "id": "card_17GCzFKaReE7xLUdZfftdcPf" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQwLJfXCoq4W", + "status": 200, + "response": { + "id": "cus_7VDQwLJfXCoq4W", + "alipay_accounts": { + "has_more": false + }, + "email": "user149@me.com", + "metadata": { + "id": "0000000000000000000186d3" + }, + "sources": { + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDQkxjwBQw0Qx", + "cancel_at_period_end": false, + "current_period_end": 1452365304, + "current_period_start": 1449686904, + "customer": "cus_7VDQwLJfXCoq4W", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQwLJfXCoq4W", + "subscription": "sub_7VDQkxjwBQw0Qx" + }, + "metadata": { + "id": "0000000000000000000186d3" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQwLJfXCoq4W", + "status": 200, + "response": { + "id": "cus_7VDQwLJfXCoq4W", + "alipay_accounts": { + "has_more": false + }, + "email": "user149@me.com", + "metadata": { + "id": "0000000000000000000186d3" + }, + "sources": { + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDQkxjwBQw0Qx", + "cancel_at_period_end": false, + "current_period_end": 1452365304, + "current_period_start": 1449686904, + "customer": "cus_7VDQwLJfXCoq4W", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQwLJfXCoq4W", + "subscription": "sub_7VDQkxjwBQw0Qx" + }, + "metadata": { + "id": "0000000000000000000186d3" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDQlxv5S0eBtk", + "alipay_accounts": { + "has_more": false + }, + "email": "user150@me.com", + "metadata": { + "id": "0000000000000000000186d4" + }, + "sources": { + "data": [ + { + "id": "card_17GCzFKaReE7xLUdZfftdcPf", + "customer": "cus_7VDQlxv5S0eBtk" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQlxv5S0eBtk", + "status": 200, + "response": { + "id": "cus_7VDQlxv5S0eBtk", + "alipay_accounts": { + "has_more": false + }, + "email": "user150@me.com", + "metadata": { + "id": "0000000000000000000186d4" + }, + "sources": { + "data": [ + { + "id": "card_17GCzFKaReE7xLUdZfftdcPf", + "customer": "cus_7VDQlxv5S0eBtk" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQlxv5S0eBtk/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDQXC0aQzjUhm", + "cancel_at_period_end": false, + "current_period_end": 1452365307, + "current_period_start": 1449686907, + "customer": "cus_7VDQlxv5S0eBtk", + "metadata": { + "id": "0000000000000000000186d4" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 0 + } + } +] \ No newline at end of file diff --git a/spec/fixtures/sub-test-31.json b/spec/fixtures/sub-test-31.json new file mode 100644 index 000000000..e1ec8a1f0 --- /dev/null +++ b/spec/fixtures/sub-test-31.json @@ -0,0 +1,842 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCzIKaReE7xLUdpd3xMQM2", + "card": { + "id": "card_17GCzIKaReE7xLUdoKnZvG6Z" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDQreyG0YOAk3", + "alipay_accounts": { + "has_more": false + }, + "email": "user153@me.com", + "metadata": { + "id": "0000000000000000000186d7" + }, + "sources": { + "data": [ + { + "id": "card_17GCzIKaReE7xLUdoKnZvG6Z", + "customer": "cus_7VDQreyG0YOAk3" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQreyG0YOAk3/subscriptions", + "status": 200, + "response": { + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQreyG0YOAk3", + "status": 200, + "response": { + "id": "cus_7VDQreyG0YOAk3", + "alipay_accounts": { + "has_more": false + }, + "email": "user153@me.com", + "metadata": { + "id": "0000000000000000000186d7" + }, + "sources": { + "data": [ + { + "id": "card_17GCzIKaReE7xLUdoKnZvG6Z", + "customer": "cus_7VDQreyG0YOAk3" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQreyG0YOAk3/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDQN2xmA3qRv1", + "cancel_at_period_end": false, + "current_period_end": 1452365309, + "current_period_start": 1449686909, + "customer": "cus_7VDQreyG0YOAk3", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQreyG0YOAk3", + "subscription": "sub_7VDQN2xmA3qRv1" + }, + "metadata": { + "id": "0000000000000000000186d5" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQreyG0YOAk3/subscriptions", + "status": 200, + "response": { + "data": [ + { + "id": "sub_7VDQN2xmA3qRv1", + "cancel_at_period_end": false, + "current_period_end": 1452365309, + "current_period_start": 1449686909, + "customer": "cus_7VDQreyG0YOAk3", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQreyG0YOAk3", + "subscription": "sub_7VDQN2xmA3qRv1" + }, + "metadata": { + "id": "0000000000000000000186d5" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQreyG0YOAk3/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDQ2wKmp32Bog", + "cancel_at_period_end": false, + "current_period_end": 1452365311, + "current_period_start": 1449686911, + "customer": "cus_7VDQreyG0YOAk3", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQreyG0YOAk3", + "subscription": "sub_7VDQ2wKmp32Bog" + }, + "metadata": { + "id": "0000000000000000000186d6" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQreyG0YOAk3", + "status": 200, + "response": { + "id": "cus_7VDQreyG0YOAk3", + "alipay_accounts": { + "has_more": false + }, + "email": "user153@me.com", + "metadata": { + "id": "0000000000000000000186d7" + }, + "sources": { + "data": [ + { + "id": "card_17GCzIKaReE7xLUdoKnZvG6Z", + "customer": "cus_7VDQreyG0YOAk3" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDQ2wKmp32Bog", + "cancel_at_period_end": false, + "current_period_end": 1452365311, + "current_period_start": 1449686911, + "customer": "cus_7VDQreyG0YOAk3", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQreyG0YOAk3", + "subscription": "sub_7VDQ2wKmp32Bog" + }, + "metadata": { + "id": "0000000000000000000186d6" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQN2xmA3qRv1", + "cancel_at_period_end": false, + "current_period_end": 1452365309, + "current_period_start": 1449686909, + "customer": "cus_7VDQreyG0YOAk3", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQreyG0YOAk3", + "subscription": "sub_7VDQN2xmA3qRv1" + }, + "metadata": { + "id": "0000000000000000000186d5" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQreyG0YOAk3/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDQDLhx5W5nrE", + "cancel_at_period_end": false, + "current_period_end": 1452365312, + "current_period_start": 1449686912, + "customer": "cus_7VDQreyG0YOAk3", + "metadata": { + "id": "0000000000000000000186d7" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 1798 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices", + "status": 200, + "response": { + "data": [ + { + "id": "in_17GCzMKaReE7xLUdi37Cczto", + "customer": "cus_7VDQreyG0YOAk3", + "lines": { + "data": [ + { + "id": "sub_7VDQDLhx5W5nrE", + "amount": 1798, + "metadata": { + "id": "0000000000000000000186d7" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 1798, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDQDLhx5W5nrE", + "total": 1798 + }, + { + "id": "in_17GCzLKaReE7xLUdL9gwdOLR", + "customer": "cus_7VDQreyG0YOAk3", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQreyG0YOAk3", + "subscription": "sub_7VDQ2wKmp32Bog" + }, + "lines": { + "data": [ + { + "id": "sub_7VDQ2wKmp32Bog", + "amount": 999, + "metadata": { + "id": "0000000000000000000186d6" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDQ2wKmp32Bog", + "total": 0 + }, + { + "id": "in_17GCzJKaReE7xLUdLZGrlA16", + "customer": "cus_7VDQreyG0YOAk3", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQreyG0YOAk3", + "subscription": "sub_7VDQN2xmA3qRv1" + }, + "lines": { + "data": [ + { + "id": "sub_7VDQN2xmA3qRv1", + "amount": 999, + "metadata": { + "id": "0000000000000000000186d5" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDQN2xmA3qRv1", + "total": 0 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQreyG0YOAk3", + "status": 200, + "response": { + "id": "cus_7VDQreyG0YOAk3", + "alipay_accounts": { + "has_more": false + }, + "email": "user153@me.com", + "metadata": { + "id": "0000000000000000000186d7" + }, + "sources": { + "data": [ + { + "id": "card_17GCzIKaReE7xLUdoKnZvG6Z", + "customer": "cus_7VDQreyG0YOAk3" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDQDLhx5W5nrE", + "cancel_at_period_end": false, + "current_period_end": 1452365312, + "current_period_start": 1449686912, + "customer": "cus_7VDQreyG0YOAk3", + "metadata": { + "id": "0000000000000000000186d7" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 1798 + }, + { + "id": "sub_7VDQ2wKmp32Bog", + "cancel_at_period_end": false, + "current_period_end": 1452365311, + "current_period_start": 1449686911, + "customer": "cus_7VDQreyG0YOAk3", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQreyG0YOAk3", + "subscription": "sub_7VDQ2wKmp32Bog" + }, + "metadata": { + "id": "0000000000000000000186d6" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQN2xmA3qRv1", + "cancel_at_period_end": false, + "current_period_end": 1452365309, + "current_period_start": 1449686909, + "customer": "cus_7VDQreyG0YOAk3", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQreyG0YOAk3", + "subscription": "sub_7VDQN2xmA3qRv1" + }, + "metadata": { + "id": "0000000000000000000186d5" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQreyG0YOAk3", + "status": 200, + "response": { + "id": "cus_7VDQreyG0YOAk3", + "alipay_accounts": { + "has_more": false + }, + "email": "user153@me.com", + "metadata": { + "id": "0000000000000000000186d7" + }, + "sources": { + "data": [ + { + "id": "card_17GCzIKaReE7xLUdoKnZvG6Z", + "customer": "cus_7VDQreyG0YOAk3" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDQDLhx5W5nrE", + "cancel_at_period_end": false, + "current_period_end": 1452365312, + "current_period_start": 1449686912, + "customer": "cus_7VDQreyG0YOAk3", + "metadata": { + "id": "0000000000000000000186d7" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 1798 + }, + { + "id": "sub_7VDQ2wKmp32Bog", + "cancel_at_period_end": false, + "current_period_end": 1452365311, + "current_period_start": 1449686911, + "customer": "cus_7VDQreyG0YOAk3", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQreyG0YOAk3", + "subscription": "sub_7VDQ2wKmp32Bog" + }, + "metadata": { + "id": "0000000000000000000186d6" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQN2xmA3qRv1", + "cancel_at_period_end": false, + "current_period_end": 1452365309, + "current_period_start": 1449686909, + "customer": "cus_7VDQreyG0YOAk3", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQreyG0YOAk3", + "subscription": "sub_7VDQN2xmA3qRv1" + }, + "metadata": { + "id": "0000000000000000000186d5" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCzMKaReE7xLUdi37Cczto", + "status": 200, + "response": { + "id": "in_17GCzMKaReE7xLUdi37Cczto", + "customer": "cus_7VDQreyG0YOAk3", + "lines": { + "data": [ + { + "id": "sub_7VDQDLhx5W5nrE", + "amount": 1798, + "metadata": { + "id": "0000000000000000000186d7" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 1798, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDQDLhx5W5nrE", + "total": 1798 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQreyG0YOAk3", + "status": 200, + "response": { + "id": "cus_7VDQreyG0YOAk3", + "alipay_accounts": { + "has_more": false + }, + "email": "user153@me.com", + "metadata": { + "id": "0000000000000000000186d7" + }, + "sources": { + "data": [ + { + "id": "card_17GCzIKaReE7xLUdoKnZvG6Z", + "customer": "cus_7VDQreyG0YOAk3" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDQDLhx5W5nrE", + "cancel_at_period_end": false, + "current_period_end": 1452365312, + "current_period_start": 1449686912, + "customer": "cus_7VDQreyG0YOAk3", + "metadata": { + "id": "0000000000000000000186d7" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 1798 + }, + { + "id": "sub_7VDQ2wKmp32Bog", + "cancel_at_period_end": false, + "current_period_end": 1452365311, + "current_period_start": 1449686911, + "customer": "cus_7VDQreyG0YOAk3", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQreyG0YOAk3", + "subscription": "sub_7VDQ2wKmp32Bog" + }, + "metadata": { + "id": "0000000000000000000186d6" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQN2xmA3qRv1", + "cancel_at_period_end": false, + "current_period_end": 1452365309, + "current_period_start": 1449686909, + "customer": "cus_7VDQreyG0YOAk3", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQreyG0YOAk3", + "subscription": "sub_7VDQN2xmA3qRv1" + }, + "metadata": { + "id": "0000000000000000000186d5" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCzLKaReE7xLUdL9gwdOLR", + "status": 200, + "response": { + "id": "in_17GCzLKaReE7xLUdL9gwdOLR", + "customer": "cus_7VDQreyG0YOAk3", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQreyG0YOAk3", + "subscription": "sub_7VDQ2wKmp32Bog" + }, + "lines": { + "data": [ + { + "id": "sub_7VDQ2wKmp32Bog", + "amount": 999, + "metadata": { + "id": "0000000000000000000186d6" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDQ2wKmp32Bog", + "total": 0 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCzJKaReE7xLUdLZGrlA16", + "status": 200, + "response": { + "id": "in_17GCzJKaReE7xLUdLZGrlA16", + "customer": "cus_7VDQreyG0YOAk3", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQreyG0YOAk3", + "subscription": "sub_7VDQN2xmA3qRv1" + }, + "lines": { + "data": [ + { + "id": "sub_7VDQN2xmA3qRv1", + "amount": 999, + "metadata": { + "id": "0000000000000000000186d5" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDQN2xmA3qRv1", + "total": 0 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQreyG0YOAk3/subscriptions/sub_7VDQDLhx5W5nrE", + "status": 200, + "response": { + "id": "sub_7VDQDLhx5W5nrE", + "cancel_at_period_end": false, + "current_period_end": 1452365312, + "current_period_start": 1449686912, + "customer": "cus_7VDQreyG0YOAk3", + "metadata": { + "id": "0000000000000000000186d7" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 1798 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQreyG0YOAk3/subscriptions/sub_7VDQ2wKmp32Bog", + "status": 200, + "response": { + "id": "sub_7VDQ2wKmp32Bog", + "cancel_at_period_end": false, + "current_period_end": 1452365311, + "current_period_start": 1449686911, + "customer": "cus_7VDQreyG0YOAk3", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQreyG0YOAk3", + "subscription": "sub_7VDQ2wKmp32Bog" + }, + "metadata": { + "id": "0000000000000000000186d6" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQreyG0YOAk3/subscriptions/sub_7VDQDLhx5W5nrE", + "status": 200, + "response": { + "id": "sub_7VDQDLhx5W5nrE", + "cancel_at_period_end": false, + "current_period_end": 1452365312, + "current_period_start": 1449686912, + "customer": "cus_7VDQreyG0YOAk3", + "metadata": { + "id": "0000000000000000000186d7" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 1798 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQreyG0YOAk3/subscriptions/sub_7VDQN2xmA3qRv1", + "status": 200, + "response": { + "id": "sub_7VDQN2xmA3qRv1", + "cancel_at_period_end": false, + "current_period_end": 1452365309, + "current_period_start": 1449686909, + "customer": "cus_7VDQreyG0YOAk3", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQreyG0YOAk3", + "subscription": "sub_7VDQN2xmA3qRv1" + }, + "metadata": { + "id": "0000000000000000000186d5" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + } +] \ No newline at end of file diff --git a/spec/fixtures/sub-test-32.json b/spec/fixtures/sub-test-32.json new file mode 100644 index 000000000..74ebf3aa1 --- /dev/null +++ b/spec/fixtures/sub-test-32.json @@ -0,0 +1,1836 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCzRKaReE7xLUdtc6sLdyQ", + "card": { + "id": "card_17GCzQKaReE7xLUd4kDDn4Fh" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDQrpzK9GSS5U", + "alipay_accounts": { + "has_more": false + }, + "email": "user156@me.com", + "metadata": { + "id": "0000000000000000000186da" + }, + "sources": { + "data": [ + { + "id": "card_17GCzQKaReE7xLUd4kDDn4Fh", + "customer": "cus_7VDQrpzK9GSS5U" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQrpzK9GSS5U", + "status": 200, + "response": { + "id": "cus_7VDQrpzK9GSS5U", + "alipay_accounts": { + "has_more": false + }, + "email": "user156@me.com", + "metadata": { + "id": "0000000000000000000186da" + }, + "sources": { + "data": [ + { + "id": "card_17GCzQKaReE7xLUd4kDDn4Fh", + "customer": "cus_7VDQrpzK9GSS5U" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQrpzK9GSS5U/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDQqnNzHi02T7", + "cancel_at_period_end": false, + "current_period_end": 1452365318, + "current_period_start": 1449686918, + "customer": "cus_7VDQrpzK9GSS5U", + "metadata": { + "id": "0000000000000000000186da" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQrpzK9GSS5U", + "status": 200, + "response": { + "id": "cus_7VDQrpzK9GSS5U", + "alipay_accounts": { + "has_more": false + }, + "email": "user156@me.com", + "metadata": { + "id": "0000000000000000000186da" + }, + "sources": { + "data": [ + { + "id": "card_17GCzQKaReE7xLUd4kDDn4Fh", + "customer": "cus_7VDQrpzK9GSS5U" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDQqnNzHi02T7", + "cancel_at_period_end": false, + "current_period_end": 1452365318, + "current_period_start": 1449686918, + "customer": "cus_7VDQrpzK9GSS5U", + "metadata": { + "id": "0000000000000000000186da" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQrpzK9GSS5U", + "status": 200, + "response": { + "id": "cus_7VDQrpzK9GSS5U", + "alipay_accounts": { + "has_more": false + }, + "email": "user156@me.com", + "metadata": { + "id": "0000000000000000000186da" + }, + "sources": { + "data": [ + { + "id": "card_17GCzQKaReE7xLUd4kDDn4Fh", + "customer": "cus_7VDQrpzK9GSS5U" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDQqnNzHi02T7", + "cancel_at_period_end": false, + "current_period_end": 1452365318, + "current_period_start": 1449686918, + "customer": "cus_7VDQrpzK9GSS5U", + "metadata": { + "id": "0000000000000000000186da" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQrpzK9GSS5U", + "status": 200, + "response": { + "id": "cus_7VDQrpzK9GSS5U", + "alipay_accounts": { + "has_more": false + }, + "email": "user156@me.com", + "metadata": { + "id": "0000000000000000000186da" + }, + "sources": { + "data": [ + { + "id": "card_17GCzQKaReE7xLUd4kDDn4Fh", + "customer": "cus_7VDQrpzK9GSS5U" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDQqnNzHi02T7", + "cancel_at_period_end": false, + "current_period_end": 1452365318, + "current_period_start": 1449686918, + "customer": "cus_7VDQrpzK9GSS5U", + "metadata": { + "id": "0000000000000000000186da" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQrpzK9GSS5U/subscriptions", + "status": 200, + "response": { + "data": [ + { + "id": "sub_7VDQqnNzHi02T7", + "cancel_at_period_end": false, + "current_period_end": 1452365318, + "current_period_start": 1449686918, + "customer": "cus_7VDQrpzK9GSS5U", + "metadata": { + "id": "0000000000000000000186da" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQrpzK9GSS5U/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDQAGb91sokrC", + "cancel_at_period_end": false, + "current_period_end": 1452365321, + "current_period_start": 1449686921, + "customer": "cus_7VDQrpzK9GSS5U", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQrpzK9GSS5U", + "subscription": "sub_7VDQAGb91sokrC" + }, + "metadata": { + "id": "0000000000000000000186d8" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQrpzK9GSS5U/subscriptions", + "status": 200, + "response": { + "data": [ + { + "id": "sub_7VDQAGb91sokrC", + "cancel_at_period_end": false, + "current_period_end": 1452365321, + "current_period_start": 1449686921, + "customer": "cus_7VDQrpzK9GSS5U", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQrpzK9GSS5U", + "subscription": "sub_7VDQAGb91sokrC" + }, + "metadata": { + "id": "0000000000000000000186d8" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQqnNzHi02T7", + "cancel_at_period_end": false, + "current_period_end": 1452365318, + "current_period_start": 1449686918, + "customer": "cus_7VDQrpzK9GSS5U", + "metadata": { + "id": "0000000000000000000186da" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQrpzK9GSS5U/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDQ5Bu6XkKKf7", + "cancel_at_period_end": false, + "current_period_end": 1452365323, + "current_period_start": 1449686923, + "customer": "cus_7VDQrpzK9GSS5U", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQrpzK9GSS5U", + "subscription": "sub_7VDQ5Bu6XkKKf7" + }, + "metadata": { + "id": "0000000000000000000186d9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQrpzK9GSS5U", + "status": 200, + "response": { + "id": "cus_7VDQrpzK9GSS5U", + "alipay_accounts": { + "has_more": false + }, + "email": "user156@me.com", + "metadata": { + "id": "0000000000000000000186da" + }, + "sources": { + "data": [ + { + "id": "card_17GCzQKaReE7xLUd4kDDn4Fh", + "customer": "cus_7VDQrpzK9GSS5U" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDQ5Bu6XkKKf7", + "cancel_at_period_end": false, + "current_period_end": 1452365323, + "current_period_start": 1449686923, + "customer": "cus_7VDQrpzK9GSS5U", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQrpzK9GSS5U", + "subscription": "sub_7VDQ5Bu6XkKKf7" + }, + "metadata": { + "id": "0000000000000000000186d9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQAGb91sokrC", + "cancel_at_period_end": false, + "current_period_end": 1452365321, + "current_period_start": 1449686921, + "customer": "cus_7VDQrpzK9GSS5U", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQrpzK9GSS5U", + "subscription": "sub_7VDQAGb91sokrC" + }, + "metadata": { + "id": "0000000000000000000186d8" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQqnNzHi02T7", + "cancel_at_period_end": false, + "current_period_end": 1452365318, + "current_period_start": 1449686918, + "customer": "cus_7VDQrpzK9GSS5U", + "metadata": { + "id": "0000000000000000000186da" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQrpzK9GSS5U/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDQIByGPu92Pi", + "cancel_at_period_end": false, + "current_period_end": 1452365325, + "current_period_start": 1449686925, + "customer": "cus_7VDQrpzK9GSS5U", + "metadata": { + "id": "0000000000000000000186da" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 1598 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices", + "status": 200, + "response": { + "data": [ + { + "id": "in_17GCzZKaReE7xLUdZuvouIlH", + "customer": "cus_7VDQrpzK9GSS5U", + "lines": { + "data": [ + { + "id": "sub_7VDQIByGPu92Pi", + "amount": 1598, + "metadata": { + "id": "0000000000000000000186da" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 1598, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDQIByGPu92Pi", + "total": 1598 + }, + { + "id": "in_17GCzXKaReE7xLUdMlG9IOJd", + "customer": "cus_7VDQrpzK9GSS5U", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQrpzK9GSS5U", + "subscription": "sub_7VDQ5Bu6XkKKf7" + }, + "lines": { + "data": [ + { + "id": "sub_7VDQ5Bu6XkKKf7", + "amount": 999, + "metadata": { + "id": "0000000000000000000186d9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDQ5Bu6XkKKf7", + "total": 0 + }, + { + "id": "in_17GCzVKaReE7xLUd743tdEzQ", + "customer": "cus_7VDQrpzK9GSS5U", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQrpzK9GSS5U", + "subscription": "sub_7VDQAGb91sokrC" + }, + "lines": { + "data": [ + { + "id": "sub_7VDQAGb91sokrC", + "amount": 999, + "metadata": { + "id": "0000000000000000000186d8" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDQAGb91sokrC", + "total": 0 + }, + { + "id": "in_17GCzSKaReE7xLUdm6NqRmYu", + "customer": "cus_7VDQrpzK9GSS5U", + "lines": { + "data": [ + { + "id": "sub_7VDQqnNzHi02T7", + "amount": 999, + "metadata": { + "id": "0000000000000000000186da" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDQqnNzHi02T7", + "total": 999 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQrpzK9GSS5U", + "status": 200, + "response": { + "id": "cus_7VDQrpzK9GSS5U", + "alipay_accounts": { + "has_more": false + }, + "email": "user156@me.com", + "metadata": { + "id": "0000000000000000000186da" + }, + "sources": { + "data": [ + { + "id": "card_17GCzQKaReE7xLUd4kDDn4Fh", + "customer": "cus_7VDQrpzK9GSS5U" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDQIByGPu92Pi", + "cancel_at_period_end": false, + "current_period_end": 1452365325, + "current_period_start": 1449686925, + "customer": "cus_7VDQrpzK9GSS5U", + "metadata": { + "id": "0000000000000000000186da" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 1598 + }, + { + "id": "sub_7VDQ5Bu6XkKKf7", + "cancel_at_period_end": false, + "current_period_end": 1452365323, + "current_period_start": 1449686923, + "customer": "cus_7VDQrpzK9GSS5U", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQrpzK9GSS5U", + "subscription": "sub_7VDQ5Bu6XkKKf7" + }, + "metadata": { + "id": "0000000000000000000186d9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQAGb91sokrC", + "cancel_at_period_end": false, + "current_period_end": 1452365321, + "current_period_start": 1449686921, + "customer": "cus_7VDQrpzK9GSS5U", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQrpzK9GSS5U", + "subscription": "sub_7VDQAGb91sokrC" + }, + "metadata": { + "id": "0000000000000000000186d8" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQqnNzHi02T7", + "cancel_at_period_end": false, + "current_period_end": 1452365318, + "current_period_start": 1449686918, + "customer": "cus_7VDQrpzK9GSS5U", + "metadata": { + "id": "0000000000000000000186da" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQrpzK9GSS5U", + "status": 200, + "response": { + "id": "cus_7VDQrpzK9GSS5U", + "alipay_accounts": { + "has_more": false + }, + "email": "user156@me.com", + "metadata": { + "id": "0000000000000000000186da" + }, + "sources": { + "data": [ + { + "id": "card_17GCzQKaReE7xLUd4kDDn4Fh", + "customer": "cus_7VDQrpzK9GSS5U" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDQIByGPu92Pi", + "cancel_at_period_end": false, + "current_period_end": 1452365325, + "current_period_start": 1449686925, + "customer": "cus_7VDQrpzK9GSS5U", + "metadata": { + "id": "0000000000000000000186da" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 1598 + }, + { + "id": "sub_7VDQ5Bu6XkKKf7", + "cancel_at_period_end": false, + "current_period_end": 1452365323, + "current_period_start": 1449686923, + "customer": "cus_7VDQrpzK9GSS5U", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQrpzK9GSS5U", + "subscription": "sub_7VDQ5Bu6XkKKf7" + }, + "metadata": { + "id": "0000000000000000000186d9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQAGb91sokrC", + "cancel_at_period_end": false, + "current_period_end": 1452365321, + "current_period_start": 1449686921, + "customer": "cus_7VDQrpzK9GSS5U", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQrpzK9GSS5U", + "subscription": "sub_7VDQAGb91sokrC" + }, + "metadata": { + "id": "0000000000000000000186d8" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQqnNzHi02T7", + "cancel_at_period_end": false, + "current_period_end": 1452365318, + "current_period_start": 1449686918, + "customer": "cus_7VDQrpzK9GSS5U", + "metadata": { + "id": "0000000000000000000186da" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCzZKaReE7xLUdZuvouIlH", + "status": 200, + "response": { + "id": "in_17GCzZKaReE7xLUdZuvouIlH", + "customer": "cus_7VDQrpzK9GSS5U", + "lines": { + "data": [ + { + "id": "sub_7VDQIByGPu92Pi", + "amount": 1598, + "metadata": { + "id": "0000000000000000000186da" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 1598, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDQIByGPu92Pi", + "total": 1598 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQrpzK9GSS5U", + "status": 200, + "response": { + "id": "cus_7VDQrpzK9GSS5U", + "alipay_accounts": { + "has_more": false + }, + "email": "user156@me.com", + "metadata": { + "id": "0000000000000000000186da" + }, + "sources": { + "data": [ + { + "id": "card_17GCzQKaReE7xLUd4kDDn4Fh", + "customer": "cus_7VDQrpzK9GSS5U" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDQIByGPu92Pi", + "cancel_at_period_end": false, + "current_period_end": 1452365325, + "current_period_start": 1449686925, + "customer": "cus_7VDQrpzK9GSS5U", + "metadata": { + "id": "0000000000000000000186da" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 1598 + }, + { + "id": "sub_7VDQ5Bu6XkKKf7", + "cancel_at_period_end": false, + "current_period_end": 1452365323, + "current_period_start": 1449686923, + "customer": "cus_7VDQrpzK9GSS5U", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQrpzK9GSS5U", + "subscription": "sub_7VDQ5Bu6XkKKf7" + }, + "metadata": { + "id": "0000000000000000000186d9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQAGb91sokrC", + "cancel_at_period_end": false, + "current_period_end": 1452365321, + "current_period_start": 1449686921, + "customer": "cus_7VDQrpzK9GSS5U", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQrpzK9GSS5U", + "subscription": "sub_7VDQAGb91sokrC" + }, + "metadata": { + "id": "0000000000000000000186d8" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQqnNzHi02T7", + "cancel_at_period_end": false, + "current_period_end": 1452365318, + "current_period_start": 1449686918, + "customer": "cus_7VDQrpzK9GSS5U", + "metadata": { + "id": "0000000000000000000186da" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCzXKaReE7xLUdMlG9IOJd", + "status": 200, + "response": { + "id": "in_17GCzXKaReE7xLUdMlG9IOJd", + "customer": "cus_7VDQrpzK9GSS5U", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQrpzK9GSS5U", + "subscription": "sub_7VDQ5Bu6XkKKf7" + }, + "lines": { + "data": [ + { + "id": "sub_7VDQ5Bu6XkKKf7", + "amount": 999, + "metadata": { + "id": "0000000000000000000186d9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDQ5Bu6XkKKf7", + "total": 0 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCzVKaReE7xLUd743tdEzQ", + "status": 200, + "response": { + "id": "in_17GCzVKaReE7xLUd743tdEzQ", + "customer": "cus_7VDQrpzK9GSS5U", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQrpzK9GSS5U", + "subscription": "sub_7VDQAGb91sokrC" + }, + "lines": { + "data": [ + { + "id": "sub_7VDQAGb91sokrC", + "amount": 999, + "metadata": { + "id": "0000000000000000000186d8" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDQAGb91sokrC", + "total": 0 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCzSKaReE7xLUdm6NqRmYu", + "status": 200, + "response": { + "id": "in_17GCzSKaReE7xLUdm6NqRmYu", + "customer": "cus_7VDQrpzK9GSS5U", + "lines": { + "data": [ + { + "id": "sub_7VDQqnNzHi02T7", + "amount": 999, + "metadata": { + "id": "0000000000000000000186da" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDQqnNzHi02T7", + "total": 999 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQrpzK9GSS5U/subscriptions/sub_7VDQIByGPu92Pi", + "status": 200, + "response": { + "id": "sub_7VDQIByGPu92Pi", + "cancel_at_period_end": false, + "current_period_end": 1452365325, + "current_period_start": 1449686925, + "customer": "cus_7VDQrpzK9GSS5U", + "metadata": { + "id": "0000000000000000000186da" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 1598 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQrpzK9GSS5U", + "status": 200, + "response": { + "id": "cus_7VDQrpzK9GSS5U", + "alipay_accounts": { + "has_more": false + }, + "email": "user156@me.com", + "metadata": { + "id": "0000000000000000000186da" + }, + "sources": { + "data": [ + { + "id": "card_17GCzQKaReE7xLUd4kDDn4Fh", + "customer": "cus_7VDQrpzK9GSS5U" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDQIByGPu92Pi", + "cancel_at_period_end": false, + "current_period_end": 1452365325, + "current_period_start": 1449686925, + "customer": "cus_7VDQrpzK9GSS5U", + "metadata": { + "id": "0000000000000000000186da" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 1598 + }, + { + "id": "sub_7VDQ5Bu6XkKKf7", + "cancel_at_period_end": false, + "current_period_end": 1452365323, + "current_period_start": 1449686923, + "customer": "cus_7VDQrpzK9GSS5U", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQrpzK9GSS5U", + "subscription": "sub_7VDQ5Bu6XkKKf7" + }, + "metadata": { + "id": "0000000000000000000186d9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQAGb91sokrC", + "cancel_at_period_end": false, + "current_period_end": 1452365321, + "current_period_start": 1449686921, + "customer": "cus_7VDQrpzK9GSS5U", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQrpzK9GSS5U", + "subscription": "sub_7VDQAGb91sokrC" + }, + "metadata": { + "id": "0000000000000000000186d8" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQqnNzHi02T7", + "cancel_at_period_end": false, + "current_period_end": 1452365318, + "current_period_start": 1449686918, + "customer": "cus_7VDQrpzK9GSS5U", + "metadata": { + "id": "0000000000000000000186da" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQrpzK9GSS5U/subscriptions/sub_7VDQAGb91sokrC", + "status": 200, + "response": { + "id": "sub_7VDQAGb91sokrC", + "cancel_at_period_end": false, + "current_period_end": 1452365321, + "current_period_start": 1449686921, + "customer": "cus_7VDQrpzK9GSS5U", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQrpzK9GSS5U", + "subscription": "sub_7VDQAGb91sokrC" + }, + "metadata": { + "id": "0000000000000000000186d8" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQrpzK9GSS5U/subscriptions/sub_7VDQIByGPu92Pi", + "status": 200, + "response": { + "id": "sub_7VDQIByGPu92Pi", + "cancel_at_period_end": false, + "current_period_end": 1452365325, + "current_period_start": 1449686925, + "customer": "cus_7VDQrpzK9GSS5U", + "metadata": { + "id": "0000000000000000000186da" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 1598 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQrpzK9GSS5U/subscriptions/sub_7VDQ5Bu6XkKKf7", + "status": 200, + "response": { + "id": "sub_7VDQ5Bu6XkKKf7", + "cancel_at_period_end": false, + "current_period_end": 1452365323, + "current_period_start": 1449686923, + "customer": "cus_7VDQrpzK9GSS5U", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQrpzK9GSS5U", + "subscription": "sub_7VDQ5Bu6XkKKf7" + }, + "metadata": { + "id": "0000000000000000000186d9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQrpzK9GSS5U/subscriptions/sub_7VDQAGb91sokrC", + "status": 200, + "response": { + "id": "sub_7VDQAGb91sokrC", + "cancel_at_period_end": false, + "current_period_end": 1452365321, + "current_period_start": 1449686921, + "customer": "cus_7VDQrpzK9GSS5U", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQrpzK9GSS5U", + "subscription": "sub_7VDQAGb91sokrC" + }, + "metadata": { + "id": "0000000000000000000186d8" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "DELETE", + "path": "/v1/customers/cus_7VDQrpzK9GSS5U/subscriptions/sub_7VDQAGb91sokrC", + "status": 200, + "response": { + "id": "sub_7VDQAGb91sokrC", + "cancel_at_period_end": false, + "current_period_end": 1452365321, + "current_period_start": 1449686921, + "customer": "cus_7VDQrpzK9GSS5U", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQrpzK9GSS5U", + "subscription": "sub_7VDQAGb91sokrC" + }, + "metadata": { + "id": "0000000000000000000186d8" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQrpzK9GSS5U", + "status": 200, + "response": { + "id": "cus_7VDQrpzK9GSS5U", + "alipay_accounts": { + "has_more": false + }, + "email": "user156@me.com", + "metadata": { + "id": "0000000000000000000186da" + }, + "sources": { + "data": [ + { + "id": "card_17GCzQKaReE7xLUd4kDDn4Fh", + "customer": "cus_7VDQrpzK9GSS5U" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDQIByGPu92Pi", + "cancel_at_period_end": false, + "current_period_end": 1452365325, + "current_period_start": 1449686925, + "customer": "cus_7VDQrpzK9GSS5U", + "metadata": { + "id": "0000000000000000000186da" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 1598 + }, + { + "id": "sub_7VDQ5Bu6XkKKf7", + "cancel_at_period_end": false, + "current_period_end": 1452365323, + "current_period_start": 1449686923, + "customer": "cus_7VDQrpzK9GSS5U", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQrpzK9GSS5U", + "subscription": "sub_7VDQ5Bu6XkKKf7" + }, + "metadata": { + "id": "0000000000000000000186d9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQqnNzHi02T7", + "cancel_at_period_end": false, + "current_period_end": 1452365318, + "current_period_start": 1449686918, + "customer": "cus_7VDQrpzK9GSS5U", + "metadata": { + "id": "0000000000000000000186da" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQrpzK9GSS5U/subscriptions/sub_7VDQIByGPu92Pi", + "status": 200, + "response": { + "id": "sub_7VDQIByGPu92Pi", + "cancel_at_period_end": false, + "current_period_end": 1452365325, + "current_period_start": 1449686925, + "customer": "cus_7VDQrpzK9GSS5U", + "metadata": { + "id": "0000000000000000000186da" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 799 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQrpzK9GSS5U/subscriptions", + "status": 200, + "response": { + "data": [ + { + "id": "sub_7VDQIByGPu92Pi", + "cancel_at_period_end": false, + "current_period_end": 1452365325, + "current_period_start": 1449686925, + "customer": "cus_7VDQrpzK9GSS5U", + "metadata": { + "id": "0000000000000000000186da" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 799 + }, + { + "id": "sub_7VDQ5Bu6XkKKf7", + "cancel_at_period_end": false, + "current_period_end": 1452365323, + "current_period_start": 1449686923, + "customer": "cus_7VDQrpzK9GSS5U", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQrpzK9GSS5U", + "subscription": "sub_7VDQ5Bu6XkKKf7" + }, + "metadata": { + "id": "0000000000000000000186d9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQqnNzHi02T7", + "cancel_at_period_end": false, + "current_period_end": 1452365318, + "current_period_start": 1449686918, + "customer": "cus_7VDQrpzK9GSS5U", + "metadata": { + "id": "0000000000000000000186da" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQrpzK9GSS5U", + "status": 200, + "response": { + "id": "cus_7VDQrpzK9GSS5U", + "alipay_accounts": { + "has_more": false + }, + "email": "user156@me.com", + "metadata": { + "id": "0000000000000000000186da" + }, + "sources": { + "data": [ + { + "id": "card_17GCzQKaReE7xLUd4kDDn4Fh", + "customer": "cus_7VDQrpzK9GSS5U" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDQIByGPu92Pi", + "cancel_at_period_end": false, + "current_period_end": 1452365325, + "current_period_start": 1449686925, + "customer": "cus_7VDQrpzK9GSS5U", + "metadata": { + "id": "0000000000000000000186da" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 799 + }, + { + "id": "sub_7VDQ5Bu6XkKKf7", + "cancel_at_period_end": false, + "current_period_end": 1452365323, + "current_period_start": 1449686923, + "customer": "cus_7VDQrpzK9GSS5U", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQrpzK9GSS5U", + "subscription": "sub_7VDQ5Bu6XkKKf7" + }, + "metadata": { + "id": "0000000000000000000186d9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQqnNzHi02T7", + "cancel_at_period_end": false, + "current_period_end": 1452365318, + "current_period_start": 1449686918, + "customer": "cus_7VDQrpzK9GSS5U", + "metadata": { + "id": "0000000000000000000186da" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQrpzK9GSS5U/subscriptions/sub_7VDQIByGPu92Pi", + "status": 200, + "response": { + "id": "sub_7VDQIByGPu92Pi", + "cancel_at_period_end": false, + "current_period_end": 1452365325, + "current_period_start": 1449686925, + "customer": "cus_7VDQrpzK9GSS5U", + "metadata": { + "id": "0000000000000000000186da" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 799 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQrpzK9GSS5U/subscriptions/sub_7VDQ5Bu6XkKKf7", + "status": 200, + "response": { + "id": "sub_7VDQ5Bu6XkKKf7", + "cancel_at_period_end": false, + "current_period_end": 1452365323, + "current_period_start": 1449686923, + "customer": "cus_7VDQrpzK9GSS5U", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQrpzK9GSS5U", + "subscription": "sub_7VDQ5Bu6XkKKf7" + }, + "metadata": { + "id": "0000000000000000000186d9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "DELETE", + "path": "/v1/customers/cus_7VDQrpzK9GSS5U/subscriptions/sub_7VDQ5Bu6XkKKf7", + "status": 200, + "response": { + "id": "sub_7VDQ5Bu6XkKKf7", + "cancel_at_period_end": false, + "current_period_end": 1452365323, + "current_period_start": 1449686923, + "customer": "cus_7VDQrpzK9GSS5U", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQrpzK9GSS5U", + "subscription": "sub_7VDQ5Bu6XkKKf7" + }, + "metadata": { + "id": "0000000000000000000186d9" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQrpzK9GSS5U/subscriptions/sub_7VDQIByGPu92Pi", + "status": 200, + "response": { + "id": "sub_7VDQIByGPu92Pi", + "cancel_at_period_end": false, + "current_period_end": 1452365325, + "current_period_start": 1449686925, + "customer": "cus_7VDQrpzK9GSS5U", + "metadata": { + "id": "0000000000000000000186da" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 0 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQrpzK9GSS5U", + "status": 200, + "response": { + "id": "cus_7VDQrpzK9GSS5U", + "alipay_accounts": { + "has_more": false + }, + "email": "user156@me.com", + "metadata": { + "id": "0000000000000000000186da" + }, + "sources": { + "data": [ + { + "id": "card_17GCzQKaReE7xLUd4kDDn4Fh", + "customer": "cus_7VDQrpzK9GSS5U" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDQIByGPu92Pi", + "cancel_at_period_end": false, + "current_period_end": 1452365325, + "current_period_start": 1449686925, + "customer": "cus_7VDQrpzK9GSS5U", + "metadata": { + "id": "0000000000000000000186da" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 0 + }, + { + "id": "sub_7VDQqnNzHi02T7", + "cancel_at_period_end": false, + "current_period_end": 1452365318, + "current_period_start": 1449686918, + "customer": "cus_7VDQrpzK9GSS5U", + "metadata": { + "id": "0000000000000000000186da" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQrpzK9GSS5U", + "status": 200, + "response": { + "id": "cus_7VDQrpzK9GSS5U", + "alipay_accounts": { + "has_more": false + }, + "email": "user156@me.com", + "metadata": { + "id": "0000000000000000000186da" + }, + "sources": { + "data": [ + { + "id": "card_17GCzQKaReE7xLUd4kDDn4Fh", + "customer": "cus_7VDQrpzK9GSS5U" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDQIByGPu92Pi", + "cancel_at_period_end": false, + "current_period_end": 1452365325, + "current_period_start": 1449686925, + "customer": "cus_7VDQrpzK9GSS5U", + "metadata": { + "id": "0000000000000000000186da" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 0 + }, + { + "id": "sub_7VDQqnNzHi02T7", + "cancel_at_period_end": false, + "current_period_end": 1452365318, + "current_period_start": 1449686918, + "customer": "cus_7VDQrpzK9GSS5U", + "metadata": { + "id": "0000000000000000000186da" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQrpzK9GSS5U/subscriptions", + "status": 200, + "response": { + "data": [ + { + "id": "sub_7VDQIByGPu92Pi", + "cancel_at_period_end": false, + "current_period_end": 1452365325, + "current_period_start": 1449686925, + "customer": "cus_7VDQrpzK9GSS5U", + "metadata": { + "id": "0000000000000000000186da" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 0 + }, + { + "id": "sub_7VDQqnNzHi02T7", + "cancel_at_period_end": false, + "current_period_end": 1452365318, + "current_period_start": 1449686918, + "customer": "cus_7VDQrpzK9GSS5U", + "metadata": { + "id": "0000000000000000000186da" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQrpzK9GSS5U/subscriptions/sub_7VDQIByGPu92Pi", + "status": 200, + "response": { + "id": "sub_7VDQIByGPu92Pi", + "cancel_at_period_end": false, + "current_period_end": 1452365325, + "current_period_start": 1449686925, + "customer": "cus_7VDQrpzK9GSS5U", + "metadata": { + "id": "0000000000000000000186da" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 0 + } + } +] \ No newline at end of file diff --git a/spec/fixtures/sub-test-33.json b/spec/fixtures/sub-test-33.json new file mode 100644 index 000000000..e31c362fe --- /dev/null +++ b/spec/fixtures/sub-test-33.json @@ -0,0 +1,2811 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GCznKaReE7xLUdqZxzUdKq", + "card": { + "id": "card_17GCznKaReE7xLUdmclsW7nv" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDQzWMIpIdaTg", + "alipay_accounts": { + "has_more": false + }, + "email": "user160@me.com", + "metadata": { + "id": "0000000000000000000186de" + }, + "sources": { + "data": [ + { + "id": "card_17GCznKaReE7xLUdmclsW7nv", + "customer": "cus_7VDQzWMIpIdaTg" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg", + "status": 200, + "response": { + "id": "cus_7VDQzWMIpIdaTg", + "alipay_accounts": { + "has_more": false + }, + "email": "user160@me.com", + "metadata": { + "id": "0000000000000000000186de" + }, + "sources": { + "data": [ + { + "id": "card_17GCznKaReE7xLUdmclsW7nv", + "customer": "cus_7VDQzWMIpIdaTg" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDQYgFOUGI8r9", + "cancel_at_period_end": false, + "current_period_end": 1452365340, + "current_period_start": 1449686940, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg", + "status": 200, + "response": { + "id": "cus_7VDQzWMIpIdaTg", + "alipay_accounts": { + "has_more": false + }, + "email": "user160@me.com", + "metadata": { + "id": "0000000000000000000186de" + }, + "sources": { + "data": [ + { + "id": "card_17GCznKaReE7xLUdmclsW7nv", + "customer": "cus_7VDQzWMIpIdaTg" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDQYgFOUGI8r9", + "cancel_at_period_end": false, + "current_period_end": 1452365340, + "current_period_start": 1449686940, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg", + "status": 200, + "response": { + "id": "cus_7VDQzWMIpIdaTg", + "alipay_accounts": { + "has_more": false + }, + "email": "user160@me.com", + "metadata": { + "id": "0000000000000000000186de" + }, + "sources": { + "data": [ + { + "id": "card_17GCznKaReE7xLUdmclsW7nv", + "customer": "cus_7VDQzWMIpIdaTg" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDQYgFOUGI8r9", + "cancel_at_period_end": false, + "current_period_end": 1452365340, + "current_period_start": 1449686940, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg/subscriptions", + "status": 200, + "response": { + "data": [ + { + "id": "sub_7VDQYgFOUGI8r9", + "cancel_at_period_end": false, + "current_period_end": 1452365340, + "current_period_start": 1449686940, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg", + "status": 200, + "response": { + "id": "cus_7VDQzWMIpIdaTg", + "alipay_accounts": { + "has_more": false + }, + "email": "user160@me.com", + "metadata": { + "id": "0000000000000000000186de" + }, + "sources": { + "data": [ + { + "id": "card_17GCznKaReE7xLUdmclsW7nv", + "customer": "cus_7VDQzWMIpIdaTg" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDQYgFOUGI8r9", + "cancel_at_period_end": false, + "current_period_end": 1452365340, + "current_period_start": 1449686940, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDQZ91PX2G0Tj", + "cancel_at_period_end": false, + "current_period_end": 1452365343, + "current_period_start": 1449686943, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQZ91PX2G0Tj" + }, + "metadata": { + "id": "0000000000000000000186db" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg/subscriptions", + "status": 200, + "response": { + "data": [ + { + "id": "sub_7VDQZ91PX2G0Tj", + "cancel_at_period_end": false, + "current_period_end": 1452365343, + "current_period_start": 1449686943, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQZ91PX2G0Tj" + }, + "metadata": { + "id": "0000000000000000000186db" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQYgFOUGI8r9", + "cancel_at_period_end": false, + "current_period_end": 1452365340, + "current_period_start": 1449686940, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDQj6CEnlk5u8", + "cancel_at_period_end": false, + "current_period_end": 1452365344, + "current_period_start": 1449686944, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQj6CEnlk5u8" + }, + "metadata": { + "id": "0000000000000000000186dc" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg/subscriptions", + "status": 200, + "response": { + "data": [ + { + "id": "sub_7VDQj6CEnlk5u8", + "cancel_at_period_end": false, + "current_period_end": 1452365344, + "current_period_start": 1449686944, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQj6CEnlk5u8" + }, + "metadata": { + "id": "0000000000000000000186dc" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQZ91PX2G0Tj", + "cancel_at_period_end": false, + "current_period_end": 1452365343, + "current_period_start": 1449686943, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQZ91PX2G0Tj" + }, + "metadata": { + "id": "0000000000000000000186db" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQYgFOUGI8r9", + "cancel_at_period_end": false, + "current_period_end": 1452365340, + "current_period_start": 1449686940, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDQOGP4cNiGgs", + "cancel_at_period_end": false, + "current_period_end": 1452365346, + "current_period_start": 1449686946, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQOGP4cNiGgs" + }, + "metadata": { + "id": "0000000000000000000186dd" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg", + "status": 200, + "response": { + "id": "cus_7VDQzWMIpIdaTg", + "alipay_accounts": { + "has_more": false + }, + "email": "user160@me.com", + "metadata": { + "id": "0000000000000000000186de" + }, + "sources": { + "data": [ + { + "id": "card_17GCznKaReE7xLUdmclsW7nv", + "customer": "cus_7VDQzWMIpIdaTg" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDQOGP4cNiGgs", + "cancel_at_period_end": false, + "current_period_end": 1452365346, + "current_period_start": 1449686946, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQOGP4cNiGgs" + }, + "metadata": { + "id": "0000000000000000000186dd" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQj6CEnlk5u8", + "cancel_at_period_end": false, + "current_period_end": 1452365344, + "current_period_start": 1449686944, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQj6CEnlk5u8" + }, + "metadata": { + "id": "0000000000000000000186dc" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQZ91PX2G0Tj", + "cancel_at_period_end": false, + "current_period_end": 1452365343, + "current_period_start": 1449686943, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQZ91PX2G0Tj" + }, + "metadata": { + "id": "0000000000000000000186db" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQYgFOUGI8r9", + "cancel_at_period_end": false, + "current_period_end": 1452365340, + "current_period_start": 1449686940, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDQl97MLLoXEp", + "cancel_at_period_end": false, + "current_period_end": 1452365348, + "current_period_start": 1449686948, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 2398 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices", + "status": 200, + "response": { + "data": [ + { + "id": "in_17GCzwKaReE7xLUdBi1VCrbQ", + "customer": "cus_7VDQzWMIpIdaTg", + "lines": { + "data": [ + { + "id": "sub_7VDQl97MLLoXEp", + "amount": 2398, + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 2398, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDQl97MLLoXEp", + "total": 2398 + }, + { + "id": "in_17GCzuKaReE7xLUdlt1WrP6F", + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQOGP4cNiGgs" + }, + "lines": { + "data": [ + { + "id": "sub_7VDQOGP4cNiGgs", + "amount": 999, + "metadata": { + "id": "0000000000000000000186dd" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDQOGP4cNiGgs", + "total": 0 + }, + { + "id": "in_17GCzsKaReE7xLUd0r2dKONY", + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQj6CEnlk5u8" + }, + "lines": { + "data": [ + { + "id": "sub_7VDQj6CEnlk5u8", + "amount": 999, + "metadata": { + "id": "0000000000000000000186dc" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDQj6CEnlk5u8", + "total": 0 + }, + { + "id": "in_17GCzrKaReE7xLUdDFBkmIM1", + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQZ91PX2G0Tj" + }, + "lines": { + "data": [ + { + "id": "sub_7VDQZ91PX2G0Tj", + "amount": 999, + "metadata": { + "id": "0000000000000000000186db" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDQZ91PX2G0Tj", + "total": 0 + }, + { + "id": "in_17GCzoKaReE7xLUdILkFu9Lf", + "customer": "cus_7VDQzWMIpIdaTg", + "lines": { + "data": [ + { + "id": "sub_7VDQYgFOUGI8r9", + "amount": 999, + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDQYgFOUGI8r9", + "total": 999 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg", + "status": 200, + "response": { + "id": "cus_7VDQzWMIpIdaTg", + "alipay_accounts": { + "has_more": false + }, + "email": "user160@me.com", + "metadata": { + "id": "0000000000000000000186de" + }, + "sources": { + "data": [ + { + "id": "card_17GCznKaReE7xLUdmclsW7nv", + "customer": "cus_7VDQzWMIpIdaTg" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDQl97MLLoXEp", + "cancel_at_period_end": false, + "current_period_end": 1452365348, + "current_period_start": 1449686948, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 2398 + }, + { + "id": "sub_7VDQOGP4cNiGgs", + "cancel_at_period_end": false, + "current_period_end": 1452365346, + "current_period_start": 1449686946, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQOGP4cNiGgs" + }, + "metadata": { + "id": "0000000000000000000186dd" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQj6CEnlk5u8", + "cancel_at_period_end": false, + "current_period_end": 1452365344, + "current_period_start": 1449686944, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQj6CEnlk5u8" + }, + "metadata": { + "id": "0000000000000000000186dc" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQZ91PX2G0Tj", + "cancel_at_period_end": false, + "current_period_end": 1452365343, + "current_period_start": 1449686943, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQZ91PX2G0Tj" + }, + "metadata": { + "id": "0000000000000000000186db" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQYgFOUGI8r9", + "cancel_at_period_end": false, + "current_period_end": 1452365340, + "current_period_start": 1449686940, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCzwKaReE7xLUdBi1VCrbQ", + "status": 200, + "response": { + "id": "in_17GCzwKaReE7xLUdBi1VCrbQ", + "customer": "cus_7VDQzWMIpIdaTg", + "lines": { + "data": [ + { + "id": "sub_7VDQl97MLLoXEp", + "amount": 2398, + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "proration": false, + "quantity": 2398, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDQl97MLLoXEp", + "total": 2398 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg", + "status": 200, + "response": { + "id": "cus_7VDQzWMIpIdaTg", + "alipay_accounts": { + "has_more": false + }, + "email": "user160@me.com", + "metadata": { + "id": "0000000000000000000186de" + }, + "sources": { + "data": [ + { + "id": "card_17GCznKaReE7xLUdmclsW7nv", + "customer": "cus_7VDQzWMIpIdaTg" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDQl97MLLoXEp", + "cancel_at_period_end": false, + "current_period_end": 1452365348, + "current_period_start": 1449686948, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 2398 + }, + { + "id": "sub_7VDQOGP4cNiGgs", + "cancel_at_period_end": false, + "current_period_end": 1452365346, + "current_period_start": 1449686946, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQOGP4cNiGgs" + }, + "metadata": { + "id": "0000000000000000000186dd" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQj6CEnlk5u8", + "cancel_at_period_end": false, + "current_period_end": 1452365344, + "current_period_start": 1449686944, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQj6CEnlk5u8" + }, + "metadata": { + "id": "0000000000000000000186dc" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQZ91PX2G0Tj", + "cancel_at_period_end": false, + "current_period_end": 1452365343, + "current_period_start": 1449686943, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQZ91PX2G0Tj" + }, + "metadata": { + "id": "0000000000000000000186db" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQYgFOUGI8r9", + "cancel_at_period_end": false, + "current_period_end": 1452365340, + "current_period_start": 1449686940, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg", + "status": 200, + "response": { + "id": "cus_7VDQzWMIpIdaTg", + "alipay_accounts": { + "has_more": false + }, + "email": "user160@me.com", + "metadata": { + "id": "0000000000000000000186de" + }, + "sources": { + "data": [ + { + "id": "card_17GCznKaReE7xLUdmclsW7nv", + "customer": "cus_7VDQzWMIpIdaTg" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDQl97MLLoXEp", + "cancel_at_period_end": false, + "current_period_end": 1452365348, + "current_period_start": 1449686948, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 2398 + }, + { + "id": "sub_7VDQOGP4cNiGgs", + "cancel_at_period_end": false, + "current_period_end": 1452365346, + "current_period_start": 1449686946, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQOGP4cNiGgs" + }, + "metadata": { + "id": "0000000000000000000186dd" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQj6CEnlk5u8", + "cancel_at_period_end": false, + "current_period_end": 1452365344, + "current_period_start": 1449686944, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQj6CEnlk5u8" + }, + "metadata": { + "id": "0000000000000000000186dc" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQZ91PX2G0Tj", + "cancel_at_period_end": false, + "current_period_end": 1452365343, + "current_period_start": 1449686943, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQZ91PX2G0Tj" + }, + "metadata": { + "id": "0000000000000000000186db" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQYgFOUGI8r9", + "cancel_at_period_end": false, + "current_period_end": 1452365340, + "current_period_start": 1449686940, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCzuKaReE7xLUdlt1WrP6F", + "status": 200, + "response": { + "id": "in_17GCzuKaReE7xLUdlt1WrP6F", + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQOGP4cNiGgs" + }, + "lines": { + "data": [ + { + "id": "sub_7VDQOGP4cNiGgs", + "amount": 999, + "metadata": { + "id": "0000000000000000000186dd" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDQOGP4cNiGgs", + "total": 0 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCzsKaReE7xLUd0r2dKONY", + "status": 200, + "response": { + "id": "in_17GCzsKaReE7xLUd0r2dKONY", + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQj6CEnlk5u8" + }, + "lines": { + "data": [ + { + "id": "sub_7VDQj6CEnlk5u8", + "amount": 999, + "metadata": { + "id": "0000000000000000000186dc" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDQj6CEnlk5u8", + "total": 0 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCzrKaReE7xLUdDFBkmIM1", + "status": 200, + "response": { + "id": "in_17GCzrKaReE7xLUdDFBkmIM1", + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQZ91PX2G0Tj" + }, + "lines": { + "data": [ + { + "id": "sub_7VDQZ91PX2G0Tj", + "amount": 999, + "metadata": { + "id": "0000000000000000000186db" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDQZ91PX2G0Tj", + "total": 0 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/invoices/in_17GCzoKaReE7xLUdILkFu9Lf", + "status": 200, + "response": { + "id": "in_17GCzoKaReE7xLUdILkFu9Lf", + "customer": "cus_7VDQzWMIpIdaTg", + "lines": { + "data": [ + { + "id": "sub_7VDQYgFOUGI8r9", + "amount": 999, + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "proration": false, + "quantity": 1, + "type": "subscription" + } + ], + "has_more": false + }, + "paid": true, + "subscription": "sub_7VDQYgFOUGI8r9", + "total": 999 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg/subscriptions/sub_7VDQl97MLLoXEp", + "status": 200, + "response": { + "id": "sub_7VDQl97MLLoXEp", + "cancel_at_period_end": false, + "current_period_end": 1452365348, + "current_period_start": 1449686948, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 2398 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg", + "status": 200, + "response": { + "id": "cus_7VDQzWMIpIdaTg", + "alipay_accounts": { + "has_more": false + }, + "email": "user160@me.com", + "metadata": { + "id": "0000000000000000000186de" + }, + "sources": { + "data": [ + { + "id": "card_17GCznKaReE7xLUdmclsW7nv", + "customer": "cus_7VDQzWMIpIdaTg" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDQl97MLLoXEp", + "cancel_at_period_end": false, + "current_period_end": 1452365348, + "current_period_start": 1449686948, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 2398 + }, + { + "id": "sub_7VDQOGP4cNiGgs", + "cancel_at_period_end": false, + "current_period_end": 1452365346, + "current_period_start": 1449686946, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQOGP4cNiGgs" + }, + "metadata": { + "id": "0000000000000000000186dd" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQj6CEnlk5u8", + "cancel_at_period_end": false, + "current_period_end": 1452365344, + "current_period_start": 1449686944, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQj6CEnlk5u8" + }, + "metadata": { + "id": "0000000000000000000186dc" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQZ91PX2G0Tj", + "cancel_at_period_end": false, + "current_period_end": 1452365343, + "current_period_start": 1449686943, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQZ91PX2G0Tj" + }, + "metadata": { + "id": "0000000000000000000186db" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQYgFOUGI8r9", + "cancel_at_period_end": false, + "current_period_end": 1452365340, + "current_period_start": 1449686940, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg/subscriptions/sub_7VDQZ91PX2G0Tj", + "status": 200, + "response": { + "id": "sub_7VDQZ91PX2G0Tj", + "cancel_at_period_end": false, + "current_period_end": 1452365343, + "current_period_start": 1449686943, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQZ91PX2G0Tj" + }, + "metadata": { + "id": "0000000000000000000186db" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg/subscriptions/sub_7VDQl97MLLoXEp", + "status": 200, + "response": { + "id": "sub_7VDQl97MLLoXEp", + "cancel_at_period_end": false, + "current_period_end": 1452365348, + "current_period_start": 1449686948, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 2398 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg/subscriptions/sub_7VDQj6CEnlk5u8", + "status": 200, + "response": { + "id": "sub_7VDQj6CEnlk5u8", + "cancel_at_period_end": false, + "current_period_end": 1452365344, + "current_period_start": 1449686944, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQj6CEnlk5u8" + }, + "metadata": { + "id": "0000000000000000000186dc" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg/subscriptions/sub_7VDQl97MLLoXEp", + "status": 200, + "response": { + "id": "sub_7VDQl97MLLoXEp", + "cancel_at_period_end": false, + "current_period_end": 1452365348, + "current_period_start": 1449686948, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 2398 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg/subscriptions/sub_7VDQOGP4cNiGgs", + "status": 200, + "response": { + "id": "sub_7VDQOGP4cNiGgs", + "cancel_at_period_end": false, + "current_period_end": 1452365346, + "current_period_start": 1449686946, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQOGP4cNiGgs" + }, + "metadata": { + "id": "0000000000000000000186dd" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg/subscriptions/sub_7VDQZ91PX2G0Tj", + "status": 200, + "response": { + "id": "sub_7VDQZ91PX2G0Tj", + "cancel_at_period_end": false, + "current_period_end": 1452365343, + "current_period_start": 1449686943, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQZ91PX2G0Tj" + }, + "metadata": { + "id": "0000000000000000000186db" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "DELETE", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg/subscriptions/sub_7VDQZ91PX2G0Tj", + "status": 200, + "response": { + "id": "sub_7VDQZ91PX2G0Tj", + "cancel_at_period_end": false, + "current_period_end": 1452365343, + "current_period_start": 1449686943, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQZ91PX2G0Tj" + }, + "metadata": { + "id": "0000000000000000000186db" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg", + "status": 200, + "response": { + "id": "cus_7VDQzWMIpIdaTg", + "alipay_accounts": { + "has_more": false + }, + "email": "user160@me.com", + "metadata": { + "id": "0000000000000000000186de" + }, + "sources": { + "data": [ + { + "id": "card_17GCznKaReE7xLUdmclsW7nv", + "customer": "cus_7VDQzWMIpIdaTg" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDQl97MLLoXEp", + "cancel_at_period_end": false, + "current_period_end": 1452365348, + "current_period_start": 1449686948, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 2398 + }, + { + "id": "sub_7VDQOGP4cNiGgs", + "cancel_at_period_end": false, + "current_period_end": 1452365346, + "current_period_start": 1449686946, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQOGP4cNiGgs" + }, + "metadata": { + "id": "0000000000000000000186dd" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQj6CEnlk5u8", + "cancel_at_period_end": false, + "current_period_end": 1452365344, + "current_period_start": 1449686944, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQj6CEnlk5u8" + }, + "metadata": { + "id": "0000000000000000000186dc" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQYgFOUGI8r9", + "cancel_at_period_end": false, + "current_period_end": 1452365340, + "current_period_start": 1449686940, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg/subscriptions/sub_7VDQl97MLLoXEp", + "status": 200, + "response": { + "id": "sub_7VDQl97MLLoXEp", + "cancel_at_period_end": false, + "current_period_end": 1452365348, + "current_period_start": 1449686948, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 1598 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg/subscriptions", + "status": 200, + "response": { + "data": [ + { + "id": "sub_7VDQl97MLLoXEp", + "cancel_at_period_end": false, + "current_period_end": 1452365348, + "current_period_start": 1449686948, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 1598 + }, + { + "id": "sub_7VDQOGP4cNiGgs", + "cancel_at_period_end": false, + "current_period_end": 1452365346, + "current_period_start": 1449686946, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQOGP4cNiGgs" + }, + "metadata": { + "id": "0000000000000000000186dd" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQj6CEnlk5u8", + "cancel_at_period_end": false, + "current_period_end": 1452365344, + "current_period_start": 1449686944, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQj6CEnlk5u8" + }, + "metadata": { + "id": "0000000000000000000186dc" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQYgFOUGI8r9", + "cancel_at_period_end": false, + "current_period_end": 1452365340, + "current_period_start": 1449686940, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg", + "status": 200, + "response": { + "id": "cus_7VDQzWMIpIdaTg", + "alipay_accounts": { + "has_more": false + }, + "email": "user160@me.com", + "metadata": { + "id": "0000000000000000000186de" + }, + "sources": { + "data": [ + { + "id": "card_17GCznKaReE7xLUdmclsW7nv", + "customer": "cus_7VDQzWMIpIdaTg" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDQl97MLLoXEp", + "cancel_at_period_end": false, + "current_period_end": 1452365348, + "current_period_start": 1449686948, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 1598 + }, + { + "id": "sub_7VDQOGP4cNiGgs", + "cancel_at_period_end": false, + "current_period_end": 1452365346, + "current_period_start": 1449686946, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQOGP4cNiGgs" + }, + "metadata": { + "id": "0000000000000000000186dd" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQj6CEnlk5u8", + "cancel_at_period_end": false, + "current_period_end": 1452365344, + "current_period_start": 1449686944, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQj6CEnlk5u8" + }, + "metadata": { + "id": "0000000000000000000186dc" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQYgFOUGI8r9", + "cancel_at_period_end": false, + "current_period_end": 1452365340, + "current_period_start": 1449686940, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg/subscriptions/sub_7VDQl97MLLoXEp", + "status": 200, + "response": { + "id": "sub_7VDQl97MLLoXEp", + "cancel_at_period_end": false, + "current_period_end": 1452365348, + "current_period_start": 1449686948, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 1598 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg/subscriptions/sub_7VDQj6CEnlk5u8", + "status": 200, + "response": { + "id": "sub_7VDQj6CEnlk5u8", + "cancel_at_period_end": false, + "current_period_end": 1452365344, + "current_period_start": 1449686944, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQj6CEnlk5u8" + }, + "metadata": { + "id": "0000000000000000000186dc" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "DELETE", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg/subscriptions/sub_7VDQj6CEnlk5u8", + "status": 200, + "response": { + "id": "sub_7VDQj6CEnlk5u8", + "cancel_at_period_end": false, + "current_period_end": 1452365344, + "current_period_start": 1449686944, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQj6CEnlk5u8" + }, + "metadata": { + "id": "0000000000000000000186dc" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg", + "status": 200, + "response": { + "id": "cus_7VDQzWMIpIdaTg", + "alipay_accounts": { + "has_more": false + }, + "email": "user160@me.com", + "metadata": { + "id": "0000000000000000000186de" + }, + "sources": { + "data": [ + { + "id": "card_17GCznKaReE7xLUdmclsW7nv", + "customer": "cus_7VDQzWMIpIdaTg" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDQl97MLLoXEp", + "cancel_at_period_end": false, + "current_period_end": 1452365348, + "current_period_start": 1449686948, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 1598 + }, + { + "id": "sub_7VDQOGP4cNiGgs", + "cancel_at_period_end": false, + "current_period_end": 1452365346, + "current_period_start": 1449686946, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQOGP4cNiGgs" + }, + "metadata": { + "id": "0000000000000000000186dd" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQYgFOUGI8r9", + "cancel_at_period_end": false, + "current_period_end": 1452365340, + "current_period_start": 1449686940, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg/subscriptions/sub_7VDQl97MLLoXEp", + "status": 200, + "response": { + "id": "sub_7VDQl97MLLoXEp", + "cancel_at_period_end": false, + "current_period_end": 1452365348, + "current_period_start": 1449686948, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 799 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg/subscriptions", + "status": 200, + "response": { + "data": [ + { + "id": "sub_7VDQl97MLLoXEp", + "cancel_at_period_end": false, + "current_period_end": 1452365348, + "current_period_start": 1449686948, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 799 + }, + { + "id": "sub_7VDQOGP4cNiGgs", + "cancel_at_period_end": false, + "current_period_end": 1452365346, + "current_period_start": 1449686946, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQOGP4cNiGgs" + }, + "metadata": { + "id": "0000000000000000000186dd" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQYgFOUGI8r9", + "cancel_at_period_end": false, + "current_period_end": 1452365340, + "current_period_start": 1449686940, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg", + "status": 200, + "response": { + "id": "cus_7VDQzWMIpIdaTg", + "alipay_accounts": { + "has_more": false + }, + "email": "user160@me.com", + "metadata": { + "id": "0000000000000000000186de" + }, + "sources": { + "data": [ + { + "id": "card_17GCznKaReE7xLUdmclsW7nv", + "customer": "cus_7VDQzWMIpIdaTg" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDQl97MLLoXEp", + "cancel_at_period_end": false, + "current_period_end": 1452365348, + "current_period_start": 1449686948, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 799 + }, + { + "id": "sub_7VDQOGP4cNiGgs", + "cancel_at_period_end": false, + "current_period_end": 1452365346, + "current_period_start": 1449686946, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQOGP4cNiGgs" + }, + "metadata": { + "id": "0000000000000000000186dd" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQYgFOUGI8r9", + "cancel_at_period_end": false, + "current_period_end": 1452365340, + "current_period_start": 1449686940, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg/subscriptions/sub_7VDQl97MLLoXEp", + "status": 200, + "response": { + "id": "sub_7VDQl97MLLoXEp", + "cancel_at_period_end": false, + "current_period_end": 1452365348, + "current_period_start": 1449686948, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 799 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "DELETE", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg/subscriptions/sub_7VDQYgFOUGI8r9", + "status": 200, + "response": { + "id": "sub_7VDQYgFOUGI8r9", + "cancel_at_period_end": true, + "current_period_end": 1452365340, + "current_period_start": 1449686940, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg/subscriptions/sub_7VDQYgFOUGI8r9", + "status": 200, + "response": { + "id": "sub_7VDQYgFOUGI8r9", + "cancel_at_period_end": true, + "current_period_end": 1452365340, + "current_period_start": 1449686940, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg", + "status": 200, + "response": { + "id": "cus_7VDQzWMIpIdaTg", + "alipay_accounts": { + "has_more": false + }, + "email": "user160@me.com", + "metadata": { + "id": "0000000000000000000186de" + }, + "sources": { + "data": [ + { + "id": "card_17GCznKaReE7xLUdmclsW7nv", + "customer": "cus_7VDQzWMIpIdaTg" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDQl97MLLoXEp", + "cancel_at_period_end": false, + "current_period_end": 1452365348, + "current_period_start": 1449686948, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 799 + }, + { + "id": "sub_7VDQOGP4cNiGgs", + "cancel_at_period_end": false, + "current_period_end": 1452365346, + "current_period_start": 1449686946, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQOGP4cNiGgs" + }, + "metadata": { + "id": "0000000000000000000186dd" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQYgFOUGI8r9", + "cancel_at_period_end": true, + "current_period_end": 1452365340, + "current_period_start": 1449686940, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg", + "status": 200, + "response": { + "id": "cus_7VDQzWMIpIdaTg", + "alipay_accounts": { + "has_more": false + }, + "email": "user160@me.com", + "metadata": { + "id": "0000000000000000000186de" + }, + "sources": { + "data": [ + { + "id": "card_17GCznKaReE7xLUdmclsW7nv", + "customer": "cus_7VDQzWMIpIdaTg" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDQl97MLLoXEp", + "cancel_at_period_end": false, + "current_period_end": 1452365348, + "current_period_start": 1449686948, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 799 + }, + { + "id": "sub_7VDQOGP4cNiGgs", + "cancel_at_period_end": false, + "current_period_end": 1452365346, + "current_period_start": 1449686946, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQOGP4cNiGgs" + }, + "metadata": { + "id": "0000000000000000000186dd" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + }, + { + "id": "sub_7VDQYgFOUGI8r9", + "cancel_at_period_end": true, + "current_period_end": 1452365340, + "current_period_start": 1449686940, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg/subscriptions/sub_7VDQl97MLLoXEp", + "status": 200, + "response": { + "id": "sub_7VDQl97MLLoXEp", + "cancel_at_period_end": false, + "current_period_end": 1452365348, + "current_period_start": 1449686948, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 799 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg/subscriptions/sub_7VDQOGP4cNiGgs", + "status": 200, + "response": { + "id": "sub_7VDQOGP4cNiGgs", + "cancel_at_period_end": false, + "current_period_end": 1452365346, + "current_period_start": 1449686946, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQOGP4cNiGgs" + }, + "metadata": { + "id": "0000000000000000000186dd" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg/subscriptions/sub_7VDQOGP4cNiGgs", + "status": 200, + "response": { + "id": "sub_7VDQOGP4cNiGgs", + "cancel_at_period_end": false, + "current_period_end": 1452365346, + "current_period_start": 1449686946, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQOGP4cNiGgs" + }, + "metadata": { + "id": "0000000000000000000186dd" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "DELETE", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg/subscriptions/sub_7VDQOGP4cNiGgs", + "status": 200, + "response": { + "id": "sub_7VDQOGP4cNiGgs", + "cancel_at_period_end": false, + "current_period_end": 1452365346, + "current_period_start": 1449686946, + "customer": "cus_7VDQzWMIpIdaTg", + "discount": { + "coupon": { + "id": "free" + }, + "customer": "cus_7VDQzWMIpIdaTg", + "subscription": "sub_7VDQOGP4cNiGgs" + }, + "metadata": { + "id": "0000000000000000000186dd" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg", + "status": 200, + "response": { + "id": "cus_7VDQzWMIpIdaTg", + "alipay_accounts": { + "has_more": false + }, + "email": "user160@me.com", + "metadata": { + "id": "0000000000000000000186de" + }, + "sources": { + "data": [ + { + "id": "card_17GCznKaReE7xLUdmclsW7nv", + "customer": "cus_7VDQzWMIpIdaTg" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDQl97MLLoXEp", + "cancel_at_period_end": false, + "current_period_end": 1452365348, + "current_period_start": 1449686948, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 799 + }, + { + "id": "sub_7VDQYgFOUGI8r9", + "cancel_at_period_end": true, + "current_period_end": 1452365340, + "current_period_start": 1449686940, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg/subscriptions/sub_7VDQl97MLLoXEp", + "status": 200, + "response": { + "id": "sub_7VDQl97MLLoXEp", + "cancel_at_period_end": false, + "current_period_end": 1452365348, + "current_period_start": 1449686948, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 0 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg/subscriptions", + "status": 200, + "response": { + "data": [ + { + "id": "sub_7VDQl97MLLoXEp", + "cancel_at_period_end": false, + "current_period_end": 1452365348, + "current_period_start": 1449686948, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 0 + }, + { + "id": "sub_7VDQYgFOUGI8r9", + "cancel_at_period_end": true, + "current_period_end": 1452365340, + "current_period_start": 1449686940, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg", + "status": 200, + "response": { + "id": "cus_7VDQzWMIpIdaTg", + "alipay_accounts": { + "has_more": false + }, + "email": "user160@me.com", + "metadata": { + "id": "0000000000000000000186de" + }, + "sources": { + "data": [ + { + "id": "card_17GCznKaReE7xLUdmclsW7nv", + "customer": "cus_7VDQzWMIpIdaTg" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDQl97MLLoXEp", + "cancel_at_period_end": false, + "current_period_end": 1452365348, + "current_period_start": 1449686948, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 0 + }, + { + "id": "sub_7VDQYgFOUGI8r9", + "cancel_at_period_end": true, + "current_period_end": 1452365340, + "current_period_start": 1449686940, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDQzWMIpIdaTg/subscriptions/sub_7VDQl97MLLoXEp", + "status": 200, + "response": { + "id": "sub_7VDQl97MLLoXEp", + "cancel_at_period_end": false, + "current_period_end": 1452365348, + "current_period_start": 1449686948, + "customer": "cus_7VDQzWMIpIdaTg", + "metadata": { + "id": "0000000000000000000186de" + }, + "plan": { + "id": "incremental", + "amount": 1 + }, + "quantity": 0 + } + } +] \ No newline at end of file diff --git a/spec/fixtures/sub-test-35.json b/spec/fixtures/sub-test-35.json new file mode 100644 index 000000000..486ab4ef5 --- /dev/null +++ b/spec/fixtures/sub-test-35.json @@ -0,0 +1,94 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GD0HKaReE7xLUd0rxsuvV4", + "card": { + "id": "card_17GD0HKaReE7xLUd8s6L2LQd" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDR3TICfZ2dOG", + "alipay_accounts": { + "has_more": false + }, + "email": "user161@me.com", + "metadata": { + "id": "0000000000000000000186df" + }, + "sources": { + "data": [ + { + "id": "card_17GD0HKaReE7xLUd8s6L2LQd", + "customer": "cus_7VDR3TICfZ2dOG" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDR3TICfZ2dOG", + "status": 200, + "response": { + "id": "cus_7VDR3TICfZ2dOG", + "alipay_accounts": { + "has_more": false + }, + "email": "user161@me.com", + "metadata": { + "id": "0000000000000000000186df" + }, + "sources": { + "data": [ + { + "id": "card_17GD0HKaReE7xLUd8s6L2LQd", + "customer": "cus_7VDR3TICfZ2dOG" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/charges", + "status": 200, + "response": { + "id": "ch_17GD0IKaReE7xLUd0tKU82hA", + "amount": 9900, + "customer": "cus_7VDR3TICfZ2dOG", + "metadata": { + "gems": "42000", + "timestamp": "2015" + }, + "paid": true, + "refunds": { + "has_more": false + }, + "source": { + "id": "card_17GD0HKaReE7xLUd8s6L2LQd", + "customer": "cus_7VDR3TICfZ2dOG" + } + } + } +] \ No newline at end of file diff --git a/spec/fixtures/sub-test-36.json b/spec/fixtures/sub-test-36.json new file mode 100644 index 000000000..a7a278d43 --- /dev/null +++ b/spec/fixtures/sub-test-36.json @@ -0,0 +1,94 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GD0JKaReE7xLUdWVmsHjiV", + "card": { + "id": "card_17GD0JKaReE7xLUdtK4zhxIR" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDRHzOeafhAar", + "alipay_accounts": { + "has_more": false + }, + "email": "user162@me.com", + "metadata": { + "id": "0000000000000000000186e0" + }, + "sources": { + "data": [ + { + "id": "card_17GD0JKaReE7xLUdtK4zhxIR", + "customer": "cus_7VDRHzOeafhAar" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDRHzOeafhAar", + "status": 200, + "response": { + "id": "cus_7VDRHzOeafhAar", + "alipay_accounts": { + "has_more": false + }, + "email": "user162@me.com", + "metadata": { + "id": "0000000000000000000186e0" + }, + "sources": { + "data": [ + { + "id": "card_17GD0JKaReE7xLUdtK4zhxIR", + "customer": "cus_7VDRHzOeafhAar" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/charges", + "status": 200, + "response": { + "id": "ch_17GD0LKaReE7xLUdyUUQP4Mr", + "amount": 9900, + "customer": "cus_7VDRHzOeafhAar", + "metadata": { + "gems": "42000", + "timestamp": "2015" + }, + "paid": true, + "refunds": { + "has_more": false + }, + "source": { + "id": "card_17GD0JKaReE7xLUdtK4zhxIR", + "customer": "cus_7VDRHzOeafhAar" + } + } + } +] \ No newline at end of file diff --git a/spec/fixtures/sub-test-37.json b/spec/fixtures/sub-test-37.json new file mode 100644 index 000000000..773828a76 --- /dev/null +++ b/spec/fixtures/sub-test-37.json @@ -0,0 +1,94 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GD0LKaReE7xLUdy08w9LuO", + "card": { + "id": "card_17GD0LKaReE7xLUd4Cm4gxaL" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDRlNbTkRVP3r", + "alipay_accounts": { + "has_more": false + }, + "email": "user163@me.com", + "metadata": { + "id": "0000000000000000000186e1" + }, + "sources": { + "data": [ + { + "id": "card_17GD0LKaReE7xLUd4Cm4gxaL", + "customer": "cus_7VDRlNbTkRVP3r" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDRlNbTkRVP3r", + "status": 200, + "response": { + "id": "cus_7VDRlNbTkRVP3r", + "alipay_accounts": { + "has_more": false + }, + "email": "user163@me.com", + "metadata": { + "id": "0000000000000000000186e1" + }, + "sources": { + "data": [ + { + "id": "card_17GD0LKaReE7xLUd4Cm4gxaL", + "customer": "cus_7VDRlNbTkRVP3r" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/charges", + "status": 200, + "response": { + "id": "ch_17GD0MKaReE7xLUdH67q6iml", + "amount": 9900, + "customer": "cus_7VDRlNbTkRVP3r", + "metadata": { + "gems": "42000", + "timestamp": "2015" + }, + "paid": true, + "refunds": { + "has_more": false + }, + "source": { + "id": "card_17GD0LKaReE7xLUd4Cm4gxaL", + "customer": "cus_7VDRlNbTkRVP3r" + } + } + } +] \ No newline at end of file diff --git a/spec/fixtures/sub-test-38.json b/spec/fixtures/sub-test-38.json new file mode 100644 index 000000000..050be9e1e --- /dev/null +++ b/spec/fixtures/sub-test-38.json @@ -0,0 +1,94 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GD0NKaReE7xLUd6Y69uvhH", + "card": { + "id": "card_17GD0NKaReE7xLUdvoT4Bxbf" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDR4GCxl8RkvD", + "alipay_accounts": { + "has_more": false + }, + "email": "user164@me.com", + "metadata": { + "id": "0000000000000000000186e2" + }, + "sources": { + "data": [ + { + "id": "card_17GD0NKaReE7xLUdvoT4Bxbf", + "customer": "cus_7VDR4GCxl8RkvD" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDR4GCxl8RkvD", + "status": 200, + "response": { + "id": "cus_7VDR4GCxl8RkvD", + "alipay_accounts": { + "has_more": false + }, + "email": "user164@me.com", + "metadata": { + "id": "0000000000000000000186e2" + }, + "sources": { + "data": [ + { + "id": "card_17GD0NKaReE7xLUdvoT4Bxbf", + "customer": "cus_7VDR4GCxl8RkvD" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/charges", + "status": 200, + "response": { + "id": "ch_17GD0OKaReE7xLUdqjX31jEh", + "amount": 9900, + "customer": "cus_7VDR4GCxl8RkvD", + "metadata": { + "gems": "42000", + "timestamp": "2015" + }, + "paid": true, + "refunds": { + "has_more": false + }, + "source": { + "id": "card_17GD0NKaReE7xLUdvoT4Bxbf", + "customer": "cus_7VDR4GCxl8RkvD" + } + } + } +] \ No newline at end of file diff --git a/spec/fixtures/sub-test-39.json b/spec/fixtures/sub-test-39.json new file mode 100644 index 000000000..13d779bcd --- /dev/null +++ b/spec/fixtures/sub-test-39.json @@ -0,0 +1,359 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GD0OKaReE7xLUdiNcc7Cys", + "card": { + "id": "card_17GD0OKaReE7xLUdDRyoVrtY" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers", + "status": 200, + "response": { + "id": "cus_7VDRVYqBwNBHmv", + "alipay_accounts": { + "has_more": false + }, + "email": "user165@me.com", + "metadata": { + "id": "0000000000000000000186e3" + }, + "sources": { + "data": [ + { + "id": "card_17GD0OKaReE7xLUdDRyoVrtY", + "customer": "cus_7VDRVYqBwNBHmv" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDRVYqBwNBHmv", + "status": 200, + "response": { + "id": "cus_7VDRVYqBwNBHmv", + "alipay_accounts": { + "has_more": false + }, + "email": "user165@me.com", + "metadata": { + "id": "0000000000000000000186e3" + }, + "sources": { + "data": [ + { + "id": "card_17GD0OKaReE7xLUdDRyoVrtY", + "customer": "cus_7VDRVYqBwNBHmv" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDRVYqBwNBHmv/subscriptions", + "status": 200, + "response": { + "id": "sub_7VDRuyYXRERHFN", + "cancel_at_period_end": false, + "current_period_end": 1452365378, + "current_period_start": 1449686978, + "customer": "cus_7VDRVYqBwNBHmv", + "metadata": { + "id": "0000000000000000000186e3" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDRVYqBwNBHmv/subscriptions/sub_7VDRuyYXRERHFN", + "status": 200, + "response": { + "id": "sub_7VDRuyYXRERHFN", + "cancel_at_period_end": false, + "current_period_end": 1452365378, + "current_period_start": 1449686978, + "customer": "cus_7VDRVYqBwNBHmv", + "metadata": { + "id": "0000000000000000000186e3" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GD0RKaReE7xLUdo8pKXEBA", + "card": { + "id": "card_17GD0RKaReE7xLUd29ankyPW" + }, + "type": "card" + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDRVYqBwNBHmv", + "status": 200, + "response": { + "id": "cus_7VDRVYqBwNBHmv", + "alipay_accounts": { + "has_more": false + }, + "email": "user165@me.com", + "metadata": { + "id": "0000000000000000000186e3" + }, + "sources": { + "data": [ + { + "id": "card_17GD0OKaReE7xLUdDRyoVrtY", + "customer": "cus_7VDRVYqBwNBHmv" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDRuyYXRERHFN", + "cancel_at_period_end": false, + "current_period_end": 1452365378, + "current_period_start": 1449686978, + "customer": "cus_7VDRVYqBwNBHmv", + "metadata": { + "id": "0000000000000000000186e3" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDRVYqBwNBHmv", + "status": 200, + "response": { + "id": "cus_7VDRVYqBwNBHmv", + "alipay_accounts": { + "has_more": false + }, + "email": "user165@me.com", + "metadata": { + "id": "0000000000000000000186e3" + }, + "sources": { + "data": [ + { + "id": "card_17GD0OKaReE7xLUdDRyoVrtY", + "customer": "cus_7VDRVYqBwNBHmv" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDRuyYXRERHFN", + "cancel_at_period_end": false, + "current_period_end": 1452365378, + "current_period_start": 1449686978, + "customer": "cus_7VDRVYqBwNBHmv", + "metadata": { + "id": "0000000000000000000186e3" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDRVYqBwNBHmv", + "status": 200, + "response": { + "id": "cus_7VDRVYqBwNBHmv", + "alipay_accounts": { + "has_more": false + }, + "email": "user165@me.com", + "metadata": { + "id": "0000000000000000000186e3" + }, + "sources": { + "data": [ + { + "id": "card_17GD0RKaReE7xLUd29ankyPW", + "customer": "cus_7VDRVYqBwNBHmv" + } + ], + "has_more": false + }, + "subscriptions": { + "data": [ + { + "id": "sub_7VDRuyYXRERHFN", + "cancel_at_period_end": false, + "current_period_end": 1452365378, + "current_period_start": 1449686978, + "customer": "cus_7VDRVYqBwNBHmv", + "metadata": { + "id": "0000000000000000000186e3" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "GET", + "path": "/v1/customers/cus_7VDRVYqBwNBHmv/subscriptions", + "status": 200, + "response": { + "data": [ + { + "id": "sub_7VDRuyYXRERHFN", + "cancel_at_period_end": false, + "current_period_end": 1452365378, + "current_period_start": 1449686978, + "customer": "cus_7VDRVYqBwNBHmv", + "metadata": { + "id": "0000000000000000000186e3" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + ], + "has_more": false + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "DELETE", + "path": "/v1/customers/cus_7VDRVYqBwNBHmv/subscriptions/sub_7VDRuyYXRERHFN", + "status": 200, + "response": { + "id": "sub_7VDRuyYXRERHFN", + "cancel_at_period_end": false, + "current_period_end": 1452365378, + "current_period_start": 1449686978, + "customer": "cus_7VDRVYqBwNBHmv", + "metadata": { + "id": "0000000000000000000186e3" + }, + "plan": { + "id": "basic", + "amount": 999 + }, + "quantity": 1 + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/customers/cus_7VDRVYqBwNBHmv", + "status": 200, + "response": { + "id": "cus_7VDRVYqBwNBHmv", + "alipay_accounts": { + "has_more": false + }, + "email": "user165@me.com", + "metadata": { + "id": "0000000000000000000186e3" + }, + "sources": { + "data": [ + { + "id": "card_17GD0RKaReE7xLUd29ankyPW", + "customer": "cus_7VDRVYqBwNBHmv" + } + ], + "has_more": false + }, + "subscriptions": { + "has_more": false + } + } + }, + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/charges", + "status": 200, + "response": { + "id": "ch_17GD0TKaReE7xLUdd4be3O6z", + "amount": 9900, + "customer": "cus_7VDRVYqBwNBHmv", + "metadata": { + "gems": "42000", + "timestamp": "2015" + }, + "paid": true, + "refunds": { + "has_more": false + }, + "source": { + "id": "card_17GD0RKaReE7xLUd29ankyPW", + "customer": "cus_7VDRVYqBwNBHmv" + } + } + } +] \ No newline at end of file diff --git a/spec/fixtures/sub-test-40.json b/spec/fixtures/sub-test-40.json new file mode 100644 index 000000000..9b0fa0146 --- /dev/null +++ b/spec/fixtures/sub-test-40.json @@ -0,0 +1,15 @@ +[ + { + "scope": "https://api.stripe.com:443", + "method": "POST", + "path": "/v1/tokens", + "status": 200, + "response": { + "id": "tok_17GD0UKaReE7xLUdREQ2VEUm", + "card": { + "id": "card_17GD0UKaReE7xLUdL9YrUxgz" + }, + "type": "card" + } + } +] \ No newline at end of file diff --git a/spec/helpers/helper.js b/spec/helpers/helper.js new file mode 100644 index 000000000..76664a21c --- /dev/null +++ b/spec/helpers/helper.js @@ -0,0 +1,71 @@ +var _ = require('lodash'); + +require('coffee-script'); +require('coffee-script/register'); + +// Various assurances that in running tests, we don't accidentally run them +// on the production DB. + +// 1. Make sure there are no environmental variables for COCO_ in place + +var allowedKeys = [ + 'COCO_TRAVIS_TEST' +]; + +var cocoKeysPresent = _.any(_.keys(process.env), function(envKey) { + return envKey.indexOf('COCO_') >= 0 && !_.contains(allowedKeys, envKey); +}); +if (cocoKeysPresent) { + throw Error('Stopping server tests because COCO_ environmental variables are present.'); +} + +// 2. Clear environmental variables anyway +process.env = {}; + +// 3. Check server_config +global.testing = true; +var config = require('../../server_config'); +if(config.mongo.host !== 'localhost') { + throw Error('Stopping server tests because mongo host is not localhost.'); +} + +// 4. Check database string +var database = require('../../server/commons/database'); +var dbString = 'mongodb://localhost:27017/coco_unittest'; +if (database.generateMongoConnectionString() !== dbString) { + throw Error('Stopping server tests because db connection string was not as expected.'); +} + +jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 120; // for long Stripe tests + +describe('Server Test Helper', function() { + it('starts the test server', function(done) { + var server = require('../../server'); + server.startServer(done); + }); + + it('checks the db is fairly empty', function(done) { + // 5. Check actual database. + var User = require('../../server/users/User'); + User.find({}).count(function(err, count) { + // For this to serve as a line of defense against testing with the + // production DB, tests must be run with + expect(err).toBeNull(); + expect(count).toBeLessThan(100); + if(err || count >= 100) { + // the only way to be sure we don't keep going with the tests + process.exit(1); + } + GLOBAL.mc.lists.subscribe = _.noop; + done() + }); + }); + + it('clears the db', function(done) { + var mongoose = require('mongoose'); + mongoose.connection.db.command({dropDatabase:1}, function(err, result) { + if (err) { console.log(err); } + done(); + }); + }) +}); \ No newline at end of file diff --git a/test/server/common.coffee b/spec/server/common.coffee similarity index 91% rename from test/server/common.coffee rename to spec/server/common.coffee index 0635cbc45..5dce83251 100644 --- a/test/server/common.coffee +++ b/spec/server/common.coffee @@ -5,24 +5,10 @@ console.log 'IT BEGINS' if process.env.COCO_MONGO_HOST throw Error('Tests may not run with production environment') -require 'jasmine-spec-reporter' -jasmine.getEnv().defaultTimeoutInterval = 300000 -jasmine.getEnv().reporter.subReporters_ = [] -jasmine.getEnv().addReporter(new jasmine.SpecReporter({ - displayFailedSpec: true - displayPendingSpec: true - displaySpecDuration: true - displaySuccessfulSpec: true - })) - -rep = new jasmine.JsApiReporter() -jasmine.getEnv().addReporter(rep) - GLOBAL._ = require 'lodash' _.str = require 'underscore.string' _.mixin(_.str.exports()) GLOBAL.mongoose = require 'mongoose' -mongoose.connect('mongodb://localhost/coco_unittest') path = require 'path' GLOBAL.testing = true GLOBAL.tv4 = require 'tv4' # required for TreemaUtils to work @@ -252,13 +238,8 @@ _drop = (done) -> chunks = mongoose.connection.db.collection('media.chunks') chunks.remove {}, -> done() + +GLOBAL.resetUserIDCounter = (number=0) -> + auth = require '../../server/routes/auth' + auth.idCounter = number -tickInterval = null -tick = -> - # When you want jasmine-node to exit after running the tests, - # you have to close the connection first. - if rep.finished - mongoose.disconnect() - clearTimeout tickInterval - -tickInterval = setInterval tick, 1000 diff --git a/test/server/functional/achievement.spec.coffee b/spec/server/functional/achievement.spec.coffee similarity index 91% rename from test/server/functional/achievement.spec.coffee rename to spec/server/functional/achievement.spec.coffee index 9d677cd07..e6e4c6a9f 100644 --- a/test/server/functional/achievement.spec.coffee +++ b/spec/server/functional/achievement.spec.coffee @@ -170,24 +170,26 @@ describe 'Achieving Achievements', -> done() it 'verify that a repeatable achievement has been earned', (done) -> - unittest.getNormalJoe (joe) -> - - User.findById(joe.get('_id')).exec (err, joe2) -> - expect(joe2.get('earned').gems).toBe(2) - - EarnedAchievement.find {achievementName: repeatable.name}, (err, docs) -> - expect(err).toBeNull() - expect(docs.length).toBe(1) - achievement = docs[0] - - if achievement - expect(achievement.get 'achievement').toBe repeatable._id - expect(achievement.get 'user').toBe joe._id.toHexString() - expect(achievement.get 'notified').toBeFalsy() - expect(achievement.get 'earnedPoints').toBe 2 * repeatable.worth - expect(achievement.get 'achievedAmount').toBe 2 - expect(achievement.get 'previouslyAchievedAmount').toBeFalsy() - done() + func = -> + unittest.getNormalJoe (joe) -> + + User.findById(joe.get('_id')).exec (err, joe2) -> + expect(joe2.get('earned').gems).toBe(2) + + EarnedAchievement.find {achievementName: repeatable.name}, (err, docs) -> + expect(err).toBeNull() + expect(docs.length).toBe(1) + achievement = docs[0] + + if achievement + expect(achievement.get 'achievement').toBe repeatable._id + expect(achievement.get 'user').toBe joe._id.toHexString() + expect(achievement.get 'notified').toBeFalsy() + expect(achievement.get 'earnedPoints').toBe 2 * repeatable.worth + expect(achievement.get 'achievedAmount').toBe 2 + expect(achievement.get 'previouslyAchievedAmount').toBeFalsy() + done() + setTimeout(func, 500) # give server time to apply achievement it 'verify that the repeatable achievement with complex exp has been earned', (done) -> unittest.getNormalJoe (joe) -> diff --git a/test/server/functional/admin.spec.coffee b/spec/server/functional/admin.spec.coffee similarity index 100% rename from test/server/functional/admin.spec.coffee rename to spec/server/functional/admin.spec.coffee diff --git a/test/server/functional/article.spec.coffee b/spec/server/functional/article.spec.coffee similarity index 100% rename from test/server/functional/article.spec.coffee rename to spec/server/functional/article.spec.coffee diff --git a/test/server/functional/auth.spec.coffee b/spec/server/functional/auth.spec.coffee similarity index 100% rename from test/server/functional/auth.spec.coffee rename to spec/server/functional/auth.spec.coffee diff --git a/test/server/functional/campaign_handler.spec.coffee b/spec/server/functional/campaign_handler.spec.coffee similarity index 100% rename from test/server/functional/campaign_handler.spec.coffee rename to spec/server/functional/campaign_handler.spec.coffee diff --git a/test/server/functional/clan.spec.coffee b/spec/server/functional/clan.spec.coffee similarity index 100% rename from test/server/functional/clan.spec.coffee rename to spec/server/functional/clan.spec.coffee diff --git a/test/server/functional/classrooms.spec.coffee b/spec/server/functional/classrooms.spec.coffee similarity index 100% rename from test/server/functional/classrooms.spec.coffee rename to spec/server/functional/classrooms.spec.coffee diff --git a/test/server/functional/course_instance.spec.coffee b/spec/server/functional/course_instance.spec.coffee similarity index 98% rename from test/server/functional/course_instance.spec.coffee rename to spec/server/functional/course_instance.spec.coffee index 114d079c6..8be250c1b 100644 --- a/test/server/functional/course_instance.spec.coffee +++ b/spec/server/functional/course_instance.spec.coffee @@ -10,7 +10,7 @@ describe 'POST /db/course_instance', -> beforeEach (done) -> loginJoe (@joe) => done() beforeEach init.course() beforeEach init.classroom() - + it 'creates a CourseInstance', (done) -> test = @ url = getURL('/db/course_instance') @@ -23,7 +23,7 @@ describe 'POST /db/course_instance', -> expect(res.statusCode).toBe(200) expect(body.classroomID).toBeDefined() done() - + it 'returns 404 if the Course does not exist', (done) -> test = @ url = getURL('/db/course_instance') @@ -47,7 +47,7 @@ describe 'POST /db/course_instance', -> request.post {uri: url, json: data}, (err, res, body) -> expect(res.statusCode).toBe(404) done() - + it 'return 403 if the logged in user does not own the Classroom', (done) -> test = @ loginSam -> @@ -60,10 +60,10 @@ describe 'POST /db/course_instance', -> request.post {uri: url, json: data}, (err, res, body) -> expect(res.statusCode).toBe(403) done() - - + + describe 'POST /db/course_instance/:id/members', -> - + beforeEach (done) -> clearModels([CourseInstance, Course, User, Classroom, Prepaid], done) beforeEach (done) -> loginJoe (@joe) => done() beforeEach init.course({free: true}) @@ -71,10 +71,10 @@ describe 'POST /db/course_instance/:id/members', -> beforeEach init.courseInstance() beforeEach init.user() beforeEach init.prepaid() - + it 'adds a member to the given CourseInstance', (done) -> async.eachSeries([ - + addTestUserToClassroom, (test, cb) -> url = getURL("/db/course_instance/#{test.courseInstance.id}/members") @@ -83,9 +83,9 @@ describe 'POST /db/course_instance/:id/members', -> expect(body.members.length).toBe(1) expect(body.members[0]).toBe(test.user.id) cb() - + ], makeTestIterator(@), done) - + it 'adds the CourseInstance id to the user', (done) -> async.eachSeries([ @@ -100,16 +100,16 @@ describe 'POST /db/course_instance/:id/members', -> it 'return 403 if the member is not in the classroom', (done) -> async.eachSeries([ - + (test, cb) -> url = getURL("/db/course_instance/#{test.courseInstance.id}/members") request.post {uri: url, json: {userID: test.user.id}}, (err, res) -> expect(res.statusCode).toBe(403) cb() - + ], makeTestIterator(@), done) - - + + it 'returns 403 if the user does not own the course instance and is not adding self', (done) -> async.eachSeries([ @@ -122,12 +122,12 @@ describe 'POST /db/course_instance/:id/members', -> cb() ], makeTestIterator(@), done) - + it 'returns 200 if the user is a member of the classroom and is adding self', -> it 'return 402 if the course is not free and the user is not in a prepaid', (done) -> async.eachSeries([ - + addTestUserToClassroom, makeTestCourseNotFree, (test, cb) -> diff --git a/test/server/functional/db-id-version.spec.coffee b/spec/server/functional/db-id-version.spec.coffee similarity index 100% rename from test/server/functional/db-id-version.spec.coffee rename to spec/server/functional/db-id-version.spec.coffee diff --git a/spec/server/functional/discount_handler.spec.coffee b/spec/server/functional/discount_handler.spec.coffee new file mode 100644 index 000000000..4dc7ac07a --- /dev/null +++ b/spec/server/functional/discount_handler.spec.coffee @@ -0,0 +1,134 @@ +config = require '../../../server_config' +require '../common' + +# sample data that comes in through the webhook when you subscribe + +nockUtils = require '../nock-utils' + +describe '/db/user, editing stripe.couponID property', -> + + stripe = require('stripe')(config.stripe.secretKey) + userURL = getURL('/db/user') + webhookURL = getURL('/stripe/webhook') + afterEach nockUtils.teardownNock + + it 'clears the db first', (done) -> + clearModels [User, Payment], (err) -> + throw err if err + done() + + #- shared data between tests + joeData = null + firstSubscriptionID = null + + it 'does not work for non-admins', (done) -> + loginJoe (joe) -> + joeData = joe.toObject() + expect(joeData.stripe).toBeUndefined() + joeData.stripe = { couponID: '20pct' } + request.put {uri: userURL, json: joeData }, (err, res, body) -> + expect(res.statusCode).toBe(200) # fails silently + expect(res.body.stripe).toBeUndefined() # but still fails + done() + + it 'does not work with invalid coupons', (done) -> + nockUtils.setupNock 'db-discount-handler-test-1.json', (err, nockDone) -> + loginAdmin (admin) -> + joeData.stripe = { couponID: 'DNE' } + request.put {uri: userURL, json: joeData }, (err, res, body) -> + expect(res.statusCode).toBe(404) + nockDone() + done() + + it 'sets the couponID on a user without an existing stripe object', (done) -> + nockUtils.setupNock 'db-discount-handler-test-2.json', (err, nockDone) -> + joeData.stripe = { couponID: '20pct' } + request.put {uri: userURL, json: joeData }, (err, res, body) -> + expect(err).toBeNull() + return done() if err + joeData = body + expect(res.statusCode).toBe(200) + expect(body.stripe.couponID).toBe('20pct') + nockDone() + done() + + it 'just updates the couponID when it changes and there is no existing subscription', (done) -> + nockUtils.setupNock 'db-discount-handler-test-3.json', (err, nockDone) -> + joeData.stripe.couponID = '500off' + request.put {uri: userURL, json: joeData }, (err, res, body) -> + expect(res.statusCode).toBe(200) + expect(body.stripe.couponID).toBe('500off') + nockDone() + done() + + it 'removes the couponID from the user when the admin makes it so', (done) -> + nockUtils.setupNock 'db-discount-handler-test-4.json', (err, nockDone) -> + delete joeData.stripe.couponID + request.put {uri: userURL, json: joeData }, (err, res, body) -> + joeData = body + expect(res.statusCode).toBe(200) + expect(body.stripe).toBeUndefined() + nockDone() + done() + + it 'puts the coupon back', (done) -> + nockUtils.setupNock 'db-discount-handler-test-5.json', (err, nockDone) -> + joeData.stripe = {couponID: '500off'} + request.put {uri: userURL, json: joeData }, (err, res, body) -> + expect(res.statusCode).toBe(200) + expect(body.stripe.couponID).toBe('500off') + nockDone() + done() + + it 'applies a discount to the newly created subscription when a plan is set', (done) -> + nockUtils.setupNock 'db-discount-handler-test-6.json', (err, nockDone) -> + stripe.tokens.create { + card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + stripeTokenID = token.id + loginJoe (joe) -> + joeData.stripe.token = stripeTokenID + joeData.stripe.planID = 'basic' + request.put {uri: userURL, json: joeData, headers: {'X-Change-Plan': 'true'} }, (err, res, body) -> + joeData = body + expect(res.statusCode).toBe(200) + stripe.customers.retrieveSubscription joeData.stripe.customerID, joeData.stripe.subscriptionID, (err, subscription) -> + expect(subscription.discount).toBeDefined() + expect(subscription.discount?.coupon.id).toBe('500off') + nockDone() + done() + + + it 'updates the discount on the customer when an admin changes the couponID', (done) -> + nockUtils.setupNock 'db-discount-handler-test-7.json', (err, nockDone) -> + loginAdmin (admin) -> + joeData.stripe.couponID = '20pct' + request.put {uri: userURL, json: joeData }, (err, res, body) -> + expect(res.statusCode).toBe(200) + expect(body.stripe.couponID).toBe('20pct') + stripe.customers.retrieve joeData.stripe.customerID, (err, customer) -> + expect(customer.discount.coupon.id).toBe('20pct') + nockDone() + done() + + it 'removes discounts from the customer when an admin removes the couponID', (done) -> + nockUtils.setupNock 'db-discount-handler-test-8.json', (err, nockDone) -> + delete joeData.stripe.couponID + request.put {uri: userURL, json: joeData }, (err, res, body) -> + expect(res.statusCode).toBe(200) + expect(body.stripe.couponID).toBeUndefined() + stripe.customers.retrieve joeData.stripe.customerID, (err, customer) -> + expect(customer.discount).toBeFalsy() + nockDone() + done() + + it 'adds a discount to the customer when an admin adds the couponID', (done) -> + nockUtils.setupNock 'db-discount-handler-test-9.json', (err, nockDone) -> + joeData.stripe.couponID = '20pct' + request.put {uri: userURL, json: joeData }, (err, res, body) -> + expect(res.statusCode).toBe(200) + expect(body.stripe.couponID).toBe('20pct') + stripe.customers.retrieve joeData.stripe.customerID, (err, customer) -> + expect(customer.discount.coupon.id).toBe('20pct') + nockDone() + done() diff --git a/test/server/functional/file.spec.coffee b/spec/server/functional/file.spec.coffee similarity index 100% rename from test/server/functional/file.spec.coffee rename to spec/server/functional/file.spec.coffee diff --git a/test/server/functional/folder.spec.coffee b/spec/server/functional/folder.spec.coffee similarity index 100% rename from test/server/functional/folder.spec.coffee rename to spec/server/functional/folder.spec.coffee diff --git a/test/server/functional/languages.spec.coffee b/spec/server/functional/languages.spec.coffee similarity index 100% rename from test/server/functional/languages.spec.coffee rename to spec/server/functional/languages.spec.coffee diff --git a/test/server/functional/level.spec.coffee b/spec/server/functional/level.spec.coffee similarity index 100% rename from test/server/functional/level.spec.coffee rename to spec/server/functional/level.spec.coffee diff --git a/test/server/functional/level_component.spec.coffee b/spec/server/functional/level_component.spec.coffee similarity index 96% rename from test/server/functional/level_component.spec.coffee rename to spec/server/functional/level_component.spec.coffee index a0c3b33e8..2748d2e51 100644 --- a/test/server/functional/level_component.spec.coffee +++ b/spec/server/functional/level_component.spec.coffee @@ -121,11 +121,6 @@ describe 'LevelComponent', -> expect(body.version.isLatestMajor).toBe(false) done() - xit ' can\'t be requested with HTTP PUT method', (done) -> - request.put {uri: url+'/'+components[0]._id}, (err, res) -> - expect(res.statusCode).toBe(405) - done() - it ' can\'t be requested with HTTP HEAD method', (done) -> request.head {uri: url+'/'+components[0]._id}, (err, res) -> expect(res.statusCode).toBe(405) diff --git a/test/server/functional/level_feedback.spec.coffee b/spec/server/functional/level_feedback.spec.coffee similarity index 100% rename from test/server/functional/level_feedback.spec.coffee rename to spec/server/functional/level_feedback.spec.coffee diff --git a/test/server/functional/level_session.spec.coffee b/spec/server/functional/level_session.spec.coffee similarity index 100% rename from test/server/functional/level_session.spec.coffee rename to spec/server/functional/level_session.spec.coffee diff --git a/test/server/functional/level_system.spec.coffee b/spec/server/functional/level_system.spec.coffee similarity index 100% rename from test/server/functional/level_system.spec.coffee rename to spec/server/functional/level_system.spec.coffee diff --git a/test/server/functional/level_thang_component.spec.coffee b/spec/server/functional/level_thang_component.spec.coffee similarity index 100% rename from test/server/functional/level_thang_component.spec.coffee rename to spec/server/functional/level_thang_component.spec.coffee diff --git a/test/server/functional/level_thang_type.spec.coffee b/spec/server/functional/level_thang_type.spec.coffee similarity index 100% rename from test/server/functional/level_thang_type.spec.coffee rename to spec/server/functional/level_thang_type.spec.coffee diff --git a/test/server/functional/mail.spec.coffee b/spec/server/functional/mail.spec.coffee similarity index 100% rename from test/server/functional/mail.spec.coffee rename to spec/server/functional/mail.spec.coffee diff --git a/spec/server/functional/nocked.spec.coffee b/spec/server/functional/nocked.spec.coffee new file mode 100644 index 000000000..3883c86fa --- /dev/null +++ b/spec/server/functional/nocked.spec.coffee @@ -0,0 +1,29 @@ +request = require 'request' +require '../common' +config = require '../../../server_config' +nockUtils = require('../nock-utils') + +xdescribe 'nock-utils', -> + afterEach nockUtils.teardownNock + + describe 'a test using setupNock', -> + it 'records and plays back third-party requests, but not localhost requests', (done) -> + nockUtils.setupNock 'nock-test.json', (err, nockDone) -> + request.get { uri: getURL('/db/level') }, (err) -> + expect(err).toBeNull() + t0 = new Date().getTime() + request.get { uri: 'http://zombo.com/' }, (err) -> + console.log 'cached speed', new Date().getTime() - t0 + expect(err).toBeNull() + nockDone() + done() + + describe 'another, sibling test that does not use setupNock', -> + it 'is proceeds normally', (done) -> + request.get { uri: getURL('/db/level') }, (err) -> + expect(err).toBeNull() + t0 = new Date().getTime() + request.get { uri: 'http://zombo.com/' }, (err) -> + console.log 'uncached speed', new Date().getTime() - t0 + expect(err).toBeNull() + done() diff --git a/test/server/functional/patch.spec.coffee b/spec/server/functional/patch.spec.coffee similarity index 100% rename from test/server/functional/patch.spec.coffee rename to spec/server/functional/patch.spec.coffee diff --git a/spec/server/functional/payment.spec.coffee b/spec/server/functional/payment.spec.coffee new file mode 100644 index 000000000..f1adba083 --- /dev/null +++ b/spec/server/functional/payment.spec.coffee @@ -0,0 +1,483 @@ +testReceipt = 'MIIVEQYJKoZIhvcNAQcCoIIVAjCCFP4CAQExCzAJBgUrDgMCGgUAMIIEwgYJKoZIhvcNAQcBoIIEswSCBK8xggSrMAoCAQgCAQEEAhYAMAoCARQCAQEEAgwAMAsCAQECAQEEAwIBADALAgEDAgEBBAMMATkwCwIBCwIBAQQDAgEAMAsCAQ4CAQEEAwIBTTALAgEPAgEBBAMCAQAwCwIBEAIBAQQDAgEAMAsCARkCAQEEAwIBAzAMAgEKAgEBBAQWAjQrMA0CAQ0CAQEEBQIDATjkMA0CARMCAQEEBQwDMS4wMA4CAQkCAQEEBgIEUDIzMTAYAgEEAgECBBBFm6ID3eNcNpCJVGMvofTCMBsCAQACAQEEEwwRUHJvZHVjdGlvblNhbmRib3gwHAIBBQIBAQQUshze7K1i43z3C/N8znUlSOq0OpkwHgIBDAIBAQQWFhQyMDE0LTExLTEyVDAwOjUwOjM3WjAeAgESAgEBBBYWFDIwMTMtMDgtMDFUMDc6MDA6MDBaMCMCAQICAQEEGwwZY29tLmNvZGVjb21iYXQuQ29kZUNvbWJhdDBCAgEHAgEBBDqqVISWC4wNjaBXqlNV7plPdTXyDx32V1y7ydj0cF8hhG/4rs/XJxhXtesY4ke9xCSq9+SQbgDWUAgAMF0CAQYCAQEEVfREWcK86WrR/8tApnityEV/y1WFszw7Pso3NclvMXkL5qBE0tBvLF8mO890BdA1Dr0TjkN69uLToEn/uVYjmKJ388shlls6eE3krpaFsl/48qVSADkwggFLAgERAgEBBIIBQTGCAT0wCwICBqwCAQEEAhYAMAsCAgatAgEBBAIMADALAgIGsAIBAQQCFgAwCwICBrICAQEEAgwAMAsCAgazAgEBBAIMADALAgIGtAIBAQQCDAAwCwICBrUCAQEEAgwAMAsCAga2AgEBBAIMADAMAgIGpQIBAQQDAgEBMAwCAgarAgEBBAMCAQEwDAICBq4CAQEEAwIBADAMAgIGrwIBAQQDAgEAMAwCAgaxAgEBBAMCAQAwEQICBqYCAQEECAwGZ2Vtc181MBsCAganAgEBBBIMEDEwMDAwMDAxMzEyNzQ0MzkwGwICBqkCAQEEEgwQMTAwMDAwMDEzMTI3NDQzOTAfAgIGqAIBAQQWFhQyMDE0LTExLTEyVDAwOjUwOjM3WjAfAgIGqgIBAQQWFhQyMDE0LTExLTExVDIxOjQyOjU4WjCCAUwCARECAQEEggFCMYIBPjALAgIGrAIBAQQCFgAwCwICBq0CAQEEAgwAMAsCAgawAgEBBAIWADALAgIGsgIBAQQCDAAwCwICBrMCAQEEAgwAMAsCAga0AgEBBAIMADALAgIGtQIBAQQCDAAwCwICBrYCAQEEAgwAMAwCAgalAgEBBAMCAQEwDAICBqsCAQEEAwIBATAMAgIGrgIBAQQDAgEAMAwCAgavAgEBBAMCAQAwDAICBrECAQEEAwIBADASAgIGpgIBAQQJDAdnZW1zXzEwMBsCAganAgEBBBIMEDEwMDAwMDAxMzEyODM2MDgwGwICBqkCAQEEEgwQMTAwMDAwMDEzMTI4MzYwODAfAgIGqAIBAQQWFhQyMDE0LTExLTEyVDAwOjUwOjM3WjAfAgIGqgIBAQQWFhQyMDE0LTExLTEyVDAwOjUwOjM3WqCCDlUwggVrMIIEU6ADAgECAggYWUMhcnSc/DANBgkqhkiG9w0BAQUFADCBljELMAkGA1UEBhMCVVMxEzARBgNVBAoMCkFwcGxlIEluYy4xLDAqBgNVBAsMI0FwcGxlIFdvcmxkd2lkZSBEZXZlbG9wZXIgUmVsYXRpb25zMUQwQgYDVQQDDDtBcHBsZSBXb3JsZHdpZGUgRGV2ZWxvcGVyIFJlbGF0aW9ucyBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0xMDExMTEyMTU4MDFaFw0xNTExMTEyMTU4MDFaMHgxJjAkBgNVBAMMHU1hYyBBcHAgU3RvcmUgUmVjZWlwdCBTaWduaW5nMSwwKgYDVQQLDCNBcHBsZSBXb3JsZHdpZGUgRGV2ZWxvcGVyIFJlbGF0aW9uczETMBEGA1UECgwKQXBwbGUgSW5jLjELMAkGA1UEBhMCVVMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC2k8K3DyRe7dI0SOiFBeMzlGZb6Cc3v3tDSev5yReXM3MySUrIb2gpFLiUpvRlSztH19EsZku4mNm89RJRy+YvqfSznxzoKPxSwIGiy1ZigFqika5OQMN9KC7X0+1N2a2K+/JnSOzreb0CbQRZGP+MN5+KN/Fi/7uiA1CHCtWS4IYRXiNG9eElYyuiaoyyELeRI02aP4NA8mQJWveNrlZc1PW0bgMbBF0sG68AmRfXpftJkc7ioRExXhkBwNrOUINeyOtJO0kaKurgn7/SRkmc2Kuhg2FsD8H8s62ZdSr8I5vvIgjre1kUEZ9zNC3muTmmO/fmPuzKpvurrybfj4iBAgMBAAGjggHYMIIB1DAMBgNVHRMBAf8EAjAAMB8GA1UdIwQYMBaAFIgnFwmpthhgi+zruvZHWcVSVKO3ME0GA1UdHwRGMEQwQqBAoD6GPGh0dHA6Ly9kZXZlbG9wZXIuYXBwbGUuY29tL2NlcnRpZmljYXRpb25hdXRob3JpdHkvd3dkcmNhLmNybDAOBgNVHQ8BAf8EBAMCB4AwHQYDVR0OBBYEFHV2JKJrYgyXNKH6Tl4IDCK/c+++MIIBEQYDVR0gBIIBCDCCAQQwggEABgoqhkiG92NkBQYBMIHxMIHDBggrBgEFBQcCAjCBtgyBs1JlbGlhbmNlIG9uIHRoaXMgY2VydGlmaWNhdGUgYnkgYW55IHBhcnR5IGFzc3VtZXMgYWNjZXB0YW5jZSBvZiB0aGUgdGhlbiBhcHBsaWNhYmxlIHN0YW5kYXJkIHRlcm1zIGFuZCBjb25kaXRpb25zIG9mIHVzZSwgY2VydGlmaWNhdGUgcG9saWN5IGFuZCBjZXJ0aWZpY2F0aW9uIHByYWN0aWNlIHN0YXRlbWVudHMuMCkGCCsGAQUFBwIBFh1odHRwOi8vd3d3LmFwcGxlLmNvbS9hcHBsZWNhLzAQBgoqhkiG92NkBgsBBAIFADANBgkqhkiG9w0BAQUFAAOCAQEAoDvxh7xptLeDfBn0n8QCZN8CyY4xc8scPtwmB4v9nvPtvkPWjWEt5PDcFnMB1jSjaRl3FL+5WMdSyYYAf2xsgJepmYXoePOaEqd+ODhk8wTLX/L2QfsHJcsCIXHzRD/Q4nth90Ljq793bN0sUJyAhMWlb1hZekYxQWi7EzVFQqSM+hHVSxbyMjXeH7zSmV3I5gIyWZDojcs53yHaw3b7ejYaFhqYTIUb5itFLS9ZGi3GmtZmkqPSNlJQgCBNM8iymtZTYrFgUvD1930QUOQSv71xvrSAx23Eb1s5NdHnt96BICeOOFyChzpzYMTW8RygqWZEfs4MKJsjf6zs5qA73TCCBCMwggMLoAMCAQICARkwDQYJKoZIhvcNAQEFBQAwYjELMAkGA1UEBhMCVVMxEzARBgNVBAoTCkFwcGxlIEluYy4xJjAkBgNVBAsTHUFwcGxlIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRYwFAYDVQQDEw1BcHBsZSBSb290IENBMB4XDTA4MDIxNDE4NTYzNVoXDTE2MDIxNDE4NTYzNVowgZYxCzAJBgNVBAYTAlVTMRMwEQYDVQQKDApBcHBsZSBJbmMuMSwwKgYDVQQLDCNBcHBsZSBXb3JsZHdpZGUgRGV2ZWxvcGVyIFJlbGF0aW9uczFEMEIGA1UEAww7QXBwbGUgV29ybGR3aWRlIERldmVsb3BlciBSZWxhdGlvbnMgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDKOFSmy1aqyCQ5SOmM7uxfuH8mkbw0U3rOfGOAYXdkXqUHI7Y5/lAtFVZYcC1+xG7BSoU+L/DehBqhV8mvexj/avoVEkkVCBmsqtsqMu2WY2hSFT2Miuy/axiV4AOsAX2XBWfODoWVN2rtCbauZ81RZJ/GXNG8V25nNYB2NqSHgW44j9grFU57Jdhav06DwY3Sk9UacbVgnJ0zTlX5ElgMhrgWDcHld0WNUEi6Ky3klIXh6MSdxmilsKP8Z35wugJZS3dCkTm59c3hTO/AO0iMpuUhXf1qarunFjVg0uat80YpyejDi+l5wGphZxWy8P3laLxiX27Pmd3vG2P+kmWrAgMBAAGjga4wgaswDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFIgnFwmpthhgi+zruvZHWcVSVKO3MB8GA1UdIwQYMBaAFCvQaUeUdgn+9GuNLkCm90dNfwheMDYGA1UdHwQvMC0wK6ApoCeGJWh0dHA6Ly93d3cuYXBwbGUuY29tL2FwcGxlY2Evcm9vdC5jcmwwEAYKKoZIhvdjZAYCAQQCBQAwDQYJKoZIhvcNAQEFBQADggEBANoyAJbFVJTTO4I3Zn0uaNXDxrjLJoxIkM8TJGpGjmPU8NATBt3YxME3FfIzEzkmLc4uVUDjCwOv+hLC5w0huNWAz6woL84ts06vhhkExulQ3UwpRxAj/Gy7G5hrSInhW53eRts1hTXvPtDiWEs49O11Wh9ccB1WORLl4Q0R5IklBr3VtBWOXtBZl5DpS4Hi3xivRHQeGaA6R8yRHTrrI1r+pS2X93u71odGQoXrUj0msmOotLHKj/TM4rPIR+C/mlmD+tqYUyqC9XxlLpXZM1317WXMMTfFWgToa+HniANKdZ6bKMtKQIhlQ3XdyzolI8WeV/guztKpkl5zLi8ldRUwggS7MIIDo6ADAgECAgECMA0GCSqGSIb3DQEBBQUAMGIxCzAJBgNVBAYTAlVTMRMwEQYDVQQKEwpBcHBsZSBJbmMuMSYwJAYDVQQLEx1BcHBsZSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEWMBQGA1UEAxMNQXBwbGUgUm9vdCBDQTAeFw0wNjA0MjUyMTQwMzZaFw0zNTAyMDkyMTQwMzZaMGIxCzAJBgNVBAYTAlVTMRMwEQYDVQQKEwpBcHBsZSBJbmMuMSYwJAYDVQQLEx1BcHBsZSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEWMBQGA1UEAxMNQXBwbGUgUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOSRqQkfkdseR1DrBe1eeYQt6zaiV0xV7IsZid75S2z1B6siMALoGD74UAnTf0GomPnRymacJGsR0KO75Bsqwx+VnnoMpEeLW9QWNzPLxA9NzhRp0ckZcvVdDtV/X5vyJQO6VY9NXQ3xZDUjFUsVWR2zlPf2nJ7PULrBWFBnjwi0IPfLrCwgb3C2PwEwjLdDzw+dPfMrSSgayP7OtbkO2V4c1ss9tTqt9A8OAJILsSEWLnTVPA3bYharo3GSR1NVwa8vQbP4++NwzeajTEV+H0xrUJZBicR0YgsQg0GHM4qBsTBY7FoEMoxos48d3mVz/2deZbxJ2HafMxRloXeUyS0CAwEAAaOCAXowggF2MA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBQr0GlHlHYJ/vRrjS5ApvdHTX8IXjAfBgNVHSMEGDAWgBQr0GlHlHYJ/vRrjS5ApvdHTX8IXjCCAREGA1UdIASCAQgwggEEMIIBAAYJKoZIhvdjZAUBMIHyMCoGCCsGAQUFBwIBFh5odHRwczovL3d3dy5hcHBsZS5jb20vYXBwbGVjYS8wgcMGCCsGAQUFBwICMIG2GoGzUmVsaWFuY2Ugb24gdGhpcyBjZXJ0aWZpY2F0ZSBieSBhbnkgcGFydHkgYXNzdW1lcyBhY2NlcHRhbmNlIG9mIHRoZSB0aGVuIGFwcGxpY2FibGUgc3RhbmRhcmQgdGVybXMgYW5kIGNvbmRpdGlvbnMgb2YgdXNlLCBjZXJ0aWZpY2F0ZSBwb2xpY3kgYW5kIGNlcnRpZmljYXRpb24gcHJhY3RpY2Ugc3RhdGVtZW50cy4wDQYJKoZIhvcNAQEFBQADggEBAFw2mUwteLftjJvc83eb8nbSdzBPwR+Fg4UbmT1HN/Kpm0COLNSxkBLYvvRzm+7SZA/LeU802KI++Xj/a8gH7H05g4tTINM4xLG/mk8Ka/8r/FmnBQl8F0BWER5007eLIztHo9VvJOLr0bdw3w9F4SfK8W147ee1Fxeo3H4iNcol1dkP1mvUoiQjEfehrI9zgWDGG1sJL5Ky+ERI8GA4nhX1PSZnIIozavcNgs/e66Mv+VNqW2TAYzN39zoHLFbr2g8hDtq6cxlPtdk2f8GHVdmnmbkyQvvY1XGefqFStxu9k0IkEirHDx22TZxeY8hLgBdQqorV2uT80AkHN7B1dSExggHLMIIBxwIBATCBozCBljELMAkGA1UEBhMCVVMxEzARBgNVBAoMCkFwcGxlIEluYy4xLDAqBgNVBAsMI0FwcGxlIFdvcmxkd2lkZSBEZXZlbG9wZXIgUmVsYXRpb25zMUQwQgYDVQQDDDtBcHBsZSBXb3JsZHdpZGUgRGV2ZWxvcGVyIFJlbGF0aW9ucyBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eQIIGFlDIXJ0nPwwCQYFKw4DAhoFADANBgkqhkiG9w0BAQEFAASCAQCsTExkCPLotDyUC58PSCh7DBlv/qyZl0JTf/mrx7PPOdO0TB2RjEG7R0TIim9xoKIq1gY0gVdP5X+cpLNRhfB64cHmA5eMXXpyZChQu664gPJ22y0bjcz2q69NF/dDVwrIw7Y6/YGi5+PGE8gQKbIEyFGknKmpz7+r9lUwzaQ8rjS0bYGFlmxTOAvW0bRa1Ok04Qt38K7rs1ondBcSwAilGdp6pVVwJIx/UGGpVsqFuN54n6NwM56TJHX8InBHMvLawMt1eH+4ghwLgpi7uNiIAyvt4IxcHU36ktc42ACswyfEMBCUVA4+bo0QlB0q25EgbQ5MV0J1XCJoYWUjP4iI' + +config = require '../../../server_config' +require '../common' +nockUtils = require '../nock-utils' + + +describe '/db/payment', -> + request = require 'request' + paymentURL = getURL('/db/payment') + checkChargesURL = getURL('/db/payment/check-stripe-charges') + customPaymentURL = getURL('/db/payment/custom') + + firstApplePayment = { + apple: { + rawReceipt: testReceipt + transactionID: '1000000131274439' + localPrice: '$5.00' + } + } + + secondApplePayment = { + apple: { + rawReceipt: testReceipt + transactionID: '1000000131283608' + localPrice: '$10.00' + } + } + + paymentCreated = null + + it 'clears the db first', (done) -> + clearModels [User, Payment], (err) -> + throw err if err + done() + + describe 'posting Apple IAPs', -> + + afterEach nockUtils.teardownNock + + it 'denies anonymous users trying to pay', (done) -> + request.get getURL('/auth/whoami'), -> + request.post {uri: paymentURL, json: firstApplePayment}, (err, res, body) -> + expect(res.statusCode).toBe 403 + done() + + it 'creates a payment object and credits gems to the user', (done) -> + nockUtils.setupNock 'db-payment-apple-test-1.json', (err, nockDone) -> + loginJoe -> + request.post {uri: paymentURL, json: firstApplePayment}, (err, res, body) -> + paymentCreated = body?._id + expect(res.statusCode).toBe 201 + User.findOne({name:'Joe'}).exec(err, (err, user) -> + expect(user.get('purchased')?.gems).toBe(5000) + nockDone() + done() + ) + + it 'is idempotent', (done) -> + nockUtils.setupNock 'db-payment-apple-test-2.json', (err, nockDone) -> + loginJoe -> + request.post {uri: paymentURL, json: firstApplePayment}, (err, res, body) -> + expect(body._id is paymentCreated).toBe(true) + expect(res.statusCode).toBe 200 + User.findOne({name:'Joe'}).exec(err, (err, user) -> + expect(user.get('purchased')?.gems).toBe(5000) + nockDone() + done() + ) + + it 'prevents other users from reusing payment receipts', (done) -> + nockUtils.setupNock 'db-payment-apple-test-3.json', (err, nockDone) -> + loginSam -> + request.post {uri: paymentURL, json: firstApplePayment}, (err, res, body) -> + expect(res.statusCode).toBe 403 + nockDone() + done() + + it 'processes only the transactionID that is given', (done) -> + nockUtils.setupNock 'db-payment-apple-test-4.json', (err, nockDone) -> + loginJoe -> + request.post {uri: paymentURL, json: secondApplePayment}, (err, res, body) -> + expect(body._id is paymentCreated).toBe(false) + expect(res.statusCode).toBe 201 + User.findOne({name:'Joe'}).exec(err, (err, user) -> + expect(user.get('purchased')?.gems).toBe(16000) + nockDone() + done() + ) + + describe 'posting Stripe purchases', -> + afterEach nockUtils.teardownNock + stripe = require('stripe')(config.stripe.secretKey) + + charge = null + joeID = null + timestamp = 1447443579286 + stripeTokenID = null + joeData = null + + it 'clears the db first', (done) -> + clearModels [User, Payment], (err) -> + throw err if err + done() + + it 'handles a purchase', (done) -> + nockUtils.setupNock 'db-payment-stripe-test-01.json', { keep: {productID: true} }, (err, nockDone) -> + stripe.tokens.create({ + card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + stripeTokenID = token.id + loginJoe (joe) -> + joeID = joe.get('_id')+'' + data = { + productID: 'gems_5' + stripe: { + token: token.id + timestamp: timestamp + } + } + request.post {uri: paymentURL, json: data }, (err, res, body) -> + expect(res.statusCode).toBe 201 + expect(body.stripe.chargeID).toBeDefined() + expect(body.stripe.timestamp).toBe(timestamp) + expect(body.stripe.customerID).toBeDefined() + expect(body.gems).toBe(5000) + expect(body.amount).toBe(499) + expect(body.productID).toBe('gems_5') + expect(body.service).toBe('stripe') + expect(body.recipient).toBe(joeID) + expect(body.purchaser).toBe(joeID) + User.findById(joe.get('_id'), (err, user) -> + expect(user.get('purchased').gems).toBe(5000) + expect(user.get('stripe').customerID).toBe(body.stripe.customerID) + nockDone() + done() + ) + ) + + it 'ignores repeated purchases', (done) -> + nockUtils.setupNock 'db-payment-stripe-test-02.json', (err, nockDone) -> + data = { productID: 'gems_5', stripe: { token: stripeTokenID, timestamp: timestamp } } + request.post {uri: paymentURL, json: data }, (err, res, body) -> + expect(res.statusCode).toBe 200 + Payment.count({}, (err, count) -> + expect(count).toBe(1) + User.findById(joeID, (err, user) -> + expect(user.get('purchased').gems).toBe(5000) + nockDone() + done() + ) + ) + + it 'allows a new charge on the existing customer', (done) -> + nockUtils.setupNock 'db-payment-stripe-test-03.json', (err, nockDone) -> + data = { productID: 'gems_5', stripe: { timestamp: new Date().getTime() } } + request.post {uri: paymentURL, json: data }, (err, res, body) -> + expect(res.statusCode).toBe 201 + Payment.count {}, (err, count) -> + expect(count).toBe(2) + User.findById joeID, (err, user) -> + joeData = user.toObject() + expect(user.get('purchased').gems).toBe(10000) + nockDone() + done() + + it "updates the customer's card when you submit a new token", (done) -> + nockUtils.setupNock 'db-payment-stripe-test-04.json', (err, nockDone) -> + stripe.customers.retrieve joeData.stripe.customerID, (err, customer) -> + originalCustomerID = customer.id + originalCardID = customer.sources.data[0].id + stripe.tokens.create { + card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + data = { productID: 'gems_5', stripe: { timestamp: new Date().getTime(), token: token.id } } + request.post {uri: paymentURL, json: data }, (err, res, body) -> + expect(res.statusCode).toBe(201) + User.findById joeID, (err, user) -> + joeData = user.toObject() + expect(joeData.stripe.customerID).toBe(originalCustomerID) + stripe.customers.retrieve joeData.stripe.customerID, (err, customer) -> + expect(customer.sources.data[0].id).not.toBe(originalCardID) + nockDone() + done() + + it 'clears the db', (done) -> + clearModels [User, Payment], (err) -> + throw err if err + done() + + it 'recovers from breaking between charge and document creation', (done) -> + nockUtils.setupNock 'db-payment-stripe-test-05.json', (err, nockDone) -> + stripe.tokens.create({ + card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + + data = { + productID: 'gems_5' + stripe: { token: token.id, timestamp: timestamp } + breakAfterCharging: true + } + + loginJoe (joe) -> + request.post {uri: paymentURL, json: data }, (err, res, body) -> + expect(res.statusCode).toBe 500 + + data = _.omit data, 'breakAfterCharging' + request.post {uri: paymentURL, json: data }, (err, res, body) -> + expect(res.statusCode).toBe 201 + + Payment.count({}, (err, count) -> + expect(count).toBe(1) + User.findById(joe.get('_id'), (err, user) -> + expect(user.get('purchased').gems).toBe(5000) + nockDone() + done() + ) + ) + ) + + it 'clears the db', (done) -> + clearModels [User, Payment], (err) -> + throw err if err + done() + + # Testing card numbers are here: https://stripe.com/docs/testing + + it 'handles card that attaches to customer but fails to be charged', (done) -> + nockUtils.setupNock 'db-payment-stripe-test-06.json', (err, nockDone) -> + stripe.tokens.create({ + card: { number: '4000000000000341', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + loginJoe (joe) -> + timestamp = new Date().getTime() + data = { productID: 'gems_5', stripe: { token: token.id, timestamp: timestamp } } + request.post {uri: paymentURL, json: data }, (err, res, body) -> + expect(res.statusCode).toBe(402) + nockDone() + done() + ) + + it 'handles card that always is declined with card_declined code', (done) -> + nockUtils.setupNock 'db-payment-stripe-test-07.json', (err, nockDone) -> + stripe.tokens.create({ + card: { number: '4000000000000002', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + loginJoe (joe) -> + timestamp = new Date().getTime() + data = { productID: 'gems_5', stripe: { token: token.id, timestamp: timestamp } } + request.post {uri: paymentURL, json: data }, (err, res, body) -> + expect(res.statusCode).toBe(402) + nockDone() + done() + ) + + it 'handles card that always is declined with incorrect_cvc code', (done) -> + nockUtils.setupNock 'db-payment-stripe-test-08.json', (err, nockDone) -> + stripe.tokens.create({ + card: { number: '4000000000000127', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + loginJoe (joe) -> + timestamp = new Date().getTime() + data = { productID: 'gems_5', stripe: { token: token.id, timestamp: timestamp } } + request.post {uri: paymentURL, json: data }, (err, res, body) -> + expect(res.statusCode).toBe(402) + nockDone() + done() + ) + + it 'handles card that always is declined with expired_card code', (done) -> + nockUtils.setupNock 'db-payment-stripe-test-09.json', (err, nockDone) -> + stripe.tokens.create({ + card: { number: '4000000000000069', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + loginJoe (joe) -> + timestamp = new Date().getTime() + data = { productID: 'gems_5', stripe: { token: token.id, timestamp: timestamp } } + request.post {uri: paymentURL, json: data }, (err, res, body) -> + expect(res.statusCode).toBe(402) + nockDone() + done() + ) + + it 'handles card that always is declined with processing_error code', (done) -> + nockUtils.setupNock 'db-payment-stripe-test-10.json', (err, nockDone) -> + stripe.tokens.create({ + card: { number: '4000000000000119', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + loginJoe (joe) -> + timestamp = new Date().getTime() + data = { productID: 'gems_5', stripe: { token: token.id, timestamp: timestamp } } + request.post {uri: paymentURL, json: data }, (err, res, body) -> + expect(res.statusCode).toBe(402) + nockDone() + done() + ) + + describe '/db/payment/check-stripe-charges', -> + afterEach nockUtils.teardownNock + stripe = require('stripe')(config.stripe.secretKey) + + it 'clears the db', (done) -> + clearModels [User, Payment], (err) -> + throw err if err + done() + + it 'finds and records charges which are not in our db', (done) -> + nockUtils.setupNock 'db-payment-check-stripe-charges-test-01.json', (err, nockDone) -> + timestamp = new Date().getTime() + stripe.tokens.create { + card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + + data = { + productID: 'gems_5' + stripe: { token: token.id, timestamp: timestamp } + breakAfterCharging: true + } + + loginJoe (joe) -> + request.post {uri: paymentURL, json: data }, (err, res, body) -> + expect(res.statusCode).toBe 500 + + request.post { uri: checkChargesURL }, (err, res, body) -> + expect(res.statusCode).toBe 201 + Payment.count({}, (err, count) -> + expect(count).toBe(1) + User.findById(joe.get('_id'), (err, user) -> + expect(user.get('purchased').gems).toBe(5000) + nockDone() + done() + ) + ) + + describe '/db/payment/custom', -> + afterEach nockUtils.teardownNock + stripe = require('stripe')(config.stripe.secretKey) + + it 'clears the db', (done) -> + clearModels [User, Payment], (err) -> + throw err if err + done() + + it 'handles a custom purchase with description', (done) -> + nockUtils.setupNock 'db-payment-custom-stripe-test-01.json', { keep: { 'description': true, 'productID': true }}, (err, nockDone) -> + timestamp = 1447445242091 + amount = 5000 + description = 'A sweet Coco t-shirt' + + stripe.tokens.create({ + card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + stripeTokenID = token.id + loginJoe (joe) -> + joeID = joe.get('_id') + '' + data = { + amount: amount + description: description + stripe: { + token: token.id + timestamp: timestamp + } + } + request.post {uri: customPaymentURL, json: data }, (err, res, body) -> + expect(res.statusCode).toBe 201 + expect(body.stripe.chargeID).toBeDefined() + expect(body.stripe.timestamp).toBe(timestamp) + expect(body.stripe.customerID).toBeDefined() + expect(body.description).toEqual(description) + expect(body.amount).toEqual(amount) + expect(body.productID).toBe('custom') + expect(body.service).toBe('stripe') + expect(body.recipient).toBe(joeID) + expect(body.purchaser).toBe(joeID) + User.findById(joe.get('_id'), (err, user) -> + expect(user.get('stripe').customerID).toBe(body.stripe.customerID) + + criteria = + recipient: user.get('_id') + purchaser: user.get('_id') + amount: amount + description: description + service: 'stripe' + "stripe.customerID": user.get('stripe').customerID + Payment.findOne criteria, (err, payment) -> + expect(err).toBeNull() + expect(payment).not.toBeNull() + nockDone() + done() + ) + ) + + it 'handles a custom purchase without description', (done) -> + nockUtils.setupNock 'db-payment-custom-stripe-test-02.json', { keep: { 'productID': true }}, (err, nockDone) -> + timestamp = 1447445242092 + amount = 73000 + + stripe.tokens.create({ + card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + stripeTokenID = token.id + loginJoe (joe) -> + joeID = joe.get('_id') + '' + data = { + amount: amount + stripe: { + token: token.id + timestamp: timestamp + } + } + request.post {uri: customPaymentURL, json: data }, (err, res, body) -> + expect(res.statusCode).toBe 201 + expect(body.stripe.chargeID).toBeDefined() + expect(body.stripe.timestamp).toBe(timestamp) + expect(body.stripe.customerID).toBeDefined() + expect(body.amount).toEqual(amount) + expect(body.productID).toBe('custom') + expect(body.service).toBe('stripe') + expect(body.recipient).toBe(joeID) + expect(body.purchaser).toBe(joeID) + User.findById(joe.get('_id'), (err, user) -> + expect(user.get('stripe').customerID).toBe(body.stripe.customerID) + + criteria = + recipient: user.get('_id') + purchaser: user.get('_id') + amount: amount + service: 'stripe' + "stripe.customerID": user.get('stripe').customerID + Payment.findOne criteria, (err, payment) -> + expect(err).toBeNull() + expect(payment).not.toBeNull() + nockDone() + done() + ) + ) + + it 'handles a custom purchase with invalid amount', (done) -> + nockUtils.setupNock 'db-payment-custom-stripe-test-03.json', (err, nockDone) -> + timestamp = 1447445242093 + amount = 'free?' + + stripe.tokens.create({ + card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + stripeTokenID = token.id + loginJoe (joe) -> + joeID = joe.get('_id') + '' + data = { + amount: amount + stripe: { + token: token.id + timestamp: timestamp + } + } + request.post {uri: customPaymentURL, json: data }, (err, res, body) -> + expect(res.statusCode).toBe(400) + nockDone() + done() + ) + + it 'handles a custom purchase with no amount', (done) -> + nockUtils.setupNock 'db-payment-custom-stripe-test-03.json', (err, nockDone) -> + timestamp = 1447445242094 + + stripe.tokens.create({ + card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + stripeTokenID = token.id + loginJoe (joe) -> + joeID = joe.get('_id') + '' + data = { + stripe: { + token: token.id + timestamp: timestamp + } + } + request.post {uri: customPaymentURL, json: data }, (err, res, body) -> + expect(res.statusCode).toBe(400) + nockDone() + done() + ) + diff --git a/test/server/functional/prepaid.spec.coffee b/spec/server/functional/prepaid.spec.coffee similarity index 61% rename from test/server/functional/prepaid.spec.coffee rename to spec/server/functional/prepaid.spec.coffee index 4c28d71fd..31c7a9a7e 100644 --- a/test/server/functional/prepaid.spec.coffee +++ b/spec/server/functional/prepaid.spec.coffee @@ -3,6 +3,7 @@ config = require '../../../server_config' moment = require 'moment' {findStripeSubscription} = require '../../../server/lib/utils' async = require 'async' +nockUtils = require '../nock-utils' describe '/db/prepaid', -> prepaidURL = getURL('/db/prepaid') @@ -33,7 +34,7 @@ describe '/db/prepaid', -> clearModels [Course, CourseInstance, Payment, Prepaid, User], (err) -> throw err if err done() - + describe 'POST /db/prepaid/<id>/redeemers', -> it 'adds a given user to the redeemers property', (done) -> @@ -51,16 +52,15 @@ describe '/db/prepaid', -> url = getURL("/db/prepaid/#{prepaid.id}/redeemers") redeemer = { userID: otherUser.id } request.post {uri: url, json: redeemer }, (err, res, body) -> - expect(body.redeemers?.length).toBe(1) + expect(body.redeemers.length).toBe(1) expect(res.statusCode).toBe(200) - return done() unless res.statusCode is 200 prepaid = Prepaid.findById body._id, (err, prepaid) -> expect(err).toBeNull() expect(prepaid.get('redeemers').length).toBe(1) User.findById otherUser.id, (err, user) -> expect(user.get('coursePrepaidID').equals(prepaid.get('_id'))).toBe(true) done() - + it 'does not allow more redeemers than maxRedeemers', (done) -> loginNewUser (user1) -> prepaid = new Prepaid({ @@ -97,7 +97,7 @@ describe '/db/prepaid', -> request.post {uri: url, json: redeemer }, (err, res, body) -> expect(res.statusCode).toBe(403) done() - + it 'is idempotent across prepaids collection', (done) -> loginNewUser (user1) -> otherUser = new User({ @@ -110,21 +110,22 @@ describe '/db/prepaid', -> type: 'course' }) prepaid1.save (err, prepaid1) -> - prepaid2 = new Prepaid({ - maxRedeemers: 10, - redeemers: [], - creator: user1.get('_id') - code: 4 - type: 'course' - }) - prepaid2.save (err, prepaid2) -> - url = getURL("/db/prepaid/#{prepaid2.id}/redeemers") - redeemer = { userID: otherUser.id } - request.post {uri: url, json: redeemer }, (err, res, body) -> - expect(res.statusCode).toBe(200) - return done() unless res.statusCode is 200 - expect(body.redeemers.length).toBe(0) - done() + otherUser.set 'coursePrepaidID', prepaid1.id + otherUser.save (err, otherUser) -> + prepaid2 = new Prepaid({ + maxRedeemers: 10, + redeemers: [], + creator: user1.get('_id') + code: 4 + type: 'course' + }) + prepaid2.save (err, prepaid2) -> + url = getURL("/db/prepaid/#{prepaid2.id}/redeemers") + redeemer = { userID: otherUser.id } + request.post {uri: url, json: redeemer }, (err, res, body) -> + expect(res.statusCode).toBe(200) + expect(body.redeemers.length).toBe(0) + done() it 'is idempotent to itself for a user other than the creator', (done) -> loginNewUser (user1) -> @@ -278,7 +279,7 @@ describe '/db/prepaid', -> request.post {uri: url, json: redeemer }, (err, res, body) -> expect(res.statusCode).toBe(403) done() - + it 'Clear database', (done) -> clearModels [Course, CourseInstance, Payment, Prepaid, User], (err) -> throw err if err @@ -390,143 +391,171 @@ describe '/db/prepaid', -> done() unless found describe 'Purchase course', -> + afterEach nockUtils.teardownNock + it 'Standard user purchases a prepaid for 0 seats', (done) -> - stripe.tokens.create { - card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> - loginNewUser (user1) -> - purchasePrepaid 'course', {}, 0, token.id, (err, res, prepaid) -> - expect(err).toBeNull() - expect(res.statusCode).toBe(422) - done() - + nockUtils.setupNock 'db-prepaid-purchase-course-test-1.json', (err, nockDone) -> + stripe.tokens.create { + card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + loginNewUser (user1) -> + purchasePrepaid 'course', {}, 0, token.id, (err, res, prepaid) -> + expect(err).toBeNull() + expect(res.statusCode).toBe(422) + nockDone() + done() + it 'Standard user purchases a prepaid for 1 seat', (done) -> - stripe.tokens.create { - card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> - loginNewUser (user1) -> - purchasePrepaid 'course', {}, 1, token.id, (err, res, prepaid) -> - expect(err).toBeNull() - expect(res.statusCode).toBe(200) - verifyCoursePrepaid(user1, prepaid, done) + nockUtils.setupNock 'db-prepaid-purchase-course-test-2.json', (err, nockDone) -> + stripe.tokens.create { + card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + loginNewUser (user1) -> + purchasePrepaid 'course', {}, 1, token.id, (err, res, prepaid) -> + expect(err).toBeNull() + expect(res.statusCode).toBe(200) + verifyCoursePrepaid user1, prepaid, -> + nockDone() + done() it 'Standard user purchases a prepaid for 3 seats', (done) -> - stripe.tokens.create { - card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> - loginNewUser (user1) -> - purchasePrepaid 'course', {}, 3, token.id, (err, res, prepaid) -> - expect(err).toBeNull() - expect(res.statusCode).toBe(200) - verifyCoursePrepaid(user1, prepaid, done) - + nockUtils.setupNock 'db-prepaid-purchase-course-test-3.json', (err, nockDone) -> + stripe.tokens.create { + card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + loginNewUser (user1) -> + purchasePrepaid 'course', {}, 3, token.id, (err, res, prepaid) -> + expect(err).toBeNull() + expect(res.statusCode).toBe(200) + verifyCoursePrepaid user1, prepaid, -> + nockDone() + done() + describe 'Purchase terminal_subscription', -> + afterEach nockUtils.teardownNock + it 'Anonymous submits a prepaid purchase', (done) -> - stripe.tokens.create { - card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> - logoutUser () -> - purchasePrepaid 'terminal_subscription', months: 3, 3, token.id, (err, res, prepaid) -> - expect(err).toBeNull() - expect(res.statusCode).toBe(401) - done() + nockUtils.setupNock 'db-prepaid-purchase-term-sub-test-1.json', (err, nockDone) -> + stripe.tokens.create { + card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + logoutUser () -> + purchasePrepaid 'terminal_subscription', months: 3, 3, token.id, (err, res, prepaid) -> + expect(err).toBeNull() + expect(res.statusCode).toBe(401) + nockDone() + done() it 'Should error if type isnt terminal_subscription', (done) -> - stripe.tokens.create { - card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> - loginNewUser (user1) -> - purchasePrepaid 'subscription', months: 3, 3, token.id, (err, res, prepaid) -> - expect(err).toBeNull() - expect(res.statusCode).toBe(403) - done() + nockUtils.setupNock 'db-prepaid-purchase-term-sub-test-2.json', (err, nockDone) -> + stripe.tokens.create { + card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + loginNewUser (user1) -> + purchasePrepaid 'subscription', months: 3, 3, token.id, (err, res, prepaid) -> + expect(err).toBeNull() + expect(res.statusCode).toBe(403) + nockDone() + done() it 'Should error if maxRedeemers is -1', (done) -> - stripe.tokens.create { - card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> - loginNewUser (user1) -> - purchasePrepaid 'terminal_subscription', months: 3, -1, token.id, (err, res, prepaid) -> - expect(err).toBeNull() - expect(res.statusCode).toBe(422) - done() + nockUtils.setupNock 'db-prepaid-purchase-term-sub-test-3.json', (err, nockDone) -> + stripe.tokens.create { + card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + loginNewUser (user1) -> + purchasePrepaid 'terminal_subscription', months: 3, -1, token.id, (err, res, prepaid) -> + expect(err).toBeNull() + expect(res.statusCode).toBe(422) + nockDone() + done() it 'Should error if maxRedeemers is foo', (done) -> - stripe.tokens.create { - card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> - loginNewUser (user1) -> - purchasePrepaid 'terminal_subscription', months: 3, 'foo', token.id, (err, res, prepaid) -> - expect(err).toBeNull() - expect(res.statusCode).toBe(422) - done() + nockUtils.setupNock 'db-prepaid-purchase-term-sub-test-4.json', (err, nockDone) -> + stripe.tokens.create { + card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + loginNewUser (user1) -> + purchasePrepaid 'terminal_subscription', months: 3, 'foo', token.id, (err, res, prepaid) -> + expect(err).toBeNull() + expect(res.statusCode).toBe(422) + nockDone() + done() it 'Should error if months is -1', (done) -> - stripe.tokens.create { - card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> - loginNewUser (user1) -> - purchasePrepaid 'terminal_subscription', months: -1, 3, token.id, (err, res, prepaid) -> - expect(err).toBeNull() - expect(res.statusCode).toBe(422) - done() + nockUtils.setupNock 'db-prepaid-purchase-term-sub-test-5.json', (err, nockDone) -> + stripe.tokens.create { + card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + loginNewUser (user1) -> + purchasePrepaid 'terminal_subscription', months: -1, 3, token.id, (err, res, prepaid) -> + expect(err).toBeNull() + expect(res.statusCode).toBe(422) + nockDone() + done() it 'Should error if months is foo', (done) -> - stripe.tokens.create { - card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> - loginNewUser (user1) -> - purchasePrepaid 'terminal_subscription', months: 'foo', 3, token.id, (err, res, prepaid) -> - expect(err).toBeNull() - expect(res.statusCode).toBe(422) - done() + nockUtils.setupNock 'db-prepaid-purchase-term-sub-test-6.json', (err, nockDone) -> + stripe.tokens.create { + card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + loginNewUser (user1) -> + purchasePrepaid 'terminal_subscription', months: 'foo', 3, token.id, (err, res, prepaid) -> + expect(err).toBeNull() + expect(res.statusCode).toBe(422) + nockDone() + done() it 'Should error if maxRedeemers and months are less than 3', (done) -> - stripe.tokens.create { - card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> - loginNewUser (user1) -> - purchasePrepaid 'terminal_subscription', months: 1, 1, token.id, (err, res, prepaid) -> - expect(err).toBeNull() - expect(res.statusCode).toBe(403) - done() + nockUtils.setupNock 'db-prepaid-purchase-term-sub-test-7.json', (err, nockDone) -> + stripe.tokens.create { + card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + loginNewUser (user1) -> + purchasePrepaid 'terminal_subscription', months: 1, 1, token.id, (err, res, prepaid) -> + expect(err).toBeNull() + expect(res.statusCode).toBe(403) + nockDone() + done() it 'User submits valid prepaid code purchase', (done) -> - stripe.tokens.create { - card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> - stripeTokenID = token.id - loginJoe (joe) -> - joeData = joe.toObject() - joeData.stripe = { - token: stripeTokenID - planID: 'basic' - } - request.put {uri: getURL('/db/user'), json: joeData, headers: headers }, (err, res, body) -> - joeData = body - expect(res.statusCode).toBe(200) - expect(joeData.stripe.customerID).toBeDefined() - expect(firstSubscriptionID = joeData.stripe.subscriptionID).toBeDefined() - expect(joeData.stripe.planID).toBe('basic') - expect(joeData.stripe.token).toBeUndefined() - # TODO: is this test still valid after new token? - stripe.tokens.create { - card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> - purchasePrepaid 'terminal_subscription', months: 3, 3, token.id, (err, res, prepaid) -> - expect(err).toBeNull() - expect(res.statusCode).toBe(200) - expect(prepaid.type).toEqual('terminal_subscription') - expect(prepaid.code).toBeDefined() - # Saving this code for later tests - # TODO: don't make tests dependent on each other - joeCode = prepaid.code - expect(prepaid.creator).toBeDefined() - expect(prepaid.maxRedeemers).toEqual(3) - expect(prepaid.exhausted).toBe(false) - expect(prepaid.properties).toBeDefined() - expect(prepaid.properties.months).toEqual(3) - done() + nockUtils.setupNock 'db-prepaid-purchase-term-sub-test-8.json', (err, nockDone) -> + stripe.tokens.create { + card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + stripeTokenID = token.id + loginJoe (joe) -> + joeData = joe.toObject() + joeData.stripe = { + token: stripeTokenID + planID: 'basic' + } + request.put {uri: getURL('/db/user'), json: joeData, headers: headers }, (err, res, body) -> + joeData = body + expect(res.statusCode).toBe(200) + expect(joeData.stripe.customerID).toBeDefined() + expect(firstSubscriptionID = joeData.stripe.subscriptionID).toBeDefined() + expect(joeData.stripe.planID).toBe('basic') + expect(joeData.stripe.token).toBeUndefined() + # TODO: is this test still valid after new token? + stripe.tokens.create { + card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + purchasePrepaid 'terminal_subscription', months: 3, 3, token.id, (err, res, prepaid) -> + expect(err).toBeNull() + expect(res.statusCode).toBe(200) + expect(prepaid.type).toEqual('terminal_subscription') + expect(prepaid.code).toBeDefined() + # Saving this code for later tests + # TODO: don't make tests dependent on each other + joeCode = prepaid.code + expect(prepaid.creator).toBeDefined() + expect(prepaid.maxRedeemers).toEqual(3) + expect(prepaid.exhausted).toBe(false) + expect(prepaid.properties).toBeDefined() + expect(prepaid.properties.months).toEqual(3) + nockDone() + done() it 'Should have logged a Payment with the correct amount', (done) -> loginJoe (joe) -> @@ -586,33 +615,37 @@ describe '/db/prepaid', -> # TODO: Move redeem subscription prepaid code tests to subscription tests file describe 'Subscription redeem tests', -> + afterEach nockUtils.teardownNock + it 'Creator can redeeem a prepaid code', (done) -> - loginJoe (joe) -> - expect(joeCode).not.toBeNull() - expect(joeData.stripe?.customerID).toBeDefined() - expect(joeData.stripe?.subscriptionID).toBeDefined() - return done() unless joeData.stripe?.customerID - - # joe has a stripe subscription, so test if the months are added to the end of it. - stripe.customers.retrieve joeData.stripe.customerID, (err, customer) => - expect(err).toBeNull() - - findStripeSubscription customer.id, subscriptionID: joeData.stripe?.subscriptionID, (subscription) => - if subscription - stripeSubscriptionPeriodEndDate = new moment(subscription.current_period_end * 1000) - else - expect(stripeSubscriptionPeriodEndDate).toBeDefined() - return done() - - subscribeWithPrepaid joeCode, (err, res, result) => - expect(err).toBeNull() - expect(res.statusCode).toEqual(200) - endDate = stripeSubscriptionPeriodEndDate.add(3, 'months').toISOString().substring(0, 10) - expect(result?.stripe?.free).toEqual(endDate) - expect(result?.purchased?.gems).toEqual(14000) - findStripeSubscription customer.id, subscriptionID: joeData.stripe?.subscriptionID, (subscription) => - expect(subscription).toBeNull() - done() + nockUtils.setupNock 'db-sub-redeem-test-1.json', (err, nockDone) -> + loginJoe (joe) -> + expect(joeCode).not.toBeNull() + expect(joeData.stripe?.customerID).toBeDefined() + expect(joeData.stripe?.subscriptionID).toBeDefined() + return done() unless joeData.stripe?.customerID + + # joe has a stripe subscription, so test if the months are added to the end of it. + stripe.customers.retrieve joeData.stripe.customerID, (err, customer) => + expect(err).toBeNull() + + findStripeSubscription customer.id, subscriptionID: joeData.stripe?.subscriptionID, (subscription) => + if subscription + stripeSubscriptionPeriodEndDate = new moment(subscription.current_period_end * 1000) + else + expect(stripeSubscriptionPeriodEndDate).toBeDefined() + return done() + + subscribeWithPrepaid joeCode, (err, res, result) => + expect(err).toBeNull() + expect(res.statusCode).toEqual(200) + endDate = stripeSubscriptionPeriodEndDate.add(3, 'months').toISOString().substring(0, 10) + expect(result?.stripe?.free).toEqual(endDate) + expect(result?.purchased?.gems).toEqual(14000) + findStripeSubscription customer.id, subscriptionID: joeData.stripe?.subscriptionID, (subscription) => + expect(subscription).toBeNull() + nockDone() + done() it 'User can redeem a prepaid code', (done) -> loginSam (sam) -> @@ -659,20 +692,22 @@ describe '/db/prepaid', -> it 'Can fetch a list of purchased and redeemed prepaid codes', (done) -> - stripe.tokens.create { - card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> - loginNewUser (user) -> - purchasePrepaid 'terminal_subscription', months: 1, 3, token.id, (err, res, prepaid) -> - request.get "#{getURL('/db/user')}/#{user.id}/prepaid_codes", (err, res) -> - expect(err).toBeNull() - expect(res.statusCode).toEqual(200); - codes = JSON.parse res.body - expect(codes.length).toEqual(1) - expect(codes[0].maxRedeemers).toEqual(3) - expect(codes[0].properties).toBeDefined() - expect(codes[0].properties.months).toEqual(1) - done() + nockUtils.setupNock 'db-sub-redeem-test-2.json', (err, nockDone) -> + stripe.tokens.create { + card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + loginNewUser (user) -> + purchasePrepaid 'terminal_subscription', months: 1, 3, token.id, (err, res, prepaid) -> + request.get "#{getURL('/db/user')}/#{user.id}/prepaid_codes", (err, res) -> + expect(err).toBeNull() + expect(res.statusCode).toEqual(200); + codes = JSON.parse res.body + expect(codes.length).toEqual(1) + expect(codes[0].maxRedeemers).toEqual(3) + expect(codes[0].properties).toBeDefined() + expect(codes[0].properties.months).toEqual(1) + nockDone() + done() it 'Test for injection', (done) -> loginNewUser (user) -> @@ -682,47 +717,51 @@ describe '/db/prepaid', -> expect(res.statusCode).not.toEqual(200) done() -# it 'Test a bunch of people trying to redeem at once', (done) -> -# doRedeem = (userX, code, testnum, retry, fnDone) => -# loginUser userX, () => -# endDate = new moment().add(3, 'months').toISOString().substring(0, 10) -# subscribeWithPrepaid code, (err, res, result) -> -# if err -# return fnDone(err) -# -# expect(err).toBeNull() -# expect(result).toBeDefined() -# if result.stripe -# expect(result.stripe).toBeDefined() -# expect(result.stripe.free).toEqual(endDate) -# expect(result?.purchased?.gems).toEqual(10500) -# return fnDone(null, {status: "ok", msg: "Redeemed " + retry}) -# else -# return fnDone(null, {status: 'error', msg: "Redeem attempt Error #{result} (#{userX.id})" + retry }) -# -# redeemPrepaidFn = (code, testnum) => -# (fnDone) => -# loginNewUser (user1) => -# doRedeem(user1, code, testnum, 0, fnDone) -# -# stripe.tokens.create { -# card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } -# }, (err, token) -> -# loginNewUser (user) => -# codeRedeemers = 50 -# codeMonths = 3 -# redeemers = 51 -# purchasePrepaid 'terminal_subscription', months: codeMonths, codeRedeemers, token.id, (err, res, prepaid) -> -# expect(err).toBeNull() -# expect(prepaid).toBeDefined() -# expect(prepaid.code).toBeDefined() -# tasks = (redeemPrepaidFn(prepaid.code, i) for i in [0...redeemers]) -# async.parallel tasks, (err, results) => -# redeemed = 0 -# error = 0 -# for result in results -# redeemed += 1 if result.status is 'ok' -# error += 1 if result.status is 'error' -# expect(redeemed).toEqual(codeRedeemers) -# expect(error).toEqual(redeemers - codeRedeemers) -# done() + # TODO: Fix this server test + + xit 'Test a bunch of people trying to redeem at once', (done) -> + nockUtils.setupNock 'db-sub-redeem-test-3.json', (err, nockDone) -> + doRedeem = (userX, code, testnum, retry, fnDone) => + loginUser userX, () => + endDate = new moment().add(3, 'months').toISOString().substring(0, 10) + subscribeWithPrepaid code, (err, res, result) -> + if err + return fnDone(err) + + expect(err).toBeNull() + expect(result).toBeDefined() + if result.stripe + expect(result.stripe).toBeDefined() + expect(result.stripe.free).toEqual(endDate) + expect(result?.purchased?.gems).toEqual(10500) + return fnDone(null, {status: "ok", msg: "Redeemed " + retry}) + else + return fnDone(null, {status: 'error', msg: "Redeem attempt Error #{result} (#{userX.id})" + retry }) + + redeemPrepaidFn = (code, testnum) => + (fnDone) => + loginNewUser (user1) => + doRedeem(user1, code, testnum, 0, fnDone) + + stripe.tokens.create { + card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + loginNewUser (user) => + codeRedeemers = 50 + codeMonths = 3 + redeemers = 51 + purchasePrepaid 'terminal_subscription', months: codeMonths, codeRedeemers, token.id, (err, res, prepaid) -> + expect(err).toBeNull() + expect(prepaid).toBeDefined() + expect(prepaid.code).toBeDefined() + tasks = (redeemPrepaidFn(prepaid.code, i) for i in [0...redeemers]) + async.parallel tasks, (err, results) => + redeemed = 0 + error = 0 + for result in results + redeemed += 1 if result.status is 'ok' + error += 1 if result.status is 'error' + expect(redeemed).toEqual(codeRedeemers) + expect(error).toEqual(redeemers - codeRedeemers) + nockDone() + done() diff --git a/test/server/functional/queue.spec.coffee b/spec/server/functional/queue.spec.coffee similarity index 100% rename from test/server/functional/queue.spec.coffee rename to spec/server/functional/queue.spec.coffee diff --git a/test/server/functional/subscription.spec.coffee b/spec/server/functional/subscription.spec.coffee similarity index 70% rename from test/server/functional/subscription.spec.coffee rename to spec/server/functional/subscription.spec.coffee index 8010c324a..15ed861f0 100644 --- a/test/server/functional/subscription.spec.coffee +++ b/spec/server/functional/subscription.spec.coffee @@ -4,6 +4,8 @@ require '../common' utils = require '../../../app/core/utils' # Must come after require /common mongoose = require 'mongoose' TRAVIS = process.env.COCO_TRAVIS_TEST +nockUtils = require '../nock-utils' + # sample data that comes in through the webhook when you subscribe invoiceChargeSampleEvent = { @@ -84,6 +86,7 @@ customerSubscriptionDeletedSampleEvent = { describe '/db/user, editing stripe property', -> + afterEach nockUtils.teardownNock stripe = require('stripe')(config.stripe.secretKey) userURL = getURL('/db/user') @@ -93,6 +96,7 @@ describe '/db/user, editing stripe property', -> it 'clears the db first', (done) -> clearModels [User, Payment], (err) -> throw err if err + resetUserIDCounter(100000) # because fixtures depend on dependable user ids done() it 'denies anonymous users trying to subscribe', (done) -> @@ -108,114 +112,130 @@ describe '/db/user, editing stripe property', -> firstSubscriptionID = null it 'returns client error when a token fails to charge', (done) -> - stripe.tokens.create { - card: { number: '4000000000000002', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> - stripeTokenID = token.id - loginJoe (joe) -> - joeData = joe.toObject() - joeData.stripe = { - token: stripeTokenID - planID: 'basic' - } - request.put {uri: userURL, json: joeData, headers: headers }, (err, res, body) -> - expect(res.statusCode).toBe(402) - done() + nockUtils.setupNock 'db-user-sub-test-1.json', (err, nockDone) -> + stripe.tokens.create { + card: { number: '4000000000000002', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + stripeTokenID = token.id + loginJoe (joe) -> + joeData = joe.toObject() + joeData.stripe = { + token: stripeTokenID + planID: 'basic' + } + request.put {uri: userURL, json: joeData, headers: headers }, (err, res, body) -> + expect(res.statusCode).toBe(402) + nockDone() + done() it 'creates a subscription when you put a token and plan', (done) -> - stripe.tokens.create { - card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> - stripeTokenID = token.id - loginJoe (joe) -> - joeData = joe.toObject() - joeData.stripe = { - token: stripeTokenID - planID: 'basic' - } - request.put {uri: userURL, json: joeData, headers: headers }, (err, res, body) -> - joeData = body - expect(res.statusCode).toBe(200) - expect(joeData.purchased.gems).toBe(3500) - expect(joeData.stripe.customerID).toBeDefined() - expect(firstSubscriptionID = joeData.stripe.subscriptionID).toBeDefined() - expect(joeData.stripe.planID).toBe('basic') - expect(joeData.stripe.token).toBeUndefined() - done() + nockUtils.setupNock 'db-user-sub-test-2.json', (err, nockDone) -> + stripe.tokens.create { + card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + stripeTokenID = token.id + loginJoe (joe) -> + joeData = joe.toObject() + joeData.stripe = { + token: stripeTokenID + planID: 'basic' + } + request.put {uri: userURL, json: joeData, headers: headers }, (err, res, body) -> + joeData = body + expect(res.statusCode).toBe(200) + expect(joeData.purchased.gems).toBe(3500) + expect(joeData.stripe.customerID).toBeDefined() + expect(firstSubscriptionID = joeData.stripe.subscriptionID).toBeDefined() + expect(joeData.stripe.planID).toBe('basic') + expect(joeData.stripe.token).toBeUndefined() + nockDone() + done() it 'records a payment through the webhook', (done) -> - # Don't even want to think about hooking in tests to webhooks, so... put in some data manually - stripe.invoices.list {customer: joeData.stripe.customerID}, (err, invoices) -> - expect(invoices.data.length).toBe(1) - event = _.cloneDeep(invoiceChargeSampleEvent) - event.data.object = invoices.data[0] - - request.post {uri: webhookURL, json: event}, (err, res, body) -> - expect(res.statusCode).toBe(201) - Payment.find {}, (err, payments) -> - expect(payments.length).toBe(1) - User.findById joeData._id, (err, user) -> - expect(user.get('purchased').gems).toBe(3500) - done() + nockUtils.setupNock 'db-user-sub-test-3.json', (err, nockDone) -> + # Don't even want to think about hooking in tests to webhooks, so... put in some data manually + stripe.invoices.list {customer: joeData.stripe.customerID}, (err, invoices) -> + expect(invoices.data.length).toBe(1) + event = _.cloneDeep(invoiceChargeSampleEvent) + event.data.object = invoices.data[0] + + request.post {uri: webhookURL, json: event}, (err, res, body) -> + expect(res.statusCode).toBe(201) + Payment.find {}, (err, payments) -> + expect(payments.length).toBe(1) + User.findById joeData._id, (err, user) -> + expect(user.get('purchased').gems).toBe(3500) + nockDone() + done() it 'schedules the stripe subscription to be cancelled when stripe.planID is removed from the user', (done) -> - delete joeData.stripe.planID - request.put {uri: userURL, json: joeData, headers: headers }, (err, res, body) -> - joeData = body - expect(res.statusCode).toBe(200) - expect(joeData.stripe.subscriptionID).toBeDefined() - expect(joeData.stripe.planID).toBeUndefined() - expect(joeData.stripe.customerID).toBeDefined() - stripe.customers.retrieve joeData.stripe.customerID, (err, customer) -> - expect(customer.subscriptions.data.length).toBe(1) - expect(customer.subscriptions.data[0].cancel_at_period_end).toBe(true) - done() - - it 'allows you to sign up again using the same customer ID as before, no token necessary', (done) -> - joeData.stripe.planID = 'basic' - request.put {uri: userURL, json: joeData, headers: headers }, (err, res, body) -> - joeData = body - - expect(res.statusCode).toBe(200) - expect(joeData.stripe.customerID).toBeDefined() - expect(joeData.stripe.subscriptionID).toBeDefined() - expect(joeData.stripe.subscriptionID).not.toBe(firstSubscriptionID) - expect(joeData.stripe.planID).toBe('basic') - done() - - it 'will not have immediately created new payments when signing back up from a cancelled subscription', (done) -> - stripe.invoices.list {customer: joeData.stripe.customerID}, (err, invoices) -> - expect(invoices.data.length).toBe(2) - expect(invoices.data[0].total).toBe(0) - event = _.cloneDeep(invoiceChargeSampleEvent) - event.data.object = invoices.data[0] - - request.post {uri: webhookURL, json: event}, (err, res, body) -> + nockUtils.setupNock 'db-user-sub-test-4.json', {keep: {cancel_at_period_end: true}}, (err, nockDone) -> + delete joeData.stripe.planID + request.put {uri: userURL, json: joeData, headers: headers }, (err, res, body) -> + joeData = body expect(res.statusCode).toBe(200) - Payment.find {}, (err, payments) -> - expect(payments.length).toBe(1) - User.findById joeData._id, (err, user) -> - expect(user.get('purchased').gems).toBe(3500) - done() - - it 'deletes the subscription from the user object when an event about it comes through the webhook', (done) -> - stripe.customers.retrieveSubscription joeData.stripe.customerID, joeData.stripe.subscriptionID, (err, subscription) -> - event = _.cloneDeep(customerSubscriptionDeletedSampleEvent) - event.data.object = subscription - request.post {uri: webhookURL, json: event}, (err, res, body) -> - User.findById joeData._id, (err, user) -> - expect(user.get('purchased').gems).toBe(3500) - expect(user.get('stripe').subscriptionID).toBeUndefined() - expect(user.get('stripe').planID).toBeUndefined() + expect(joeData.stripe.subscriptionID).toBeDefined() + expect(joeData.stripe.planID).toBeUndefined() + expect(joeData.stripe.customerID).toBeDefined() + stripe.customers.retrieve joeData.stripe.customerID, (err, customer) -> + expect(customer.subscriptions.data.length).toBe(1) + expect(customer.subscriptions.data[0].cancel_at_period_end).toBe(true) + nockDone() done() - it "updates the customer's email when you change the user's email", (done) -> - joeData.email = 'newEmail@gmail.com' - request.put {uri: userURL, json: joeData, headers: headers }, (err, res, body) -> - f = -> stripe.customers.retrieve joeData.stripe.customerID, (err, customer) -> - expect(customer.email).toBe('newEmail@gmail.com') + it 'allows you to sign up again using the same customer ID as before, no token necessary', (done) -> + nockUtils.setupNock 'db-user-sub-test-5.json', (err, nockDone) -> + joeData.stripe.planID = 'basic' + request.put {uri: userURL, json: joeData, headers: headers }, (err, res, body) -> + joeData = body + + expect(res.statusCode).toBe(200) + expect(joeData.stripe.customerID).toBeDefined() + expect(joeData.stripe.subscriptionID).toBeDefined() + expect(joeData.stripe.subscriptionID).not.toBe(firstSubscriptionID) + expect(joeData.stripe.planID).toBe('basic') + nockDone() done() - setTimeout(f, 500) # bit of a race condition here, response returns before stripe has been updated + + it 'will not have immediately created new payments when signing back up from a cancelled subscription', (done) -> + nockUtils.setupNock 'db-user-sub-test-6.json', (err, nockDone) -> + stripe.invoices.list {customer: joeData.stripe.customerID}, (err, invoices) -> + expect(invoices.data.length).toBe(2) + expect(invoices.data[0].total).toBe(0) + event = _.cloneDeep(invoiceChargeSampleEvent) + event.data.object = invoices.data[0] + + request.post {uri: webhookURL, json: event}, (err, res, body) -> + expect(res.statusCode).toBe(200) + Payment.find {}, (err, payments) -> + expect(payments.length).toBe(1) + User.findById joeData._id, (err, user) -> + expect(user.get('purchased').gems).toBe(3500) + nockDone() + done() + + it 'deletes the subscription from the user object when an event about it comes through the webhook', (done) -> + nockUtils.setupNock 'db-user-sub-test-7.json', (err, nockDone) -> + stripe.customers.retrieveSubscription joeData.stripe.customerID, joeData.stripe.subscriptionID, (err, subscription) -> + event = _.cloneDeep(customerSubscriptionDeletedSampleEvent) + event.data.object = subscription + request.post {uri: webhookURL, json: event}, (err, res, body) -> + User.findById joeData._id, (err, user) -> + expect(user.get('purchased').gems).toBe(3500) + expect(user.get('stripe').subscriptionID).toBeUndefined() + expect(user.get('stripe').planID).toBeUndefined() + nockDone() + done() + + it "updates the customer's email when you change the user's email", (done) -> + nockUtils.setupNock 'db-user-sub-test-8.json', {keep: {email: true}}, (err, nockDone) -> + joeData.email = 'newEmail@gmail.com' + request.put {uri: userURL, json: joeData, headers: headers }, (err, res, body) -> + f = -> stripe.customers.retrieve joeData.stripe.customerID, (err, customer) -> + expect(customer.email).toBe('newEmail@gmail.com') + nockDone() + done() + setTimeout(f, 500) # bit of a race condition here, response returns before stripe has been updated describe 'Subscriptions', -> @@ -229,6 +249,7 @@ describe 'Subscriptions', -> subPrice = 999 subGems = 3500 invoicesWebHooked = {} + afterEach nockUtils.teardownNock # Start helpers @@ -330,7 +351,7 @@ describe 'Subscriptions', -> break expect(recipientInfo).toBeDefined() expect(recipientInfo.subscriptionID).toBeDefined() - expect(recipientInfo.subscriptionID).toNotEqual(sponsorStripe.sponsorSubscriptionID) + expect(recipientInfo.subscriptionID).not.toEqual(sponsorStripe.sponsorSubscriptionID) expect(recipientInfo.couponID).toEqual('free') # Verify Stripe recipient subscription data @@ -520,126 +541,137 @@ describe 'Subscriptions', -> describe 'Personal', -> it 'Subscribe user with new token', (done) -> - stripe.tokens.create { - card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> - loginNewUser (user1) -> - subscribeUser user1, token, null, done + nockUtils.setupNock 'sub-test-01.json', (err, nockDone) -> + stripe.tokens.create { + card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + loginNewUser (user1) -> + subscribeUser user1, token, null, -> + nockDone() + done() it 'User delete unsubscribes', (done) -> - stripe.tokens.create { - card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> - loginNewUser (user1) -> - subscribeUser user1, token, null, -> - User.findById user1.id, (err, user1) -> - expect(err).toBeNull() - customerID = user1.get('stripe').customerID - subscriptionID = user1.get('stripe').subscriptionID - request.del {uri: "#{userURL}/#{user1.id}"}, (err, res) -> + nockUtils.setupNock 'sub-test-02.json', (err, nockDone) -> + stripe.tokens.create { + card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + loginNewUser (user1) -> + subscribeUser user1, token, null, -> + User.findById user1.id, (err, user1) -> expect(err).toBeNull() - stripe.customers.retrieveSubscription customerID, subscriptionID, (err, subscription) -> - expect(err).toBeNull() - expect(subscription?.cancel_at_period_end).toEqual(true) - done() - - it 'User subscribes, deletes themselves, subscription ends', (done) -> - stripe.tokens.create { - card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> - loginNewUser (user1) -> - # Subscribe user - subscribeUser user1, token, null, -> - User.findById user1.id, (err, user1) -> - expect(err).toBeNull() - customerID = user1.get('stripe').customerID - subscriptionID = user1.get('stripe').subscriptionID - stripe.customers.retrieveSubscription customerID, subscriptionID, (err, subscription) -> - expect(err).toBeNull() - expect(subscription).not.toBeNull() - # Delete user + customerID = user1.get('stripe').customerID + subscriptionID = user1.get('stripe').subscriptionID request.del {uri: "#{userURL}/#{user1.id}"}, (err, res) -> expect(err).toBeNull() - # Simulate Stripe subscription deleted via webhook - event = _.cloneDeep(customerSubscriptionDeletedSampleEvent) - event.data.object = subscription - request.post {uri: webhookURL, json: event}, (err, res, body) -> + stripe.customers.retrieveSubscription customerID, subscriptionID, (err, subscription) -> expect(err).toBeNull() - expect(res.statusCode).toEqual(200) + expect(subscription?.cancel_at_period_end).toEqual(true) + nockDone() done() - it 'Subscribe with prepaid, then delete', (done) -> - loginNewUser (user1) -> - user1.set('permissions', ['admin']) - user1.save (err, user1) -> - expect(err).toBeNull() - expect(user1.isAdmin()).toEqual(true) - createPrepaid 'subscription', 1, 0, (err, res, prepaid) -> - expect(err).toBeNull() - subscribeUser user1, null, prepaid.code, -> - Prepaid.findById prepaid._id, (err, prepaid) -> + it 'User subscribes, deletes themselves, subscription ends', (done) -> + nockUtils.setupNock 'sub-test-03.json', (err, nockDone) -> + stripe.tokens.create { + card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + loginNewUser (user1) -> + # Subscribe user + subscribeUser user1, token, null, -> + User.findById user1.id, (err, user1) -> expect(err).toBeNull() - expect(prepaid.get('maxRedeemers')).toEqual(1) - expect(prepaid.get('redeemers')[0].userID).toEqual(user1.get('_id')) - expect(prepaid.get('redeemers')[0].date).toBeLessThan(new Date()) - User.findById user1.id, (err, user1) -> + customerID = user1.get('stripe').customerID + subscriptionID = user1.get('stripe').subscriptionID + stripe.customers.retrieveSubscription customerID, subscriptionID, (err, subscription) -> expect(err).toBeNull() - unsubscribeUser user1, -> - User.findById user1.id, (err, user1) -> + expect(subscription).not.toBeNull() + # Delete user + request.del {uri: "#{userURL}/#{user1.id}"}, (err, res) -> + expect(err).toBeNull() + # Simulate Stripe subscription deleted via webhook + event = _.cloneDeep(customerSubscriptionDeletedSampleEvent) + event.data.object = subscription + request.post {uri: webhookURL, json: event}, (err, res, body) -> expect(err).toBeNull() - stripeInfo = user1.get('stripe') - expect(stripeInfo.prepaidCode).toEqual(prepaid.get('code')) - expect(stripeInfo.subscriptionID).toBeDefined() - return done() unless stripeInfo.subscriptionID + expect(res.statusCode).toEqual(200) + nockDone() + done() - # Delete subscription - stripe.customers.retrieveSubscription stripeInfo.customerID, stripeInfo.subscriptionID, (err, subscription) -> - expect(err).toBeNull() - event = _.cloneDeep(customerSubscriptionDeletedSampleEvent) - event.data.object = subscription - request.post {uri: webhookURL, json: event}, (err, res, body) -> - expect(err).toBeNull() - User.findById user1.id, (err, user1) -> - expect(err).toBeNull() - stripeInfo = user1.get('stripe') - expect(stripeInfo.planID).toBeUndefined() - expect(stripeInfo.prepaidCode).toBeUndefined() - expect(stripeInfo.subscriptionID).toBeUndefined() - done() - - it 'Subscribe normally, subscribe with valid prepaid', (done) -> - stripe.tokens.create { - card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> + it 'Subscribe with prepaid, then delete', (done) -> + nockUtils.setupNock 'sub-test-04.json', (err, nockDone) -> loginNewUser (user1) -> user1.set('permissions', ['admin']) user1.save (err, user1) -> expect(err).toBeNull() expect(user1.isAdmin()).toEqual(true) - subscribeUser user1, token, null, -> - User.findById user1.id, (err, user1) -> - expect(err).toBeNull() - createPrepaid 'subscription', 1, 0, (err, res, prepaid) -> + createPrepaid 'subscription', 1, 0, (err, res, prepaid) -> + expect(err).toBeNull() + subscribeUser user1, null, prepaid.code, -> + Prepaid.findById prepaid._id, (err, prepaid) -> expect(err).toBeNull() - subscribeUser user1, null, prepaid.code, -> - Prepaid.findById prepaid._id, (err, prepaid) -> - expect(err).toBeNull() - expect(prepaid.get('maxRedeemers')).toEqual(1) - expect(prepaid.get('redeemers')[0].userID).toEqual(user1.get('_id')) - expect(prepaid.get('redeemers')[0].date).toBeLessThan(new Date()) + expect(prepaid.get('maxRedeemers')).toEqual(1) + expect(prepaid.get('redeemers')[0].userID).toEqual(user1.get('_id')) + expect(prepaid.get('redeemers')[0].date).toBeLessThan(new Date()) + User.findById user1.id, (err, user1) -> + expect(err).toBeNull() + unsubscribeUser user1, -> User.findById user1.id, (err, user1) -> expect(err).toBeNull() - customerID = user1.get('stripe').customerID - subscriptionID = user1.get('stripe').subscriptionID - stripe.customers.retrieveSubscription customerID, subscriptionID, (err, subscription) -> + stripeInfo = user1.get('stripe') + expect(stripeInfo.prepaidCode).toEqual(prepaid.get('code')) + expect(stripeInfo.subscriptionID).toBeDefined() + return done() unless stripeInfo.subscriptionID + + # Delete subscription + stripe.customers.retrieveSubscription stripeInfo.customerID, stripeInfo.subscriptionID, (err, subscription) -> expect(err).toBeNull() - expect(subscription).not.toBeNull() - return done() unless subscription - expect(subscription.discount?.coupon?.id).toEqual('free') - done() + event = _.cloneDeep(customerSubscriptionDeletedSampleEvent) + event.data.object = subscription + request.post {uri: webhookURL, json: event}, (err, res, body) -> + expect(err).toBeNull() + User.findById user1.id, (err, user1) -> + expect(err).toBeNull() + stripeInfo = user1.get('stripe') + expect(stripeInfo.planID).toBeUndefined() + expect(stripeInfo.prepaidCode).toBeUndefined() + expect(stripeInfo.subscriptionID).toBeUndefined() + nockDone() + done() - unless TRAVIS - it 'Subscribe with coupon, subscribe with valid prepaid', (done) -> + it 'Subscribe normally, subscribe with valid prepaid', (done) -> + nockUtils.setupNock 'sub-test-05.json', (err, nockDone) -> + stripe.tokens.create { + card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + loginNewUser (user1) -> + user1.set('permissions', ['admin']) + user1.save (err, user1) -> + expect(err).toBeNull() + expect(user1.isAdmin()).toEqual(true) + subscribeUser user1, token, null, -> + User.findById user1.id, (err, user1) -> + expect(err).toBeNull() + createPrepaid 'subscription', 1, 0, (err, res, prepaid) -> + expect(err).toBeNull() + subscribeUser user1, null, prepaid.code, -> + Prepaid.findById prepaid._id, (err, prepaid) -> + expect(err).toBeNull() + expect(prepaid.get('maxRedeemers')).toEqual(1) + expect(prepaid.get('redeemers')[0].userID).toEqual(user1.get('_id')) + expect(prepaid.get('redeemers')[0].date).toBeLessThan(new Date()) + User.findById user1.id, (err, user1) -> + expect(err).toBeNull() + customerID = user1.get('stripe').customerID + subscriptionID = user1.get('stripe').subscriptionID + stripe.customers.retrieveSubscription customerID, subscriptionID, (err, subscription) -> + expect(err).toBeNull() + expect(subscription).not.toBeNull() + return done() unless subscription + expect(subscription.discount?.coupon?.id).toEqual('free') + nockDone() + done() + + it 'Subscribe with coupon, subscribe with valid prepaid', (done) -> + nockUtils.setupNock 'sub-test-06.json', (err, nockDone) -> stripe.tokens.create { card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } }, (err, token) -> @@ -669,9 +701,11 @@ describe 'Subscriptions', -> expect(err).toBeNull() expect(subscription).not.toBeNull() expect(subscription?.discount?.coupon?.id).toEqual('free') + nockDone() done() - it 'Subscribe with prepaid, then cancel', (done) -> + it 'Subscribe with prepaid, then cancel', (done) -> + nockUtils.setupNock 'sub-test-07.json', (err, nockDone) -> loginNewUser (user1) -> user1.set('permissions', ['admin']) user1.save (err, user1) -> @@ -691,9 +725,11 @@ describe 'Subscriptions', -> User.findById user1.id, (err, user1) -> expect(err).toBeNull() expect(user1.get('stripe').prepaidCode).toEqual(prepaid.get('code')) + nockDone() done() - it 'User2 subscribes with used prepaid', (done) -> + it 'User2 subscribes with used prepaid', (done) -> + nockUtils.setupNock 'sub-test-08.json', (err, nockDone) -> loginNewUser (user1) -> user1.set('permissions', ['admin']) user1.save (err, user1) -> @@ -714,9 +750,11 @@ describe 'Subscriptions', -> expect(err).toBeNull() expect(prepaid.get('redeemers')[0].userID).toEqual(user1.get('_id')) expect(prepaid.get('redeemers')[0].date).toBeLessThan(new Date()) + nockDone() done() - it 'User2 subscribes with same active prepaid', (done) -> + it 'User2 subscribes with same active prepaid', (done) -> + nockUtils.setupNock 'sub-test-09.json', (err, nockDone) -> loginNewUser (user1) -> user1.set('permissions', ['admin']) user1.save (err, user1) -> @@ -730,9 +768,11 @@ describe 'Subscriptions', -> Prepaid.findById prepaid._id, (err, prepaid) -> expect(err).toBeNull() expect(prepaid.get('redeemers').length).toEqual(2) + nockDone() done() - it 'Admin subscribes self with valid prepaid', (done) -> + it 'Admin subscribes self with valid prepaid', (done) -> + nockUtils.setupNock 'sub-test-10.json', (err, nockDone) -> loginNewUser (user1) -> user1.set('permissions', ['admin']) user1.save (err, user1) -> @@ -746,9 +786,11 @@ describe 'Subscriptions', -> expect(prepaid.get('maxRedeemers')).toEqual(1) expect(prepaid.get('redeemers')[0].userID).toEqual(user1.get('_id')) expect(prepaid.get('redeemers')[0].date).toBeLessThan(new Date()) + nockDone() done() - it 'Admin subscribes self with valid prepaid twice', (done) -> + it 'Admin subscribes self with valid prepaid twice', (done) -> + nockUtils.setupNock 'sub-test-11.json', (err, nockDone) -> loginNewUser (user1) -> user1.set('permissions', ['admin']) user1.save (err, user1) -> @@ -768,9 +810,11 @@ describe 'Subscriptions', -> request.put {uri: userURL, json: requestBody, headers: headers }, (err, res, body) -> expect(err).toBeNull() expect(res.statusCode).toBe(403) + nockDone() done() - it 'Admin subscribes self with invalid prepaid', (done) -> + it 'Admin subscribes self with invalid prepaid', (done) -> + nockUtils.setupNock 'sub-test-12.json', (err, nockDone) -> loginNewUser (user1) -> user1.set('permissions', ['admin']) user1.save (err, user1) -> @@ -783,20 +827,25 @@ describe 'Subscriptions', -> request.put {uri: userURL, json: requestBody, headers: headers }, (err, res, body) -> expect(err).toBeNull() expect(res.statusCode).toBe(404) + nockDone() done() describe 'Sponsored', -> it 'Unsubscribed user1 subscribes user2', (done) -> - stripe.tokens.create { - card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> - createNewUser (user2) -> - loginNewUser (user1) -> - subscribeRecipients user1, [user2], token, (updatedUser) -> - verifySponsorship user1.id, user2.id, done + nockUtils.setupNock 'sub-test-13.json', (err, nockDone) -> + stripe.tokens.create { + card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + createNewUser (user2) -> + loginNewUser (user1) -> + subscribeRecipients user1, [user2], token, (updatedUser) -> + verifySponsorship user1.id, user2.id, -> + nockDone() + done() - unless TRAVIS - it 'Recipient user delete unsubscribes', (done) -> + + it 'Recipient user delete unsubscribes', (done) -> + nockUtils.setupNock 'sub-test-14.json', (err, nockDone) -> stripe.tokens.create { card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } }, (err, token) -> @@ -822,9 +871,11 @@ describe 'Subscriptions', -> stripe.customers.retrieveSubscription customerID, user1.get('stripe').sponsorSubscriptionID, (err, subscription) -> expect(err).toBeNull() expect(subscription.quantity).toEqual(0) + nockDone() done() - it 'Subscribed user1 subscribes user2, one token', (done) -> + it 'Subscribed user1 subscribes user2, one token', (done) -> + nockUtils.setupNock 'sub-test-15.json', (err, nockDone) -> stripe.tokens.create { card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } }, (err, token) -> @@ -838,9 +889,12 @@ describe 'Subscriptions', -> expect(err).toBeNull() expect(user1.get('stripe').subscriptionID).toBeDefined() expect(user1.isPremium()).toEqual(true) - verifySponsorship user1.id, user2.id, done + verifySponsorship user1.id, user2.id, -> + nockDone() + done() - it 'Clean up sponsorships upon sub cancel after setup sponsor sub fails', (done) -> + it 'Clean up sponsorships upon sub cancel after setup sponsor sub fails', (done) -> + nockUtils.setupNock 'sub-test-16.json', (err, nockDone) -> stripe.tokens.create { card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } }, (err, token) -> @@ -869,10 +923,13 @@ describe 'Subscriptions', -> expect(user1.isPremium()).toEqual(true) User.findById user2.id, (err, user2) -> verifyNotSponsoring user1.id, user2.id, -> - verifyNotRecipient user2.id, done + verifyNotRecipient user2.id, -> + nockDone() + done() - it 'Unsubscribed user1 unsubscribes user2 and their sub ends', (done) -> + it 'Unsubscribed user1 unsubscribes user2 and their sub ends', (done) -> + nockUtils.setupNock 'sub-test-17.json', (err, nockDone) -> stripe.tokens.create { card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } }, (err, token) -> @@ -882,9 +939,13 @@ describe 'Subscriptions', -> User.findById user1.id, (err, user1) -> unsubscribeRecipient user1, user2, -> verifyNotSponsoring user1.id, user2.id, -> - verifyNotRecipient user2.id, done + verifyNotRecipient user2.id, -> + nockDone() + done() + - it 'Unsubscribed user1 immediately resubscribes user2, one token', (done) -> + it 'Unsubscribed user1 immediately resubscribes user2, one token', (done) -> + nockUtils.setupNock 'sub-test-18.json', (err, nockDone) -> stripe.tokens.create { card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } }, (err, token) -> @@ -894,9 +955,12 @@ describe 'Subscriptions', -> User.findById user1.id, (err, user1) -> unsubscribeRecipient user1, user2, -> subscribeRecipients user1, [user2], null, (updatedUser) -> - verifySponsorship user1.id, user2.id, done + verifySponsorship user1.id, user2.id, -> + nockDone() + done() - it 'Sponsored user2 subscribes their sponsor user1', (done) -> + it 'Sponsored user2 subscribes their sponsor user1', (done) -> + nockUtils.setupNock 'sub-test-19.json', (err, nockDone) -> stripe.tokens.create { card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } }, (err, token) -> @@ -909,9 +973,12 @@ describe 'Subscriptions', -> }, (err, token) -> subscribeRecipients user2, [user1], token, (updatedUser) -> verifySponsorship user1.id, user2.id, -> - verifySponsorship user2.id, user1.id, done + verifySponsorship user2.id, user1.id, -> + nockDone() + done() - it 'Unsubscribed user1 subscribes user1', (done) -> + it 'Unsubscribed user1 subscribes user1', (done) -> + nockUtils.setupNock 'sub-test-20.json', (err, nockDone) -> stripe.tokens.create { card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } }, (err, token) -> @@ -932,9 +999,11 @@ describe 'Subscriptions', -> expect(stripeInfo.planID).toBeUndefined() expect(stripeInfo.subscriptionID).toBeUndefined() expect(stripeInfo.recipients.length).toEqual(0) + nockDone() done() - it 'Subscribed user1 unsubscribes user2', (done) -> + it 'Subscribed user1 unsubscribes user2', (done) -> + nockUtils.setupNock 'sub-test-21.json', (err, nockDone) -> stripe.tokens.create { card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } }, (err, token) -> @@ -952,9 +1021,12 @@ describe 'Subscriptions', -> expect(user1.isPremium()).toEqual(true) User.findById user2.id, (err, user2) -> verifyNotSponsoring user1.id, user2.id, -> - verifyNotRecipient user2.id, done + verifyNotRecipient user2.id, -> + nockDone() + done() - it 'Subscribed user1 subscribes user2, unsubscribes themselves', (done) -> + it 'Subscribed user1 subscribes user2, unsubscribes themselves', (done) -> + nockUtils.setupNock 'sub-test-22.json', (err, nockDone) -> stripe.tokens.create { card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } }, (err, token) -> @@ -966,9 +1038,12 @@ describe 'Subscriptions', -> subscribeRecipients user1, [user2], null, (updatedUser) -> User.findById user1.id, (err, user1) -> unsubscribeUser user1, -> - verifySponsorship user1.id, user2.id, done + verifySponsorship user1.id, user2.id, -> + nockDone() + done() - it 'Sponsored user2 tries to subscribe', (done) -> + it 'Sponsored user2 tries to subscribe', (done) -> + nockUtils.setupNock 'sub-test-23.json', (err, nockDone) -> stripe.tokens.create { card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } }, (err, token) -> @@ -986,9 +1061,11 @@ describe 'Subscriptions', -> request.put {uri: userURL, json: requestBody, headers: headers }, (err, res, body) -> expect(err).toBeNull() expect(res.statusCode).toBe(403) + nockDone() done() - it 'Sponsored user2 tries to subscribe with valid prepaid', (done) -> + it 'Sponsored user2 tries to subscribe with valid prepaid', (done) -> + nockUtils.setupNock 'sub-test-24.json', (err, nockDone) -> stripe.tokens.create { card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } }, (err, token) -> @@ -1009,9 +1086,11 @@ describe 'Subscriptions', -> request.put {uri: userURL, json: requestBody, headers: headers }, (err, res, body) -> expect(err).toBeNull() expect(res.statusCode).toBe(403) + nockDone() done() - it 'Sponsored user2 tries to unsubscribe', (done) -> + it 'Sponsored user2 tries to unsubscribe', (done) -> + nockUtils.setupNock 'sub-test-25.json', (err, nockDone) -> stripe.tokens.create { card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } }, (err, token) -> @@ -1025,9 +1104,12 @@ describe 'Subscriptions', -> request.put {uri: userURL, json: requestBody, headers: headers }, (err, res, body) -> expect(err).toBeNull() expect(res.statusCode).toBe(200) - verifySponsorship user1.id, user2.id, done + verifySponsorship user1.id, user2.id, -> + nockDone() + done() - it 'Cancel sponsor subscription with 2 recipient subscriptions, then subscribe 1 old and 1 new', (done) -> + it 'Cancel sponsor subscription with 2 recipient subscriptions, then subscribe 1 old and 1 new', (done) -> + nockUtils.setupNock 'sub-test-26.json', (err, nockDone) -> stripe.tokens.create { card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } }, (err, token) -> @@ -1080,9 +1162,12 @@ describe 'Subscriptions', -> loginUser user1, (user1) -> User.findById user1.id, (err, user1) -> subscribeRecipients user1, [user4], null, (updatedUser) -> - verifySponsorship user1.id, user4.id, done + verifySponsorship user1.id, user4.id, -> + nockDone() + done() - it 'Subscribing two users separately yields proration payment', (done) -> + it 'Subscribing two users separately yields proration payment', (done) -> + nockUtils.setupNock 'sub-test-27.json', (err, nockDone) -> # TODO: Use test plan with low duration + setTimeout to test delay between 2 subscribes stripe.tokens.create { card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } @@ -1108,14 +1193,17 @@ describe 'Subscriptions', -> Payment.findOne "stripe.invoiceID": invoice.id, (err, payment) -> expect(err).toBeNull() expect(payment.get('amount')).toEqual(invoice.total) + nockDone() done() foundProratedInvoice = true break unless foundProratedInvoice expect(foundProratedInvoice).toEqual(true) + nockDone() done() - it 'Invalid subscribeEmails', (done) -> + it 'Invalid subscribeEmails', (done) -> + nockUtils.setupNock 'sub-test-28.json', (err, nockDone) -> stripe.tokens.create { card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } }, (err, token) -> @@ -1134,9 +1222,11 @@ describe 'Subscriptions', -> expect(sponsor.get('stripe').customerID).toBeDefined() expect(sponsor.get('stripe').sponsorSubscriptionID).toBeDefined() expect(sponsor.get('stripe').recipients?.length).toEqual(0) + nockDone() done() - it 'User1 subscribes user2 then themselves', (done) -> + it 'User1 subscribes user2 then themselves', (done) -> + nockUtils.setupNock 'sub-test-29.json', (err, nockDone) -> stripe.tokens.create { card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } }, (err, token) -> @@ -1168,9 +1258,11 @@ describe 'Subscriptions', -> else expect(sub.plan.id).toEqual('incremental') expect(sub.metadata?.id).toEqual(user1.id) + nockDone() done() - it 'Subscribe with prepaid, then get sponsored', (done) -> + it 'Subscribe with prepaid, then get sponsored', (done) -> + nockUtils.setupNock 'sub-test-30.json', (err, nockDone) -> loginNewUser (user1) -> user1.set('permissions', ['admin']) user1.save (err, user1) -> @@ -1197,16 +1289,18 @@ describe 'Subscriptions', -> expect(stripeInfo.planID).toBeDefined() expect(stripeInfo.subscriptionID).toBeDefined() expect(stripeInfo.sponsorID).toBeUndefined() + nockDone() done() - describe 'Bulk discounts', -> - # Bulk discount algorithm (includes personal sub): - # 1 100% - # 2-11 80% - # 12+ 60% + describe 'Bulk discounts', -> + # Bulk discount algorithm (includes personal sub): + # 1 100% + # 2-11 80% + # 12+ 60% - it 'Unsubscribed user1 subscribes two users', (done) -> + it 'Unsubscribed user1 subscribes two users', (done) -> + nockUtils.setupNock 'sub-test-31.json', (err, nockDone) -> stripe.tokens.create { card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } }, (err, token) -> @@ -1215,31 +1309,34 @@ describe 'Subscriptions', -> loginNewUser (user1) -> subscribeRecipients user1, [user2, user3], token, (updatedUser) -> verifySponsorship user1.id, user2.id, -> - verifySponsorship user1.id, user3.id, done + verifySponsorship user1.id, user3.id, -> + nockDone() + done() - it 'Subscribed user1 subscribes 2 users, unsubscribes 2', (done) -> + it 'Subscribed user1 subscribes 2 users, unsubscribes 2', (done) -> + nockUtils.setupNock 'sub-test-32.json', (err, nockDone) -> recipientCount = 2 recipientsToVerify = [0, 1] recipients = new SubbedRecipients recipientCount, recipientsToVerify - + # Create recipients recipients.createRecipients -> expect(recipients.length()).toEqual(recipientCount) - + stripe.tokens.create { card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } }, (err, token) -> - + # Create sponsor user loginNewUser (user1) -> subscribeUser user1, token, null, (updatedUser) -> User.findById user1.id, (err, user1) -> expect(err).toBeNull() - + # Subscribe recipients recipients.subRecipients user1, null, -> User.findById user1.id, (err, user1) -> - + # Unsubscribe recipient0 unsubscribeRecipient user1, recipients.get(0), -> User.findById user1.id, (err, user1) -> @@ -1251,7 +1348,7 @@ describe 'Subscriptions', -> expect(err).toBeNull() expect(subscription).not.toBeNull() expect(subscription?.quantity).toEqual(getSubscribedQuantity(1)) - + # Unsubscribe recipient1 unsubscribeRecipient user1, recipients.get(1), -> User.findById user1.id, (err, user1) -> @@ -1264,9 +1361,11 @@ describe 'Subscriptions', -> expect(subscription).not.toBeNull() return done() unless subscription expect(subscription.quantity).toEqual(0) + nockDone() done() - it 'Subscribed user1 subscribes 3 users, unsubscribes 2, themselves, then 1', (done) -> + it 'Subscribed user1 subscribes 3 users, unsubscribes 2, themselves, then 1', (done) -> + nockUtils.setupNock 'sub-test-33.json', (err, nockDone) -> recipientCount = 3 recipientsToVerify = [0, 1, 2] recipients = new SubbedRecipients recipientCount, recipientsToVerify @@ -1334,9 +1433,11 @@ describe 'Subscriptions', -> expect(err).toBeNull() expect(subscription).not.toBeNull() expect(subscription?.quantity).toEqual(getSubscribedQuantity(recipientCount - 3)) + nockDone() done() - xit 'Unsubscribed user1 subscribes 13 users, unsubcribes 2', (done) -> + xit 'Unsubscribed user1 subscribes 13 users, unsubcribes 2', (done) -> + nockUtils.setupNock 'sub-test-34.json', (err, nockDone) -> # TODO: Hits the Stripe error 'Request rate limit exceeded'. # TODO: Need a better test for 12+ bulk discounts. Or, we could update the bulk disount logic. # TODO: verify interim invoices? @@ -1389,193 +1490,206 @@ describe 'Subscriptions', -> expect(subscription.quantity).toEqual(subPrice + (numSponsored - 1) * subPrice * 0.8) else expect(subscription.quantity).toEqual(subPrice + 10 * subPrice * 0.8 + (numSponsored - 11) * subPrice * 0.6) + nockDone() done() describe 'APIs', -> subscriptionURL = getURL('/db/subscription') it 'year_sale', (done) -> - stripe.tokens.create { - card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> - loginNewUser (user1) -> - expect(user1.get('stripe')?.free).toBeUndefined() - requestBody = - stripe: - token: token.id - timestamp: new Date() - request.put {uri: "#{subscriptionURL}/-/year_sale", json: requestBody, headers: headers }, (err, res) -> - expect(err).toBeNull() - expect(res.statusCode).toBe(200) - User.findById user1.id, (err, user1) -> + nockUtils.setupNock 'sub-test-35.json', (err, nockDone) -> + stripe.tokens.create { + card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + loginNewUser (user1) -> + expect(user1.get('stripe')?.free).toBeUndefined() + requestBody = + stripe: + token: token.id + timestamp: new Date() + request.put {uri: "#{subscriptionURL}/-/year_sale", json: requestBody, headers: headers }, (err, res) -> expect(err).toBeNull() - stripeInfo = user1.get('stripe') - expect(stripeInfo).toBeDefined() - return done() unless stripeInfo - endDate = new Date() - endDate.setUTCFullYear(endDate.getUTCFullYear() + 1) - expect(stripeInfo.free).toEqual(endDate.toISOString().substring(0, 10)) - expect(stripeInfo.customerID).toBeDefined() - expect(user1.get('purchased')?.gems).toEqual(3500*12) - Payment.findOne 'stripe.customerID': stripeInfo.customerID, (err, payment) -> + expect(res.statusCode).toBe(200) + User.findById user1.id, (err, user1) -> expect(err).toBeNull() - expect(payment).toBeDefined() - expect(payment.get('gems')).toEqual(3500*12) - done() + stripeInfo = user1.get('stripe') + expect(stripeInfo).toBeDefined() + return done() unless stripeInfo + endDate = new Date() + endDate.setUTCFullYear(endDate.getUTCFullYear() + 1) + expect(stripeInfo.free).toEqual(endDate.toISOString().substring(0, 10)) + expect(stripeInfo.customerID).toBeDefined() + expect(user1.get('purchased')?.gems).toEqual(3500*12) + Payment.findOne 'stripe.customerID': stripeInfo.customerID, (err, payment) -> + expect(err).toBeNull() + expect(payment).toBeDefined() + expect(payment.get('gems')).toEqual(3500*12) + nockDone() + done() it 'year_sale when stripe.free === true', (done) -> - stripe.tokens.create { - card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> - loginNewUser (user1) -> - user1.set('stripe', {free: true}) - user1.save (err, user1) -> - expect(err).toBeNull() - expect(user1.get('stripe')?.free).toEqual(true) - requestBody = - stripe: - token: token.id - timestamp: new Date() - request.put {uri: "#{subscriptionURL}/-/year_sale", json: requestBody, headers: headers }, (err, res) -> + nockUtils.setupNock 'sub-test-36.json', (err, nockDone) -> + stripe.tokens.create { + card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + loginNewUser (user1) -> + user1.set('stripe', {free: true}) + user1.save (err, user1) -> expect(err).toBeNull() - expect(res.statusCode).toBe(200) - User.findById user1.id, (err, user1) -> + expect(user1.get('stripe')?.free).toEqual(true) + requestBody = + stripe: + token: token.id + timestamp: new Date() + request.put {uri: "#{subscriptionURL}/-/year_sale", json: requestBody, headers: headers }, (err, res) -> expect(err).toBeNull() - stripeInfo = user1.get('stripe') - expect(stripeInfo).toBeDefined() - return done() unless stripeInfo - endDate = new Date() - endDate.setUTCFullYear(endDate.getUTCFullYear() + 1) - expect(stripeInfo.free).toEqual(endDate.toISOString().substring(0, 10)) - expect(stripeInfo.customerID).toBeDefined() - expect(user1.get('purchased')?.gems).toEqual(3500*12) - Payment.findOne 'stripe.customerID': stripeInfo.customerID, (err, payment) -> + expect(res.statusCode).toBe(200) + User.findById user1.id, (err, user1) -> expect(err).toBeNull() - expect(payment).toBeDefined() - expect(payment.get('gems')).toEqual(3500*12) - done() + stripeInfo = user1.get('stripe') + expect(stripeInfo).toBeDefined() + return done() unless stripeInfo + endDate = new Date() + endDate.setUTCFullYear(endDate.getUTCFullYear() + 1) + expect(stripeInfo.free).toEqual(endDate.toISOString().substring(0, 10)) + expect(stripeInfo.customerID).toBeDefined() + expect(user1.get('purchased')?.gems).toEqual(3500*12) + Payment.findOne 'stripe.customerID': stripeInfo.customerID, (err, payment) -> + expect(err).toBeNull() + expect(payment).toBeDefined() + expect(payment.get('gems')).toEqual(3500*12) + nockDone() + done() it 'year_sale when stripe.free < today', (done) -> - stripe.tokens.create { - card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> - loginNewUser (user1) -> - endDate = new Date() - endDate.setUTCFullYear(endDate.getUTCFullYear() - 1) - user1.set('stripe', {free: endDate.toISOString().substring(0, 10)}) - user1.save (err, user1) -> - expect(err).toBeNull() - expect(user1.get('stripe')?.free).toEqual(endDate.toISOString().substring(0, 10)) - requestBody = - stripe: - token: token.id - timestamp: new Date() - request.put {uri: "#{subscriptionURL}/-/year_sale", json: requestBody, headers: headers }, (err, res) -> + nockUtils.setupNock 'sub-test-37.json', (err, nockDone) -> + stripe.tokens.create { + card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + loginNewUser (user1) -> + endDate = new Date() + endDate.setUTCFullYear(endDate.getUTCFullYear() - 1) + user1.set('stripe', {free: endDate.toISOString().substring(0, 10)}) + user1.save (err, user1) -> expect(err).toBeNull() - expect(res.statusCode).toBe(200) - User.findById user1.id, (err, user1) -> + expect(user1.get('stripe')?.free).toEqual(endDate.toISOString().substring(0, 10)) + requestBody = + stripe: + token: token.id + timestamp: new Date() + request.put {uri: "#{subscriptionURL}/-/year_sale", json: requestBody, headers: headers }, (err, res) -> expect(err).toBeNull() - stripeInfo = user1.get('stripe') - expect(stripeInfo).toBeDefined() - return done() unless stripeInfo - endDate = new Date() - endDate.setUTCFullYear(endDate.getUTCFullYear() + 1) - expect(stripeInfo.free).toEqual(endDate.toISOString().substring(0, 10)) - expect(stripeInfo.customerID).toBeDefined() - expect(user1.get('purchased')?.gems).toEqual(3500*12) - Payment.findOne 'stripe.customerID': stripeInfo.customerID, (err, payment) -> + expect(res.statusCode).toBe(200) + User.findById user1.id, (err, user1) -> expect(err).toBeNull() - expect(payment).toBeDefined() - expect(payment.get('gems')).toEqual(3500*12) - done() + stripeInfo = user1.get('stripe') + expect(stripeInfo).toBeDefined() + return done() unless stripeInfo + endDate = new Date() + endDate.setUTCFullYear(endDate.getUTCFullYear() + 1) + expect(stripeInfo.free).toEqual(endDate.toISOString().substring(0, 10)) + expect(stripeInfo.customerID).toBeDefined() + expect(user1.get('purchased')?.gems).toEqual(3500*12) + Payment.findOne 'stripe.customerID': stripeInfo.customerID, (err, payment) -> + expect(err).toBeNull() + expect(payment).toBeDefined() + expect(payment.get('gems')).toEqual(3500*12) + nockDone() + done() it 'year_sale when stripe.free > today', (done) -> - stripe.tokens.create { - card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> - loginNewUser (user1) -> - endDate = new Date() - endDate.setUTCDate(endDate.getUTCDate() + 5) - user1.set('stripe', {free: endDate.toISOString().substring(0, 10)}) - user1.save (err, user1) -> - expect(err).toBeNull() - expect(user1.get('stripe')?.free).toEqual(endDate.toISOString().substring(0, 10)) - requestBody = - stripe: - token: token.id - timestamp: new Date() - request.put {uri: "#{subscriptionURL}/-/year_sale", json: requestBody, headers: headers }, (err, res) -> + nockUtils.setupNock 'sub-test-38.json', (err, nockDone) -> + stripe.tokens.create { + card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + loginNewUser (user1) -> + endDate = new Date() + endDate.setUTCDate(endDate.getUTCDate() + 5) + user1.set('stripe', {free: endDate.toISOString().substring(0, 10)}) + user1.save (err, user1) -> expect(err).toBeNull() - expect(res.statusCode).toBe(200) + expect(user1.get('stripe')?.free).toEqual(endDate.toISOString().substring(0, 10)) + requestBody = + stripe: + token: token.id + timestamp: new Date() + request.put {uri: "#{subscriptionURL}/-/year_sale", json: requestBody, headers: headers }, (err, res) -> + expect(err).toBeNull() + expect(res.statusCode).toBe(200) + User.findById user1.id, (err, user1) -> + expect(err).toBeNull() + stripeInfo = user1.get('stripe') + expect(stripeInfo).toBeDefined() + return done() unless stripeInfo + endDate = new Date() + endDate.setUTCFullYear(endDate.getUTCFullYear() + 1) + endDate.setUTCDate(endDate.getUTCDate() + 5) + expect(stripeInfo.free).toEqual(endDate.toISOString().substring(0, 10)) + expect(stripeInfo.customerID).toBeDefined() + expect(user1.get('purchased')?.gems).toEqual(3500*12) + Payment.findOne 'stripe.customerID': stripeInfo.customerID, (err, payment) -> + expect(err).toBeNull() + expect(payment).toBeDefined() + expect(payment.get('gems')).toEqual(3500*12) + nockDone() + done() + + it 'year_sale with monthly sub', (done) -> + nockUtils.setupNock 'sub-test-39.json', (err, nockDone) -> + stripe.tokens.create { + card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + loginNewUser (user1) -> + subscribeUser user1, token, null, -> User.findById user1.id, (err, user1) -> expect(err).toBeNull() stripeInfo = user1.get('stripe') - expect(stripeInfo).toBeDefined() - return done() unless stripeInfo - endDate = new Date() - endDate.setUTCFullYear(endDate.getUTCFullYear() + 1) - endDate.setUTCDate(endDate.getUTCDate() + 5) - expect(stripeInfo.free).toEqual(endDate.toISOString().substring(0, 10)) - expect(stripeInfo.customerID).toBeDefined() - expect(user1.get('purchased')?.gems).toEqual(3500*12) - Payment.findOne 'stripe.customerID': stripeInfo.customerID, (err, payment) -> + stripe.customers.retrieveSubscription stripeInfo.customerID, stripeInfo.subscriptionID, (err, subscription) -> expect(err).toBeNull() - expect(payment).toBeDefined() - expect(payment.get('gems')).toEqual(3500*12) - done() - - it 'year_sale with monthly sub', (done) -> - stripe.tokens.create { - card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> - loginNewUser (user1) -> - subscribeUser user1, token, null, -> - User.findById user1.id, (err, user1) -> - expect(err).toBeNull() - stripeInfo = user1.get('stripe') - stripe.customers.retrieveSubscription stripeInfo.customerID, stripeInfo.subscriptionID, (err, subscription) -> - expect(err).toBeNull() - expect(subscription).not.toBeNull() - stripeSubscriptionPeriodEndDate = new Date(subscription.current_period_end * 1000) - stripe.tokens.create { - card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> - requestBody = - stripe: - token: token.id - timestamp: new Date() - request.put {uri: "#{subscriptionURL}/-/year_sale", json: requestBody, headers: headers }, (err, res) -> - expect(err).toBeNull() - expect(res.statusCode).toBe(200) - User.findById user1.id, (err, user1) -> + expect(subscription).not.toBeNull() + stripeSubscriptionPeriodEndDate = new Date(subscription.current_period_end * 1000) + stripe.tokens.create { + card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + requestBody = + stripe: + token: token.id + timestamp: new Date() + request.put {uri: "#{subscriptionURL}/-/year_sale", json: requestBody, headers: headers }, (err, res) -> expect(err).toBeNull() - stripeInfo = user1.get('stripe') - expect(stripeInfo).toBeDefined() - return done() unless stripeInfo - endDate = stripeSubscriptionPeriodEndDate - endDate.setUTCFullYear(endDate.getUTCFullYear() + 1) - expect(stripeInfo.free).toEqual(endDate.toISOString().substring(0, 10)) - expect(stripeInfo.customerID).toBeDefined() - expect(user1.get('purchased')?.gems).toEqual(3500+3500*12) - Payment.findOne 'stripe.customerID': stripeInfo.customerID, (err, payment) -> + expect(res.statusCode).toBe(200) + User.findById user1.id, (err, user1) -> expect(err).toBeNull() - expect(payment).toBeDefined() - expect(payment.get('gems')).toEqual(3500*12) - done() + stripeInfo = user1.get('stripe') + expect(stripeInfo).toBeDefined() + return done() unless stripeInfo + endDate = stripeSubscriptionPeriodEndDate + endDate.setUTCFullYear(endDate.getUTCFullYear() + 1) + expect(stripeInfo.free).toEqual(endDate.toISOString().substring(0, 10)) + expect(stripeInfo.customerID).toBeDefined() + expect(user1.get('purchased')?.gems).toEqual(3500+3500*12) + Payment.findOne 'stripe.customerID': stripeInfo.customerID, (err, payment) -> + expect(err).toBeNull() + expect(payment).toBeDefined() + expect(payment.get('gems')).toEqual(3500*12) + nockDone() + done() it 'year_sale with sponsored sub', (done) -> - stripe.tokens.create { - card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> - loginNewUser (user1) -> - user1.set('stripe', {sponsorID: 'dummyID'}) - user1.save (err, user1) -> - expect(err).toBeNull() - requestBody = - stripe: - token: token.id - timestamp: new Date() - request.put {uri: "#{subscriptionURL}/-/year_sale", json: requestBody, headers: headers }, (err, res) -> - console.log err + nockUtils.setupNock 'sub-test-40.json', (err, nockDone) -> + stripe.tokens.create { + card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } + }, (err, token) -> + loginNewUser (user1) -> + user1.set('stripe', {sponsorID: 'dummyID'}) + user1.save (err, user1) -> expect(err).toBeNull() - done() + requestBody = + stripe: + token: token.id + timestamp: new Date() + request.put {uri: "#{subscriptionURL}/-/year_sale", json: requestBody, headers: headers }, (err, res) -> + console.log err + expect(err).toBeNull() + nockDone() + done() diff --git a/test/server/functional/trial_request.spec.coffee b/spec/server/functional/trial_request.spec.coffee similarity index 100% rename from test/server/functional/trial_request.spec.coffee rename to spec/server/functional/trial_request.spec.coffee diff --git a/test/server/functional/user.spec.coffee b/spec/server/functional/user.spec.coffee similarity index 98% rename from test/server/functional/user.spec.coffee rename to spec/server/functional/user.spec.coffee index ad47fb892..0d7958eda 100644 --- a/test/server/functional/user.spec.coffee +++ b/spec/server/functional/user.spec.coffee @@ -4,6 +4,7 @@ User = require '../../../server/users/User' urlUser = '/db/user' + describe 'Server user object', -> it 'uses the schema defaults to fill in email preferences', (done) -> @@ -30,9 +31,7 @@ describe 'Server user object', -> describe 'User.updateServiceSettings', -> makeMC = (callback) -> - GLOBAL.mc = - lists: - subscribe: callback + spyOn(mc.lists, 'subscribe').and.callFake callback it 'uses emails to determine what to send to MailChimp', (done) -> makeMC (params) -> @@ -74,8 +73,8 @@ describe 'POST /db/user', -> done() it 'serves the user through /db/user/id', (done) -> - request.post getURL('/auth/logout'), -> - unittest.getNormalJoe (user) -> + unittest.getNormalJoe (user) -> + request.post getURL('/auth/logout'), -> url = getURL(urlUser+'/'+user._id) request.get url, (err, res, body) -> expect(res.statusCode).toBe(200) @@ -366,7 +365,7 @@ describe 'Statistics', -> it 'recalculates games completed', (done) -> unittest.getNormalJoe (joe) -> loginAdmin -> - User.findByIdAndUpdate joe.get('id'), {$unset:'stats.gamesCompleted': ''}, (err, guy) -> + User.findByIdAndUpdate joe.get('id'), {$unset:'stats.gamesCompleted': ''}, {new: true}, (err, guy) -> expect(err).toBeNull() expect(guy.get 'stats.gamesCompleted').toBeUndefined() @@ -408,7 +407,7 @@ describe 'Statistics', -> it 'recalculates article edits', (done) -> loginAdmin (carl) -> - User.findByIdAndUpdate carl.get('id'), {$unset:'stats.articleEdits': ''}, (err, guy) -> + User.findByIdAndUpdate carl.get('id'), {$unset:'stats.articleEdits': ''}, {new: true}, (err, guy) -> expect(err).toBeNull() expect(guy.get User.statsMapping.edits.article).toBeUndefined() @@ -441,7 +440,7 @@ describe 'Statistics', -> it 'recalculates level edits', (done) -> unittest.getAdmin (jose) -> - User.findByIdAndUpdate jose.get('id'), {$unset:'stats.levelEdits':''}, (err, guy) -> + User.findByIdAndUpdate jose.get('id'), {$unset:'stats.levelEdits':''}, {new: true}, (err, guy) -> expect(err).toBeNull() expect(guy.get User.statsMapping.edits.level).toBeUndefined() diff --git a/test/server/init.coffee b/spec/server/init.coffee similarity index 100% rename from test/server/init.coffee rename to spec/server/init.coffee diff --git a/test/server/integration/models/Level.spec.coffee b/spec/server/integration/models/Level.spec.coffee similarity index 100% rename from test/server/integration/models/Level.spec.coffee rename to spec/server/integration/models/Level.spec.coffee diff --git a/test/server/integration/models/LevelComponent.spec.coffee b/spec/server/integration/models/LevelComponent.spec.coffee similarity index 100% rename from test/server/integration/models/LevelComponent.spec.coffee rename to spec/server/integration/models/LevelComponent.spec.coffee diff --git a/test/server/integration/models/LevelSession.spec.coffee b/spec/server/integration/models/LevelSession.spec.coffee similarity index 100% rename from test/server/integration/models/LevelSession.spec.coffee rename to spec/server/integration/models/LevelSession.spec.coffee diff --git a/test/server/integration/models/LevelSystem.spec.coffee b/spec/server/integration/models/LevelSystem.spec.coffee similarity index 100% rename from test/server/integration/models/LevelSystem.spec.coffee rename to spec/server/integration/models/LevelSystem.spec.coffee diff --git a/test/server/integration/models/LevelThangType.spec.coffee b/spec/server/integration/models/LevelThangType.spec.coffee similarity index 100% rename from test/server/integration/models/LevelThangType.spec.coffee rename to spec/server/integration/models/LevelThangType.spec.coffee diff --git a/test/server/integration/models/article.spec.coffee b/spec/server/integration/models/article.spec.coffee similarity index 100% rename from test/server/integration/models/article.spec.coffee rename to spec/server/integration/models/article.spec.coffee diff --git a/test/server/integration/models/plugins.spec.coffee b/spec/server/integration/models/plugins.spec.coffee similarity index 100% rename from test/server/integration/models/plugins.spec.coffee rename to spec/server/integration/models/plugins.spec.coffee diff --git a/spec/server/nock-utils.coffee b/spec/server/nock-utils.coffee new file mode 100644 index 000000000..2409abb61 --- /dev/null +++ b/spec/server/nock-utils.coffee @@ -0,0 +1,78 @@ +nock = require('nock') +nockBack = nock.back +nockBack.fixtures = 'spec/fixtures/' + +module.exports.setupNock = (fixtureFilename, options, done) -> + if _.isFunction(options) + done = options + options = {} + + keep = { + has_more: true + email: true + subscription: true + description: true + current_period_end: true + current_period_start: true + cancel_at_period_end: true + productID: true + amount: true + customer: true + gems: true + id: true + product_id: true + proration: true + paid: true + quantity: true + timestamp: true + total: true + transaction_id: true + type: true + months: true + } + + if options.keep + _.extend(keep, options.keep) + + afterRecord = (scopes) -> + scopes = _.filter scopes, (scope) -> not _.contains(scope.scope, '//localhost:') + for scope in scopes + delete scope['body'] + delete scope['headers'] + clean(scope.response) + return scopes + + clean = (obj) -> + for key, value of obj + unless keep[key] or _.isArray(value) or _.isObject(value) + delete obj[key] + if _.isNull(value) + delete obj[key] + if _.isArray(value) + for child in value + clean(child) + if _.isEmpty(value) + delete obj[key] + if _.isObject(value) + clean(value) + if _.isEmpty(value) + delete obj[key] + + nockBack.setMode('record') + nockBack fixtureFilename, {afterRecord: afterRecord, before: before}, (nockDone) -> + nock.enableNetConnect('localhost') + done(null, nockDone) + +module.exports.teardownNock = -> + nockBack.setMode('wild') + nock.cleanAll() + +# payment.spec.coffee needs this, because each test creates new Users with new _ids which +# are sent to Stripe as metadata. This messes up the tests which expect inputs to be +# uniform. This scope-preprocessor makes nock ignore body for matching requests. +# Ideally we would not do this; perhaps a better system would be to figure out a way +# to create users with consistent _id values. + +before = (scope) -> + scope.body = (body) -> true + diff --git a/test/server/unit/analytics.spec.coffee b/spec/server/unit/analytics.spec.coffee similarity index 100% rename from test/server/unit/analytics.spec.coffee rename to spec/server/unit/analytics.spec.coffee diff --git a/test/server/unit/patch.spec.coffee b/spec/server/unit/patch.spec.coffee similarity index 100% rename from test/server/unit/patch.spec.coffee rename to spec/server/unit/patch.spec.coffee diff --git a/test/server/unit/user.spec.coffee b/spec/server/unit/user.spec.coffee similarity index 100% rename from test/server/unit/user.spec.coffee rename to spec/server/unit/user.spec.coffee diff --git a/spec/support/jasmine.json b/spec/support/jasmine.json new file mode 100644 index 000000000..32d8cf68f --- /dev/null +++ b/spec/support/jasmine.json @@ -0,0 +1,10 @@ +{ + "spec_dir": "spec", + "spec_files": [ + "**/*[sS]pec.js", + "**/*[sS]pec.coffee" + ], + "helpers": [ + "helpers/**/*.js" + ] +} diff --git a/test/server/functional/discount_handler.spec.coffee b/test/server/functional/discount_handler.spec.coffee deleted file mode 100644 index 9cca335bc..000000000 --- a/test/server/functional/discount_handler.spec.coffee +++ /dev/null @@ -1,114 +0,0 @@ -config = require '../../../server_config' -require '../common' - -# sample data that comes in through the webhook when you subscribe - - -describe '/db/user, editing stripe.couponID property', -> - - stripe = require('stripe')(config.stripe.secretKey) - userURL = getURL('/db/user') - webhookURL = getURL('/stripe/webhook') - - it 'clears the db first', (done) -> - clearModels [User, Payment], (err) -> - throw err if err - done() - - #- shared data between tests - joeData = null - firstSubscriptionID = null - - it 'does not work for non-admins', (done) -> - loginJoe (joe) -> - joeData = joe.toObject() - expect(joeData.stripe).toBeUndefined() - joeData.stripe = { couponID: '20pct' } - request.put {uri: userURL, json: joeData }, (err, res, body) -> - expect(res.statusCode).toBe(200) # fails silently - expect(res.body.stripe).toBeUndefined() # but still fails - done() - - it 'does not work with invalid coupons', (done) -> - loginAdmin (admin) -> - joeData.stripe = { couponID: 'DNE' } - request.put {uri: userURL, json: joeData }, (err, res, body) -> - expect(res.statusCode).toBe(404) - done() - - it 'sets the couponID on a user without an existing stripe object', (done) -> - joeData.stripe = { couponID: '20pct' } - request.put {uri: userURL, json: joeData }, (err, res, body) -> - expect(err).toBeNull() - return done() if err - joeData = body - expect(res.statusCode).toBe(200) - expect(body.stripe.couponID).toBe('20pct') - done() - - it 'just updates the couponID when it changes and there is no existing subscription', (done) -> - joeData.stripe.couponID = '500off' - request.put {uri: userURL, json: joeData }, (err, res, body) -> - expect(res.statusCode).toBe(200) - expect(body.stripe.couponID).toBe('500off') - done() - - it 'removes the couponID from the user when the admin makes it so', (done) -> - delete joeData.stripe.couponID - request.put {uri: userURL, json: joeData }, (err, res, body) -> - joeData = body - expect(res.statusCode).toBe(200) - expect(body.stripe).toBeUndefined() - done() - - it 'puts the coupon back', (done) -> - joeData.stripe = {couponID: '500off'} - request.put {uri: userURL, json: joeData }, (err, res, body) -> - expect(res.statusCode).toBe(200) - expect(body.stripe.couponID).toBe('500off') - done() - - it 'applies a discount to the newly created subscription when a plan is set', (done) -> - stripe.tokens.create { - card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> - stripeTokenID = token.id - loginJoe (joe) -> - joeData.stripe.token = stripeTokenID - joeData.stripe.planID = 'basic' - request.put {uri: userURL, json: joeData, headers: {'X-Change-Plan': 'true'} }, (err, res, body) -> - joeData = body - expect(res.statusCode).toBe(200) - stripe.customers.retrieveSubscription joeData.stripe.customerID, joeData.stripe.subscriptionID, (err, subscription) -> - expect(subscription.discount).toBeDefined() - expect(subscription.discount?.coupon.id).toBe('500off') - done() - - - it 'updates the discount on the customer when an admin changes the couponID', (done) -> - loginAdmin (admin) -> - joeData.stripe.couponID = '20pct' - request.put {uri: userURL, json: joeData }, (err, res, body) -> - expect(res.statusCode).toBe(200) - expect(body.stripe.couponID).toBe('20pct') - stripe.customers.retrieve joeData.stripe.customerID, (err, customer) -> - expect(customer.discount.coupon.id).toBe('20pct') - done() - - it 'removes discounts from the customer when an admin removes the couponID', (done) -> - delete joeData.stripe.couponID - request.put {uri: userURL, json: joeData }, (err, res, body) -> - expect(res.statusCode).toBe(200) - expect(body.stripe.couponID).toBeUndefined() - stripe.customers.retrieve joeData.stripe.customerID, (err, customer) -> - expect(customer.discount).toBe(null) - done() - - it 'adds a discount to the customer when an admin adds the couponID', (done) -> - joeData.stripe.couponID = '20pct' - request.put {uri: userURL, json: joeData }, (err, res, body) -> - expect(res.statusCode).toBe(200) - expect(body.stripe.couponID).toBe('20pct') - stripe.customers.retrieve joeData.stripe.customerID, (err, customer) -> - expect(customer.discount.coupon.id).toBe('20pct') - done() diff --git a/test/server/functional/payment.spec.coffee b/test/server/functional/payment.spec.coffee deleted file mode 100644 index a20adb714..000000000 --- a/test/server/functional/payment.spec.coffee +++ /dev/null @@ -1,437 +0,0 @@ -testReceipt = 'MIIVEQYJKoZIhvcNAQcCoIIVAjCCFP4CAQExCzAJBgUrDgMCGgUAMIIEwgYJKoZIhvcNAQcBoIIEswSCBK8xggSrMAoCAQgCAQEEAhYAMAoCARQCAQEEAgwAMAsCAQECAQEEAwIBADALAgEDAgEBBAMMATkwCwIBCwIBAQQDAgEAMAsCAQ4CAQEEAwIBTTALAgEPAgEBBAMCAQAwCwIBEAIBAQQDAgEAMAsCARkCAQEEAwIBAzAMAgEKAgEBBAQWAjQrMA0CAQ0CAQEEBQIDATjkMA0CARMCAQEEBQwDMS4wMA4CAQkCAQEEBgIEUDIzMTAYAgEEAgECBBBFm6ID3eNcNpCJVGMvofTCMBsCAQACAQEEEwwRUHJvZHVjdGlvblNhbmRib3gwHAIBBQIBAQQUshze7K1i43z3C/N8znUlSOq0OpkwHgIBDAIBAQQWFhQyMDE0LTExLTEyVDAwOjUwOjM3WjAeAgESAgEBBBYWFDIwMTMtMDgtMDFUMDc6MDA6MDBaMCMCAQICAQEEGwwZY29tLmNvZGVjb21iYXQuQ29kZUNvbWJhdDBCAgEHAgEBBDqqVISWC4wNjaBXqlNV7plPdTXyDx32V1y7ydj0cF8hhG/4rs/XJxhXtesY4ke9xCSq9+SQbgDWUAgAMF0CAQYCAQEEVfREWcK86WrR/8tApnityEV/y1WFszw7Pso3NclvMXkL5qBE0tBvLF8mO890BdA1Dr0TjkN69uLToEn/uVYjmKJ388shlls6eE3krpaFsl/48qVSADkwggFLAgERAgEBBIIBQTGCAT0wCwICBqwCAQEEAhYAMAsCAgatAgEBBAIMADALAgIGsAIBAQQCFgAwCwICBrICAQEEAgwAMAsCAgazAgEBBAIMADALAgIGtAIBAQQCDAAwCwICBrUCAQEEAgwAMAsCAga2AgEBBAIMADAMAgIGpQIBAQQDAgEBMAwCAgarAgEBBAMCAQEwDAICBq4CAQEEAwIBADAMAgIGrwIBAQQDAgEAMAwCAgaxAgEBBAMCAQAwEQICBqYCAQEECAwGZ2Vtc181MBsCAganAgEBBBIMEDEwMDAwMDAxMzEyNzQ0MzkwGwICBqkCAQEEEgwQMTAwMDAwMDEzMTI3NDQzOTAfAgIGqAIBAQQWFhQyMDE0LTExLTEyVDAwOjUwOjM3WjAfAgIGqgIBAQQWFhQyMDE0LTExLTExVDIxOjQyOjU4WjCCAUwCARECAQEEggFCMYIBPjALAgIGrAIBAQQCFgAwCwICBq0CAQEEAgwAMAsCAgawAgEBBAIWADALAgIGsgIBAQQCDAAwCwICBrMCAQEEAgwAMAsCAga0AgEBBAIMADALAgIGtQIBAQQCDAAwCwICBrYCAQEEAgwAMAwCAgalAgEBBAMCAQEwDAICBqsCAQEEAwIBATAMAgIGrgIBAQQDAgEAMAwCAgavAgEBBAMCAQAwDAICBrECAQEEAwIBADASAgIGpgIBAQQJDAdnZW1zXzEwMBsCAganAgEBBBIMEDEwMDAwMDAxMzEyODM2MDgwGwICBqkCAQEEEgwQMTAwMDAwMDEzMTI4MzYwODAfAgIGqAIBAQQWFhQyMDE0LTExLTEyVDAwOjUwOjM3WjAfAgIGqgIBAQQWFhQyMDE0LTExLTEyVDAwOjUwOjM3WqCCDlUwggVrMIIEU6ADAgECAggYWUMhcnSc/DANBgkqhkiG9w0BAQUFADCBljELMAkGA1UEBhMCVVMxEzARBgNVBAoMCkFwcGxlIEluYy4xLDAqBgNVBAsMI0FwcGxlIFdvcmxkd2lkZSBEZXZlbG9wZXIgUmVsYXRpb25zMUQwQgYDVQQDDDtBcHBsZSBXb3JsZHdpZGUgRGV2ZWxvcGVyIFJlbGF0aW9ucyBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0xMDExMTEyMTU4MDFaFw0xNTExMTEyMTU4MDFaMHgxJjAkBgNVBAMMHU1hYyBBcHAgU3RvcmUgUmVjZWlwdCBTaWduaW5nMSwwKgYDVQQLDCNBcHBsZSBXb3JsZHdpZGUgRGV2ZWxvcGVyIFJlbGF0aW9uczETMBEGA1UECgwKQXBwbGUgSW5jLjELMAkGA1UEBhMCVVMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC2k8K3DyRe7dI0SOiFBeMzlGZb6Cc3v3tDSev5yReXM3MySUrIb2gpFLiUpvRlSztH19EsZku4mNm89RJRy+YvqfSznxzoKPxSwIGiy1ZigFqika5OQMN9KC7X0+1N2a2K+/JnSOzreb0CbQRZGP+MN5+KN/Fi/7uiA1CHCtWS4IYRXiNG9eElYyuiaoyyELeRI02aP4NA8mQJWveNrlZc1PW0bgMbBF0sG68AmRfXpftJkc7ioRExXhkBwNrOUINeyOtJO0kaKurgn7/SRkmc2Kuhg2FsD8H8s62ZdSr8I5vvIgjre1kUEZ9zNC3muTmmO/fmPuzKpvurrybfj4iBAgMBAAGjggHYMIIB1DAMBgNVHRMBAf8EAjAAMB8GA1UdIwQYMBaAFIgnFwmpthhgi+zruvZHWcVSVKO3ME0GA1UdHwRGMEQwQqBAoD6GPGh0dHA6Ly9kZXZlbG9wZXIuYXBwbGUuY29tL2NlcnRpZmljYXRpb25hdXRob3JpdHkvd3dkcmNhLmNybDAOBgNVHQ8BAf8EBAMCB4AwHQYDVR0OBBYEFHV2JKJrYgyXNKH6Tl4IDCK/c+++MIIBEQYDVR0gBIIBCDCCAQQwggEABgoqhkiG92NkBQYBMIHxMIHDBggrBgEFBQcCAjCBtgyBs1JlbGlhbmNlIG9uIHRoaXMgY2VydGlmaWNhdGUgYnkgYW55IHBhcnR5IGFzc3VtZXMgYWNjZXB0YW5jZSBvZiB0aGUgdGhlbiBhcHBsaWNhYmxlIHN0YW5kYXJkIHRlcm1zIGFuZCBjb25kaXRpb25zIG9mIHVzZSwgY2VydGlmaWNhdGUgcG9saWN5IGFuZCBjZXJ0aWZpY2F0aW9uIHByYWN0aWNlIHN0YXRlbWVudHMuMCkGCCsGAQUFBwIBFh1odHRwOi8vd3d3LmFwcGxlLmNvbS9hcHBsZWNhLzAQBgoqhkiG92NkBgsBBAIFADANBgkqhkiG9w0BAQUFAAOCAQEAoDvxh7xptLeDfBn0n8QCZN8CyY4xc8scPtwmB4v9nvPtvkPWjWEt5PDcFnMB1jSjaRl3FL+5WMdSyYYAf2xsgJepmYXoePOaEqd+ODhk8wTLX/L2QfsHJcsCIXHzRD/Q4nth90Ljq793bN0sUJyAhMWlb1hZekYxQWi7EzVFQqSM+hHVSxbyMjXeH7zSmV3I5gIyWZDojcs53yHaw3b7ejYaFhqYTIUb5itFLS9ZGi3GmtZmkqPSNlJQgCBNM8iymtZTYrFgUvD1930QUOQSv71xvrSAx23Eb1s5NdHnt96BICeOOFyChzpzYMTW8RygqWZEfs4MKJsjf6zs5qA73TCCBCMwggMLoAMCAQICARkwDQYJKoZIhvcNAQEFBQAwYjELMAkGA1UEBhMCVVMxEzARBgNVBAoTCkFwcGxlIEluYy4xJjAkBgNVBAsTHUFwcGxlIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRYwFAYDVQQDEw1BcHBsZSBSb290IENBMB4XDTA4MDIxNDE4NTYzNVoXDTE2MDIxNDE4NTYzNVowgZYxCzAJBgNVBAYTAlVTMRMwEQYDVQQKDApBcHBsZSBJbmMuMSwwKgYDVQQLDCNBcHBsZSBXb3JsZHdpZGUgRGV2ZWxvcGVyIFJlbGF0aW9uczFEMEIGA1UEAww7QXBwbGUgV29ybGR3aWRlIERldmVsb3BlciBSZWxhdGlvbnMgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDKOFSmy1aqyCQ5SOmM7uxfuH8mkbw0U3rOfGOAYXdkXqUHI7Y5/lAtFVZYcC1+xG7BSoU+L/DehBqhV8mvexj/avoVEkkVCBmsqtsqMu2WY2hSFT2Miuy/axiV4AOsAX2XBWfODoWVN2rtCbauZ81RZJ/GXNG8V25nNYB2NqSHgW44j9grFU57Jdhav06DwY3Sk9UacbVgnJ0zTlX5ElgMhrgWDcHld0WNUEi6Ky3klIXh6MSdxmilsKP8Z35wugJZS3dCkTm59c3hTO/AO0iMpuUhXf1qarunFjVg0uat80YpyejDi+l5wGphZxWy8P3laLxiX27Pmd3vG2P+kmWrAgMBAAGjga4wgaswDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFIgnFwmpthhgi+zruvZHWcVSVKO3MB8GA1UdIwQYMBaAFCvQaUeUdgn+9GuNLkCm90dNfwheMDYGA1UdHwQvMC0wK6ApoCeGJWh0dHA6Ly93d3cuYXBwbGUuY29tL2FwcGxlY2Evcm9vdC5jcmwwEAYKKoZIhvdjZAYCAQQCBQAwDQYJKoZIhvcNAQEFBQADggEBANoyAJbFVJTTO4I3Zn0uaNXDxrjLJoxIkM8TJGpGjmPU8NATBt3YxME3FfIzEzkmLc4uVUDjCwOv+hLC5w0huNWAz6woL84ts06vhhkExulQ3UwpRxAj/Gy7G5hrSInhW53eRts1hTXvPtDiWEs49O11Wh9ccB1WORLl4Q0R5IklBr3VtBWOXtBZl5DpS4Hi3xivRHQeGaA6R8yRHTrrI1r+pS2X93u71odGQoXrUj0msmOotLHKj/TM4rPIR+C/mlmD+tqYUyqC9XxlLpXZM1317WXMMTfFWgToa+HniANKdZ6bKMtKQIhlQ3XdyzolI8WeV/guztKpkl5zLi8ldRUwggS7MIIDo6ADAgECAgECMA0GCSqGSIb3DQEBBQUAMGIxCzAJBgNVBAYTAlVTMRMwEQYDVQQKEwpBcHBsZSBJbmMuMSYwJAYDVQQLEx1BcHBsZSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEWMBQGA1UEAxMNQXBwbGUgUm9vdCBDQTAeFw0wNjA0MjUyMTQwMzZaFw0zNTAyMDkyMTQwMzZaMGIxCzAJBgNVBAYTAlVTMRMwEQYDVQQKEwpBcHBsZSBJbmMuMSYwJAYDVQQLEx1BcHBsZSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEWMBQGA1UEAxMNQXBwbGUgUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOSRqQkfkdseR1DrBe1eeYQt6zaiV0xV7IsZid75S2z1B6siMALoGD74UAnTf0GomPnRymacJGsR0KO75Bsqwx+VnnoMpEeLW9QWNzPLxA9NzhRp0ckZcvVdDtV/X5vyJQO6VY9NXQ3xZDUjFUsVWR2zlPf2nJ7PULrBWFBnjwi0IPfLrCwgb3C2PwEwjLdDzw+dPfMrSSgayP7OtbkO2V4c1ss9tTqt9A8OAJILsSEWLnTVPA3bYharo3GSR1NVwa8vQbP4++NwzeajTEV+H0xrUJZBicR0YgsQg0GHM4qBsTBY7FoEMoxos48d3mVz/2deZbxJ2HafMxRloXeUyS0CAwEAAaOCAXowggF2MA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBQr0GlHlHYJ/vRrjS5ApvdHTX8IXjAfBgNVHSMEGDAWgBQr0GlHlHYJ/vRrjS5ApvdHTX8IXjCCAREGA1UdIASCAQgwggEEMIIBAAYJKoZIhvdjZAUBMIHyMCoGCCsGAQUFBwIBFh5odHRwczovL3d3dy5hcHBsZS5jb20vYXBwbGVjYS8wgcMGCCsGAQUFBwICMIG2GoGzUmVsaWFuY2Ugb24gdGhpcyBjZXJ0aWZpY2F0ZSBieSBhbnkgcGFydHkgYXNzdW1lcyBhY2NlcHRhbmNlIG9mIHRoZSB0aGVuIGFwcGxpY2FibGUgc3RhbmRhcmQgdGVybXMgYW5kIGNvbmRpdGlvbnMgb2YgdXNlLCBjZXJ0aWZpY2F0ZSBwb2xpY3kgYW5kIGNlcnRpZmljYXRpb24gcHJhY3RpY2Ugc3RhdGVtZW50cy4wDQYJKoZIhvcNAQEFBQADggEBAFw2mUwteLftjJvc83eb8nbSdzBPwR+Fg4UbmT1HN/Kpm0COLNSxkBLYvvRzm+7SZA/LeU802KI++Xj/a8gH7H05g4tTINM4xLG/mk8Ka/8r/FmnBQl8F0BWER5007eLIztHo9VvJOLr0bdw3w9F4SfK8W147ee1Fxeo3H4iNcol1dkP1mvUoiQjEfehrI9zgWDGG1sJL5Ky+ERI8GA4nhX1PSZnIIozavcNgs/e66Mv+VNqW2TAYzN39zoHLFbr2g8hDtq6cxlPtdk2f8GHVdmnmbkyQvvY1XGefqFStxu9k0IkEirHDx22TZxeY8hLgBdQqorV2uT80AkHN7B1dSExggHLMIIBxwIBATCBozCBljELMAkGA1UEBhMCVVMxEzARBgNVBAoMCkFwcGxlIEluYy4xLDAqBgNVBAsMI0FwcGxlIFdvcmxkd2lkZSBEZXZlbG9wZXIgUmVsYXRpb25zMUQwQgYDVQQDDDtBcHBsZSBXb3JsZHdpZGUgRGV2ZWxvcGVyIFJlbGF0aW9ucyBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eQIIGFlDIXJ0nPwwCQYFKw4DAhoFADANBgkqhkiG9w0BAQEFAASCAQCsTExkCPLotDyUC58PSCh7DBlv/qyZl0JTf/mrx7PPOdO0TB2RjEG7R0TIim9xoKIq1gY0gVdP5X+cpLNRhfB64cHmA5eMXXpyZChQu664gPJ22y0bjcz2q69NF/dDVwrIw7Y6/YGi5+PGE8gQKbIEyFGknKmpz7+r9lUwzaQ8rjS0bYGFlmxTOAvW0bRa1Ok04Qt38K7rs1ondBcSwAilGdp6pVVwJIx/UGGpVsqFuN54n6NwM56TJHX8InBHMvLawMt1eH+4ghwLgpi7uNiIAyvt4IxcHU36ktc42ACswyfEMBCUVA4+bo0QlB0q25EgbQ5MV0J1XCJoYWUjP4iI' - -config = require '../../../server_config' -require '../common' - -describe '/db/payment', -> - request = require 'request' - paymentURL = getURL('/db/payment') - checkChargesURL = getURL('/db/payment/check-stripe-charges') - customPaymentURL = getURL('/db/payment/custom') - - firstApplePayment = { - apple: { - rawReceipt: testReceipt - transactionID: '1000000131274439' - localPrice: '$5.00' - } - } - - secondApplePayment = { - apple: { - rawReceipt: testReceipt - transactionID: '1000000131283608' - localPrice: '$10.00' - } - } - - paymentCreated = null - - it 'clears the db first', (done) -> - clearModels [User, Payment], (err) -> - throw err if err - done() - - describe 'posting Apple IAPs', -> - - it 'denies anonymous users trying to pay', (done) -> - request.get getURL('/auth/whoami'), -> - request.post {uri: paymentURL, json: firstApplePayment}, (err, res, body) -> - expect(res.statusCode).toBe 403 - done() - - it 'creates a payment object and credits gems to the user', (done) -> - loginJoe -> - request.post {uri: paymentURL, json: firstApplePayment}, (err, res, body) -> - paymentCreated = body?._id - expect(res.statusCode).toBe 201 - User.findOne({name:'Joe'}).exec(err, (err, user) -> - expect(user.get('purchased')?.gems).toBe(5000) - done() - ) - - it 'is idempotent', (done) -> - loginJoe -> - request.post {uri: paymentURL, json: firstApplePayment}, (err, res, body) -> - expect(body._id is paymentCreated).toBe(true) - expect(res.statusCode).toBe 200 - User.findOne({name:'Joe'}).exec(err, (err, user) -> - expect(user.get('purchased')?.gems).toBe(5000) - done() - ) - - it 'prevents other users from reusing payment receipts', (done) -> - loginSam -> - request.post {uri: paymentURL, json: firstApplePayment}, (err, res, body) -> - expect(res.statusCode).toBe 403 - done() - - it 'processes only the transactionID that is given', (done) -> - loginJoe -> - request.post {uri: paymentURL, json: secondApplePayment}, (err, res, body) -> - expect(body._id is paymentCreated).toBe(false) - expect(res.statusCode).toBe 201 - User.findOne({name:'Joe'}).exec(err, (err, user) -> - expect(user.get('purchased')?.gems).toBe(16000) - done() - ) - - describe 'posting Stripe purchases', -> - stripe = require('stripe')(config.stripe.secretKey) - - charge = null - joeID = null - timestamp = new Date().getTime() - stripeTokenID = null - joeData = null - - it 'clears the db first', (done) -> - clearModels [User, Payment], (err) -> - throw err if err - done() - - it 'handles a purchase', (done) -> - stripe.tokens.create({ - card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> - stripeTokenID = token.id - loginJoe (joe) -> - joeID = joe.get('_id')+'' - data = { - productID: 'gems_5' - stripe: { - token: token.id - timestamp: timestamp - } - } - request.post {uri: paymentURL, json: data }, (err, res, body) -> - expect(res.statusCode).toBe 201 - expect(body.stripe.chargeID).toBeDefined() - expect(body.stripe.timestamp).toBe(timestamp) - expect(body.stripe.customerID).toBeDefined() - expect(body.gems).toBe(5000) - expect(body.amount).toBe(499) - expect(body.productID).toBe('gems_5') - expect(body.service).toBe('stripe') - expect(body.recipient).toBe(joeID) - expect(body.purchaser).toBe(joeID) - User.findById(joe.get('_id'), (err, user) -> - expect(user.get('purchased').gems).toBe(5000) - expect(user.get('stripe').customerID).toBe(body.stripe.customerID) - done() - ) - ) - - it 'ignores repeated purchases', (done) -> - data = { productID: 'gems_5', stripe: { token: stripeTokenID, timestamp: timestamp } } - request.post {uri: paymentURL, json: data }, (err, res, body) -> - expect(res.statusCode).toBe 200 - Payment.count({}, (err, count) -> - expect(count).toBe(1) - User.findById(joeID, (err, user) -> - expect(user.get('purchased').gems).toBe(5000) - done() - ) - ) - - it 'allows a new charge on the existing customer', (done) -> - data = { productID: 'gems_5', stripe: { timestamp: new Date().getTime() } } - request.post {uri: paymentURL, json: data }, (err, res, body) -> - expect(res.statusCode).toBe 201 - Payment.count {}, (err, count) -> - expect(count).toBe(2) - User.findById joeID, (err, user) -> - joeData = user.toObject() - expect(user.get('purchased').gems).toBe(10000) - done() - - it "updates the customer's card when you submit a new token", (done) -> - stripe.customers.retrieve joeData.stripe.customerID, (err, customer) -> - originalCustomerID = customer.id - originalCardID = customer.sources.data[0].id - stripe.tokens.create { - card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> - data = { productID: 'gems_5', stripe: { timestamp: new Date().getTime(), token: token.id } } - request.post {uri: paymentURL, json: data }, (err, res, body) -> - expect(res.statusCode).toBe(201) - User.findById joeID, (err, user) -> - joeData = user.toObject() - expect(joeData.stripe.customerID).toBe(originalCustomerID) - stripe.customers.retrieve joeData.stripe.customerID, (err, customer) -> - expect(customer.sources.data[0].id).not.toBe(originalCardID) - done() - - it 'clears the db', (done) -> - clearModels [User, Payment], (err) -> - throw err if err - done() - - it 'recovers from breaking between charge and document creation', (done) -> - stripe.tokens.create({ - card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> - - data = { - productID: 'gems_5' - stripe: { token: token.id, timestamp: timestamp } - breakAfterCharging: true - } - - loginJoe (joe) -> - request.post {uri: paymentURL, json: data }, (err, res, body) -> - expect(res.statusCode).toBe 500 - - data = _.omit data, 'breakAfterCharging' - request.post {uri: paymentURL, json: data }, (err, res, body) -> - expect(res.statusCode).toBe 201 - - Payment.count({}, (err, count) -> - expect(count).toBe(1) - User.findById(joe.get('_id'), (err, user) -> - expect(user.get('purchased').gems).toBe(5000) - done() - ) - ) - ) - - it 'clears the db', (done) -> - clearModels [User, Payment], (err) -> - throw err if err - done() - - # Testing card numbers are here: https://stripe.com/docs/testing - - it 'handles card that attaches to customer but fails to be charged', (done) -> - stripe.tokens.create({ - card: { number: '4000000000000341', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> - loginJoe (joe) -> - timestamp = new Date().getTime() - data = { productID: 'gems_5', stripe: { token: token.id, timestamp: timestamp } } - request.post {uri: paymentURL, json: data }, (err, res, body) -> - expect(res.statusCode).toBe(402) - done() - ) - - it 'handles card that always is declined with card_declined code', (done) -> - stripe.tokens.create({ - card: { number: '4000000000000002', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> - loginJoe (joe) -> - timestamp = new Date().getTime() - data = { productID: 'gems_5', stripe: { token: token.id, timestamp: timestamp } } - request.post {uri: paymentURL, json: data }, (err, res, body) -> - expect(res.statusCode).toBe(402) - done() - ) - - it 'handles card that always is declined with incorrect_cvc code', (done) -> - stripe.tokens.create({ - card: { number: '4000000000000127', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> - loginJoe (joe) -> - timestamp = new Date().getTime() - data = { productID: 'gems_5', stripe: { token: token.id, timestamp: timestamp } } - request.post {uri: paymentURL, json: data }, (err, res, body) -> - expect(res.statusCode).toBe(402) - done() - ) - - it 'handles card that always is declined with expired_card code', (done) -> - stripe.tokens.create({ - card: { number: '4000000000000069', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> - loginJoe (joe) -> - timestamp = new Date().getTime() - data = { productID: 'gems_5', stripe: { token: token.id, timestamp: timestamp } } - request.post {uri: paymentURL, json: data }, (err, res, body) -> - expect(res.statusCode).toBe(402) - done() - ) - - it 'handles card that always is declined with processing_error code', (done) -> - stripe.tokens.create({ - card: { number: '4000000000000119', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> - loginJoe (joe) -> - timestamp = new Date().getTime() - data = { productID: 'gems_5', stripe: { token: token.id, timestamp: timestamp } } - request.post {uri: paymentURL, json: data }, (err, res, body) -> - expect(res.statusCode).toBe(402) - done() - ) - - describe '/db/payment/check-stripe-charges', -> - stripe = require('stripe')(config.stripe.secretKey) - - it 'clears the db', (done) -> - clearModels [User, Payment], (err) -> - throw err if err - done() - - it 'finds and records charges which are not in our db', (done) -> - timestamp = new Date().getTime() - stripe.tokens.create { - card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> - - data = { - productID: 'gems_5' - stripe: { token: token.id, timestamp: timestamp } - breakAfterCharging: true - } - - loginJoe (joe) -> - request.post {uri: paymentURL, json: data }, (err, res, body) -> - expect(res.statusCode).toBe 500 - - request.post { uri: checkChargesURL }, (err, res, body) -> - expect(res.statusCode).toBe 201 - Payment.count({}, (err, count) -> - expect(count).toBe(1) - User.findById(joe.get('_id'), (err, user) -> - expect(user.get('purchased').gems).toBe(5000) - done() - ) - ) - - describe '/db/payment/custom', -> - stripe = require('stripe')(config.stripe.secretKey) - - it 'clears the db', (done) -> - clearModels [User, Payment], (err) -> - throw err if err - done() - - it 'handles a custom purchase with description', (done) -> - timestamp = new Date().getTime() - amount = 5000 - description = 'A sweet Coco t-shirt' - - stripe.tokens.create({ - card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> - stripeTokenID = token.id - loginJoe (joe) -> - joeID = joe.get('_id') + '' - data = { - amount: amount - description: description - stripe: { - token: token.id - timestamp: timestamp - } - } - request.post {uri: customPaymentURL, json: data }, (err, res, body) -> - expect(res.statusCode).toBe 201 - expect(body.stripe.chargeID).toBeDefined() - expect(body.stripe.timestamp).toBe(timestamp) - expect(body.stripe.customerID).toBeDefined() - expect(body.description).toEqual(description) - expect(body.amount).toEqual(amount) - expect(body.productID).toBe('custom') - expect(body.service).toBe('stripe') - expect(body.recipient).toBe(joeID) - expect(body.purchaser).toBe(joeID) - User.findById(joe.get('_id'), (err, user) -> - expect(user.get('stripe').customerID).toBe(body.stripe.customerID) - - criteria = - recipient: user.get('_id') - purchaser: user.get('_id') - amount: amount - description: description - service: 'stripe' - "stripe.customerID": user.get('stripe').customerID - Payment.findOne criteria, (err, payment) -> - expect(err).toBeNull() - expect(payment).not.toBeNull() - done() - ) - ) - - it 'handles a custom purchase without description', (done) -> - timestamp = new Date().getTime() - amount = 73000 - - stripe.tokens.create({ - card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> - stripeTokenID = token.id - loginJoe (joe) -> - joeID = joe.get('_id') + '' - data = { - amount: amount - stripe: { - token: token.id - timestamp: timestamp - } - } - request.post {uri: customPaymentURL, json: data }, (err, res, body) -> - expect(res.statusCode).toBe 201 - expect(body.stripe.chargeID).toBeDefined() - expect(body.stripe.timestamp).toBe(timestamp) - expect(body.stripe.customerID).toBeDefined() - expect(body.amount).toEqual(amount) - expect(body.productID).toBe('custom') - expect(body.service).toBe('stripe') - expect(body.recipient).toBe(joeID) - expect(body.purchaser).toBe(joeID) - User.findById(joe.get('_id'), (err, user) -> - expect(user.get('stripe').customerID).toBe(body.stripe.customerID) - - criteria = - recipient: user.get('_id') - purchaser: user.get('_id') - amount: amount - service: 'stripe' - "stripe.customerID": user.get('stripe').customerID - Payment.findOne criteria, (err, payment) -> - expect(err).toBeNull() - expect(payment).not.toBeNull() - done() - ) - ) - - it 'handles a custom purchase with invalid amount', (done) -> - timestamp = new Date().getTime() - amount = 'free?' - - stripe.tokens.create({ - card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> - stripeTokenID = token.id - loginJoe (joe) -> - joeID = joe.get('_id') + '' - data = { - amount: amount - stripe: { - token: token.id - timestamp: timestamp - } - } - request.post {uri: customPaymentURL, json: data }, (err, res, body) -> - expect(res.statusCode).toBe(400) - done() - ) - - it 'handles a custom purchase with no amount', (done) -> - timestamp = new Date().getTime() - - stripe.tokens.create({ - card: { number: '4242424242424242', exp_month: 12, exp_year: 2020, cvc: '123' } - }, (err, token) -> - stripeTokenID = token.id - loginJoe (joe) -> - joeID = joe.get('_id') + '' - data = { - stripe: { - token: token.id - timestamp: timestamp - } - } - request.post {uri: customPaymentURL, json: data }, (err, res, body) -> - expect(res.statusCode).toBe(400) - done() - )