diff --git a/lib/active_merchant/billing/gateways/visanet_peru.rb b/lib/active_merchant/billing/gateways/visanet_peru.rb index fd16ef3f424..34e4dfc8545 100644 --- a/lib/active_merchant/billing/gateways/visanet_peru.rb +++ b/lib/active_merchant/billing/gateways/visanet_peru.rb @@ -39,6 +39,7 @@ def authorize(amount, payment_method, options={}) def capture(amount, authorization, options={}) params = {} + params[:amount] = amount(amount) if amount options[:id_unico] = split_authorization(authorization)[1] add_auth_order_id(params, authorization, options) commit('deposit', params, options) diff --git a/test/remote/gateways/remote_visanet_peru_test.rb b/test/remote/gateways/remote_visanet_peru_test.rb index 9309d63a622..9a1d9084d42 100644 --- a/test/remote/gateways/remote_visanet_peru_test.rb +++ b/test/remote/gateways/remote_visanet_peru_test.rb @@ -65,6 +65,23 @@ def test_successful_authorize_and_capture assert_equal @options[:order_id], capture.params['externalTransactionId'] end + def test_successful_authorize_and_partial_capture + response = @gateway.authorize(@amount, @credit_card, @options) + assert_success response + assert_equal 'OK', response.message + assert response.authorization + assert_equal @options[:order_id], response.params['externalTransactionId'] + assert_equal '1.00', response.params['data']['IMP_AUTORIZADO'] + + first_capture = @gateway.capture(@amount-1, response.authorization, @options) + assert_success first_capture + assert_equal 'OK', first_capture.message + + second_capture = @gateway.capture(1, response.authorization, @options) + assert_success second_capture + assert_equal 'OK', second_capture.message + end + def test_successful_authorize_fractional_amount amount = 199 response = @gateway.authorize(amount, @credit_card)