-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added handling of parameters of stripev3.load #35
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,7 @@ package.json.ember-try | |
|
||
.DS_Store | ||
yarn-error.log | ||
|
||
#Eclipse | ||
.settings | ||
.project |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,7 +43,7 @@ export default Component.extend({ | |
// Fetch autofocus, set by user | ||
let autofocus = get(this, 'autofocus'); | ||
let stripeElement = get(this, 'stripeElement'); | ||
let iframe = this.element.querySelector('iframe') | ||
let iframe = this.element.querySelector('iframe'); | ||
if (autofocus && iframe) { | ||
iframe.onload = () => { | ||
stripeElement.focus(); | ||
|
@@ -64,6 +64,25 @@ export default Component.extend({ | |
|
||
setEventListeners() { | ||
let stripeElement = get(this, 'stripeElement'); | ||
stripeElement.on('ready', (event) => this.sendAction('ready', stripeElement, event)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The changes to this file need to be removed because they are unrelated to what this PR is trying to do - i.e. add options to the |
||
stripeElement.on('blur', (event) => this.sendAction('blur', stripeElement, event)); | ||
stripeElement.on('focus', (event) => this.sendAction('focus', stripeElement, event)); | ||
stripeElement.on('change', (...args) => { | ||
let [{ complete, error: stripeError }] = args; | ||
this.sendAction('change', stripeElement, ...args); | ||
|
||
if (complete) { | ||
this.sendAction('complete', stripeElement); | ||
} else if (stripeError) { | ||
this.sendAction('error', stripeError); | ||
} | ||
|
||
set(this, 'stripeError', stripeError); | ||
}); | ||
} | ||
|
||
/*setEventListeners() { | ||
let stripeElement = get(this, 'stripeElement'); | ||
|
||
stripeElement.on('ready', (event) => { | ||
this._invokeAction('ready', stripeElement, event) | ||
|
@@ -110,5 +129,5 @@ export default Component.extend({ | |
focus() { }, | ||
change() { }, | ||
complete() { }, | ||
error() { } | ||
error() { }*/ | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,8 +43,13 @@ export default Service.extend({ | |
this.configure(); | ||
} | ||
}, | ||
|
||
load(publishableKey = null) { | ||
|
||
unload() { | ||
this.set('didConfigure', false); | ||
this.set('didLoad', false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In |
||
}, | ||
|
||
load(publishableKey = null, params = null) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we set the |
||
if (publishableKey) { | ||
this.set('publishableKey', publishableKey); | ||
} | ||
|
@@ -56,12 +61,12 @@ 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) { | ||
|
@@ -71,7 +76,7 @@ export default Service.extend({ | |
throw new EmberError("stripev3: Missing Stripe key, please set `ENV.stripe.publishableKey` in config.environment.js"); | ||
} | ||
|
||
let stripe = new Stripe(publishableKey); | ||
let stripe = new Stripe(publishableKey, params); | ||
let functions = getProperties(stripe, STRIPE_FUNCTIONS); | ||
setProperties(this, functions); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change isn't necessary. If it's the editor you use, then it should be in your global gitignore not here.