Skip to content

Commit

Permalink
Merge pull request #18 from jhawthorn/avs_response
Browse files Browse the repository at this point in the history
Rebase #9
  • Loading branch information
jhawthorn committed Mar 31, 2016
2 parents 3c9de59 + c722b21 commit c4a9370
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
15 changes: 14 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,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

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 eq "M"
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 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
Expand Down

0 comments on commit c4a9370

Please sign in to comment.