Giter Club home page Giter Club logo

fake_braintree's People

Contributors

alexbartlow avatar birarda avatar brandon-beacher avatar bwittenbrook3 avatar chrishunt avatar clemens avatar gabebw avatar jferris avatar larrylv avatar m1k3 avatar mattknox avatar mike-burns avatar mislav avatar mjc-gh avatar netoneko avatar r00k avatar sorentwo avatar southgate avatar twalpole avatar wacii avatar yepitschunked avatar zamith avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fake_braintree's Issues

Use outside of ruby?

I'd like to use fake_braintree when testing some python code.

Since it looks like this just starts a local server, I'm planning to point the python client library at it - there's a development config for it as well - and hope for the best. Does this sound reasonable? ๐Ÿ˜

If it does, do you know how I can start up the server and leave it running indefinitely? Running a file with just require "fake_braintree" exits immediately without errors.

Once I've got that working I should be set -- I'll just need to manage that process during my python testing.

Can't hit the sinatra app

I keep getting:

 ActionController::RoutingError:
   No route matches [POST] "/merchants/xxx/transparent_redirect_requests"

Even though the sinatra server is supposedly running. I can make request with curl and get the correct response. Not sure what's happening here.

i18n gem

Is there a reason why i18n is a dependency? I do not see any use of it in the code. I ask because including fake_braintree in a rails application yields these deprecation errors:

[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.

And will have to resort to something like this for fixing it.

FakeBraintree.transaction has a bizarre return value

I'm on 0.0.6.

FakeBraintree.transaction returns this (for an example transaction):
{"261c5147c60b9c7636f482a8c69c4ef7"=>{"id"=>"261c5147c60b9c7636f482a8c69c4ef7", "amount"=>"81.24"}}

Keying the return value by an id doesn't seem to make sense. Users of the API will need to know the id the transaction created, which they often won't.

Anyone using this with vZero?

I'm not having good luck with VCR and Braintree so looking at solutions.

This looks like it could be perfect except I'm not certain if it supports VZero or not

And also it has not had any commits since 2016

Is anyone using this with Braintree now? Any forks or branches you can suggest?

Braintree::UnexpectedError: expected a gzipped response

While using fake_braintree, every action which creates a braintree request fails due to Braintree::UnexpectedError: expected a gzipped response. Although this may look like #48 i don't use redirects but instead server-to-server api.

How to reproduce this problem:

require 'fake_braintree'
FakeBraintree.activate!
result = Braintree::Customer.create(
    :credit_card => {
     :payment_method_nonce => Braintree::Test::Nonce::Transactable,
     :options => {
       :verify_card => true
     }
  }
)

And the backtrace

NoMethodError - undefined method `[]' for nil:NilClass:
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/fake_braintree-0.6.0/lib/fake_braintree/customer.rb:113:in `generate_credit_cards_from'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/fake_braintree-0.6.0/lib/fake_braintree/customer.rb:66:in `customer_hash'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/fake_braintree-0.6.0/lib/fake_braintree/customer.rb:82:in `invalid_credit_card?'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/fake_braintree-0.6.0/lib/fake_braintree/customer.rb:49:in `invalid?'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/fake_braintree-0.6.0/lib/fake_braintree/customer.rb:16:in `create'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/fake_braintree-0.6.0/lib/fake_braintree/sinatra_app.rb:25:in `block in <class:SinatraApp>'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/sinatra-1.4.5/lib/sinatra/base.rb:1603:in `call'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/sinatra-1.4.5/lib/sinatra/base.rb:1603:in `block in compile!'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/sinatra-1.4.5/lib/sinatra/base.rb:966:in `[]'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/sinatra-1.4.5/lib/sinatra/base.rb:966:in `block (3 levels) in route!'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/sinatra-1.4.5/lib/sinatra/base.rb:985:in `route_eval'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/sinatra-1.4.5/lib/sinatra/base.rb:966:in `block (2 levels) in route!'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/sinatra-1.4.5/lib/sinatra/base.rb:1006:in `block in process_route'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/sinatra-1.4.5/lib/sinatra/base.rb:1004:in `catch'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/sinatra-1.4.5/lib/sinatra/base.rb:1004:in `process_route'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/sinatra-1.4.5/lib/sinatra/base.rb:964:in `block in route!'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/sinatra-1.4.5/lib/sinatra/base.rb:963:in `each'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/sinatra-1.4.5/lib/sinatra/base.rb:963:in `route!'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/sinatra-1.4.5/lib/sinatra/base.rb:1076:in `block in dispatch!'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `block in invoke'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `catch'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `invoke'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/sinatra-1.4.5/lib/sinatra/base.rb:1073:in `dispatch!'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/sinatra-1.4.5/lib/sinatra/base.rb:898:in `block in call!'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `block in invoke'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `catch'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `invoke'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/sinatra-1.4.5/lib/sinatra/base.rb:898:in `call!'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/sinatra-1.4.5/lib/sinatra/base.rb:886:in `call'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/rack-protection-1.5.3/lib/rack/protection/xss_header.rb:18:in `call'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/rack-protection-1.5.3/lib/rack/protection/path_traversal.rb:16:in `call'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/rack-protection-1.5.3/lib/rack/protection/json_csrf.rb:18:in `call'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/rack-protection-1.5.3/lib/rack/protection/frame_options.rb:31:in `call'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/rack-1.6.0/lib/rack/nulllogger.rb:9:in `call'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/rack-1.6.0/lib/rack/head.rb:13:in `call'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/sinatra-1.4.5/lib/sinatra/base.rb:180:in `call'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/sinatra-1.4.5/lib/sinatra/base.rb:2014:in `call'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/sinatra-1.4.5/lib/sinatra/base.rb:1478:in `block in call'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/sinatra-1.4.5/lib/sinatra/base.rb:1788:in `synchronize'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/sinatra-1.4.5/lib/sinatra/base.rb:1478:in `call'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/capybara-2.4.4/lib/capybara/server.rb:19:in `call'
    /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/rack-1.6.0/lib/rack/handler/webrick.rb:89:in `service'
    /Users/michal/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/webrick/httpserver.rb:138:in `service'
    /Users/michal/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/webrick/httpserver.rb:94:in `run'
    /Users/michal/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/webrick/server.rb:295:in `block in start_thread'
Braintree::UnexpectedError: expected a gzipped response
from /Users/michal/.rvm/gems/ruby-2.1.5@my_gemset/gems/braintree-2.38.0/lib/braintree/http.rb:100:in `_body'

My setup
fake_braintree (0.6.0)
rails (4.2.0)
braintree (2.38.0)
ruby 2.1.5

Please feel free to to ask me for additional info. Thanks in advance guys!

Rails 5 error

I get this error after migrating to Rails 5. I have attached the relevant error message below . It's an easy fix but as far as I can see, this gem doesn't look like it's going to get updated in the near future.

Any plans for a version bump any time soon? ๐Ÿ˜€

TypeError - no implicit conversion of nil into Hash:
/.rvm/gems/ruby-2.3.0/gems/fake_braintree-0.8.0/lib/fake_braintree/customer.rb:215:in merge!' /.rvm/gems/ruby-2.3.0/gems/fake_braintree-0.8.0/lib/fake_braintree/customer.rb:215:in load_payment_method!'
/.rvm/gems/ruby-2.3.0/gems/fake_braintree-0.8.0/lib/fake_braintree/customer.rb:23:in create' /.rvm/gems/ruby-2.3.0/gems/fake_braintree-0.8.0/lib/fake_braintree/sinatra_app.rb:86:in block in <class:SinatraApp

Can't use in conjunction with WebMock

We are already using WebMock for other tests and it seems to be incompatible with FakeBraintree. I attempted to configure WebMock to allow connections on 127.0.0.1, but it seems that FakeBraintree is attempting to make a connection in the bundler require, before I get a chance to make this configuration. Is there anything that could make the two gems work in harmony?

How can I run the tests in a forked repo?

I forked this repo and I have the code in /lib/fake_braintree-0.7.0 (open to suggestions on where the standard place to put a forked repo in your project is. this is the first time I've done it).

I'm trying to follow the readme and the principles of TDD and run the tests, then write my test for the feature I'm adding, then add the feature.

This is what I'm trying in my root directory:

rspec lib/fake_braintree-0.7.0/spec/fake_braintree
/Users/gregblass/apps/myapp/lib/fake_braintree-0.7.0/spec/fake_braintree/registry_spec.rb:3:in `<top (required)>': uninitialized constant FakeBraintree::Registry (NameError)
from /Users/gregblass/.rvm/gems/ruby-2.2.2@myapp/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1327:in `load'
from /Users/gregblass/.rvm/gems/ruby-2.2.2@myapp/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1327:in `block in load_spec_files'
from /Users/gregblass/.rvm/gems/ruby-2.2.2@myapp/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1325:in `each'
from /Users/gregblass/.rvm/gems/ruby-2.2.2@myapp/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1325:in `load_spec_files'
from /Users/gregblass/.rvm/gems/ruby-2.2.2@myapp/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:102:in `setup'
from /Users/gregblass/.rvm/gems/ruby-2.2.2@myapp/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:88:in `run'
from /Users/gregblass/.rvm/gems/ruby-2.2.2@myapp/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:73:in `run'
from /Users/gregblass/.rvm/gems/ruby-2.2.2@myapp/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:41:in `invoke'
from /Users/gregblass/.rvm/gems/ruby-2.2.2@myapp/gems/rspec-core-3.3.2/exe/rspec:4:in `<top (required)>'
from /Users/gregblass/.rvm/gems/ruby-2.2.2@myapp/bin/rspec:23:in `load'
from /Users/gregblass/.rvm/gems/ruby-2.2.2@myapp/bin/rspec:23:in `<main>'
from /Users/gregblass/.rvm/gems/ruby-2.2.2@myapp/bin/ruby_executable_hooks:15:in `eval'
from /Users/gregblass/.rvm/gems/ruby-2.2.2@myapp/bin/ruby_executable_hooks:15:in `<main>'

What am I missing here?

No Rack handler was defined!

fake_braintree-0.5.0/lib/fake_braintree/server.rb:34:in 'handler': No Rack handler was defined! Please include gem "thin" or gem "puma" in your Gemfile." (RuntimeError).

Using capybara-webkit.

Is it possible to test for a failed subscription purchase with an existing card?

I'm trying to test my controller code that would happen if a user tried to create a subscription with an existing card, but that fails (fraud, not enough funds, etc).

I'm checking out the specs for subscriptions here: https://github.com/highfidelity/fake_braintree/blob/master/spec/fake_braintree/subscription_spec.rb

I don't see any example of how I could make Braintree::Subscription.create fail. Calling FakeBraintree.decline_all_cards! doesn't seem to have any effect on creating a subscription with an existing card.

I'm thinking I could just mock it? Is that possible? Or does anyone have any advice for this situation?

In other words, I'm looking for a way for the result returned by Braintree::Subscription.create() to not be success so I can test that my controller does what it is supposed to do in that case.

cannot load such file -- rack/showexceptions (LoadError)

It raises exception on requiring the gem.

/usr/local/bundle/gems/sinatra-1.0/lib/sinatra/showexceptions.rb:1:in `require': cannot load such file -- rack/showexceptions (LoadError)
	from /usr/local/bundle/gems/sinatra-1.0/lib/sinatra/showexceptions.rb:1:in `<top (required)>'
	from /usr/local/bundle/gems/sinatra-1.0/lib/sinatra/base.rb:6:in `require'
	from /usr/local/bundle/gems/sinatra-1.0/lib/sinatra/base.rb:6:in `<top (required)>'
	from /usr/local/bundle/gems/fake_braintree-0.8.0/lib/fake_braintree/sinatra_app.rb:1:in `require'
	from /usr/local/bundle/gems/fake_braintree-0.8.0/lib/fake_braintree/sinatra_app.rb:1:in `<top (required)>'
	from /usr/local/bundle/gems/fake_braintree-0.8.0/lib/fake_braintree/server.rb:3:in `require'
	from /usr/local/bundle/gems/fake_braintree-0.8.0/lib/fake_braintree/server.rb:3:in `<top (required)>'
	from /usr/local/bundle/gems/fake_braintree-0.8.0/lib/fake_braintree.rb:8:in `require'
	from /usr/local/bundle/gems/fake_braintree-0.8.0/lib/fake_braintree.rb:8:in `<top (required)>'

Using gem causes Thin server to boot on Rspec, and can't quit specs

After installing the gem, it adds an additional 'starting Thin server', as well as causing me to be unable to cancel the tests as usual. Removing the gem results in tests being able to be cancelled fine.

I've tried using the gem straight from Ruby Gems, as well as via GitHub using the master branch.

RSpec Matchers

It'd be really nice to ship with some RSpec matchers so that you can do this:

Braintree::Subscription.create(:payment_method_token => 'abc123', :plan_id => 'my_plan')

FakeBraintree.should have_created(:subscription).with(:payment_method_token => 'abc123', :plan_id => 'my_plan')

I'm not entirely sure what you'd call .should on - calling it on FakeBraintree seems wrong. Also, I feel that the matchers could be much more elegant than the DSL I sketched above.

@jferris, anything to add?

Prevent disaster when accidentally in development mode

I just spent two hours figuring out why my development server would start two instances of thin then crash. It turns out, it's because I was including fake_braintree in both test and development mode. Here's the error I got:

Thin web server (v1.5.1 codename Straight Razor)
Maximum connections set to 1024
Listening on 0.0.0.0:51960, CTRL+C to stop
Booting Thin
Rails 3.2.11 application starting in development on http://0.0.0.0:3000
Call with -d to detach
Ctrl-C to shutdown server
Thin web server (v1.5.1 codename Straight Razor)
Maximum connections set to 1024
Listening on 0.0.0.0:3000, CTRL+C to stop
Exiting

It took a bit for me to see that and think "oh, fake_braintree! Of course!". Which is why I want to fix it for the next person.

Anyways, would you guys be open for a patch that makes it so the fake_braintree server doesn't start up if rails is in development, production, or staging? If so, let me know and I'll cook something up.

Net::ReadTimeout Exception: Net::ReadTimeout

Hello guys,
using FakeBraintree with inside my application reults Net::ReadTimeout Exception: Net::ReadTimeout error.

class Payments::PaymentMethod < ActiveRecord::Base
  private
  def submit

    result = Braintree::CreditCard.create(:customer_id => "the_customer_id", :number => "4111111111111111", :expiration_date => "05/2009", :options => {    :verify_card => true,    :verification_merchant_account_id => "the_merchant_account_id"  })
  end
end

can you figure this out?

Curious to see more

Can you update the read me with a quick intent on this project? I'm doing some integration with Braintree and would love to have an easy way to fake it in our specs.

Does this actually hit their API or just fake the request/response?

Thanks for sharing, you thoughbot guys really make my life easy!

Best practice for creating a customer to use for each test using Rails4 / RSpec

I'm using Rails 4 and RSpec, and I'm trying testing a controller that adds, removes, and sets the default payment method. In order for any of that to work, I need a braintree customer to be created first.

I guess my question is, has anyone dealt with this before that could recommend a best practice? Should I be creating a customer in a before each block for every test I run for that controller? Or could I abstract that to only happen once per controller, like with a let statement? I'm using factory girl to use factories in my let statements.

Referenced entries not updated correctly in registry

The current implementation suffers from issues because the registry values aren't updated correctly.

Sample use case:

  • Create a customer with a credit card using Braintree::Customer.create
  • Create a subscription with a discount using Braintree::Subscription.create with the credit card from above.
  • Update the discount using Braintree::Subscription.update with appropriate values for discounts: { update: [...] }.
  • Check the discount via the customer (Braintree::Customer.find(...).credit_cards[0].subscriptions[0].discounts[0]) or the credit card (Braintree::CreditCard.find(...).subscriptions[0].discounts[0]) => it still has the old values. Check the subscription directly (Braintree::Subscription.find(...).discounts[0]`) => it has the new values.

Is there any desire to fix this? I'd imagine it's not too easy since it would probably be necessary to come up with an entirely new concept for the registry (e.g. using a database or building something like an identity map).

Still hitting Sandbox

I've just set up fake_braintree like explained in the README, but my specs are still hitting the real Braintree sandbox.

Will this only work in my features with Capybara? Or should it automatically stub requests made from my unit tests also? If not, is there an easy way to make this work? Also, this should probably be stated in the README. Let me know and I'll be happy to send a pull request.

Here's my spec in /spec/workers/worker_spec.rb:

require 'spec_helper'

describe Worker do

  describe "#perform" do
    it "creates a customer" do
        u = FactoryGirl.create(:user)
        card_num = FakeBraintree::VALID_CREDIT_CARDS.first
        card_exp = "05/2012"
       Worker.perform(u.id, card_num, card_exp)
    end
  end

end

Here's my worker.rb in /app/workers/worker.rb:

class Worker

  @queue = :worker

  def self.perform(user_id, credit_card_number, credit_card_expiration)

    u = User.find(user_id)

    result = Braintree::Customer.create(
          :email => u.email,
          :id => "customer_#{u.id}",
          :credit_card => {
            :number => credit_card_number,
            :expiration_date => credit_card_expiration
          }
        )

        if result.success?
          u.customer_id = result.customer.id
          u.save
        else
          raise Exception, result.errors.map { |e| "#{e.code}: #{e.message}"}
        end

  end

