code-corps / ember-stripe-service Goto Github PK
View Code? Open in Web Editor NEWAn ember-cli addon which injects Stripe as an Ember service
License: MIT License
An ember-cli addon which injects Stripe as an Ember service
License: MIT License
I'm wondering why https://github.com/ride/ember-stripe-service/blob/master/app/services/stripe.js#L12 exists
Inch CI can crawl documentation and keep us updated on the state of documentation across the project. This is an issue for tracking the steps needed to integrate ember-stripe-service with inch-ci
inch.json
and configure to crawl the correct foldersstripe terminal is slated to be out of beta within the next few months and would be great if that would be supported. I'm in the beta now and would be happy to do some legwork to add support for this.
Injecting the stripe service into a controller that is rendered by FastBoot currently throws an exception:
Ember FastBoot running at http://[::]:4200
ReferenceError: Stripe is not defined
at Object.initialize (/.../dist/fastboot/ui.js:903:5)
Looks like there's been some work done recently โ should we cut a release?
Are there any plans to support the stripe v3 api?
the stripe docs currently state:
Starting September 2019, a new regulation called Strong Customer Authentication (SCA) will require businesses in Europe to request additional authentication for online payments. To be ready for these rule changes, we recommend that all European businesses start building their Stripe integration with either our PaymentIntents API or our new Checkout.
Migrating your Stripe integration
If your Stripe integration does not yet use Stripe.js v3 and Elements, you may wish to first update your integration accordingly before adopting PaymentIntents. It is, however, still possible to use PaymentIntents without Elements by creating a source on the client side and attaching it to the PaymentIntent.
I am not 100% sure yet if this really requires the use of v3, but still it might be a good idea to support. I noticed that there also is ember-stripe-elements which uses v3, however that appears to be no longer maintained? how is that project related to this repo?
Most of our users and most pages in the app don't have anything to do with billing. I'd really like to be able to do something like
// route:billing
export default Ember.Route.extend({
stripe: Ember.inject.service(),
beforeModel: function() {
return this.get('stripe').fetchJS();
}
});
Where fetchJS
would (a) return a resolved promise if window.Stripe
is already defined, or (b) fetch and evaluate stripe.js
and return a pending Promise that resolves when the library becomes available.
This would let us save a network request and some JS evaluation time for most users.
v7.0.0: stripe.js, lines 175 and 184 - swap Ember.logger.info to console.log
This should be false
in released Ember addons.
See https://github.com/dockyard/ember-suave/issues/67 and ember-animation/liquid-fire#383.
Is there any easy way to use Stripe's checkout.js
with this? I'm just getting started with Stripe.
Ember's default Promise.on('error')
hook causes the current test to fail if it ever encounters a reject({ anything: "here" })
. Because this library uses reject
to indicate that the update failed, I can't write a test that asserts that I show an appropriate error message in case of failure.
I think this should be changed in Ember, but if they're going to hold firm, we should probably change it here.
I'm getting a ReferenceError: document is not defined
error when loading a route with Fastboot that lazy loads Stripe.
Any pointers would be welcomed!
My process works fine when I run it normally but fails during Acceptance test.
Is it possible for you to help me figure out what I'm doing wrong?
I'm kind of new to Ember Acceptance tests so I'm probably missing something simple.
Uncaught TypeError: Cannot read property 'assert' of undefined
at Class.asyncStart (adapter.js:10)
at Object.asyncStart (ember.debug.js:38454)
at Object.async (ember.debug.js:37626)
at fulfill (ember.debug.js:58105)
at handleMaybeThenable (ember.debug.js:58067)
at resolve (ember.debug.js:58080)
at resolvePromise (ember.debug.js:58216)
at stripe.js:46
at Object.success ((index):2)
at Object.<anonymous> ((index):3)
we want to be able to change between testing and production based on the REST-interface we are currently using. therefore, our REST-interface should set the STRIPE_CLIENT_KEY
.
we lack a good solution to the problem, a simple interface which lets us set that value on runtime.
i could extend the library so that the key can also be set/changed during runtime. what about that?
Hola @buritica! ๐
I found your this stripe wrapper through emberobserver
I see that the latest build version 4.0.0
is failing: https://travis-ci.org/ride/ember-stripe-service/builds
I can see it's failing with recent versions of Ember only: https://travis-ci.org/ride/ember-stripe-service/builds/71610063
Nevertheless I see the latests version you pushed 4.1.0
, although no build was triggered.
Is the build fixed in that version? Is it possible if you trigger latest build, or is there a way I can help you?
Thanks in advance! Cheers! ๐ธ
While this library works for creating a Stripe token for a card, there's no way to edit a credit card. I need this feature for allowing users to correct expired/failing credit cards
In test mode (at least in environments without networking), the <script>
tag that this addon injects won't run and Stripe won't be defined. That means Stripe.setPublishableKey
won't exist and the initializer will fail.
The smallest change I can think of that would work (which I've used locally successfully) is
// app/services/stripe.js
function createToken (card) {
Ember.assert("Cannot create Stripe token in test environment", config.environment !== 'test');
// ...
}
// app/initializers/stripe-service.js
export function initialize() {
if (config.environment === 'test') { return; }
// ...
}
This isn't perfect, but it's pretty good. I end up stubbing out stripe.createToken
whenever I need to actually run that function, with without a standard stubbing library, I can't think of a good way of doing this here.
trying to run STRIPE_PUBLISHABLE_KEY="TEST_KEY" ember try:one "ember-beta" test --skip-cleanup
in a fresh environment after cloning the repo in my local machine gives me an error on the following test
not ok 4 PhantomJS 2.1 - Acceptance | Publishable Key: it throws an error if config.stripe.publishableKey is not set
---
actual: >
false
expected: >
true
stack: >
exception@http://localhost:7357/assets/test-support.js:13640:49
adapterDispatch@http://localhost:7357/assets/vendor.js:52173:22
dispatchError@http://localhost:7357/assets/vendor.js:30366:23
invokeWithOnError@http://localhost:7357/assets/vendor.js:12778:14
flush@http://localhost:7357/assets/vendor.js:12834:15
flush@http://localhost:7357/assets/vendor.js:12958:20
end@http://localhost:7357/assets/vendor.js:13028:28
run@http://localhost:7357/assets/vendor.js:13142:19
run@http://localhost:7357/assets/vendor.js:34994:32
startApp@http://localhost:7357/assets/tests.js:231:26
http://localhost:7357/assets/tests.js:54:49
throws@http://localhost:7357/assets/test-support.js:4138:17
http://localhost:7357/assets/tests.js:53:18
runTest@http://localhost:7357/assets/test-support.js:3292:34
run@http://localhost:7357/assets/test-support.js:3278:13
http://localhost:7357/assets/test-support.js:3454:15
advance@http://localhost:7357/assets/test-support.js:2963:26
begin@http://localhost:7357/assets/test-support.js:4613:27
http://localhost:7357/assets/test-support.js:4573:11
message: >
Error: StripeService: Missing Stripe key, please set `ENV.stripe.publishableKey` in config.environment.js
Log: |
{ type: 'info', text: '\'StripeService: initialize\'\n' }
{ type: 'error', text: 'null\n' }
{ type: 'error', text: 'null\n' }
...
you can see the test failing because of that in recent versions of Ember: #55
and also in this pull request also fails because of that #54
do you have any hint how to solve that?, I tried different approaches but they didn't worked, I tried to read ember's new deprecations and new release notes but they didn't say anything related to that, maybe you people know what to do
in stripe.js you call Ember.run.begin();
and Ember.run.end()
and I was wondering why you'd want to do that? Isn't that a bit unusual?
function createCardToken (card) {
// manually start Ember loop
Ember.run.begin();
return new Ember.RSVP.Promise(function (resolve, reject) {
Stripe.card.createToken(card, function (status, response) {
if (response.error) {
reject(response);
return Ember.run.end();
}
resolve(response);
Ember.run.end();
});
});
}
function createBankAccountToken(bankAccount) {
// manually start Ember loop
Ember.run.begin();
return new Ember.RSVP.Promise(function (resolve, reject) {
Stripe.bankAccount.createToken(bankAccount, function (status, response) {
if (response.error) {
reject(response);
return Ember.run.end();
}
resolve(response);
Ember.run.end();
});
});
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.