Permalink
Browse files

2.13.3

  • Loading branch information...
1 parent 1616289 commit daf568c2f7a4c7dfcb56fb79eb0e4d16a5c54d07 @braintreeps braintreeps committed Feb 1, 2012
View
@@ -1,3 +1,8 @@
+== 2.13.3
+
+* Exposes plan_id on transactions
+* Fixes GitHub issue #19 - Unescapes escaped characters in query string
+
== 2.13.2
* Added error code for invalid purchase order number
@@ -53,6 +53,7 @@ module Type # :nodoc:
attr_reader :merchant_account_id
attr_reader :order_id
attr_reader :billing_details, :shipping_details
+ attr_reader :plan_id
# The authorization code from the processor.
attr_reader :processor_authorization_code
# The response code from the processor.
@@ -40,6 +40,7 @@ def create_customer_data(params)
def parse_and_validate_query_string(query_string) # :nodoc:
params = Util.symbolize_keys(Util.parse_query_string(query_string))
query_string_without_hash = query_string.split("&").reject{|param| param =~ /\Ahash=/}.join("&")
+ query_string_without_hash = Util.url_decode(query_string_without_hash)
if params[:http_status] == nil
raise UnexpectedError, "expected query string to have an http_status param"
View
@@ -25,6 +25,10 @@ def self.parse_query_string(qs)
end
end
+ def self.url_decode(text)
+ CGI.unescape text.to_s
+ end
+
def self.url_encode(text)
CGI.escape text.to_s
end
View
@@ -2,7 +2,7 @@ module Braintree
module Version
Major = 2
Minor = 13
- Tiny = 1
+ Tiny = 3
String = "#{Major}.#{Minor}.#{Tiny}"
end
@@ -577,7 +577,7 @@
end
end
- it "snapshots add_ons and discounts from subscription" do
+ it "snapshots plan, add_ons and discounts from subscription" do
customer = Braintree::Customer.create!(
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
@@ -619,6 +619,8 @@
result.success?.should be_true
transaction = result.subscription.transactions.first
+ transaction.plan_id.should == SpecHelper::TriallessPlan[:id]
+
transaction.add_ons.size.should == 2
add_ons = transaction.add_ons.sort_by { |add_on| add_on.id }
@@ -65,6 +65,19 @@
end.to raise_error(Braintree::ForgedQueryString)
end
+ it "does not raise ForgedQueryString if any parameter is url encoded" do
+ url_encoded_query_string_without_hash = "http_status=200&nested_param%5Bsub_param%5D=testing"
+ url_decoded_query_string_without_hash = Braintree::Util.url_decode(url_encoded_query_string_without_hash)
+
+ hash = Braintree::Digest.hexdigest(Braintree::Configuration.private_key, url_decoded_query_string_without_hash)
+
+ url_encoded_query_string = "#{url_encoded_query_string_without_hash}&hash=#{hash}"
+
+ expect do
+ Braintree::Configuration.gateway.transparent_redirect.parse_and_validate_query_string url_encoded_query_string
+ end.to_not raise_error(Braintree::ForgedQueryString)
+ end
+
it "raises an AuthenticationError if authentication fails" do
expect do
Braintree::Configuration.gateway.transparent_redirect.parse_and_validate_query_string add_hash_to_query_string("http_status=401")
@@ -257,4 +257,10 @@
Braintree::Util.url_encode("foo?bar").should == "foo%3Fbar"
end
end
+
+ describe "self.url_decode" do
+ it "url encodes the given text" do
+ Braintree::Util.url_decode("foo%3Fbar").should == "foo?bar"
+ end
+ end
end

0 comments on commit daf568c

Please sign in to comment.