saucy 0.2.8 → 0.2.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -49,7 +49,7 @@ Feature: Manage Plan
49
49
  And I follow "Billing"
50
50
  Then I should see "card ending in 1111"
51
51
 
52
- Scenario: Change the plan from free to paid with credit card number
52
+ Scenario: Change the plan from free to paid with an invalid credit card number
53
53
  Given that the credit card "4111112" is invalid
54
54
  And a plan exists with a name of "Free"
55
55
  And a paid plan exists with a name of "Basic"
@@ -62,7 +62,6 @@ Feature: Manage Plan
62
62
  Then I should not see "Billing" within ".tabs"
63
63
  Then I should see "Your Plan"
64
64
  And I follow "Upgrade"
65
- Then I should see "Upgrade Your Plan"
66
65
  When I choose the "Basic" plan
67
66
  Then I should see "Billing Information"
68
67
  And I fill in "Cardholder name" with "Ralph Robot"
data/lib/saucy/account.rb CHANGED
@@ -175,6 +175,7 @@ module Saucy
175
175
  self.customer_token = result.customer.id
176
176
  flush_cache :customer
177
177
  else
178
+ p result.credit_card_verification
178
179
  verification = result.credit_card_verification
179
180
  if verification && verification.status == "processor_declined"
180
181
  errors[:card_number] << "was denied by the payment processor with the message: #{verification.processor_response_text}"
@@ -68,16 +68,20 @@ ShamRack.at("www.braintreegateway.com", 443).sinatra do
68
68
 
69
69
  put "/merchants/:merchant_id/customers/:id" do
70
70
  customer = Hash.from_xml(request.body).delete("customer")
71
- customer["id"] = params[:id]
72
- customer["merchant-id"] = params[:merchant_id]
73
- if customer["credit_card"] && customer["credit_card"].is_a?(Hash)
74
- customer["credit_card"]["last_4"] = customer["credit_card"].delete("number")[-4..-1]
75
- customer["credit_card"]["token"] = Digest::MD5.hexdigest("#{customer['merchant_id']}#{customer['id']}#{Time.now.to_f}")
76
- credit_card = customer.delete("credit_card")
77
- customer["credit_cards"] = [credit_card]
71
+ if !FakeBraintree.failure?(customer["credit_card"]["number"])
72
+ customer["id"] = params[:id]
73
+ customer["merchant-id"] = params[:merchant_id]
74
+ if customer["credit_card"] && customer["credit_card"].is_a?(Hash)
75
+ customer["credit_card"]["last_4"] = customer["credit_card"].delete("number")[-4..-1]
76
+ customer["credit_card"]["token"] = Digest::MD5.hexdigest("#{customer['merchant_id']}#{customer['id']}#{Time.now.to_f}")
77
+ credit_card = customer.delete("credit_card")
78
+ customer["credit_cards"] = [credit_card]
79
+ end
80
+ FakeBraintree.customers[params["id"]] = customer
81
+ [200, { "Content-Encoding" => "gzip" }, ActiveSupport::Gzip.compress(customer.to_xml(:root => 'customer'))]
82
+ else
83
+ [422, { "Content-Encoding" => "gzip" }, ActiveSupport::Gzip.compress(FakeBraintree.failure_response(customer["credit_card"]["number"]).to_xml(:root => 'api_error_response'))]
78
84
  end
79
- FakeBraintree.customers[params["id"]] = customer
80
- [200, { "Content-Encoding" => "gzip" }, ActiveSupport::Gzip.compress(customer.to_xml(:root => 'customer'))]
81
85
  end
82
86
 
83
87
  post "/merchants/:merchant_id/subscriptions" do
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: saucy
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 125
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
9
  - 8
10
- version: 0.2.8
10
+ - 1
11
+ version: 0.2.8.1
11
12
  platform: ruby
12
13
  authors:
13
14
  - thoughtbot, inc.