Skip to content

Commit

Permalink
Stripe: Add application fee only on non-EMV transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
bizla committed Aug 5, 2015
1 parent 0ce945a commit e54bef3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* TNS: Handle non existent country [duff]
* TNS: Rescue Errors [anellis]
* CenPOS: Support avs_result and cvv_result [tjstankus]
* Stripe: Add application fee only on non-EMV transactions [bizla]


== Version 1.52.0 (July 20, 2015)
Expand Down
3 changes: 1 addition & 2 deletions lib/active_merchant/billing/gateways/stripe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,11 @@ def purchase(money, payment, options = {})
def capture(money, authorization, options = {})
post = {}

add_application_fee(post, options)

if emv_tc_response = options.delete(:icc_data)
post[:card] = { emv_approval_data: emv_tc_response }
commit(:post, "charges/#{CGI.escape(authorization)}", post, options)
else
add_application_fee(post, options)
add_amount(post, money, options)
commit(:post, "charges/#{CGI.escape(authorization)}/capture", post, options)
end
Expand Down
10 changes: 10 additions & 0 deletions test/unit/gateways/stripe_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,16 @@ def test_supports_network_tokenization
assert_instance_of TrueClass, @gateway.supports_network_tokenization?
end

def test_emv_capture_application_fee_ignored
response = stub_comms(@gateway, :ssl_request) do
@gateway.capture(@amount, "ch_test_charge", application_fee: 100, icc_data: @emv_credit_card.icc_data)
end.check_request do |method, endpoint, data, headers|
assert data !~ /application_fee/, "request should not include application_fee"
end.respond_with(successful_capture_response_with_icc_data)

assert_success response
end

private

# this mock is only useful with unit tests, as cryptograms generated by an EMV terminal
Expand Down

0 comments on commit e54bef3

Please sign in to comment.