Skip to content
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

Ability to pass options to stripe.elements() #33

Open
fotinakis opened this issue Apr 4, 2018 · 9 comments
Open

Ability to pass options to stripe.elements() #33

fotinakis opened this issue Apr 4, 2018 · 9 comments

Comments

@fotinakis
Copy link

Hello! Thanks for creating this addon, it's awesome.

Is there a way to pass the options hash on init to stripe.elements(options)? This is different than the per-element options hash.
https://stripe.com/docs/stripe-js/reference#stripe-elements

I believe the init is this line: https://github.com/code-corps/ember-stripe-elements/blob/0.3.0/addon/components/stripe-element.js#L16

@fotinakis
Copy link
Author

Ping here, any ideas or direction on this? We want to be able to use custom fonts with Stripe Elements, which require the ability to pass initialization options.

@jackhair
Copy link

jackhair commented May 8, 2018

We managed to use custom fonts by passing them in the style object, same way detailed here: https://github.com/code-corps/ember-stripe-elements#block-usage-with-options

@PixelJanitor
Copy link

@jackhair Can you share a snippet of the code you used to get this working? We're trying to utilize a Typekit font, so we need to pass in the stylesheet for it to load similar to https://gist.github.com/matthooks/03d7c741cd48789a140b1503193b0b6c

@jackhair
Copy link

@PixelJanitor That is pretty much what we did. I'll give a brief overview. Bear in mind we're pulling from master branch, as we couldn't use the individual fields without this PR: #26

Component containing stripe form:

options: {
  style: {
    base: {
      fontFamily: '"Custom Font Name", Helvetica, sans-serif'
    }
  }
},

init() {
  this._super(...arguments);
  let elements = this.get('stripe').elements({
    fonts: [{
      cssSrc: 'https://example.com/stylesheet.css',
    }]
  });
  this.set('cardElements', elements);
},

Component template:

{{#stripe-card-number id="cardnumber" elements=cardElements options=options change=(action (mut stripeElement)) as |stripeElement stripeError|}}
   ...
{{/stripe-card-number}}

@joshsmith
Copy link
Contributor

Just an update to @jackhair's comment here that you should be able to use version 0.4.0 and up now rather than pull from master.

@idgm81
Copy link

idgm81 commented Aug 8, 2019

Hey guys!

As you can read in the documentation https://github.com/code-corps/ember-stripe-elements#block-usage-with-options, it can be possible to pass options object to component context but then why options object is always initialized as "{}" on init hook

? it's a bug?

@lindyhopchris
Copy link
Contributor

@idgm81 haven't tried it, have you confirmed it doesn't work? If so, maybe open a separate issue and/or submit a PR?

@lindyhopchris
Copy link
Contributor

Actually @idgm81 you're right that it does look like a bug. I'll fix now.

@idgm81
Copy link

idgm81 commented Aug 10, 2019

Great @lindyhopchris , I also found that style object at

is wrong, style object is passed as property shorthand to stripe-element "create" function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants