Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use my version of credit card creation

IMO the version in master is a bit smelly - you'd think this would belong in
credit_card.rb. This version also remembers to update the customer hash when
creating a credit card for a customer. And lastly, this runs a check against the
decline_all_cards/verify_all_cards flags, which should be useful for testing
credit card TR.
  • Loading branch information...
commit 9d665c90a0d694a324127f6fb0745c5468d43076 1 parent b3b439a
@wonnage wonnage authored gabebw committed
View
16 lib/fake_braintree/sinatra_app.rb
@@ -91,20 +91,6 @@ def hash_from_request_body_with_key(request, key)
end
end
- post "/merchants/:merchant_id/payment_methods" do
- opts = {
- :token => md5("#{Time.now}#{rand}"),
- :merchant_id => params[:merchant_id]
- }
- data = hash_from_request_body_with_key(request, 'credit_card')
- if data[:token]
- opts[:token] = data[:token]
- end
- credit_card = CreditCard.new(data, opts)
- FakeBraintree.registry.credit_cards[opts[:token]] = credit_card
- gzipped_response(200, credit_card.to_xml)
- end
-
# Braintree::CreditCard.update
put "/merchants/:merchant_id/payment_methods/:credit_card_token" do
credit_card = FakeBraintree.registry.credit_cards[params[:credit_card_token]]
@@ -116,7 +102,7 @@ def hash_from_request_body_with_key(request, key)
# Braintree::CreditCard.create
post "/merchants/:merchant_id/payment_methods" do
credit_card_hash = hash_from_request_body_with_key(request, "credit_card")
- options = {:token => params[:credit_card_token], :merchant_id => params[:merchant_id]}
+ options = {:merchant_id => params[:merchant_id]}
if credit_card_hash['options']
options.merge!(credit_card_hash.delete('options')).symbolize_keys!
View
13 spec/fake_braintree/credit_card_spec.rb
@@ -14,19 +14,6 @@
let(:token) { braintree_credit_card_token(TEST_CC_NUMBER, [month, year].join('/')) }
end
-describe "Braintree::CreditCard.create" do
- let(:month) { '04' }
- let(:year) { '2016' }
- let(:token) { braintree_credit_card_token(TEST_CC_NUMBER, [month, year].join('/')) }
- it "successfully creates card with valid data" do
- result = Braintree::CreditCard.create :token => token,
- :number => TEST_CC_NUMBER
- result.should be_success
-
- Braintree::CreditCard.find(token).should be
- end
-end
-
describe "Braintree::CreditCard.sale" do
it "successfully creates a sale" do
result = Braintree::CreditCard.sale(cc_token, :amount => 10.00)

0 comments on commit 9d665c9

Please sign in to comment.
Something went wrong with that request. Please try again.