gtramontina / stripe-angular Goto Github PK
View Code? Open in Web Editor NEWAngular directives to deal with Stripe.
Angular directives to deal with Stripe.
It would be better to add disabled attr to fieldset, instead of a button. Can submit a pull request if you agree with me :)
I have a form with various steps, the last one is the "review order" one with the confirm button, that charges the user.
this section is accessible only if the user has already a stripe single-use token generated for him in the previous step, where the form gets submitted and the response is handled.
By the way, even if the button in the final step isn't a submit button, the form gets submitted again, the stripe's api gets called with i don't know what values and the api respondes with a 400(Bad Request) status code.
EDIT(workaround)
changing the button to an a fixes the problem and the form doesn't get submitted again.
previous:
<button class="btn btn-primary" ng-click="charge()">Confirm</button>
edited:
<a class="btn btn-primary" ng-click="charge()">Confirm</a>
This is exactly what I need.
Thanks.
I got following error on javascript console:
m.stripe.network/inner.html#referrer=http%3A%2F%2Flocalhost%3A3000%2Fcampai…c78-d54be95e7fe1&sid=50ce770d-87a4-434c-a162-0da7cb878503&preview=false&:1 Uncaught (in promise) undefined
But all process like downgrade, upgrade plan is working fine. Don't know what is this issue is about.
I get this error Failed to instantiate module myApp due to: Error: [$injector:unpr] Unknown provider: Stripe
When I try to include the library as follows:
angular.module('myApp', ['stripe]).config(function (Stripe) { Stripe.setPublishableKey('my_key'); })
Both uppercase and lowercase fail.
This was installed with bower and I see stripe-angular
in my bower_components folder.
Since Bower is trying to go away, is there any way you would consider adding support for npm and/or yarn?
Right now the directive returns a single-use-token, not a stripeCustomerId. Think it would be nice if the README made that clear and then pointed people to https://stripe.com/docs/tutorials/charges if they want to generate a stripeCustomerId for charges at a later time.
angular.module('stripe', []).directive('stripeForm', ['$window',
function($window) {
var directive = { restrict: 'A' };
directive.link = function(scope, element, attributes) {
if(!$window.Stripe){
throw 'stripeForm is not included in the HTML.';
}
var form = angular.element(element);
form.bind('submit', function() {
var button = form.find('button');
button.prop('disabled', true);
// can either pass an object or can parse a form with data-stripe attributes
$window.Stripe.createToken(form[0], function() {
// after getting token, reenable form
button.prop('disabled', false);
console.log(scope[attributes.stripeForm]);console.log(scope);
var args = arguments;
scope.$apply(function() {
scope[attributes.stripeForm].apply(scope, args);
});
});
});
};
return directive;
}]);
Here is the full error:
TypeError: Cannot read property 'apply' of undefined
at http://localhost:8100/lib/stripe-angular/stripe-angular.js:22:39
at Scope.$eval (http://localhost:8100/lib/ionic/js/ionic.bundle.js:20326:28)
at Scope.$apply (http://localhost:8100/lib/ionic/js/ionic.bundle.js:20424:23)
at http://localhost:8100/lib/stripe-angular/stripe-angular.js:21:15
at Object.e.request.success (https://js.stripe.com/v2/:1:1697)
at window.(anonymous function) (https://js.stripe.com/v2/:1:10496)
at https://api.stripe.com/v1/tokens?card[number]=4242424242424242&card[cvc]=12…er_agent=stripe.js%2F4871079&callback=sjsonp1418772119600&_method=POST:1:1
This code is exactly the same as what exists in your stripe-angular.js file as far as I can tell. What would cause this issue to happen?
There were also a few gaps in the setup of stripe-angular in my project. Not sure if this is an error on my part of if there is something else missing from the docs here.
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.