Skip to content

Commit

Permalink
Add AVS response code to ActiveMerchant responses
Browse files Browse the repository at this point in the history
  • Loading branch information
philbirt committed Nov 23, 2015
1 parent 3df2323 commit 12027d9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
12 changes: 11 additions & 1 deletion app/models/solidus/gateway/braintree_gateway.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,22 @@ def message_from_result(result)
end
end

def options_from_results(result)
options_hash = {}
options_hash.merge!(
authorization: result.transaction.id,
avs_result: { code: result.transaction.avs_street_address_response_code }
) if result.success?

options_hash
end

def handle_result(result)
ActiveMerchant::Billing::Response.new(
result.success?,
message_from_result(result),
{},
{ authorization: (result.transaction.id if result.success?) }
options_from_results(result)
)
end

Expand Down
3 changes: 3 additions & 0 deletions spec/solidus/gateway/braintree_gateway_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
capture = payment_method.capture(5000, auth.authorization, {})
expect(capture).to be_success
expect(capture.authorization).to be_present
expect(capture.avs_result["code"]).to be_present
end
end

Expand Down Expand Up @@ -151,10 +152,12 @@
auth = payment_method.authorize(5000, card, {})
expect(auth).to be_success
expect(auth.authorization).to be_present
expect(auth.avs_result["code"]).to be_present

capture = payment_method.capture(5000, auth.authorization, {})
expect(capture).to be_success
expect(capture.authorization).to be_present
expect(capture.avs_result["code"]).to be_present
end

it "succeeds capture on pending settlement" do
Expand Down

0 comments on commit 12027d9

Please sign in to comment.