Skip to content

Commit

Permalink
Worldpay: Update where to pass shopperIPAddress
Browse files Browse the repository at this point in the history
For NetworkTokens shopperIPAddress should be passed after the
stored credentials fields. And for Fast Access transactions
shopperIPAddress should be passed within paymentDetails

Remote
117 tests, 498 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
98.2906% passed

Unit
134 tests, 743 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
  • Loading branch information
Alma Malambo committed Nov 26, 2024
1 parent 6e98120 commit e8b09be
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 28 deletions.
4 changes: 2 additions & 2 deletions lib/active_merchant/billing/gateways/worldpay.rb
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,6 @@ def build_fast_fund_credit_request(money, payment_method, options)
add_amount(xml, money, options)
add_order_content(xml, options)
add_payment_details_for_ff_credit(xml, payment_method, options)
add_shopper_id(xml, options)
end
end
end
Expand Down Expand Up @@ -477,6 +476,7 @@ def add_payment_details_for_ff_credit(xml, payment_method, options)
add_token_for_ff_credit(xml, payment_method, options)
end
end
add_shopper_id(xml, options)
end
end

Expand Down Expand Up @@ -670,8 +670,8 @@ def add_network_tokenization_card(xml, payment_method, options)
eci = eci_value(payment_method, options)
xml.eciIndicator eci if eci.present?
end
add_shopper_id(xml, options, false)
add_stored_credential_options(xml, options)
add_shopper_id(xml, options, false)
end
end

Expand Down
50 changes: 24 additions & 26 deletions test/remote/gateways/remote_worldpay_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ def setup

@options = {
order_id: generate_unique_id,
email: '[email protected]'
email: '[email protected]',
ip: '127.0.0.1'
}

@level_two_data = {
Expand Down Expand Up @@ -1037,35 +1038,32 @@ def test_failed_visa_account_funding_transfer_acquirer_error
assert_equal '20', credit.error_code
end

# These three fast_fund_credit tests are currently failing with the message: Disbursement transaction not supported
# It seems that the current sandbox setup does not support testing this.

# def test_successful_fast_fund_credit_on_cft_gateway
# options = @options.merge({ fast_fund_credit: true })
def test_successful_fast_fund_credit_on_cft_gateway
options = @options.merge({ fast_fund_credit: true })

# credit = @cftgateway.credit(@amount, @credit_card, options)
# assert_success credit
# assert_equal 'SUCCESS', credit.message
# end
credit = @cftgateway.credit(@amount, @credit_card, options)
assert_success credit
assert_equal 'SUCCESS', credit.message
end

# def test_successful_fast_fund_credit_with_token_on_cft_gateway
# assert store = @gateway.store(@credit_card, @store_options)
# assert_success store
def test_successful_fast_fund_credit_with_token_on_cft_gateway
assert store = @gateway.store(@credit_card, @store_options)
assert_success store

# options = @options.merge({ fast_fund_credit: true })
# assert credit = @cftgateway.credit(@amount, store.authorization, options)
# assert_success credit
# end
options = @options.merge({ fast_fund_credit: true })
assert credit = @cftgateway.credit(@amount, store.authorization, options)
assert_success credit
end

# def test_failed_fast_fund_credit_on_cft_gateway
# options = @options.merge({ fast_fund_credit: true })
# refused_card = credit_card('4444333322221111', name: 'REFUSED') # 'magic' value for testing failures, provided by Worldpay
def test_failed_fast_fund_credit_on_cft_gateway
options = @options.merge({ fast_fund_credit: true })
refused_card = credit_card('4444333322221111', name: 'REFUSED') # 'magic' value for testing failures, provided by Worldpay

# credit = @cftgateway.credit(@amount, refused_card, options)
# assert_failure credit
# assert_equal '01', credit.params['action_code']
# assert_equal "A transaction status of 'ok' or 'PUSH_APPROVED' is required.", credit.message
# end
credit = @cftgateway.credit(@amount, refused_card, options)
assert_failure credit
assert_equal '01', credit.params['action_code']
assert_equal "A transaction status of 'ok' or 'PUSH_APPROVED' is required.", credit.message
end

def test_transcript_scrubbing
transcript = capture_transcript(@gateway) do
Expand Down Expand Up @@ -1342,7 +1340,7 @@ def test_failed_refund_synchronous_response

refund = @cftgateway.refund(@amount * 2, auth.authorization, authorization_validated: true)
assert_failure refund
assert_equal 'Refund amount too high', refund.message
assert_equal 'Invalid amount: The refund amount should be equal to the captured value', refund.message
end

def test_successful_purchase_with_options_synchronous_response
Expand Down

0 comments on commit e8b09be

Please sign in to comment.