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

undefined is not an object #69

Closed
radar opened this issue Sep 17, 2015 · 14 comments
Closed

undefined is not an object #69

radar opened this issue Sep 17, 2015 · 14 comments

Comments

@radar
Copy link

radar commented Sep 17, 2015

When running the JS tests for my app (radar/twist@cf16123) (my-sass branch), they fail with this error:

     Failure/Error: click_button "Create Account"
     Capybara::Poltergeist::JavascriptError:
       One or more errors were raised in the Javascript code on the page. If you don't care about these errors, you can ignore them by setting js_errors: false in your Poltergeist configuration (see documentation for details).

       TypeError: undefined is not an object (evaluating 'this.views[this.currentView].handleRequestNonce')
       TypeError: undefined is not an object (evaluating 'this.views[this.currentView].handleRequestNonce')
           at https://assets.braintreegateway.com/dropin/1.3.12/braintree-dropin-internal.min.js:7 in handleNonceRequest
           at https://assets.braintreegateway.com/dropin/1.3.12/braintree-dropin-internal.min.js:5 in e
           at https://assets.braintreegateway.com/dropin/1.3.12/braintree-dropin-internal.min.js:3 in _handleRequest

I don't know why this is. I would expect the Braintree drop-in to Just Work(tm), but that is definitely not the case here.

I have tried following the advice in #19, but it is cryptic. You can see my attempt here.

Please advise what I need to do to prevent this error from happening.

@EvanHahn
Copy link

@radar I'm cloning your repo now and will try to reproduce this—stay tuned!

@EvanHahn
Copy link

@radar I was unable to get your app running in a VM. Could you try updating to https://js.braintreegateway.com/js/braintree-2.14.2.js (looks like it's this line) and seeing if that fixes things?

@radar
Copy link
Author

radar commented Sep 27, 2015

Hi @EvanHahn, I tried updating it to 2.14.2 but I get the same error there.

What problems did you run into with the application?

@EvanHahn
Copy link

@radar I set up a Vagrant box and was unable to install the json gem when doing a bundle install. I had a colleague of mine with much more Rails experience take a look, but he was stumped too.

Do you happen to have step-by-step instructions for getting this set up on an Ubuntu VM? That would really help.

@radar
Copy link
Author

radar commented Sep 29, 2015

Please follow the instructions here: http://ryanbigg.com/2014/10/ubuntu-ruby-ruby-install-chruby-and-you/. That should give you a decent setup for Ruby and Rails.

If you tell me exactly what steps are failing then I can guide you from there. Give me as much info as possible.

@mrak
Copy link
Contributor

mrak commented Oct 7, 2015

@radar have you tried disabling Turbolinks in your rails app? It has been known to cause issues with some of our SDK functionality.

@radar
Copy link
Author

radar commented Oct 7, 2015

Please kindly point out where in the application's Gemfile I am using turbolinks. I do not see it anywhere.

@mrak
Copy link
Contributor

mrak commented Oct 7, 2015

It may not be in your Gemfile or Gemfile.lock as I believe Rails 4+ ships with turbolinks by default. (described in Rails' guide on Working with JavaScript in Rails)

Some known issues that cause trouble are documented in the turbolinks README and may apply to the phantomjs versions used by Capybara/Poltergeist.

Could you try Opting out of Turbolinks and see if it makes any difference?

@radar
Copy link
Author

radar commented Oct 7, 2015

I wrote a book about Rails. I know how it works. There is no Turbolinks within this application. Stop trying to palm it off on it being a Turbolinks problem, because it is not a Turbolinks problem.

For proof: If I look for "turbolinks" in either Sublime Text 3 or iTerm by running "ack 'turbolinks'", neither of them return a result.

Can I please get someone to help with this who knows Rails?

@radar
Copy link
Author

radar commented Oct 7, 2015

Sorry, I've been told that was a bit harsh. I would like to apologise for that. It's upsetting to me to be told that this is a turbolinks problem because I can see very obviously it isn't, and it makes me feel like you haven't even bothered to clone down my application and run it.

Is there something that is preventing you from doing that? I would really appreciate some help with this and anything I can do to get the help of an experienced Braintree developer.

Would it make it easier if we could pair on this over something like Skype/Google Hangouts?

@pblesi
Copy link

pblesi commented Oct 7, 2015

@radar We have successfully reproduced the error on our end and will dig further into the issues causing it. Upon first glance, the issue appears to be isolated to the testing suite.

@radar
Copy link
Author

radar commented Oct 8, 2015

Thank you @pblesi.

@pblesi
Copy link

pblesi commented Oct 8, 2015

@radar, We have identified the issue. The issue is that you are attempting to click the "Create Account" submit button before Drop-in is fully loaded. This is an issue that a user could encounter as well if they click the submit button before Drop-in has loaded. It is for this reason that we recommend you disable the button by default and then enable it once Drop-in has loaded.

<%= account.submit class: "btn btn-primary", disabled: true %>
  braintree.setup(
    "<%= @client_token %>",
    'dropin', {
      container: 'dropin',
      paymentMethodNonceReceived: function (event, nonce) {
      },
      onReady: function () {
        console.log('Braintree is ready');
        $('#new_account input[type=submit]').removeProp('disabled');
      }
    }
  );

Let us know if you run into more issues.

@radar
Copy link
Author

radar commented Oct 11, 2015

Excellent, thank you @pblesi :) I will try filling in the field for Braintree's form before hitting the "Create Account" button and I'll let you know how it goes.

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

No branches or pull requests

5 participants