├── .functions └── stripe-charge.js ├── .gitignore ├── .prettierrc ├── LICENSE ├── README.md ├── functions └── stripe-charge.js ├── gatsby-browser.js ├── gatsby-config.js ├── gatsby-node.js ├── gatsby-ssr.js ├── netlify.toml ├── package-lock.json ├── package.json ├── src ├── components │ ├── Card.css │ ├── Card.js │ ├── Cell.js │ ├── Footer.js │ ├── Header.css │ ├── Section.js │ ├── Wave.js │ └── header.js ├── layouts │ ├── index.css │ └── index.js └── pages │ ├── 404.js │ ├── index.js │ └── page-2.js ├── static └── images │ ├── logo-designcode.svg │ ├── logo-figma.png │ ├── logo-framer.png │ ├── logo-invision.png │ ├── logo-react.png │ ├── logo-sketch.png │ ├── logo-studio.png │ ├── logo-swift.png │ ├── logo-xcode.png │ ├── wallpaper.jpg │ ├── wallpaper2.jpg │ ├── wallpaper3.jpg │ └── wallpaper4.jpg ├── staticdata.json └── yarn.lock /.functions/stripe-charge.js: -------------------------------------------------------------------------------- 1 | (function(e, a) { for(var i in a) e[i] = a[i]; }(exports, /******/ (function(modules) { // webpackBootstrap 2 | /******/ // The module cache 3 | /******/ var installedModules = {}; 4 | /******/ 5 | /******/ // The require function 6 | /******/ function __webpack_require__(moduleId) { 7 | /******/ 8 | /******/ // Check if module is in cache 9 | /******/ if(installedModules[moduleId]) { 10 | /******/ return installedModules[moduleId].exports; 11 | /******/ } 12 | /******/ // Create a new module (and put it into the cache) 13 | /******/ var module = installedModules[moduleId] = { 14 | /******/ i: moduleId, 15 | /******/ l: false, 16 | /******/ exports: {} 17 | /******/ }; 18 | /******/ 19 | /******/ // Execute the module function 20 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 21 | /******/ 22 | /******/ // Flag the module as loaded 23 | /******/ module.l = true; 24 | /******/ 25 | /******/ // Return the exports of the module 26 | /******/ return module.exports; 27 | /******/ } 28 | /******/ 29 | /******/ 30 | /******/ // expose the modules object (__webpack_modules__) 31 | /******/ __webpack_require__.m = modules; 32 | /******/ 33 | /******/ // expose the module cache 34 | /******/ __webpack_require__.c = installedModules; 35 | /******/ 36 | /******/ // define getter function for harmony exports 37 | /******/ __webpack_require__.d = function(exports, name, getter) { 38 | /******/ if(!__webpack_require__.o(exports, name)) { 39 | /******/ Object.defineProperty(exports, name, { 40 | /******/ configurable: false, 41 | /******/ enumerable: true, 42 | /******/ get: getter 43 | /******/ }); 44 | /******/ } 45 | /******/ }; 46 | /******/ 47 | /******/ // getDefaultExport function for compatibility with non-harmony modules 48 | /******/ __webpack_require__.n = function(module) { 49 | /******/ var getter = module && module.__esModule ? 50 | /******/ function getDefault() { return module['default']; } : 51 | /******/ function getModuleExports() { return module; }; 52 | /******/ __webpack_require__.d(getter, 'a', getter); 53 | /******/ return getter; 54 | /******/ }; 55 | /******/ 56 | /******/ // Object.prototype.hasOwnProperty.call 57 | /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 58 | /******/ 59 | /******/ // __webpack_public_path__ 60 | /******/ __webpack_require__.p = ""; 61 | /******/ 62 | /******/ // Load entry module and return exports 63 | /******/ return __webpack_require__(__webpack_require__.s = 12); 64 | /******/ }) 65 | /************************************************************************/ 66 | /******/ ([ 67 | /* 0 */ 68 | /***/ (function(module, exports, __webpack_require__) { 69 | 70 | "use strict"; 71 | 72 | 73 | var http = __webpack_require__(4); 74 | var https = __webpack_require__(16); 75 | var path = __webpack_require__(17); 76 | 77 | var utils = __webpack_require__(1); 78 | var Error = __webpack_require__(2); 79 | 80 | var hasOwn = {}.hasOwnProperty; 81 | 82 | // Provide extension mechanism for Stripe Resource Sub-Classes 83 | StripeResource.extend = utils.protoExtend; 84 | 85 | // Expose method-creator & prepared (basic) methods 86 | StripeResource.method = __webpack_require__(11); 87 | StripeResource.BASIC_METHODS = __webpack_require__(22); 88 | 89 | /** 90 | * Encapsulates request logic for a Stripe Resource 91 | */ 92 | function StripeResource(stripe, urlData) { 93 | this._stripe = stripe; 94 | this._urlData = urlData || {}; 95 | 96 | this.basePath = utils.makeURLInterpolator(stripe.getApiField('basePath')); 97 | this.resourcePath = this.path; 98 | this.path = utils.makeURLInterpolator(this.path); 99 | 100 | if (this.includeBasic) { 101 | this.includeBasic.forEach(function(methodName) { 102 | this[methodName] = StripeResource.BASIC_METHODS[methodName]; 103 | }, this); 104 | } 105 | 106 | this.initialize.apply(this, arguments); 107 | } 108 | 109 | StripeResource.prototype = { 110 | 111 | path: '', 112 | 113 | initialize: function() {}, 114 | 115 | // Function to override the default data processor. This allows full control 116 | // over how a StripeResource's request data will get converted into an HTTP 117 | // body. This is useful for non-standard HTTP requests. The function should 118 | // take method name, data, and headers as arguments. 119 | requestDataProcessor: null, 120 | 121 | // String that overrides the base API endpoint. If `overrideHost` is not null 122 | // then all requests for a particular resource will be sent to a base API 123 | // endpoint as defined by `overrideHost`. 124 | overrideHost: null, 125 | 126 | // Function to add a validation checks before sending the request, errors should 127 | // be thrown, and they will be passed to the callback/promise. 128 | validateRequest: null, 129 | 130 | createFullPath: function(commandPath, urlData) { 131 | return path.join( 132 | this.basePath(urlData), 133 | this.path(urlData), 134 | typeof commandPath == 'function' ? 135 | commandPath(urlData) : commandPath 136 | ).replace(/\\/g, '/'); // ugly workaround for Windows 137 | }, 138 | 139 | // Creates a relative resource path with symbols left in (unlike 140 | // createFullPath which takes some data to replace them with). For example it 141 | // might produce: /invoices/{id} 142 | createResourcePathWithSymbols: function(pathWithSymbols) { 143 | return '/' + path.join( 144 | this.resourcePath, 145 | pathWithSymbols || '' 146 | ).replace(/\\/g, '/'); // ugly workaround for Windows 147 | }, 148 | 149 | createUrlData: function() { 150 | var urlData = {}; 151 | // Merge in baseData 152 | for (var i in this._urlData) { 153 | if (hasOwn.call(this._urlData, i)) { 154 | urlData[i] = this._urlData[i]; 155 | } 156 | } 157 | return urlData; 158 | }, 159 | 160 | wrapTimeout: function(promise, callback) { 161 | if (callback) { 162 | // Ensure callback is called outside of promise stack. 163 | return promise.then(function(res) { 164 | setTimeout(function() { callback(null, res) }, 0); 165 | }, function(err) { 166 | setTimeout(function() { callback(err, null); }, 0); 167 | }); 168 | } 169 | 170 | return promise; 171 | }, 172 | 173 | _timeoutHandler: function(timeout, req, callback) { 174 | var self = this; 175 | return function() { 176 | var timeoutErr = new Error('ETIMEDOUT'); 177 | timeoutErr.code = 'ETIMEDOUT'; 178 | 179 | req._isAborted = true; 180 | req.abort(); 181 | 182 | callback.call( 183 | self, 184 | new Error.StripeConnectionError({ 185 | message: 'Request aborted due to timeout being reached (' + timeout + 'ms)', 186 | detail: timeoutErr, 187 | }), 188 | null 189 | ); 190 | } 191 | }, 192 | 193 | _responseHandler: function(req, callback) { 194 | var self = this; 195 | return function(res) { 196 | var response = ''; 197 | 198 | res.setEncoding('utf8'); 199 | res.on('data', function(chunk) { 200 | response += chunk; 201 | }); 202 | res.on('end', function() { 203 | var headers = res.headers || {}; 204 | // NOTE: Stripe responds with lowercase header names/keys. 205 | 206 | // For convenience, make Request-Id easily accessible on 207 | // lastResponse. 208 | res.requestId = headers['request-id']; 209 | 210 | var responseEvent = utils.removeEmpty({ 211 | api_version: headers['stripe-version'], 212 | account: headers['stripe-account'], 213 | idempotency_key: headers['idempotency-key'], 214 | method: req._requestEvent.method, 215 | path: req._requestEvent.path, 216 | status: res.statusCode, 217 | request_id: res.requestId, 218 | elapsed: Date.now() - req._requestStart, 219 | }); 220 | 221 | self._stripe._emitter.emit('response', responseEvent); 222 | 223 | try { 224 | response = JSON.parse(response); 225 | 226 | if (response.error) { 227 | var err; 228 | 229 | response.error.headers = headers; 230 | response.error.statusCode = res.statusCode; 231 | response.error.requestId = res.requestId; 232 | 233 | if (res.statusCode === 401) { 234 | err = new Error.StripeAuthenticationError(response.error); 235 | } else if (res.statusCode === 403) { 236 | err = new Error.StripePermissionError(response.error); 237 | } else if (res.statusCode === 429) { 238 | err = new Error.StripeRateLimitError(response.error); 239 | } else { 240 | err = Error.StripeError.generate(response.error); 241 | } 242 | return callback.call(self, err, null); 243 | } 244 | } catch (e) { 245 | return callback.call( 246 | self, 247 | new Error.StripeAPIError({ 248 | message: 'Invalid JSON received from the Stripe API', 249 | response: response, 250 | exception: e, 251 | requestId: headers['request-id'], 252 | }), 253 | null 254 | ); 255 | } 256 | // Expose res object 257 | Object.defineProperty(response, 'lastResponse', { 258 | enumerable: false, 259 | writable: false, 260 | value: res, 261 | }); 262 | callback.call(self, null, response); 263 | }); 264 | }; 265 | }, 266 | 267 | _errorHandler: function(req, callback) { 268 | var self = this; 269 | return function(error) { 270 | if (req._isAborted) { 271 | // already handled 272 | return; 273 | } 274 | callback.call( 275 | self, 276 | new Error.StripeConnectionError({ 277 | message: 'An error occurred with our connection to Stripe', 278 | detail: error, 279 | }), 280 | null 281 | ); 282 | } 283 | }, 284 | 285 | _defaultHeaders: function(auth, contentLength, apiVersion) { 286 | var userAgentString = 'Stripe/v1 NodeBindings/' + this._stripe.getConstant('PACKAGE_VERSION'); 287 | 288 | if (this._stripe._appInfo) { 289 | userAgentString += ' ' + this._stripe.getAppInfoAsString(); 290 | } 291 | 292 | var headers = { 293 | // Use specified auth token or use default from this stripe instance: 294 | 'Authorization': auth ? 295 | 'Bearer ' + auth : 296 | this._stripe.getApiField('auth'), 297 | 'Accept': 'application/json', 298 | 'Content-Type': 'application/x-www-form-urlencoded', 299 | 'Content-Length': contentLength, 300 | 'User-Agent': userAgentString, 301 | }; 302 | 303 | if (apiVersion) { 304 | headers['Stripe-Version'] = apiVersion; 305 | } 306 | 307 | return headers; 308 | }, 309 | 310 | _request: function(method, path, data, auth, options, callback) { 311 | var self = this; 312 | var requestData; 313 | 314 | function makeRequestWithData(error, data) { 315 | var apiVersion; 316 | var headers; 317 | 318 | if (error) { 319 | return callback(error); 320 | } 321 | 322 | apiVersion = self._stripe.getApiField('version'); 323 | requestData = data; 324 | headers = self._defaultHeaders(auth, requestData.length, apiVersion); 325 | 326 | self._stripe.getClientUserAgent(function(cua) { 327 | headers['X-Stripe-Client-User-Agent'] = cua; 328 | 329 | if (options.headers) { 330 | Object.assign(headers, options.headers); 331 | } 332 | 333 | makeRequest(apiVersion, headers); 334 | }); 335 | } 336 | 337 | if (self.requestDataProcessor) { 338 | self.requestDataProcessor(method, data, options.headers, makeRequestWithData); 339 | } else { 340 | makeRequestWithData(null, utils.stringifyRequestData(data || {})); 341 | } 342 | 343 | function makeRequest(apiVersion, headers) { 344 | var timeout = self._stripe.getApiField('timeout'); 345 | var isInsecureConnection = self._stripe.getApiField('protocol') == 'http'; 346 | 347 | var host = self.overrideHost || self._stripe.getApiField('host'); 348 | 349 | var req = ( 350 | isInsecureConnection ? http : https 351 | ).request({ 352 | host: host, 353 | port: self._stripe.getApiField('port'), 354 | path: path, 355 | method: method, 356 | agent: self._stripe.getApiField('agent'), 357 | headers: headers, 358 | ciphers: 'DEFAULT:!aNULL:!eNULL:!LOW:!EXPORT:!SSLv2:!MD5', 359 | }); 360 | 361 | var requestEvent = utils.removeEmpty({ 362 | api_version: apiVersion, 363 | account: headers['Stripe-Account'], 364 | idempotency_key: headers['Idempotency-Key'], 365 | method: method, 366 | path: path, 367 | }); 368 | 369 | req._requestEvent = requestEvent; 370 | 371 | req._requestStart = Date.now(); 372 | 373 | self._stripe._emitter.emit('request', requestEvent); 374 | 375 | req.setTimeout(timeout, self._timeoutHandler(timeout, req, callback)); 376 | req.on('response', self._responseHandler(req, callback)); 377 | req.on('error', self._errorHandler(req, callback)); 378 | 379 | req.on('socket', function(socket) { 380 | if (socket.connecting) { 381 | socket.on((isInsecureConnection ? 'connect' : 'secureConnect'), function() { 382 | // Send payload; we're safe: 383 | req.write(requestData); 384 | req.end(); 385 | }); 386 | } else { 387 | // we're already connected 388 | req.write(requestData); 389 | req.end(); 390 | } 391 | }); 392 | } 393 | }, 394 | 395 | }; 396 | 397 | module.exports = StripeResource; 398 | 399 | 400 | /***/ }), 401 | /* 1 */ 402 | /***/ (function(module, exports, __webpack_require__) { 403 | 404 | "use strict"; 405 | 406 | 407 | var Buffer = __webpack_require__(3).Buffer; 408 | var EventEmitter = __webpack_require__(5).EventEmitter; 409 | var qs = __webpack_require__(19); 410 | var crypto = __webpack_require__(9); 411 | 412 | var hasOwn = {}.hasOwnProperty; 413 | var isPlainObject = __webpack_require__(10); 414 | 415 | var OPTIONS_KEYS = ['api_key', 'idempotency_key', 'stripe_account', 'stripe_version']; 416 | 417 | var utils = module.exports = { 418 | 419 | isAuthKey: function(key) { 420 | return typeof key == 'string' && /^(?:[a-z]{2}_)?[A-z0-9]{32}$/.test(key); 421 | }, 422 | 423 | isOptionsHash: function(o) { 424 | return isPlainObject(o) && OPTIONS_KEYS.some(function(key) { 425 | return hasOwn.call(o, key); 426 | }); 427 | }, 428 | 429 | /** 430 | * Stringifies an Object, accommodating nested objects 431 | * (forming the conventional key 'parent[child]=value') 432 | */ 433 | stringifyRequestData: function(data) { 434 | return qs.stringify(data, {arrayFormat: 'brackets'}); 435 | }, 436 | 437 | /** 438 | * Outputs a new function with interpolated object property values. 439 | * Use like so: 440 | * var fn = makeURLInterpolator('some/url/{param1}/{param2}'); 441 | * fn({ param1: 123, param2: 456 }); // => 'some/url/123/456' 442 | */ 443 | makeURLInterpolator: (function() { 444 | var rc = { 445 | '\n': '\\n', '\"': '\\\"', 446 | '\u2028': '\\u2028', '\u2029': '\\u2029', 447 | }; 448 | return function makeURLInterpolator(str) { 449 | var cleanString = str.replace(/["\n\r\u2028\u2029]/g, function($0) { 450 | return rc[$0]; 451 | }); 452 | return function(outputs) { 453 | return cleanString.replace(/\{([\s\S]+?)\}/g, function($0, $1) { 454 | return encodeURIComponent(outputs[$1] || ''); 455 | }); 456 | }; 457 | }; 458 | }()), 459 | 460 | /** 461 | * Return the data argument from a list of arguments 462 | */ 463 | getDataFromArgs: function(args) { 464 | if (args.length < 1 || !isPlainObject(args[0])) { 465 | return {}; 466 | } 467 | 468 | if (!utils.isOptionsHash(args[0])) { 469 | return args.shift(); 470 | } 471 | 472 | var argKeys = Object.keys(args[0]); 473 | 474 | var optionKeysInArgs = argKeys.filter(function(key) { 475 | return OPTIONS_KEYS.indexOf(key) > -1; 476 | }); 477 | 478 | // In some cases options may be the provided as the first argument. 479 | // Here we're detecting a case where there are two distinct arguments 480 | // (the first being args and the second options) and with known 481 | // option keys in the first so that we can warn the user about it. 482 | if (optionKeysInArgs.length > 0 && optionKeysInArgs.length !== argKeys.length) { 483 | emitWarning( 484 | 'Options found in arguments (' + optionKeysInArgs.join(', ') + '). Did you mean to pass an options ' + 485 | 'object? See https://github.com/stripe/stripe-node/wiki/Passing-Options.' 486 | ); 487 | } 488 | 489 | return {}; 490 | }, 491 | 492 | /** 493 | * Return the options hash from a list of arguments 494 | */ 495 | getOptionsFromArgs: function(args) { 496 | var opts = { 497 | auth: null, 498 | headers: {}, 499 | } 500 | if (args.length > 0) { 501 | var arg = args[args.length - 1]; 502 | if (utils.isAuthKey(arg)) { 503 | opts.auth = args.pop(); 504 | } else if (utils.isOptionsHash(arg)) { 505 | var params = args.pop(); 506 | 507 | var extraKeys = Object.keys(params).filter(function(key) { 508 | return OPTIONS_KEYS.indexOf(key) == -1; 509 | }); 510 | 511 | if (extraKeys.length) { 512 | emitWarning('Invalid options found (' + extraKeys.join(', ') + '); ignoring.'); 513 | } 514 | 515 | if (params.api_key) { 516 | opts.auth = params.api_key; 517 | } 518 | if (params.idempotency_key) { 519 | opts.headers['Idempotency-Key'] = params.idempotency_key; 520 | } 521 | if (params.stripe_account) { 522 | opts.headers['Stripe-Account'] = params.stripe_account; 523 | } 524 | if (params.stripe_version) { 525 | opts.headers['Stripe-Version'] = params.stripe_version; 526 | } 527 | } 528 | } 529 | return opts; 530 | }, 531 | 532 | /** 533 | * Provide simple "Class" extension mechanism 534 | */ 535 | protoExtend: function(sub) { 536 | var Super = this; 537 | var Constructor = hasOwn.call(sub, 'constructor') ? sub.constructor : function() { 538 | Super.apply(this, arguments); 539 | }; 540 | 541 | // This initialization logic is somewhat sensitive to be compatible with 542 | // divergent JS implementations like the one found in Qt. See here for more 543 | // context: 544 | // 545 | // https://github.com/stripe/stripe-node/pull/334 546 | Object.assign(Constructor, Super); 547 | Constructor.prototype = Object.create(Super.prototype); 548 | Object.assign(Constructor.prototype, sub); 549 | 550 | return Constructor; 551 | }, 552 | 553 | /** 554 | * Encodes a particular param of data, whose value is an array, as an 555 | * object with integer string attributes. Returns the entirety of data 556 | * with just that param modified. 557 | */ 558 | encodeParamWithIntegerIndexes: function(param, data) { 559 | if (data[param] !== undefined) { 560 | data[param] = utils.arrayToObject(data[param]); 561 | } 562 | return data; 563 | }, 564 | 565 | /** 566 | * Convert an array into an object with integer string attributes 567 | */ 568 | arrayToObject: function(arr) { 569 | if (Array.isArray(arr)) { 570 | var obj = {}; 571 | arr.map(function(item, i) { 572 | obj[i.toString()] = item; 573 | }); 574 | return obj; 575 | } 576 | return arr; 577 | }, 578 | 579 | /** 580 | * Secure compare, from https://github.com/freewil/scmp 581 | */ 582 | secureCompare: function(a, b) { 583 | a = Buffer.from(a); 584 | b = Buffer.from(b); 585 | 586 | // return early here if buffer lengths are not equal since timingSafeEqual 587 | // will throw if buffer lengths are not equal 588 | if (a.length !== b.length) { 589 | return false; 590 | } 591 | 592 | // use crypto.timingSafeEqual if available (since Node.js v6.6.0), 593 | // otherwise use our own scmp-internal function. 594 | if (crypto.timingSafeEqual) { 595 | return crypto.timingSafeEqual(a, b); 596 | } 597 | 598 | var len = a.length; 599 | var result = 0; 600 | 601 | for (var i = 0; i < len; ++i) { 602 | result |= a[i] ^ b[i]; 603 | } 604 | return result === 0; 605 | }, 606 | 607 | /** 608 | * Remove empty values from an object 609 | */ 610 | removeEmpty: function(obj) { 611 | if (typeof obj !== 'object') { 612 | throw new Error('Argument must be an object'); 613 | } 614 | 615 | Object.keys(obj).forEach(function(key) { 616 | if (obj[key] === null || obj[key] === undefined) { 617 | delete obj[key]; 618 | } 619 | }); 620 | 621 | return obj; 622 | }, 623 | 624 | /** 625 | * Determine if file data is a derivative of EventEmitter class. 626 | * https://nodejs.org/api/events.html#events_events 627 | */ 628 | checkForStream: function (obj) { 629 | if (obj.file && obj.file.data) { 630 | return obj.file.data instanceof EventEmitter; 631 | } 632 | return false; 633 | }, 634 | }; 635 | 636 | function emitWarning(warning) { 637 | if (typeof process.emitWarning !== 'function') { 638 | return console.warn('Stripe: ' + warning); /* eslint-disable-line no-console */ 639 | } 640 | 641 | return process.emitWarning(warning, 'Stripe'); 642 | } 643 | 644 | 645 | /***/ }), 646 | /* 2 */ 647 | /***/ (function(module, exports, __webpack_require__) { 648 | 649 | "use strict"; 650 | 651 | 652 | var utils = __webpack_require__(1); 653 | 654 | module.exports = _Error; 655 | 656 | /** 657 | * Generic Error klass to wrap any errors returned by stripe-node 658 | */ 659 | function _Error(raw) { 660 | this.populate.apply(this, arguments); 661 | this.stack = (new Error(this.message)).stack; 662 | } 663 | 664 | // Extend Native Error 665 | _Error.prototype = Object.create(Error.prototype); 666 | 667 | _Error.prototype.type = 'GenericError'; 668 | _Error.prototype.populate = function(type, message) { 669 | this.type = type; 670 | this.message = message; 671 | }; 672 | 673 | _Error.extend = utils.protoExtend; 674 | 675 | /** 676 | * Create subclass of internal Error klass 677 | * (Specifically for errors returned from Stripe's REST API) 678 | */ 679 | var StripeError = _Error.StripeError = _Error.extend({ 680 | type: 'StripeError', 681 | populate: function(raw) { 682 | // Move from prototype def (so it appears in stringified obj) 683 | this.type = this.type; 684 | 685 | this.stack = (new Error(raw.message)).stack; 686 | this.rawType = raw.type; 687 | this.code = raw.code; 688 | this.param = raw.param; 689 | this.message = raw.message; 690 | this.detail = raw.detail; 691 | this.raw = raw; 692 | this.headers = raw.headers; 693 | this.requestId = raw.requestId; 694 | this.statusCode = raw.statusCode; 695 | }, 696 | }); 697 | 698 | /** 699 | * Helper factory which takes raw stripe errors and outputs wrapping instances 700 | */ 701 | StripeError.generate = function(rawStripeError) { 702 | switch (rawStripeError.type) { 703 | case 'card_error': 704 | return new _Error.StripeCardError(rawStripeError); 705 | case 'invalid_request_error': 706 | return new _Error.StripeInvalidRequestError(rawStripeError); 707 | case 'api_error': 708 | return new _Error.StripeAPIError(rawStripeError); 709 | case 'idempotency_error': 710 | return new _Error.StripeIdempotencyError(rawStripeError); 711 | } 712 | return new _Error('Generic', 'Unknown Error'); 713 | }; 714 | 715 | // Specific Stripe Error types: 716 | _Error.StripeCardError = StripeError.extend({type: 'StripeCardError'}); 717 | _Error.StripeInvalidRequestError = StripeError.extend({type: 'StripeInvalidRequestError'}); 718 | _Error.StripeAPIError = StripeError.extend({type: 'StripeAPIError'}); 719 | _Error.StripeAuthenticationError = StripeError.extend({type: 'StripeAuthenticationError'}); 720 | _Error.StripePermissionError = StripeError.extend({type: 'StripePermissionError'}); 721 | _Error.StripeRateLimitError = StripeError.extend({type: 'StripeRateLimitError'}); 722 | _Error.StripeConnectionError = StripeError.extend({type: 'StripeConnectionError'}); 723 | _Error.StripeSignatureVerificationError = StripeError.extend({type: 'StripeSignatureVerificationError'}); 724 | _Error.StripeIdempotencyError = StripeError.extend({type: 'StripeIdempotencyError'}); 725 | 726 | 727 | /***/ }), 728 | /* 3 */ 729 | /***/ (function(module, exports, __webpack_require__) { 730 | 731 | /* eslint-disable node/no-deprecated-api */ 732 | var buffer = __webpack_require__(18) 733 | var Buffer = buffer.Buffer 734 | 735 | // alternative to using Object.keys for old browsers 736 | function copyProps (src, dst) { 737 | for (var key in src) { 738 | dst[key] = src[key] 739 | } 740 | } 741 | if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) { 742 | module.exports = buffer 743 | } else { 744 | // Copy properties from require('buffer') 745 | copyProps(buffer, exports) 746 | exports.Buffer = SafeBuffer 747 | } 748 | 749 | function SafeBuffer (arg, encodingOrOffset, length) { 750 | return Buffer(arg, encodingOrOffset, length) 751 | } 752 | 753 | // Copy static methods from Buffer 754 | copyProps(Buffer, SafeBuffer) 755 | 756 | SafeBuffer.from = function (arg, encodingOrOffset, length) { 757 | if (typeof arg === 'number') { 758 | throw new TypeError('Argument must not be a number') 759 | } 760 | return Buffer(arg, encodingOrOffset, length) 761 | } 762 | 763 | SafeBuffer.alloc = function (size, fill, encoding) { 764 | if (typeof size !== 'number') { 765 | throw new TypeError('Argument must be a number') 766 | } 767 | var buf = Buffer(size) 768 | if (fill !== undefined) { 769 | if (typeof encoding === 'string') { 770 | buf.fill(fill, encoding) 771 | } else { 772 | buf.fill(fill) 773 | } 774 | } else { 775 | buf.fill(0) 776 | } 777 | return buf 778 | } 779 | 780 | SafeBuffer.allocUnsafe = function (size) { 781 | if (typeof size !== 'number') { 782 | throw new TypeError('Argument must be a number') 783 | } 784 | return Buffer(size) 785 | } 786 | 787 | SafeBuffer.allocUnsafeSlow = function (size) { 788 | if (typeof size !== 'number') { 789 | throw new TypeError('Argument must be a number') 790 | } 791 | return buffer.SlowBuffer(size) 792 | } 793 | 794 | 795 | /***/ }), 796 | /* 4 */ 797 | /***/ (function(module, exports) { 798 | 799 | module.exports = require("http"); 800 | 801 | /***/ }), 802 | /* 5 */ 803 | /***/ (function(module, exports) { 804 | 805 | module.exports = require("events"); 806 | 807 | /***/ }), 808 | /* 6 */ 809 | /***/ (function(module, exports, __webpack_require__) { 810 | 811 | "use strict"; 812 | 813 | 814 | var StripeResource = __webpack_require__(0); 815 | var stripeMethod = StripeResource.method; 816 | 817 | module.exports = StripeResource.extend({ 818 | // Since path can either be `account` or `accounts`, support both through stripeMethod path 819 | 820 | create: stripeMethod({ 821 | method: 'POST', 822 | path: 'accounts', 823 | }), 824 | 825 | list: stripeMethod({ 826 | method: 'GET', 827 | path: 'accounts', 828 | }), 829 | 830 | update: stripeMethod({ 831 | method: 'POST', 832 | path: 'accounts/{id}', 833 | urlParams: ['id'], 834 | }), 835 | 836 | // Avoid 'delete' keyword in JS 837 | del: stripeMethod({ 838 | method: 'DELETE', 839 | path: 'accounts/{id}', 840 | urlParams: ['id'], 841 | }), 842 | 843 | reject: stripeMethod({ 844 | method: 'POST', 845 | path: 'accounts/{id}/reject', 846 | urlParams: ['id'], 847 | }), 848 | 849 | retrieve: function(id) { 850 | // No longer allow an api key to be passed as the first string to this function due to ambiguity between 851 | // old account ids and api keys. To request the account for an api key, send null as the id 852 | if (typeof id === 'string') { 853 | return stripeMethod({ 854 | method: 'GET', 855 | path: 'accounts/{id}', 856 | urlParams: ['id'], 857 | }).apply(this, arguments); 858 | } else { 859 | if (id === null || id === undefined) { 860 | // Remove id as stripeMethod would complain of unexpected argument 861 | [].shift.apply(arguments); 862 | } 863 | return stripeMethod({ 864 | method: 'GET', 865 | path: 'account', 866 | }).apply(this, arguments); 867 | } 868 | }, 869 | 870 | /** 871 | * Accounts: External account methods 872 | */ 873 | 874 | createExternalAccount: stripeMethod({ 875 | method: 'POST', 876 | path: 'accounts/{accountId}/external_accounts', 877 | urlParams: ['accountId'], 878 | }), 879 | 880 | listExternalAccounts: stripeMethod({ 881 | method: 'GET', 882 | path: 'accounts/{accountId}/external_accounts', 883 | urlParams: ['accountId'], 884 | }), 885 | 886 | retrieveExternalAccount: stripeMethod({ 887 | method: 'GET', 888 | path: 'accounts/{accountId}/external_accounts/{externalAccountId}', 889 | urlParams: ['accountId', 'externalAccountId'], 890 | }), 891 | 892 | updateExternalAccount: stripeMethod({ 893 | method: 'POST', 894 | path: 'accounts/{accountId}/external_accounts/{externalAccountId}', 895 | urlParams: ['accountId', 'externalAccountId'], 896 | }), 897 | 898 | deleteExternalAccount: stripeMethod({ 899 | method: 'DELETE', 900 | path: 'accounts/{accountId}/external_accounts/{externalAccountId}', 901 | urlParams: ['accountId', 'externalAccountId'], 902 | }), 903 | 904 | /** 905 | * Accounts: LoginLink methods 906 | */ 907 | 908 | createLoginLink: stripeMethod({ 909 | method: 'POST', 910 | path: 'accounts/{accountId}/login_links', 911 | urlParams: ['accountId'], 912 | }), 913 | }); 914 | 915 | 916 | /***/ }), 917 | /* 7 */ 918 | /***/ (function(module, exports, __webpack_require__) { 919 | 920 | "use strict"; 921 | 922 | 923 | var has = Object.prototype.hasOwnProperty; 924 | 925 | var hexTable = (function () { 926 | var array = []; 927 | for (var i = 0; i < 256; ++i) { 928 | array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase()); 929 | } 930 | 931 | return array; 932 | }()); 933 | 934 | var compactQueue = function compactQueue(queue) { 935 | var obj; 936 | 937 | while (queue.length) { 938 | var item = queue.pop(); 939 | obj = item.obj[item.prop]; 940 | 941 | if (Array.isArray(obj)) { 942 | var compacted = []; 943 | 944 | for (var j = 0; j < obj.length; ++j) { 945 | if (typeof obj[j] !== 'undefined') { 946 | compacted.push(obj[j]); 947 | } 948 | } 949 | 950 | item.obj[item.prop] = compacted; 951 | } 952 | } 953 | 954 | return obj; 955 | }; 956 | 957 | exports.arrayToObject = function arrayToObject(source, options) { 958 | var obj = options && options.plainObjects ? Object.create(null) : {}; 959 | for (var i = 0; i < source.length; ++i) { 960 | if (typeof source[i] !== 'undefined') { 961 | obj[i] = source[i]; 962 | } 963 | } 964 | 965 | return obj; 966 | }; 967 | 968 | exports.merge = function merge(target, source, options) { 969 | if (!source) { 970 | return target; 971 | } 972 | 973 | if (typeof source !== 'object') { 974 | if (Array.isArray(target)) { 975 | target.push(source); 976 | } else if (typeof target === 'object') { 977 | if (options.plainObjects || options.allowPrototypes || !has.call(Object.prototype, source)) { 978 | target[source] = true; 979 | } 980 | } else { 981 | return [target, source]; 982 | } 983 | 984 | return target; 985 | } 986 | 987 | if (typeof target !== 'object') { 988 | return [target].concat(source); 989 | } 990 | 991 | var mergeTarget = target; 992 | if (Array.isArray(target) && !Array.isArray(source)) { 993 | mergeTarget = exports.arrayToObject(target, options); 994 | } 995 | 996 | if (Array.isArray(target) && Array.isArray(source)) { 997 | source.forEach(function (item, i) { 998 | if (has.call(target, i)) { 999 | if (target[i] && typeof target[i] === 'object') { 1000 | target[i] = exports.merge(target[i], item, options); 1001 | } else { 1002 | target.push(item); 1003 | } 1004 | } else { 1005 | target[i] = item; 1006 | } 1007 | }); 1008 | return target; 1009 | } 1010 | 1011 | return Object.keys(source).reduce(function (acc, key) { 1012 | var value = source[key]; 1013 | 1014 | if (has.call(acc, key)) { 1015 | acc[key] = exports.merge(acc[key], value, options); 1016 | } else { 1017 | acc[key] = value; 1018 | } 1019 | return acc; 1020 | }, mergeTarget); 1021 | }; 1022 | 1023 | exports.assign = function assignSingleSource(target, source) { 1024 | return Object.keys(source).reduce(function (acc, key) { 1025 | acc[key] = source[key]; 1026 | return acc; 1027 | }, target); 1028 | }; 1029 | 1030 | exports.decode = function (str) { 1031 | try { 1032 | return decodeURIComponent(str.replace(/\+/g, ' ')); 1033 | } catch (e) { 1034 | return str; 1035 | } 1036 | }; 1037 | 1038 | exports.encode = function encode(str) { 1039 | // This code was originally written by Brian White (mscdex) for the io.js core querystring library. 1040 | // It has been adapted here for stricter adherence to RFC 3986 1041 | if (str.length === 0) { 1042 | return str; 1043 | } 1044 | 1045 | var string = typeof str === 'string' ? str : String(str); 1046 | 1047 | var out = ''; 1048 | for (var i = 0; i < string.length; ++i) { 1049 | var c = string.charCodeAt(i); 1050 | 1051 | if ( 1052 | c === 0x2D // - 1053 | || c === 0x2E // . 1054 | || c === 0x5F // _ 1055 | || c === 0x7E // ~ 1056 | || (c >= 0x30 && c <= 0x39) // 0-9 1057 | || (c >= 0x41 && c <= 0x5A) // a-z 1058 | || (c >= 0x61 && c <= 0x7A) // A-Z 1059 | ) { 1060 | out += string.charAt(i); 1061 | continue; 1062 | } 1063 | 1064 | if (c < 0x80) { 1065 | out = out + hexTable[c]; 1066 | continue; 1067 | } 1068 | 1069 | if (c < 0x800) { 1070 | out = out + (hexTable[0xC0 | (c >> 6)] + hexTable[0x80 | (c & 0x3F)]); 1071 | continue; 1072 | } 1073 | 1074 | if (c < 0xD800 || c >= 0xE000) { 1075 | out = out + (hexTable[0xE0 | (c >> 12)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]); 1076 | continue; 1077 | } 1078 | 1079 | i += 1; 1080 | c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF)); 1081 | out += hexTable[0xF0 | (c >> 18)] 1082 | + hexTable[0x80 | ((c >> 12) & 0x3F)] 1083 | + hexTable[0x80 | ((c >> 6) & 0x3F)] 1084 | + hexTable[0x80 | (c & 0x3F)]; 1085 | } 1086 | 1087 | return out; 1088 | }; 1089 | 1090 | exports.compact = function compact(value) { 1091 | var queue = [{ obj: { o: value }, prop: 'o' }]; 1092 | var refs = []; 1093 | 1094 | for (var i = 0; i < queue.length; ++i) { 1095 | var item = queue[i]; 1096 | var obj = item.obj[item.prop]; 1097 | 1098 | var keys = Object.keys(obj); 1099 | for (var j = 0; j < keys.length; ++j) { 1100 | var key = keys[j]; 1101 | var val = obj[key]; 1102 | if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) { 1103 | queue.push({ obj: obj, prop: key }); 1104 | refs.push(val); 1105 | } 1106 | } 1107 | } 1108 | 1109 | return compactQueue(queue); 1110 | }; 1111 | 1112 | exports.isRegExp = function isRegExp(obj) { 1113 | return Object.prototype.toString.call(obj) === '[object RegExp]'; 1114 | }; 1115 | 1116 | exports.isBuffer = function isBuffer(obj) { 1117 | if (obj === null || typeof obj === 'undefined') { 1118 | return false; 1119 | } 1120 | 1121 | return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj)); 1122 | }; 1123 | 1124 | 1125 | /***/ }), 1126 | /* 8 */ 1127 | /***/ (function(module, exports, __webpack_require__) { 1128 | 1129 | "use strict"; 1130 | 1131 | 1132 | var replace = String.prototype.replace; 1133 | var percentTwenties = /%20/g; 1134 | 1135 | module.exports = { 1136 | 'default': 'RFC3986', 1137 | formatters: { 1138 | RFC1738: function (value) { 1139 | return replace.call(value, percentTwenties, '+'); 1140 | }, 1141 | RFC3986: function (value) { 1142 | return value; 1143 | } 1144 | }, 1145 | RFC1738: 'RFC1738', 1146 | RFC3986: 'RFC3986' 1147 | }; 1148 | 1149 | 1150 | /***/ }), 1151 | /* 9 */ 1152 | /***/ (function(module, exports) { 1153 | 1154 | module.exports = require("crypto"); 1155 | 1156 | /***/ }), 1157 | /* 10 */ 1158 | /***/ (function(module, exports) { 1159 | 1160 | /** 1161 | * lodash (Custom Build) 1162 | * Build: `lodash modularize exports="npm" -o ./` 1163 | * Copyright jQuery Foundation and other contributors 1164 | * Released under MIT license 1165 | * Based on Underscore.js 1.8.3 1166 | * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors 1167 | */ 1168 | 1169 | /** `Object#toString` result references. */ 1170 | var objectTag = '[object Object]'; 1171 | 1172 | /** 1173 | * Checks if `value` is a host object in IE < 9. 1174 | * 1175 | * @private 1176 | * @param {*} value The value to check. 1177 | * @returns {boolean} Returns `true` if `value` is a host object, else `false`. 1178 | */ 1179 | function isHostObject(value) { 1180 | // Many host objects are `Object` objects that can coerce to strings 1181 | // despite having improperly defined `toString` methods. 1182 | var result = false; 1183 | if (value != null && typeof value.toString != 'function') { 1184 | try { 1185 | result = !!(value + ''); 1186 | } catch (e) {} 1187 | } 1188 | return result; 1189 | } 1190 | 1191 | /** 1192 | * Creates a unary function that invokes `func` with its argument transformed. 1193 | * 1194 | * @private 1195 | * @param {Function} func The function to wrap. 1196 | * @param {Function} transform The argument transform. 1197 | * @returns {Function} Returns the new function. 1198 | */ 1199 | function overArg(func, transform) { 1200 | return function(arg) { 1201 | return func(transform(arg)); 1202 | }; 1203 | } 1204 | 1205 | /** Used for built-in method references. */ 1206 | var funcProto = Function.prototype, 1207 | objectProto = Object.prototype; 1208 | 1209 | /** Used to resolve the decompiled source of functions. */ 1210 | var funcToString = funcProto.toString; 1211 | 1212 | /** Used to check objects for own properties. */ 1213 | var hasOwnProperty = objectProto.hasOwnProperty; 1214 | 1215 | /** Used to infer the `Object` constructor. */ 1216 | var objectCtorString = funcToString.call(Object); 1217 | 1218 | /** 1219 | * Used to resolve the 1220 | * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) 1221 | * of values. 1222 | */ 1223 | var objectToString = objectProto.toString; 1224 | 1225 | /** Built-in value references. */ 1226 | var getPrototype = overArg(Object.getPrototypeOf, Object); 1227 | 1228 | /** 1229 | * Checks if `value` is object-like. A value is object-like if it's not `null` 1230 | * and has a `typeof` result of "object". 1231 | * 1232 | * @static 1233 | * @memberOf _ 1234 | * @since 4.0.0 1235 | * @category Lang 1236 | * @param {*} value The value to check. 1237 | * @returns {boolean} Returns `true` if `value` is object-like, else `false`. 1238 | * @example 1239 | * 1240 | * _.isObjectLike({}); 1241 | * // => true 1242 | * 1243 | * _.isObjectLike([1, 2, 3]); 1244 | * // => true 1245 | * 1246 | * _.isObjectLike(_.noop); 1247 | * // => false 1248 | * 1249 | * _.isObjectLike(null); 1250 | * // => false 1251 | */ 1252 | function isObjectLike(value) { 1253 | return !!value && typeof value == 'object'; 1254 | } 1255 | 1256 | /** 1257 | * Checks if `value` is a plain object, that is, an object created by the 1258 | * `Object` constructor or one with a `[[Prototype]]` of `null`. 1259 | * 1260 | * @static 1261 | * @memberOf _ 1262 | * @since 0.8.0 1263 | * @category Lang 1264 | * @param {*} value The value to check. 1265 | * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. 1266 | * @example 1267 | * 1268 | * function Foo() { 1269 | * this.a = 1; 1270 | * } 1271 | * 1272 | * _.isPlainObject(new Foo); 1273 | * // => false 1274 | * 1275 | * _.isPlainObject([1, 2, 3]); 1276 | * // => false 1277 | * 1278 | * _.isPlainObject({ 'x': 0, 'y': 0 }); 1279 | * // => true 1280 | * 1281 | * _.isPlainObject(Object.create(null)); 1282 | * // => true 1283 | */ 1284 | function isPlainObject(value) { 1285 | if (!isObjectLike(value) || 1286 | objectToString.call(value) != objectTag || isHostObject(value)) { 1287 | return false; 1288 | } 1289 | var proto = getPrototype(value); 1290 | if (proto === null) { 1291 | return true; 1292 | } 1293 | var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor; 1294 | return (typeof Ctor == 'function' && 1295 | Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString); 1296 | } 1297 | 1298 | module.exports = isPlainObject; 1299 | 1300 | 1301 | /***/ }), 1302 | /* 11 */ 1303 | /***/ (function(module, exports, __webpack_require__) { 1304 | 1305 | "use strict"; 1306 | 1307 | 1308 | var utils = __webpack_require__(1); 1309 | var OPTIONAL_REGEX = /^optional!/; 1310 | 1311 | /** 1312 | * Create an API method from the declared spec. 1313 | * 1314 | * @param [spec.method='GET'] Request Method (POST, GET, DELETE, PUT) 1315 | * @param [spec.path=''] Path to be appended to the API BASE_PATH, joined with 1316 | * the instance's path (e.g. 'charges' or 'customers') 1317 | * @param [spec.required=[]] Array of required arguments in the order that they 1318 | * must be passed by the consumer of the API. Subsequent optional arguments are 1319 | * optionally passed through a hash (Object) as the penultimate argument 1320 | * (preceding the also-optional callback argument 1321 | * @param [spec.encode] Function for mutating input parameters to a method. 1322 | * Usefully for applying transforms to data on a per-method basis. 1323 | */ 1324 | function stripeMethod(spec) { 1325 | var commandPath = typeof spec.path == 'function' ? spec.path 1326 | : utils.makeURLInterpolator(spec.path || ''); 1327 | var requestMethod = (spec.method || 'GET').toUpperCase(); 1328 | var urlParams = spec.urlParams || []; 1329 | var encode = spec.encode || function(data) {return data;}; 1330 | 1331 | return function() { 1332 | var self = this; 1333 | var args = [].slice.call(arguments); 1334 | 1335 | var callback = typeof args[args.length - 1] == 'function' && args.pop(); 1336 | var urlData = this.createUrlData(); 1337 | 1338 | return this.wrapTimeout(new Promise((function(resolve, reject) { 1339 | for (var i = 0, l = urlParams.length; i < l; ++i) { 1340 | var path 1341 | var err; 1342 | 1343 | // Note that we shift the args array after every iteration so this just 1344 | // grabs the "next" argument for use as a URL parameter. 1345 | var arg = args[0]; 1346 | 1347 | var param = urlParams[i]; 1348 | 1349 | var isOptional = OPTIONAL_REGEX.test(param); 1350 | param = param.replace(OPTIONAL_REGEX, ''); 1351 | 1352 | if (param == 'id' && typeof arg !== 'string') { 1353 | path = this.createResourcePathWithSymbols(spec.path); 1354 | err = new Error( 1355 | 'Stripe: "id" must be a string, but got: ' + typeof arg + 1356 | ' (on API request to `' + requestMethod + ' ' + path + '`)' 1357 | ); 1358 | reject(err); 1359 | return; 1360 | } 1361 | 1362 | if (!arg) { 1363 | if (isOptional) { 1364 | urlData[param] = ''; 1365 | continue; 1366 | } 1367 | 1368 | path = this.createResourcePathWithSymbols(spec.path); 1369 | err = new Error( 1370 | 'Stripe: Argument "' + urlParams[i] + '" required, but got: ' + arg + 1371 | ' (on API request to `' + requestMethod + ' ' + path + '`)' 1372 | ); 1373 | reject(err); 1374 | return; 1375 | } 1376 | 1377 | urlData[param] = args.shift(); 1378 | } 1379 | 1380 | var data; 1381 | try { 1382 | data = encode(utils.getDataFromArgs(args)); 1383 | } catch (e) { 1384 | reject(e); 1385 | } 1386 | var opts = utils.getOptionsFromArgs(args); 1387 | 1388 | if (args.length) { 1389 | path = this.createResourcePathWithSymbols(spec.path); 1390 | err = new Error( 1391 | 'Stripe: Unknown arguments (' + args + '). Did you mean to pass an options ' + 1392 | 'object? See https://github.com/stripe/stripe-node/wiki/Passing-Options.' + 1393 | ' (on API request to ' + requestMethod + ' `' + path + '`)' 1394 | ); 1395 | reject(err); 1396 | return; 1397 | } 1398 | 1399 | var requestPath = this.createFullPath(commandPath, urlData); 1400 | var options = {headers: Object.assign(opts.headers, spec.headers)}; 1401 | 1402 | if (spec.validator) { 1403 | try { 1404 | spec.validator(data, options); 1405 | } catch (err) { 1406 | reject(err); 1407 | return; 1408 | } 1409 | } 1410 | 1411 | function requestCallback(err, response) { 1412 | if (err) { 1413 | reject(err); 1414 | } else { 1415 | resolve( 1416 | spec.transformResponseData ? 1417 | spec.transformResponseData(response) : 1418 | response 1419 | ); 1420 | } 1421 | } 1422 | 1423 | self._request(requestMethod, requestPath, data, opts.auth, options, requestCallback); 1424 | }).bind(this)), callback); 1425 | }; 1426 | } 1427 | 1428 | module.exports = stripeMethod; 1429 | 1430 | 1431 | /***/ }), 1432 | /* 12 */ 1433 | /***/ (function(module, exports, __webpack_require__) { 1434 | 1435 | "use strict"; 1436 | 1437 | 1438 | function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } 1439 | 1440 | const stripe = __webpack_require__(13)('sk_test_4VuxA0doyoVb7Yl6RU7u43ya'); 1441 | 1442 | exports.handler = (() => { 1443 | var _ref = _asyncToGenerator(function* (event) { 1444 | const { 1445 | tokenId, 1446 | email, 1447 | name, 1448 | description, 1449 | amount 1450 | } = JSON.parse(event.body); 1451 | 1452 | const customer = yield stripe.customers.create({ 1453 | description: email, 1454 | source: tokenId 1455 | }); 1456 | 1457 | yield stripe.charges.create({ 1458 | customer: customer.id, 1459 | amount, 1460 | name, 1461 | description, 1462 | currency: 'usd' 1463 | }); 1464 | }); 1465 | 1466 | return function (_x) { 1467 | return _ref.apply(this, arguments); 1468 | }; 1469 | })(); 1470 | 1471 | /***/ }), 1472 | /* 13 */ 1473 | /***/ (function(module, exports, __webpack_require__) { 1474 | 1475 | "use strict"; 1476 | 1477 | 1478 | Stripe.DEFAULT_HOST = 'api.stripe.com'; 1479 | Stripe.DEFAULT_PORT = '443'; 1480 | Stripe.DEFAULT_BASE_PATH = '/v1/'; 1481 | Stripe.DEFAULT_API_VERSION = null; 1482 | 1483 | // Use node's default timeout: 1484 | Stripe.DEFAULT_TIMEOUT = __webpack_require__(4).createServer().timeout; 1485 | 1486 | Stripe.PACKAGE_VERSION = __webpack_require__(14).version; 1487 | 1488 | Stripe.USER_AGENT = { 1489 | bindings_version: Stripe.PACKAGE_VERSION, 1490 | lang: 'node', 1491 | lang_version: process.version, 1492 | platform: process.platform, 1493 | publisher: 'stripe', 1494 | uname: null, 1495 | }; 1496 | 1497 | Stripe.USER_AGENT_SERIALIZED = null; 1498 | 1499 | var APP_INFO_PROPERTIES = ['name', 'version', 'url']; 1500 | 1501 | var EventEmitter = __webpack_require__(5).EventEmitter; 1502 | var exec = __webpack_require__(15).exec; 1503 | 1504 | var resources = { 1505 | // Support Accounts for consistency, Account for backwards compat 1506 | Account: __webpack_require__(6), 1507 | Accounts: __webpack_require__(6), 1508 | ApplePayDomains: __webpack_require__(23), 1509 | Balance: __webpack_require__(24), 1510 | Charges: __webpack_require__(25), 1511 | CountrySpecs: __webpack_require__(26), 1512 | Coupons: __webpack_require__(27), 1513 | Customers: __webpack_require__(28), 1514 | Disputes: __webpack_require__(29), 1515 | EphemeralKeys: __webpack_require__(30), 1516 | Events: __webpack_require__(31), 1517 | ExchangeRates: __webpack_require__(32), 1518 | Invoices: __webpack_require__(33), 1519 | InvoiceItems: __webpack_require__(34), 1520 | IssuerFraudRecords: __webpack_require__(35), 1521 | LoginLinks: __webpack_require__(36), 1522 | PaymentIntents: __webpack_require__(37), 1523 | Payouts: __webpack_require__(38), 1524 | Plans: __webpack_require__(39), 1525 | RecipientCards: __webpack_require__(40), 1526 | Recipients: __webpack_require__(41), 1527 | Refunds: __webpack_require__(42), 1528 | Tokens: __webpack_require__(43), 1529 | Topups: __webpack_require__(44), 1530 | Transfers: __webpack_require__(45), 1531 | ApplicationFees: __webpack_require__(46), 1532 | FileUploads: __webpack_require__(47), 1533 | BitcoinReceivers: __webpack_require__(49), 1534 | Products: __webpack_require__(50), 1535 | Skus: __webpack_require__(51), 1536 | Orders: __webpack_require__(52), 1537 | OrderReturns: __webpack_require__(53), 1538 | Subscriptions: __webpack_require__(54), 1539 | SubscriptionItems: __webpack_require__(55), 1540 | ThreeDSecure: __webpack_require__(56), 1541 | Sources: __webpack_require__(57), 1542 | UsageRecords: __webpack_require__(58), 1543 | 1544 | // The following rely on pre-filled IDs: 1545 | CustomerCards: __webpack_require__(59), 1546 | CustomerSubscriptions: __webpack_require__(60), 1547 | ChargeRefunds: __webpack_require__(61), 1548 | ApplicationFeeRefunds: __webpack_require__(62), 1549 | TransferReversals: __webpack_require__(63), 1550 | 1551 | }; 1552 | 1553 | Stripe.StripeResource = __webpack_require__(0); 1554 | Stripe.resources = resources; 1555 | 1556 | function Stripe(key, version) { 1557 | if (!(this instanceof Stripe)) { 1558 | return new Stripe(key, version); 1559 | } 1560 | 1561 | Object.defineProperty(this, '_emitter', { 1562 | value: new EventEmitter(), 1563 | enumerable: false, 1564 | configurable: false, 1565 | writeable: false, 1566 | }); 1567 | 1568 | this.on = this._emitter.on.bind(this._emitter); 1569 | this.off = this._emitter.removeListener.bind(this._emitter); 1570 | 1571 | this._api = { 1572 | auth: null, 1573 | host: Stripe.DEFAULT_HOST, 1574 | port: Stripe.DEFAULT_PORT, 1575 | basePath: Stripe.DEFAULT_BASE_PATH, 1576 | version: Stripe.DEFAULT_API_VERSION, 1577 | timeout: Stripe.DEFAULT_TIMEOUT, 1578 | agent: null, 1579 | dev: false, 1580 | }; 1581 | 1582 | this._prepResources(); 1583 | this.setApiKey(key); 1584 | this.setApiVersion(version); 1585 | 1586 | this.errors = __webpack_require__(2); 1587 | this.webhooks = __webpack_require__(64); 1588 | } 1589 | 1590 | Stripe.prototype = { 1591 | 1592 | setHost: function(host, port, protocol) { 1593 | this._setApiField('host', host); 1594 | if (port) { 1595 | this.setPort(port); 1596 | } 1597 | if (protocol) { 1598 | this.setProtocol(protocol); 1599 | } 1600 | }, 1601 | 1602 | setProtocol: function(protocol) { 1603 | this._setApiField('protocol', protocol.toLowerCase()); 1604 | }, 1605 | 1606 | setPort: function(port) { 1607 | this._setApiField('port', port); 1608 | }, 1609 | 1610 | setApiVersion: function(version) { 1611 | if (version) { 1612 | this._setApiField('version', version); 1613 | } 1614 | }, 1615 | 1616 | setApiKey: function(key) { 1617 | if (key) { 1618 | this._setApiField( 1619 | 'auth', 1620 | 'Bearer ' + key 1621 | ); 1622 | } 1623 | }, 1624 | 1625 | setTimeout: function(timeout) { 1626 | this._setApiField( 1627 | 'timeout', 1628 | timeout == null ? Stripe.DEFAULT_TIMEOUT : timeout 1629 | ); 1630 | }, 1631 | 1632 | setAppInfo: function(info) { 1633 | if (info && typeof info !== 'object') { 1634 | throw new Error('AppInfo must be an object.'); 1635 | } 1636 | 1637 | if (info && !info.name) { 1638 | throw new Error('AppInfo.name is required'); 1639 | } 1640 | 1641 | info = info || {}; 1642 | 1643 | var appInfo = APP_INFO_PROPERTIES.reduce(function(accum, prop) { 1644 | if (typeof info[prop] == 'string') { 1645 | accum = accum || {}; 1646 | 1647 | accum[prop] = info[prop]; 1648 | } 1649 | 1650 | return accum; 1651 | }, undefined); 1652 | 1653 | // Kill the cached UA string because it may no longer be valid 1654 | Stripe.USER_AGENT_SERIALIZED = undefined; 1655 | 1656 | this._appInfo = appInfo; 1657 | }, 1658 | 1659 | setHttpAgent: function(agent) { 1660 | this._setApiField('agent', agent); 1661 | }, 1662 | 1663 | _setApiField: function(key, value) { 1664 | this._api[key] = value; 1665 | }, 1666 | 1667 | getApiField: function(key) { 1668 | return this._api[key]; 1669 | }, 1670 | 1671 | getConstant: function(c) { 1672 | return Stripe[c]; 1673 | }, 1674 | 1675 | // Gets a JSON version of a User-Agent and uses a cached version for a slight 1676 | // speed advantage. 1677 | getClientUserAgent: function(cb) { 1678 | if (Stripe.USER_AGENT_SERIALIZED) { 1679 | return cb(Stripe.USER_AGENT_SERIALIZED); 1680 | } 1681 | this.getClientUserAgentSeeded(Stripe.USER_AGENT, function(cua) { 1682 | Stripe.USER_AGENT_SERIALIZED = cua; 1683 | cb(Stripe.USER_AGENT_SERIALIZED); 1684 | }) 1685 | }, 1686 | 1687 | // Gets a JSON version of a User-Agent by encoding a seeded object and 1688 | // fetching a uname from the system. 1689 | getClientUserAgentSeeded: function(seed, cb) { 1690 | var self = this; 1691 | 1692 | exec('uname -a', function(err, uname) { 1693 | var userAgent = {}; 1694 | for (var field in seed) { 1695 | userAgent[field] = encodeURIComponent(seed[field]); 1696 | } 1697 | 1698 | // URI-encode in case there are unusual characters in the system's uname. 1699 | userAgent.uname = encodeURIComponent(uname) || 'UNKNOWN'; 1700 | 1701 | if (self._appInfo) { 1702 | userAgent.application = self._appInfo; 1703 | } 1704 | 1705 | cb(JSON.stringify(userAgent)); 1706 | }); 1707 | }, 1708 | 1709 | getAppInfoAsString: function() { 1710 | if (!this._appInfo) { 1711 | return ''; 1712 | } 1713 | 1714 | var formatted = this._appInfo.name; 1715 | 1716 | if (this._appInfo.version) { 1717 | formatted += '/' + this._appInfo.version; 1718 | } 1719 | 1720 | if (this._appInfo.url) { 1721 | formatted += ' (' + this._appInfo.url + ')'; 1722 | } 1723 | 1724 | return formatted; 1725 | }, 1726 | 1727 | _prepResources: function() { 1728 | for (var name in resources) { 1729 | this[ 1730 | name[0].toLowerCase() + name.substring(1) 1731 | ] = new resources[name](this); 1732 | } 1733 | }, 1734 | 1735 | }; 1736 | 1737 | module.exports = Stripe; 1738 | // expose constructor as a named property to enable mocking with Sinon.JS 1739 | module.exports.Stripe = Stripe; 1740 | 1741 | 1742 | /***/ }), 1743 | /* 14 */ 1744 | /***/ (function(module, exports) { 1745 | 1746 | module.exports = {"_from":"stripe@^6.3.0","_id":"stripe@6.3.0","_inBundle":false,"_integrity":"sha512-f2GtsoqGLdAZe1mrtFBthpbvM9uHr6IEusyqZymJgj/Nx0xvHkzRkO/h2sePbk/4lhCjfprr4+hbhui7RMPCsw==","_location":"/stripe","_phantomChildren":{},"_requested":{"type":"range","registry":true,"raw":"stripe@^6.3.0","name":"stripe","escapedName":"stripe","rawSpec":"^6.3.0","saveSpec":null,"fetchSpec":"^6.3.0"},"_requiredBy":["#USER","/"],"_resolved":"https://registry.npmjs.org/stripe/-/stripe-6.3.0.tgz","_shasum":"d11a2e7112af97b4a6701cb1379fb9df021fbab1","_spec":"stripe@^6.3.0","_where":"/Users/mengto/Desktop/my-app","author":{"name":"Stripe","email":"support@stripe.com","url":"https://stripe.com/"},"bugs":{"url":"https://github.com/stripe/stripe-node/issues"},"bugs:":"https://github.com/stripe/stripe-node/issues","bundleDependencies":false,"contributors":[{"name":"Ask Bjørn Hansen","email":"ask@develooper.com","url":"http://www.askask.com/"},{"name":"Michelle Bu","email":"michelle@stripe.com"},{"name":"Alex Sexton","email":"alex@stripe.com"},{"name":"James Padolsey"}],"dependencies":{"lodash.isplainobject":"^4.0.6","qs":"~6.5.1","safe-buffer":"^5.1.1"},"deprecated":false,"description":"Stripe API wrapper","devDependencies":{"chai":"~4.1.2","chai-as-promised":"~7.1.1","coveralls":"^3.0.0","eslint":"^4.19.1","eslint-plugin-chai-friendly":"^0.4.0","mocha":"~5.0.5","nyc":"^11.3.0"},"engines":{"node":">=4"},"homepage":"https://github.com/stripe/stripe-node","keywords":["stripe","payment processing","credit cards","api"],"license":"MIT","main":"lib/stripe.js","name":"stripe","repository":{"type":"git","url":"git://github.com/stripe/stripe-node.git"},"scripts":{"clean":"rm -rf ./.nyc_output ./node_modules/.cache ./coverage","coveralls":"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js","lint":"eslint .","mocha":"nyc mocha","report":"nyc -r text -r lcov report","test":"npm run lint && npm run mocha"},"version":"6.3.0"} 1747 | 1748 | /***/ }), 1749 | /* 15 */ 1750 | /***/ (function(module, exports) { 1751 | 1752 | module.exports = require("child_process"); 1753 | 1754 | /***/ }), 1755 | /* 16 */ 1756 | /***/ (function(module, exports) { 1757 | 1758 | module.exports = require("https"); 1759 | 1760 | /***/ }), 1761 | /* 17 */ 1762 | /***/ (function(module, exports) { 1763 | 1764 | module.exports = require("path"); 1765 | 1766 | /***/ }), 1767 | /* 18 */ 1768 | /***/ (function(module, exports) { 1769 | 1770 | module.exports = require("buffer"); 1771 | 1772 | /***/ }), 1773 | /* 19 */ 1774 | /***/ (function(module, exports, __webpack_require__) { 1775 | 1776 | "use strict"; 1777 | 1778 | 1779 | var stringify = __webpack_require__(20); 1780 | var parse = __webpack_require__(21); 1781 | var formats = __webpack_require__(8); 1782 | 1783 | module.exports = { 1784 | formats: formats, 1785 | parse: parse, 1786 | stringify: stringify 1787 | }; 1788 | 1789 | 1790 | /***/ }), 1791 | /* 20 */ 1792 | /***/ (function(module, exports, __webpack_require__) { 1793 | 1794 | "use strict"; 1795 | 1796 | 1797 | var utils = __webpack_require__(7); 1798 | var formats = __webpack_require__(8); 1799 | 1800 | var arrayPrefixGenerators = { 1801 | brackets: function brackets(prefix) { // eslint-disable-line func-name-matching 1802 | return prefix + '[]'; 1803 | }, 1804 | indices: function indices(prefix, key) { // eslint-disable-line func-name-matching 1805 | return prefix + '[' + key + ']'; 1806 | }, 1807 | repeat: function repeat(prefix) { // eslint-disable-line func-name-matching 1808 | return prefix; 1809 | } 1810 | }; 1811 | 1812 | var toISO = Date.prototype.toISOString; 1813 | 1814 | var defaults = { 1815 | delimiter: '&', 1816 | encode: true, 1817 | encoder: utils.encode, 1818 | encodeValuesOnly: false, 1819 | serializeDate: function serializeDate(date) { // eslint-disable-line func-name-matching 1820 | return toISO.call(date); 1821 | }, 1822 | skipNulls: false, 1823 | strictNullHandling: false 1824 | }; 1825 | 1826 | var stringify = function stringify( // eslint-disable-line func-name-matching 1827 | object, 1828 | prefix, 1829 | generateArrayPrefix, 1830 | strictNullHandling, 1831 | skipNulls, 1832 | encoder, 1833 | filter, 1834 | sort, 1835 | allowDots, 1836 | serializeDate, 1837 | formatter, 1838 | encodeValuesOnly 1839 | ) { 1840 | var obj = object; 1841 | if (typeof filter === 'function') { 1842 | obj = filter(prefix, obj); 1843 | } else if (obj instanceof Date) { 1844 | obj = serializeDate(obj); 1845 | } else if (obj === null) { 1846 | if (strictNullHandling) { 1847 | return encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder) : prefix; 1848 | } 1849 | 1850 | obj = ''; 1851 | } 1852 | 1853 | if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean' || utils.isBuffer(obj)) { 1854 | if (encoder) { 1855 | var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults.encoder); 1856 | return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults.encoder))]; 1857 | } 1858 | return [formatter(prefix) + '=' + formatter(String(obj))]; 1859 | } 1860 | 1861 | var values = []; 1862 | 1863 | if (typeof obj === 'undefined') { 1864 | return values; 1865 | } 1866 | 1867 | var objKeys; 1868 | if (Array.isArray(filter)) { 1869 | objKeys = filter; 1870 | } else { 1871 | var keys = Object.keys(obj); 1872 | objKeys = sort ? keys.sort(sort) : keys; 1873 | } 1874 | 1875 | for (var i = 0; i < objKeys.length; ++i) { 1876 | var key = objKeys[i]; 1877 | 1878 | if (skipNulls && obj[key] === null) { 1879 | continue; 1880 | } 1881 | 1882 | if (Array.isArray(obj)) { 1883 | values = values.concat(stringify( 1884 | obj[key], 1885 | generateArrayPrefix(prefix, key), 1886 | generateArrayPrefix, 1887 | strictNullHandling, 1888 | skipNulls, 1889 | encoder, 1890 | filter, 1891 | sort, 1892 | allowDots, 1893 | serializeDate, 1894 | formatter, 1895 | encodeValuesOnly 1896 | )); 1897 | } else { 1898 | values = values.concat(stringify( 1899 | obj[key], 1900 | prefix + (allowDots ? '.' + key : '[' + key + ']'), 1901 | generateArrayPrefix, 1902 | strictNullHandling, 1903 | skipNulls, 1904 | encoder, 1905 | filter, 1906 | sort, 1907 | allowDots, 1908 | serializeDate, 1909 | formatter, 1910 | encodeValuesOnly 1911 | )); 1912 | } 1913 | } 1914 | 1915 | return values; 1916 | }; 1917 | 1918 | module.exports = function (object, opts) { 1919 | var obj = object; 1920 | var options = opts ? utils.assign({}, opts) : {}; 1921 | 1922 | if (options.encoder !== null && options.encoder !== undefined && typeof options.encoder !== 'function') { 1923 | throw new TypeError('Encoder has to be a function.'); 1924 | } 1925 | 1926 | var delimiter = typeof options.delimiter === 'undefined' ? defaults.delimiter : options.delimiter; 1927 | var strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling; 1928 | var skipNulls = typeof options.skipNulls === 'boolean' ? options.skipNulls : defaults.skipNulls; 1929 | var encode = typeof options.encode === 'boolean' ? options.encode : defaults.encode; 1930 | var encoder = typeof options.encoder === 'function' ? options.encoder : defaults.encoder; 1931 | var sort = typeof options.sort === 'function' ? options.sort : null; 1932 | var allowDots = typeof options.allowDots === 'undefined' ? false : options.allowDots; 1933 | var serializeDate = typeof options.serializeDate === 'function' ? options.serializeDate : defaults.serializeDate; 1934 | var encodeValuesOnly = typeof options.encodeValuesOnly === 'boolean' ? options.encodeValuesOnly : defaults.encodeValuesOnly; 1935 | if (typeof options.format === 'undefined') { 1936 | options.format = formats['default']; 1937 | } else if (!Object.prototype.hasOwnProperty.call(formats.formatters, options.format)) { 1938 | throw new TypeError('Unknown format option provided.'); 1939 | } 1940 | var formatter = formats.formatters[options.format]; 1941 | var objKeys; 1942 | var filter; 1943 | 1944 | if (typeof options.filter === 'function') { 1945 | filter = options.filter; 1946 | obj = filter('', obj); 1947 | } else if (Array.isArray(options.filter)) { 1948 | filter = options.filter; 1949 | objKeys = filter; 1950 | } 1951 | 1952 | var keys = []; 1953 | 1954 | if (typeof obj !== 'object' || obj === null) { 1955 | return ''; 1956 | } 1957 | 1958 | var arrayFormat; 1959 | if (options.arrayFormat in arrayPrefixGenerators) { 1960 | arrayFormat = options.arrayFormat; 1961 | } else if ('indices' in options) { 1962 | arrayFormat = options.indices ? 'indices' : 'repeat'; 1963 | } else { 1964 | arrayFormat = 'indices'; 1965 | } 1966 | 1967 | var generateArrayPrefix = arrayPrefixGenerators[arrayFormat]; 1968 | 1969 | if (!objKeys) { 1970 | objKeys = Object.keys(obj); 1971 | } 1972 | 1973 | if (sort) { 1974 | objKeys.sort(sort); 1975 | } 1976 | 1977 | for (var i = 0; i < objKeys.length; ++i) { 1978 | var key = objKeys[i]; 1979 | 1980 | if (skipNulls && obj[key] === null) { 1981 | continue; 1982 | } 1983 | 1984 | keys = keys.concat(stringify( 1985 | obj[key], 1986 | key, 1987 | generateArrayPrefix, 1988 | strictNullHandling, 1989 | skipNulls, 1990 | encode ? encoder : null, 1991 | filter, 1992 | sort, 1993 | allowDots, 1994 | serializeDate, 1995 | formatter, 1996 | encodeValuesOnly 1997 | )); 1998 | } 1999 | 2000 | var joined = keys.join(delimiter); 2001 | var prefix = options.addQueryPrefix === true ? '?' : ''; 2002 | 2003 | return joined.length > 0 ? prefix + joined : ''; 2004 | }; 2005 | 2006 | 2007 | /***/ }), 2008 | /* 21 */ 2009 | /***/ (function(module, exports, __webpack_require__) { 2010 | 2011 | "use strict"; 2012 | 2013 | 2014 | var utils = __webpack_require__(7); 2015 | 2016 | var has = Object.prototype.hasOwnProperty; 2017 | 2018 | var defaults = { 2019 | allowDots: false, 2020 | allowPrototypes: false, 2021 | arrayLimit: 20, 2022 | decoder: utils.decode, 2023 | delimiter: '&', 2024 | depth: 5, 2025 | parameterLimit: 1000, 2026 | plainObjects: false, 2027 | strictNullHandling: false 2028 | }; 2029 | 2030 | var parseValues = function parseQueryStringValues(str, options) { 2031 | var obj = {}; 2032 | var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str; 2033 | var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit; 2034 | var parts = cleanStr.split(options.delimiter, limit); 2035 | 2036 | for (var i = 0; i < parts.length; ++i) { 2037 | var part = parts[i]; 2038 | 2039 | var bracketEqualsPos = part.indexOf(']='); 2040 | var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1; 2041 | 2042 | var key, val; 2043 | if (pos === -1) { 2044 | key = options.decoder(part, defaults.decoder); 2045 | val = options.strictNullHandling ? null : ''; 2046 | } else { 2047 | key = options.decoder(part.slice(0, pos), defaults.decoder); 2048 | val = options.decoder(part.slice(pos + 1), defaults.decoder); 2049 | } 2050 | if (has.call(obj, key)) { 2051 | obj[key] = [].concat(obj[key]).concat(val); 2052 | } else { 2053 | obj[key] = val; 2054 | } 2055 | } 2056 | 2057 | return obj; 2058 | }; 2059 | 2060 | var parseObject = function (chain, val, options) { 2061 | var leaf = val; 2062 | 2063 | for (var i = chain.length - 1; i >= 0; --i) { 2064 | var obj; 2065 | var root = chain[i]; 2066 | 2067 | if (root === '[]') { 2068 | obj = []; 2069 | obj = obj.concat(leaf); 2070 | } else { 2071 | obj = options.plainObjects ? Object.create(null) : {}; 2072 | var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root; 2073 | var index = parseInt(cleanRoot, 10); 2074 | if ( 2075 | !isNaN(index) 2076 | && root !== cleanRoot 2077 | && String(index) === cleanRoot 2078 | && index >= 0 2079 | && (options.parseArrays && index <= options.arrayLimit) 2080 | ) { 2081 | obj = []; 2082 | obj[index] = leaf; 2083 | } else { 2084 | obj[cleanRoot] = leaf; 2085 | } 2086 | } 2087 | 2088 | leaf = obj; 2089 | } 2090 | 2091 | return leaf; 2092 | }; 2093 | 2094 | var parseKeys = function parseQueryStringKeys(givenKey, val, options) { 2095 | if (!givenKey) { 2096 | return; 2097 | } 2098 | 2099 | // Transform dot notation to bracket notation 2100 | var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, '[$1]') : givenKey; 2101 | 2102 | // The regex chunks 2103 | 2104 | var brackets = /(\[[^[\]]*])/; 2105 | var child = /(\[[^[\]]*])/g; 2106 | 2107 | // Get the parent 2108 | 2109 | var segment = brackets.exec(key); 2110 | var parent = segment ? key.slice(0, segment.index) : key; 2111 | 2112 | // Stash the parent if it exists 2113 | 2114 | var keys = []; 2115 | if (parent) { 2116 | // If we aren't using plain objects, optionally prefix keys 2117 | // that would overwrite object prototype properties 2118 | if (!options.plainObjects && has.call(Object.prototype, parent)) { 2119 | if (!options.allowPrototypes) { 2120 | return; 2121 | } 2122 | } 2123 | 2124 | keys.push(parent); 2125 | } 2126 | 2127 | // Loop through children appending to the array until we hit depth 2128 | 2129 | var i = 0; 2130 | while ((segment = child.exec(key)) !== null && i < options.depth) { 2131 | i += 1; 2132 | if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) { 2133 | if (!options.allowPrototypes) { 2134 | return; 2135 | } 2136 | } 2137 | keys.push(segment[1]); 2138 | } 2139 | 2140 | // If there's a remainder, just add whatever is left 2141 | 2142 | if (segment) { 2143 | keys.push('[' + key.slice(segment.index) + ']'); 2144 | } 2145 | 2146 | return parseObject(keys, val, options); 2147 | }; 2148 | 2149 | module.exports = function (str, opts) { 2150 | var options = opts ? utils.assign({}, opts) : {}; 2151 | 2152 | if (options.decoder !== null && options.decoder !== undefined && typeof options.decoder !== 'function') { 2153 | throw new TypeError('Decoder has to be a function.'); 2154 | } 2155 | 2156 | options.ignoreQueryPrefix = options.ignoreQueryPrefix === true; 2157 | options.delimiter = typeof options.delimiter === 'string' || utils.isRegExp(options.delimiter) ? options.delimiter : defaults.delimiter; 2158 | options.depth = typeof options.depth === 'number' ? options.depth : defaults.depth; 2159 | options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : defaults.arrayLimit; 2160 | options.parseArrays = options.parseArrays !== false; 2161 | options.decoder = typeof options.decoder === 'function' ? options.decoder : defaults.decoder; 2162 | options.allowDots = typeof options.allowDots === 'boolean' ? options.allowDots : defaults.allowDots; 2163 | options.plainObjects = typeof options.plainObjects === 'boolean' ? options.plainObjects : defaults.plainObjects; 2164 | options.allowPrototypes = typeof options.allowPrototypes === 'boolean' ? options.allowPrototypes : defaults.allowPrototypes; 2165 | options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : defaults.parameterLimit; 2166 | options.strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling; 2167 | 2168 | if (str === '' || str === null || typeof str === 'undefined') { 2169 | return options.plainObjects ? Object.create(null) : {}; 2170 | } 2171 | 2172 | var tempObj = typeof str === 'string' ? parseValues(str, options) : str; 2173 | var obj = options.plainObjects ? Object.create(null) : {}; 2174 | 2175 | // Iterate over the keys and setup the new object 2176 | 2177 | var keys = Object.keys(tempObj); 2178 | for (var i = 0; i < keys.length; ++i) { 2179 | var key = keys[i]; 2180 | var newObj = parseKeys(key, tempObj[key], options); 2181 | obj = utils.merge(obj, newObj, options); 2182 | } 2183 | 2184 | return utils.compact(obj); 2185 | }; 2186 | 2187 | 2188 | /***/ }), 2189 | /* 22 */ 2190 | /***/ (function(module, exports, __webpack_require__) { 2191 | 2192 | "use strict"; 2193 | 2194 | 2195 | var isPlainObject = __webpack_require__(10); 2196 | var stripeMethod = __webpack_require__(11); 2197 | 2198 | module.exports = { 2199 | 2200 | create: stripeMethod({ 2201 | method: 'POST', 2202 | }), 2203 | 2204 | list: stripeMethod({ 2205 | method: 'GET', 2206 | }), 2207 | 2208 | retrieve: stripeMethod({ 2209 | method: 'GET', 2210 | path: '/{id}', 2211 | urlParams: ['id'], 2212 | }), 2213 | 2214 | update: stripeMethod({ 2215 | method: 'POST', 2216 | path: '{id}', 2217 | urlParams: ['id'], 2218 | }), 2219 | 2220 | // Avoid 'delete' keyword in JS 2221 | del: stripeMethod({ 2222 | method: 'DELETE', 2223 | path: '{id}', 2224 | urlParams: ['id'], 2225 | }), 2226 | 2227 | setMetadata: function(id, key, value, auth, cb) { 2228 | var self = this; 2229 | var data = key; 2230 | var isObject = isPlainObject(key); 2231 | // We assume null for an empty object 2232 | var isNull = data === null || (isObject && !Object.keys(data).length); 2233 | 2234 | // Allow optional passing of auth & cb: 2235 | if ((isNull || isObject) && typeof value == 'string') { 2236 | auth = value; 2237 | } else if (typeof auth != 'string') { 2238 | if (!cb && typeof auth == 'function') { 2239 | cb = auth; 2240 | } 2241 | auth = null; 2242 | } 2243 | 2244 | var urlData = this.createUrlData(); 2245 | var path = this.createFullPath('/' + id, urlData); 2246 | 2247 | return this.wrapTimeout(new Promise((function(resolve, reject) { 2248 | if (isNull) { 2249 | // Reset metadata: 2250 | sendMetadata(null, auth); 2251 | } else if (!isObject) { 2252 | // Set individual metadata property: 2253 | var metadata = {}; 2254 | metadata[key] = value; 2255 | sendMetadata(metadata, auth); 2256 | } else { 2257 | // Set entire metadata object after resetting it: 2258 | this._request('POST', path, { 2259 | metadata: null, 2260 | }, auth, {}, function(err, response) { 2261 | if (err) { 2262 | return reject(err); 2263 | } 2264 | sendMetadata(data, auth); 2265 | }); 2266 | } 2267 | 2268 | function sendMetadata(metadata, auth) { 2269 | self._request('POST', path, { 2270 | metadata: metadata, 2271 | }, auth, {}, function(err, response) { 2272 | if (err) { 2273 | reject(err); 2274 | } else { 2275 | resolve(response.metadata); 2276 | } 2277 | }); 2278 | } 2279 | }).bind(this)), cb); 2280 | }, 2281 | 2282 | getMetadata: function(id, auth, cb) { 2283 | if (!cb && typeof auth == 'function') { 2284 | cb = auth; 2285 | auth = null; 2286 | } 2287 | 2288 | var urlData = this.createUrlData(); 2289 | var path = this.createFullPath('/' + id, urlData); 2290 | 2291 | return this.wrapTimeout(new Promise((function(resolve, reject) { 2292 | this._request('GET', path, {}, auth, {}, function(err, response) { 2293 | if (err) { 2294 | reject(err); 2295 | } else { 2296 | resolve(response.metadata); 2297 | } 2298 | }); 2299 | }).bind(this)), cb); 2300 | }, 2301 | 2302 | }; 2303 | 2304 | 2305 | /***/ }), 2306 | /* 23 */ 2307 | /***/ (function(module, exports, __webpack_require__) { 2308 | 2309 | "use strict"; 2310 | 2311 | 2312 | module.exports = __webpack_require__(0).extend({ 2313 | path: 'apple_pay/domains', 2314 | includeBasic: ['create', 'list', 'retrieve', 'del'], 2315 | }); 2316 | 2317 | 2318 | /***/ }), 2319 | /* 24 */ 2320 | /***/ (function(module, exports, __webpack_require__) { 2321 | 2322 | "use strict"; 2323 | 2324 | 2325 | var StripeResource = __webpack_require__(0); 2326 | var stripeMethod = StripeResource.method; 2327 | 2328 | module.exports = StripeResource.extend({ 2329 | 2330 | path: 'balance', 2331 | 2332 | retrieve: stripeMethod({ 2333 | method: 'GET', 2334 | }), 2335 | 2336 | listTransactions: stripeMethod({ 2337 | method: 'GET', 2338 | path: 'history', 2339 | }), 2340 | 2341 | retrieveTransaction: stripeMethod({ 2342 | method: 'GET', 2343 | path: 'history/{transactionId}', 2344 | urlParams: ['transactionId'], 2345 | }), 2346 | 2347 | }); 2348 | 2349 | 2350 | /***/ }), 2351 | /* 25 */ 2352 | /***/ (function(module, exports, __webpack_require__) { 2353 | 2354 | "use strict"; 2355 | 2356 | 2357 | var StripeResource = __webpack_require__(0); 2358 | var stripeMethod = StripeResource.method; 2359 | 2360 | module.exports = StripeResource.extend({ 2361 | 2362 | path: 'charges', 2363 | 2364 | includeBasic: [ 2365 | 'create', 'list', 'retrieve', 'update', 2366 | 'setMetadata', 'getMetadata', 2367 | ], 2368 | 2369 | capture: stripeMethod({ 2370 | method: 'POST', 2371 | path: '/{id}/capture', 2372 | urlParams: ['id'], 2373 | }), 2374 | 2375 | refund: stripeMethod({ 2376 | method: 'POST', 2377 | path: '/{id}/refund', 2378 | urlParams: ['id'], 2379 | }), 2380 | 2381 | updateDispute: stripeMethod({ 2382 | method: 'POST', 2383 | path: '/{id}/dispute', 2384 | urlParams: ['id'], 2385 | }), 2386 | 2387 | closeDispute: stripeMethod({ 2388 | method: 'POST', 2389 | path: '/{id}/dispute/close', 2390 | urlParams: ['id'], 2391 | }), 2392 | 2393 | /** 2394 | * Charge: Refund methods 2395 | * (Deprecated) 2396 | */ 2397 | createRefund: stripeMethod({ 2398 | method: 'POST', 2399 | path: '/{chargeId}/refunds', 2400 | urlParams: ['chargeId'], 2401 | }), 2402 | 2403 | listRefunds: stripeMethod({ 2404 | method: 'GET', 2405 | path: '/{chargeId}/refunds', 2406 | urlParams: ['chargeId'], 2407 | }), 2408 | 2409 | retrieveRefund: stripeMethod({ 2410 | method: 'GET', 2411 | path: '/{chargeId}/refunds/{refundId}', 2412 | urlParams: ['chargeId', 'refundId'], 2413 | }), 2414 | 2415 | updateRefund: stripeMethod({ 2416 | method: 'POST', 2417 | path: '/{chargeId}/refunds/{refundId}', 2418 | urlParams: ['chargeId', 'refundId'], 2419 | }), 2420 | 2421 | markAsSafe: function(chargeId) { 2422 | return this.update(chargeId, {'fraud_details': {'user_report': 'safe'}}) 2423 | }, 2424 | 2425 | markAsFraudulent: function(chargeId) { 2426 | return this.update(chargeId, {'fraud_details': {'user_report': 'fraudulent'}}) 2427 | }, 2428 | }); 2429 | 2430 | 2431 | /***/ }), 2432 | /* 26 */ 2433 | /***/ (function(module, exports, __webpack_require__) { 2434 | 2435 | "use strict"; 2436 | 2437 | 2438 | var StripeResource = __webpack_require__(0); 2439 | 2440 | module.exports = StripeResource.extend({ 2441 | 2442 | path: 'country_specs', 2443 | 2444 | includeBasic: [ 2445 | 'list', 'retrieve', 2446 | ], 2447 | }); 2448 | 2449 | 2450 | /***/ }), 2451 | /* 27 */ 2452 | /***/ (function(module, exports, __webpack_require__) { 2453 | 2454 | "use strict"; 2455 | 2456 | 2457 | module.exports = __webpack_require__(0).extend({ 2458 | path: 'coupons', 2459 | includeBasic: ['create', 'list', 'update', 'retrieve', 'del'], 2460 | }); 2461 | 2462 | 2463 | 2464 | /***/ }), 2465 | /* 28 */ 2466 | /***/ (function(module, exports, __webpack_require__) { 2467 | 2468 | "use strict"; 2469 | 2470 | 2471 | var StripeResource = __webpack_require__(0); 2472 | var utils = __webpack_require__(1); 2473 | var stripeMethod = StripeResource.method; 2474 | 2475 | module.exports = StripeResource.extend({ 2476 | 2477 | path: 'customers', 2478 | includeBasic: [ 2479 | 'create', 'list', 'retrieve', 'update', 'del', 2480 | 'setMetadata', 'getMetadata', 2481 | ], 2482 | 2483 | /** 2484 | * Customer: Subscription methods 2485 | */ 2486 | 2487 | _legacyUpdateSubscription: stripeMethod({ 2488 | method: 'POST', 2489 | path: '{customerId}/subscription', 2490 | urlParams: ['customerId'], 2491 | }), 2492 | 2493 | _newstyleUpdateSubscription: stripeMethod({ 2494 | method: 'POST', 2495 | path: '/{customerId}/subscriptions/{subscriptionId}', 2496 | urlParams: ['customerId', 'subscriptionId'], 2497 | }), 2498 | 2499 | _legacyCancelSubscription: stripeMethod({ 2500 | method: 'DELETE', 2501 | path: '{customerId}/subscription', 2502 | urlParams: ['customerId'], 2503 | }), 2504 | 2505 | _newstyleCancelSubscription: stripeMethod({ 2506 | method: 'DELETE', 2507 | path: '/{customerId}/subscriptions/{subscriptionId}', 2508 | urlParams: ['customerId', 'subscriptionId'], 2509 | }), 2510 | 2511 | createSubscription: stripeMethod({ 2512 | method: 'POST', 2513 | path: '/{customerId}/subscriptions', 2514 | urlParams: ['customerId'], 2515 | }), 2516 | 2517 | listSubscriptions: stripeMethod({ 2518 | method: 'GET', 2519 | path: '/{customerId}/subscriptions', 2520 | urlParams: ['customerId'], 2521 | }), 2522 | 2523 | retrieveSubscription: stripeMethod({ 2524 | method: 'GET', 2525 | path: '/{customerId}/subscriptions/{subscriptionId}', 2526 | urlParams: ['customerId', 'subscriptionId'], 2527 | }), 2528 | 2529 | updateSubscription: function(customerId, subscriptionId) { 2530 | if (typeof subscriptionId == 'string') { 2531 | return this._newstyleUpdateSubscription.apply(this, arguments); 2532 | } else { 2533 | return this._legacyUpdateSubscription.apply(this, arguments); 2534 | } 2535 | }, 2536 | 2537 | cancelSubscription: function(customerId, subscriptionId) { 2538 | // This is a hack, but it lets us maximize our overloading. 2539 | // Precarious assumption: If it's not an auth key it _could_ be a sub id: 2540 | if (typeof subscriptionId == 'string' && !utils.isAuthKey(subscriptionId)) { 2541 | return this._newstyleCancelSubscription.apply(this, arguments); 2542 | } else { 2543 | return this._legacyCancelSubscription.apply(this, arguments); 2544 | } 2545 | }, 2546 | 2547 | /** 2548 | * Customer: Card methods 2549 | */ 2550 | 2551 | createCard: stripeMethod({ 2552 | method: 'POST', 2553 | path: '/{customerId}/cards', 2554 | urlParams: ['customerId'], 2555 | }), 2556 | 2557 | listCards: stripeMethod({ 2558 | method: 'GET', 2559 | path: '/{customerId}/cards', 2560 | urlParams: ['customerId'], 2561 | }), 2562 | 2563 | retrieveCard: stripeMethod({ 2564 | method: 'GET', 2565 | path: '/{customerId}/cards/{cardId}', 2566 | urlParams: ['customerId', 'cardId'], 2567 | }), 2568 | 2569 | updateCard: stripeMethod({ 2570 | method: 'POST', 2571 | path: '/{customerId}/cards/{cardId}', 2572 | urlParams: ['customerId', 'cardId'], 2573 | }), 2574 | 2575 | deleteCard: stripeMethod({ 2576 | method: 'DELETE', 2577 | path: '/{customerId}/cards/{cardId}', 2578 | urlParams: ['customerId', 'cardId'], 2579 | }), 2580 | 2581 | /** 2582 | * Customer: Source methods 2583 | */ 2584 | 2585 | createSource: stripeMethod({ 2586 | method: 'POST', 2587 | path: '/{customerId}/sources', 2588 | urlParams: ['customerId'], 2589 | }), 2590 | 2591 | listSources: stripeMethod({ 2592 | method: 'GET', 2593 | path: '/{customerId}/sources', 2594 | urlParams: ['customerId'], 2595 | }), 2596 | 2597 | retrieveSource: stripeMethod({ 2598 | method: 'GET', 2599 | path: '/{customerId}/sources/{sourceId}', 2600 | urlParams: ['customerId', 'sourceId'], 2601 | }), 2602 | 2603 | updateSource: stripeMethod({ 2604 | method: 'POST', 2605 | path: '/{customerId}/sources/{sourceId}', 2606 | urlParams: ['customerId', 'sourceId'], 2607 | }), 2608 | 2609 | deleteSource: stripeMethod({ 2610 | method: 'DELETE', 2611 | path: '/{customerId}/sources/{sourceId}', 2612 | urlParams: ['customerId', 'sourceId'], 2613 | }), 2614 | 2615 | verifySource: stripeMethod({ 2616 | method: 'POST', 2617 | path: '/{customerId}/sources/{sourceId}/verify', 2618 | urlParams: ['customerId', 'sourceId'], 2619 | }), 2620 | 2621 | /** 2622 | * Customer: Discount methods 2623 | */ 2624 | 2625 | deleteDiscount: stripeMethod({ 2626 | method: 'DELETE', 2627 | path: '/{customerId}/discount', 2628 | urlParams: ['customerId'], 2629 | }), 2630 | 2631 | deleteSubscriptionDiscount: stripeMethod({ 2632 | method: 'DELETE', 2633 | path: '/{customerId}/subscriptions/{subscriptionId}/discount', 2634 | urlParams: ['customerId', 'subscriptionId'], 2635 | }), 2636 | 2637 | }); 2638 | 2639 | 2640 | /***/ }), 2641 | /* 29 */ 2642 | /***/ (function(module, exports, __webpack_require__) { 2643 | 2644 | "use strict"; 2645 | 2646 | 2647 | var StripeResource = __webpack_require__(0); 2648 | var stripeMethod = StripeResource.method; 2649 | 2650 | module.exports = StripeResource.extend({ 2651 | 2652 | path: 'disputes', 2653 | 2654 | includeBasic: [ 2655 | 'list', 'retrieve', 'update', 'setMetadata', 'getMetadata', 2656 | ], 2657 | 2658 | close: stripeMethod({ 2659 | method: 'POST', 2660 | path: '/{id}/close', 2661 | urlParams: ['id'], 2662 | }), 2663 | 2664 | }); 2665 | 2666 | 2667 | 2668 | /***/ }), 2669 | /* 30 */ 2670 | /***/ (function(module, exports, __webpack_require__) { 2671 | 2672 | "use strict"; 2673 | 2674 | 2675 | var StripeResource = __webpack_require__(0); 2676 | var stripeMethod = StripeResource.method; 2677 | 2678 | module.exports = StripeResource.extend({ 2679 | create: stripeMethod({ 2680 | method: 'POST', 2681 | validator: function(data, options) { 2682 | if (!options.headers || !options.headers['Stripe-Version']) { 2683 | throw new Error('stripe_version must be specified to create an ephemeral key'); 2684 | } 2685 | }, 2686 | }), 2687 | 2688 | path: 'ephemeral_keys', 2689 | 2690 | includeBasic: ['del'], 2691 | }); 2692 | 2693 | 2694 | /***/ }), 2695 | /* 31 */ 2696 | /***/ (function(module, exports, __webpack_require__) { 2697 | 2698 | "use strict"; 2699 | 2700 | 2701 | module.exports = __webpack_require__(0).extend({ 2702 | path: 'events', 2703 | includeBasic: ['list', 'retrieve'], 2704 | }); 2705 | 2706 | 2707 | 2708 | /***/ }), 2709 | /* 32 */ 2710 | /***/ (function(module, exports, __webpack_require__) { 2711 | 2712 | "use strict"; 2713 | 2714 | 2715 | var StripeResource = __webpack_require__(0); 2716 | 2717 | module.exports = StripeResource.extend({ 2718 | 2719 | path: 'exchange_rates', 2720 | 2721 | includeBasic: [ 2722 | 'list', 'retrieve', 2723 | ], 2724 | }); 2725 | 2726 | 2727 | /***/ }), 2728 | /* 33 */ 2729 | /***/ (function(module, exports, __webpack_require__) { 2730 | 2731 | "use strict"; 2732 | 2733 | 2734 | var StripeResource = __webpack_require__(0); 2735 | var stripeMethod = StripeResource.method; 2736 | var utils = __webpack_require__(1); 2737 | 2738 | module.exports = StripeResource.extend({ 2739 | 2740 | path: 'invoices', 2741 | includeBasic: ['create', 'list', 'retrieve', 'update'], 2742 | 2743 | retrieveLines: stripeMethod({ 2744 | method: 'GET', 2745 | path: '{invoiceId}/lines', 2746 | urlParams: ['invoiceId'], 2747 | }), 2748 | 2749 | pay: stripeMethod({ 2750 | method: 'POST', 2751 | path: '{invoiceId}/pay', 2752 | urlParams: ['invoiceId'], 2753 | }), 2754 | 2755 | retrieveUpcoming: stripeMethod({ 2756 | method: 'GET', 2757 | path: function(urlData) { 2758 | var url = 'upcoming?customer=' + urlData.customerId; 2759 | // Legacy support where second argument is the subscription id 2760 | if (urlData.invoiceOptions && typeof urlData.invoiceOptions === 'string') { 2761 | return url + '&subscription=' + urlData.invoiceOptions; 2762 | } else if (urlData.invoiceOptions && typeof urlData.invoiceOptions === 'object') { 2763 | if (urlData.invoiceOptions.subscription_items !== undefined) { 2764 | urlData.invoiceOptions.subscription_items = utils.arrayToObject(urlData.invoiceOptions.subscription_items); 2765 | } 2766 | return url + '&' + utils.stringifyRequestData(urlData.invoiceOptions); 2767 | } 2768 | return url; 2769 | }, 2770 | urlParams: ['customerId', 'optional!invoiceOptions'], 2771 | encode: utils.encodeParamWithIntegerIndexes.bind(null, 'subscription_items'), 2772 | }), 2773 | 2774 | }); 2775 | 2776 | 2777 | /***/ }), 2778 | /* 34 */ 2779 | /***/ (function(module, exports, __webpack_require__) { 2780 | 2781 | "use strict"; 2782 | 2783 | 2784 | module.exports = __webpack_require__(0).extend({ 2785 | path: 'invoiceitems', 2786 | includeBasic: [ 2787 | 'create', 'list', 'retrieve', 'update', 'del', 2788 | 'setMetadata', 'getMetadata', 2789 | ], 2790 | }); 2791 | 2792 | 2793 | 2794 | /***/ }), 2795 | /* 35 */ 2796 | /***/ (function(module, exports, __webpack_require__) { 2797 | 2798 | "use strict"; 2799 | 2800 | 2801 | var StripeResource = __webpack_require__(0); 2802 | 2803 | module.exports = StripeResource.extend({ 2804 | path: 'issuer_fraud_records', 2805 | 2806 | includeBasic: ['list', 'retrieve'], 2807 | }); 2808 | 2809 | 2810 | /***/ }), 2811 | /* 36 */ 2812 | /***/ (function(module, exports, __webpack_require__) { 2813 | 2814 | "use strict"; 2815 | 2816 | 2817 | var StripeResource = __webpack_require__(0); 2818 | 2819 | module.exports = StripeResource.extend({ 2820 | path: 'accounts/{accountId}/login_links', 2821 | includeBasic: ['create'], 2822 | }); 2823 | 2824 | 2825 | /***/ }), 2826 | /* 37 */ 2827 | /***/ (function(module, exports, __webpack_require__) { 2828 | 2829 | "use strict"; 2830 | 2831 | 2832 | var StripeResource = __webpack_require__(0); 2833 | var stripeMethod = StripeResource.method; 2834 | 2835 | module.exports = StripeResource.extend({ 2836 | path: 'payment_intents', 2837 | includeBasic: ['create', 'list', 'retrieve', 'update'], 2838 | 2839 | cancel: stripeMethod({ 2840 | method: 'POST', 2841 | path: '{paymentIntentId}/cancel', 2842 | urlParams: ['paymentIntentId'], 2843 | }), 2844 | 2845 | capture: stripeMethod({ 2846 | method: 'POST', 2847 | path: '{paymentIntentId}/capture', 2848 | urlParams: ['paymentIntentId'], 2849 | }), 2850 | 2851 | confirm: stripeMethod({ 2852 | method: 'POST', 2853 | path: '{paymentIntentId}/confirm', 2854 | urlParams: ['paymentIntentId'], 2855 | }), 2856 | }); 2857 | 2858 | 2859 | 2860 | /***/ }), 2861 | /* 38 */ 2862 | /***/ (function(module, exports, __webpack_require__) { 2863 | 2864 | "use strict"; 2865 | 2866 | 2867 | var StripeResource = __webpack_require__(0); 2868 | var stripeMethod = StripeResource.method; 2869 | 2870 | module.exports = StripeResource.extend({ 2871 | 2872 | path: 'payouts', 2873 | 2874 | includeBasic: [ 2875 | 'create', 'list', 'retrieve', 'update', 2876 | 'setMetadata', 'getMetadata', 2877 | ], 2878 | 2879 | cancel: stripeMethod({ 2880 | method: 'POST', 2881 | path: '{payoutId}/cancel', 2882 | urlParams: ['payoutId'], 2883 | }), 2884 | 2885 | listTransactions: stripeMethod({ 2886 | method: 'GET', 2887 | path: '{payoutId}/transactions', 2888 | urlParams: ['payoutId'], 2889 | }), 2890 | }); 2891 | 2892 | 2893 | 2894 | /***/ }), 2895 | /* 39 */ 2896 | /***/ (function(module, exports, __webpack_require__) { 2897 | 2898 | "use strict"; 2899 | 2900 | 2901 | module.exports = __webpack_require__(0).extend({ 2902 | path: 'plans', 2903 | includeBasic: ['create', 'list', 'retrieve', 'update', 'del'], 2904 | }); 2905 | 2906 | 2907 | 2908 | /***/ }), 2909 | /* 40 */ 2910 | /***/ (function(module, exports, __webpack_require__) { 2911 | 2912 | "use strict"; 2913 | 2914 | 2915 | var StripeResource = __webpack_require__(0); 2916 | 2917 | /** 2918 | * RecipientCard is similar to CustomerCard in that, upon instantiation, it 2919 | * requires a recipientId, and therefore each of its methods only 2920 | * require the cardId argument. 2921 | * 2922 | * This streamlines the API specifically for the case of accessing cards 2923 | * on a returned recipient object. 2924 | * 2925 | * E.g. recipientObject.cards.retrieve(cardId) 2926 | * (As opposed to the also-supported stripe.recipients.retrieveCard(recipientId, cardId)) 2927 | */ 2928 | module.exports = StripeResource.extend({ 2929 | path: 'recipients/{recipientId}/cards', 2930 | includeBasic: ['create', 'list', 'retrieve', 'update', 'del'], 2931 | }); 2932 | 2933 | 2934 | /***/ }), 2935 | /* 41 */ 2936 | /***/ (function(module, exports, __webpack_require__) { 2937 | 2938 | "use strict"; 2939 | 2940 | 2941 | var StripeResource = __webpack_require__(0); 2942 | var stripeMethod = StripeResource.method; 2943 | 2944 | module.exports = StripeResource.extend({ 2945 | 2946 | path: 'recipients', 2947 | includeBasic: [ 2948 | 'create', 'list', 'retrieve', 'update', 'del', 2949 | 'setMetadata', 'getMetadata', 2950 | ], 2951 | 2952 | createCard: stripeMethod({ 2953 | method: 'POST', 2954 | path: '/{recipientId}/cards', 2955 | urlParams: ['recipientId'], 2956 | }), 2957 | 2958 | listCards: stripeMethod({ 2959 | method: 'GET', 2960 | path: '/{recipientId}/cards', 2961 | urlParams: ['recipientId'], 2962 | }), 2963 | 2964 | retrieveCard: stripeMethod({ 2965 | method: 'GET', 2966 | path: '/{recipientId}/cards/{cardId}', 2967 | urlParams: ['recipientId', 'cardId'], 2968 | }), 2969 | 2970 | updateCard: stripeMethod({ 2971 | method: 'POST', 2972 | path: '/{recipientId}/cards/{cardId}', 2973 | urlParams: ['recipientId', 'cardId'], 2974 | }), 2975 | 2976 | deleteCard: stripeMethod({ 2977 | method: 'DELETE', 2978 | path: '/{recipientId}/cards/{cardId}', 2979 | urlParams: ['recipientId', 'cardId'], 2980 | }), 2981 | 2982 | }); 2983 | 2984 | 2985 | 2986 | /***/ }), 2987 | /* 42 */ 2988 | /***/ (function(module, exports, __webpack_require__) { 2989 | 2990 | "use strict"; 2991 | 2992 | 2993 | var StripeResource = __webpack_require__(0); 2994 | 2995 | module.exports = StripeResource.extend({ 2996 | 2997 | path: 'refunds', 2998 | 2999 | includeBasic: [ 3000 | 'create', 'list', 'retrieve', 'update', 3001 | ], 3002 | }); 3003 | 3004 | 3005 | 3006 | /***/ }), 3007 | /* 43 */ 3008 | /***/ (function(module, exports, __webpack_require__) { 3009 | 3010 | "use strict"; 3011 | 3012 | 3013 | module.exports = __webpack_require__(0).extend({ 3014 | path: 'tokens', 3015 | includeBasic: ['create', 'retrieve'], 3016 | }); 3017 | 3018 | 3019 | /***/ }), 3020 | /* 44 */ 3021 | /***/ (function(module, exports, __webpack_require__) { 3022 | 3023 | "use strict"; 3024 | 3025 | 3026 | var StripeResource = __webpack_require__(0); 3027 | 3028 | module.exports = StripeResource.extend({ 3029 | path: 'topups', 3030 | includeBasic: ['create', 'list', 'retrieve', 'update', 'setMetadata', 'getMetadata'], 3031 | }); 3032 | 3033 | 3034 | /***/ }), 3035 | /* 45 */ 3036 | /***/ (function(module, exports, __webpack_require__) { 3037 | 3038 | "use strict"; 3039 | 3040 | 3041 | var StripeResource = __webpack_require__(0); 3042 | var stripeMethod = StripeResource.method; 3043 | 3044 | module.exports = StripeResource.extend({ 3045 | 3046 | path: 'transfers', 3047 | 3048 | includeBasic: [ 3049 | 'create', 'list', 'retrieve', 'update', 3050 | 'setMetadata', 'getMetadata', 3051 | ], 3052 | 3053 | reverse: stripeMethod({ 3054 | method: 'POST', 3055 | path: '/{transferId}/reversals', 3056 | urlParams: ['transferId'], 3057 | }), 3058 | 3059 | cancel: stripeMethod({ 3060 | method: 'POST', 3061 | path: '{transferId}/cancel', 3062 | urlParams: ['transferId'], 3063 | }), 3064 | 3065 | listTransactions: stripeMethod({ 3066 | method: 'GET', 3067 | path: '{transferId}/transactions', 3068 | urlParams: ['transferId'], 3069 | }), 3070 | 3071 | /** 3072 | * Transfer: Reversal methods 3073 | */ 3074 | createReversal: stripeMethod({ 3075 | method: 'POST', 3076 | path: '/{transferId}/reversals', 3077 | urlParams: ['transferId'], 3078 | }), 3079 | 3080 | listReversals: stripeMethod({ 3081 | method: 'GET', 3082 | path: '/{transferId}/reversals', 3083 | urlParams: ['transferId'], 3084 | }), 3085 | 3086 | retrieveReversal: stripeMethod({ 3087 | method: 'GET', 3088 | path: '/{transferId}/reversals/{reversalId}', 3089 | urlParams: ['transferId', 'reversalId'], 3090 | }), 3091 | 3092 | updateReversal: stripeMethod({ 3093 | method: 'POST', 3094 | path: '/{transferId}/reversals/{reversalId}', 3095 | urlParams: ['transferId', 'reversalId'], 3096 | }), 3097 | }); 3098 | 3099 | 3100 | 3101 | /***/ }), 3102 | /* 46 */ 3103 | /***/ (function(module, exports, __webpack_require__) { 3104 | 3105 | "use strict"; 3106 | 3107 | 3108 | var StripeResource = __webpack_require__(0); 3109 | var stripeMethod = StripeResource.method; 3110 | 3111 | module.exports = StripeResource.extend({ 3112 | 3113 | path: 'application_fees', 3114 | 3115 | includeBasic: [ 3116 | 'list', 'retrieve', 3117 | ], 3118 | 3119 | refund: stripeMethod({ 3120 | method: 'POST', 3121 | path: '/{id}/refund', 3122 | urlParams: ['id'], 3123 | }), 3124 | 3125 | createRefund: stripeMethod({ 3126 | method: 'POST', 3127 | path: '/{feeId}/refunds', 3128 | urlParams: ['feeId'], 3129 | }), 3130 | 3131 | listRefunds: stripeMethod({ 3132 | method: 'GET', 3133 | path: '/{feeId}/refunds', 3134 | urlParams: ['feeId'], 3135 | }), 3136 | 3137 | retrieveRefund: stripeMethod({ 3138 | method: 'GET', 3139 | path: '/{feeId}/refunds/{refundId}', 3140 | urlParams: ['feeId', 'refundId'], 3141 | }), 3142 | 3143 | updateRefund: stripeMethod({ 3144 | method: 'POST', 3145 | path: '/{feeId}/refunds/{refundId}', 3146 | urlParams: ['feeId', 'refundId'], 3147 | }), 3148 | }); 3149 | 3150 | 3151 | /***/ }), 3152 | /* 47 */ 3153 | /***/ (function(module, exports, __webpack_require__) { 3154 | 3155 | "use strict"; 3156 | 3157 | 3158 | var Buffer = __webpack_require__(3).Buffer; 3159 | var utils = __webpack_require__(1); 3160 | var StripeResource = __webpack_require__(0); 3161 | var stripeMethod = StripeResource.method; 3162 | var multipartDataGenerator = __webpack_require__(48); 3163 | var Error = __webpack_require__(2); 3164 | 3165 | module.exports = StripeResource.extend({ 3166 | 3167 | overrideHost: 'uploads.stripe.com', 3168 | 3169 | requestDataProcessor: function(method, data, headers, callback) { 3170 | data = data || {}; 3171 | 3172 | if (method === 'POST') { 3173 | return getProcessorForSourceType(data); 3174 | } else { 3175 | return callback(null, utils.stringifyRequestData(data)); 3176 | } 3177 | 3178 | function getProcessorForSourceType(data) { 3179 | var isStream = utils.checkForStream(data); 3180 | if (isStream) { 3181 | return streamProcessor(multipartDataGenerator); 3182 | } else { 3183 | var buffer = multipartDataGenerator(method, data, headers); 3184 | return callback(null, buffer); 3185 | } 3186 | } 3187 | 3188 | function streamProcessor (fn) { 3189 | var bufferArray = []; 3190 | data.file.data.on('data', function(line) { 3191 | bufferArray.push(line); 3192 | }).on('end', function() { 3193 | var bufferData = Object.assign({}, data); 3194 | bufferData.file.data = Buffer.concat(bufferArray); 3195 | var buffer = fn(method, bufferData, headers); 3196 | callback(null, buffer); 3197 | }).on('error', function(err) { 3198 | var errorHandler = streamError(callback); 3199 | errorHandler(err, null); 3200 | }); 3201 | } 3202 | 3203 | function streamError(callback) { 3204 | var StreamProcessingError = Error.extend({ 3205 | type: 'StreamProcessingError', 3206 | populate: function(raw) { 3207 | this.type = this.type; 3208 | this.message = raw.message; 3209 | this.detail = raw.detail; 3210 | } 3211 | }); 3212 | return function(error) { 3213 | callback( 3214 | new StreamProcessingError({ 3215 | message: 'An error occurred while attempting to process the file for upload.', 3216 | detail: error, 3217 | }), 3218 | null 3219 | ); 3220 | } 3221 | } 3222 | }, 3223 | 3224 | path: 'files', 3225 | 3226 | includeBasic: [ 3227 | 'retrieve', 3228 | 'list', 3229 | ], 3230 | 3231 | create: stripeMethod({ 3232 | method: 'POST', 3233 | headers: { 3234 | 'Content-Type': 'multipart/form-data', 3235 | }, 3236 | }), 3237 | }); 3238 | 3239 | 3240 | /***/ }), 3241 | /* 48 */ 3242 | /***/ (function(module, exports, __webpack_require__) { 3243 | 3244 | "use strict"; 3245 | 3246 | 3247 | var Buffer = __webpack_require__(3).Buffer; 3248 | 3249 | // Method for formatting HTTP body for the multipart/form-data specification 3250 | // Mostly taken from Fermata.js 3251 | // https://github.com/natevw/fermata/blob/5d9732a33d776ce925013a265935facd1626cc88/fermata.js#L315-L343 3252 | function multipartDataGenerator(method, data, headers) { 3253 | var segno = (Math.round(Math.random() * 1e16) + Math.round(Math.random() * 1e16)).toString(); 3254 | headers['Content-Type'] = ('multipart/form-data; boundary=' + segno); 3255 | var buffer = new Buffer(0); 3256 | 3257 | function push(l) { 3258 | var prevBuffer = buffer; 3259 | var newBuffer = (l instanceof Buffer) ? l : new Buffer(l); 3260 | buffer = new Buffer(prevBuffer.length + newBuffer.length + 2); 3261 | prevBuffer.copy(buffer); 3262 | newBuffer.copy(buffer, prevBuffer.length); 3263 | buffer.write('\r\n', buffer.length - 2); 3264 | } 3265 | 3266 | function q(s) { 3267 | return '"' + s.replace(/"|"/g, '%22').replace(/\r\n|\r|\n/g, ' ') + '"'; 3268 | } 3269 | 3270 | for (var k in data) { 3271 | var v = data[k]; 3272 | push('--' + segno); 3273 | if (v.hasOwnProperty('data')) { 3274 | push('Content-Disposition: form-data; name=' + q(k) + '; filename=' + q(v.name || 'blob')); 3275 | push('Content-Type: ' + (v.type || 'application/octet-stream')); 3276 | push(''); 3277 | push(v.data); 3278 | } else { 3279 | push('Content-Disposition: form-data; name=' + q(k)); 3280 | push(''); 3281 | push(v); 3282 | } 3283 | } 3284 | push('--' + segno + '--'); 3285 | 3286 | return buffer; 3287 | } 3288 | 3289 | module.exports = multipartDataGenerator; 3290 | 3291 | 3292 | /***/ }), 3293 | /* 49 */ 3294 | /***/ (function(module, exports, __webpack_require__) { 3295 | 3296 | "use strict"; 3297 | 3298 | 3299 | var StripeResource = __webpack_require__(0); 3300 | var stripeMethod = StripeResource.method; 3301 | 3302 | module.exports = StripeResource.extend({ 3303 | 3304 | path: 'bitcoin/receivers', 3305 | 3306 | includeBasic: [ 3307 | 'create', 'list', 'retrieve', 3308 | 'update', 'setMetadata', 'getMetadata', 3309 | ], 3310 | 3311 | listTransactions: stripeMethod({ 3312 | method: 'GET', 3313 | path: '/{receiverId}/transactions', 3314 | urlParams: ['receiverId'], 3315 | }), 3316 | }); 3317 | 3318 | 3319 | /***/ }), 3320 | /* 50 */ 3321 | /***/ (function(module, exports, __webpack_require__) { 3322 | 3323 | "use strict"; 3324 | 3325 | 3326 | var StripeResource = __webpack_require__(0); 3327 | var stripeMethod = StripeResource.method; 3328 | 3329 | module.exports = StripeResource.extend({ 3330 | 3331 | path: 'products', 3332 | 3333 | includeBasic: [ 3334 | 'list', 'retrieve', 'update', 'del', 3335 | ], 3336 | 3337 | create: stripeMethod({ 3338 | method: 'POST', 3339 | required: ['name'], 3340 | }), 3341 | 3342 | }); 3343 | 3344 | 3345 | /***/ }), 3346 | /* 51 */ 3347 | /***/ (function(module, exports, __webpack_require__) { 3348 | 3349 | "use strict"; 3350 | 3351 | 3352 | var StripeResource = __webpack_require__(0); 3353 | var stripeMethod = StripeResource.method; 3354 | 3355 | module.exports = StripeResource.extend({ 3356 | 3357 | path: 'skus', 3358 | 3359 | includeBasic: [ 3360 | 'list', 'retrieve', 'update', 'del', 3361 | ], 3362 | 3363 | create: stripeMethod({ 3364 | method: 'POST', 3365 | required: ['currency', 'inventory', 'price', 'product'], 3366 | }), 3367 | 3368 | }); 3369 | 3370 | 3371 | /***/ }), 3372 | /* 52 */ 3373 | /***/ (function(module, exports, __webpack_require__) { 3374 | 3375 | "use strict"; 3376 | 3377 | 3378 | var StripeResource = __webpack_require__(0); 3379 | var stripeMethod = StripeResource.method; 3380 | 3381 | module.exports = StripeResource.extend({ 3382 | 3383 | path: 'orders', 3384 | 3385 | includeBasic: [ 3386 | 'list', 'retrieve', 'update', 3387 | ], 3388 | 3389 | create: stripeMethod({ 3390 | method: 'POST', 3391 | required: ['currency'], 3392 | }), 3393 | 3394 | pay: stripeMethod({ 3395 | method: 'POST', 3396 | path: '/{orderId}/pay', 3397 | urlParams: ['orderId'], 3398 | }), 3399 | 3400 | returnOrder: stripeMethod({ 3401 | method: 'POST', 3402 | path: '/{orderId}/returns', 3403 | urlParams: ['orderId'], 3404 | }), 3405 | 3406 | }); 3407 | 3408 | 3409 | /***/ }), 3410 | /* 53 */ 3411 | /***/ (function(module, exports, __webpack_require__) { 3412 | 3413 | "use strict"; 3414 | 3415 | 3416 | var StripeResource = __webpack_require__(0); 3417 | 3418 | module.exports = StripeResource.extend({ 3419 | 3420 | path: 'order_returns', 3421 | 3422 | includeBasic: [ 3423 | 'list', 'retrieve', 3424 | ], 3425 | }); 3426 | 3427 | 3428 | /***/ }), 3429 | /* 54 */ 3430 | /***/ (function(module, exports, __webpack_require__) { 3431 | 3432 | "use strict"; 3433 | 3434 | 3435 | var StripeResource = __webpack_require__(0); 3436 | var utils = __webpack_require__(1); 3437 | var stripeMethod = StripeResource.method; 3438 | 3439 | module.exports = StripeResource.extend({ 3440 | 3441 | path: 'subscriptions', 3442 | includeBasic: ['list', 'retrieve', 'del',], 3443 | 3444 | create: stripeMethod({ 3445 | method: 'POST', 3446 | encode: utils.encodeParamWithIntegerIndexes.bind(null, 'items'), 3447 | }), 3448 | 3449 | update: stripeMethod({ 3450 | method: 'POST', 3451 | path: '{id}', 3452 | urlParams: ['id'], 3453 | encode: utils.encodeParamWithIntegerIndexes.bind(null, 'items'), 3454 | }), 3455 | 3456 | /** 3457 | * Subscription: Discount methods 3458 | */ 3459 | deleteDiscount: stripeMethod({ 3460 | method: 'DELETE', 3461 | path: '/{subscriptionId}/discount', 3462 | urlParams: ['subscriptionId'], 3463 | }), 3464 | }); 3465 | 3466 | 3467 | /***/ }), 3468 | /* 55 */ 3469 | /***/ (function(module, exports, __webpack_require__) { 3470 | 3471 | "use strict"; 3472 | 3473 | 3474 | var StripeResource = __webpack_require__(0); 3475 | 3476 | module.exports = StripeResource.extend({ 3477 | path: 'subscription_items', 3478 | includeBasic: ['create', 'list', 'retrieve', 'update', 'del',], 3479 | }); 3480 | 3481 | 3482 | 3483 | /***/ }), 3484 | /* 56 */ 3485 | /***/ (function(module, exports, __webpack_require__) { 3486 | 3487 | "use strict"; 3488 | 3489 | 3490 | var StripeResource = __webpack_require__(0); 3491 | 3492 | module.exports = StripeResource.extend({ 3493 | 3494 | path: '3d_secure', 3495 | 3496 | includeBasic: [ 3497 | 'create', 3498 | 'retrieve', 3499 | ], 3500 | }); 3501 | 3502 | 3503 | /***/ }), 3504 | /* 57 */ 3505 | /***/ (function(module, exports, __webpack_require__) { 3506 | 3507 | "use strict"; 3508 | 3509 | 3510 | var StripeResource = __webpack_require__(0); 3511 | var stripeMethod = StripeResource.method; 3512 | 3513 | module.exports = StripeResource.extend({ 3514 | 3515 | path: 'sources', 3516 | 3517 | includeBasic: [ 3518 | 'create', 'retrieve', 'update', 'setMetadata', 'getMetadata', 3519 | ], 3520 | 3521 | listSourceTransactions: stripeMethod({ 3522 | method: 'GET', 3523 | path: '/{id}/source_transactions', 3524 | urlParams: ['id'], 3525 | }), 3526 | 3527 | verify: stripeMethod({ 3528 | method: 'POST', 3529 | path: '/{id}/verify', 3530 | urlParams: ['id'], 3531 | }), 3532 | 3533 | }); 3534 | 3535 | 3536 | /***/ }), 3537 | /* 58 */ 3538 | /***/ (function(module, exports, __webpack_require__) { 3539 | 3540 | "use strict"; 3541 | 3542 | 3543 | var StripeResource = __webpack_require__(0); 3544 | var stripeMethod = StripeResource.method; 3545 | 3546 | module.exports = StripeResource.extend({ 3547 | path: 'subscription_items', 3548 | 3549 | create: stripeMethod({ 3550 | method: 'POST', 3551 | path: '{subscriptionItem}/usage_records', 3552 | urlParams: ['subscriptionItem'], 3553 | }), 3554 | }); 3555 | 3556 | 3557 | /***/ }), 3558 | /* 59 */ 3559 | /***/ (function(module, exports, __webpack_require__) { 3560 | 3561 | "use strict"; 3562 | 3563 | 3564 | var StripeResource = __webpack_require__(0); 3565 | 3566 | /** 3567 | * CustomerCard is a unique resource in that, upon instantiation, 3568 | * requires a customerId, and therefore each of its methods only 3569 | * require the cardId argument. 3570 | * 3571 | * This streamlines the API specifically for the case of accessing cards 3572 | * on a returned customer object. 3573 | * 3574 | * E.g. customerObject.cards.retrieve(cardId) 3575 | * (As opposed to the also-supported stripe.customers.retrieveCard(custId, cardId)) 3576 | */ 3577 | module.exports = StripeResource.extend({ 3578 | path: 'customers/{customerId}/cards', 3579 | includeBasic: ['create', 'list', 'retrieve', 'update', 'del'], 3580 | }); 3581 | 3582 | 3583 | /***/ }), 3584 | /* 60 */ 3585 | /***/ (function(module, exports, __webpack_require__) { 3586 | 3587 | "use strict"; 3588 | 3589 | 3590 | var StripeResource = __webpack_require__(0); 3591 | var stripeMethod = StripeResource.method; 3592 | 3593 | /** 3594 | * CustomerSubscription is a unique resource in that, upon instantiation, 3595 | * requires a customerId, and therefore each of its methods only 3596 | * require the subscriptionId argument. 3597 | * 3598 | * This streamlines the API specifically for the case of accessing cards 3599 | * on a returned customer object. 3600 | * 3601 | * E.g. customerObject.cards.retrieve(cardId) 3602 | * (As opposed to the also-supported stripe.customers.retrieveCard(custId, cardId)) 3603 | */ 3604 | module.exports = StripeResource.extend({ 3605 | path: 'customers/{customerId}/subscriptions', 3606 | includeBasic: ['create', 'list', 'retrieve', 'update', 'del'], 3607 | 3608 | /** 3609 | * Customer: Discount methods 3610 | */ 3611 | 3612 | deleteDiscount: stripeMethod({ 3613 | method: 'DELETE', 3614 | path: '/{subscriptionId}/discount', 3615 | urlParams: ['customerId', 'subscriptionId'], 3616 | }), 3617 | }); 3618 | 3619 | 3620 | /***/ }), 3621 | /* 61 */ 3622 | /***/ (function(module, exports, __webpack_require__) { 3623 | 3624 | "use strict"; 3625 | 3626 | 3627 | var StripeResource = __webpack_require__(0); 3628 | 3629 | /** 3630 | * ChargeRefunds is a unique resource in that, upon instantiation, 3631 | * requires a chargeId, and therefore each of its methods only 3632 | * require the refundId argument. 3633 | * 3634 | * This streamlines the API specifically for the case of accessing refunds 3635 | * on a returned charge object. 3636 | * 3637 | * E.g. chargeObject.refunds.retrieve(refundId) 3638 | * (As opposed to the also-supported stripe.charges.retrieveRefund(chargeId, 3639 | * refundId)) 3640 | */ 3641 | module.exports = StripeResource.extend({ 3642 | path: 'charges/{chargeId}/refunds', 3643 | includeBasic: ['create', 'list', 'retrieve', 'update'], 3644 | }); 3645 | 3646 | 3647 | /***/ }), 3648 | /* 62 */ 3649 | /***/ (function(module, exports, __webpack_require__) { 3650 | 3651 | "use strict"; 3652 | 3653 | 3654 | var StripeResource = __webpack_require__(0); 3655 | 3656 | /** 3657 | * ApplicationFeeRefunds is a unique resource in that, upon instantiation, 3658 | * requires an application fee id , and therefore each of its methods only 3659 | * require the refundId argument. 3660 | * 3661 | * This streamlines the API specifically for the case of accessing refunds 3662 | * on a returned application fee object. 3663 | * 3664 | * E.g. applicationFeeObject.refunds.retrieve(refundId) 3665 | * (As opposed to the also-supported stripe.applicationFees.retrieveRefund(chargeId, 3666 | * refundId)) 3667 | */ 3668 | module.exports = StripeResource.extend({ 3669 | path: 'application_fees/{feeId}/refunds', 3670 | includeBasic: ['create', 'list', 'retrieve', 'update'], 3671 | }); 3672 | 3673 | 3674 | /***/ }), 3675 | /* 63 */ 3676 | /***/ (function(module, exports, __webpack_require__) { 3677 | 3678 | "use strict"; 3679 | 3680 | 3681 | var StripeResource = __webpack_require__(0); 3682 | 3683 | /** 3684 | * TransferReversals is a unique resource in that, upon instantiation, 3685 | * requires a transferId, and therefore each of its methods only 3686 | * require the reversalId argument. 3687 | * 3688 | * This streamlines the API specifically for the case of accessing reversals 3689 | * on a returned transfer object. 3690 | * 3691 | * E.g. transferObject.reversals.retrieve(reversalId) 3692 | * (As opposed to the also-supported stripe.transfers.retrieveReversal(transferId, 3693 | * reversalId)) 3694 | */ 3695 | module.exports = StripeResource.extend({ 3696 | path: 'transfers/{transferId}/reversals', 3697 | includeBasic: ['create', 'list', 'retrieve', 'update'], 3698 | }); 3699 | 3700 | 3701 | 3702 | /***/ }), 3703 | /* 64 */ 3704 | /***/ (function(module, exports, __webpack_require__) { 3705 | 3706 | var crypto = __webpack_require__(9); 3707 | 3708 | var utils = __webpack_require__(1); 3709 | var Error = __webpack_require__(2); 3710 | 3711 | var Webhook = { 3712 | DEFAULT_TOLERANCE: 300, 3713 | 3714 | constructEvent: function(payload, header, secret, tolerance) { 3715 | var jsonPayload = JSON.parse(payload); 3716 | 3717 | this.signature.verifyHeader(payload, header, secret, tolerance || Webhook.DEFAULT_TOLERANCE); 3718 | 3719 | return jsonPayload; 3720 | }, 3721 | }; 3722 | 3723 | var signature = { 3724 | EXPECTED_SCHEME: 'v1', 3725 | 3726 | _computeSignature: function(payload, secret) { 3727 | return crypto.createHmac('sha256', secret) 3728 | .update(payload, 'utf8') 3729 | .digest('hex'); 3730 | }, 3731 | 3732 | verifyHeader: function(payload, header, secret, tolerance) { 3733 | var details = parseHeader(header, this.EXPECTED_SCHEME); 3734 | 3735 | if (!details || details.timestamp === -1) { 3736 | throw new Error.StripeSignatureVerificationError({ 3737 | message: 'Unable to extract timestamp and signatures from header', 3738 | detail: { 3739 | header: header, 3740 | payload: payload, 3741 | }, 3742 | }); 3743 | } 3744 | 3745 | if (!details.signatures.length) { 3746 | throw new Error.StripeSignatureVerificationError({ 3747 | message: 'No signatures found with expected scheme', 3748 | detail: { 3749 | header: header, 3750 | payload: payload, 3751 | }, 3752 | }); 3753 | } 3754 | 3755 | var expectedSignature = this._computeSignature(details.timestamp + '.' + payload, secret); 3756 | 3757 | var signatureFound = !!details.signatures 3758 | .filter(utils.secureCompare.bind(utils, expectedSignature)) 3759 | .length; 3760 | 3761 | if (!signatureFound) { 3762 | throw new Error.StripeSignatureVerificationError({ 3763 | message: 'No signatures found matching the expected signature for payload.' + 3764 | ' Are you passing the raw request body you received from Stripe?' + 3765 | ' https://github.com/stripe/stripe-node#webhook-signing', 3766 | detail: { 3767 | header: header, 3768 | payload: payload, 3769 | }, 3770 | }); 3771 | } 3772 | 3773 | var timestampAge = Math.floor(Date.now() / 1000) - details.timestamp; 3774 | 3775 | if (tolerance > 0 && timestampAge > tolerance) { 3776 | throw new Error.StripeSignatureVerificationError({ 3777 | message: 'Timestamp outside the tolerance zone', 3778 | detail: { 3779 | header: header, 3780 | payload: payload, 3781 | }, 3782 | }); 3783 | } 3784 | 3785 | return true; 3786 | }, 3787 | }; 3788 | 3789 | function parseHeader(header, scheme) { 3790 | if (typeof header !== 'string') { 3791 | return null; 3792 | } 3793 | 3794 | return header.split(',').reduce(function(accum, item) { 3795 | var kv = item.split('='); 3796 | 3797 | if (kv[0] === 't') { 3798 | accum.timestamp = kv[1]; 3799 | } 3800 | 3801 | if (kv[0] === scheme) { 3802 | accum.signatures.push(kv[1]); 3803 | } 3804 | 3805 | return accum; 3806 | }, { 3807 | timestamp: -1, 3808 | signatures: [], 3809 | }); 3810 | } 3811 | 3812 | Webhook.signature = signature; 3813 | 3814 | module.exports = Webhook; 3815 | 3816 | 3817 | /***/ }) 3818 | /******/ ]))); -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Project dependencies 2 | .cache 3 | node_modules 4 | yarn-error.log 5 | 6 | # Build directory 7 | /public 8 | .DS_Store 9 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "semi": false, 3 | "singleQuote": true, 4 | "trailingComma": "es5" 5 | } 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 gatsbyjs 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # React for Designers 2 | ![](https://cl.ly/0Q093L3s2Q27/download/react-promo.jpg) 3 | React is the most popular javascript framework. It’s component-based, similar to how you use Components in [Figma](https://www.figma.com/?ref=designcode) in order to reuse the elements in powerful ways. This in turn allows for better collaboration between teammates. With this course, you'll learn how to build and animate your site from scratch. Create highly customizable components for your design system. Full video tutorials: 4 | https://designcode.io/react 5 | 6 | ## Course Downloads 7 | - [Intro to React](https://github.com/MengTo/my-react-app/tree/f095062888caa9f09a454507ee4b51e0760cf024) 8 | - [Basic Styling in CSS](https://github.com/MengTo/my-react-app/tree/25acf94655e10cf6a7b2b503df49d291dcef5cc3) 9 | - [Adaptive Layouts with CSS Grid](https://github.com/MengTo/my-react-app/tree/ad4d5eec229d7a72ad53d3f0b8f5a3e52b3a86bc) 10 | - [Interactions and Animations](https://github.com/MengTo/my-react-app/tree/7c6f0948754fe8e876212b6c84474ed4a69da207) 11 | - [SVG Animation](https://github.com/MengTo/my-react-app/tree/adaba5ab5339dcf97a5aead4a5dea173a7b629fd) 12 | - [Components and Props](https://github.com/MengTo/my-react-app/tree/f8cecaf15638e633cfc70248a6590206bae08ac0) 13 | - [States and Events](https://github.com/MengTo/my-react-app/tree/6795aeb92155de1046e44255fdc988663ff18b14) 14 | - [Styled Components](https://github.com/MengTo/my-react-app/tree/555833defc42f63db1e64c7893cdf0923be88943) 15 | - [Static Data with JSON](https://github.com/MengTo/my-react-app/tree/6777553e4293a34072d40a2c8913357c982cffb0) 16 | - [GraphQL with Contentful](https://github.com/MengTo/my-react-app/tree/e9e674ba40f91faf929d219f5c680114e9e0881e) 17 | - [Publish to Netlify](https://github.com/MengTo/my-react-app/tree/e9e674ba40f91faf929d219f5c680114e9e0881e) 18 | - [Payments with Stripe](https://github.com/MengTo/my-react-app/tree/87ccfa1431301313511e29875f5c8a2221caed36) 19 | 20 | ## Install Gatsby and Node 21 | 22 | Make sure that you have the Gatsby installed and [Node](https://nodejs.org/en/download/): 23 | ```sh 24 | npm install --global gatsby-cli 25 | ``` 26 | 27 | ## Install Libraries 28 | ```sh 29 | npm install 30 | ``` 31 | 32 | ## Known Issues 33 | ### Permission Issue Installing Gatsby 34 | If you have issues installing Gatsby, please use sudo in front. 35 | ```sh 36 | sudo npm install --global gatsby-cli 37 | ``` 38 | 39 | ### Image issue in In Basic Styling in CSS 40 | You may get an error when you call the local image. The easiest solution is to put the image online using [CloudApp](http://getcloudapp.com). 41 | ```css 42 | background: url('https://cl.ly/3k1F152x261C/download/wallpaper3.jpg'); 43 | ``` 44 | 45 | Or, you can try installing this library. 46 | ```sh 47 | npm install --save url-loader 48 | ``` 49 | 50 | Or, you can also put the images inside `/static/images` or `/public/images` instead of `/src/images`. Link the images like this: 51 | ```css 52 | background: url('../../static/images/wallpaper3.jpg'); 53 | ``` 54 | 55 | ### GraphQL giving an error 56 | Make sure to restart your local environment by doing **Control + C** in the Terminal, and then `gatsby develop`. 57 | -------------------------------------------------------------------------------- /functions/stripe-charge.js: -------------------------------------------------------------------------------- 1 | const stripe = require('stripe')('sk_test_4VuxA0doyoVb7Yl6RU7u43ya') 2 | 3 | exports.handler = async function(event) { 4 | const { 5 | tokenId, 6 | email, 7 | name, 8 | description, 9 | amount 10 | } = JSON.parse(event.body) 11 | 12 | const customer = await stripe.customers.create({ 13 | description: email, 14 | source: tokenId 15 | }) 16 | 17 | await stripe.charges.create({ 18 | customer: customer.id, 19 | amount, 20 | name, 21 | description, 22 | currency: 'usd' 23 | }) 24 | } -------------------------------------------------------------------------------- /gatsby-browser.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Implement Gatsby's Browser APIs in this file. 3 | * 4 | * See: https://www.gatsbyjs.org/docs/browser-apis/ 5 | */ 6 | 7 | // You can delete this file if you're not using it -------------------------------------------------------------------------------- /gatsby-config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | siteMetadata: { 3 | title: 'Design+Code 3', 4 | description: 'Complete courses about the best tools and design systems. Prototype and build apps with React and Swift. 60 hours of video content and resource materials. No coding experience required.', 5 | keywords: 'react course, react for designers, ios development, sketch app, swift app course, arkit 2, after effects, create sketch plugin' 6 | }, 7 | plugins: [ 8 | 'gatsby-plugin-react-helmet', 9 | { 10 | resolve: 'gatsby-source-contentful', 11 | options: { 12 | spaceId: '0ge8xzmnbp2c', 13 | accessToken: 'b3b275d4fda32085546b9100cb9ae7cb8796fdddd462fd42ba53c4c17bf2f99d' 14 | } 15 | } 16 | ], 17 | } -------------------------------------------------------------------------------- /gatsby-node.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Implement Gatsby's Node APIs in this file. 3 | * 4 | * See: https://www.gatsbyjs.org/docs/node-apis/ 5 | */ 6 | 7 | // You can delete this file if you're not using it -------------------------------------------------------------------------------- /gatsby-ssr.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Implement Gatsby's SSR (Server Side Rendering) APIs in this file. 3 | * 4 | * See: https://www.gatsbyjs.org/docs/ssr-apis/ 5 | */ 6 | 7 | // You can delete this file if you're not using it -------------------------------------------------------------------------------- /netlify.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | functions = './.functions' -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gatsby-starter-default", 3 | "description": "Gatsby default starter", 4 | "version": "1.0.0", 5 | "author": "Kyle Mathews ", 6 | "dependencies": { 7 | "gatsby": "^1.9.247", 8 | "gatsby-link": "^1.6.40", 9 | "gatsby-plugin-react-helmet": "^2.0.10", 10 | "gatsby-source-contentful": "^1.3.54", 11 | "react-helmet": "^5.2.0", 12 | "react-stripe-checkout": "^2.6.3", 13 | "stripe": "^6.3.0", 14 | "styled-components": "^3.3.3" 15 | }, 16 | "keywords": [ 17 | "gatsby" 18 | ], 19 | "license": "MIT", 20 | "scripts": { 21 | "build": "gatsby build", 22 | "develop": "gatsby develop", 23 | "format": "prettier --write 'src/**/*.js'", 24 | "test": "echo \"Error: no test specified\" && exit 1" 25 | }, 26 | "devDependencies": { 27 | "prettier": "^1.12.0" 28 | }, 29 | "repository": { 30 | "type": "git", 31 | "url": "https://github.com/gatsbyjs/gatsby-starter-default" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/components/Card.css: -------------------------------------------------------------------------------- 1 | .Card { 2 | width: 300px; 3 | height: 225px; 4 | position: relative; 5 | overflow: hidden; 6 | border-radius: 20px; 7 | box-shadow: 0 20px 40px rgba(0,0,0, 0.25); 8 | display: grid; 9 | grid-template-rows: 1fr 1fr; 10 | transition: 0.8s cubic-bezier(0.2, 0.8, 0.2, 1); 11 | } 12 | 13 | .Card:hover { 14 | transform: scale(1.1, 1.1); 15 | box-shadow: 0 30px 60px rgba(0,0,0, 0.5); 16 | } 17 | 18 | .Card:hover img { 19 | transform: translateY(-20px); 20 | } 21 | 22 | .Card img { 23 | position: absolute; 24 | top: 0; 25 | height: 110%; 26 | z-index: -1; 27 | transition: 0.8s cubic-bezier(0.2, 0.8, 0.2, 1); 28 | } 29 | 30 | .Card h3 { 31 | color: white; 32 | font-size: 30px; 33 | margin: 20px 0 0 20px; 34 | width: 190px; 35 | } 36 | 37 | .Card p { 38 | color: rgba(255,255,255, 0.8); 39 | text-transform: uppercase; 40 | font-weight: 600; 41 | font-size: 18px; 42 | align-self: end; 43 | margin: 0 0 20px 20px; 44 | } -------------------------------------------------------------------------------- /src/components/Card.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import './Card.css' 3 | 4 | const Card = props => ( 5 |
6 | 7 |

{props.title}

8 |

{props.text}

9 |
10 | ) 11 | 12 | export default Card -------------------------------------------------------------------------------- /src/components/Cell.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import styled from 'styled-components' 3 | 4 | const CellGroup = styled.div` 5 | display: grid; 6 | grid-template-columns: 60px auto; 7 | grid-gap: 25px; 8 | align-items: center; 9 | ` 10 | 11 | const CellImage = styled.div` 12 | width: 60px; 13 | height: 60px; 14 | background: black; 15 | border-radius: 10px; 16 | background-image: url(${props => props.image}); 17 | background-size: 60px; 18 | ` 19 | 20 | const CellTitle = styled.div` 21 | font-size: 24px; 22 | border-bottom: 1px solid rgba(0,0,0, 0.1); 23 | padding: 30px 0; 24 | ` 25 | 26 | const Cell = props => ( 27 | 28 | 29 | {props.title} 30 | 31 | ) 32 | 33 | export default Cell -------------------------------------------------------------------------------- /src/components/Footer.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import styled from 'styled-components' 3 | 4 | const FooterGroup = styled.div` 5 | background: #F1F3F5; 6 | padding: 50px 0; 7 | display: grid; 8 | grid-gap: 20px; 9 | ` 10 | const Text = styled.p` 11 | font-size: 24px; 12 | font-weight: 600; 13 | color: #486791; 14 | max-width: 500px; 15 | margin: 0 auto; 16 | ` 17 | const Button = styled.button` 18 | background: linear-gradient(102.24deg, #9B51E0 0%, #3436E7 100%); 19 | box-shadow: 0px 10px 20px rgba(101, 41, 255, 0.15); 20 | border-radius: 30px; 21 | color: white; 22 | border: none; 23 | padding: 16px 60px; 24 | font-weight: 600; 25 | font-size: 24px; 26 | justify-self: center; 27 | transition: 0.8s cubic-bezier(0.2, 0.8, 0.2, 1); 28 | 29 | &:hover { 30 | box-shadow: 0 20px 40px rgba(0,0,0, 0.15); 31 | transform: translateY(-3px); 32 | } 33 | ` 34 | const LinkGroup = styled.div` 35 | width: 500px; 36 | margin: 50px auto; 37 | display: grid; 38 | grid-template-columns: repeat(2, 1fr); 39 | grid-gap: 10px; 40 | 41 | a { 42 | transition: 0.8s; 43 | } 44 | 45 | a:hover { 46 | color: black; 47 | } 48 | ` 49 | 50 | const Copyright = styled.div` 51 | color: #486791; 52 | max-width: 500px; 53 | margin: 0 auto; 54 | padding: 0 20px; 55 | ` 56 | 57 | const Footer = ({data, children}) => ( 58 | 59 | Tweet “Prototype and build apps with React and Swift. New courses by @MengTo” 60 | 61 | {data.allContentfulLink.edges.map(edge => ( 62 | {edge.node.title} 63 | ))} 64 | {children} 65 | 66 | ) 67 | 68 | export default Footer -------------------------------------------------------------------------------- /src/components/Header.css: -------------------------------------------------------------------------------- 1 | .Header { 2 | position: fixed; 3 | width: 100%; 4 | padding: 50px 0; 5 | z-index: 100; 6 | transition: 0.8s cubic-bezier(0.2, 0.8, 0.2, 1); 7 | } 8 | 9 | .HeaderScrolled { 10 | background: rgba(0,0,0, 0.8); 11 | padding: 15px 0; 12 | backdrop-filter: blur(20px); 13 | } 14 | 15 | .HeaderGroup { 16 | max-width: 800px; 17 | margin: 0 auto; 18 | display: grid; 19 | grid-template-columns: repeat(5, auto); 20 | align-items: center; 21 | justify-items: center; 22 | } 23 | 24 | .Header a { 25 | color: white; 26 | font-weight: 700; 27 | } 28 | 29 | .Header button { 30 | padding: 8px 20px; 31 | font-size: 20px; 32 | background: #56CCF2; 33 | border: none; 34 | font-weight: 700; 35 | border-radius: 10px; 36 | outline: none; 37 | cursor: pointer; 38 | transition: 1s cubic-bezier(0.2, 0.8, 0.2, 1); 39 | } 40 | 41 | .Header button:hover { 42 | background: white; 43 | box-shadow: 0 10px 20px rgba(0,0,0, 0.25); 44 | transform: translateY(-3px); 45 | } 46 | 47 | @media (max-width: 640px) { 48 | .Header { 49 | padding: 15px 0; 50 | } 51 | 52 | .HeaderGroup { 53 | grid-template-columns: repeat(4, auto); 54 | } 55 | 56 | .Header a:nth-child(4) { 57 | display: none; 58 | } 59 | } -------------------------------------------------------------------------------- /src/components/Section.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import styled from 'styled-components' 3 | import Wave from './Wave'; 4 | 5 | const SectionGroup = styled.div` 6 | background: url(${props => props.image}); 7 | height: 720px; 8 | background-size: cover; 9 | display: grid; 10 | grid-template-rows: 300px auto; 11 | grid-gap: 20px; 12 | position: relative; 13 | 14 | @media (max-width: 640px) { 15 | height: 820px; 16 | } 17 | ` 18 | 19 | const SectionLogo = styled.img` 20 | align-self: end; 21 | width: 128px; 22 | margin: 0 auto; 23 | ` 24 | 25 | const SectionTitleGroup = styled.div` 26 | display: grid; 27 | grid-template-columns: 300px auto; 28 | margin: 0 40px; 29 | grid-gap: 20px; 30 | grid-template-rows: auto 100%; 31 | 32 | @media (max-width: 720px) { 33 | grid-template-columns: 1fr; 34 | } 35 | ` 36 | 37 | const SectionTitle = styled.h3` 38 | color: white; 39 | font-size: 60px; 40 | margin: 0; 41 | line-height: 1.2; 42 | 43 | @media (max-width: 720px) { 44 | font-size: 40px; 45 | } 46 | ` 47 | 48 | const SectionText = styled.p` 49 | color: white; 50 | ` 51 | 52 | const WaveBottom = styled.div` 53 | position: absolute; 54 | width: 100%; 55 | bottom: -6px; 56 | ` 57 | 58 | const WaveTop = styled.div` 59 | position: absolute; 60 | width: 100%; 61 | top: -6px; 62 | transform: rotate(180deg); 63 | ` 64 | 65 | const Section = props => ( 66 | 67 | 68 | 69 | 70 | 71 | {props.title} 72 | {props.text} 73 | 74 | 75 | ) 76 | 77 | export default Section -------------------------------------------------------------------------------- /src/components/Wave.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | const Wave = () => ( 4 | 5 | 6 | 15 | 16 | 17 | ) 18 | 19 | export default Wave -------------------------------------------------------------------------------- /src/components/header.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import Link from 'gatsby-link' 3 | import './Header.css' 4 | import StripeCheckout from 'react-stripe-checkout' 5 | 6 | class Header extends React.Component { 7 | constructor(props) { 8 | super(props) 9 | 10 | this.state = { 11 | hasScrolled: false 12 | } 13 | } 14 | 15 | componentDidMount() { 16 | window.addEventListener('scroll', this.handleScroll) 17 | } 18 | 19 | handleScroll = (event) => { 20 | const scrollTop = window.pageYOffset 21 | 22 | if (scrollTop > 50) { 23 | this.setState({ hasScrolled: true }) 24 | } else { 25 | this.setState({ hasScrolled: false }) 26 | } 27 | } 28 | 29 | handlePurchase = (token) => { 30 | const amount = 5000 31 | const description = "My awesome product" 32 | 33 | const bodyObject = { 34 | tokenId: token.id, 35 | email: token.email, 36 | name: token.name, 37 | description, 38 | amount 39 | } 40 | 41 | fetch('http://localhost:9000/stripe-charge', { 42 | method: 'POST', 43 | body: JSON.stringify(bodyObject) 44 | }) 45 | } 46 | 47 | render() { 48 | return ( 49 |
50 |
51 | 52 | Courses 53 | Downloads 54 | Workshops 55 | 61 | 62 | 63 |
64 |
65 | ) 66 | } 67 | } 68 | 69 | export default Header 70 | -------------------------------------------------------------------------------- /src/layouts/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; 3 | margin: 0; 4 | font-size: 20px; 5 | -webkit-font-smoothing: antialiased; 6 | line-height: 1.3; 7 | } 8 | 9 | a { 10 | color: #5334F5; 11 | text-decoration: none; 12 | font-weight: 600; 13 | } 14 | 15 | .Hero { 16 | background: url(/images/wallpaper3.jpg); 17 | height: 920px; 18 | background-size: cover; 19 | background-position: center; 20 | position: relative; 21 | } 22 | 23 | .HeroGroup { 24 | margin: 0 auto; 25 | max-width: 500px; 26 | padding: 150px 50px; 27 | text-align: center; 28 | } 29 | 30 | .Hero h1 { 31 | margin: 0; 32 | color: white; 33 | font-size: 60px; 34 | line-height: 1.2; 35 | opacity: 0; 36 | animation: HeroAnimation; 37 | animation-duration: 3s; 38 | animation-delay: 0.1s; 39 | animation-fill-mode: forwards; 40 | animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1); 41 | } 42 | 43 | .Hero p { 44 | color: rgba(255, 255, 255, 0.8); 45 | font-size: 30px; 46 | line-height: 1.5; 47 | animation: HeroAnimation 3s 0.2s forwards cubic-bezier(0.2, 0.8, 0.2, 1); 48 | opacity: 0; 49 | } 50 | 51 | .Hero a { 52 | font-size: 17px; 53 | font-weight: 600; 54 | color: white; 55 | text-transform: uppercase; 56 | background: rgba(0,0,0, 0.7); 57 | padding: 9px 20px; 58 | border: 1px solid rgba(255, 255, 255, 0.25); 59 | border-radius: 20px; 60 | transition: 0.8s cubic-bezier(0.2, 0.8, 0.2, 1); 61 | } 62 | 63 | .Hero a:hover { 64 | background: white; 65 | color: black; 66 | } 67 | 68 | @media (max-width: 640px) { 69 | .HeroGroup { 70 | padding: 100px 20px; 71 | } 72 | 73 | .Hero h1 { 74 | font-size: 40px; 75 | } 76 | 77 | .Hero p { 78 | font-size: 24px; 79 | } 80 | } 81 | 82 | @keyframes HeroAnimation { 83 | 0% { 84 | opacity: 0; 85 | transform: translateY(20px); 86 | } 87 | 100% { 88 | opacity: 1; 89 | transform: translateY(0px); 90 | } 91 | } 92 | 93 | .Hero svg { 94 | position: absolute; 95 | bottom: 0; 96 | left: 0; 97 | } 98 | 99 | .Hero .Logos { 100 | display: grid; 101 | grid-template-columns: repeat(6, 1fr); 102 | grid-gap: 40px; 103 | margin: 100px 0; 104 | justify-items: center; 105 | } 106 | 107 | @media (max-width: 640px) { 108 | .Hero .Logos { 109 | grid-template-columns: repeat(3, 1fr); 110 | } 111 | } 112 | 113 | .Cards h2 { 114 | margin: 50px 20px; 115 | font-size: 60px; 116 | text-align: center; 117 | font-weight: 700; 118 | background: linear-gradient(104deg, #050A27 0%, #4A548C 100%); 119 | -webkit-background-clip: text; 120 | background-clip: text; 121 | -webkit-text-fill-color: transparent; 122 | } 123 | 124 | .CardGroup { 125 | margin: 50px 40px 100px; 126 | display: grid; 127 | grid-template-columns: repeat(3, 1fr); 128 | grid-gap: 40px; 129 | justify-items: center; 130 | } 131 | 132 | @media (max-width: 1060px) { 133 | .CardGroup { 134 | grid-template-columns: repeat(2, 1fr); 135 | } 136 | } 137 | 138 | @media (max-width: 720px) { 139 | .CardGroup { 140 | grid-template-columns: repeat(1, 1fr); 141 | } 142 | } -------------------------------------------------------------------------------- /src/layouts/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import PropTypes from 'prop-types' 3 | import Helmet from 'react-helmet' 4 | 5 | import Header from '../components/header' 6 | import './index.css' 7 | import Footer from '../components/Footer'; 8 | 9 | const Layout = ({ children, data }) => ( 10 |
11 | 18 |
19 | {children()} 20 |
21 | Backgrounds made in Cinema 4D, iOS app in Swift, site in React. Email us to ask anything. © 2018 22 |
23 |
24 | ) 25 | 26 | Layout.propTypes = { 27 | children: PropTypes.func, 28 | } 29 | 30 | export default Layout 31 | 32 | export const query = graphql` 33 | query SiteTitleQuery { 34 | site { 35 | siteMetadata { 36 | title 37 | description 38 | keywords 39 | } 40 | } 41 | allContentfulLink(sort: { fields: [createdAt], order: ASC }) { 42 | edges { 43 | node { 44 | title 45 | url 46 | createdAt 47 | } 48 | } 49 | } 50 | } 51 | ` 52 | -------------------------------------------------------------------------------- /src/pages/404.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | const NotFoundPage = () => ( 4 |
5 |

NOT FOUND

6 |

You just hit a route that doesn't exist... the sadness.

7 |
8 | ) 9 | 10 | export default NotFoundPage 11 | -------------------------------------------------------------------------------- /src/pages/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import Link from 'gatsby-link' 3 | import Card from '../components/Card'; 4 | import Section from '../components/Section'; 5 | import Wave from '../components/Wave'; 6 | import staticdata from '../../staticdata.json' 7 | import Cell from '../components/Cell'; 8 | import styled from 'styled-components' 9 | 10 | const SectionCaption = styled.p` 11 | font-weight: 600; 12 | font-size: 18px; 13 | text-transform: uppercase; 14 | color: #94A4BA; 15 | text-align: center; 16 | ` 17 | 18 | const SectionCellGroup = styled.div` 19 | max-width: 800px; 20 | margin: 0 auto 100px; 21 | display: grid; 22 | grid-template-columns: repeat(2, 1fr); 23 | grid-column-gap: 20px; 24 | padding: 0 20px; 25 | 26 | @media (max-width: 800px) { 27 | grid-template-columns: repeat(1, 1fr); 28 | } 29 | ` 30 | 31 | const IndexPage = () => ( 32 |
33 |
34 |
35 |

Learn to
design and code React apps

36 |

Complete courses about the best tools and design systems. Prototype and build apps with React and Swift.

37 | Watch the video 38 |
39 | 40 | 41 | 42 | 43 | 44 | 45 |
46 | 47 |
48 |
49 |
50 |

11 courses, more coming

51 |
52 | 56 | 60 | 64 | 68 |
69 |
70 |
76 | 12 sections - 6 hours 77 | 78 | {staticdata.cells.map(cell => ( 79 | 82 | ))} 83 | 84 |
85 | ) 86 | 87 | export default IndexPage 88 | -------------------------------------------------------------------------------- /src/pages/page-2.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import Link from 'gatsby-link' 3 | 4 | const SecondPage = () => ( 5 |
6 |

Hi from the second page

7 |

Welcome to page 2

8 | Go back to the homepage 9 |
10 | ) 11 | 12 | export default SecondPage 13 | -------------------------------------------------------------------------------- /static/images/logo-designcode.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /static/images/logo-figma.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MengTo/my-react-app/611e4607d5495c2967c949b27b49c7a6c01678f6/static/images/logo-figma.png -------------------------------------------------------------------------------- /static/images/logo-framer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MengTo/my-react-app/611e4607d5495c2967c949b27b49c7a6c01678f6/static/images/logo-framer.png -------------------------------------------------------------------------------- /static/images/logo-invision.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MengTo/my-react-app/611e4607d5495c2967c949b27b49c7a6c01678f6/static/images/logo-invision.png -------------------------------------------------------------------------------- /static/images/logo-react.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MengTo/my-react-app/611e4607d5495c2967c949b27b49c7a6c01678f6/static/images/logo-react.png -------------------------------------------------------------------------------- /static/images/logo-sketch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MengTo/my-react-app/611e4607d5495c2967c949b27b49c7a6c01678f6/static/images/logo-sketch.png -------------------------------------------------------------------------------- /static/images/logo-studio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MengTo/my-react-app/611e4607d5495c2967c949b27b49c7a6c01678f6/static/images/logo-studio.png -------------------------------------------------------------------------------- /static/images/logo-swift.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MengTo/my-react-app/611e4607d5495c2967c949b27b49c7a6c01678f6/static/images/logo-swift.png -------------------------------------------------------------------------------- /static/images/logo-xcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MengTo/my-react-app/611e4607d5495c2967c949b27b49c7a6c01678f6/static/images/logo-xcode.png -------------------------------------------------------------------------------- /static/images/wallpaper.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MengTo/my-react-app/611e4607d5495c2967c949b27b49c7a6c01678f6/static/images/wallpaper.jpg -------------------------------------------------------------------------------- /static/images/wallpaper2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MengTo/my-react-app/611e4607d5495c2967c949b27b49c7a6c01678f6/static/images/wallpaper2.jpg -------------------------------------------------------------------------------- /static/images/wallpaper3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MengTo/my-react-app/611e4607d5495c2967c949b27b49c7a6c01678f6/static/images/wallpaper3.jpg -------------------------------------------------------------------------------- /static/images/wallpaper4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MengTo/my-react-app/611e4607d5495c2967c949b27b49c7a6c01678f6/static/images/wallpaper4.jpg -------------------------------------------------------------------------------- /staticdata.json: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "title": "Intro to React", 5 | "image": "https://cl.ly/0Q1n3K431Y1S/download/logo-react-small.png" 6 | }, 7 | { 8 | "title": "Basic Styling in CSS", 9 | "image": "https://cl.ly/1U1F170x3D0L/download/logo-react-small.png" 10 | }, 11 | { 12 | "title": "Adaptive Layout with CSS Grid", 13 | "image": "https://cl.ly/1U1F170x3D0L/download/logo-react-small.png" 14 | }, 15 | { 16 | "title": "Interactions and Animations", 17 | "image": "https://cl.ly/1U1F170x3D0L/download/logo-react-small.png" 18 | }, 19 | { 20 | "title": "SVG Animation", 21 | "image": "https://cl.ly/1U1F170x3D0L/download/logo-react-small.png" 22 | }, 23 | { 24 | "title": "Components and Props", 25 | "image": "https://cl.ly/1U1F170x3D0L/download/logo-react-small.png" 26 | }, 27 | { 28 | "title": "States and Events", 29 | "image": "https://cl.ly/1U1F170x3D0L/download/logo-react-small.png" 30 | }, 31 | { 32 | "title": "Styled Components", 33 | "image": "https://cl.ly/1U1F170x3D0L/download/logo-react-small.png" 34 | }, 35 | { 36 | "title": "Static Data with JSON", 37 | "image": "https://cl.ly/1U1F170x3D0L/download/logo-react-small.png" 38 | }, 39 | { 40 | "title": "GraphQL with Contentful", 41 | "image": "https://cl.ly/1U1F170x3D0L/download/logo-react-small.png" 42 | }, 43 | { 44 | "title": "Publish to Netlify", 45 | "image": "https://cl.ly/1U1F170x3D0L/download/logo-react-small.png" 46 | }, 47 | { 48 | "title": "Payment with Stripe Checkout", 49 | "image": "https://cl.ly/1U1F170x3D0L/download/logo-react-small.png" 50 | } 51 | ] 52 | } --------------------------------------------------------------------------------