end

Document Transparent Redirect

The README and #8 says we should be able to use TransparentRedirect.confirm and get the returned object.

However, there is no documentation about it, and the way the tests are using it is quite not something I would believe to be a public API.

It would be awesome to have some documentation to generate the query necessary to use this.

expected a gzipped response

I'm always getting this on any request with fake_braintree (0.3):

An error occurred in an after hook
  Braintree::UnexpectedError: expected a gzipped response
  occurred at /Users/knoopx/.rvm/gems/ruby-1.9.3-p392/gems/braintree-2.22.0/lib/braintree/http.rb:85:in `_body'

Exception raised undefined method `[]' for nil:NilClass

Hey,

first of all, thanks for maintaining fake_braintree. it helps us a ton.

we recently encountered a a strange problem where we try to parse the response from a transparent_redirect request. our JSON parsing failed and said that the response is not a valid JSON. it is very hard to reproduce but i finally got a log output. it not very much, but it's a start. i just want to put that out there, maybe other people are facing the same problem.

we are using rspec with parallel_tests and therefor running 6 fake braintree servers.

minor problems i faced so far:

  • the log file get's overwritten, since multiple threads want to access the same file. maybe we can add a uniq identifier to the log file?
  • all logging is disable, maybe add a debug option, it's really hard to get any output from fake_braintree to the surface.

