From a2c44d9aa798e2d84fcb168d0e6d868d5d8d5af1 Mon Sep 17 00:00:00 2001 From: Daniele Caltabiano Date: Sat, 2 Jun 2018 20:27:56 +0200 Subject: [PATCH] added handling of parameters of stripev3.load --- .gitignore | 4 ++++ addon/services/stripev3.js | 25 +++++++++++++++++++------ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index a168461..695a6fe 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,7 @@ package.json.ember-try .DS_Store yarn-error.log + +#Eclipse +.settings +.project diff --git a/addon/services/stripev3.js b/addon/services/stripev3.js index a9002eb..ef7a634 100644 --- a/addon/services/stripev3.js +++ b/addon/services/stripev3.js @@ -24,8 +24,13 @@ export default Service.extend({ this.configure(); } }, - - load() { + + unload() { + this.set('didConfigure', false); + this.set('didLoad', false); + }, + + load(params) { let lazyLoad = this.get('lazyLoad'); let mock = this.get('mock'); let shouldLoad = lazyLoad && !mock @@ -33,19 +38,27 @@ export default Service.extend({ let doLoad = shouldLoad ? loadScript("https://js.stripe.com/v3/") : resolve(); return doLoad.then(() => { - this.configure(); + this.configure(params); this.set('didLoad', true); }); }, - configure() { + configure(params) { let didConfigure = this.get('didConfigure'); if (!didConfigure) { let publishableKey = this.get('publishableKey'); - let { elements, createToken, createSource, retrieveSource, paymentRequest } = new Stripe(publishableKey); - setProperties(this, { elements, createToken, createSource, retrieveSource, paymentRequest }); + var _ref = new Stripe(publishableKey, params); + + setProperties(this, { + ref: _ref, //only used for debug + elements: _ref.elements, + createToken: _ref.createToken, + createSource: _ref.createSource, + retrieveSource: _ref.retrieveSource, + paymentRequest: _ref.paymentRequest, + }); this.set('didConfigure', true); }