MethodNotAllowedHttpException on Form Submission Stripe.js

MethodNotAllowedHttpException on Form Submission Stripe.js

By : 幻影显形
Date : November 29 2020, 09:01 AM
this one helps. In your routes file you defined the path as a GET request but your form submission is doing a POST request either change your form to submit as a GET request or update your routes so it is a POST request
code :

Share : facebook icon twitter icon
Form submission with Stripe and Rails

Form submission with Stripe and Rails

By : Bilal Medaci
Date : March 29 2020, 07:55 AM
I wish this help you Okay, so I figured out what's going on here. After a lot more testing I realized that if I hit refresh on the page, and then filled out the form and submitted it, it worked every time. But, if I navigated to the subscription_path through the app, it would create an error unless you manually refreshed the page after getting there.
So...after a lot of digging around I found out that the problem is with Turbolinks. This post helped me figure out how to fix the problem: Rails 4: how to use $(document).ready() with turbo-links. From what I can gather, jQuery wasn't loading up Stripe.js because of turbo-links.
How can I trigger stripe token generation from an ng-click or controller event instead of a form submission?

How can I trigger stripe token generation from an ng-click or controller event instead of a form submission?

By : D. A.
Date : March 29 2020, 07:55 AM
will be helpful for those in need I over complicated this entirely. All of the stripe examples that I'd seen were done with jQuery so I was trying to re-invent that into angular. It became much easier when I simply looked into the methods provided with stripe. For example tokenization looks like this Stripe.card.generateToken(card, callback()); Card is just an object provided you pull the right properties from their documentation. So throwing that into an ng-clickable function was not a problem.
Angular Stripe - Converting Stripe Payment Form to Stripe Elements

Angular Stripe - Converting Stripe Payment Form to Stripe Elements

By : Srinath
Date : March 29 2020, 07:55 AM
I wish did fix the issue. I have now changed the Controller to a directive and placed all the jquery and angular codes inside the Link function. This is how my directive code looks like after the update:
code :
function stripeForm() {

        // Link Function
        function link(scope, element, attrs) {

            scope.submitCard = submitCard;

            var elements = stripe.elements();
            var style = {
                          iconStyle: 'solid',
                          style: {
                            base: {
                              iconColor: '#8898AA',
                              color: '#000',
                              lineHeight: '36px',
                              fontWeight: 300,
                              fontFamily: 'Helvetica Neue',
                              fontSize: '19px',

                              '::placeholder': {
                                color: '#8898AA',
                            invalid: {
                              iconColor: '#e85746',
                              color: '#e85746',
                          classes: {
                            focus: 'is-focused',
                            empty: 'is-empty',
            var card = elements.create('card', style);

            // Handle real-time validation errors from the card Element.
            card.on('change', function(event) {

            // Form Submit Button Click
            function submitCard() {
                var errorElement = document.querySelector('.error');

            // Send data directly to stripe server to create a token (uses stripe.js)
            function createToken() {

            // Common SetOutcome Function
            function setOutcome(result) {
                var errorElement = document.querySelector('.error');
                if (result.token) {
                  // Use the token to create a charge or a customer
                } else if (result.error) {
                  errorElement.textContent = result.error.message;

            // Response Handler callback to handle the response from Stripe server
            function stripeTokenHandler(token) {
                ..send to server ...

        // DIRECTIVE
        return {
            restrict: 'A',
            replace: true,
            templateUrl: 'payment/PaymentForm.html'
            link: link
<form ng-submit="submitCard()">
        <div id="card-element" class="field"></div>
        <button class="btn btn-primary pull-right" type="submit">Pay!</button>
        <button class="btn btn-danger pull-left" type="button" ng-click="cancel()">Cancel</button>
      <div class="error"></div>
Prevent stripe form from submission

Prevent stripe form from submission

By : Gaurav Singh
Date : March 29 2020, 07:55 AM
I hope this helps you . It seems error is in your jquery (means jquery is generating error), because of it form is not preventing. Check it carefully on your development site.
How to access Stripe token from form POST submission in Python?

How to access Stripe token from form POST submission in Python?

By : Enigma
Date : March 29 2020, 07:55 AM
hope this fix your issue I'm using pretty much the standard Stripe code to obtain a token which I can see from the console is successful and then I am passing that in a hidden input form field to my Python app. , You want to use:
code :
document.getElementById('stripe-token-return').value = result.token.id;
Related Posts Related Posts :
  • convert select DB::table to array on laravel
  • Lumen Blade result to array gives empty value
  • Where to put migration within a Laravel 5.1 package?
  • Cannot change rydurham/sentinel default page design in laravel 4.2
  • Detecting specific exceptions Laravel 5.1
  • Laravel 5.1 AuthController user registration unique random id
  • Difference between before and after middleware in Laravel 5.1
  • How to reference a custom class in Laravel 5.1?
  • Laravel cron not working automatically
  • laravel register custom validator
  • Laravel 5 and Entrust. How to create subscription model based on roles and assignment
  • Hidden Laravel Methods (5.1)
  • Including page layout to Laravel project
  • Impossible to modify the localization in Lumen
  • Laravel: display data in view without Eloquent
  • Behaviour of routing in laravel
  • ReflectionException Controller does not exist error in Lumen
  • Laravel eloquent get all from one table and one from another
  • Changing the name of the "users" table to account Laravel 5
  • Laravel 5 - change default log location, move log file outside the app
  • Laravel Get created_at in Millisecond Timestamp
  • Need an efficient way to avoid repeated code snippets using Laravel 5
  • Laravel Authentication With Two Tables
  • How to check migration status?
  • How to stop laravel directory browsing
  • How to echo (array with $i) blade in Laravel 5.2?
  • Laravel Function at Scheduler
  • shadow
    Privacy Policy - Terms - Contact Us © animezone.co