the exception i see. sadly i don't have a stack trace yet nor which route is causing this.

Internal Server Error
undefined method `[]' for nil:NilClass


 WEBrick/1.3.1 (Ruby/2.2.3/2015-08-18) at
 localhost:39331

i will update the issue when i have more information.

9c90839 needs release

Please make a release for: 9c90839

0.2.0 is throwing

#<NotImplementedError: method `default' called on hidden T_OBJECT object (0x007fc8c7068a50 flags=0x9000000000000001 klass=0x0)>

from bundler. Removing mongrel dependency fixes.

cucumber routing

I'm having a hard time finding anybody talking about fake_braintree and cucumber, but I'm having a hard time getting the transparent redirect functionality working.

I'm running into this error when I submit:

  No route matches [POST] "/merchants/xxx/transparent_redirect_requests" (ActionController::RoutingError)

It looks like my rails app is intercepting what should be going to the fake_braintree server. Is there something I need to do to tell cucumber/capybara to leave it alone, or to pay attention to the port, or something like that?

malformed params returned on verification error via Transparent Redirect

I don't have a minimal test case for this yet, but I wanted to get some notes down on the behavior I'm seeing.

Given I have turned on verification:

FakeBraintree.verify_all_cards!

When I submit a TR request with an "invalid" credit card number ("1234123412341234"), I get back an error result with a string where the params hash should be:

