diff --git a/app/models/solidus/gateway/braintree_gateway.rb b/app/models/solidus/gateway/braintree_gateway.rb index 9bea8875..4af8e05f 100644 --- a/app/models/solidus/gateway/braintree_gateway.rb +++ b/app/models/solidus/gateway/braintree_gateway.rb @@ -150,12 +150,25 @@ def message_from_result(result) end end + def build_results_hash(result) + if result.success? + { + authorization: result.transaction.id, + avs_result: { + code: result.transaction.avs_street_address_response_code + } + } + else + {} + end + end + def handle_result(result) ActiveMerchant::Billing::Response.new( result.success?, message_from_result(result), {}, - { authorization: (result.transaction.id if result.success?) } + build_results_hash(result) ) end diff --git a/spec/solidus/gateway/braintree_gateway_spec.rb b/spec/solidus/gateway/braintree_gateway_spec.rb index c01907c9..58712e85 100644 --- a/spec/solidus/gateway/braintree_gateway_spec.rb +++ b/spec/solidus/gateway/braintree_gateway_spec.rb @@ -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 eq "M" end end @@ -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 eq "I" capture = payment_method.capture(5000, auth.authorization, {}) expect(capture).to be_success expect(capture.authorization).to be_present + expect(capture.avs_result["code"]).to eq "I" end it "succeeds capture on pending settlement" do