Skip to content

Commit

Permalink
2.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
braintreeps committed Mar 25, 2011
1 parent a97da09 commit ab80f6f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 4 deletions.
1 change: 1 addition & 0 deletions lib/braintree/error_codes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ module Transaction
CannotBeVoided = "91504"
CannotRefundCredit = "91505"
CannotRefundUnlessSettled = "91506"
CannotRefundWithSuspendedMerchantAccount = "91538"
CannotSubmitForSettlement = "91507"
CreditCardIsRequired = "91508"
CustomFieldIsInvalid = "91526"
Expand Down
1 change: 1 addition & 0 deletions lib/braintree/transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module GatewayRejectionReason
end

module Status
AuthorizationExpired = 'authorization_expired'
Authorizing = 'authorizing'
Authorized = 'authorized'
GatewayRejected = 'gateway_rejected'
Expand Down
3 changes: 2 additions & 1 deletion lib/braintree/transaction_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ class TransactionSearch < AdvancedSearch # :nodoc:

key_value_fields :refund

range_fields :amount, :created_at, :authorized_at, :failed_at, :gateway_rejected_at, :processor_declined_at,
range_fields :amount, :created_at, :authorization_expired_at, :authorized_at,
:failed_at, :gateway_rejected_at, :processor_declined_at,
:settled_at, :submitted_for_settlement_at, :voided_at
end
end
36 changes: 33 additions & 3 deletions spec/integration/braintree/transaction_search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,9 @@
transaction = Braintree::Transaction.sale!(
:amount => Braintree::Test::TransactionAmounts::Authorize,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/12"
}
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/12"
}
)

collection = Braintree::Transaction.search do |search|
Expand All @@ -290,6 +290,15 @@
collection.maximum_size.should == 0
end

it "finds expired authorizations by status" do
collection = Braintree::Transaction.search do |search|
search.status.in Braintree::Transaction::Status::AuthorizationExpired
end

collection.maximum_size.should > 0
collection.first.status.should == Braintree::Transaction::Status::AuthorizationExpired
end

it "searches on source" do
transaction = Braintree::Transaction.sale!(
:amount => Braintree::Test::TransactionAmounts::Authorize,
Expand Down Expand Up @@ -626,6 +635,27 @@
collection.first.id.should == transaction.id
end

it "finds expired authorizations in a given range" do
collection = Braintree::Transaction.search do |search|
search.authorization_expired_at.between(
Date.today - 2,
Date.today - 1
)
end

collection.maximum_size.should == 0

collection = Braintree::Transaction.search do |search|
search.authorization_expired_at.between(
Date.today - 1,
Date.today + 1
)
end

collection.maximum_size.should > 0
collection.first.status.should == Braintree::Transaction::Status::AuthorizationExpired
end

it "finds transactions gateway_rejected in a given range" do
old_merchant = Braintree::Configuration.merchant_id
old_public_key = Braintree::Configuration.public_key
Expand Down

0 comments on commit ab80f6f

Please sign in to comment.