(rdb:1) p result
#<Braintree::ErrorResult params:{...} errors:<> credit_card_verification: #<Braintree::CreditCardVerification status: nil, processor_response_code: nil, processor_response_text: nil, cvv_response_code: nil, avs_error_response_code: nil, avs_postal_code_response_code: nil, avs_street_address_response_code: nil, merchant_account_id: nil, gateway_rejection_reason: "cvv", id: nil, credit_card: nil, billing: nil, created_at: nil>>
(rdb:1) p result.params
"\n  "

Weirdly, result.inspect suggests params is a hash, but result.params is a string. I'd expect it to be a hash of the user-submitted params, which I can use to repopulate the form.

(I don't know why it's saying the rejection is due to "cvv"; AFAIK it's only the card number that's invalid.)

I looked at the situation from within FakeBraintree::Customer#failure_response:

/Users/eostrom/.rvm/gems/ruby-1.9.3-p194@iowl/gems/fake_braintree-0.2.1/lib/fake_braintree/customer.rb:164
gzipped_response(code, FakeBraintree.failure_response(credit_card_number).to_xml(:root => 'api_error_response'))
(rdb:2) p FakeBraintree.failure_response(credit_card_number)
{"message"=>nil, "verification"=>{"status"=>nil, "processor_response_text"=>nil, "processor_response_code"=>nil, "gateway_rejection_reason"=>"cvv", "cvv_response_code"=>nil}, "errors"=>{"errors"=>[]}, "params"=>{}}
(rdb:2) p FakeBraintree.failure_response(credit_card_number).to_xml(:root => 'api_error_response')
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<api-error-response>\n  <message nil=\"true\"/>\n  <verification>\n    <status nil=\"true\"/>\n    <processor-response-text nil=\"true\"/>\n    <processor-response-code nil=\"true\"/>\n    <gateway-rejection-reason>cvv</gateway-rejection-reason>\n    <cvv-response-code nil=\"true\"/>\n  </verification>\n  <errors>\n    <errors type=\"array\"/>\n  </errors>\n  <params>\n  </params>\n</api-error-response>\n"

I don't know if that's how an empty hash should be encoded to XML (it doesn't seem to be decoded properly, by whatever's decoding it), but I don't think the params hash should be empty in the first place.

I'm using Ruby 1.9.3, Rails 3.2.12, Braintree 2.22.0, Fake Braintree 0.2.1, and obviously a bunch of other gems. I'd appreciate any informed suggestions about where the trouble might be, or how to figure that out.

Public braintree XML API

Hi,
I would like to make something similar like fake_braintree for unit testing in python using httprety to intercept calls to BT servers.

The problem is that I have not found any documentation to BT XML API. There is no mention about message format etc. on their pages and support told me that they cannot share any doc regarding the API with me. I was able to reverse-engineer some basics from public clients, but it is slow and quite hard to determine what is really allowed to send and what not.

So...don't you posses any documents regarding the Braintree XML API that you would be able to share with rest of the world? :) Or just the source that you once used for getting this knowledge? I would be really grateful for anything, it does not have to be 100% up to date or so...

Thanks, best regards
Karel

Support for Subscription first_billing_date

I noticed when testing there is no support for first_billing_date for subscriptions during creation.
Braintree reference:
https://developers.braintreepayments.com/reference/request/subscription/create/ruby#set-start-date

Supposedly the billing_period_start_date should reflect and be calculated by first_billing_date and/or billing_day_of_month.

If anyone has a solution for testing this behaviour please let me know, otherwise I'll see if I can implement this in my spare time.

Deactivating fake_braintree for specific tests

For the vast majority of our tests, we want to have fake braintree enabled in order to keep things quick. However, some of our tests need to get to braintree and test the sandbox. It'd be great if we could do something like:

FakeBraintree.disable!

# Test code

FakeBraintree.enable! 

Just to allow requests through as and when we need to. Is there a way to do this?

Create transaction with subscription

The braintree API Braintree::Subscription.create also creates a transaction, but FakeBraintree does not create a transaction when we create a subscription.

How can I create a transaction when I create a subscription? Thoughts!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.