From 3d4d7d9f58d8d4b7537bc9f6ede78720d01951ba Mon Sep 17 00:00:00 2001
From: Filipe Costa
Date: Wed, 4 Jul 2018 09:47:02 -0400
Subject: [PATCH 0001/2234] Release 1.80.0
---
CHANGELOG | 2 ++
lib/active_merchant/version.rb | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 64f96ed2222..a63a94dd4d2 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,8 @@
= ActiveMerchant CHANGELOG
== HEAD
+
+== Version 1.80.0 (July 4, 2018)
* Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909
* Paymentez: return a Result object even when the upstream server 500s [bpollack] #2871
* Drop support for Ruby versions older than 2.3 [bpollack] #2863
diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb
index 46c298f78d8..b1883e4e5c3 100644
--- a/lib/active_merchant/version.rb
+++ b/lib/active_merchant/version.rb
@@ -1,3 +1,3 @@
module ActiveMerchant
- VERSION = '1.79.2'
+ VERSION = '1.80.0'
end
From 0c2cb7f21bfd225b47f2ae32ffcc224adccde631 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Wed, 4 Jul 2018 08:11:10 -0400
Subject: [PATCH 0002/2234] Prevent connections being made in unit tests
The test introduced in 262b65c45bf9 was not properly stubbed, and
would attempt to make connections. This fixes it.
Unit: 3866 tests, 67888 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
test/unit/connection_test.rb | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/test/unit/connection_test.rb b/test/unit/connection_test.rb
index 03261fcbf0c..564fea45f49 100644
--- a/test/unit/connection_test.rb
+++ b/test/unit/connection_test.rb
@@ -46,7 +46,9 @@ def test_connection_does_pass_requested_proxy
def test_connection_does_not_mutate_headers_argument
headers = { 'Content-Type' => 'text/xml' }.freeze
- @connection.request(:get, nil, headers)
+ Net::HTTP.any_instance.expects(:get).with('/tx.php', headers.merge({'connection' => 'close'})).returns(@ok)
+ Net::HTTP.any_instance.expects(:start).returns(true)
+ response = @connection.request(:get, nil, headers)
assert_equal({ 'Content-Type' => 'text/xml' }, headers)
end
From eb86d5eec73a40aa6d0ba037a59140113f48bb96 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Wed, 4 Jul 2018 08:04:55 -0400
Subject: [PATCH 0003/2234] Convert all YAML calls from .load to .safe_load
.load can deserialize arbitrary Ruby classes. Currently, we only use YAML for
fixtures and other patently safe purposes, but leaving them sets a bad
precedent, and prevents us using RuboCop's security linter for YAML properly.
Enable the linter and fix the usages.
3866 tests, 67884 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications
100% passed
---
.rubocop_todo.yml | 9 ---------
generators/gateway/gateway_generator.rb | 2 +-
test/test_helper.rb | 2 +-
test/unit/fixtures_test.rb | 2 +-
test/unit/gateways/firstdata_e4_test.rb | 4 ++--
test/unit/gateways/payeezy_test.rb | 14 +++++++-------
6 files changed, 12 insertions(+), 21 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index f00fcb20eb8..2a376ba8a24 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -860,15 +860,6 @@ Performance/StringReplacement:
- 'lib/active_merchant/billing/gateways/realex.rb'
- 'test/unit/gateways/nab_transact_test.rb'
-# Offense count: 11
-# Cop supports --auto-correct.
-Security/YAMLLoad:
- Exclude:
- - 'test/test_helper.rb'
- - 'test/unit/fixtures_test.rb'
- - 'test/unit/gateways/firstdata_e4_test.rb'
- - 'test/unit/gateways/payeezy_test.rb'
-
# Offense count: 2
# Configuration parameters: EnforcedStyle.
# SupportedStyles: inline, group
diff --git a/generators/gateway/gateway_generator.rb b/generators/gateway/gateway_generator.rb
index d20ad21343c..febddbb1c7e 100644
--- a/generators/gateway/gateway_generator.rb
+++ b/generators/gateway/gateway_generator.rb
@@ -38,7 +38,7 @@ def fixtures_file
end
def next_identifier
- fixtures = (YAML.load(File.read(fixtures_file)).keys + [identifier]).uniq.sort
+ fixtures = (YAML.safe_load(File.read(fixtures_file)).keys + [identifier], [], [], true).uniq.sort
fixtures[fixtures.sort.index(identifier)+1]
end
end
diff --git a/test/test_helper.rb b/test/test_helper.rb
index e26efecf87d..1f1159493c5 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -261,7 +261,7 @@ def fixtures(key)
def load_fixtures
[DEFAULT_CREDENTIALS, LOCAL_CREDENTIALS].inject({}) do |credentials, file_name|
if File.exist?(file_name)
- yaml_data = YAML.load(File.read(file_name))
+ yaml_data = YAML.safe_load(File.read(file_name), [], [], true)
credentials.merge!(symbolize_keys(yaml_data))
end
credentials
diff --git a/test/unit/fixtures_test.rb b/test/unit/fixtures_test.rb
index 5f5baa93eb0..b72720d928c 100644
--- a/test/unit/fixtures_test.rb
+++ b/test/unit/fixtures_test.rb
@@ -2,7 +2,7 @@
class FixturesTest < Test::Unit::TestCase
def test_sort
- keys = YAML.load(File.read(ActiveMerchant::Fixtures::DEFAULT_CREDENTIALS)).keys
+ keys = YAML.safe_load(File.read(ActiveMerchant::Fixtures::DEFAULT_CREDENTIALS), [], [], true).keys
assert_equal(
keys,
keys.sort
diff --git a/test/unit/gateways/firstdata_e4_test.rb b/test/unit/gateways/firstdata_e4_test.rb
index eb01abdebbd..e7e6e6c9fc4 100755
--- a/test/unit/gateways/firstdata_e4_test.rb
+++ b/test/unit/gateways/firstdata_e4_test.rb
@@ -1037,7 +1037,7 @@ def no_transaction_response
read: true
socket:
RESPONSE
- YAML.load(yamlexcep)
+ YAML.safe_load(yamlexcep, ['Net::HTTPBadRequest', 'ActiveMerchant::ResponseError'])
end
def bad_credentials_response
@@ -1074,7 +1074,7 @@ def bad_credentials_response
http_version: '1.1'
socket:
RESPONSE
- YAML.load(yamlexcep)
+ YAML.safe_load(yamlexcep, ['Net::HTTPUnauthorized', 'ActiveMerchant::ResponseError'])
end
def successful_void_response
diff --git a/test/unit/gateways/payeezy_test.rb b/test/unit/gateways/payeezy_test.rb
index 08319f927f4..87c61922b34 100644
--- a/test/unit/gateways/payeezy_test.rb
+++ b/test/unit/gateways/payeezy_test.rb
@@ -511,7 +511,7 @@ def failed_purchase_response
body_exist: true
message:
RESPONSE
- YAML.load(yamlexcep)
+ YAML.safe_load(yamlexcep, ['Net::HTTPBadRequest', 'ActiveMerchant::ResponseError'])
end
def successful_authorize_response
@@ -586,7 +586,7 @@ def failed_refund_response
body_exist: true
message:
RESPONSE
- YAML.load(yamlexcep)
+ YAML.safe_load(yamlexcep, ['Net::HTTPBadRequest', 'ActiveMerchant::ResponseError'])
end
def successful_void_response
@@ -631,7 +631,7 @@ def failed_void_response
body_exist: true
message:
RESPONSE
- YAML.load(yamlexcep)
+ YAML.safe_load(yamlexcep, ['Net::HTTPBadRequest', 'ActiveMerchant::ResponseError'])
end
def failed_capture_response
@@ -671,7 +671,7 @@ def failed_capture_response
body_exist: true
message:
RESPONSE
- YAML.load(yamlexcep)
+ YAML.safe_load(yamlexcep, ['Net::HTTPBadRequest', 'ActiveMerchant::ResponseError'])
end
def invalid_token_response
@@ -710,7 +710,7 @@ def invalid_token_response
body_exist: true
message:
RESPONSE
- YAML.load(yamlexcep)
+ YAML.safe_load(yamlexcep, ['Net::HTTPUnauthorized', 'ActiveMerchant::ResponseError'])
end
def invalid_token_response_integration
@@ -735,7 +735,7 @@ def invalid_token_response_integration
body_exist: true
message:
RESPONSE
- YAML.load(yamlexcep)
+ YAML.safe_load(yamlexcep, ['Net::HTTPUnauthorized', 'ActiveMerchant::ResponseError'])
end
def bad_credentials_response
@@ -760,6 +760,6 @@ def bad_credentials_response
body_exist: true
message:
RESPONSE
- YAML.load(yamlexcep)
+ YAML.safe_load(yamlexcep, ['Net::HTTPForbidden', 'ActiveMerchant::ResponseError'])
end
end
From b10bee7956d3b66fdd5f92718004df26b32c31b9 Mon Sep 17 00:00:00 2001
From: David Perry
Date: Thu, 5 Jul 2018 15:04:30 -0400
Subject: [PATCH 0004/2234] GlobalCollect: Don't overwrite contactDetails
Previously, if there was an address provided, it would overwrite the
contactDeatails field which may have already had an email field added.
Now we have a conditional for both email and phone number elements
within contactDetails.
Also updates the sandbox url to the current endpoint.
Closes #2915
Remote:
16 tests, 37 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
17 tests, 79 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/global_collect.rb | 18 +++++++-----------
.../gateways/remote_global_collect_test.rb | 3 ++-
test/unit/gateways/global_collect_test.rb | 3 +++
4 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index a63a94dd4d2..868e36b876f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
= ActiveMerchant CHANGELOG
== HEAD
+* GlobalCollect: Don't overwrite contactDetails [curiousepic] #2915
== Version 1.80.0 (July 4, 2018)
* Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909
diff --git a/lib/active_merchant/billing/gateways/global_collect.rb b/lib/active_merchant/billing/gateways/global_collect.rb
index 3f37eb85177..1152f495e56 100644
--- a/lib/active_merchant/billing/gateways/global_collect.rb
+++ b/lib/active_merchant/billing/gateways/global_collect.rb
@@ -4,7 +4,7 @@ class GlobalCollectGateway < Gateway
self.display_name = 'GlobalCollect'
self.homepage_url = 'http://www.globalcollect.com/'
- self.test_url = 'https://api-sandbox.globalcollect.com/'
+ self.test_url = 'https://eu.sandbox.api-ingenico.com/'
self.live_url = 'https://api.globalcollect.com/'
self.supported_countries = ['AD', 'AE', 'AG', 'AI', 'AL', 'AM', 'AO', 'AR', 'AS', 'AT', 'AU', 'AW', 'AX', 'AZ', 'BA', 'BB', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BL', 'BM', 'BN', 'BO', 'BQ', 'BR', 'BS', 'BT', 'BW', 'BY', 'BZ', 'CA', 'CC', 'CD', 'CF', 'CH', 'CI', 'CK', 'CL', 'CM', 'CN', 'CO', 'CR', 'CU', 'CV', 'CW', 'CX', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM', 'DO', 'DZ', 'EC', 'EE', 'EG', 'ER', 'ES', 'ET', 'FI', 'FJ', 'FK', 'FM', 'FO', 'FR', 'GA', 'GB', 'GD', 'GE', 'GF', 'GH', 'GI', 'GL', 'GM', 'GN', 'GP', 'GQ', 'GR', 'GS', 'GT', 'GU', 'GW', 'GY', 'HK', 'HN', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IM', 'IN', 'IS', 'IT', 'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI', 'KM', 'KN', 'KR', 'KW', 'KY', 'KZ', 'LA', 'LB', 'LC', 'LI', 'LK', 'LR', 'LS', 'LT', 'LU', 'LV', 'MA', 'MC', 'MD', 'ME', 'MF', 'MG', 'MH', 'MK', 'MM', 'MN', 'MO', 'MP', 'MQ', 'MR', 'MS', 'MT', 'MU', 'MV', 'MW', 'MX', 'MY', 'MZ', 'NA', 'NC', 'NE', 'NG', 'NI', 'NL', 'NO', 'NP', 'NR', 'NU', 'NZ', 'OM', 'PA', 'PE', 'PF', 'PG', 'PH', 'PL', 'PN', 'PS', 'PT', 'PW', 'QA', 'RE', 'RO', 'RS', 'RU', 'RW', 'SA', 'SB', 'SC', 'SE', 'SG', 'SH', 'SI', 'SJ', 'SK', 'SL', 'SM', 'SN', 'SR', 'ST', 'SV', 'SZ', 'TC', 'TD', 'TG', 'TH', 'TJ', 'TL', 'TM', 'TN', 'TO', 'TR', 'TT', 'TV', 'TW', 'TZ', 'UA', 'UG', 'US', 'UY', 'UZ', 'VC', 'VE', 'VG', 'VI', 'VN', 'WF', 'WS', 'ZA', 'ZM', 'ZW']
@@ -154,13 +154,9 @@ def add_customer_data(post, options, payment = nil)
post['order']['companyInformation'] = {
'name' => options[:company]
}
- post['order']['contactDetails'] = {
- 'emailAddress' => options[:email]
- }
+ post['order']['contactDetails']['emailAddress'] = options[:email] if options[:email]
if address = options[:billing_address] || options[:address]
- post['order']['contactDetails'] = {
- 'phoneNumber' => address[:phone]
- }
+ post['order']['contactDetails']['phoneNumber'] = address[:phone] if address[:phone]
end
end
@@ -169,10 +165,10 @@ def add_refund_customer_data(post, options)
post['customer']['address'] = {
'countryCode' => address[:country]
}
- post['customer']['contactDetails'] = {
- 'emailAddress' => options[:email],
- 'phoneNumber' => address[:phone]
- }
+ post['customer']['contactDetails']['emailAddress'] = options[:email] if options[:email]
+ if address = options[:billing_address] || options[:address]
+ post['customer']['contactDetails']['phoneNumber'] = address[:phone] if address[:phone]
+ end
end
end
diff --git a/test/remote/gateways/remote_global_collect_test.rb b/test/remote/gateways/remote_global_collect_test.rb
index b04a60ae53a..519db653470 100644
--- a/test/remote/gateways/remote_global_collect_test.rb
+++ b/test/remote/gateways/remote_global_collect_test.rb
@@ -10,6 +10,7 @@ def setup
@accepted_amount = 4005
@rejected_amount = 2997
@options = {
+ email: 'example@example.com',
billing_address: address,
description: 'Store Purchase'
}
@@ -153,7 +154,7 @@ def test_invalid_login
response = gateway.purchase(@amount, @credit_card, @options)
assert_failure response
- assert_match %r{MISSING_OR_INVALID_AUTHORIZATION}, response.message
+ assert_match %r{UNKNOWN_SERVER_ERROR}, response.message
end
def test_transcript_scrubbing
diff --git a/test/unit/gateways/global_collect_test.rb b/test/unit/gateways/global_collect_test.rb
index d7c9a81801b..605e1aa0563 100644
--- a/test/unit/gateways/global_collect_test.rb
+++ b/test/unit/gateways/global_collect_test.rb
@@ -68,6 +68,7 @@ def test_authorize_without_pre_authorization_flag
def test_successful_authorization_with_extra_options
options = @options.merge(
{
+ email: 'example@example.com',
order_id: '123',
ip: '127.0.0.1',
fraud_fields:
@@ -83,6 +84,8 @@ def test_successful_authorization_with_extra_options
end.check_request do |endpoint, data, headers|
assert_match %r("fraudFields":{"website":"www.example.com","giftMessage":"Happy Day!","customerIpAddress":"127.0.0.1"}), data
assert_match %r("merchantReference":"123"), data
+ assert_match %r("emailAddress":"example@example.com"), data
+ assert_match %r("phoneNumber":"\(555\)555-5555"), data
end.respond_with(successful_authorize_response)
assert_success response
From 371b07613a8b154b18123ed245fa4eaed74a1760 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Fri, 6 Jul 2018 12:52:38 -0400
Subject: [PATCH 0005/2234] Set RuboCop to require: false
It makes zero sense to auto-require RuboCop, since we never use it as
a library at any point.
---
Gemfile | 2 +-
Gemfile.rails42 | 2 +-
Gemfile.rails50 | 2 +-
Gemfile.rails51 | 2 +-
Gemfile.rails52 | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/Gemfile b/Gemfile
index 2c314a40873..6e287b04095 100644
--- a/Gemfile
+++ b/Gemfile
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
gemspec
gem 'jruby-openssl', :platforms => :jruby
-gem 'rubocop', '~> 0.57.2'
+gem 'rubocop', '~> 0.57.2', require: false
group :test, :remote_test do
# gateway-specific dependencies, keeping these gems out of the gemspec
diff --git a/Gemfile.rails42 b/Gemfile.rails42
index 98b0dd0c7a4..890b340923a 100644
--- a/Gemfile.rails42
+++ b/Gemfile.rails42
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
gemspec
gem 'jruby-openssl', :platforms => :jruby
-gem 'rubocop', '~> 0.57.2'
+gem 'rubocop', '~> 0.57.2', require: false
group :test, :remote_test do
# gateway-specific dependencies, keeping these gems out of the gemspec
diff --git a/Gemfile.rails50 b/Gemfile.rails50
index cfe7103ac08..c014f53a18e 100644
--- a/Gemfile.rails50
+++ b/Gemfile.rails50
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
gemspec
gem 'jruby-openssl', :platforms => :jruby
-gem 'rubocop', '~> 0.57.2'
+gem 'rubocop', '~> 0.57.2', require: false
group :test, :remote_test do
# gateway-specific dependencies, keeping these gems out of the gemspec
diff --git a/Gemfile.rails51 b/Gemfile.rails51
index 4bbed6e8884..c83abf0b54b 100644
--- a/Gemfile.rails51
+++ b/Gemfile.rails51
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
gemspec
gem 'jruby-openssl', :platforms => :jruby
-gem 'rubocop', '~> 0.57.2'
+gem 'rubocop', '~> 0.57.2', require: false
group :test, :remote_test do
# gateway-specific dependencies, keeping these gems out of the gemspec
diff --git a/Gemfile.rails52 b/Gemfile.rails52
index e76569231cf..cf1a88c3011 100644
--- a/Gemfile.rails52
+++ b/Gemfile.rails52
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
gemspec
gem 'jruby-openssl', :platforms => :jruby
-gem 'rubocop', '~> 0.57.2'
+gem 'rubocop', '~> 0.57.2', require: false
group :test, :remote_test do
# gateway-specific dependencies, keeping these gems out of the gemspec
From 89e446357c19d66477b7e4ab39a269d94c2f46ef Mon Sep 17 00:00:00 2001
From: David Perry
Date: Fri, 6 Jul 2018 16:26:58 -0400
Subject: [PATCH 0006/2234] Pin Payments: Pass reference for statement desc
This passes an undocumented field that is used to specify a descriptor
that appears on the customer's statement.
Closes #2919
Remote:
16 tests, 46 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
37 tests, 112 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/pin.rb | 1 +
test/remote/gateways/remote_pin_test.rb | 5 +++++
3 files changed, 7 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index 868e36b876f..c7d7091e4a2 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,7 @@
== HEAD
* GlobalCollect: Don't overwrite contactDetails [curiousepic] #2915
+* Pin Payments: Pass reference for statement desc [curiousepic] #2919
== Version 1.80.0 (July 4, 2018)
* Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909
diff --git a/lib/active_merchant/billing/gateways/pin.rb b/lib/active_merchant/billing/gateways/pin.rb
index 7b364e2eaea..3d8af8a56b1 100644
--- a/lib/active_merchant/billing/gateways/pin.rb
+++ b/lib/active_merchant/billing/gateways/pin.rb
@@ -114,6 +114,7 @@ def add_address(post, creditcard, options)
def add_invoice(post, options)
post[:description] = options[:description] || 'Active Merchant Purchase'
+ post[:reference] = options[:reference] if options[:reference]
end
def add_capture(post, options)
diff --git a/test/remote/gateways/remote_pin_test.rb b/test/remote/gateways/remote_pin_test.rb
index 010830cf89b..e9851eacdf6 100644
--- a/test/remote/gateways/remote_pin_test.rb
+++ b/test/remote/gateways/remote_pin_test.rb
@@ -38,6 +38,11 @@ def test_successful_purchase_with_metadata
assert_equal options_with_metadata[:metadata][:purchase_number], response.params['response']['metadata']['purchase_number']
end
+ def test_successful_purchase_with_reference
+ response = @gateway.purchase(@amount, @credit_card, @options.merge(reference: 'statement descriptor'))
+ assert_success response
+ end
+
def test_successful_authorize_and_capture
authorization = @gateway.authorize(@amount, @credit_card, @options)
assert_success authorization
From 4cd2a2ef6e98c94d396ad7fa48dbffa3b75a5e5e Mon Sep 17 00:00:00 2001
From: Sanjay Chakrapani
Date: Wed, 4 Jul 2018 00:08:35 +0530
Subject: [PATCH 0007/2234] Firstdata E4 (GGE4) v27: Add new gateway
v27 diverges significantly from existing firstdata_e4 (v11) in terms of
additional credentials for HMAC and multiple field changes including
address & cvv fields.
Unit: 29 tests, 136 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote: 23 tests, 92 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Closes #2912
---
CHANGELOG | 1 +
.../billing/gateways/firstdata_e4_v27.rb | 444 ++++++++
test/fixtures.yml | 6 +
.../gateways/remote_firstdata_e4_v27_test.rb | 222 ++++
test/schema/firstdata_e4/v27.xsd | 223 ++++
test/unit/gateways/firstdata_e4_v27_test.rb | 979 ++++++++++++++++++
6 files changed, 1875 insertions(+)
create mode 100644 lib/active_merchant/billing/gateways/firstdata_e4_v27.rb
create mode 100644 test/remote/gateways/remote_firstdata_e4_v27_test.rb
create mode 100644 test/schema/firstdata_e4/v27.xsd
create mode 100644 test/unit/gateways/firstdata_e4_v27_test.rb
diff --git a/CHANGELOG b/CHANGELOG
index c7d7091e4a2..ef8d131a9d0 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -3,6 +3,7 @@
== HEAD
* GlobalCollect: Don't overwrite contactDetails [curiousepic] #2915
* Pin Payments: Pass reference for statement desc [curiousepic] #2919
+* FirstData: introduce v27 gateway [shasum] #2912
== Version 1.80.0 (July 4, 2018)
* Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909
diff --git a/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb b/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb
new file mode 100644
index 00000000000..9bdd77d9b62
--- /dev/null
+++ b/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb
@@ -0,0 +1,444 @@
+module ActiveMerchant #:nodoc:
+ module Billing #:nodoc:
+ class FirstdataE4V27Gateway < Gateway
+ self.test_url = 'https://api.demo.globalgatewaye4.firstdata.com/transaction/v27'
+ self.live_url = 'https://api.globalgatewaye4.firstdata.com/transaction/v27'
+
+ TRANSACTIONS = {
+ sale: '00',
+ authorization: '01',
+ verify: '05',
+ capture: '32',
+ void: '33',
+ credit: '34',
+ store: '05'
+ }
+
+ SUCCESS = 'true'
+
+ SENSITIVE_FIELDS = [:cvdcode, :expiry_date, :card_number]
+
+ BRANDS = {
+ :visa => 'Visa',
+ :master => 'Mastercard',
+ :american_express => 'American Express',
+ :jcb => 'JCB',
+ :discover => 'Discover'
+ }
+
+ DEFAULT_ECI = '07'
+
+ self.supported_cardtypes = BRANDS.keys
+ self.supported_countries = ['CA', 'US']
+ self.default_currency = 'USD'
+ self.homepage_url = 'http://www.firstdata.com'
+ self.display_name = 'FirstData Global Gateway e4 v27'
+
+ STANDARD_ERROR_CODE_MAPPING = {
+ # Bank error codes: https://support.payeezy.com/hc/en-us/articles/203730509-First-Data-Global-Gateway-e4-Bank-Response-Codes
+ '201' => STANDARD_ERROR_CODE[:incorrect_number],
+ '531' => STANDARD_ERROR_CODE[:invalid_cvc],
+ '503' => STANDARD_ERROR_CODE[:invalid_cvc],
+ '811' => STANDARD_ERROR_CODE[:invalid_cvc],
+ '605' => STANDARD_ERROR_CODE[:invalid_expiry_date],
+ '522' => STANDARD_ERROR_CODE[:expired_card],
+ '303' => STANDARD_ERROR_CODE[:card_declined],
+ '530' => STANDARD_ERROR_CODE[:card_declined],
+ '401' => STANDARD_ERROR_CODE[:call_issuer],
+ '402' => STANDARD_ERROR_CODE[:call_issuer],
+ '501' => STANDARD_ERROR_CODE[:pickup_card],
+ # Ecommerce error codes: https://support.payeezy.com/hc/en-us/articles/203730499-eCommerce-Response-Codes-ETG-e4-Transaction-Gateway-Codes
+ '22' => STANDARD_ERROR_CODE[:invalid_number],
+ '25' => STANDARD_ERROR_CODE[:invalid_expiry_date],
+ '31' => STANDARD_ERROR_CODE[:incorrect_cvc],
+ '44' => STANDARD_ERROR_CODE[:incorrect_zip],
+ '42' => STANDARD_ERROR_CODE[:processing_error]
+ }
+
+ def initialize(options = {})
+ requires!(options, :login, :password, :key_id, :hmac_key)
+ @options = options
+
+ super
+ end
+
+ def authorize(money, credit_card_or_store_authorization, options = {})
+ commit(:authorization, build_sale_or_authorization_request(money, credit_card_or_store_authorization, options))
+ end
+
+ def purchase(money, credit_card_or_store_authorization, options = {})
+ commit(:sale, build_sale_or_authorization_request(money, credit_card_or_store_authorization, options))
+ end
+
+ def capture(money, authorization, options = {})
+ commit(:capture, build_capture_or_credit_request(money, authorization, options))
+ end
+
+ def void(authorization, options = {})
+ commit(:void, build_capture_or_credit_request(money_from_authorization(authorization), authorization, options))
+ end
+
+ def refund(money, authorization, options = {})
+ commit(:credit, build_capture_or_credit_request(money, authorization, options))
+ end
+
+ def verify(credit_card, options = {})
+ commit(:verify, build_sale_or_authorization_request(0, credit_card, options))
+ end
+
+ # Tokenize a credit card with TransArmor
+ #
+ # The TransArmor token and other card data necessary for subsequent
+ # transactions is stored in the response's +authorization+ attribute.
+ # The authorization string may be passed to +authorize+ and +purchase+
+ # instead of a +ActiveMerchant::Billing::CreditCard+ instance.
+ #
+ # TransArmor support must be explicitly activated on your gateway
+ # account by FirstData. If your authorization string is empty, contact
+ # FirstData support for account setup assistance.
+ #
+ # https://support.payeezy.com/hc/en-us/articles/203731189-TransArmor-Tokenization
+ def store(credit_card, options = {})
+ commit(:store, build_store_request(credit_card, options), credit_card)
+ end
+
+ def verify_credentials
+ response = void('0')
+ response.message != 'Unauthorized Request. Bad or missing credentials.'
+ end
+
+ def supports_scrubbing?
+ true
+ end
+
+ def scrub(transcript)
+ transcript
+ .gsub(%r(().+()), '\1[FILTERED]\2')
+ .gsub(%r(().+()), '\1[FILTERED]\2')
+ .gsub(%r(().+())i, '\1[FILTERED]\2')
+ .gsub(%r(().+()), '\1[FILTERED]\2')
+ .gsub(%r((CARD NUMBER\s+: )#+\d+), '\1[FILTERED]')
+ end
+
+ def supports_network_tokenization?
+ true
+ end
+
+ private
+
+ def build_request(action, body)
+ xml = Builder::XmlMarkup.new
+
+ xml.instruct!
+ xml.tag! 'Transaction', xmlns: 'http://secure2.e-xact.com/vplug-in/transaction/rpc-enc/encodedTypes' do
+ add_credentials(xml)
+ add_transaction_type(xml, action)
+ xml << body
+ end
+
+ xml.target!
+ end
+
+ def build_sale_or_authorization_request(money, credit_card_or_store_authorization, options)
+ xml = Builder::XmlMarkup.new
+
+ add_amount(xml, money, options)
+
+ if credit_card_or_store_authorization.is_a? String
+ add_credit_card_token(xml, credit_card_or_store_authorization, options)
+ else
+ add_credit_card(xml, credit_card_or_store_authorization, options)
+ end
+
+ add_address(xml, options)
+ add_customer_data(xml, options)
+ add_invoice(xml, options)
+ add_tax_fields(xml, options)
+ add_level_3(xml, options)
+
+ xml.target!
+ end
+
+ def build_capture_or_credit_request(money, identification, options)
+ xml = Builder::XmlMarkup.new
+
+ add_identification(xml, identification)
+ add_amount(xml, money, options)
+ add_customer_data(xml, options)
+ add_card_authentication_data(xml, options)
+
+ xml.target!
+ end
+
+ def build_store_request(credit_card, options)
+ xml = Builder::XmlMarkup.new
+
+ add_credit_card(xml, credit_card, options)
+ add_address(xml, options)
+ add_customer_data(xml, options)
+
+ xml.target!
+ end
+
+ def add_credentials(xml)
+ xml.tag! 'ExactID', @options[:login]
+ xml.tag! 'Password', @options[:password]
+ end
+
+ def add_transaction_type(xml, action)
+ xml.tag! 'Transaction_Type', TRANSACTIONS[action]
+ end
+
+ def add_identification(xml, identification)
+ authorization_num, transaction_tag, _ = identification.split(';')
+
+ xml.tag! 'Authorization_Num', authorization_num
+ xml.tag! 'Transaction_Tag', transaction_tag
+ end
+
+ def add_amount(xml, money, options)
+ currency_code = options[:currency] || default_currency
+ xml.tag! 'DollarAmount', localized_amount(money, currency_code)
+ xml.tag! 'Currency', currency_code
+ end
+
+ def add_credit_card(xml, credit_card, options)
+ if credit_card.respond_to?(:track_data) && credit_card.track_data.present?
+ xml.tag! 'Track1', credit_card.track_data
+ xml.tag! 'Ecommerce_Flag', 'R'
+ else
+ xml.tag! 'Card_Number', credit_card.number
+ xml.tag! 'Expiry_Date', expdate(credit_card)
+ xml.tag! 'CardHoldersName', credit_card.name
+ xml.tag! 'CardType', card_type(credit_card.brand)
+
+ add_credit_card_eci(xml, credit_card, options)
+ add_credit_card_verification_strings(xml, credit_card, options)
+ end
+ end
+
+ def add_credit_card_eci(xml, credit_card, options)
+ eci = if credit_card.is_a?(NetworkTokenizationCreditCard) && credit_card.source == :apple_pay && card_brand(credit_card) == 'discover'
+ # Discover requires any Apple Pay transaction, regardless of in-app
+ # or web, and regardless of the ECI contained in the PKPaymentToken,
+ # to have an ECI value explicitly of 04.
+ '04'
+ else
+ (credit_card.respond_to?(:eci) ? credit_card.eci : nil) || options[:eci] || DEFAULT_ECI
+ end
+
+ xml.tag! 'Ecommerce_Flag', eci.to_s =~ /^[0-9]+$/ ? eci.to_s.rjust(2, '0') : eci
+ end
+
+ def add_credit_card_verification_strings(xml, credit_card, options)
+ if credit_card.is_a?(NetworkTokenizationCreditCard)
+ add_network_tokenization_credit_card(xml, credit_card)
+ else
+ if credit_card.verification_value?
+ xml.tag! 'CVD_Presence_Ind', '1'
+ xml.tag! 'CVDCode', credit_card.verification_value
+ end
+
+ add_card_authentication_data(xml, options)
+ end
+ end
+
+ def add_network_tokenization_credit_card(xml, credit_card)
+ case card_brand(credit_card).to_sym
+ when :american_express
+ cryptogram = Base64.decode64(credit_card.payment_cryptogram)
+ xml.tag!('XID', Base64.encode64(cryptogram[20...40]))
+ xml.tag!('CAVV', Base64.encode64(cryptogram[0...20]))
+ else
+ xml.tag!('XID', credit_card.transaction_id) if credit_card.transaction_id
+ xml.tag!('CAVV', credit_card.payment_cryptogram)
+ end
+ end
+
+ def add_card_authentication_data(xml, options)
+ xml.tag! 'CAVV', options[:cavv]
+ xml.tag! 'XID', options[:xid]
+ end
+
+ def add_credit_card_token(xml, store_authorization, options)
+ params = store_authorization.split(';')
+ credit_card = CreditCard.new(
+ :brand => params[1],
+ :first_name => params[2],
+ :last_name => params[3],
+ :month => params[4],
+ :year => params[5])
+
+ xml.tag! 'TransarmorToken', params[0]
+ xml.tag! 'Expiry_Date', expdate(credit_card)
+ xml.tag! 'CardHoldersName', credit_card.name
+ xml.tag! 'CardType', card_type(credit_card.brand)
+ add_card_authentication_data(xml, options)
+ end
+
+ def add_customer_data(xml, options)
+ xml.tag! 'Customer_Ref', options[:customer] if options[:customer]
+ xml.tag! 'Client_IP', options[:ip] if options[:ip]
+ xml.tag! 'Client_Email', options[:email] if options[:email]
+ end
+
+ def add_address(xml, options)
+ if (address = options[:billing_address] || options[:address])
+ xml.tag! 'Address' do
+ xml.tag! 'Address1', address[:address1]
+ xml.tag! 'Address2', address[:address2] if address[:address2]
+ xml.tag! 'City', address[:city]
+ xml.tag! 'State', address[:state]
+ xml.tag! 'Zip', address[:zip]
+ xml.tag! 'CountryCode', address[:country]
+ end
+ xml.tag! 'ZipCode', address[:zip]
+ end
+ end
+
+ def add_invoice(xml, options)
+ xml.tag! 'Reference_No', options[:order_id]
+ xml.tag! 'Reference_3', options[:description] if options[:description]
+ end
+
+ def add_tax_fields(xml, options)
+ xml.tag! 'Tax1Amount', options[:tax1_amount] if options[:tax1_amount]
+ xml.tag! 'Tax1Number', options[:tax1_number] if options[:tax1_number]
+ end
+
+ def add_level_3(xml, options)
+ xml.tag!('Level3') { |x| x << options[:level_3] } if options[:level_3]
+ end
+
+ def expdate(credit_card)
+ "#{format(credit_card.month, :two_digits)}#{format(credit_card.year, :two_digits)}"
+ end
+
+ def card_type(credit_card_brand)
+ BRANDS[credit_card_brand.to_sym] if credit_card_brand
+ end
+
+ def commit(action, data, credit_card = nil)
+ url = (test? ? self.test_url : self.live_url)
+ request = build_request(action, data)
+ begin
+ response = parse(ssl_post(url, request, headers('POST', url, request)))
+ rescue ResponseError => e
+ response = parse_error(e.response)
+ end
+
+ Response.new(successful?(response), message_from(response), response,
+ :test => test?,
+ :authorization => successful?(response) ? response_authorization(action, response, credit_card) : '',
+ :avs_result => {:code => response[:avs]},
+ :cvv_result => response[:cvv2],
+ :error_code => standard_error_code(response)
+ )
+ end
+
+ def headers(method, url, request)
+ content_type = 'application/xml'
+ content_digest = Digest::SHA1.hexdigest(request)
+ sending_time = Time.now.utc.iso8601
+ payload = [method, content_type, content_digest, sending_time, url.split('.com')[1]].join("\n")
+ hmac = OpenSSL::HMAC.digest('sha1', @options[:hmac_key], payload)
+ encoded = Base64.strict_encode64(hmac)
+
+ {
+ 'x-gge4-date' => sending_time,
+ 'x-gge4-content-sha1' => content_digest,
+ 'Authorization' => 'GGE4_API ' + @options[:key_id].to_s + ':' + encoded,
+ 'Accepts' => content_type,
+ 'Content-Type' => content_type
+ }
+ end
+
+ def successful?(response)
+ response[:transaction_approved] == SUCCESS
+ end
+
+ def response_authorization(action, response, credit_card)
+ if action == :store
+ store_authorization_from(response, credit_card)
+ else
+ authorization_from(response)
+ end
+ end
+
+ def authorization_from(response)
+ if response[:authorization_num] && response[:transaction_tag]
+ [
+ response[:authorization_num],
+ response[:transaction_tag],
+ (response[:dollar_amount].to_f * 100).round
+ ].join(';')
+ else
+ ''
+ end
+ end
+
+ def store_authorization_from(response, credit_card)
+ if response[:transarmor_token].present?
+ [
+ response[:transarmor_token],
+ credit_card.brand,
+ credit_card.first_name,
+ credit_card.last_name,
+ credit_card.month,
+ credit_card.year
+ ].map { |value| value.to_s.tr(';', '') }.join(';')
+ else
+ raise StandardError, "TransArmor support is not enabled on your #{display_name} account"
+ end
+ end
+
+ def money_from_authorization(auth)
+ _, _, amount = auth.split(/;/, 3)
+ amount.to_i
+ end
+
+ def message_from(response)
+ if(response[:faultcode] && response[:faultstring])
+ response[:faultstring]
+ elsif(response[:error_number] && response[:error_number] != '0')
+ response[:error_description]
+ else
+ result = (response[:exact_message] || '')
+ result << " - #{response[:bank_message]}" if response[:bank_message].present?
+ result
+ end
+ end
+
+ def parse_error(error)
+ {
+ :transaction_approved => 'false',
+ :error_number => error.code,
+ :error_description => error.body,
+ :ecommerce_error_code => error.body.gsub(/[^\d]/, '')
+ }
+ end
+
+ def standard_error_code(response)
+ STANDARD_ERROR_CODE_MAPPING[response[:bank_resp_code] || response[:ecommerce_error_code]]
+ end
+
+ def parse(xml)
+ response = {}
+ xml = REXML::Document.new(xml)
+
+ if (root = REXML::XPath.first(xml, '//TransactionResult'))
+ parse_elements(response, root)
+ end
+
+ SENSITIVE_FIELDS.each { |key| response.delete(key) }
+ response
+ end
+
+ def parse_elements(response, root)
+ root.elements.to_a.each do |node|
+ response[node.name.gsub(/EXact/, 'Exact').underscore.to_sym] = (node.text || '').strip
+ end
+ end
+ end
+ end
+end
diff --git a/test/fixtures.yml b/test/fixtures.yml
index c14a40480aa..99d218d55eb 100644
--- a/test/fixtures.yml
+++ b/test/fixtures.yml
@@ -331,6 +331,12 @@ firstdata_e4:
login: SD8821-67
password: T6bxSywbcccbJ19eDXNIGaCDOBg1W7T8
+firstdata_e4_v27:
+ login: ALOGIN
+ password: APASSWORD
+ key_id: ANINTEGER
+ hmac_key: AMAGICALKEY
+
flo2cash:
username: SOMECREDENTIAL
password: ANOTHERCREDENTIAL
diff --git a/test/remote/gateways/remote_firstdata_e4_v27_test.rb b/test/remote/gateways/remote_firstdata_e4_v27_test.rb
new file mode 100644
index 00000000000..464f8d87f56
--- /dev/null
+++ b/test/remote/gateways/remote_firstdata_e4_v27_test.rb
@@ -0,0 +1,222 @@
+require 'test_helper'
+
+class RemoteFirstdataE4V27Test < Test::Unit::TestCase
+ def setup
+ @gateway = FirstdataE4V27Gateway.new(fixtures(:firstdata_e4_v27))
+ @credit_card = credit_card
+ @bad_credit_card = credit_card('4111111111111113')
+ @credit_card_with_track_data = credit_card_with_track_data('4003000123456781')
+ @amount = 100
+ @options = {
+ :order_id => '1',
+ :billing_address => address,
+ :description => 'Store Purchase'
+ }
+ @options_with_authentication_data = @options.merge({
+ eci: '5',
+ cavv: 'TESTCAVV',
+ xid: 'TESTXID'
+ })
+ end
+
+ def test_successful_purchase
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
+ assert_match(/Transaction Normal/, response.message)
+ assert_success response
+ end
+
+ def test_successful_purchase_with_network_tokenization
+ @credit_card = network_tokenization_credit_card('4242424242424242',
+ payment_cryptogram: 'BwABB4JRdgAAAAAAiFF2AAAAAAA=',
+ verification_value: nil
+ )
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
+ assert_success response
+ assert_equal 'Transaction Normal - Approved', response.message
+ assert_false response.authorization.blank?
+ end
+
+ def test_successful_purchase_with_track_data
+ assert response = @gateway.purchase(@amount, @credit_card_with_track_data, @options)
+ assert_match(/Transaction Normal/, response.message)
+ assert_success response
+ end
+
+ def test_successful_purchase_with_level_3
+ level_3_xml = <<-LEVEL3
+
+ 107.20
+ 3
+ The Description
+ 2.33
+
+ LEVEL3
+
+ response = @gateway.purchase(500, @credit_card, @options.merge(level_3: level_3_xml))
+ assert_success response
+ assert_equal 'Transaction Normal - Approved', response.message
+ end
+
+ def test_successful_purchase_with_tax_fields
+ response = @gateway.purchase(500, @credit_card, @options.merge(tax1_amount: 50, tax1_number: 'A458'))
+ assert_success response
+ assert_equal '50.0', response.params['tax1_amount']
+ assert_equal '', response.params['tax1_number'], 'E4 blanks this out in the response'
+ end
+
+ def test_successful_purchase_with_customer_ref
+ response = @gateway.purchase(500, @credit_card, @options.merge(customer: '267'))
+ assert_success response
+ assert_equal '267', response.params['customer_ref']
+ end
+
+ def test_successful_purchase_with_card_authentication
+ assert response = @gateway.purchase(@amount, @credit_card, @options_with_authentication_data)
+ assert_equal response.params['cavv'], @options_with_authentication_data[:cavv]
+ assert_equal response.params['ecommerce_flag'], @options_with_authentication_data[:eci]
+ assert_equal response.params['xid'], @options_with_authentication_data[:xid]
+ assert_success response
+ end
+
+ def test_unsuccessful_purchase
+ # ask for error 13 response (Amount Error) via dollar amount 5,000 + error
+ @amount = 501300
+ assert response = @gateway.purchase(@amount, @credit_card, @options )
+ assert_match(/Transaction Normal/, response.message)
+ assert_failure response
+ end
+
+ def test_bad_creditcard_number
+ assert response = @gateway.purchase(@amount, @bad_credit_card, @options)
+ assert_match(/Invalid Credit Card/, response.message)
+ assert_failure response
+ assert_equal response.error_code, 'invalid_number'
+ end
+
+ def test_trans_error
+ # ask for error 42 (unable to send trans) as the cents bit...
+ @amount = 500042
+ assert response = @gateway.purchase(@amount, @credit_card, @options )
+ assert_match(/Unable to Send Transaction/, response.message) # 42 is 'unable to send trans'
+ assert_failure response
+ assert_equal response.error_code, 'processing_error'
+ end
+
+ def test_purchase_and_credit
+ assert purchase = @gateway.purchase(@amount, @credit_card, @options)
+ assert_success purchase
+ assert purchase.authorization
+ assert credit = @gateway.refund(@amount, purchase.authorization)
+ assert_success credit
+ end
+
+ def test_purchase_and_void
+ assert purchase = @gateway.purchase(29234, @credit_card, @options)
+ assert_success purchase
+
+ assert purchase.authorization
+ assert void = @gateway.void(purchase.authorization)
+ assert_success void
+ end
+
+ def test_purchase_and_void_with_even_dollar_amount
+ assert purchase = @gateway.purchase(5000, @credit_card, @options)
+ assert_success purchase
+
+ assert purchase.authorization
+ assert void = @gateway.void(purchase.authorization)
+ assert_success void
+ end
+
+ def test_authorize_and_capture
+ assert auth = @gateway.authorize(@amount, @credit_card, @options)
+ assert_success auth
+ assert auth.authorization
+ assert capture = @gateway.capture(@amount, auth.authorization)
+ assert_success capture
+ end
+
+ def test_failed_capture
+ assert response = @gateway.capture(@amount, 'ET838747474;frob')
+ assert_failure response
+ assert_match(/Invalid Authorization Number/i, response.message)
+ end
+
+ def test_successful_verify
+ assert response = @gateway.verify(@credit_card, @options)
+ assert_success response
+
+ assert_equal 'Transaction Normal - Approved', response.message
+ assert_equal '0.0', response.params['dollar_amount']
+ assert_equal '05', response.params['transaction_type']
+ end
+
+ def test_failed_verify
+ assert response = @gateway.verify(@bad_credit_card, @options)
+ assert_failure response
+ assert_match %r{Invalid Credit Card Number}, response.message
+ assert_equal response.error_code, 'invalid_number'
+ end
+
+ def test_invalid_login
+ gateway = FirstdataE4V27Gateway.new(:login => 'NotARealUser',
+ :password => 'NotARealPassword',
+ :key_id => 'NotARealKey',
+ :hmac_key => 'NotARealHMAC' )
+ assert response = gateway.purchase(@amount, @credit_card, @options)
+ assert_match %r{Unauthorized Request}, response.message
+ assert_failure response
+ end
+
+ def test_response_contains_cvv_and_avs_results
+ response = @gateway.purchase(@amount, @credit_card, @options)
+ assert_success response
+ assert_equal 'M', response.cvv_result['code']
+ assert_equal '4', response.avs_result['code']
+ end
+
+ def test_refund
+ assert purchase = @gateway.purchase(@amount, @credit_card, @options)
+ assert_match(/Transaction Normal/, purchase.message)
+ assert_success purchase
+
+ assert response = @gateway.refund(50, purchase.authorization)
+ assert_success response
+ assert_match(/Transaction Normal/, response.message)
+ assert response.authorization
+ end
+
+ def test_refund_with_track_data
+ assert purchase = @gateway.purchase(@amount, @credit_card_with_track_data, @options)
+ assert_match(/Transaction Normal/, purchase.message)
+ assert_success purchase
+
+ assert response = @gateway.refund(50, purchase.authorization)
+ assert_success response
+ assert_match(/Transaction Normal/, response.message)
+ assert response.authorization
+ end
+
+ def test_verify_credentials
+ assert @gateway.verify_credentials
+
+ gateway = FirstdataE4V27Gateway.new(login: 'unknown', password: 'unknown', key_id: 'unknown', hmac_key: 'unknown')
+ assert !gateway.verify_credentials
+ gateway = FirstdataE4V27Gateway.new(login: fixtures(:firstdata_e4)[:login], password: 'unknown', key_id: 'unknown', hmac_key: 'unknown')
+ assert !gateway.verify_credentials
+ end
+
+ def test_transcript_scrubbing
+ cc_with_different_cvc = credit_card(verification_value: '999')
+ transcript = capture_transcript(@gateway) do
+ @gateway.purchase(@amount, cc_with_different_cvc, @options)
+ end
+ transcript = @gateway.scrub(transcript)
+
+ assert_scrubbed(cc_with_different_cvc.number, transcript)
+ assert_scrubbed(cc_with_different_cvc.verification_value, transcript)
+ assert_scrubbed(@gateway.options[:password], transcript)
+ assert_scrubbed(@gateway.options[:hmac_key], transcript)
+ end
+
+end
diff --git a/test/schema/firstdata_e4/v27.xsd b/test/schema/firstdata_e4/v27.xsd
new file mode 100644
index 00000000000..775018838c6
--- /dev/null
+++ b/test/schema/firstdata_e4/v27.xsd
@@ -0,0 +1,223 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/unit/gateways/firstdata_e4_v27_test.rb b/test/unit/gateways/firstdata_e4_v27_test.rb
new file mode 100644
index 00000000000..ed4e9c45512
--- /dev/null
+++ b/test/unit/gateways/firstdata_e4_v27_test.rb
@@ -0,0 +1,979 @@
+require 'test_helper'
+require 'nokogiri'
+require 'yaml'
+
+class FirstdataE4V27Test < Test::Unit::TestCase
+ include CommStub
+
+ def setup
+ @gateway = FirstdataE4V27Gateway.new(
+ :login => 'A00427-01',
+ :password => 'testus',
+ :key_id => '12345',
+ :hmac_key => 'hexkey'
+ )
+
+ @credit_card = credit_card
+ @amount = 100
+ @options = {
+ :order_id => '1',
+ :billing_address => address,
+ :description => 'Store Purchase'
+ }
+ @authorization = 'ET1700;106625152;4738'
+ end
+
+ def test_invalid_credentials
+ @gateway.expects(:ssl_post).raises(bad_credentials_response)
+ assert response = @gateway.store(@credit_card, {})
+ assert_failure response
+ assert response.test?
+ assert_equal '', response.authorization
+ assert_equal 'Unauthorized Request. Bad or missing credentials.', response.message
+ end
+
+ def test_successful_purchase
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
+ assert_success response
+ assert_equal 'ET1700;106625152;4738', response.authorization
+ assert response.test?
+ assert_equal 'Transaction Normal - Approved', response.message
+
+ FirstdataE4V27Gateway::SENSITIVE_FIELDS.each{|f| assert !response.params.has_key?(f.to_s)}
+ end
+
+ def test_successful_purchase_with_token
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
+ assert response = @gateway.purchase(@amount, '8938737759041111;visa;Longbob;Longsen;9;2014')
+ assert_success response
+ end
+
+ def test_successful_void
+ @gateway.expects(:ssl_post).returns(successful_void_response)
+ assert response = @gateway.void(@authorization, @options)
+ assert_success response
+ end
+
+ def test_successful_refund
+ @gateway.expects(:ssl_post).returns(successful_refund_response)
+ assert response = @gateway.refund(@amount, @authorization)
+ assert_success response
+ end
+
+ def test_successful_store
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
+ assert response = @gateway.store(@credit_card, @options)
+ assert_success response
+ assert_equal '8938737759041111', response.params['transarmor_token']
+ assert_equal "8938737759041111;visa;Longbob;Longsen;9;#{@credit_card.year}", response.authorization
+ end
+
+ def test_failed_store_without_transarmor_support
+ @gateway.expects(:ssl_post).returns(successful_purchase_response_without_transarmor)
+ assert_raise StandardError do
+ @gateway.store(@credit_card, @options)
+ end
+ end
+
+ def test_failed_purchase
+ @gateway.expects(:ssl_post).returns(failed_purchase_response)
+
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
+ assert_instance_of Response, response
+ assert_failure response
+ assert_equal response.error_code, 'invalid_expiry_date'
+ end
+
+ def test_successful_verify
+ response = stub_comms do
+ @gateway.verify(@credit_card)
+ end.respond_with(successful_verify_response)
+ assert_success response
+ end
+
+ def test_expdate
+ assert_equal(
+ '%02d%2s' % [@credit_card.month, @credit_card.year.to_s[-2..-1]],
+ @gateway.send(:expdate, @credit_card)
+ )
+ end
+
+ def test_no_transaction
+ @gateway.expects(:ssl_post).raises(no_transaction_response())
+ assert response = @gateway.purchase(100, @credit_card, {})
+ assert_failure response
+ assert response.test?
+ assert_equal 'Malformed request: Transaction Type is missing.', response.message
+ end
+
+ def test_supported_countries
+ assert_equal ['CA', 'US'], FirstdataE4V27Gateway.supported_countries
+ end
+
+ def test_supported_cardtypes
+ assert_equal [:visa, :master, :american_express, :jcb, :discover], FirstdataE4V27Gateway.supported_cardtypes
+ end
+
+ def test_avs_result
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
+
+ response = @gateway.purchase(@amount, @credit_card)
+ assert_equal 'U', response.avs_result['code']
+ end
+
+ def test_cvv_result
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
+
+ response = @gateway.purchase(@amount, @credit_card)
+ assert_equal 'M', response.cvv_result['code']
+ end
+
+ def test_request_includes_address
+ stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options)
+ end.check_request do |endpoint, data, headers|
+ assert_match '456 My StreetApt 1OttawaONK1C2N6CA', data
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_tax_fields_are_sent
+ stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options.merge(tax1_amount: 830, tax1_number: 'Br59a'))
+ end.check_request do |endpoint, data, headers|
+ assert_match '830', data
+ assert_match 'Br59a', data
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_customer_ref_is_sent
+ stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options.merge(customer: '932'))
+ end.check_request do |endpoint, data, headers|
+ assert_match '932', data
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_eci_default_value
+ stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options)
+ end.check_request do |endpoint, data, headers|
+ assert_match '07', data
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_eci_numeric_padding
+ @credit_card = network_tokenization_credit_card
+ @credit_card.eci = '5'
+
+ stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options)
+ end.check_request do |endpoint, data, headers|
+ assert_match '05', data
+ end.respond_with(successful_purchase_response)
+
+ @credit_card = network_tokenization_credit_card
+ @credit_card.eci = 5
+
+ stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options)
+ end.check_request do |endpoint, data, headers|
+ assert_match '05', data
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_eci_option_value
+ stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options.merge(eci: '05'))
+ end.check_request do |endpoint, data, headers|
+ assert_match '05', data
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_network_tokenization_requests_with_amex
+ stub_comms do
+ credit_card = network_tokenization_credit_card(
+ '378282246310005',
+ brand: 'american_express',
+ transaction_id: '123',
+ eci: '05',
+ payment_cryptogram: 'whatever_the_cryptogram_of_at_least_20_characters_is',
+ )
+
+ @gateway.purchase(@amount, credit_card, @options)
+ end.check_request do |_, data, _|
+ assert_match '05', data
+ assert_match "mrLdtHIWq2nLXq7IrA==\n", data
+ assert_match "whateverthecryptogramofatlc=\n", data
+ assert_xml_valid_to_wsdl(data)
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_network_tokenization_requests_with_discover
+ stub_comms do
+ credit_card = network_tokenization_credit_card(
+ '6011111111111117',
+ brand: 'discover',
+ transaction_id: '123',
+ eci: '05',
+ payment_cryptogram: 'whatever_the_cryptogram_is',
+ )
+
+ @gateway.purchase(@amount, credit_card, @options)
+ end.check_request do |_, data, _|
+ assert_match '04', data
+ assert_match '123', data
+ assert_match 'whatever_the_cryptogram_is', data
+ assert_xml_valid_to_wsdl(data)
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_network_tokenization_requests_with_other_brands
+ %w(visa mastercard other).each do |brand|
+ stub_comms do
+ credit_card = network_tokenization_credit_card(
+ '378282246310005',
+ brand: brand,
+ transaction_id: '123',
+ eci: '05',
+ payment_cryptogram: 'whatever_the_cryptogram_is',
+ )
+
+ @gateway.purchase(@amount, credit_card, @options)
+ end.check_request do |_, data, _|
+ assert_match '05', data
+ assert_match '123', data
+ assert_match 'whatever_the_cryptogram_is', data
+ assert_xml_valid_to_wsdl(data)
+ end.respond_with(successful_purchase_response)
+ end
+ end
+
+ def test_requests_include_card_authentication_data
+ authentication_hash = {
+ eci: '06',
+ cavv: 'SAMPLECAVV',
+ xid: 'SAMPLEXID'
+ }
+ options_with_authentication_data = @options.merge(authentication_hash)
+
+ stub_comms do
+ @gateway.purchase(@amount, @credit_card, options_with_authentication_data)
+ end.check_request do |endpoint, data, headers|
+ assert_match '06', data
+ assert_match 'SAMPLECAVV', data
+ assert_match 'SAMPLEXID', data
+ assert_xml_valid_to_wsdl(data)
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_card_type
+ assert_equal 'Visa', @gateway.send(:card_type, 'visa')
+ assert_equal 'Mastercard', @gateway.send(:card_type, 'master')
+ assert_equal 'American Express', @gateway.send(:card_type, 'american_express')
+ assert_equal 'JCB', @gateway.send(:card_type, 'jcb')
+ assert_equal 'Discover', @gateway.send(:card_type, 'discover')
+ end
+
+ def test_add_swipe_data_with_creditcard
+ @credit_card.track_data = 'Track Data'
+
+ stub_comms do
+ @gateway.purchase(@amount, @credit_card)
+ end.check_request do |endpoint, data, headers|
+ assert_match 'Track Data', data
+ assert_match 'R', data
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_transcript_scrubbing
+ assert @gateway.supports_scrubbing?
+ assert_equal @gateway.scrub(pre_scrub), post_scrub
+ end
+
+ def test_supports_network_tokenization
+ assert_instance_of TrueClass, @gateway.supports_network_tokenization?
+ end
+
+ private
+
+ def assert_xml_valid_to_wsdl(data)
+ xsd = Nokogiri::XML::Schema(File.open("#{File.dirname(__FILE__)}/../../schema/firstdata_e4/v27.xsd"))
+ doc = Nokogiri::XML(data)
+ errors = xsd.validate(doc)
+ assert_empty errors, "XSD validation errors in the following XML:\n#{doc}"
+ end
+
+ def pre_scrub
+ <<-PRE_SCRUBBED
+ opening connection to api.demo.globalgatewaye4.firstdata.com:443...
+ opened
+ starting SSL for api.demo.globalgatewaye4.firstdata.com:443...
+ SSL established
+ <- "POST /transaction/v27 HTTP/1.1\r\nContent-Type: application/xml\r\nX-Gge4-Date: 2018-07-03T07:35:34Z\r\nX-Gge4-Content-Sha1: 5335f81daf59c493fe5d4c18910d17eba69558d4\r\nAuthorization: GGE4_API 397439:iwaxRr8f3GQIMSucb+dmDeiwoAk=\r\nAccepts: application/xml\r\nConnection: close\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nHost: api.demo.globalgatewaye4.firstdata.com\r\nContent-Length: 807\r\n\r\n"
+ <- "SD8821-67cBhEc4GENtZ5fnVtpb2qlrhKUDprqtar001.00USD42424242424242420919Longbob LongsenVisa071123456 My StreetApt 1OttawaONK1C2N6CA1Store Purchase"
+ -> "HTTP/1.1 201 Created\r\n"
+ -> "Server: nginx\r\n"
+ -> "Date: Tue, 03 Jul 2018 07:35:34 GMT\r\n"
+ -> "Content-Type: application/xml; charset=utf-8\r\n"
+ -> "Transfer-Encoding: chunked\r\n"
+ -> "Connection: close\r\n"
+ -> "X-Frame-Options: SAMEORIGIN\r\n"
+ -> "X-XSS-Protection: 1; mode=block\r\n"
+ -> "X-Content-Type-Options: nosniff\r\n"
+ -> "X-GGE4-Date: 2018-07-03T07:35:34Z\r\n"
+ -> "X-GGE4-CONTENT-SHA1: 87ae8c40ae5afbfd060c7569645f3f6b4045994f\r\n"
+ -> "Authorization: GGE4_API 397439:dPOI+d2MkNJjBJhHTYUo0ieILw4=\r\n"
+ -> "Pragma: no-cache\r\n"
+ -> "Expires: Tue, 03 Jul 2018 06:35:34 GMT\r\n"
+ -> "Cache-Control: no-store, no-cache\r\n"
+ -> "X-Request-Id: 0f9ba7k2rd80a2tpch40\r\n"
+ -> "Location: https://api.demo.globalgatewaye4.firstdata.com/transaction/v27/2264726018\r\n"
+ -> "Status: 201 Created\r\n"
+ -> "Strict-Transport-Security: max-age=31536000; includeSubDomains\r\n"
+ -> "Strict-Transport-Security: max-age=315360000; includeSubdomains\r\n"
+ -> "\r\n"
+ -> "2da\r\n"
+ reading 2944 bytes...
+ -> "\n\n SD8821-67\n \n 00\n 1.0\n \n ############4242\n 2264726018\n \n \n \n \n ET121995\n 0919\n Longbob Longsen\n 1\n \n \n \n \n \n \n \n 7\n \n \n 1\n \n Store Purchase\n \n \n \n \n false\n true\n 00\n Transaction Normal\n 100\n Approved\n \n 001157\n 4\n M\n 1196543\n \n USD\n \n false\n Spreedly DEMO0095\n 123 Testing\n Durham\n North Carolina\n United States\n 27701\n \n \n Visa\n \n \n \n \n false\n ========== TRANSACTION RECORD ==========\nSpreedly DEMO0095\n123 Testing\nDurham, NC 27701\nUnited States\n\n\nTYPE: Purchase\n\nACCT: Visa $ 1.00 USD\n\nCARDHOLDER NAME : Longbob Longsen\nCARD NUMBER : ############4242\nDATE/TIME : 03 Jul 18 03:35:34\nREFERENCE # : 03 001157 M\nAUTHOR. # : ET121995\nTRANS. REF. : 1\n\n Approved - Thank You 100\n\n\nPlease retain this copy for your records.\n\nCardholder will pay above amount to\ncard issuer pursuant to cardholder\nagreement.\n========================================\n \n \n 456 My Street\n Apt 1\n Ottawa\n ON\n K1C2N6\n CA\n \n 123\n \n\n"
+ read 2944 bytes
+ Conn close
+ PRE_SCRUBBED
+ end
+
+ def post_scrub
+ <<-POST_SCRUBBED
+ opening connection to api.demo.globalgatewaye4.firstdata.com:443...
+ opened
+ starting SSL for api.demo.globalgatewaye4.firstdata.com:443...
+ SSL established
+ <- "POST /transaction/v27 HTTP/1.1\r\nContent-Type: application/xml\r\nX-Gge4-Date: 2018-07-03T07:35:34Z\r\nX-Gge4-Content-Sha1: 5335f81daf59c493fe5d4c18910d17eba69558d4\r\nAuthorization: GGE4_API 397439:iwaxRr8f3GQIMSucb+dmDeiwoAk=\r\nAccepts: application/xml\r\nConnection: close\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nHost: api.demo.globalgatewaye4.firstdata.com\r\nContent-Length: 807\r\n\r\n"
+ <- "SD8821-67[FILTERED]001.00USD[FILTERED]0919Longbob LongsenVisa071[FILTERED]456 My StreetApt 1OttawaONK1C2N6CA1Store Purchase"
+ -> "HTTP/1.1 201 Created\r\n"
+ -> "Server: nginx\r\n"
+ -> "Date: Tue, 03 Jul 2018 07:35:34 GMT\r\n"
+ -> "Content-Type: application/xml; charset=utf-8\r\n"
+ -> "Transfer-Encoding: chunked\r\n"
+ -> "Connection: close\r\n"
+ -> "X-Frame-Options: SAMEORIGIN\r\n"
+ -> "X-XSS-Protection: 1; mode=block\r\n"
+ -> "X-Content-Type-Options: nosniff\r\n"
+ -> "X-GGE4-Date: 2018-07-03T07:35:34Z\r\n"
+ -> "X-GGE4-CONTENT-SHA1: 87ae8c40ae5afbfd060c7569645f3f6b4045994f\r\n"
+ -> "Authorization: GGE4_API 397439:dPOI+d2MkNJjBJhHTYUo0ieILw4=\r\n"
+ -> "Pragma: no-cache\r\n"
+ -> "Expires: Tue, 03 Jul 2018 06:35:34 GMT\r\n"
+ -> "Cache-Control: no-store, no-cache\r\n"
+ -> "X-Request-Id: 0f9ba7k2rd80a2tpch40\r\n"
+ -> "Location: https://api.demo.globalgatewaye4.firstdata.com/transaction/v27/2264726018\r\n"
+ -> "Status: 201 Created\r\n"
+ -> "Strict-Transport-Security: max-age=31536000; includeSubDomains\r\n"
+ -> "Strict-Transport-Security: max-age=315360000; includeSubdomains\r\n"
+ -> "\r\n"
+ -> "2da\r\n"
+ reading 2944 bytes...
+ -> "\n\n SD8821-67\n \n 00\n 1.0\n \n [FILTERED]\n 2264726018\n \n \n \n \n ET121995\n 0919\n Longbob Longsen\n 1\n \n \n \n \n \n \n \n 7\n \n \n 1\n \n Store Purchase\n \n \n \n \n false\n true\n 00\n Transaction Normal\n 100\n Approved\n \n 001157\n 4\n M\n 1196543\n \n USD\n \n false\n Spreedly DEMO0095\n 123 Testing\n Durham\n North Carolina\n United States\n 27701\n \n \n Visa\n \n \n \n \n false\n ========== TRANSACTION RECORD ==========\nSpreedly DEMO0095\n123 Testing\nDurham, NC 27701\nUnited States\n\n\nTYPE: Purchase\n\nACCT: Visa $ 1.00 USD\n\nCARDHOLDER NAME : Longbob Longsen\nCARD NUMBER : [FILTERED]\nDATE/TIME : 03 Jul 18 03:35:34\nREFERENCE # : 03 001157 M\nAUTHOR. # : ET121995\nTRANS. REF. : 1\n\n Approved - Thank You 100\n\n\nPlease retain this copy for your records.\n\nCardholder will pay above amount to\ncard issuer pursuant to cardholder\nagreement.\n========================================\n \n \n 456 My Street\n Apt 1\n Ottawa\n ON\n K1C2N6\n CA\n \n [FILTERED]\n \n\n"
+ read 2944 bytes
+ Conn close
+ POST_SCRUBBED
+ end
+
+ def successful_purchase_response
+ <<-RESPONSE
+
+
+ AD1234-56
+
+ 00
+ 47.38
+
+ ############1111
+ 106625152
+
+
+
+ ET1700
+ 0913
+ Fred Burfle
+ 0
+
+
+
+
+
+
+
+
+
+
+
+ 77
+
+
+
+ 1.1.1.10
+
+ false
+ true
+ 00
+ Transaction Normal
+ 100
+ Approved
+
+ 000040
+ U
+ M
+ 3146117
+
+ USD
+
+ false
+ Friendly Inc DEMO0983
+ 123 King St
+ Toronto
+ Ontario
+ Canada
+ L7Z 3K8
+
+ 8938737759041111
+ =========== TRANSACTION RECORD ==========
+Friendly Inc DEMO0983
+123 King St
+Toronto, ON L7Z 3K8
+Canada
+
+
+TYPE: Purchase
+
+ACCT: Visa $ 47.38 USD
+
+CARD NUMBER : ############1111
+DATE/TIME : 28 Sep 12 07:54:48
+REFERENCE # : 000040 M
+AUTHOR. # : ET120454
+TRANS. REF. : 77
+
+ Approved - Thank You 100
+
+
+Please retain this copy for your records.
+
+Cardholder will pay above amount to card
+issuer pursuant to cardholder agreement.
+=========================================
+
+ 456 My Street
+ Apt 1
+ Ottawa
+ ON
+ K1C2N6
+ CA
+
+
+ RESPONSE
+ end
+
+ def successful_purchase_response_without_transarmor
+ <<-RESPONSE
+
+
+ AD1234-56
+
+ 00
+ 47.38
+
+ ############1111
+ 106625152
+
+
+
+ ET1700
+ 0913
+ Fred Burfle
+ 0
+
+
+
+
+
+
+
+
+
+
+
+ 77
+
+
+
+ 1.1.1.10
+
+ false
+ true
+ 00
+ Transaction Normal
+ 100
+ Approved
+
+ 000040
+ U
+ M
+ 3146117
+
+ USD
+
+ false
+ Friendly Inc DEMO0983
+ 123 King St
+ Toronto
+ Ontario
+ Canada
+ L7Z 3K8
+
+
+ =========== TRANSACTION RECORD ==========
+Friendly Inc DEMO0983
+123 King St
+Toronto, ON L7Z 3K8
+Canada
+
+
+TYPE: Purchase
+
+ACCT: Visa $ 47.38 USD
+
+CARD NUMBER : ############1111
+DATE/TIME : 28 Sep 12 07:54:48
+REFERENCE # : 000040 M
+AUTHOR. # : ET120454
+TRANS. REF. : 77
+
+ Approved - Thank You 100
+
+
+Please retain this copy for your records.
+
+Cardholder will pay above amount to card
+issuer pursuant to cardholder agreement.
+=========================================
+
+ RESPONSE
+ end
+
+ def successful_refund_response
+ <<-RESPONSE
+
+
+ AD1234-56
+
+ 34
+ 123
+
+ ############1111
+ 888
+
+
+
+ ET112216
+ 0913
+ Fred Burfle
+ 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1.1.1.10
+
+ false
+ true
+ 00
+ Transaction Normal
+ 100
+ Approved
+
+ 000041
+
+ I
+ 9176784
+
+ USD
+
+ false
+ Friendly Inc DEMO0983
+ 123 King St
+ Toronto
+ Ontario
+ Canada
+ L7Z 3K8
+
+ =========== TRANSACTION RECORD ==========
+Friendly Inc DEMO0983
+123 King St
+Toronto, ON L7Z 3K8
+Canada
+
+
+TYPE: Refund
+
+ACCT: Visa $ 23.69 USD
+
+CARD NUMBER : ############1111
+DATE/TIME : 28 Sep 12 08:31:23
+REFERENCE # : 000041 M
+AUTHOR. # : ET112216
+TRANS. REF. :
+
+ Approved - Thank You 100
+
+
+Please retain this copy for your records.
+
+=========================================
+
+ RESPONSE
+ end
+
+ def failed_purchase_response
+ <<-RESPONSE
+
+
+ AD1234-56
+
+ 00
+ 5013.0
+
+ ############1111
+ 555555
+
+
+
+
+ 0911
+ Fred Burfle
+ 0
+
+
+
+
+
+
+
+
+
+
+
+ 77
+
+
+
+ 1.1.1.10
+
+
+ 0
+
+ false
+ false
+ 00
+ Transaction Normal
+ 605
+ Invalid Expiration Date
+
+ 000033
+
+
+
+
+ USD
+
+ false
+ Friendly Inc DEMO0983
+ 123 King St
+ Toronto
+ Ontario
+ Canada
+ L7Z 3K8
+
+ =========== TRANSACTION RECORD ==========
+Friendly Inc DEMO0983
+123 King St
+Toronto, ON L7Z 3K8
+Canada
+
+
+TYPE: Purchase
+ACCT: Visa $ 5,013.00 USD
+CARD NUMBER : ############1111
+DATE/TIME : 25 Sep 12 07:27:00
+REFERENCE # : 000033 M
+AUTHOR. # :
+TRANS. REF. : 77
+Transaction not approved 605
+Please retain this copy for your records.
+=========================================
+
+ RESPONSE
+ end
+
+ def successful_verify_response
+ <<-RESPONSE
+
+
+ AD2552-05
+
+ 05
+ 0.0
+
+ ############4242
+ 25101911
+
+
+
+ ET184931
+ 0915
+ Longbob Longsen
+ 0
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+ Store Purchase
+
+ 75.182.123.244
+
+ false
+ true
+ 00
+ Transaction Normal
+ 100
+ Approved
+
+ 000040
+ 1
+ M
+ 7228838
+
+ USD
+
+ false
+ FriendlyInc
+ 123 Main Street
+ Durham
+ North Carolina
+ United States
+ 27592
+
+
+ Visa
+
+
+
+
+ false
+ =========== TRANSACTION RECORD ==========
+FriendlyInc DEMO0
+123 Main Street
+Durham, NC 27592
+United States
+
+
+TYPE: Auth Only
+
+ACCT: Visa $ 0.00 USD
+
+CARDHOLDER NAME : Longbob Longsen
+CARD NUMBER : ############4242
+DATE/TIME : 04 Jul 14 14:21:52
+REFERENCE # : 000040 M
+AUTHOR. # : ET184931
+TRANS. REF. : 1
+
+ Approved - Thank You 100
+
+
+Please retain this copy for your records.
+
+Cardholder will pay above amount to card
+issuer pursuant to cardholder agreement.
+=========================================
+
+ RESPONSE
+ end
+
+ def no_transaction_response
+ yamlexcep = <<-RESPONSE
+--- !ruby/exception:ActiveMerchant::ResponseError
+message: Failed with 400 Bad Request
+message:
+response: !ruby/object:Net::HTTPBadRequest
+ body: "Malformed request: Transaction Type is missing."
+ body_exist: true
+ code: "400"
+ header:
+ connection:
+ - Close
+ content-type:
+ - text/html; charset=utf-8
+ server:
+ - Apache
+ date:
+ - Fri, 28 Sep 2012 18:21:37 GMT
+ content-length:
+ - "47"
+ status:
+ - "400"
+ cache-control:
+ - no-cache
+ http_version: "1.1"
+ message: Bad Request
+ read: true
+ socket:
+ RESPONSE
+ YAML.safe_load(yamlexcep, ['Net::HTTPBadRequest', 'ActiveMerchant::ResponseError'])
+ end
+
+ def bad_credentials_response
+ yamlexcep = <<-RESPONSE
+--- !ruby/exception:ActiveMerchant::ResponseError
+message:
+response: !ruby/object:Net::HTTPUnauthorized
+ code: '401'
+ message: Authorization Required
+ body: Unauthorized Request. Bad or missing credentials.
+ read: true
+ header:
+ cache-control:
+ - no-cache
+ content-type:
+ - text/html; charset=utf-8
+ date:
+ - Tue, 30 Dec 2014 23:28:32 GMT
+ server:
+ - Apache
+ status:
+ - '401'
+ x-rack-cache:
+ - invalidate, pass
+ x-request-id:
+ - 4157e21cc5620a95ead8d2025b55bdf4
+ x-ua-compatible:
+ - IE=Edge,chrome=1
+ content-length:
+ - '49'
+ connection:
+ - Close
+ body_exist: true
+ http_version: '1.1'
+ socket:
+ RESPONSE
+ YAML.safe_load(yamlexcep, ['Net::HTTPUnauthorized', 'ActiveMerchant::ResponseError'])
+ end
+
+ def successful_void_response
+ <<-RESPONSE
+
+
+ AD1234-56
+
+ 33
+ 11.45
+
+ ############1111
+ 987123
+
+
+
+ ET112112
+ 0913
+ Fred Burfle
+ 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1.1.1.10
+
+
+ 0
+
+ false
+ true
+ 00
+ Transaction Normal
+ 100
+ Approved
+
+ 000166
+
+ I
+ 2046743
+
+ USD
+
+ false
+ FreshBooks DEMO0785
+ 35 Golden Ave
+ Toronto
+ Ontario
+ Canada
+ M6R 2J5
+
+=========== TRANSACTION RECORD ==========
+FreshBooks DEMO0785
+35 Golden Ave
+Toronto, ON M6R 2J5
+Canada
+
+
+TYPE: Void
+
+ACCT: Visa $ 47.38 USD
+
+CARD NUMBER : ############1111
+DATE/TIME : 15 Nov 12 08:20:36
+REFERENCE # : 000166 M
+AUTHOR. # : ET112112
+TRANS. REF. :
+
+Approved - Thank You 100
+
+
+Please retain this copy for your records.
+
+Cardholder will pay above amount to card
+issuer pursuant to cardholder agreement.
+=========================================
+
+RESPONSE
+ end
+end
From dc9206f9d3f2d65077ed6d0a6a52a5b0269a72a7 Mon Sep 17 00:00:00 2001
From: Abhinandan Ramaprasath
Date: Thu, 5 Jul 2018 23:47:20 -0400
Subject: [PATCH 0008/2234] Set contactless_magstripe_mode when transaction is
contactless magstripe. Fix silently failing tests.
---
lib/active_merchant/billing/gateways/stripe.rb | 1 +
test/unit/gateways/stripe_test.rb | 6 +++---
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb
index aeaac0b4b82..d680dfaf353 100644
--- a/lib/active_merchant/billing/gateways/stripe.rb
+++ b/lib/active_merchant/billing/gateways/stripe.rb
@@ -397,6 +397,7 @@ def add_creditcard(post, creditcard, options)
if emv_payment?(creditcard)
add_emv_creditcard(post, creditcard.icc_data)
post[:card][:read_method] = 'contactless' if creditcard.read_method == 'contactless'
+ post[:card][:read_method] = 'contactless_magstripe_mode' if creditcard.read_method == 'contactless_magstripe'
if creditcard.encrypted_pin_cryptogram.present? && creditcard.encrypted_pin_ksn.present?
post[:card][:encrypted_pin] = creditcard.encrypted_pin_cryptogram
post[:card][:encrypted_pin_key_id] = creditcard.encrypted_pin_ksn
diff --git a/test/unit/gateways/stripe_test.rb b/test/unit/gateways/stripe_test.rb
index c5b2b0ba2c4..4839433bd48 100644
--- a/test/unit/gateways/stripe_test.rb
+++ b/test/unit/gateways/stripe_test.rb
@@ -1105,7 +1105,7 @@ def test_contactless_flag_is_included_with_emv_card_data
@emv_credit_card.read_method = 'contactless'
@gateway.purchase(@amount, @emv_credit_card, @options)
end.check_request do |method, endpoint, data, headers|
- data =~ /card\[read_method\]=contactless/
+ assert data =~ /card\[read_method\]=contactless/
end.respond_with(successful_purchase_response)
end
@@ -1114,7 +1114,7 @@ def test_contactless_magstripe_flag_is_included_with_emv_card_data
@emv_credit_card.read_method = 'contactless_magstripe'
@gateway.purchase(@amount, @emv_credit_card, @options)
end.check_request do |method, endpoint, data, headers|
- data =~ /card\[read_method\]=contactless_magstripe_mode/
+ assert data =~ /card\[read_method\]=contactless_magstripe_mode/
end.respond_with(successful_purchase_response)
end
@@ -1122,7 +1122,7 @@ def test_contactless_flag_is_not_included_with_emv_card_data_by_default
stub_comms(@gateway, :ssl_request) do
@gateway.purchase(@amount, @emv_credit_card, @options)
end.check_request do |method, endpoint, data, headers|
- data !~ /card\[read_method\]=contactless/ && data !~ /card\[read_method\]=contactless_magstripe_mode/
+ assert data !~ /card\[read_method\]=contactless/ && data !~ /card\[read_method\]=contactless_magstripe_mode/
end.respond_with(successful_purchase_response)
end
From 5ddf3143ae5fddea02ba150ae258746ac49531f0 Mon Sep 17 00:00:00 2001
From: Abhinandan Ramaprasath
Date: Fri, 6 Jul 2018 11:37:33 -0400
Subject: [PATCH 0009/2234] Update changelog
---
CHANGELOG | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG b/CHANGELOG
index ef8d131a9d0..dfaff4123c5 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -4,6 +4,7 @@
* GlobalCollect: Don't overwrite contactDetails [curiousepic] #2915
* Pin Payments: Pass reference for statement desc [curiousepic] #2919
* FirstData: introduce v27 gateway [shasum] #2912
+* Stripe: Fix contactless magstripe support [abhiin1947] #2917
== Version 1.80.0 (July 4, 2018)
* Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909
From 220f06d98ca9bef18bc9eeceb3bda8770b02574b Mon Sep 17 00:00:00 2001
From: Niaja
Date: Fri, 15 Jun 2018 15:21:39 -0400
Subject: [PATCH 0010/2234] CT Payment: Add new gateway
Adds a new gateway (ct_payment) along with a certicication test file
Loaded suite test/unit/gateways/ct_payment_test
14 tests, 48 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Loaded suite test/remote/gateways/remote_ct_payment_test
20 tests, 56 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/ct_payment.rb | 267 ++++++++++++++++
test/fixtures.yml | 5 +
.../remote_ct_payment_certification_test.rb | 243 ++++++++++++++
.../remote/gateways/remote_ct_payment_test.rb | 173 ++++++++++
test/unit/gateways/ct_payment_test.rb | 302 ++++++++++++++++++
6 files changed, 991 insertions(+)
create mode 100644 lib/active_merchant/billing/gateways/ct_payment.rb
create mode 100644 test/remote/gateways/remote_ct_payment_certification_test.rb
create mode 100644 test/remote/gateways/remote_ct_payment_test.rb
create mode 100644 test/unit/gateways/ct_payment_test.rb
diff --git a/CHANGELOG b/CHANGELOG
index dfaff4123c5..44097274cb2 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -38,6 +38,7 @@
* Redsys: Fix payments with cc token [Leonardo Diez] #2586
* Redsys: Missing cardnumber params in xml_signed_fields [nerburish] #2628
* Bogus: allow authorizing with a tokenized card [Azdaroth] #2703
+* CT Payment: Add new gateway [nfarve] #2911
== Version 1.79.2 (June 2, 2018)
* Fix Gateway#max_version= overwriting min_version [bdewater]
diff --git a/lib/active_merchant/billing/gateways/ct_payment.rb b/lib/active_merchant/billing/gateways/ct_payment.rb
new file mode 100644
index 00000000000..889266d65c1
--- /dev/null
+++ b/lib/active_merchant/billing/gateways/ct_payment.rb
@@ -0,0 +1,267 @@
+module ActiveMerchant #:nodoc:
+ module Billing #:nodoc:
+ class CtPaymentGateway < Gateway
+ self.test_url = 'https://test.ctpaiement.ca/v1/'
+ self.live_url = 'hhtps://www.ctpaiement.com/v1/'
+
+ self.supported_countries = ['US', 'CA']
+ self.default_currency = 'CAD'
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club]
+
+ self.homepage_url = 'http://www.ct-payment.com/'
+ self.display_name = 'CT Payment'
+
+ STANDARD_ERROR_CODE_MAPPING = {
+ '14' => STANDARD_ERROR_CODE[:invalid_number],
+ '05' => STANDARD_ERROR_CODE[:card_declined],
+ 'M6' => STANDARD_ERROR_CODE[:card_declined],
+ '9068' => STANDARD_ERROR_CODE[:incorrect_number],
+ '9067' => STANDARD_ERROR_CODE[:incorrect_number]
+ }
+ CARD_BRAND = {
+ 'american_express' => 'A',
+ 'master' => 'M',
+ 'diners_club' => 'I',
+ 'visa' => 'V',
+ 'discover' => 'O'
+ }
+
+ def initialize(options={})
+ requires!(options, :api_key, :company_number, :merchant_number)
+ super
+ end
+
+ def purchase(money, payment, options={})
+ requires!(options, :order_id)
+ post = {}
+ add_terminal_number(post, options)
+ add_money(post, money)
+ add_operator_id(post, options)
+ add_invoice(post, money, options)
+ add_payment(post, payment)
+ add_address(post, payment, options)
+ add_customer_data(post, options)
+
+ payment.is_a?(String) ? commit('purchaseWithToken', post) : commit('purchase', post)
+ end
+
+ def authorize(money, payment, options={})
+ requires!(options, :order_id)
+ post = {}
+ add_money(post, money)
+ add_terminal_number(post, options)
+ add_operator_id(post, options)
+ add_invoice(post, money, options)
+ add_payment(post, payment)
+ add_address(post, payment, options)
+ add_customer_data(post, options)
+
+ payment.is_a?(String) ? commit('preAuthorizationWithToken', post) : commit('preAuthorization', post)
+ end
+
+ def capture(money, authorization, options={})
+ requires!(options, :order_id)
+ post = {}
+ add_invoice(post, money, options)
+ add_money(post, money)
+ add_customer_data(post, options)
+ transaction_number, authorization_number, invoice_number = split_authorization(authorization)
+ post[:OriginalTransactionNumber] = transaction_number
+ post[:OriginalAuthorizationNumber] = authorization_number
+ post[:OriginalInvoiceNumber] = invoice_number
+
+ commit('completion', post)
+ end
+
+ def refund(money, authorization, options={})
+ requires!(options, :order_id)
+ post = {}
+ add_invoice(post, money, options)
+ add_money(post, money)
+ add_customer_data(post, options)
+ transaction_number, _, invoice_number = split_authorization(authorization)
+ post[:OriginalTransactionNumber] = transaction_number
+ post[:OriginalInvoiceNumber] = invoice_number
+
+ commit('refundWithoutCard', post)
+ end
+
+ def credit(money, payment, options={})
+ requires!(options, :order_id)
+ post = {}
+ add_terminal_number(post, options)
+ add_money(post, money)
+ add_operator_id(post, options)
+ add_invoice(post, money, options)
+ add_payment(post, payment)
+ add_address(post, payment, options)
+ add_customer_data(post, options)
+
+ payment.is_a?(String) ? commit('refundWithToken', post) : commit('refund', post)
+ end
+
+ def void(authorization, options={})
+ post = {}
+ post[:InputType] = 'I'
+ post[:LanguageCode] = 'E'
+ transaction_number, _, invoice_number = split_authorization(authorization)
+ post[:OriginalTransactionNumber] = transaction_number
+ post[:OriginalInvoiceNumber] = invoice_number
+ add_operator_id(post, options)
+ add_customer_data(post, options)
+
+ commit('void', post)
+ end
+
+ def verify(credit_card, options={})
+ requires!(options, :order_id)
+ post = {}
+ add_terminal_number(post, options)
+ add_operator_id(post, options)
+ add_invoice(post,0, options)
+ add_payment(post, credit_card)
+ add_customer_data(post, options)
+
+ commit('verifyAccount', post)
+ end
+
+ def store(credit_card, options={})
+ requires!(options, :email)
+ post = {
+ LanguageCode: 'E',
+ Name: credit_card.name.rjust(50, ' '),
+ Email: options[:email].rjust(240, ' ')
+ }
+ add_operator_id(post, options)
+ add_payment(post, credit_card)
+ add_customer_data(post, options)
+
+ commit('recur/AddUser', post)
+ end
+
+ def supports_scrubbing?
+ true
+ end
+
+ def scrub(transcript)
+ transcript.
+ gsub(%r((&?auth-api-key=)[^&]*)i, '\1[FILTERED]').
+ gsub(%r((&?payload=)[a-zA-Z%0-9=]+)i, '\1[FILTERED]').
+ gsub(%r((&?token:)[^&]*)i, '\1[FILTERED]').
+ gsub(%r((&?cardNumber:)[^&]*)i, '\1[FILTERED]')
+ end
+
+ private
+
+ def add_terminal_number(post, options)
+ post[:MerchantTerminalNumber] = options[:merchant_terminal_number] || ' ' * 5
+ end
+
+ def add_money(post, money)
+ post[:Amount] = money.to_s.rjust(11,'0')
+ end
+
+ def add_operator_id(post, options)
+ post[:OperatorID] = options[:operator_id] || '0' * 8
+ end
+
+ def add_customer_data(post, options)
+ post[:CustomerNumber] = options[:customer_number] || '0' * 8
+ end
+
+ def add_address(post, creditcard, options)
+ if address = options[:billing_address] || options[:address]
+ post[:CardHolderAddress] = ("#{address[:address1]} #{address[:address2]}").rjust(20, ' ')
+ post[:CardHolderPostalCode] = address[:zip].gsub(/\s+/, '').rjust(9, ' ')
+ end
+ end
+
+ def add_invoice(post, money, options)
+ post[:CurrencyCode] = options[:currency] || (currency(money) if money)
+ post[:InvoiceNumber] = options[:order_id].rjust(12,'0')
+ post[:InputType] = 'I'
+ post[:LanguageCode] = 'E'
+ end
+
+ def add_payment(post, payment)
+ if payment.is_a?(String)
+ post[:Token] = split_authorization(payment)[3].strip
+ else
+ post[:CardType] = CARD_BRAND[payment.brand] || ' '
+ post[:CardNumber] = payment.number.rjust(40,' ')
+ post[:ExpirationDate] = expdate(payment)
+ post[:Cvv2Cvc2Number] = payment.verification_value
+ end
+ end
+
+ def parse(body)
+ JSON.parse(body)
+ end
+
+ def split_authorization(authorization)
+ authorization.split(';')
+ end
+
+ def commit_raw(action, parameters)
+ url = (test? ? test_url : live_url) + action
+ response = parse(ssl_post(url, post_data(action, parameters)))
+
+ final_response = Response.new(
+ success_from(response),
+ message_from(response),
+ response,
+ authorization: authorization_from(response),
+ avs_result: AVSResult.new(code: response['avsStatus']),
+ cvv_result: CVVResult.new(response['cvv2Cvc2Status']),
+ test: test?,
+ error_code: error_code_from(response)
+ )
+ end
+
+ def commit(action, parameters)
+ if action == 'void'
+ commit_raw(action, parameters)
+ else
+ MultiResponse.run(true) do |r|
+ r.process { commit_raw(action, parameters)}
+ r.process {
+ split_auth = split_authorization(r.authorization)
+ auth = (action.include?('recur')? split_auth[4] : split_auth[0])
+ action.include?('recur') ? commit_raw('recur/ack', {ID: auth}) : commit_raw('ack', {TransactionNumber: auth})
+ }
+ end
+ end
+ end
+
+ def success_from(response)
+ return true if response['returnCode'] == ' 00'
+ return true if response['returnCode'] == 'true'
+ return true if response['recurReturnCode'] == ' 00'
+ return false
+ end
+
+ def message_from(response)
+ response['errorDescription'] || (response['terminalDisp'].strip if response['terminalDisp'])
+ end
+
+ def authorization_from(response)
+ "#{response['transactionNumber']};#{response['authorizationNumber']};"\
+ "#{response['invoiceNumber']};#{response['token']};#{response['id']}"
+ end
+
+ def post_data(action, parameters = {})
+ parameters[:CompanyNumber] = @options[:company_number]
+ parameters[:MerchantNumber] = @options[:merchant_number]
+ parameters = parameters.collect do |key, value|
+ "#{key}=#{value}" unless (value.nil? || value.empty?)
+ end.join('&')
+ payload = Base64.strict_encode64(parameters)
+ "auth-api-key=#{@options[:api_key]}&payload=#{payload}".strip
+ end
+
+ def error_code_from(response)
+ STANDARD_ERROR_CODE_MAPPING[response['returnCode'].strip || response['recurReturnCode'.strip]] unless success_from(response)
+ end
+ end
+ end
+end
diff --git a/test/fixtures.yml b/test/fixtures.yml
index 99d218d55eb..d7775b0ef28 100644
--- a/test/fixtures.yml
+++ b/test/fixtures.yml
@@ -219,6 +219,11 @@ credorax:
merchant_id: 'merchant_id'
cipher_key: 'cipher_key'
+ct_payment:
+ api_key: SOMECREDENTIAL
+ company_number: '12345'
+ merchant_number: '12345678'
+
# Culqi does not provide public testing data
culqi:
merchant_id: MERCHANT
diff --git a/test/remote/gateways/remote_ct_payment_certification_test.rb b/test/remote/gateways/remote_ct_payment_certification_test.rb
new file mode 100644
index 00000000000..97ac2d6073b
--- /dev/null
+++ b/test/remote/gateways/remote_ct_payment_certification_test.rb
@@ -0,0 +1,243 @@
+require 'test_helper'
+
+class RemoteCtPaymentCertificationTest < Test::Unit::TestCase
+ def setup
+ @gateway = CtPaymentGateway.new(fixtures(:ct_payment))
+
+ @amount = 100
+ @declined_card = credit_card('4502244713161718')
+ @options = {
+ billing_address: address,
+ description: 'Store Purchase',
+ merchant_terminal_number: ' ',
+ order_id: generate_unique_id[0,11]
+ }
+ end
+
+ def test1
+ @credit_card = credit_card('4501161107217214', month: '07', year: 2025)
+ response = @gateway.purchase(@amount, @credit_card, @options)
+ print_result(1, response)
+ end
+
+ def test2
+ @credit_card = credit_card('5194419000000007', month: '07', year: 2025)
+ @credit_card.brand = 'master'
+ response = @gateway.purchase(@amount, @credit_card, @options)
+ print_result(2, response)
+ end
+
+ def test3
+ @credit_card = credit_card('341400000000000', month: '07', year: 2025, verification_value: '1234')
+ @credit_card.brand = 'american_express'
+ response = @gateway.purchase(@amount, @credit_card, @options)
+ print_result(3, response)
+ end
+
+ def test6
+ @credit_card = credit_card('341400000000000', month: '07', year: 2025, verification_value: '1234')
+ @credit_card.brand = 'american_express'
+ response = @gateway.credit(@amount, @credit_card, @options)
+ print_result(6, response)
+ end
+
+ def test4
+ @credit_card = credit_card('4501161107217214', month: '07', year: 2025)
+ response = @gateway.credit(@amount, @credit_card, @options)
+ print_result(4, response)
+ end
+
+ def test5
+ @credit_card = credit_card('5194419000000007', month: '07', year: 2025)
+ @credit_card.brand = 'master'
+ response = @gateway.credit(@amount, @credit_card, @options)
+ print_result(5, response)
+ end
+
+ def test7
+ @credit_card = credit_card('4501161107217214', month: '07', year: 2025)
+ response = @gateway.authorize(@amount, @credit_card, @options)
+ print_result(7, response)
+
+ capture_response = @gateway.capture(@amount, response.authorization, @options.merge(order_id: generate_unique_id[0,11]))
+ print_result(10, capture_response)
+ end
+
+ def test8
+ @credit_card = credit_card('5194419000000007', month: '07', year: 2025)
+ @credit_card.brand = 'master'
+ response = @gateway.authorize(@amount, @credit_card, @options)
+ print_result(8, response)
+
+ capture_response = @gateway.capture(@amount, response.authorization, @options.merge(order_id: generate_unique_id[0,11]))
+ print_result(11, capture_response)
+ end
+
+ def test9
+ @credit_card = credit_card('341400000000000', month: '07', year: 2025, verification_value: '1234')
+ @credit_card.brand = 'american_express'
+ response = @gateway.authorize(@amount, @credit_card, @options.merge(order_id: generate_unique_id[0,11]))
+ print_result(9, response)
+
+ capture_response = @gateway.capture(@amount, response.authorization, @options)
+ print_result(12, capture_response)
+ end
+
+ def test13
+ @credit_card = credit_card('4501161107217214', month: '07', year: 2025)
+ response = @gateway.purchase('000', @credit_card, @options)
+ print_result(13, response)
+ end
+
+ def test14
+ @credit_card = credit_card('4501161107217214', month: '07', year: 2025)
+ response = @gateway.purchase(-100, @credit_card, @options)
+ print_result(14, response)
+ end
+
+ def test15
+ @credit_card = credit_card('4501161107217214', month: '07', year: 2025)
+ response = @gateway.purchase('-1A0', @credit_card, @options)
+ print_result(15, response)
+ end
+
+ def test16
+ @credit_card = credit_card('5194419000000007', month: '07', year: 2025)
+ @credit_card.brand = 'visa'
+ response = @gateway.purchase(@amount, @credit_card, @options)
+ print_result(16, response)
+ end
+
+ def test17
+ @credit_card = credit_card('4501161107217214', month: '07', year: 2025)
+ @credit_card.brand = 'master'
+ response = @gateway.purchase(@amount, @credit_card, @options)
+ print_result(17, response)
+ end
+
+ def test18
+ @credit_card = credit_card('', month: '07', year: 2025)
+ response = @gateway.purchase(@amount, @credit_card, @options)
+ print_result(18, response)
+ end
+
+ def test19
+ @credit_card = credit_card('4501123412341234', month: '07', year: 2025)
+ response = @gateway.purchase(@amount, @credit_card, @options)
+ print_result(19, response)
+ end
+
+ def test20
+ #requires editing the model to run with a 3 digit expiration date
+ @credit_card = credit_card('4501161107217214', month: '07', year: 2)
+ response = @gateway.purchase(@amount, @credit_card, @options)
+ print_result(20, response)
+ end
+
+ def test21
+ @credit_card = credit_card('4501161107217214', month: 17, year: 2017)
+ response = @gateway.purchase(@amount, @credit_card, @options)
+ print_result(21, response)
+ end
+
+ def test22
+ @credit_card = credit_card('4501161107217214', month: '01', year: 2016)
+ response = @gateway.purchase(@amount, @credit_card, @options)
+ print_result(22, response)
+ end
+
+ def test24
+ @credit_card = credit_card('4502244713161718', month: '07', year: 2025)
+ response = @gateway.purchase(@amount, @credit_card, @options)
+ print_result(24, response)
+ end
+
+ def test25
+ # Needs an edit to the Model to run
+ @credit_card = credit_card('4501161107217214', month: '07', year: 2025)
+ response = @gateway.purchase(@amount, @credit_card, @options)
+ print_result(25, response)
+ end
+
+ def test26
+ @credit_card = credit_card('4501161107217214', month: '07', year: 2025)
+ response = @gateway.credit('000', @credit_card, @options)
+ print_result(26, response)
+ end
+
+ def test27
+ @credit_card = credit_card('4501161107217214', month: '07', year: 2025)
+ response = @gateway.credit(-100, @credit_card, @options)
+ print_result(27, response)
+ end
+
+ def test28
+ @credit_card = credit_card('4501161107217214', month: '07', year: 2025)
+ response = @gateway.credit('-1A0', @credit_card, @options)
+ print_result(28, response)
+ end
+
+ def test29
+ @credit_card = credit_card('5194419000000007', month: '07', year: 2025)
+ @credit_card.brand = 'visa'
+ response = @gateway.credit(@amount, @credit_card, @options)
+ print_result(29, response)
+ end
+
+ def test30
+ @credit_card = credit_card('4501161107217214', month: '07', year: 2025)
+ @credit_card.brand = 'master'
+ response = @gateway.credit(@amount, @credit_card, @options)
+ print_result(30, response)
+ end
+
+ def test31
+ @credit_card = credit_card('', month: '07', year: 2025)
+ response = @gateway.purchase(@amount, @credit_card, @options)
+ print_result(31, response)
+ end
+
+ def test32
+ @credit_card = credit_card('4501123412341234', month: '07', year: 2025)
+ response = @gateway.credit(@amount, @credit_card, @options)
+ print_result(32, response)
+ end
+
+ def test33
+ #requires edit to model to make 3 digit expiration date
+ @credit_card = credit_card('4501161107217214', month: '07', year: 2)
+ response = @gateway.credit(@amount, @credit_card, @options)
+ print_result(33, response)
+ end
+
+ def test34
+ @credit_card = credit_card('4501161107217214', month: 17, year: 2017)
+ response = @gateway.credit(@amount, @credit_card, @options)
+ print_result(34, response)
+ end
+
+ def test35
+ @credit_card = credit_card('4501161107217214', month: '01', year: 2016)
+ response = @gateway.credit(@amount, @credit_card, @options)
+ print_result(35, response)
+ end
+
+ def test37
+ @credit_card = credit_card('4502244713161718', month: '07', year: 2025)
+ response = @gateway.purchase(@amount, @credit_card, @options)
+ print_result(37, response)
+ end
+
+ def test38
+ # Needs an edit to the Model to run
+ @credit_card = credit_card('4501161107217214', month: '07', year: 2025)
+ response = @gateway.purchase(@amount, @credit_card, @options)
+ print_result(38, response)
+ end
+
+ def print_result(test_number, response)
+ puts "Test #{test_number} | transaction number: #{response.params['transactionNumber']}, invoice number #{response.params['invoiceNumber']}, timestamp: #{response.params['timeStamp']}, result: #{response.params['returnCode']}"
+ puts response.inspect
+ end
+
+end
diff --git a/test/remote/gateways/remote_ct_payment_test.rb b/test/remote/gateways/remote_ct_payment_test.rb
new file mode 100644
index 00000000000..43a198bd09a
--- /dev/null
+++ b/test/remote/gateways/remote_ct_payment_test.rb
@@ -0,0 +1,173 @@
+require 'test_helper'
+
+class RemoteCtPaymentTest < Test::Unit::TestCase
+ def setup
+ @gateway = CtPaymentGateway.new(fixtures(:ct_payment))
+
+ @amount = 100
+ @credit_card = credit_card('4501161107217214', month: '07', year: 2020)
+ @declined_card = credit_card('4502244713161718')
+ @options = {
+ billing_address: address,
+ description: 'Store Purchase',
+ order_id: generate_unique_id[0,11],
+ email: 'bigbird@sesamestreet.com'
+
+ }
+ end
+
+ def test_successful_purchase
+ response = @gateway.purchase(@amount, @credit_card, @options)
+ assert_success response
+ assert_equal 'APPROVED', response.message
+ end
+
+ def test_failed_purchase
+ response = @gateway.purchase(@amount, @declined_card, @options)
+ assert_failure response
+ assert_equal 'Transaction declined', response.message
+ end
+
+ def test_successful_authorize_and_capture
+ auth = @gateway.authorize(@amount, @credit_card, @options)
+ assert_success auth
+
+ assert capture = @gateway.capture(@amount, auth.authorization, @options.merge(order_id: generate_unique_id[0,11]))
+ assert_success capture
+ assert_equal 'APPROVED', capture.message
+ end
+
+ def test_failed_authorize
+ response = @gateway.authorize(@amount, @declined_card, @options)
+ assert_failure response
+ assert_equal 'Transaction declined', response.message
+ end
+
+ def test_partial_capture
+ auth = @gateway.authorize(@amount, @credit_card, @options)
+ assert_success auth
+
+ assert capture = @gateway.capture(@amount-1, auth.authorization, @options.merge(order_id: generate_unique_id[0,11]))
+ assert_success capture
+ end
+
+ def test_failed_capture
+ response = @gateway.capture(@amount, '0123456789asd;0123456789asdf;12345678', @options)
+ assert_failure response
+ assert_equal 'The original transaction number does not match any actual transaction', response.message
+ end
+
+ def test_successful_refund
+ purchase = @gateway.purchase(@amount, @credit_card, @options)
+ assert_success purchase
+
+ assert refund = @gateway.refund(@amount, purchase.authorization, @options.merge(order_id: generate_unique_id[0,11]))
+ assert_success refund
+ assert_equal 'APPROVED', refund.message
+ end
+
+ def test_partial_refund
+ purchase = @gateway.purchase(@amount, @credit_card, @options)
+ assert_success purchase
+
+ assert refund = @gateway.refund(@amount-1, purchase.authorization, @options.merge(order_id: generate_unique_id[0,11]))
+ assert_success refund
+ end
+
+ def test_failed_refund
+ response = @gateway.refund(@amount, '0123456789asd;0123456789asdf;12345678', @options.merge(order_id: generate_unique_id[0,11]))
+ assert_failure response
+ assert_equal 'The original transaction number does not match any actual transaction', response.message
+ end
+
+ def test_successful_void
+ purchase = @gateway.purchase(@amount, @credit_card, @options)
+ assert_success purchase
+
+ assert void = @gateway.void(purchase.authorization)
+ assert_success void
+ assert_equal 'APPROVED', void.message
+ end
+
+ def test_failed_void
+ response = @gateway.void('0123456789asd;0123456789asdf;12345678')
+ assert_failure response
+ assert_equal 'The original transaction number does not match any actual transaction', response.message
+ end
+
+ def test_successful_credit
+ assert response = @gateway.credit(@amount, @credit_card, @options)
+ assert_success response
+ assert_equal 'APPROVED', response.message
+ end
+
+ def test_successful_store
+ assert response = @gateway.store(@credit_card, @options)
+
+ assert_success response
+ assert !response.authorization.split(';')[3].nil?
+ end
+
+ def test_successful_purchase_using_stored_card
+ assert store_response = @gateway.store(@credit_card, @options)
+ assert_success store_response
+
+ response = @gateway.purchase(@amount, store_response.authorization, @options)
+ assert_success response
+ assert_equal 'APPROVED', response.message
+ end
+
+ def test_successful_authorize_using_stored_card
+ assert store_response = @gateway.store(@credit_card, @options)
+ assert_success store_response
+
+ response = @gateway.authorize(@amount, store_response.authorization, @options)
+ assert_success response
+ assert_equal 'APPROVED', response.message
+ end
+
+ def test_successful_verify
+ response = @gateway.verify(@credit_card, @options)
+ assert_success response
+ assert_match %r{APPROVED}, response.message
+ end
+
+ def test_failed_verify
+ response = @gateway.verify(@declined_card, @options)
+ assert_failure response
+ assert_match %r{Transaction declined}, response.message
+ end
+
+ def test_invalid_login
+ gateway = CtPaymentGateway.new(api_key: '', company_number: '12345', merchant_number: '12345')
+
+ response = gateway.purchase(@amount, @credit_card, @options)
+ assert_failure response
+ assert_match %r{Invalid API KEY}, response.message
+ end
+
+ def test_transcript_scrubbing
+ transcript = capture_transcript(@gateway) do
+ @gateway.purchase(@amount, @credit_card, @options)
+ end
+ transcript = @gateway.scrub(transcript)
+
+ assert_scrubbed(@credit_card.number, transcript)
+ assert_scrubbed(@credit_card.verification_value, transcript)
+ assert_scrubbed(Base64.strict_encode64(@credit_card.number), transcript)
+ assert_scrubbed(@gateway.options[:api_key], transcript)
+ end
+
+ def test_transcript_scrubbing_store
+ transcript = capture_transcript(@gateway) do
+ @gateway.store(@credit_card, @options)
+ end
+ transcript = @gateway.scrub(transcript)
+
+ assert_scrubbed(@credit_card.number, transcript)
+ assert_scrubbed(@credit_card.verification_value, transcript)
+ assert_scrubbed(Base64.strict_encode64(@credit_card.number), transcript)
+ assert_scrubbed(@gateway.options[:api_key], transcript)
+ end
+
+end
diff --git a/test/unit/gateways/ct_payment_test.rb b/test/unit/gateways/ct_payment_test.rb
new file mode 100644
index 00000000000..98da844e37f
--- /dev/null
+++ b/test/unit/gateways/ct_payment_test.rb
@@ -0,0 +1,302 @@
+require 'test_helper'
+
+class CtPaymentTest < Test::Unit::TestCase
+ def setup
+ @gateway = CtPaymentGateway.new(api_key: 'api_key', company_number: 'company number', merchant_number: 'merchant_number')
+ @credit_card = credit_card
+ @amount = 100
+
+ @options = {
+ order_id: '1',
+ billing_address: address,
+ description: 'Store Purchase'
+ }
+ end
+
+ def test_successful_purchase
+ @gateway.expects(:ssl_post).twice.returns(successful_purchase_response, successful_ack_response)
+
+ response = @gateway.purchase(@amount, @credit_card, @options)
+ assert_success response
+
+ assert_equal '000007708972;443752 ;021efc336262;;', response.authorization
+ assert response.test?
+ end
+
+ def test_failed_purchase
+ @gateway.expects(:ssl_post).returns(failed_purchase_response)
+
+ response = @gateway.purchase(@amount, @credit_card, @options)
+ assert_failure response
+ assert_equal Gateway::STANDARD_ERROR_CODE[:card_declined], response.error_code
+ end
+
+ def test_successful_authorize
+ @gateway.expects(:ssl_post).twice.returns(successful_authorize_response, successful_ack_response)
+
+ response = @gateway.authorize(@amount, @credit_card, @options)
+ assert_success response
+
+ assert_equal '000007708990;448572 ;0e7ebe0a804f;;', response.authorization
+ assert response.test?
+ end
+
+ def test_failed_authorize
+ @gateway.expects(:ssl_post).returns(failed_authorize_response)
+
+ response = @gateway.authorize(@amount, @credit_card, @options)
+ assert_failure response
+ assert_equal Gateway::STANDARD_ERROR_CODE[:card_declined], response.error_code
+ end
+
+ def test_successful_capture
+ @gateway.expects(:ssl_post).twice.returns(successful_capture_response, successful_ack_response)
+
+ response = @gateway.capture(@amount, '000007708990;448572 ;0e7ebe0a804f;', @options)
+ assert_success response
+
+ assert_equal '000007708991; ;0636aca3dd8e;;', response.authorization
+ assert response.test?
+ end
+
+ def test_failed_capture
+ @gateway.expects(:ssl_post).returns(failed_capture_response)
+
+ response = @gateway.capture(@amount, '0123456789asd;0123456789asdf;12345678', @options)
+ assert_failure response
+ assert_equal Gateway::STANDARD_ERROR_CODE[:incorrect_number], response.error_code
+ end
+
+ def test_successful_refund
+ @gateway.expects(:ssl_post).twice.returns(successful_refund_response, successful_ack_response)
+
+ response = @gateway.refund(@amount, '000007708990;448572 ;0e7ebe0a804f;', @options)
+ assert_success response
+
+ assert_equal '000007709004; ;0a08f144b6ea;;', response.authorization
+ assert response.test?
+ end
+
+ def test_failed_refund
+ @gateway.expects(:ssl_post).returns(failed_refund_response)
+
+ response = @gateway.capture(@amount, '0123456789asd;0123456789asdf;12345678', @options)
+ assert_failure response
+ assert_equal Gateway::STANDARD_ERROR_CODE[:incorrect_number], response.error_code
+ end
+
+ def test_successful_void
+ @gateway.expects(:ssl_post).returns(successful_void_response)
+
+ response = @gateway.void('000007708990;448572 ;0e7ebe0a804f;', @options)
+ assert_success response
+
+ assert_equal '000007709013; ;0de38871ce96;;', response.authorization
+ assert response.test?
+ end
+
+ def test_failed_void
+ @gateway.expects(:ssl_post).returns(failed_void_response)
+
+ response = @gateway.void('0123456789asd;0123456789asdf;12345678')
+ assert_failure response
+ assert_equal Gateway::STANDARD_ERROR_CODE[:incorrect_number], response.error_code
+ end
+
+ def test_successful_verify
+ @gateway.expects(:ssl_post).twice.returns(successful_verify_response, successful_ack_response)
+
+ response = @gateway.verify(@credit_card, @options)
+ assert_success response
+
+ assert_equal '000007709025; ;0b882fe35f69;;', response.authorization
+ assert response.test?
+ end
+
+ def test_failed_verify
+ @gateway.expects(:ssl_post).returns(failed_verify_response)
+
+ response = @gateway.verify(@credit_card, @options)
+ assert_failure response
+ assert_equal Gateway::STANDARD_ERROR_CODE[:card_declined], response.error_code
+ end
+
+ def test_successful_credit
+ @gateway.expects(:ssl_post).twice.returns(successful_credit_response, successful_ack_response)
+
+ response = @gateway.credit(@amount, @credit_card, @options)
+ assert_success response
+
+ assert_equal '000007709063; ;054902f2ded0;;', response.authorization
+ assert response.test?
+ end
+
+ def test_scrub
+ assert @gateway.supports_scrubbing?
+ assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed
+ end
+
+ private
+
+ def pre_scrubbed
+ %q(
+ opening connection to test.ctpaiement.ca:443...
+ opened
+ starting SSL for test.ctpaiement.ca:443...
+ SSL established
+ <- "POST /v1/purchase HTTP/1.1\r\nContent-Type: application/x-www-form-urlencoded\r\nConnection: close\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nHost: test.ctpaiement.ca\r\nContent-Length: 528\r\n\r\n"
+ <- "auth-api-key=R46SNTJ42UCJ3264182Y0T087YHBA50RTK&payload=TWVyY2hhbnRUZXJtaW5hbE51bWJlcj0gICAgICZBbW91bnQ9MDAwMDAwMDAxMDAmT3BlcmF0b3JJRD0wMDAwMDAwMCZDdXJyZW5jeUNvZGU9VVNEJkludm9pY2VOdW1iZXI9MDYzZmI1MmMyOTc2JklucHV0VHlwZT1JJkxhbmd1YWdlQ29kZT1FJkNhcmRUeXBlPVYmQ2FyZE51bWJlcj00NTAxMTYxMTA3MjE3MjE0JkV4cGlyYXRpb25EYXRlPTA3MjAmQ2FyZEhvbGRlckFkZHJlc3M9NDU2IE15IFN0cmVldE90dGF3YSAgICAgICAgICAgICAgICAgIE9OJkNhcmRIb2xkZXJQb3N0YWxDb2RlPSAgIEsxQzJONiZDdXN0b21lck51bWJlcj0wMDAwMDAwMCZDb21wYW55TnVtYmVyPTAwNTg5Jk1lcmNoYW50TnVtYmVyPTUzNDAwMDMw"
+ -> "HTTP/1.1 200 200\r\n"
+ -> "Date: Fri, 29 Jun 2018 18:21:07 GMT\r\n"
+ -> "Server: Apache\r\n"
+ -> "Strict-Transport-Security: max-age=31536000; includeSubDomains; preload\r\n"
+ -> "Connection: close\r\n"
+ -> "Transfer-Encoding: chunked\r\n"
+ -> "Content-Type: application/json;charset=ISO-8859-1\r\n"
+ -> "\r\n"
+ -> "480\r\n"
+ reading 1152 bytes...
+ -> "{\"returnCode\":\" 00\",\"errorDescription\":null,\"authorizationNumber\":\"448186 \",\"referenceNumber\":\" \",\"transactionNumber\":\"000007709037\",\"batchNumber\":\"0001\",\"terminalNumber\":\"13366\",\"serverNumber\":\"0001\",\"timeStamp\":\"20180629-14210749\",\"trxCode\":\"00\",\"merchantNumber\":\"53400030\",\"amount\":\"00000000100\",\"invoiceNumber\":\"063fb52c2976\",\"trxType\":\"C\",\"cardType\":\"V\",\"cardNumber\":\"450116XXXXXX7214 \",\"expirationDate\":\"0720\",\"bankTerminalNumber\":\"53400188\",\"trxDate\":\"06292018\",\"trxTime\":\"142107\",\"accountType\":\"0\",\"trxMethod\":\"T@1\",\"languageCode\":\"E\",\"sequenceNumber\":\"000000000028\",\"receiptDisp\":\" APPROVED-THANK YOU \",\"terminalDisp\":\"APPROVED \",\"operatorId\":\"00000000\",\"surchargeAmount\":\"\",\"companyNumber\":\"00589\",\"secureID\":\"\",\"cvv2Cvc2Status\":\" \",\"iopIssuerConfirmationNumber\":null,\"iopIssuerName\":null,\"avsStatus\":null,\"holderName\":null,\"threeDSStatus\":null,\"emvLabel\":null,\"emvAID\":null,\"emvTVR\":null,\"emvTSI\":null,\"emvTC\":null,\"demoMode\":null,\"terminalInvoiceNumber\":null,\"cashbackAmount\":null,\"tipAmount\":null,\"taxAmount\":null,\"cvmResults\":null,\"token\":null,\"customerNumber\":null,\"email\":\"\"}"
+ read 1152 bytes
+ reading 2 bytes...
+ -> "\r\n"
+ read 2 bytes
+ -> "0\r\n"
+ -> "\r\n"
+ Conn close
+ opening connection to test.ctpaiement.ca:443...
+ opened
+ starting SSL for test.ctpaiement.ca:443...
+ SSL established
+ <- "POST /v1/ack HTTP/1.1\r\nContent-Type: application/x-www-form-urlencoded\r\nConnection: close\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nHost: test.ctpaiement.ca\r\nContent-Length: 156\r\n\r\n"
+ <- "auth-api-key=R46SNTJ42UCJ3264182Y0T087YHBA50RTK&payload=VHJhbnNhY3Rpb25OdW1iZXI9MDAwMDA3NzA5MDM3JkNvbXBhbnlOdW1iZXI9MDA1ODkmTWVyY2hhbnROdW1iZXI9NTM0MDAwMzA="
+ -> "HTTP/1.1 200 200\r\n"
+ -> "Date: Fri, 29 Jun 2018 18:21:08 GMT\r\n"
+ -> "Server: Apache\r\n"
+ -> "Strict-Transport-Security: max-age=31536000; includeSubDomains; preload\r\n"
+ -> "Connection: close\r\n"
+ -> "Transfer-Encoding: chunked\r\n"
+ -> "Content-Type: application/json;charset=ISO-8859-1\r\n"
+ -> "\r\n"
+ -> "15\r\n"
+ reading 21 bytes...
+ -> "{\"returnCode\":\"true\"}"
+ read 21 bytes
+ reading 2 bytes...
+ -> "\r\n"
+ read 2 bytes
+ -> "0\r\n"
+ -> "\r\n"
+ Conn close
+ )
+ end
+
+ def post_scrubbed
+ %q(
+ opening connection to test.ctpaiement.ca:443...
+ opened
+ starting SSL for test.ctpaiement.ca:443...
+ SSL established
+ <- "POST /v1/purchase HTTP/1.1\r\nContent-Type: application/x-www-form-urlencoded\r\nConnection: close\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nHost: test.ctpaiement.ca\r\nContent-Length: 528\r\n\r\n"
+ <- "auth-api-key=[FILTERED]&payload=[FILTERED]"
+ -> "HTTP/1.1 200 200\r\n"
+ -> "Date: Fri, 29 Jun 2018 18:21:07 GMT\r\n"
+ -> "Server: Apache\r\n"
+ -> "Strict-Transport-Security: max-age=31536000; includeSubDomains; preload\r\n"
+ -> "Connection: close\r\n"
+ -> "Transfer-Encoding: chunked\r\n"
+ -> "Content-Type: application/json;charset=ISO-8859-1\r\n"
+ -> "\r\n"
+ -> "480\r\n"
+ reading 1152 bytes...
+ -> "{\"returnCode\":\" 00\",\"errorDescription\":null,\"authorizationNumber\":\"448186 \",\"referenceNumber\":\" \",\"transactionNumber\":\"000007709037\",\"batchNumber\":\"0001\",\"terminalNumber\":\"13366\",\"serverNumber\":\"0001\",\"timeStamp\":\"20180629-14210749\",\"trxCode\":\"00\",\"merchantNumber\":\"53400030\",\"amount\":\"00000000100\",\"invoiceNumber\":\"063fb52c2976\",\"trxType\":\"C\",\"cardType\":\"V\",\"cardNumber\":\"450116XXXXXX7214 \",\"expirationDate\":\"0720\",\"bankTerminalNumber\":\"53400188\",\"trxDate\":\"06292018\",\"trxTime\":\"142107\",\"accountType\":\"0\",\"trxMethod\":\"T@1\",\"languageCode\":\"E\",\"sequenceNumber\":\"000000000028\",\"receiptDisp\":\" APPROVED-THANK YOU \",\"terminalDisp\":\"APPROVED \",\"operatorId\":\"00000000\",\"surchargeAmount\":\"\",\"companyNumber\":\"00589\",\"secureID\":\"\",\"cvv2Cvc2Status\":\" \",\"iopIssuerConfirmationNumber\":null,\"iopIssuerName\":null,\"avsStatus\":null,\"holderName\":null,\"threeDSStatus\":null,\"emvLabel\":null,\"emvAID\":null,\"emvTVR\":null,\"emvTSI\":null,\"emvTC\":null,\"demoMode\":null,\"terminalInvoiceNumber\":null,\"cashbackAmount\":null,\"tipAmount\":null,\"taxAmount\":null,\"cvmResults\":null,\"token\":null,\"customerNumber\":null,\"email\":\"\"}"
+ read 1152 bytes
+ reading 2 bytes...
+ -> "\r\n"
+ read 2 bytes
+ -> "0\r\n"
+ -> "\r\n"
+ Conn close
+ opening connection to test.ctpaiement.ca:443...
+ opened
+ starting SSL for test.ctpaiement.ca:443...
+ SSL established
+ <- "POST /v1/ack HTTP/1.1\r\nContent-Type: application/x-www-form-urlencoded\r\nConnection: close\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nHost: test.ctpaiement.ca\r\nContent-Length: 156\r\n\r\n"
+ <- "auth-api-key=[FILTERED]&payload=[FILTERED]"
+ -> "HTTP/1.1 200 200\r\n"
+ -> "Date: Fri, 29 Jun 2018 18:21:08 GMT\r\n"
+ -> "Server: Apache\r\n"
+ -> "Strict-Transport-Security: max-age=31536000; includeSubDomains; preload\r\n"
+ -> "Connection: close\r\n"
+ -> "Transfer-Encoding: chunked\r\n"
+ -> "Content-Type: application/json;charset=ISO-8859-1\r\n"
+ -> "\r\n"
+ -> "15\r\n"
+ reading 21 bytes...
+ -> "{\"returnCode\":\"true\"}"
+ read 21 bytes
+ reading 2 bytes...
+ -> "\r\n"
+ read 2 bytes
+ -> "0\r\n"
+ -> "\r\n"
+ Conn close
+ )
+ end
+
+ def successful_purchase_response
+ '{"returnCode":" 00","errorDescription":null,"authorizationNumber":"443752 ","referenceNumber":" ","transactionNumber":"000007708972","batchNumber":"0001","terminalNumber":"13366","serverNumber":"0001","timeStamp":"20180629-12110905","trxCode":"00","merchantNumber":"53400030","amount":"00000000100","invoiceNumber":"021efc336262","trxType":"C","cardType":"V","cardNumber":"450116XXXXXX7214 ","expirationDate":"0720","bankTerminalNumber":"53400188","trxDate":"06292018","trxTime":"121109","accountType":"0","trxMethod":"T@1","languageCode":"E","sequenceNumber":"000000000008","receiptDisp":" APPROVED-THANK YOU ","terminalDisp":"APPROVED ","operatorId":"00000000","surchargeAmount":"","companyNumber":"00589","secureID":"","cvv2Cvc2Status":" ","iopIssuerConfirmationNumber":null,"iopIssuerName":null,"avsStatus":null,"holderName":null,"threeDSStatus":null,"emvLabel":null,"emvAID":null,"emvTVR":null,"emvTSI":null,"emvTC":null,"demoMode":null,"terminalInvoiceNumber":null,"cashbackAmount":null,"tipAmount":null,"taxAmount":null,"cvmResults":null,"token":null,"customerNumber":null,"email":""}'
+ end
+
+ def successful_ack_response
+ '{"returnCode":"true"}'
+ end
+
+ def failed_purchase_response
+ '{"returnCode":" 05","errorDescription":"Transaction declined","authorizationNumber":" ","referenceNumber":" ","transactionNumber":"000007708975","batchNumber":"0000","terminalNumber":"13366","serverNumber":"0001","timeStamp":"20180629-12272768","trxCode":"00","merchantNumber":"53400030","amount":"00000000100","invoiceNumber":"098096b31937","trxType":"C","cardType":"V","cardNumber":"450224XXXXXX1718 ","expirationDate":"0919","bankTerminalNumber":"53400188","trxDate":"06292018","trxTime":"122727","accountType":"0","trxMethod":"T@1","languageCode":"E","sequenceNumber":"000000000009","receiptDisp":" TRANSACTION NOT APPROVED ","terminalDisp":"05-DECLINE ","operatorId":"00000000","surchargeAmount":"","companyNumber":"00589","secureID":"","cvv2Cvc2Status":" ","iopIssuerConfirmationNumber":null,"iopIssuerName":null,"avsStatus":null,"holderName":null,"threeDSStatus":null,"emvLabel":null,"emvAID":null,"emvTVR":null,"emvTSI":null,"emvTC":null,"demoMode":null,"terminalInvoiceNumber":null,"cashbackAmount":null,"tipAmount":null,"taxAmount":null,"cvmResults":null,"token":null,"customerNumber":null,"email":""}'
+ end
+
+ def successful_authorize_response
+ '{"returnCode":" 00","errorDescription":null,"authorizationNumber":"448572 ","referenceNumber":" ","transactionNumber":"000007708990","batchNumber":"0001","terminalNumber":"13367","serverNumber":"0001","timeStamp":"20180629-12501747","trxCode":"01","merchantNumber":"53400030","amount":"00000000100","invoiceNumber":"0e7ebe0a804f","trxType":"C","cardType":"V","cardNumber":"450116XXXXXX7214 ","expirationDate":"0720","bankTerminalNumber":"53400189","trxDate":"06292018","trxTime":"125017","accountType":"0","trxMethod":"T@1","languageCode":"E","sequenceNumber":"000000000014","receiptDisp":" APPROVED-THANK YOU ","terminalDisp":"APPROVED ","operatorId":"00000000","surchargeAmount":"","companyNumber":"00589","secureID":"","cvv2Cvc2Status":" ","iopIssuerConfirmationNumber":null,"iopIssuerName":null,"avsStatus":null,"holderName":null,"threeDSStatus":null,"emvLabel":null,"emvAID":null,"emvTVR":null,"emvTSI":null,"emvTC":null,"demoMode":null,"terminalInvoiceNumber":null,"cashbackAmount":null,"tipAmount":null,"taxAmount":null,"cvmResults":null,"token":null,"customerNumber":null,"email":""}'
+ end
+
+ def failed_authorize_response
+ '{"returnCode":" 05","errorDescription":"Transaction declined","authorizationNumber":" ","referenceNumber":" ","transactionNumber":"000007708993","batchNumber":"0000","terminalNumber":"13367","serverNumber":"0001","timeStamp":"20180629-13072751","trxCode":"01","merchantNumber":"53400030","amount":"00000000100","invoiceNumber":"02ec22cbb5db","trxType":"C","cardType":"V","cardNumber":"450224XXXXXX1718 ","expirationDate":"0919","bankTerminalNumber":"53400189","trxDate":"06292018","trxTime":"130727","accountType":"0","trxMethod":"T@1","languageCode":"E","sequenceNumber":"000000000015","receiptDisp":" TRANSACTION NOT APPROVED ","terminalDisp":"05-DECLINE ","operatorId":"00000000","surchargeAmount":"","companyNumber":"00589","secureID":"","cvv2Cvc2Status":" ","iopIssuerConfirmationNumber":null,"iopIssuerName":null,"avsStatus":null,"holderName":null,"threeDSStatus":null,"emvLabel":null,"emvAID":null,"emvTVR":null,"emvTSI":null,"emvTC":null,"demoMode":null,"terminalInvoiceNumber":null,"cashbackAmount":null,"tipAmount":null,"taxAmount":null,"cvmResults":null,"token":null,"customerNumber":null,"email":""}'
+ end
+
+ def successful_capture_response
+ '{"returnCode":" 00","errorDescription":null,"authorizationNumber":" ","referenceNumber":" ","transactionNumber":"000007708991","batchNumber":"0001","terminalNumber":"13366","serverNumber":"0001","timeStamp":"20180629-12501869","trxCode":"02","merchantNumber":"53400030","amount":"00000000100","invoiceNumber":"0636aca3dd8e","trxType":"C","cardType":"V","cardNumber":"450116XXXXXX7214 ","expirationDate":"0720","bankTerminalNumber":"53400188","trxDate":"06292018","trxTime":"125018","accountType":"0","trxMethod":"T@1","languageCode":"E","sequenceNumber":"000000000015","receiptDisp":" APPROVED-THANK YOU ","terminalDisp":"APPROVED ","operatorId":"00000000","surchargeAmount":"","companyNumber":"00589","secureID":"","cvv2Cvc2Status":" ","iopIssuerConfirmationNumber":null,"iopIssuerName":null,"avsStatus":null,"holderName":null,"threeDSStatus":null,"emvLabel":null,"emvAID":null,"emvTVR":null,"emvTSI":null,"emvTC":null,"demoMode":null,"terminalInvoiceNumber":null,"cashbackAmount":null,"tipAmount":null,"taxAmount":null,"cvmResults":null,"token":null,"customerNumber":null,"email":""}'
+ end
+
+ def failed_capture_response
+ '{"returnCode":"9068","errorDescription":"The original transaction number does not match any actual transaction","authorizationNumber":" ","referenceNumber":" ","transactionNumber":"000007708999","batchNumber":" ","terminalNumber":" ","serverNumber":" ","timeStamp":"20180629-13224441","trxCode":" ","merchantNumber":" ","amount":"00000000000","invoiceNumber":" ","trxType":" ","cardType":" ","cardNumber":" ","expirationDate":" ","bankTerminalNumber":" ","trxDate":" ","trxTime":" ","accountType":" ","trxMethod":" ","languageCode":" ","sequenceNumber":" ","receiptDisp":" OPERATION NON COMPLETEE ","terminalDisp":"9068: Contactez support.","operatorId":" ","surchargeAmount":" ","companyNumber":" ","secureID":"","cvv2Cvc2Status":" ","iopIssuerConfirmationNumber":null,"iopIssuerName":null,"avsStatus":null,"holderName":null,"threeDSStatus":null,"emvLabel":null,"emvAID":null,"emvTVR":null,"emvTSI":null,"emvTC":null,"demoMode":null,"terminalInvoiceNumber":null,"cashbackAmount":null,"tipAmount":null,"taxAmount":null,"cvmResults":null,"token":null,"customerNumber":null,"email":""}'
+ end
+
+ def successful_refund_response
+ ' {"returnCode":" 00","errorDescription":null,"authorizationNumber":" ","referenceNumber":" ","transactionNumber":"000007709004","batchNumber":"0001","terminalNumber":"13367","serverNumber":"0001","timeStamp":"20180629-13294388","trxCode":"03","merchantNumber":"53400030","amount":"00000000100","invoiceNumber":"0a08f144b6ea","trxType":"C","cardType":"V","cardNumber":"450116XXXXXX7214 ","expirationDate":"0720","bankTerminalNumber":"53400189","trxDate":"06292018","trxTime":"132944","accountType":"0","trxMethod":"T@1","languageCode":"E","sequenceNumber":"000000000019","receiptDisp":" APPROVED-THANK YOU ","terminalDisp":"APPROVED ","operatorId":"00000000","surchargeAmount":"","companyNumber":"00589","secureID":"","cvv2Cvc2Status":" ","iopIssuerConfirmationNumber":null,"iopIssuerName":null,"avsStatus":null,"holderName":null,"threeDSStatus":null,"emvLabel":null,"emvAID":null,"emvTVR":null,"emvTSI":null,"emvTC":null,"demoMode":null,"terminalInvoiceNumber":null,"cashbackAmount":null,"tipAmount":null,"taxAmount":null,"cvmResults":null,"token":null,"customerNumber":null,"email":""}'
+ end
+
+ def failed_refund_response
+ '{"returnCode":"9068","errorDescription":"The original transaction number does not match any actual transaction","authorizationNumber":" ","referenceNumber":" ","transactionNumber":"000007709009","batchNumber":" ","terminalNumber":" ","serverNumber":" ","timeStamp":"20180629-13402119","trxCode":" ","merchantNumber":" ","amount":"00000000000","invoiceNumber":" ","trxType":" ","cardType":" ","cardNumber":" ","expirationDate":" ","bankTerminalNumber":" ","trxDate":" ","trxTime":" ","accountType":" ","trxMethod":" ","languageCode":" ","sequenceNumber":" ","receiptDisp":" OPERATION NON COMPLETEE ","terminalDisp":"9068: Contactez support.","operatorId":" ","surchargeAmount":" ","companyNumber":" ","secureID":"","cvv2Cvc2Status":" ","iopIssuerConfirmationNumber":null,"iopIssuerName":null,"avsStatus":null,"holderName":null,"threeDSStatus":null,"emvLabel":null,"emvAID":null,"emvTVR":null,"emvTSI":null,"emvTC":null,"demoMode":null,"terminalInvoiceNumber":null,"cashbackAmount":null,"tipAmount":null,"taxAmount":null,"cvmResults":null,"token":null,"customerNumber":null,"email":""}'
+ end
+
+ def successful_void_response
+ '{"returnCode":" 00","errorDescription":null,"authorizationNumber":" ","referenceNumber":" ","transactionNumber":"000007709013","batchNumber":"0001","terminalNumber":"13367","serverNumber":"0001","timeStamp":"20180629-13451840","trxCode":"04","merchantNumber":"53400030","amount":"00000000100","invoiceNumber":"0de38871ce96","trxType":"C","cardType":"V","cardNumber":"450116XXXXXX7214","expirationDate":"0720","bankTerminalNumber":"53400189","trxDate":"06292018","trxTime":"134518","accountType":"0","trxMethod":"T@1","languageCode":"E","sequenceNumber":"000000000023","receiptDisp":" APPROVED-THANK YOU ","terminalDisp":"APPROVED ","operatorId":"00000000","surchargeAmount":" ","companyNumber":" ","secureID":"","cvv2Cvc2Status":" ","iopIssuerConfirmationNumber":null,"iopIssuerName":null,"avsStatus":null,"holderName":null,"threeDSStatus":null,"emvLabel":null,"emvAID":null,"emvTVR":null,"emvTSI":null,"emvTC":null,"demoMode":null,"terminalInvoiceNumber":null,"cashbackAmount":null,"tipAmount":null,"taxAmount":null,"cvmResults":null,"token":null,"customerNumber":null,"email":""}'
+ end
+
+ def failed_void_response
+ '{"returnCode":"9068","errorDescription":"The original transaction number does not match any actual transaction","authorizationNumber":" ","referenceNumber":" ","transactionNumber":"0000000000-1","batchNumber":" ","terminalNumber":" ","serverNumber":" ","timeStamp":"20180629-13520693","trxCode":" ","merchantNumber":" ","amount":"00000000000","invoiceNumber":" ","trxType":" ","cardType":" ","cardNumber":" ","expirationDate":" ","bankTerminalNumber":" ","trxDate":" ","trxTime":" ","accountType":" ","trxMethod":" ","languageCode":" ","sequenceNumber":" ","receiptDisp":" OPERATION NOT COMPLETED ","terminalDisp":"9068: Contact support. ","operatorId":" ","surchargeAmount":" ","companyNumber":" ","secureID":"","cvv2Cvc2Status":" ","iopIssuerConfirmationNumber":null,"iopIssuerName":null,"avsStatus":null,"holderName":null,"threeDSStatus":null,"emvLabel":null,"emvAID":null,"emvTVR":null,"emvTSI":null,"emvTC":null,"demoMode":null,"terminalInvoiceNumber":null,"cashbackAmount":null,"tipAmount":null,"taxAmount":null,"cvmResults":null,"token":null,"customerNumber":null,"email":""}'
+ end
+
+ def successful_verify_response
+ '{"returnCode":" 00","errorDescription":null,"authorizationNumber":" ","referenceNumber":" ","transactionNumber":"000007709025","batchNumber":"0001","terminalNumber":"13367","serverNumber":"0001","timeStamp":"20180629-14023575","trxCode":"08","merchantNumber":"53400030","amount":"00000000000","invoiceNumber":"0b882fe35f69","trxType":"C","cardType":"V","cardNumber":"450116XXXXXX7214 ","expirationDate":"0720","bankTerminalNumber":"53400189","trxDate":"06292018","trxTime":"140236","accountType":"0","trxMethod":"T@1","languageCode":"E","sequenceNumber":"000000000025","receiptDisp":" APPROVED-THANK YOU ","terminalDisp":"APPROVED ","operatorId":"00000000","surchargeAmount":"","companyNumber":"00589","secureID":"","cvv2Cvc2Status":" ","iopIssuerConfirmationNumber":null,"iopIssuerName":null,"avsStatus":null,"holderName":null,"threeDSStatus":null,"emvLabel":null,"emvAID":null,"emvTVR":null,"emvTSI":null,"emvTC":null,"demoMode":null,"terminalInvoiceNumber":null,"cashbackAmount":null,"tipAmount":null,"taxAmount":null,"cvmResults":null,"token":null,"customerNumber":null,"email":""}'
+ end
+
+ def failed_verify_response
+ '{"returnCode":" 05","errorDescription":"Transaction declined","authorizationNumber":" ","referenceNumber":" ","transactionNumber":"000007709029","batchNumber":"0000","terminalNumber":"13367","serverNumber":"0001","timeStamp":"20180629-14104707","trxCode":"08","merchantNumber":"53400030","amount":"00000000000","invoiceNumber":"0c0054d2bb7a","trxType":"C","cardType":"V","cardNumber":"450224XXXXXX1718 ","expirationDate":"0919","bankTerminalNumber":"53400189","trxDate":"06292018","trxTime":"141047","accountType":"0","trxMethod":"T@1","languageCode":"E","sequenceNumber":"000000000026","receiptDisp":" TRANSACTION NOT APPROVED ","terminalDisp":"05-DECLINE ","operatorId":"00000000","surchargeAmount":"","companyNumber":"00589","secureID":"","cvv2Cvc2Status":" ","iopIssuerConfirmationNumber":null,"iopIssuerName":null,"avsStatus":null,"holderName":null,"threeDSStatus":null,"emvLabel":null,"emvAID":null,"emvTVR":null,"emvTSI":null,"emvTC":null,"demoMode":null,"terminalInvoiceNumber":null,"cashbackAmount":null,"tipAmount":null,"taxAmount":null,"cvmResults":null,"token":null,"customerNumber":null,"email":""}'
+ end
+
+ def successful_credit_response
+ '{"returnCode":" 00","errorDescription":null,"authorizationNumber":" ","referenceNumber":" ","transactionNumber":"000007709063","batchNumber":"0001","terminalNumber":"13366","serverNumber":"0001","timeStamp":"20180629-14420931","trxCode":"03","merchantNumber":"53400030","amount":"00000000100","invoiceNumber":"054902f2ded0","trxType":"C","cardType":"V","cardNumber":"450116XXXXXX7214 ","expirationDate":"0720","bankTerminalNumber":"53400188","trxDate":"06292018","trxTime":"144209","accountType":"0","trxMethod":"T@1","languageCode":"E","sequenceNumber":"000000000032","receiptDisp":" APPROVED-THANK YOU ","terminalDisp":"APPROVED ","operatorId":"00000000","surchargeAmount":"","companyNumber":"00589","secureID":"","cvv2Cvc2Status":" ","iopIssuerConfirmationNumber":null,"iopIssuerName":null,"avsStatus":null,"holderName":null,"threeDSStatus":null,"emvLabel":null,"emvAID":null,"emvTVR":null,"emvTSI":null,"emvTC":null,"demoMode":null,"terminalInvoiceNumber":null,"cashbackAmount":null,"tipAmount":null,"taxAmount":null,"cvmResults":null,"token":null,"customerNumber":null,"email":""}'
+ end
+end
From 44bdbd98bea484c2e0671c1e535392c260e357ae Mon Sep 17 00:00:00 2001
From: Bart
Date: Tue, 10 Jul 2018 10:31:08 -0400
Subject: [PATCH 0011/2234] Update contributing document regarding gateways [ci
skip]
---
CONTRIBUTING.md | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 7d7989b171d..c9ce8e449ea 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,10 +1,16 @@
# Contributing guidelines
-We gladly accept bugfixes and new gateways. Please follow the guidelines here to ensure your work is accepted.
+We gladly accept bugfixes, but are not actively looking to add new gateways. Please follow the guidelines here to ensure your work is accepted.
## New Gateways
-Please see the [ActiveMerchant Guide to Contributing a new Gateway](https://github.com/activemerchant/active_merchant/wiki/contributing) for information on adding a new gateway to ActiveMerchant.
+We're not taking on many new gateways at the moment. The team maintaining ActiveMerchant is small and with the limited resources available, we generally prefer not to support a gateway than to support a gateway poorly.
+
+Please see the [ActiveMerchant Guide to Contributing a new Gateway](https://github.com/activemerchant/active_merchant/wiki/contributing) for information on creating a new gateway. You can place your gateway code in your application's `lib/active_merchant/billing` folder to use it.
+
+We would like to work with the community to figure out how gateways can release and maintain their integrations outside of the the ActiveMerchant repository. Please join [the discussion](https://github.com/activemerchant/active_merchant/issues/2923) if you're interested or have ideas.
+
+Gateway placement within Shopify is available by invitation only at this time.
## Issues & Bugfixes
@@ -25,10 +31,6 @@ When submitting a pull request to resolve an issue:
4. Push your changes to your fork (`git push origin my_awesome_feature`)
5. Open a [Pull Request](https://github.com/activemerchant/active_merchant/pulls)
-## Gateway Placement within Shopify
-
-Placement within Shopify is available by invitation only at this time.
-
## Version/Release Management
Contributors don't need to worry about versions, this is something Committers do at important milestones:
From 90b6b18c1324f69a591a51db1216207afc18111b Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Wed, 11 Jul 2018 08:24:15 -0400
Subject: [PATCH 0012/2234] Do not care about test module/class lengths
This is counterproductive when it comes to tests.
---
.rubocop.yml | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/.rubocop.yml b/.rubocop.yml
index 80efd64708b..f6b1bee81b2 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -16,3 +16,12 @@ AllCops:
- "vendor/**/*"
ExtraDetails: false
TargetRubyVersion: 2.3
+
+# Limiting module/class lengths in specs is counterproductive
+Metrics/ClassLength:
+ Exclude:
+ - 'test/**/*'
+
+Metrics/ModuleLength:
+ Exclude:
+ - 'test/**/*'
From 8c254bb4faf022d016e060490a304a41f1947e0c Mon Sep 17 00:00:00 2001
From: David Perry
Date: Tue, 10 Jul 2018 16:44:51 -0400
Subject: [PATCH 0013/2234] ANET: Expose full response code
Closes #2924
Remote:
67 tests, 230 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
92 tests, 525 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/authorize_net.rb | 4 ++++
test/remote/gateways/remote_authorize_net_test.rb | 1 +
test/unit/gateways/authorize_net_test.rb | 1 +
4 files changed, 7 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index 44097274cb2..b69d679062e 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -5,6 +5,7 @@
* Pin Payments: Pass reference for statement desc [curiousepic] #2919
* FirstData: introduce v27 gateway [shasum] #2912
* Stripe: Fix contactless magstripe support [abhiin1947] #2917
+* ANET: Expose full response code [curiousepic] #2924
== Version 1.80.0 (July 4, 2018)
* Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909
diff --git a/lib/active_merchant/billing/gateways/authorize_net.rb b/lib/active_merchant/billing/gateways/authorize_net.rb
index 5db6708cb7e..12df74d02bc 100644
--- a/lib/active_merchant/billing/gateways/authorize_net.rb
+++ b/lib/active_merchant/billing/gateways/authorize_net.rb
@@ -863,6 +863,10 @@ def parse_normal(action, body)
(empty?(element.content) ? nil : element.content)
end
+ response[:full_response_code] = if(element = doc.at_xpath('//messages/message/code'))
+ (empty?(element.content) ? nil : element.content)
+ end
+
response
end
diff --git a/test/remote/gateways/remote_authorize_net_test.rb b/test/remote/gateways/remote_authorize_net_test.rb
index af48e65a4b5..57b24453e07 100644
--- a/test/remote/gateways/remote_authorize_net_test.rb
+++ b/test/remote/gateways/remote_authorize_net_test.rb
@@ -525,6 +525,7 @@ def test_bad_login
avs_result_code
card_code
cardholder_authentication_code
+ full_response_code
response_code
response_reason_code
response_reason_text
diff --git a/test/unit/gateways/authorize_net_test.rb b/test/unit/gateways/authorize_net_test.rb
index 9b3516bb25d..3c7eac296e5 100644
--- a/test/unit/gateways/authorize_net_test.rb
+++ b/test/unit/gateways/authorize_net_test.rb
@@ -262,6 +262,7 @@ def test_successful_authorization
assert_equal 'M', response.cvv_result['code']
assert_equal 'CVV matches', response.cvv_result['message']
+ assert_equal 'I00001', response.params['full_response_code']
assert_equal '508141794', response.authorization.split('#')[0]
assert response.test?
From f20dfab46920874a9317643bd2392437421106f4 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Wed, 11 Jul 2018 12:23:29 -0400
Subject: [PATCH 0014/2234] Remove redundancy in Gemfiles
---
Gemfile.rails42 | 11 +----------
Gemfile.rails50 | 11 +----------
Gemfile.rails51 | 11 +----------
Gemfile.rails52 | 11 +----------
4 files changed, 4 insertions(+), 40 deletions(-)
diff --git a/Gemfile.rails42 b/Gemfile.rails42
index 890b340923a..037e7c6a80c 100644
--- a/Gemfile.rails42
+++ b/Gemfile.rails42
@@ -1,12 +1,3 @@
-source 'https://rubygems.org'
-gemspec
-
-gem 'jruby-openssl', :platforms => :jruby
-gem 'rubocop', '~> 0.57.2', require: false
-
-group :test, :remote_test do
- # gateway-specific dependencies, keeping these gems out of the gemspec
- gem 'braintree', '>= 2.50.0'
-end
+eval File.read('Gemfile')
gem 'activesupport', '~> 4.2.0'
diff --git a/Gemfile.rails50 b/Gemfile.rails50
index c014f53a18e..9512083b540 100644
--- a/Gemfile.rails50
+++ b/Gemfile.rails50
@@ -1,12 +1,3 @@
-source 'https://rubygems.org'
-gemspec
-
-gem 'jruby-openssl', :platforms => :jruby
-gem 'rubocop', '~> 0.57.2', require: false
-
-group :test, :remote_test do
- # gateway-specific dependencies, keeping these gems out of the gemspec
- gem 'braintree', '>= 2.50.0'
-end
+eval File.read('Gemfile')
gem 'activesupport', '~> 5.0.0'
diff --git a/Gemfile.rails51 b/Gemfile.rails51
index c83abf0b54b..eee047fc94e 100644
--- a/Gemfile.rails51
+++ b/Gemfile.rails51
@@ -1,12 +1,3 @@
-source 'https://rubygems.org'
-gemspec
-
-gem 'jruby-openssl', :platforms => :jruby
-gem 'rubocop', '~> 0.57.2', require: false
-
-group :test, :remote_test do
- # gateway-specific dependencies, keeping these gems out of the gemspec
- gem 'braintree', '>= 2.50.0'
-end
+eval File.read('Gemfile')
gem 'activesupport', '~> 5.1.0'
diff --git a/Gemfile.rails52 b/Gemfile.rails52
index cf1a88c3011..c078c3f1a89 100644
--- a/Gemfile.rails52
+++ b/Gemfile.rails52
@@ -1,12 +1,3 @@
-source 'https://rubygems.org'
-gemspec
-
-gem 'jruby-openssl', :platforms => :jruby
-gem 'rubocop', '~> 0.57.2', require: false
-
-group :test, :remote_test do
- # gateway-specific dependencies, keeping these gems out of the gemspec
- gem 'braintree', '>= 2.50.0'
-end
+eval File.read('Gemfile')
gem 'activesupport', '~> 5.2.0.rc1'
From cc8585cfa0b3878965f09634cdf2ece71ba48d4c Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Wed, 11 Jul 2018 12:28:03 -0400
Subject: [PATCH 0015/2234] Run RuboCop only once, as a separate step
---
.travis.yml | 7 ++++---
Rakefile | 2 +-
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 726411a1e7e..a4c02349ad8 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,10 +13,11 @@ gemfile:
- Gemfile.rails50
- Gemfile.rails42
-matrix:
+jobs:
include:
- - rvm: 2.3
- gemfile: Gemfile.rails42
+ rvm: 2.5
+ gemfile: Gemfile
+ script: bundle exec rubocop --parallel
notifications:
email:
diff --git a/Rakefile b/Rakefile
index 1aa5657c126..5e92782a541 100644
--- a/Rakefile
+++ b/Rakefile
@@ -24,7 +24,7 @@ task :tag_release do
end
desc 'Run the unit test suite'
-task :default => 'test:local'
+task :default => 'test:units'
task :test => 'test:units'
RuboCop::RakeTask.new
From 0626f13ca8a651641627f1333a10ea873d0a1d21 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Wed, 11 Jul 2018 12:40:11 -0400
Subject: [PATCH 0016/2234] Upgrade RuboCop to 0.58.1
This *almost* allows PayPal to be re-added, but some upstream bugs
in the parser gem still prevent that being a go.
Fixes a new issue found in Mercury as well.
---
Gemfile | 2 +-
lib/active_merchant/billing/gateways/mercury.rb | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Gemfile b/Gemfile
index 6e287b04095..8fe123d5eb8 100644
--- a/Gemfile
+++ b/Gemfile
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
gemspec
gem 'jruby-openssl', :platforms => :jruby
-gem 'rubocop', '~> 0.57.2', require: false
+gem 'rubocop', '~> 0.58.1', require: false
group :test, :remote_test do
# gateway-specific dependencies, keeping these gems out of the gemspec
diff --git a/lib/active_merchant/billing/gateways/mercury.rb b/lib/active_merchant/billing/gateways/mercury.rb
index 54f51af876c..090ffaad3f1 100644
--- a/lib/active_merchant/billing/gateways/mercury.rb
+++ b/lib/active_merchant/billing/gateways/mercury.rb
@@ -103,7 +103,7 @@ def build_non_authorized_request(action, money, credit_card, options)
xml.tag! 'Transaction' do
xml.tag! 'TranType', 'Credit'
xml.tag! 'TranCode', action
- if options[:allow_partial_auth] && (action == 'PreAuth' || action == 'Sale')
+ if options[:allow_partial_auth] && ['PreAuth', 'Sale'].include?(action)
xml.tag! 'PartialAuth', 'Allow'
end
add_invoice(xml, options[:order_id], nil, options)
From c68c60cd9107ac7ed315cbc7d8d3eedf30e3018c Mon Sep 17 00:00:00 2001
From: David Perry
Date: Wed, 11 Jul 2018 15:52:01 -0400
Subject: [PATCH 0017/2234] Global Collect: Fix customer data field structure
Previously, many customer data fields were not being properly placed in
the customer envelope.
Closes #2929
Remote:
16 tests, 37 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
17 tests, 78 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/global_collect.rb | 12 ++++--------
test/unit/gateways/global_collect_test.rb | 4 ++--
3 files changed, 7 insertions(+), 10 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index b69d679062e..4a22fa8d964 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -6,6 +6,7 @@
* FirstData: introduce v27 gateway [shasum] #2912
* Stripe: Fix contactless magstripe support [abhiin1947] #2917
* ANET: Expose full response code [curiousepic] #2924
+* Global Collect: Fix customer data field structure [curiousepic] #2929
== Version 1.80.0 (July 4, 2018)
* Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909
diff --git a/lib/active_merchant/billing/gateways/global_collect.rb b/lib/active_merchant/billing/gateways/global_collect.rb
index 1152f495e56..2bd27df7aed 100644
--- a/lib/active_merchant/billing/gateways/global_collect.rb
+++ b/lib/active_merchant/billing/gateways/global_collect.rb
@@ -140,9 +140,6 @@ def add_payment(post, payment, options)
end
def add_customer_data(post, options, payment = nil)
- post['order']['customer'] = {
- 'merchantCustomerId' => options[:customer]
- }
if payment
post['order']['customer']['personalInformation'] = {
'name' => {
@@ -151,12 +148,11 @@ def add_customer_data(post, options, payment = nil)
}
}
end
- post['order']['companyInformation'] = {
- 'name' => options[:company]
- }
- post['order']['contactDetails']['emailAddress'] = options[:email] if options[:email]
+ post['order']['customer']['merchantCustomerId'] = options[:customer] if options[:customer]
+ post['order']['customer']['companyInformation']['name'] = options[:company] if options[:company]
+ post['order']['customer']['contactDetails']['emailAddress'] = options[:email] if options[:email]
if address = options[:billing_address] || options[:address]
- post['order']['contactDetails']['phoneNumber'] = address[:phone] if address[:phone]
+ post['order']['customer']['contactDetails']['phoneNumber'] = address[:phone] if address[:phone]
end
end
diff --git a/test/unit/gateways/global_collect_test.rb b/test/unit/gateways/global_collect_test.rb
index 605e1aa0563..5a5c7df22c4 100644
--- a/test/unit/gateways/global_collect_test.rb
+++ b/test/unit/gateways/global_collect_test.rb
@@ -68,6 +68,7 @@ def test_authorize_without_pre_authorization_flag
def test_successful_authorization_with_extra_options
options = @options.merge(
{
+ customer: '123987',
email: 'example@example.com',
order_id: '123',
ip: '127.0.0.1',
@@ -84,8 +85,7 @@ def test_successful_authorization_with_extra_options
end.check_request do |endpoint, data, headers|
assert_match %r("fraudFields":{"website":"www.example.com","giftMessage":"Happy Day!","customerIpAddress":"127.0.0.1"}), data
assert_match %r("merchantReference":"123"), data
- assert_match %r("emailAddress":"example@example.com"), data
- assert_match %r("phoneNumber":"\(555\)555-5555"), data
+ assert_match %r("customer":{"personalInformation":{"name":{"firstName":"Longbob","surname":"Longsen"}},"merchantCustomerId":"123987","contactDetails":{"emailAddress":"example@example.com","phoneNumber":"\(555\)555-5555"},"billingAddress":{"street":"456 My Street","additionalInfo":"Apt 1","zip":"K1C2N6","city":"Ottawa","state":"ON","countryCode":"CA"}}}), data
end.respond_with(successful_authorize_response)
assert_success response
From ccb7de63403d588cfcc742e32c245158c2da8d17 Mon Sep 17 00:00:00 2001
From: Niaja
Date: Wed, 11 Jul 2018 22:55:48 -0400
Subject: [PATCH 0018/2234] Adyen: Set Default Name for Apple Pay Transactions
Name is required for Adyen but not always paseed on Apple Pay
transactions. This creates the default name place holder of `Not
Provided` on apply pay transactions. Updates one remote test with new
message.
Loaded suite test/unit/gateways/adyen_test
......................
22 tests, 101 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Loaded suite test/remote/gateways/remote_adyen_test
Started
..................................
34 tests, 86 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/adyen.rb | 1 +
test/remote/gateways/remote_adyen_test.rb | 2 +-
test/unit/gateways/adyen_test.rb | 11 +++++++++++
4 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 4a22fa8d964..4e135584118 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -7,6 +7,7 @@
* Stripe: Fix contactless magstripe support [abhiin1947] #2917
* ANET: Expose full response code [curiousepic] #2924
* Global Collect: Fix customer data field structure [curiousepic] #2929
+* Adyen: Set Default Name for Apple Pay Transactions [nfarve] #2930
== Version 1.80.0 (July 4, 2018)
* Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index afea91c45ee..6a118616b63 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -179,6 +179,7 @@ def add_card(post, credit_card)
}
card.delete_if{|k,v| v.blank? }
+ card[:holderName] ||= 'Not Provided' if credit_card.is_a?(NetworkTokenizationCreditCard)
requires!(card, :expiryMonth, :expiryYear, :holderName, :number)
post[:card] = card
end
diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb
index a5d646f182b..e4f752d2260 100644
--- a/test/remote/gateways/remote_adyen_test.rb
+++ b/test/remote/gateways/remote_adyen_test.rb
@@ -233,7 +233,7 @@ def test_invalid_expiry_month_for_purchase
card = credit_card('4242424242424242', month: 16)
assert response = @gateway.purchase(@amount, card, @options)
assert_failure response
- assert_equal 'Expiry month should be between 1 and 12 inclusive', response.message
+ assert_equal 'Expiry Date Invalid: Expiry month should be between 1 and 12 inclusive', response.message
end
def test_invalid_expiry_year_for_purchase
diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb
index c0e0f69b3d5..e9f7753b76f 100644
--- a/test/unit/gateways/adyen_test.rb
+++ b/test/unit/gateways/adyen_test.rb
@@ -220,6 +220,17 @@ def test_add_address
assert_equal @options[:billing_address][:country], post[:card][:billingAddress][:country]
end
+ def test_authorize_with_network_tokenization_credit_card_no_name
+ @apple_pay_card.first_name = nil
+ @apple_pay_card.last_name = nil
+ response = stub_comms do
+ @gateway.authorize(@amount, @apple_pay_card, @options)
+ end.check_request do |endpoint, data, headers|
+ assert_equal 'Not Provided', JSON.parse(data)['card']['holderName']
+ end.respond_with(successful_authorize_response)
+ assert_success response
+ end
+
def test_authorize_with_network_tokenization_credit_card
response = stub_comms do
@gateway.authorize(@amount, @apple_pay_card, @options)
From dde5ab42d5c9d59f8b1e2ca805d8baa7017260ed Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Fri, 13 Jul 2018 16:52:48 -0400
Subject: [PATCH 0019/2234] Use eval_gemfile for nested Gemfiles
This also allows moving the only-used-by-Travis Gemfiles into their
own directory.
Hat-tip @varyonic for the suggestion.
---
.travis.yml | 8 ++++----
Gemfile.rails42 => gemfiles/Gemfile.rails42 | 2 +-
Gemfile.rails50 => gemfiles/Gemfile.rails50 | 2 +-
Gemfile.rails51 => gemfiles/Gemfile.rails51 | 2 +-
Gemfile.rails52 => gemfiles/Gemfile.rails52 | 2 +-
5 files changed, 8 insertions(+), 8 deletions(-)
rename Gemfile.rails42 => gemfiles/Gemfile.rails42 (55%)
rename Gemfile.rails50 => gemfiles/Gemfile.rails50 (55%)
rename Gemfile.rails51 => gemfiles/Gemfile.rails51 (55%)
rename Gemfile.rails52 => gemfiles/Gemfile.rails52 (58%)
diff --git a/.travis.yml b/.travis.yml
index a4c02349ad8..68ff33a3358 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,10 +8,10 @@ rvm:
- 2.3
gemfile:
-- Gemfile.rails52
-- Gemfile.rails51
-- Gemfile.rails50
-- Gemfile.rails42
+- gemfiles/Gemfile.rails52
+- gemfiles/Gemfile.rails51
+- gemfiles/Gemfile.rails50
+- gemfiles/Gemfile.rails42
jobs:
include:
diff --git a/Gemfile.rails42 b/gemfiles/Gemfile.rails42
similarity index 55%
rename from Gemfile.rails42
rename to gemfiles/Gemfile.rails42
index 037e7c6a80c..8d11bec617c 100644
--- a/Gemfile.rails42
+++ b/gemfiles/Gemfile.rails42
@@ -1,3 +1,3 @@
-eval File.read('Gemfile')
+eval_gemfile '../Gemfile'
gem 'activesupport', '~> 4.2.0'
diff --git a/Gemfile.rails50 b/gemfiles/Gemfile.rails50
similarity index 55%
rename from Gemfile.rails50
rename to gemfiles/Gemfile.rails50
index 9512083b540..ce57bebccbe 100644
--- a/Gemfile.rails50
+++ b/gemfiles/Gemfile.rails50
@@ -1,3 +1,3 @@
-eval File.read('Gemfile')
+eval_gemfile '../Gemfile'
gem 'activesupport', '~> 5.0.0'
diff --git a/Gemfile.rails51 b/gemfiles/Gemfile.rails51
similarity index 55%
rename from Gemfile.rails51
rename to gemfiles/Gemfile.rails51
index eee047fc94e..a352b24eaa8 100644
--- a/Gemfile.rails51
+++ b/gemfiles/Gemfile.rails51
@@ -1,3 +1,3 @@
-eval File.read('Gemfile')
+eval_gemfile '../Gemfile'
gem 'activesupport', '~> 5.1.0'
diff --git a/Gemfile.rails52 b/gemfiles/Gemfile.rails52
similarity index 58%
rename from Gemfile.rails52
rename to gemfiles/Gemfile.rails52
index c078c3f1a89..c6c439fce53 100644
--- a/Gemfile.rails52
+++ b/gemfiles/Gemfile.rails52
@@ -1,3 +1,3 @@
-eval File.read('Gemfile')
+eval_gemfile '../Gemfile'
gem 'activesupport', '~> 5.2.0.rc1'
From eb77de8230da22fcf55bc4621e2e00236f738558 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Tue, 17 Jul 2018 12:33:28 -0400
Subject: [PATCH 0020/2234] Disable Metrics/ClassLength and ModuleLength
These are great restrictions in theory, but the running design pattern
in our gateways means that basically *all* of them violate these rules.
Given most of the tests do also, let's just kill these entirely.
---
.rubocop.yml | 8 +++-----
.rubocop_todo.yml | 10 ----------
2 files changed, 3 insertions(+), 15 deletions(-)
diff --git a/.rubocop.yml b/.rubocop.yml
index f6b1bee81b2..bf6cd8ae418 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -17,11 +17,9 @@ AllCops:
ExtraDetails: false
TargetRubyVersion: 2.3
-# Limiting module/class lengths in specs is counterproductive
+# Active Merchant gateways are not amenable to length restrictions
Metrics/ClassLength:
- Exclude:
- - 'test/**/*'
+ Enabled: false
Metrics/ModuleLength:
- Exclude:
- - 'test/**/*'
+ Enabled: false
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 2a376ba8a24..35c175ad580 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -642,11 +642,6 @@ Metrics/BlockLength:
Metrics/BlockNesting:
Max: 6
-# Offense count: 489
-# Configuration parameters: CountComments.
-Metrics/ClassLength:
- Max: 2135
-
# Offense count: 175
Metrics/CyclomaticComplexity:
Max: 36
@@ -656,11 +651,6 @@ Metrics/CyclomaticComplexity:
Metrics/MethodLength:
Max: 163
-# Offense count: 5
-# Configuration parameters: CountComments.
-Metrics/ModuleLength:
- Max: 383
-
# Offense count: 2
# Configuration parameters: CountKeywordArgs.
Metrics/ParameterLists:
From 4719cb2ca0df449428a227fe05d330eaf42f114a Mon Sep 17 00:00:00 2001
From: Niaja
Date: Tue, 17 Jul 2018 11:12:06 -0400
Subject: [PATCH 0021/2234] Beanstream: Update to use api key with login
credentials
Beanstream is requiring that users that connect via username and
password also supply a api key. 2 echeck tests are failing unrelated to
this change.
Loaded suite test/remote/gateways/remote_beanstream_test
41 tests, 185 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
95.122% passed
Loaded suite test/unit/gateways/beanstream_test
23 tests, 108 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
lib/active_merchant/billing/gateways/beanstream.rb | 1 +
.../billing/gateways/beanstream/beanstream_core.rb | 3 +--
test/fixtures.yml | 1 +
test/remote/gateways/remote_beanstream_test.rb | 1 +
test/unit/gateways/beanstream_test.rb | 3 ++-
5 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/beanstream.rb b/lib/active_merchant/billing/gateways/beanstream.rb
index e86e21d60a5..3530ddfd167 100644
--- a/lib/active_merchant/billing/gateways/beanstream.rb
+++ b/lib/active_merchant/billing/gateways/beanstream.rb
@@ -199,6 +199,7 @@ def scrub(transcript)
transcript.
gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
gsub(/(&?password=)[^&\s]*(&?)/, '\1[FILTERED]\2').
+ gsub(/(&?passcode=)[^&\s]*(&?)/, '\1[FILTERED]\2').
gsub(/(&?trnCardCvd=)\d*(&?)/, '\1[FILTERED]\2').
gsub(/(&?trnCardNumber=)\d*(&?)/, '\1[FILTERED]\2')
end
diff --git a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb
index f6d8ba851d3..3a8a36fc8de 100644
--- a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb
+++ b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb
@@ -156,7 +156,6 @@ def initialize(options = {})
def capture(money, authorization, options = {})
reference, _, _ = split_auth(authorization)
-
post = {}
add_amount(post, money)
add_reference(post, reference)
@@ -313,7 +312,6 @@ def add_secure_profile_variables(post, options = {})
post[:serviceVersion] = SP_SERVICE_VERSION
post[:responseFormat] = 'QS'
post[:cardValidation] = (options[:cardValidation].to_i == 1) || '0'
-
post[:operationType] = options[:operationType] || options[:operation] || secure_profile_action(:new)
post[:customerCode] = options[:billing_id] || options[:vault_id] || false
post[:status] = options[:status]
@@ -462,6 +460,7 @@ def post_data(params, use_profile_api)
params[:username] = @options[:user] if @options[:user]
params[:password] = @options[:password] if @options[:password]
params[:merchant_id] = @options[:login]
+ params[:passcode] = @options[:api_key]
end
params[:vbvEnabled] = '0'
params[:scEnabled] = '0'
diff --git a/test/fixtures.yml b/test/fixtures.yml
index d7775b0ef28..d5dc2626ca6 100644
--- a/test/fixtures.yml
+++ b/test/fixtures.yml
@@ -67,6 +67,7 @@ beanstream:
password: password
secure_profile_api_key: API Access Passcode
recurring_api_key: API Access Passcode
+ api_key: API KEY
beanstream_interac:
login: merchant id
diff --git a/test/remote/gateways/remote_beanstream_test.rb b/test/remote/gateways/remote_beanstream_test.rb
index 0002e292bc8..67abd08ff7d 100644
--- a/test/remote/gateways/remote_beanstream_test.rb
+++ b/test/remote/gateways/remote_beanstream_test.rb
@@ -384,6 +384,7 @@ def test_transcript_scrubbing
assert_scrubbed(@visa.number, clean_transcript)
assert_scrubbed(@visa.verification_value.to_s, clean_transcript)
assert_scrubbed(@gateway.options[:password], clean_transcript)
+ assert_scrubbed(@gateway.options[:api_key], clean_transcript)
end
private
diff --git a/test/unit/gateways/beanstream_test.rb b/test/unit/gateways/beanstream_test.rb
index be07b0c9e4a..37787acfc7c 100644
--- a/test/unit/gateways/beanstream_test.rb
+++ b/test/unit/gateways/beanstream_test.rb
@@ -9,7 +9,8 @@ def setup
@gateway = BeanstreamGateway.new(
:login => 'merchant id',
:user => 'username',
- :password => 'password'
+ :password => 'password',
+ :api_key => 'api_key'
)
@credit_card = credit_card
From 959101179fa6a1ae399b316256f398ac31fa95e5 Mon Sep 17 00:00:00 2001
From: Niaja
Date: Tue, 17 Jul 2018 14:59:24 -0400
Subject: [PATCH 0022/2234] Changelog update
Update changelog for #2934
---
CHANGELOG | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG b/CHANGELOG
index 4e135584118..8bb42ae7018 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -8,6 +8,7 @@
* ANET: Expose full response code [curiousepic] #2924
* Global Collect: Fix customer data field structure [curiousepic] #2929
* Adyen: Set Default Name for Apple Pay Transactions [nfarve] #2930
+* Beanstream: Update to use api key with login credentials [nfarve] #2934
== Version 1.80.0 (July 4, 2018)
* Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909
From d3a64ec053fd39fd56b702d063a5e371a768e8f6 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Tue, 17 Jul 2018 17:21:55 -0400
Subject: [PATCH 0023/2234] CT Payments: fix URL typo
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/ct_payment.rb | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 8bb42ae7018..98ac3a559a9 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -9,6 +9,7 @@
* Global Collect: Fix customer data field structure [curiousepic] #2929
* Adyen: Set Default Name for Apple Pay Transactions [nfarve] #2930
* Beanstream: Update to use api key with login credentials [nfarve] #2934
+* CT Payments: Fix a typo in the live URL scheme [bpollack] #2936
== Version 1.80.0 (July 4, 2018)
* Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909
diff --git a/lib/active_merchant/billing/gateways/ct_payment.rb b/lib/active_merchant/billing/gateways/ct_payment.rb
index 889266d65c1..0b9083c4cf6 100644
--- a/lib/active_merchant/billing/gateways/ct_payment.rb
+++ b/lib/active_merchant/billing/gateways/ct_payment.rb
@@ -2,7 +2,7 @@ module ActiveMerchant #:nodoc:
module Billing #:nodoc:
class CtPaymentGateway < Gateway
self.test_url = 'https://test.ctpaiement.ca/v1/'
- self.live_url = 'hhtps://www.ctpaiement.com/v1/'
+ self.live_url = 'https://www.ctpaiement.com/v1/'
self.supported_countries = ['US', 'CA']
self.default_currency = 'CAD'
From 5b52f971722349032694dbd2b0b11b0ff760983a Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Wed, 18 Jul 2018 15:11:47 -0400
Subject: [PATCH 0024/2234] CyberSource: do not raise on HTML responses
Sometimes, CyberSource will 500, and return an HTML response body.
But that's a problem, because we assume all responses are XML. There
was a previous attempt to handle this situation in ba586a28b4d1, but
it won't work if an exception (e.g. a 400 or 500) is thrown as part
of the response, since the rescue block will be catching at the wrong
scope. Instead, capture the response or the exception, and then parse
that as a separate step, so we can be sure to catch the XML parse error
regardless.
Unit: 46 tests, 222 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote: didn't bother due to comment in fixtures.yml
---
CHANGELOG | 1 +
.../billing/gateways/cyber_source.rb | 8 ++++++--
test/unit/gateways/cyber_source_test.rb | 14 ++++++++++++++
3 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 98ac3a559a9..fed2409241c 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -10,6 +10,7 @@
* Adyen: Set Default Name for Apple Pay Transactions [nfarve] #2930
* Beanstream: Update to use api key with login credentials [nfarve] #2934
* CT Payments: Fix a typo in the live URL scheme [bpollack] #2936
+* CyberSource: Don't throw exceptions on HTML responses [bpollack] #2937
== Version 1.80.0 (July 4, 2018)
* Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909
diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb
index 7d7beba89d6..96278d097b2 100644
--- a/lib/active_merchant/billing/gateways/cyber_source.rb
+++ b/lib/active_merchant/billing/gateways/cyber_source.rb
@@ -708,9 +708,13 @@ def build_request(body, options)
# Response object
def commit(request, action, amount, options)
begin
- response = parse(ssl_post(test? ? self.test_url : self.live_url, build_request(request, options)))
+ raw_response = ssl_post(test? ? self.test_url : self.live_url, build_request(request, options))
rescue ResponseError => e
- response = parse(e.response.body)
+ raw_response = e.response.body
+ end
+
+ begin
+ response = parse(raw_response)
rescue REXML::ParseException => e
response = { message: e.to_s }
end
diff --git a/test/unit/gateways/cyber_source_test.rb b/test/unit/gateways/cyber_source_test.rb
index 318fc9931f9..e0765ea00fa 100644
--- a/test/unit/gateways/cyber_source_test.rb
+++ b/test/unit/gateways/cyber_source_test.rb
@@ -482,6 +482,16 @@ def test_supports_network_tokenization
assert_instance_of TrueClass, @gateway.supports_network_tokenization?
end
+ def test_does_not_throw_on_invalid_xml
+ raw_response = mock
+ raw_response.expects(:body).returns(invalid_xml_response)
+ exception = ActiveMerchant::ResponseError.new(raw_response)
+ @gateway.expects(:ssl_post).raises(exception)
+
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
+ assert_failure response
+ end
+
private
def pre_scrubbed
@@ -732,6 +742,10 @@ def successful_threedeesecure_validate_response
XML
end
+ def invalid_xml_response
+ "What's all this then, govna?
"
+ end
+
def assert_xml_valid_to_xsd(data, root_element = '//s:Body/*')
schema_file = File.open("#{File.dirname(__FILE__)}/../../schema/cyber_source/CyberSourceTransaction_#{CyberSourceGateway::XSD_VERSION}.xsd")
doc = Nokogiri::XML(data)
From 85f87a3443f6911e3ffd95ff7a2f898a54aa0fe2 Mon Sep 17 00:00:00 2001
From: Chris Coetzee
Date: Tue, 29 May 2018 14:48:19 +0200
Subject: [PATCH 0025/2234] Remove options parameter from Cybersource
add_check_service call
Closes #2861
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/cyber_source.rb | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index fed2409241c..c742044a70d 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -11,6 +11,7 @@
* Beanstream: Update to use api key with login credentials [nfarve] #2934
* CT Payments: Fix a typo in the live URL scheme [bpollack] #2936
* CyberSource: Don't throw exceptions on HTML responses [bpollack] #2937
+* CyberSource: Remove extraneous parameter blocking echecks [chriscz] #2861
== Version 1.80.0 (July 4, 2018)
* Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909
diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb
index 96278d097b2..02e81821aed 100644
--- a/lib/active_merchant/billing/gateways/cyber_source.rb
+++ b/lib/active_merchant/billing/gateways/cyber_source.rb
@@ -356,7 +356,7 @@ def build_create_subscription_request(payment_method, options)
add_subscription(xml, options)
if options[:setup_fee]
if card_brand(payment_method) == 'check'
- add_check_service(xml, options)
+ add_check_service(xml)
else
add_purchase_service(xml, payment_method, options)
add_payment_network_token(xml) if network_tokenization?(payment_method)
From a792422a3115b3350d5fa285971186ede45e56c1 Mon Sep 17 00:00:00 2001
From: Niaja
Date: Tue, 24 Jul 2018 08:58:52 -0400
Subject: [PATCH 0026/2234] FirstPay: Update Fields For Recurring Payments
Updates fields for recurring payment and adds a new field for recurring
type.
Loaded suite test/remote/gateways/remote_first_pay_test
Started
.............
13 tests, 29 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Loaded suite test/unit/gateways/first_pay_test
...........
11 tests, 116 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/first_pay.rb | 5 +++--
test/remote/gateways/remote_first_pay_test.rb | 2 +-
test/unit/gateways/first_pay_test.rb | 10 ++++++----
4 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index c742044a70d..9cdae70ea2c 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -12,6 +12,7 @@
* CT Payments: Fix a typo in the live URL scheme [bpollack] #2936
* CyberSource: Don't throw exceptions on HTML responses [bpollack] #2937
* CyberSource: Remove extraneous parameter blocking echecks [chriscz] #2861
+* FirstPay: Update Fields For Recurring Payments [nfarve] #2940
== Version 1.80.0 (July 4, 2018)
* Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909
diff --git a/lib/active_merchant/billing/gateways/first_pay.rb b/lib/active_merchant/billing/gateways/first_pay.rb
index b218557b4c7..0c0b6ff4897 100644
--- a/lib/active_merchant/billing/gateways/first_pay.rb
+++ b/lib/active_merchant/billing/gateways/first_pay.rb
@@ -93,8 +93,9 @@ def add_payment(post, payment, options)
post[:card_exp] = expdate(payment)
post[:cvv2] = payment.verification_value
post[:recurring] = options[:recurring] if options[:recurring]
- post[:recurringStartDate] = options[:recurring_start_date] if options[:recurring_start_date]
- post[:recurringEndDate] = options[:recurring_end_date] if options[:recurring_end_date]
+ post[:recurring_start_date] = options[:recurring_start_date] if options[:recurring_start_date]
+ post[:recurring_end_date] = options[:recurring_end_date] if options[:recurring_end_date]
+ post[:recurring_type] = options[:recurring_type] if options[:recurring_type]
end
def add_reference(post, action, money, authorization)
diff --git a/test/remote/gateways/remote_first_pay_test.rb b/test/remote/gateways/remote_first_pay_test.rb
index 923667078b3..23aa35e8a30 100644
--- a/test/remote/gateways/remote_first_pay_test.rb
+++ b/test/remote/gateways/remote_first_pay_test.rb
@@ -111,7 +111,7 @@ def test_invalid_login
end
def test_recurring_payment
- @options.merge!({recurring: 'none', recurring_start_date: DateTime.now, recurring_end_date: DateTime.now})
+ @options.merge!({recurring: 1, recurring_start_date: DateTime.now.strftime('%m/%d/%Y'), recurring_end_date: DateTime.now.strftime('%m/%d/%Y'), recurring_type: 'monthly'})
response = @gateway.purchase(@amount, @credit_card, @options)
assert_success response
assert_equal 'Approved', response.message
diff --git a/test/unit/gateways/first_pay_test.rb b/test/unit/gateways/first_pay_test.rb
index 0b3de0f9c25..6596389bf64 100644
--- a/test/unit/gateways/first_pay_test.rb
+++ b/test/unit/gateways/first_pay_test.rb
@@ -182,15 +182,17 @@ def test_failed_void
end
def test_recurring_payments
- @options[:recurring] = 'none'
+ @options[:recurring] = 1
@options[:recurring_start_date] = '01/01/1900'
@options[:recurring_end_date] = '02/02/1901'
+ @options[:recurring_type] = 'monthly'
response = stub_comms do
@gateway.purchase(@amount, @credit_card, @options)
end.check_request do |endpoint, data, headers|
- assert_match(%r{none}, data)
- assert_match(%r{01/01/1900}, data)
- assert_match(%r{02/02/1901}, data)
+ assert_match(%r{1}, data)
+ assert_match(%r{01/01/1900}, data)
+ assert_match(%r{02/02/1901}, data)
+ assert_match(%r{monthly}, data)
end.respond_with(successful_purchase_response)
assert response
From 33fba2fcfe32fb6597d53875ce438e9c85e9bafa Mon Sep 17 00:00:00 2001
From: David Perry
Date: Tue, 24 Jul 2018 11:40:48 -0400
Subject: [PATCH 0027/2234] BlueSnap: Update list of supported countries
Closes #2942
Unit:
18 tests, 68 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote (two unrelated failures):
25 tests, 72 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
92% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/blue_snap.rb | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 9cdae70ea2c..962a00f3365 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -13,6 +13,7 @@
* CyberSource: Don't throw exceptions on HTML responses [bpollack] #2937
* CyberSource: Remove extraneous parameter blocking echecks [chriscz] #2861
* FirstPay: Update Fields For Recurring Payments [nfarve] #2940
+* BlueSnap: Update list of supported countries [curiousepic] #2942
== Version 1.80.0 (July 4, 2018)
* Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909
diff --git a/lib/active_merchant/billing/gateways/blue_snap.rb b/lib/active_merchant/billing/gateways/blue_snap.rb
index e736fe14152..c857cbe93f6 100644
--- a/lib/active_merchant/billing/gateways/blue_snap.rb
+++ b/lib/active_merchant/billing/gateways/blue_snap.rb
@@ -5,7 +5,7 @@ module Billing
class BlueSnapGateway < Gateway
self.test_url = 'https://sandbox.bluesnap.com/services/2'
self.live_url = 'https://ws.bluesnap.com/services/2'
- self.supported_countries = %w(US CA GB AT BE BG HR CY CZ DK EE FI FR DE GR HU IE IT LV LT LU MT NL PL PT RO SK SI ES SE)
+ self.supported_countries = %w(AD AE AG AI AL AM AO AQ AR AS AT AU AW AZ BA BB BD BE BF BG BH BI BJ BM BN BO BR BS BT BV BW BY BZ CA CC CD CF CG CH CI CK CL CM CN CO CR CV CW CX CY CZ DE DJ DK DM DO DZ EC EE EG EH ER ES ET FI FJ FK FM FO FR GA GB GD GE GF GG GI GL GM GN GP GQ GR GS GT GU GW GY HK HM HN HR HT HU ID IE IL IM IN IO IS IT JE JM JO JP KE KG KH KI KM KN KR KW KY KZ LA LC LI LK LR LS LT LU LV MA MC MD ME MF MG MH MK ML MN MO MP MQ MR MS MT MU MV MW MX MY MZ NA NC NE NF NG NI NL NO NP NR NU NZ OM PA PE PF PG PH PK PL PM PN PR PT PW PY QA RE RO RS RU RW SA SB SC SE SG SH SI SJ SK SL SM SN SO SR ST SV SX SZ TC TD TF TG TH TJ TK TM TN TO TR TT TV TW TZ UA UG UM US UY UZ VA VC VE VG VI VN VU WF WS YT ZA ZM ZW)
self.default_currency = 'USD'
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners_club, :maestro]
From 3169f0c1dd58cc3e195df0e6be7ed392c7cab256 Mon Sep 17 00:00:00 2001
From: Bernard Laveaux
Date: Wed, 18 Jan 2017 12:39:57 -0500
Subject: [PATCH 0028/2234] Remove unused `handle_response` method
The `handle_response` method defined in `Connection`
- looks to be implemented on each gateway within `PostsData` module
- doesn't seem to be called anywhere in code and passes test suite
Unit: 3911 tests, 68082 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications
100% passed
Closes #2309
---
CHANGELOG | 1 +
lib/active_merchant/connection.rb | 13 -------------
2 files changed, 1 insertion(+), 13 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 962a00f3365..c580d46bd6b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -14,6 +14,7 @@
* CyberSource: Remove extraneous parameter blocking echecks [chriscz] #2861
* FirstPay: Update Fields For Recurring Payments [nfarve] #2940
* BlueSnap: Update list of supported countries [curiousepic] #2942
+* Remove unused handle_response method [bl] #2309
== Version 1.80.0 (July 4, 2018)
* Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909
diff --git a/lib/active_merchant/connection.rb b/lib/active_merchant/connection.rb
index a289bcdd82f..5df801ca301 100644
--- a/lib/active_merchant/connection.rb
+++ b/lib/active_merchant/connection.rb
@@ -177,19 +177,6 @@ def configure_cert(http)
end
end
- def handle_response(response)
- if @ignore_http_status then
- return response.body
- else
- case response.code.to_i
- when 200...300
- response.body
- else
- raise ResponseError.new(response)
- end
- end
- end
-
def debug(message, tag = nil)
log(:debug, message, tag)
end
From 7074c900409a080008239f9c628f066172272b85 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Tue, 24 Jul 2018 11:41:38 -0400
Subject: [PATCH 0029/2234] Barclaycard Smartpay: bump API to v30
This currently shouldn't change any behavior, but preps for handling
third-party payouts and also serves as a marker that the API package
should run cleanly on v30 of the API.
Unit: 25 tests, 114 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote: 29 tests, 61 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/barclaycard_smartpay.rb | 8 +++++---
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index c580d46bd6b..a89d8f73228 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -15,6 +15,7 @@
* FirstPay: Update Fields For Recurring Payments [nfarve] #2940
* BlueSnap: Update list of supported countries [curiousepic] #2942
* Remove unused handle_response method [bl] #2309
+* Barclaycard Smartpay: bump API version to v30 [bpollack] #2941
== Version 1.80.0 (July 4, 2018)
* Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909
diff --git a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb
index 56fe408d503..33e4945a434 100644
--- a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb
+++ b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb
@@ -13,6 +13,8 @@ class BarclaycardSmartpayGateway < Gateway
self.homepage_url = 'https://www.barclaycardsmartpay.com/'
self.display_name = 'Barclaycard Smartpay'
+ API_VERSION = 'v30'
+
def initialize(options = {})
requires!(options, :company, :merchant, :password)
super
@@ -222,11 +224,11 @@ def success_from(response)
def build_url(action)
case action
when 'store'
- "#{test? ? self.test_url : self.live_url}/Recurring/v12/storeToken"
+ "#{test? ? self.test_url : self.live_url}/Recurring/#{API_VERSION}/storeToken"
when 'finalize3ds'
- "#{test? ? self.test_url : self.live_url}/Payment/v12/authorise3d"
+ "#{test? ? self.test_url : self.live_url}/Payment/#{API_VERSION}/authorise3d"
else
- "#{test? ? self.test_url : self.live_url}/Payment/v12/#{action}"
+ "#{test? ? self.test_url : self.live_url}/Payment/#{API_VERSION}/#{action}"
end
end
From af70e08ba12f4ba577f56145c192deacbbe515d8 Mon Sep 17 00:00:00 2001
From: David Perry
Date: Tue, 24 Jul 2018 15:00:14 -0400
Subject: [PATCH 0030/2234] Revert "BlueSnap: Update list of supported
countries"
This reverts commit 33fba2fcfe32fb6597d53875ce438e9c85e9bafa.
Whoops, forgot that "supported countries" is actually the countries that
merchants can be based in, rather than supported billing addresses.
---
CHANGELOG | 1 -
lib/active_merchant/billing/gateways/blue_snap.rb | 2 +-
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index a89d8f73228..3e22609a554 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -13,7 +13,6 @@
* CyberSource: Don't throw exceptions on HTML responses [bpollack] #2937
* CyberSource: Remove extraneous parameter blocking echecks [chriscz] #2861
* FirstPay: Update Fields For Recurring Payments [nfarve] #2940
-* BlueSnap: Update list of supported countries [curiousepic] #2942
* Remove unused handle_response method [bl] #2309
* Barclaycard Smartpay: bump API version to v30 [bpollack] #2941
diff --git a/lib/active_merchant/billing/gateways/blue_snap.rb b/lib/active_merchant/billing/gateways/blue_snap.rb
index c857cbe93f6..e736fe14152 100644
--- a/lib/active_merchant/billing/gateways/blue_snap.rb
+++ b/lib/active_merchant/billing/gateways/blue_snap.rb
@@ -5,7 +5,7 @@ module Billing
class BlueSnapGateway < Gateway
self.test_url = 'https://sandbox.bluesnap.com/services/2'
self.live_url = 'https://ws.bluesnap.com/services/2'
- self.supported_countries = %w(AD AE AG AI AL AM AO AQ AR AS AT AU AW AZ BA BB BD BE BF BG BH BI BJ BM BN BO BR BS BT BV BW BY BZ CA CC CD CF CG CH CI CK CL CM CN CO CR CV CW CX CY CZ DE DJ DK DM DO DZ EC EE EG EH ER ES ET FI FJ FK FM FO FR GA GB GD GE GF GG GI GL GM GN GP GQ GR GS GT GU GW GY HK HM HN HR HT HU ID IE IL IM IN IO IS IT JE JM JO JP KE KG KH KI KM KN KR KW KY KZ LA LC LI LK LR LS LT LU LV MA MC MD ME MF MG MH MK ML MN MO MP MQ MR MS MT MU MV MW MX MY MZ NA NC NE NF NG NI NL NO NP NR NU NZ OM PA PE PF PG PH PK PL PM PN PR PT PW PY QA RE RO RS RU RW SA SB SC SE SG SH SI SJ SK SL SM SN SO SR ST SV SX SZ TC TD TF TG TH TJ TK TM TN TO TR TT TV TW TZ UA UG UM US UY UZ VA VC VE VG VI VN VU WF WS YT ZA ZM ZW)
+ self.supported_countries = %w(US CA GB AT BE BG HR CY CZ DK EE FI FR DE GR HU IE IT LV LT LU MT NL PL PT RO SK SI ES SE)
self.default_currency = 'USD'
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners_club, :maestro]
From ab51e8c942df53c3538d361a781e26786073f117 Mon Sep 17 00:00:00 2001
From: David Perry
Date: Thu, 26 Jul 2018 11:22:34 -0400
Subject: [PATCH 0031/2234] Safecharge: Remove duplicate supported country
Remote:
23 tests, 68 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
20 tests, 96 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/safe_charge.rb | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 3e22609a554..e8c7bb0ed8f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -15,6 +15,7 @@
* FirstPay: Update Fields For Recurring Payments [nfarve] #2940
* Remove unused handle_response method [bl] #2309
* Barclaycard Smartpay: bump API version to v30 [bpollack] #2941
+* Safecharge: Remove duplicate supported country [curiousepic]
== Version 1.80.0 (July 4, 2018)
* Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909
diff --git a/lib/active_merchant/billing/gateways/safe_charge.rb b/lib/active_merchant/billing/gateways/safe_charge.rb
index a2c8022655e..684f1c3d468 100644
--- a/lib/active_merchant/billing/gateways/safe_charge.rb
+++ b/lib/active_merchant/billing/gateways/safe_charge.rb
@@ -6,7 +6,7 @@ class SafeChargeGateway < Gateway
self.test_url = 'https://process.sandbox.safecharge.com/service.asmx/Process'
self.live_url = 'https://process.safecharge.com/service.asmx/Process'
- self.supported_countries = ['AT', 'BE', 'BG', 'CY', 'CZ', 'DE', 'DK', 'EE', 'GR', 'ES', 'FI', 'FR', 'HR', 'HU', 'IE', 'IS', 'IT', 'LI', 'LT', 'LU', 'LV', 'MT', 'NL', 'NO', 'PL', 'PT', 'RO', 'SE', 'SE', 'SI', 'SK', 'GB', 'US']
+ self.supported_countries = ['AT', 'BE', 'BG', 'CY', 'CZ', 'DE', 'DK', 'EE', 'GR', 'ES', 'FI', 'FR', 'HR', 'HU', 'IE', 'IS', 'IT', 'LI', 'LT', 'LU', 'LV', 'MT', 'NL', 'NO', 'PL', 'PT', 'RO', 'SE', 'SI', 'SK', 'GB', 'US']
self.default_currency = 'USD'
self.supported_cardtypes = [:visa, :master]
From 3baa26e4cb48f818e130cb49a6ae4c5bb211cf14 Mon Sep 17 00:00:00 2001
From: Filipe Costa
Date: Fri, 27 Jul 2018 11:49:34 -0300
Subject: [PATCH 0032/2234] Use SHIPTONAME instead of `full_name` for Payflow
Express (#2945)
* Remove whitespaces
* Use primarily SHIPTONAME for Payflow Express
`full_name` is not necessarily the person receiving the products being
bought, it's the buyer account owner name, many time SHIPTONAME and
`full_name` would be the same, but in others, products could be a gift
to someone else, shipped to their address.
---
.../payflow/payflow_express_response.rb | 12 +-
test/unit/gateways/payflow_express_test.rb | 108 ++++++++++++++----
test/unit/gateways/payflow_express_uk_test.rb | 72 +++++++++++-
3 files changed, 162 insertions(+), 30 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb b/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb
index 7b4068dea05..0c01ee481b2 100644
--- a/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb
+++ b/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb
@@ -4,26 +4,26 @@ class PayflowExpressResponse < Response
def email
@params['e_mail']
end
-
+
def full_name
"#{@params['name']} #{@params['lastname']}"
end
-
+
def token
@params['token']
end
-
+
def payer_id
@params['payer_id']
end
-
+
# Really the shipping country, but it is all the information provided
def payer_country
address['country']
end
-
+
def address
- { 'name' => full_name,
+ { 'name' => @params['shiptoname'] || full_name,
'company' => nil,
'address1' => @params['street'],
'address2' => @params['shiptostreet2'] || @params['street2'],
diff --git a/test/unit/gateways/payflow_express_test.rb b/test/unit/gateways/payflow_express_test.rb
index 719fd885117..a78238a6a3a 100644
--- a/test/unit/gateways/payflow_express_test.rb
+++ b/test/unit/gateways/payflow_express_test.rb
@@ -5,15 +5,15 @@ class PayflowExpressTest < Test::Unit::TestCase
TEST_REDIRECT_URL_MOBILE = 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout-mobile&token=1234567890'
LIVE_REDIRECT_URL = 'https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=1234567890'
LIVE_REDIRECT_URL_MOBILE = 'https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout-mobile&token=1234567890'
-
+
TEST_REDIRECT_URL_WITHOUT_REVIEW = "#{TEST_REDIRECT_URL}&useraction=commit"
LIVE_REDIRECT_URL_WITHOUT_REVIEW = "#{LIVE_REDIRECT_URL}&useraction=commit"
TEST_REDIRECT_URL_MOBILE_WITHOUT_REVIEW = "#{TEST_REDIRECT_URL_MOBILE}&useraction=commit"
LIVE_REDIRECT_URL_MOBILE_WITHOUT_REVIEW = "#{LIVE_REDIRECT_URL_MOBILE}&useraction=commit"
-
+
def setup
Base.mode = :test
-
+
@gateway = PayflowExpressGateway.new(
:login => 'LOGIN',
:password => 'PASSWORD'
@@ -29,61 +29,61 @@ def setup
:phone => '(555)555-5555'
}
end
-
+
def teardown
Base.mode = :test
end
-
+
def test_using_test_mode
assert @gateway.test?
end
-
+
def test_overriding_test_mode
Base.mode = :production
-
+
gateway = PayflowExpressGateway.new(
:login => 'LOGIN',
:password => 'PASSWORD',
:test => true
)
-
+
assert gateway.test?
end
-
+
def test_using_production_mode
Base.mode = :production
-
+
gateway = PayflowExpressGateway.new(
:login => 'LOGIN',
:password => 'PASSWORD'
)
-
+
assert !gateway.test?
end
-
+
def test_live_redirect_url
Base.mode = :production
assert_equal LIVE_REDIRECT_URL, @gateway.redirect_url_for('1234567890')
assert_equal LIVE_REDIRECT_URL_MOBILE, @gateway.redirect_url_for('1234567890', :mobile => true)
end
-
+
def test_test_redirect_url
assert_equal TEST_REDIRECT_URL, @gateway.redirect_url_for('1234567890')
assert_equal TEST_REDIRECT_URL_MOBILE, @gateway.redirect_url_for('1234567890', :mobile => true)
end
-
+
def test_live_redirect_url_without_review
Base.mode = :production
assert_equal LIVE_REDIRECT_URL_WITHOUT_REVIEW, @gateway.redirect_url_for('1234567890', :review => false)
assert_equal LIVE_REDIRECT_URL_MOBILE_WITHOUT_REVIEW, @gateway.redirect_url_for('1234567890', :review => false, :mobile => true)
end
-
+
def test_test_redirect_url_without_review
assert_equal :test, Base.mode
assert_equal TEST_REDIRECT_URL_WITHOUT_REVIEW, @gateway.redirect_url_for('1234567890', :review => false)
assert_equal TEST_REDIRECT_URL_MOBILE_WITHOUT_REVIEW, @gateway.redirect_url_for('1234567890', :review => false, :mobile => true)
end
-
+
def test_invalid_get_express_details_request
@gateway.expects(:ssl_post).returns(invalid_get_express_details_response)
response = @gateway.details_for('EC-2OPN7UJGFWK9OYFV')
@@ -91,20 +91,20 @@ def test_invalid_get_express_details_request
assert response.test?
assert_equal 'Field format error: Invalid Token', response.message
end
-
+
def test_get_express_details
@gateway.expects(:ssl_post).returns(successful_get_express_details_response)
response = @gateway.details_for('EC-2OPN7UJGFWK9OYFV')
assert_instance_of PayflowExpressResponse, response
assert_success response
assert response.test?
-
+
assert_equal 'EC-2OPN7UJGFWK9OYFV', response.token
assert_equal '12345678901234567', response.payer_id
assert_equal 'Buyer1@paypal.com', response.email
assert_equal 'Joe Smith', response.full_name
assert_equal 'US', response.payer_country
-
+
assert address = response.address
assert_equal 'Joe Smith', address['name']
assert_nil address['company']
@@ -117,6 +117,31 @@ def test_get_express_details
assert_nil address['phone']
end
+ def test_get_express_details_with_ship_to_name
+ @gateway.expects(:ssl_post).returns(successful_get_express_details_response_with_ship_to_name)
+ response = @gateway.details_for('EC-2OPN7UJGFWK9OYFV')
+ assert_instance_of PayflowExpressResponse, response
+ assert_success response
+ assert response.test?
+
+ assert_equal 'EC-2OPN7UJGFWK9OYFV', response.token
+ assert_equal '12345678901234567', response.payer_id
+ assert_equal 'Buyer1@paypal.com', response.email
+ assert_equal 'Joe Smith', response.full_name
+ assert_equal 'US', response.payer_country
+
+ assert address = response.address
+ assert_equal 'John Joseph', address['name']
+ assert_nil address['company']
+ assert_equal '111 Main St.', address['address1']
+ assert_nil address['address2']
+ assert_equal 'San Jose', address['city']
+ assert_equal 'CA', address['state']
+ assert_equal '95100', address['zip']
+ assert_equal 'US', address['country']
+ assert_nil address['phone']
+ end
+
def test_get_express_details_with_invalid_xml
@gateway.expects(:ssl_post).returns(successful_get_express_details_response(:street => 'Main & Magic'))
response = @gateway.details_for('EC-2OPN7UJGFWK9OYFV')
@@ -134,9 +159,9 @@ def test_button_source
xml_doc = REXML::Document.new(xml.target!)
assert_nil REXML::XPath.first(xml_doc, '/PayPal/ButtonSource')
end
-
+
private
-
+
def successful_get_express_details_response(options={:street => '111 Main St.'})
<<-RESPONSE
@@ -172,7 +197,44 @@ def successful_get_express_details_response(options={:street => '111 Main St.'})
RESPONSE
end
-
+
+ def successful_get_express_details_response_with_ship_to_name
+ <<-RESPONSE
+
+
+ TEST
+ verisign
+
+
+ 0
+ Approved
+
+ Buyer1@paypal.com
+ 12345678901234567
+ EC-2OPN7UJGFWK9OYFV
+ 0
+ verified
+ Joe
+
+
+ 111 Main St.
+ San Jose
+ CA
+ 95100
+ US
+
+
+ 9c3706997455e
+
+
+
+
+
+
+
+ RESPONSE
+ end
+
def invalid_get_express_details_response
<<-RESPONSE
@@ -186,7 +248,7 @@ def invalid_get_express_details_response
-
+
RESPONSE
end
end
diff --git a/test/unit/gateways/payflow_express_uk_test.rb b/test/unit/gateways/payflow_express_uk_test.rb
index 25f88820b1e..6c40fa8aca9 100644
--- a/test/unit/gateways/payflow_express_uk_test.rb
+++ b/test/unit/gateways/payflow_express_uk_test.rb
@@ -37,6 +37,31 @@ def test_get_express_details
assert_nil address['phone']
end
+ def test_get_express_details_with_ship_to_name
+ @gateway.expects(:ssl_post).returns(successful_get_express_details_response_with_ship_to_name)
+ response = @gateway.details_for('EC-2OPN7UJGFWK9OYFV')
+ assert_instance_of PayflowExpressResponse, response
+ assert_success response
+ assert response.test?
+
+ assert_equal 'EC-2OPN7UJGFWK9OYFV', response.token
+ assert_equal 'LYWCMEN4FA7ZQ', response.payer_id
+ assert_equal 'paul@test.com', response.email
+ assert_equal 'paul smith', response.full_name
+ assert_equal 'GB', response.payer_country
+
+ assert address = response.address
+ assert_equal 'John Joseph', address['name']
+ assert_nil address['company']
+ assert_equal '10 keyworth avenue', address['address1']
+ assert_equal 'grangetown', address['address2']
+ assert_equal 'hinterland', address['city']
+ assert_equal 'Tyne and Wear', address['state']
+ assert_equal 'sr5 2uh', address['zip']
+ assert_equal 'GB', address['country']
+ assert_nil address['phone']
+ end
+
private
def successful_get_express_details_response
<<-RESPONSE
@@ -73,7 +98,52 @@ def successful_get_express_details_response
-
+
+
+
+
+
+
+
+ RESPONSE
+ end
+
+ def successful_get_express_details_response_with_ship_to_name
+ <<-RESPONSE
+
+
+
+ markcoop
+ paypaluk
+
+
+ 0
+
+ Match
+ Match
+
+ Approved
+
+ paul@test.com
+ LYWCMEN4FA7ZQ
+ EC-2OPN7UJGFWK9OYFV
+ 0
+ unverified
+ paul
+
+
+ 10 keyworth avenue
+ hinterland
+ Tyne and Wear
+ sr5 2uh
+ GB
+
+
+ 1ea22ef3873ba
+
+
+
+
From 5d8da4eb5647477d23fc2c7bf9843cae4fc52e25 Mon Sep 17 00:00:00 2001
From: Filipe Costa
Date: Mon, 30 Jul 2018 10:04:11 -0300
Subject: [PATCH 0033/2234] Release v1.81.0
---
CHANGELOG | 1 +
lib/active_merchant/version.rb | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index e8c7bb0ed8f..4e6260f5886 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -16,6 +16,7 @@
* Remove unused handle_response method [bl] #2309
* Barclaycard Smartpay: bump API version to v30 [bpollack] #2941
* Safecharge: Remove duplicate supported country [curiousepic]
+* Payflow Express: Use SHIPTONAME instead of `full_name` for shipping address [filipebarcos] #2945
== Version 1.80.0 (July 4, 2018)
* Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909
diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb
index b1883e4e5c3..b305d6325eb 100644
--- a/lib/active_merchant/version.rb
+++ b/lib/active_merchant/version.rb
@@ -1,3 +1,3 @@
module ActiveMerchant
- VERSION = '1.80.0'
+ VERSION = '1.81.0'
end
From b50f685d4a6c4256ca42403306c361fdbccb6983 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Tue, 31 Jul 2018 13:31:03 -0400
Subject: [PATCH 0034/2234] FirstData E4 v27: Support WalletProviderID
Unit: 30 tests, 139 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote: 23 tests, 92 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/firstdata_e4_v27.rb | 6 ++++--
test/unit/gateways/firstdata_e4_v27_test.rb | 10 ++++++++++
3 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 4e6260f5886..820baa86cfc 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -17,6 +17,7 @@
* Barclaycard Smartpay: bump API version to v30 [bpollack] #2941
* Safecharge: Remove duplicate supported country [curiousepic]
* Payflow Express: Use SHIPTONAME instead of `full_name` for shipping address [filipebarcos] #2945
+* FirstData: add support for WalletProviderID in v27 gateway [bpollack] #2946
== Version 1.80.0 (July 4, 2018)
* Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909
diff --git a/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb b/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb
index 9bdd77d9b62..7f5fde83f3e 100644
--- a/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb
+++ b/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb
@@ -211,6 +211,7 @@ def add_credit_card(xml, credit_card, options)
xml.tag! 'Expiry_Date', expdate(credit_card)
xml.tag! 'CardHoldersName', credit_card.name
xml.tag! 'CardType', card_type(credit_card.brand)
+ xml.tag! 'WalletProviderID', options[:wallet_provider_id] if options[:wallet_provider_id]
add_credit_card_eci(xml, credit_card, options)
add_credit_card_verification_strings(xml, credit_card, options)
@@ -273,6 +274,7 @@ def add_credit_card_token(xml, store_authorization, options)
xml.tag! 'Expiry_Date', expdate(credit_card)
xml.tag! 'CardHoldersName', credit_card.name
xml.tag! 'CardType', card_type(credit_card.brand)
+ xml.tag! 'WalletProviderID', options[:wallet_provider_id] if options[:wallet_provider_id]
add_card_authentication_data(xml, options)
end
@@ -398,9 +400,9 @@ def money_from_authorization(auth)
end
def message_from(response)
- if(response[:faultcode] && response[:faultstring])
+ if response[:faultcode] && response[:faultstring]
response[:faultstring]
- elsif(response[:error_number] && response[:error_number] != '0')
+ elsif response[:error_number] && response[:error_number] != '0'
response[:error_description]
else
result = (response[:exact_message] || '')
diff --git a/test/unit/gateways/firstdata_e4_v27_test.rb b/test/unit/gateways/firstdata_e4_v27_test.rb
index ed4e9c45512..3e502c430e8 100644
--- a/test/unit/gateways/firstdata_e4_v27_test.rb
+++ b/test/unit/gateways/firstdata_e4_v27_test.rb
@@ -49,6 +49,16 @@ def test_successful_purchase_with_token
assert_success response
end
+ def test_successful_purchase_with_wallet
+ response = stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options.merge!({wallet_provider_id: 4}))
+ end.check_request do |endpoint, data, headers|
+ assert_match /WalletProviderID>4, data
+ end.respond_with(successful_purchase_response)
+
+ assert_success response
+ end
+
def test_successful_void
@gateway.expects(:ssl_post).returns(successful_void_response)
assert response = @gateway.void(@authorization, @options)
From 77b8d3b073992aa3dca52b53b47898990e743af7 Mon Sep 17 00:00:00 2001
From: David Perry
Date: Mon, 6 Aug 2018 14:25:04 -0400
Subject: [PATCH 0035/2234] BlueSnap: Handle 403 responses
403 Forbidden responses due to insufficient account permissions were
causing parsing exception errors. This handles them with a bespoke
response passing the raw text as message.
This also fixes the verify_credentials call; a change at the gateways
caused the response given for a bogus url (url/nonexistent) to be a
success with a different message. Hitting the root url now seems
sufficient to provoke a 401.
Closes #2948
Remote (1 unrelated failure):
25 tests, 72 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
96% passed
Unit:
19 tests, 72 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/blue_snap.rb | 7 ++++++-
test/unit/gateways/blue_snap_test.rb | 15 +++++++++++++--
3 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 820baa86cfc..6782a2191a6 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -18,6 +18,7 @@
* Safecharge: Remove duplicate supported country [curiousepic]
* Payflow Express: Use SHIPTONAME instead of `full_name` for shipping address [filipebarcos] #2945
* FirstData: add support for WalletProviderID in v27 gateway [bpollack] #2946
+* BlueSnap: Handle 403 responses [curiousepic] #2948
== Version 1.80.0 (July 4, 2018)
* Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909
diff --git a/lib/active_merchant/billing/gateways/blue_snap.rb b/lib/active_merchant/billing/gateways/blue_snap.rb
index e736fe14152..3a378f25716 100644
--- a/lib/active_merchant/billing/gateways/blue_snap.rb
+++ b/lib/active_merchant/billing/gateways/blue_snap.rb
@@ -116,7 +116,7 @@ def store(credit_card, options = {})
def verify_credentials
begin
- ssl_get("#{url}/nonexistent", headers)
+ ssl_get(url.to_s, headers)
rescue ResponseError => e
return false if e.response.code.to_i == 401
end
@@ -209,6 +209,7 @@ def add_authorization(doc, authorization)
def parse(response)
return bad_authentication_response if response.code.to_i == 401
+ return forbidden_response(response.body) if response.code.to_i == 403
parsed = {}
doc = Nokogiri::XML(response.body)
@@ -338,6 +339,10 @@ def handle_response(response)
def bad_authentication_response
{ 'description' => 'Unable to authenticate. Please check your credentials.' }
end
+
+ def forbidden_response(body)
+ { 'description' => body }
+ end
end
end
end
diff --git a/test/unit/gateways/blue_snap_test.rb b/test/unit/gateways/blue_snap_test.rb
index dffaf3d9565..54416d767dc 100644
--- a/test/unit/gateways/blue_snap_test.rb
+++ b/test/unit/gateways/blue_snap_test.rb
@@ -140,6 +140,14 @@ def test_verify_bad_credentials
assert !@gateway.verify_credentials
end
+ def test_failed_forbidden_response
+ @gateway.expects(:raw_ssl_request).returns(forbidden_response)
+
+ response = @gateway.purchase(@amount, @credit_card, @options)
+ assert_failure response
+ assert_equal 'You are not authorized to perform this request due to inappropriate role permissions.', response.message
+ end
+
def test_scrub
assert @gateway.supports_scrubbing?
assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed
@@ -516,12 +524,15 @@ def failed_store_response
MockResponse.failed(body, 400)
end
+ def forbidden_response
+ MockResponse.new(403, 'You are not authorized to perform this request due to inappropriate role permissions.')
+ end
+
def credentials_are_legit_response
MockResponse.new(400, 'Server Error')
end
def credentials_are_bogus_response
- MockResponse.new(401, %{Apache Tomcat/8.0.24 - Error report HTTP Status 401 - Bad credentials
type Status report
message Bad credentials
description This request requires HTTP authentication.
Apache Tomcat/8.0.24
})
+ MockResponse.new(401, %{HTTP Status 401 – UnauthorizedHTTP Status 401 – Unauthorized
Type Status Report
Message Bad credentials
Description The request has not been applied because it lacks valid authentication credentials for the target resource.
Apache Tomcat Version X
})
end
-
end
From 99db685a6940b1ba5f6d00047e9d908a5330fcd0 Mon Sep 17 00:00:00 2001
From: Niaja
Date: Wed, 8 Aug 2018 14:01:38 -0400
Subject: [PATCH 0036/2234] BlueSnap: Add StoreCard Field
With increase in visa regulations, merchants must pass a `storeCard`
value which shows if a user has authorized their card to be stored. One
test failing in remote unrelated to these changes.
Loaded suite test/unit/gateways/blue_snap_test
19 tests, 73 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
Loaded suite test/remote/gateways/remote_blue_snap_test
25 tests, 72 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
96% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/blue_snap.rb | 1 +
test/unit/gateways/blue_snap_test.rb | 8 +++++---
3 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 6782a2191a6..8583b3a9ba1 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -19,6 +19,7 @@
* Payflow Express: Use SHIPTONAME instead of `full_name` for shipping address [filipebarcos] #2945
* FirstData: add support for WalletProviderID in v27 gateway [bpollack] #2946
* BlueSnap: Handle 403 responses [curiousepic] #2948
+* BlueSnap: Add StoreCard Field [nfarve] #2953
== Version 1.80.0 (July 4, 2018)
* Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909
diff --git a/lib/active_merchant/billing/gateways/blue_snap.rb b/lib/active_merchant/billing/gateways/blue_snap.rb
index 3a378f25716..95cab53ca27 100644
--- a/lib/active_merchant/billing/gateways/blue_snap.rb
+++ b/lib/active_merchant/billing/gateways/blue_snap.rb
@@ -140,6 +140,7 @@ def scrub(transcript)
def add_auth_purchase(doc, money, payment_method, options)
doc.send('recurring-transaction', options[:recurring] ? 'RECURRING' : 'ECOMMERCE')
add_order(doc, options)
+ doc.send('storeCard', options[:store_card] || false)
add_amount(doc, money, options)
doc.send('transaction-fraud-info') do
doc.send('shopper-ip-address', options[:ip]) if options[:ip]
diff --git a/test/unit/gateways/blue_snap_test.rb b/test/unit/gateways/blue_snap_test.rb
index 54416d767dc..444e43832af 100644
--- a/test/unit/gateways/blue_snap_test.rb
+++ b/test/unit/gateways/blue_snap_test.rb
@@ -27,9 +27,11 @@ def test_failed_purchase
end
def test_successful_authorize
- @gateway.expects(:raw_ssl_request).returns(successful_authorize_response)
-
- response = @gateway.authorize(@amount, @credit_card, @options)
+ response = stub_comms(@gateway, :raw_ssl_request) do
+ @gateway.authorize(@amount, @credit_card, @options)
+ end.check_request do |type, endpoint, data, headers|
+ assert_match 'false', data
+ end.respond_with(successful_authorize_response)
assert_success response
assert_equal '1012082893', response.authorization
end
From a3874d3776996dc96afe8a7a3f20abfbc12a7892 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 9 Aug 2018 15:12:38 -0400
Subject: [PATCH 0037/2234] Worldpay: support instalments
Failing remote tests have nothing to do with the new functionality
(that test passes).
Unit: 38 tests, 217 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote: 26 tests, 90 assertions, 4 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
84.6154% passed
---
CHANGELOG | 1 +
.../billing/gateways/worldpay.rb | 12 ++++++++++-
test/remote/gateways/remote_worldpay_test.rb | 14 ++++++++++---
test/unit/gateways/worldpay_test.rb | 20 +++++++++++++++++++
4 files changed, 43 insertions(+), 4 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 8583b3a9ba1..c9d3dc34886 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -20,6 +20,7 @@
* FirstData: add support for WalletProviderID in v27 gateway [bpollack] #2946
* BlueSnap: Handle 403 responses [curiousepic] #2948
* BlueSnap: Add StoreCard Field [nfarve] #2953
+* Worldpay: support installments [bpollack] #2957
== Version 1.80.0 (July 4, 2018)
* Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909
diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb
index b88c10afe04..4ef6f38eb1a 100644
--- a/lib/active_merchant/billing/gateways/worldpay.rb
+++ b/lib/active_merchant/billing/gateways/worldpay.rb
@@ -168,6 +168,9 @@ def build_authorization_request(money, payment_method, options)
if options[:hcg_additional_data]
add_hcg_additional_data(xml, options)
end
+ if options[:instalments]
+ add_instalments_data(xml, options)
+ end
end
end
end
@@ -292,6 +295,13 @@ def add_hcg_additional_data(xml, options)
end
end
+ def add_instalments_data(xml, options)
+ xml.tag! 'thirdPartyData' do
+ xml.tag! 'instalments', options[:instalments]
+ xml.tag! 'cpf', options[:cpf] if options[:cpf]
+ end
+ end
+
def address_with_defaults(address)
address ||= {}
address.delete_if { |_, v| v.blank? }
@@ -370,7 +380,7 @@ def url
def handle_response(response)
case response.code.to_i
when 200...300
- @cookie = response.response['Set-Cookie']
+ @cookie = response['Set-Cookie']
response.body
else
raise ResponseError.new(response)
diff --git a/test/remote/gateways/remote_worldpay_test.rb b/test/remote/gateways/remote_worldpay_test.rb
index e1cb7f3cb64..ae768a760d5 100644
--- a/test/remote/gateways/remote_worldpay_test.rb
+++ b/test/remote/gateways/remote_worldpay_test.rb
@@ -82,9 +82,18 @@ def test_authorize_and_purchase_by_reference
assert_success capture
end
+ def test_authorize_and_purchase_with_instalments
+ assert auth = @gateway.authorize(@amount, @credit_card, @options.merge(instalment: 3))
+ assert_success auth
+ assert_equal 'SUCCESS', auth.message
+ assert auth.authorization
+ sleep(40)
+ assert capture = @gateway.capture(@amount, auth.authorization)
+ assert_success capture
+ end
+
def test_successful_authorize_with_3ds
session_id = generate_unique_id
- order_id = @options[:order_id]
options = @options.merge(
{
execute_threed: true,
@@ -106,7 +115,6 @@ def test_successful_authorize_with_3ds
def test_failed_authorize_with_3ds
session_id = generate_unique_id
- order_id = @options[:order_id]
options = @options.merge(
{
execute_threed: true,
@@ -196,7 +204,7 @@ def test_refund_fails_unless_status_is_captured
assert refund = @gateway.refund(30, response.authorization)
assert_failure refund
- assert_equal "A transaction status of 'CAPTURED' or 'SETTLED' or 'SETTLED_BY_MERCHANT' is required.", refund.message
+ assert_equal 'Order not ready', refund.message
end
def test_refund_nonexistent_transaction
diff --git a/test/unit/gateways/worldpay_test.rb b/test/unit/gateways/worldpay_test.rb
index 2fb4297ffcb..02a6eca5834 100644
--- a/test/unit/gateways/worldpay_test.rb
+++ b/test/unit/gateways/worldpay_test.rb
@@ -352,6 +352,26 @@ def test_email
end.respond_with(successful_authorize_response)
end
+ def test_instalments
+ stub_comms do
+ @gateway.purchase(100, @credit_card, @options.merge(instalments: 3))
+ end.check_request do |endpoint, data, headers|
+ unless // =~ data
+ assert_match %r(3), data
+ assert_no_match %r(cpf), data
+ end
+ end.respond_with(successful_authorize_response, successful_capture_response)
+
+ stub_comms do
+ @gateway.purchase(100, @credit_card, @options.merge(instalments: 3, cpf: 12341234))
+ end.check_request do |endpoint, data, headers|
+ unless // =~ data
+ assert_match %r(3), data
+ assert_match %r(12341234), data
+ end
+ end.respond_with(successful_authorize_response, successful_capture_response)
+ end
+
def test_ip
stub_comms do
@gateway.authorize(100, @credit_card, @options.merge(ip: '192.137.11.44'))
From ee619b3b9c1209ac8ee4d310d2c85c6adc607b82 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Mon, 13 Aug 2018 07:13:29 -0400
Subject: [PATCH 0038/2234] Paymentez: add support for partial refunds
Unit: 19 tests, 77 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote: 17 tests, 44 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
88.2353% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/paymentez.rb | 7 +++++--
test/remote/gateways/remote_paymentez_test.rb | 8 ++++++++
test/unit/gateways/paymentez_test.rb | 14 +++++++++++++-
4 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index c9d3dc34886..af5d69e7097 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -21,6 +21,7 @@
* BlueSnap: Handle 403 responses [curiousepic] #2948
* BlueSnap: Add StoreCard Field [nfarve] #2953
* Worldpay: support installments [bpollack] #2957
+* Paymentez: support partial refunds [bpollack] #2959
== Version 1.80.0 (July 4, 2018)
* Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909
diff --git a/lib/active_merchant/billing/gateways/paymentez.rb b/lib/active_merchant/billing/gateways/paymentez.rb
index 49b628834d7..db72d1da65e 100644
--- a/lib/active_merchant/billing/gateways/paymentez.rb
+++ b/lib/active_merchant/billing/gateways/paymentez.rb
@@ -76,8 +76,11 @@ def capture(money, authorization, _options = {})
commit_transaction('capture', post)
end
- def refund(_money, authorization, options = {})
- void(authorization, options)
+ def refund(money, authorization, options = {})
+ post = {transaction: {id: authorization}}
+ post[:order] = {amount: amount(money).to_f} if money
+
+ commit_transaction('refund', post)
end
def void(authorization, _options = {})
diff --git a/test/remote/gateways/remote_paymentez_test.rb b/test/remote/gateways/remote_paymentez_test.rb
index 6164e7e2e9b..b6c2fca7173 100644
--- a/test/remote/gateways/remote_paymentez_test.rb
+++ b/test/remote/gateways/remote_paymentez_test.rb
@@ -47,6 +47,14 @@ def test_failed_purchase
assert_equal Gateway::STANDARD_ERROR_CODE[:card_declined], response.error_code
end
+ def test_successful_refund
+ auth = @gateway.purchase(@amount, @credit_card, @options)
+ assert_success auth
+
+ assert refund = @gateway.refund(@amount, @credit_card, @options)
+ assert_success refund
+ end
+
def test_successful_void
auth = @gateway.purchase(@amount, @credit_card, @options)
assert_success auth
diff --git a/test/unit/gateways/paymentez_test.rb b/test/unit/gateways/paymentez_test.rb
index 05c16c6fd25..8cfd9eb690d 100644
--- a/test/unit/gateways/paymentez_test.rb
+++ b/test/unit/gateways/paymentez_test.rb
@@ -1,6 +1,8 @@
require 'test_helper'
class PaymentezTest < Test::Unit::TestCase
+ include CommStub
+
def setup
@gateway = PaymentezGateway.new(application_code: 'foo', app_key: 'bar')
@credit_card = credit_card
@@ -107,7 +109,17 @@ def test_failed_capture
def test_successful_refund
@gateway.expects(:ssl_post).returns(successful_refund_response)
- response = @gateway.refund(@amount, '1234', @options)
+ response = @gateway.refund(nil, '1234', @options)
+ assert_success response
+ assert response.test?
+ end
+
+ def test_partial_refund
+ response = stub_comms do
+ @gateway.refund(@amount, '1234', @options)
+ end.check_request do |_endpoint, data, _headers|
+ assert_match /"amount":1.0/, data
+ end.respond_with(successful_refund_response)
assert_success response
assert response.test?
end
From fb2c448e9f2dec84552c3ef9f5db3a93c7fca093 Mon Sep 17 00:00:00 2001
From: Pierre Nespo
Date: Mon, 13 Aug 2018 11:33:32 -0400
Subject: [PATCH 0039/2234] Allow setting CAPTURECOMPLETE on Payflow capture
transactions (#2952)
By default Payflow will consider the first capture the final one, by passing
`CAPTURECOMPLETE=N` it lets us capture again later on.
[Docs](https://developer.paypal.com/docs/classic/payflow/integration-guide/#paypal-credit-card-transaction-request-parameters)
Remote: (Failures related to ACH and recurring billing)
32 tests, 137 assertions, 8 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
75% passed
Unit:
46 tests, 208 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
.../gateways/payflow/payflow_common_api.rb | 5 ++++
.../billing/gateways/payflow_express.rb | 5 +---
test/remote/gateways/remote_payflow_test.rb | 26 +++++++++++++++++++
3 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb b/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb
index fc0b78a5013..e8258844aec 100644
--- a/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb
+++ b/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb
@@ -119,6 +119,11 @@ def build_reference_request(action, money, authorization, options)
xml.tag!('Description', options[:description]) unless options[:description].blank?
xml.tag!('Comment', options[:comment]) unless options[:comment].blank?
xml.tag!('ExtData', 'Name'=> 'COMMENT2', 'Value'=> options[:comment2]) unless options[:comment2].blank?
+ xml.tag!(
+ 'ExtData',
+ 'Name' => 'CAPTURECOMPLETE',
+ 'Value' => options[:capture_complete]
+ ) unless options[:capture_complete].blank?
end
end
end
diff --git a/lib/active_merchant/billing/gateways/payflow_express.rb b/lib/active_merchant/billing/gateways/payflow_express.rb
index d2e0b27ede5..a8fee1d6476 100644
--- a/lib/active_merchant/billing/gateways/payflow_express.rb
+++ b/lib/active_merchant/billing/gateways/payflow_express.rb
@@ -9,9 +9,7 @@ module Billing #:nodoc:
# in the docs that they recommend you pass the exact same parameters to both setup and authorize/purchase.
#
# This information was gleaned from a mix of:
- # * PayFlow documentation
- # * for key value pairs: {Express Checkout for Payflow Pro (PDF)}[https://cms.paypal.com/cms_content/US/en_US/files/developer/PFP_ExpressCheckout_PP.pdf]
- # * XMLPay: {Payflow Pro XMLPay Developer's Guide (PDF)}[https://cms.paypal.com/cms_content/US/en_US/files/developer/PP_PayflowPro_XMLPay_Guide.pdf]
+ # * {PayFlow documentation}[https://developer.paypal.com/docs/classic/payflow/integration-guide/]
# * previous ActiveMerchant code
# * trial & error
#
@@ -221,4 +219,3 @@ def build_response(success, message, response, options = {})
end
end
end
-
diff --git a/test/remote/gateways/remote_payflow_test.rb b/test/remote/gateways/remote_payflow_test.rb
index 23b7a13f37b..1ec03b627a2 100644
--- a/test/remote/gateways/remote_payflow_test.rb
+++ b/test/remote/gateways/remote_payflow_test.rb
@@ -135,6 +135,32 @@ def test_authorize_and_partial_capture
assert_success capture
end
+ def test_authorize_and_complete_capture
+ assert auth = @gateway.authorize(100 * 2, @credit_card, @options)
+ assert_success auth
+ assert_equal 'Approved', auth.message
+ assert auth.authorization
+
+ assert capture = @gateway.capture(100, auth.authorization, :capture_complete => 'Y')
+ assert_success capture
+
+ assert capture = @gateway.capture(100, auth.authorization)
+ assert_failure capture
+ end
+
+ def test_authorize_and_uncomplete_capture
+ assert auth = @gateway.authorize(100 * 2, @credit_card, @options)
+ assert_success auth
+ assert_equal 'Approved', auth.message
+ assert auth.authorization
+
+ assert capture = @gateway.capture(100, auth.authorization, :capture_complete => 'N')
+ assert_success capture
+
+ assert capture = @gateway.capture(100, auth.authorization)
+ assert_success capture
+ end
+
def test_failed_capture
assert response = @gateway.capture(100, '999')
assert_failure response
From 15761ba77de5833ba88f335c6d377d9adcf9a8d7 Mon Sep 17 00:00:00 2001
From: Filipe Costa
Date: Mon, 13 Aug 2018 12:55:31 -0400
Subject: [PATCH 0040/2234] Release 1.82.0
---
CHANGELOG | 14 +++++++++-----
lib/active_merchant/version.rb | 2 +-
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index af5d69e7097..7c3104ec011 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,15 @@
= ActiveMerchant CHANGELOG
== HEAD
+== Version 1.82.0 (August 13, 2018)
+* FirstData: add support for WalletProviderID in v27 gateway [bpollack] #2946
+* BlueSnap: Handle 403 responses [curiousepic] #2948
+* BlueSnap: Add StoreCard Field [nfarve] #2953
+* Worldpay: support installments [bpollack] #2957
+* Paymentez: support partial refunds [bpollack] #2959
+* Payflow: allow support for partial captures [pi3r] #2952
+
+== Version 1.81.0 (July 30, 2018)
* GlobalCollect: Don't overwrite contactDetails [curiousepic] #2915
* Pin Payments: Pass reference for statement desc [curiousepic] #2919
* FirstData: introduce v27 gateway [shasum] #2912
@@ -17,11 +26,6 @@
* Barclaycard Smartpay: bump API version to v30 [bpollack] #2941
* Safecharge: Remove duplicate supported country [curiousepic]
* Payflow Express: Use SHIPTONAME instead of `full_name` for shipping address [filipebarcos] #2945
-* FirstData: add support for WalletProviderID in v27 gateway [bpollack] #2946
-* BlueSnap: Handle 403 responses [curiousepic] #2948
-* BlueSnap: Add StoreCard Field [nfarve] #2953
-* Worldpay: support installments [bpollack] #2957
-* Paymentez: support partial refunds [bpollack] #2959
== Version 1.80.0 (July 4, 2018)
* Default SSL min_version to TLS 1.1 to comply with June 30 PCI DSS deadline [bdewater] #2909
diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb
index b305d6325eb..c3ac04fa8c8 100644
--- a/lib/active_merchant/version.rb
+++ b/lib/active_merchant/version.rb
@@ -1,3 +1,3 @@
module ActiveMerchant
- VERSION = '1.81.0'
+ VERSION = '1.82.0'
end
From 1202eef3fe6bacbcd354eb8393cd8b8f577b1d41 Mon Sep 17 00:00:00 2001
From: Niaja
Date: Mon, 13 Aug 2018 11:37:05 -0400
Subject: [PATCH 0041/2234] CT Payment: Update How Address is Passed
Adds city and state to the address information passed in
`CardHolderAddress`. Also allows for verify method to send address
information.
Loaded suite test/unit/gateways/ct_payment_test
..............
14 tests, 48 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Loaded suite test/remote/gateways/remote_ct_payment_test
....................
20 tests, 58 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/ct_payment.rb | 3 ++-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 7c3104ec011..b8cb47ac6ee 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -8,6 +8,7 @@
* Worldpay: support installments [bpollack] #2957
* Paymentez: support partial refunds [bpollack] #2959
* Payflow: allow support for partial captures [pi3r] #2952
+* CT Payment: Update How Address is Passed [nfarve] #2960
== Version 1.81.0 (July 30, 2018)
* GlobalCollect: Don't overwrite contactDetails [curiousepic] #2915
diff --git a/lib/active_merchant/billing/gateways/ct_payment.rb b/lib/active_merchant/billing/gateways/ct_payment.rb
index 0b9083c4cf6..2214645437e 100644
--- a/lib/active_merchant/billing/gateways/ct_payment.rb
+++ b/lib/active_merchant/billing/gateways/ct_payment.rb
@@ -120,6 +120,7 @@ def verify(credit_card, options={})
add_operator_id(post, options)
add_invoice(post,0, options)
add_payment(post, credit_card)
+ add_address(post, credit_card, options)
add_customer_data(post, options)
commit('verifyAccount', post)
@@ -171,7 +172,7 @@ def add_customer_data(post, options)
def add_address(post, creditcard, options)
if address = options[:billing_address] || options[:address]
- post[:CardHolderAddress] = ("#{address[:address1]} #{address[:address2]}").rjust(20, ' ')
+ post[:CardHolderAddress] = ("#{address[:address1]} #{address[:address2]} #{address[:city]} #{address[:state]}").rjust(20, ' ')
post[:CardHolderPostalCode] = address[:zip].gsub(/\s+/, '').rjust(9, ' ')
end
end
From 9062b6d7d0e68ccae8413132d5577589f2cebe36 Mon Sep 17 00:00:00 2001
From: Niaja
Date: Wed, 8 Aug 2018 08:41:32 -0400
Subject: [PATCH 0042/2234] Adyen: Add RecurringProcessingModel
With visa updates, Adyen now requires the type of recurring processing
model for all recurring transactions. This adds the neccessary field.
Loaded suite test/remote/gateways/remote_adyen_test
..................................
34 tests, 86 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Loaded suite test/unit/gateways/adyen_test
......................
22 tests, 102 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/adyen.rb | 1 +
test/remote/gateways/remote_adyen_test.rb | 3 ++-
test/unit/gateways/adyen_test.rb | 10 +++++++---
4 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index b8cb47ac6ee..051595682a7 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -9,6 +9,7 @@
* Paymentez: support partial refunds [bpollack] #2959
* Payflow: allow support for partial captures [pi3r] #2952
* CT Payment: Update How Address is Passed [nfarve] #2960
+* Adyen: Add RecurringProcessingModel [nfarve] #2951
== Version 1.81.0 (July 30, 2018)
* GlobalCollect: Don't overwrite contactDetails [curiousepic] #2915
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index 6a118616b63..d938036894e 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -148,6 +148,7 @@ def add_invoice(post, money, options)
currency: options[:currency] || currency(money)
}
post[:amount] = amount
+ post[:recurringProcessingModel] = options[:recurring_processing_model] if options[:recurring_processing_model]
end
def add_invoice_for_modification(post, money, options)
diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb
index e4f752d2260..6a6bd3240d8 100644
--- a/test/remote/gateways/remote_adyen_test.rb
+++ b/test/remote/gateways/remote_adyen_test.rb
@@ -31,7 +31,8 @@ def setup
shopper_ip: '77.110.174.153',
shopper_reference: 'John Smith',
billing_address: address(),
- order_id: '123'
+ order_id: '123',
+ recurring_processing_model: 'CardOnFile'
}
end
diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb
index e9f7753b76f..b752a9c4875 100644
--- a/test/unit/gateways/adyen_test.rb
+++ b/test/unit/gateways/adyen_test.rb
@@ -33,7 +33,8 @@ def setup
billing_address: address(),
shopper_reference: 'John Smith',
order_id: '345123',
- installments: 2
+ installments: 2,
+ recurring_processing_model: 'CardOnFile'
}
end
@@ -156,8 +157,11 @@ def test_failed_void
end
def test_successful_store
- @gateway.expects(:ssl_post).returns(successful_store_response)
- response = @gateway.store(@credit_card, @options)
+ response = stub_comms do
+ @gateway.store(@credit_card, @options)
+ end.check_request do |endpoint, data, headers|
+ assert_equal 'CardOnFile', JSON.parse(data)['recurringProcessingModel']
+ end.respond_with(successful_store_response)
assert_success response
assert_equal '#8835205392522157#8315202663743702', response.authorization
end
From 2c7f5e316ce0d3f4a10268da0a4189c95d448ae7 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Tue, 14 Aug 2018 09:55:55 -0400
Subject: [PATCH 0043/2234] Optimal: document additional country support
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/optimal_payment.rb | 4 +++-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 051595682a7..936c008a9ef 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -10,6 +10,7 @@
* Payflow: allow support for partial captures [pi3r] #2952
* CT Payment: Update How Address is Passed [nfarve] #2960
* Adyen: Add RecurringProcessingModel [nfarve] #2951
+* Optimal Payments: update country list [bpollack] #2961
== Version 1.81.0 (July 30, 2018)
* GlobalCollect: Don't overwrite contactDetails [curiousepic] #2915
diff --git a/lib/active_merchant/billing/gateways/optimal_payment.rb b/lib/active_merchant/billing/gateways/optimal_payment.rb
index 2bf3b323f97..2641cf7994a 100644
--- a/lib/active_merchant/billing/gateways/optimal_payment.rb
+++ b/lib/active_merchant/billing/gateways/optimal_payment.rb
@@ -5,7 +5,9 @@ class OptimalPaymentGateway < Gateway
self.live_url = 'https://webservices.optimalpayments.com/creditcardWS/CreditCardServlet/v1'
# The countries the gateway supports merchants from as 2 digit ISO country codes
- self.supported_countries = ['CA', 'US', 'GB']
+ self.supported_countries = ['CA', 'US', 'GB', 'AU', 'AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'DK',
+ 'EE', 'FI', 'DE', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT',
+ 'NL', 'NO', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE', 'CH']
# The card types supported by the payment gateway
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :solo] # :switch?
From e4ba8e6618a101fb8a46384c72f9553451078420 Mon Sep 17 00:00:00 2001
From: Vinicius Brasil
Date: Wed, 8 Aug 2018 00:56:38 -0300
Subject: [PATCH 0044/2234] Update EBANX API URL
Remote tests failing don't appear to be related to the URL change.
Unit: 16 tests, 54 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote: 21 tests, 57 assertions, 3 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
85.7143% passed
Closes #2949
---
lib/active_merchant/billing/gateways/ebanx.rb | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/ebanx.rb b/lib/active_merchant/billing/gateways/ebanx.rb
index ef42b12d449..1dc51b009cc 100644
--- a/lib/active_merchant/billing/gateways/ebanx.rb
+++ b/lib/active_merchant/billing/gateways/ebanx.rb
@@ -1,15 +1,15 @@
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
class EbanxGateway < Gateway
- self.test_url = 'https://sandbox.ebanx.com/ws/'
- self.live_url = 'https://api.ebanx.com/ws/'
+ self.test_url = 'https://sandbox.ebanxpay.com/ws/'
+ self.live_url = 'https://api.ebanxpay.com/ws/'
self.supported_countries = ['BR', 'MX', 'CO']
self.default_currency = 'USD'
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club]
self.homepage_url = 'http://www.ebanx.com/'
- self.display_name = 'Ebanx'
+ self.display_name = 'EBANX'
CARD_BRAND = {
visa: 'visa',
From 09d54fb0e4ce35df04c777ac73cb4f8a55fb0ed0 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 16 Aug 2018 15:40:42 -0400
Subject: [PATCH 0045/2234] Add missing CHANGELOG entry for #2949
---
CHANGELOG | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG b/CHANGELOG
index 936c008a9ef..f30bbe20dfd 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -11,6 +11,7 @@
* CT Payment: Update How Address is Passed [nfarve] #2960
* Adyen: Add RecurringProcessingModel [nfarve] #2951
* Optimal Payments: update country list [bpollack] #2961
+* Ebanx: update sandbox and production URLs [vnbrs] #2949
== Version 1.81.0 (July 30, 2018)
* GlobalCollect: Don't overwrite contactDetails [curiousepic] #2915
From 9e3cc3e001a45767aef81623ee2a0985a838be9e Mon Sep 17 00:00:00 2001
From: Vinicius Brasil
Date: Wed, 8 Aug 2018 01:02:55 -0300
Subject: [PATCH 0046/2234] Add additional countries for EBANX
EBANX accepts credit card payments from Chile and Argentina
(https://business.ebanx.com/en/payment-methods).
Closes #2950
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/ebanx.rb | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index f30bbe20dfd..507ec3691bd 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -12,6 +12,7 @@
* Adyen: Add RecurringProcessingModel [nfarve] #2951
* Optimal Payments: update country list [bpollack] #2961
* Ebanx: update sandbox and production URLs [vnbrs] #2949
+* Ebanx: support additional countries [vnbrs] #2950
== Version 1.81.0 (July 30, 2018)
* GlobalCollect: Don't overwrite contactDetails [curiousepic] #2915
diff --git a/lib/active_merchant/billing/gateways/ebanx.rb b/lib/active_merchant/billing/gateways/ebanx.rb
index 1dc51b009cc..d22affa971f 100644
--- a/lib/active_merchant/billing/gateways/ebanx.rb
+++ b/lib/active_merchant/billing/gateways/ebanx.rb
@@ -4,7 +4,7 @@ class EbanxGateway < Gateway
self.test_url = 'https://sandbox.ebanxpay.com/ws/'
self.live_url = 'https://api.ebanxpay.com/ws/'
- self.supported_countries = ['BR', 'MX', 'CO']
+ self.supported_countries = ['BR', 'MX', 'CO', 'CL', 'AR']
self.default_currency = 'USD'
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club]
From c9c1e3bf665c84d687e3f9625469c602ebcbb532 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 16 Aug 2018 15:30:37 -0400
Subject: [PATCH 0047/2234] Fix typo in gateway generator
When I fixed YAML, I accidentally committed this script with parens
in the wrong place. Fix that.
---
CHANGELOG | 1 +
generators/gateway/gateway_generator.rb | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 507ec3691bd..1937f880a09 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -13,6 +13,7 @@
* Optimal Payments: update country list [bpollack] #2961
* Ebanx: update sandbox and production URLs [vnbrs] #2949
* Ebanx: support additional countries [vnbrs] #2950
+* Gateway generator: fix a typo that would cause the script to crash [bpollack] #2962
== Version 1.81.0 (July 30, 2018)
* GlobalCollect: Don't overwrite contactDetails [curiousepic] #2915
diff --git a/generators/gateway/gateway_generator.rb b/generators/gateway/gateway_generator.rb
index febddbb1c7e..27dda8aa510 100644
--- a/generators/gateway/gateway_generator.rb
+++ b/generators/gateway/gateway_generator.rb
@@ -38,7 +38,7 @@ def fixtures_file
end
def next_identifier
- fixtures = (YAML.safe_load(File.read(fixtures_file)).keys + [identifier], [], [], true).uniq.sort
+ fixtures = (YAML.safe_load(File.read(fixtures_file), [], [], true).keys + [identifier]).uniq.sort
fixtures[fixtures.sort.index(identifier)+1]
end
end
From 3534c7741a1b0bad9f19df85e2eea0286c47d2c1 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 16 Aug 2018 15:46:23 -0400
Subject: [PATCH 0048/2234] Remove unused variables and fix ambiguous
invocations
This patch contains four quick fixes, all for ambiguous code or unused
variables. Specifically, the following issues are rectified:
- test/unit/connection_test.rb:51: warning: assigned but unused variable - response
- test/unit/gateways/firstdata_e4_v27_test.rb:56: warning: ambiguous first argument; put parentheses or a space even after `/' operator
- test/unit/gateways/paymentez_test.rb:121: warning: ambiguous first argument; put parentheses or a space even after `/' operator
- lib/active_merchant/billing/gateways/ct_payment.rb:210: warning: assigned but unused variable - final_response
---
lib/active_merchant/billing/gateways/ct_payment.rb | 2 +-
test/unit/connection_test.rb | 2 +-
test/unit/gateways/firstdata_e4_v27_test.rb | 2 +-
test/unit/gateways/paymentez_test.rb | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/ct_payment.rb b/lib/active_merchant/billing/gateways/ct_payment.rb
index 2214645437e..18b111f0a12 100644
--- a/lib/active_merchant/billing/gateways/ct_payment.rb
+++ b/lib/active_merchant/billing/gateways/ct_payment.rb
@@ -207,7 +207,7 @@ def commit_raw(action, parameters)
url = (test? ? test_url : live_url) + action
response = parse(ssl_post(url, post_data(action, parameters)))
- final_response = Response.new(
+ Response.new(
success_from(response),
message_from(response),
response,
diff --git a/test/unit/connection_test.rb b/test/unit/connection_test.rb
index 564fea45f49..c33797de2a0 100644
--- a/test/unit/connection_test.rb
+++ b/test/unit/connection_test.rb
@@ -48,7 +48,7 @@ def test_connection_does_not_mutate_headers_argument
headers = { 'Content-Type' => 'text/xml' }.freeze
Net::HTTP.any_instance.expects(:get).with('/tx.php', headers.merge({'connection' => 'close'})).returns(@ok)
Net::HTTP.any_instance.expects(:start).returns(true)
- response = @connection.request(:get, nil, headers)
+ @connection.request(:get, nil, headers)
assert_equal({ 'Content-Type' => 'text/xml' }, headers)
end
diff --git a/test/unit/gateways/firstdata_e4_v27_test.rb b/test/unit/gateways/firstdata_e4_v27_test.rb
index 3e502c430e8..305faf51efb 100644
--- a/test/unit/gateways/firstdata_e4_v27_test.rb
+++ b/test/unit/gateways/firstdata_e4_v27_test.rb
@@ -53,7 +53,7 @@ def test_successful_purchase_with_wallet
response = stub_comms do
@gateway.purchase(@amount, @credit_card, @options.merge!({wallet_provider_id: 4}))
end.check_request do |endpoint, data, headers|
- assert_match /WalletProviderID>4, data
+ assert_match(/WalletProviderID>4, data)
end.respond_with(successful_purchase_response)
assert_success response
diff --git a/test/unit/gateways/paymentez_test.rb b/test/unit/gateways/paymentez_test.rb
index 8cfd9eb690d..166ab7ebcf0 100644
--- a/test/unit/gateways/paymentez_test.rb
+++ b/test/unit/gateways/paymentez_test.rb
@@ -118,7 +118,7 @@ def test_partial_refund
response = stub_comms do
@gateway.refund(@amount, '1234', @options)
end.check_request do |_endpoint, data, _headers|
- assert_match /"amount":1.0/, data
+ assert_match(/"amount":1.0/, data)
end.respond_with(successful_refund_response)
assert_success response
assert response.test?
From 1dda734b861d317f17b7858d02a59e7d8f7da556 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Mon, 20 Aug 2018 13:41:42 -0400
Subject: [PATCH 0049/2234] Clearhaus: use $0 for verification tests
Clearhaus now allows $0 auths, allowing us to tweak verify to use a
$0 transaction.
Unit: 22 tests, 110 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote: 23 tests, 70 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/clearhaus.rb | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 1937f880a09..b5dbb605fb2 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -14,6 +14,7 @@
* Ebanx: update sandbox and production URLs [vnbrs] #2949
* Ebanx: support additional countries [vnbrs] #2950
* Gateway generator: fix a typo that would cause the script to crash [bpollack] #2962
+* Clearhaus: use $0 for verify transactions [bpollack] #2964
== Version 1.81.0 (July 30, 2018)
* GlobalCollect: Don't overwrite contactDetails [curiousepic] #2915
diff --git a/lib/active_merchant/billing/gateways/clearhaus.rb b/lib/active_merchant/billing/gateways/clearhaus.rb
index 43b68fb56c4..4fd7745f395 100644
--- a/lib/active_merchant/billing/gateways/clearhaus.rb
+++ b/lib/active_merchant/billing/gateways/clearhaus.rb
@@ -88,7 +88,7 @@ def void(authorization, options = {})
def verify(credit_card, options={})
MultiResponse.run(:use_first_response) do |r|
- r.process { authorize(100, credit_card, options) }
+ r.process { authorize(0, credit_card, options) }
r.process(:ignore_result) { void(r.authorization, options) }
end
end
From a1a5c99786d38fe099c8e4b601f8d4df6b46bebc Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Fri, 24 Aug 2018 08:49:40 -0400
Subject: [PATCH 0050/2234] Global Collect: allow partial captures
Unit: 17 tests, 78 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote: 16 tests, 38 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/global_collect.rb | 17 +++++++++--------
.../gateways/remote_global_collect_test.rb | 3 ++-
3 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index b5dbb605fb2..07156f32d4b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -15,6 +15,7 @@
* Ebanx: support additional countries [vnbrs] #2950
* Gateway generator: fix a typo that would cause the script to crash [bpollack] #2962
* Clearhaus: use $0 for verify transactions [bpollack] #2964
+* Global Collect: properly handle partial captures [bpollack] #2967
== Version 1.81.0 (July 30, 2018)
* GlobalCollect: Don't overwrite contactDetails [curiousepic] #2915
diff --git a/lib/active_merchant/billing/gateways/global_collect.rb b/lib/active_merchant/billing/gateways/global_collect.rb
index 2bd27df7aed..7942dbcec76 100644
--- a/lib/active_merchant/billing/gateways/global_collect.rb
+++ b/lib/active_merchant/billing/gateways/global_collect.rb
@@ -4,8 +4,8 @@ class GlobalCollectGateway < Gateway
self.display_name = 'GlobalCollect'
self.homepage_url = 'http://www.globalcollect.com/'
- self.test_url = 'https://eu.sandbox.api-ingenico.com/'
- self.live_url = 'https://api.globalcollect.com/'
+ self.test_url = 'https://eu.sandbox.api-ingenico.com'
+ self.live_url = 'https://api.globalcollect.com'
self.supported_countries = ['AD', 'AE', 'AG', 'AI', 'AL', 'AM', 'AO', 'AR', 'AS', 'AT', 'AU', 'AW', 'AX', 'AZ', 'BA', 'BB', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BL', 'BM', 'BN', 'BO', 'BQ', 'BR', 'BS', 'BT', 'BW', 'BY', 'BZ', 'CA', 'CC', 'CD', 'CF', 'CH', 'CI', 'CK', 'CL', 'CM', 'CN', 'CO', 'CR', 'CU', 'CV', 'CW', 'CX', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM', 'DO', 'DZ', 'EC', 'EE', 'EG', 'ER', 'ES', 'ET', 'FI', 'FJ', 'FK', 'FM', 'FO', 'FR', 'GA', 'GB', 'GD', 'GE', 'GF', 'GH', 'GI', 'GL', 'GM', 'GN', 'GP', 'GQ', 'GR', 'GS', 'GT', 'GU', 'GW', 'GY', 'HK', 'HN', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IM', 'IN', 'IS', 'IT', 'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI', 'KM', 'KN', 'KR', 'KW', 'KY', 'KZ', 'LA', 'LB', 'LC', 'LI', 'LK', 'LR', 'LS', 'LT', 'LU', 'LV', 'MA', 'MC', 'MD', 'ME', 'MF', 'MG', 'MH', 'MK', 'MM', 'MN', 'MO', 'MP', 'MQ', 'MR', 'MS', 'MT', 'MU', 'MV', 'MW', 'MX', 'MY', 'MZ', 'NA', 'NC', 'NE', 'NG', 'NI', 'NL', 'NO', 'NP', 'NR', 'NU', 'NZ', 'OM', 'PA', 'PE', 'PF', 'PG', 'PH', 'PL', 'PN', 'PS', 'PT', 'PW', 'QA', 'RE', 'RO', 'RS', 'RU', 'RW', 'SA', 'SB', 'SC', 'SE', 'SG', 'SH', 'SI', 'SJ', 'SK', 'SL', 'SM', 'SN', 'SR', 'ST', 'SV', 'SZ', 'TC', 'TD', 'TG', 'TH', 'TJ', 'TL', 'TM', 'TN', 'TO', 'TR', 'TT', 'TV', 'TW', 'TZ', 'UA', 'UG', 'US', 'UY', 'UZ', 'VC', 'VE', 'VG', 'VI', 'VN', 'WF', 'WS', 'ZA', 'ZM', 'ZW']
self.default_currency = 'USD'
@@ -38,7 +38,7 @@ def authorize(money, payment, options={})
def capture(money, authorization, options={})
post = nestable_hash
- add_order(post, money, options)
+ add_order(post, money, options, capture: true)
add_customer_data(post, options)
add_creator_info(post, options)
commit(:capture, post, authorization)
@@ -87,11 +87,12 @@ def scrub(transcript)
'diners_club' => '132'
}
- def add_order(post, money, options)
- post['order']['amountOfMoney'] = {
- 'amount' => amount(money),
- 'currencyCode' => options[:currency] || currency(money)
- }
+ def add_order(post, money, options, capture: false)
+ if capture
+ post['amount'] = amount(money)
+ else
+ add_amount(post['order'], money, options)
+ end
post['order']['references'] = {
'merchantReference' => options[:order_id],
'descriptor' => options[:description] # Max 256 chars
diff --git a/test/remote/gateways/remote_global_collect_test.rb b/test/remote/gateways/remote_global_collect_test.rb
index 519db653470..b7497b13f00 100644
--- a/test/remote/gateways/remote_global_collect_test.rb
+++ b/test/remote/gateways/remote_global_collect_test.rb
@@ -88,8 +88,9 @@ def test_partial_capture
auth = @gateway.authorize(@amount, @credit_card, @options)
assert_success auth
- assert capture = @gateway.capture(@amount-1, auth.authorization)
+ assert capture = @gateway.capture(@amount - 1, auth.authorization)
assert_success capture
+ assert_equal 99, capture.params['payment']['paymentOutput']['amountOfMoney']['amount']
end
def test_failed_capture
From 416e4a8d6e3a236a31b33ee98d084b6fa55cef78 Mon Sep 17 00:00:00 2001
From: dtykocki
Date: Fri, 24 Aug 2018 08:01:28 -0400
Subject: [PATCH 0051/2234] Braintree: Add support for GooglePay
Adds support for processing GooglePay payment methods. It appears that
Braintree treats GooglePay in the same manner as AndroidPay. Even their
documentation (linked below) claims that GooglePay cards are represented
as AndroidPay cards. As such, the only way to get the GooglePay remote
test to pass is to pass the payment information in as `android_pay`.
Ref: https://developers.braintreepayments.com/guides/google-pay/server-side/ruby
Remote:
63 tests, 361 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
50 tests, 124 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
.rubocop_todo.yml | 2 ++
CHANGELOG | 1 +
.../billing/gateways/braintree_blue.rb | 2 +-
.../gateways/remote_braintree_blue_test.rb | 18 ++++++++++
test/unit/gateways/braintree_blue_test.rb | 34 +++++++++++++++++++
5 files changed, 56 insertions(+), 1 deletion(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 35c175ad580..b5e9ff77717 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -659,6 +659,8 @@ Metrics/ParameterLists:
# Offense count: 126
Metrics/PerceivedComplexity:
Max: 32
+ Exclude:
+ - 'lib/active_merchant/billing/gateways/braintree_blue.rb'
# Offense count: 6
Naming/AccessorMethodName:
diff --git a/CHANGELOG b/CHANGELOG
index 07156f32d4b..d1308957428 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -16,6 +16,7 @@
* Gateway generator: fix a typo that would cause the script to crash [bpollack] #2962
* Clearhaus: use $0 for verify transactions [bpollack] #2964
* Global Collect: properly handle partial captures [bpollack] #2967
+* Braintree: Add support for GooglePay [dtykocki] [#2966]
== Version 1.81.0 (July 30, 2018)
* GlobalCollect: Don't overwrite contactDetails [curiousepic] #2915
diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb
index 96bdbdae5b8..7f0dbcaacbf 100644
--- a/lib/active_merchant/billing/gateways/braintree_blue.rb
+++ b/lib/active_merchant/billing/gateways/braintree_blue.rb
@@ -598,7 +598,7 @@ def create_transaction_parameters(money, credit_card_or_vault_id, options)
:cryptogram => credit_card_or_vault_id.payment_cryptogram,
:eci_indicator => credit_card_or_vault_id.eci
}
- elsif credit_card_or_vault_id.source == :android_pay
+ elsif credit_card_or_vault_id.source == :android_pay || credit_card_or_vault_id.source == :google_pay
parameters[:android_pay_card] = {
:number => credit_card_or_vault_id.number,
:cryptogram => credit_card_or_vault_id.payment_cryptogram,
diff --git a/test/remote/gateways/remote_braintree_blue_test.rb b/test/remote/gateways/remote_braintree_blue_test.rb
index 82ad314494b..5f48f9ee313 100644
--- a/test/remote/gateways/remote_braintree_blue_test.rb
+++ b/test/remote/gateways/remote_braintree_blue_test.rb
@@ -432,6 +432,24 @@ def test_authorize_and_capture_with_android_pay_card
assert_success capture
end
+ def test_authorize_and_capture_with_google_pay_card
+ credit_card = network_tokenization_credit_card('4111111111111111',
+ :payment_cryptogram => 'EHuWW9PiBkWvqE5juRwDzAUFBAk=',
+ :month => '01',
+ :year => '2024',
+ :source => :google_pay,
+ :transaction_id => '123456789',
+ :eci => '05'
+ )
+
+ assert auth = @gateway.authorize(@amount, credit_card, @options)
+ assert_success auth
+ assert_equal '1000 Approved', auth.message
+ assert auth.authorization
+ assert capture = @gateway.capture(@amount, auth.authorization)
+ assert_success capture
+ end
+
def test_authorize_and_void
assert auth = @gateway.authorize(@amount, @credit_card, @options)
assert_success auth
diff --git a/test/unit/gateways/braintree_blue_test.rb b/test/unit/gateways/braintree_blue_test.rb
index ff67f2dc983..194c7552176 100644
--- a/test/unit/gateways/braintree_blue_test.rb
+++ b/test/unit/gateways/braintree_blue_test.rb
@@ -681,6 +681,40 @@ def test_android_pay_card
assert_equal 'transaction_id', response.authorization
end
+ def test_google_pay_card
+ Braintree::TransactionGateway.any_instance.expects(:sale).
+ with(
+ :amount => '1.00',
+ :order_id => '1',
+ :customer => {:id => nil, :email => nil, :phone => nil,
+ :first_name => 'Longbob', :last_name => 'Longsen'},
+ :options => {:store_in_vault => false, :submit_for_settlement => nil, :hold_in_escrow => nil},
+ :custom_fields => nil,
+ :android_pay_card => {
+ :number => '4111111111111111',
+ :expiration_month => '09',
+ :expiration_year => (Time.now.year + 1).to_s,
+ :cryptogram => '111111111100cryptogram',
+ :google_transaction_id => '1234567890',
+ :source_card_type => 'visa',
+ :source_card_last_four => '1111',
+ :eci_indicator => '05'
+ }
+ ).
+ returns(braintree_result(:id => 'transaction_id'))
+
+ credit_card = network_tokenization_credit_card('4111111111111111',
+ :brand => 'visa',
+ :eci => '05',
+ :payment_cryptogram => '111111111100cryptogram',
+ :source => :google_pay,
+ :transaction_id => '1234567890'
+ )
+
+ response = @gateway.authorize(100, credit_card, :test => true, :order_id => '1')
+ assert_equal 'transaction_id', response.authorization
+ end
+
def test_supports_network_tokenization
assert_instance_of TrueClass, @gateway.supports_network_tokenization?
end
From db3a22b8a49638a426f84cc48a8d283f08942e42 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 23 Aug 2018 14:59:03 -0400
Subject: [PATCH 0052/2234] Adyen: add Maestro and Electron support
Unit: 23 tests, 109 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote: 35 tests, 88 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/adyen.rb | 5 +++-
test/remote/gateways/remote_adyen_test.rb | 24 +++++++++++++++----
test/unit/gateways/adyen_test.rb | 14 +++++++++++
4 files changed, 39 insertions(+), 5 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index d1308957428..a77eb3b0f6d 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -17,6 +17,7 @@
* Clearhaus: use $0 for verify transactions [bpollack] #2964
* Global Collect: properly handle partial captures [bpollack] #2967
* Braintree: Add support for GooglePay [dtykocki] [#2966]
+* Adyen: allow overriding card brands [bpollack] #2968
== Version 1.81.0 (July 30, 2018)
* GlobalCollect: Don't overwrite contactDetails [curiousepic] #2915
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index d938036894e..822043c8c97 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -114,9 +114,12 @@ def add_extra_data(post, payment, options)
post[:shopperIP] = options[:shopper_ip] if options[:shopper_ip]
post[:shopperReference] = options[:shopper_reference] if options[:shopper_reference]
post[:fraudOffset] = options[:fraud_offset] if options[:fraud_offset]
- post[:selectedBrand] = options[:selected_brand] || NETWORK_TOKENIZATION_CARD_SOURCE[payment.source.to_s] if payment.is_a?(NetworkTokenizationCreditCard)
+ post[:selectedBrand] = options[:selected_brand] if options[:selected_brand]
+ post[:selectedBrand] ||= NETWORK_TOKENIZATION_CARD_SOURCE[payment.source.to_s] if payment.is_a?(NetworkTokenizationCreditCard)
post[:deliveryDate] = options[:delivery_date] if options[:delivery_date]
post[:merchantOrderReference] = options[:merchant_order_reference] if options[:merchant_order_reference]
+ post[:additionalData] ||= {}
+ post[:additionalData][:overwriteBrand] = normalize(options[:overwrite_brand]) if options[:overwrite_brand]
end
def add_shopper_interaction(post, payment, options={})
diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb
index 6a6bd3240d8..b717292cba3 100644
--- a/test/remote/gateways/remote_adyen_test.rb
+++ b/test/remote/gateways/remote_adyen_test.rb
@@ -17,6 +17,16 @@ def setup
@declined_card = credit_card('4000300011112220')
+ @improperly_branded_maestro = credit_card(
+ '5500000000000004',
+ month: 8,
+ year: 2018,
+ first_name: 'John',
+ last_name: 'Smith',
+ verification_value: '737',
+ brand: 'mastercard'
+ )
+
@apple_pay_card = network_tokenization_credit_card('4111111111111111',
:payment_cryptogram => 'YwAAAAAABaYcCMX/OhNRQAAAAAA=',
:month => '08',
@@ -45,7 +55,7 @@ def test_successful_authorize
def test_failed_authorize
response = @gateway.authorize(@amount, @declined_card, @options)
assert_failure response
- assert_equal 'Refused', response.message
+ assert_equal 'CVC Declined', response.message
end
def test_successful_purchase
@@ -75,10 +85,16 @@ def test_successful_purchase_with_apple_pay
assert_equal '[capture-received]', response.message
end
+ def test_succesful_purchase_with_brand_override
+ response = @gateway.purchase(@amount, @improperly_branded_maestro, @options.merge({overwrite_brand: true, selected_brand: 'maestro'}))
+ assert_success response
+ assert_equal '[capture-received]', response.message
+ end
+
def test_failed_purchase
response = @gateway.purchase(@amount, @declined_card, @options)
assert_failure response
- assert_equal 'Refused', response.message
+ assert_equal 'CVC Declined', response.message
end
def test_successful_authorize_and_capture
@@ -154,7 +170,7 @@ def test_failed_store
assert response = @gateway.store(@declined_card, @options)
assert_failure response
- assert_equal 'Refused', response.message
+ assert_equal 'CVC Declined', response.message
end
def test_successful_purchase_using_stored_card
@@ -184,7 +200,7 @@ def test_successful_verify
def test_failed_verify
response = @gateway.verify(@declined_card, @options)
assert_failure response
- assert_match 'Refused', response.message
+ assert_match 'CVC Declined', response.message
end
def test_invalid_login
diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb
index b752a9c4875..0b3d5df48a5 100644
--- a/test/unit/gateways/adyen_test.rb
+++ b/test/unit/gateways/adyen_test.rb
@@ -100,6 +100,20 @@ def test_successful_purchase
assert response.test?
end
+ def test_successful_maestro_purchase
+ response = stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options.merge({selected_brand: 'maestro', overwrite_brand: 'true'}))
+ end.check_request do |endpoint, data, headers|
+ if endpoint =~ /authorise/
+ assert_match(/"overwriteBrand":true/, data)
+ assert_match(/"selectedBrand":"maestro"/, data)
+ end
+ end.respond_with(successful_authorize_response, successful_capture_response)
+ assert_success response
+ assert_equal '7914775043909934#8814775564188305#', response.authorization
+ assert response.test?
+ end
+
def test_installments_sent
stub_comms do
@gateway.authorize(@amount, @credit_card, @options)
From ddd7abdff569ada2212f1dce2ae4dc15080e07ff Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Mon, 27 Aug 2018 15:29:57 -0400
Subject: [PATCH 0053/2234] Adyen: add support for customRoutingFlag
Note that this can't really be tested in the sandbox (it's changing
how Adyen processes the card, so the sandbox doesn't do anything with
it), so remote tests are omitted.
Remote: 35 tests, 88 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit: 24 tests, 112 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/adyen.rb | 1 +
test/unit/gateways/adyen_test.rb | 8 ++++++++
3 files changed, 10 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index a77eb3b0f6d..8ab49a258bd 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -18,6 +18,7 @@
* Global Collect: properly handle partial captures [bpollack] #2967
* Braintree: Add support for GooglePay [dtykocki] [#2966]
* Adyen: allow overriding card brands [bpollack] #2968
+* Adyen: allow custom routing [bpollack] #2969
== Version 1.81.0 (July 30, 2018)
* GlobalCollect: Don't overwrite contactDetails [curiousepic] #2915
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index 822043c8c97..09961e936e1 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -120,6 +120,7 @@ def add_extra_data(post, payment, options)
post[:merchantOrderReference] = options[:merchant_order_reference] if options[:merchant_order_reference]
post[:additionalData] ||= {}
post[:additionalData][:overwriteBrand] = normalize(options[:overwrite_brand]) if options[:overwrite_brand]
+ post[:additionalData][:customRoutingFlag] = options[:custom_routing_flag] if options[:custom_routing_flag]
end
def add_shopper_interaction(post, payment, options={})
diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb
index 0b3d5df48a5..c989b1d45b9 100644
--- a/test/unit/gateways/adyen_test.rb
+++ b/test/unit/gateways/adyen_test.rb
@@ -122,6 +122,14 @@ def test_installments_sent
end.respond_with(successful_authorize_response)
end
+ def test_custom_routing_sent
+ stub_comms do
+ @gateway.authorize(@amount, @credit_card, @options.merge({custom_routing_flag: 'abcdefg'}))
+ end.check_request do |endpoint, data, headers|
+ assert_equal 'abcdefg', JSON.parse(data)['additionalData']['customRoutingFlag']
+ end.respond_with(successful_authorize_response)
+ end
+
def test_failed_purchase
@gateway.expects(:ssl_post).returns(failed_purchase_response)
From 0e779a865869dcfb7674cbd5b042a55f3025ea8a Mon Sep 17 00:00:00 2001
From: DeeDee Lavinder
Date: Wed, 29 Aug 2018 11:18:06 -0400
Subject: [PATCH 0054/2234] First Pay: Adds scrubbing for gateway_id,
card_number, and cvv2
Unit Tests:
12 tests, 119 assertions, 0 failures, 0 errors, 0 pendings,
0 omissions, 0 notifications
100% passed
Remote Tests:
14 tests, 32 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/first_pay.rb | 11 ++++
test/remote/gateways/remote_first_pay_test.rb | 12 +++++
test/unit/gateways/first_pay_test.rb | 51 +++++++++++++++++++
4 files changed, 75 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index 8ab49a258bd..8d3d21c4ca9 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -19,6 +19,7 @@
* Braintree: Add support for GooglePay [dtykocki] [#2966]
* Adyen: allow overriding card brands [bpollack] #2968
* Adyen: allow custom routing [bpollack] #2969
+* First Pay: Adds scrubbing [deedeelavinder] #2972
== Version 1.81.0 (July 30, 2018)
* GlobalCollect: Don't overwrite contactDetails [curiousepic] #2915
diff --git a/lib/active_merchant/billing/gateways/first_pay.rb b/lib/active_merchant/billing/gateways/first_pay.rb
index 0c0b6ff4897..08b4f417986 100644
--- a/lib/active_merchant/billing/gateways/first_pay.rb
+++ b/lib/active_merchant/billing/gateways/first_pay.rb
@@ -56,6 +56,17 @@ def void(authorization, options={})
commit('void', post)
end
+ def supports_scrubbing?
+ true
+ end
+
+ def scrub(transcript)
+ transcript.
+ gsub(%r((gateway_id)[^<]*())i, '\1[FILTERED]\2').
+ gsub(%r((card_number)[^<]*())i, '\1[FILTERED]\2').
+ gsub(%r((cvv2)[^<]*())i, '\1[FILTERED]\2')
+ end
+
private
def add_authentication(post, options)
diff --git a/test/remote/gateways/remote_first_pay_test.rb b/test/remote/gateways/remote_first_pay_test.rb
index 23aa35e8a30..3edab642a57 100644
--- a/test/remote/gateways/remote_first_pay_test.rb
+++ b/test/remote/gateways/remote_first_pay_test.rb
@@ -116,4 +116,16 @@ def test_recurring_payment
assert_success response
assert_equal 'Approved', response.message
end
+
+ def test_transcript_scrubbing
+ @credit_card.verification_value = 789
+ transcript = capture_transcript(@gateway) do
+ @gateway.purchase(@amount, @credit_card, @options)
+ end
+ transcript = @gateway.scrub(transcript)
+
+ assert_scrubbed(@credit_card.number, transcript)
+ assert_scrubbed(@credit_card.verification_value, transcript)
+ assert_scrubbed(@gateway.options[:gateway_id], transcript)
+ end
end
diff --git a/test/unit/gateways/first_pay_test.rb b/test/unit/gateways/first_pay_test.rb
index 6596389bf64..1e0bab16e96 100644
--- a/test/unit/gateways/first_pay_test.rb
+++ b/test/unit/gateways/first_pay_test.rb
@@ -199,6 +199,11 @@ def test_recurring_payments
assert_success response
end
+ def test_scrub
+ assert @gateway.supports_scrubbing?
+ assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed
+ end
+
private
def successful_purchase_response
@@ -362,6 +367,52 @@ def failed_void_response
1
+)
+ end
+
+ def pre_scrubbed
+ %(
+
+ 77b61bfe08510e00852f2f20011e7952d80f9a4be17d27cf
+ 1.00visa
+ 4111111111111111
+ 0919
+ 789
+ Jim Smith
+ 456 My Street
+ Apt 1
+ Ottawa
+ ON
+ K1C2N6
+ CA
+ (555)555-5555
+ 1264
+ a91c38c3-7d7f-4d29-acc7-927b4dca0dbe
+ sale
+
+)
+ end
+
+ def post_scrubbed
+ %(
+
+ 77b61bfe08510e00852f2f20011e7952d80f9a4be17d27cf
+ 1.00visa
+
+ 0919
+
+ Jim Smith
+ 456 My Street
+ Apt 1
+ Ottawa
+ ON
+ K1C2N6
+ CA
+ (555)555-5555
+ 1264
+
+ sale
+
)
end
end
From 58673ca6dac74eca05bf747da9018259161874bc Mon Sep 17 00:00:00 2001
From: Michael Elfassy
Date: Thu, 30 Aug 2018 08:33:26 -0400
Subject: [PATCH 0055/2234] Release 1.83.0
---
CHANGELOG | 17 ++++++++++-------
lib/active_merchant/version.rb | 2 +-
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 8d3d21c4ca9..cfc8d11137b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,13 +1,8 @@
= ActiveMerchant CHANGELOG
== HEAD
-== Version 1.82.0 (August 13, 2018)
-* FirstData: add support for WalletProviderID in v27 gateway [bpollack] #2946
-* BlueSnap: Handle 403 responses [curiousepic] #2948
-* BlueSnap: Add StoreCard Field [nfarve] #2953
-* Worldpay: support installments [bpollack] #2957
-* Paymentez: support partial refunds [bpollack] #2959
-* Payflow: allow support for partial captures [pi3r] #2952
+
+== Version 1.83.0 (August 30, 2018)
* CT Payment: Update How Address is Passed [nfarve] #2960
* Adyen: Add RecurringProcessingModel [nfarve] #2951
* Optimal Payments: update country list [bpollack] #2961
@@ -21,6 +16,14 @@
* Adyen: allow custom routing [bpollack] #2969
* First Pay: Adds scrubbing [deedeelavinder] #2972
+== Version 1.82.0 (August 13, 2018)
+* FirstData: add support for WalletProviderID in v27 gateway [bpollack] #2946
+* BlueSnap: Handle 403 responses [curiousepic] #2948
+* BlueSnap: Add StoreCard Field [nfarve] #2953
+* Worldpay: support installments [bpollack] #2957
+* Paymentez: support partial refunds [bpollack] #2959
+* Payflow: allow support for partial captures [pi3r] #2952
+
== Version 1.81.0 (July 30, 2018)
* GlobalCollect: Don't overwrite contactDetails [curiousepic] #2915
* Pin Payments: Pass reference for statement desc [curiousepic] #2919
diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb
index c3ac04fa8c8..e0f40471379 100644
--- a/lib/active_merchant/version.rb
+++ b/lib/active_merchant/version.rb
@@ -1,3 +1,3 @@
module ActiveMerchant
- VERSION = '1.82.0'
+ VERSION = '1.83.0'
end
From 0061962c749b2c05d4f103b98c35720834645912 Mon Sep 17 00:00:00 2001
From: dtykocki
Date: Fri, 24 Aug 2018 18:24:58 -0400
Subject: [PATCH 0056/2234] Adyen: Add support for GooglePay
Unit:
24 tests, 113 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
36 tests, 90 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/adyen.rb | 1 +
test/remote/gateways/remote_adyen_test.rb | 14 ++++++++++++++
test/unit/gateways/adyen_test.rb | 6 ++++--
4 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index cfc8d11137b..a2d8271ef2a 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -15,6 +15,7 @@
* Adyen: allow overriding card brands [bpollack] #2968
* Adyen: allow custom routing [bpollack] #2969
* First Pay: Adds scrubbing [deedeelavinder] #2972
+* Adyen: Add support for GooglePay [dtykocki] #2971
== Version 1.82.0 (August 13, 2018)
* FirstData: add support for WalletProviderID in v27 gateway [bpollack] #2946
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index 09961e936e1..d7fb3a94042 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -121,6 +121,7 @@ def add_extra_data(post, payment, options)
post[:additionalData] ||= {}
post[:additionalData][:overwriteBrand] = normalize(options[:overwrite_brand]) if options[:overwrite_brand]
post[:additionalData][:customRoutingFlag] = options[:custom_routing_flag] if options[:custom_routing_flag]
+ post[:additionalData]['paymentdatasource.type'] = NETWORK_TOKENIZATION_CARD_SOURCE[payment.source.to_s] if payment.is_a?(NetworkTokenizationCreditCard)
end
def add_shopper_interaction(post, payment, options={})
diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb
index b717292cba3..0ba48c81be2 100644
--- a/test/remote/gateways/remote_adyen_test.rb
+++ b/test/remote/gateways/remote_adyen_test.rb
@@ -35,6 +35,14 @@ def setup
:verification_value => nil
)
+ @google_pay_card = network_tokenization_credit_card('4111111111111111',
+ :payment_cryptogram => 'YwAAAAAABaYcCMX/OhNRQAAAAAA=',
+ :month => '08',
+ :year => '2018',
+ :source => :google_pay,
+ :verification_value => nil
+ )
+
@options = {
reference: '345123',
shopper_email: 'john.smith@test.com',
@@ -91,6 +99,12 @@ def test_succesful_purchase_with_brand_override
assert_equal '[capture-received]', response.message
end
+ def test_successful_purchase_with_google_pay
+ response = @gateway.purchase(@amount, @google_pay_card, @options)
+ assert_success response
+ assert_equal '[capture-received]', response.message
+ end
+
def test_failed_purchase
response = @gateway.purchase(@amount, @declined_card, @options)
assert_failure response
diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb
index c989b1d45b9..053b160516a 100644
--- a/test/unit/gateways/adyen_test.rb
+++ b/test/unit/gateways/adyen_test.rb
@@ -261,8 +261,10 @@ def test_authorize_with_network_tokenization_credit_card
response = stub_comms do
@gateway.authorize(@amount, @apple_pay_card, @options)
end.check_request do |endpoint, data, headers|
- assert_equal 'YwAAAAAABaYcCMX/OhNRQAAAAAA=', JSON.parse(data)['mpiData']['cavv']
- assert_equal '07', JSON.parse(data)['mpiData']['eci']
+ parsed = JSON.parse(data)
+ assert_equal 'YwAAAAAABaYcCMX/OhNRQAAAAAA=', parsed['mpiData']['cavv']
+ assert_equal '07', parsed['mpiData']['eci']
+ assert_equal 'applepay', parsed['additionalData']['paymentdatasource.type']
end.respond_with(successful_authorize_response)
assert_success response
end
From 00287a262d0607b206e0682a789dc368e3fbc2d8 Mon Sep 17 00:00:00 2001
From: "Matt R. Wilson"
Date: Thu, 30 Aug 2018 10:37:54 -0600
Subject: [PATCH 0057/2234] Check if using SSL before getting SSL conn info.
Was getting this error in a project when running its acceptance tests
against a mocking service that used a `http` schema.
```
undefined method `ssl_version' for #
$GEMS/bundler/gems/active_merchant-f3d11caabc66/lib/active_merchant/net_http_ssl_connection.rb:7:in `ssl_connection'
$GEMS/bundler/gems/active_merchant-f3d11caabc66/lib/active_merchant/connection.rb:82:in `block (2 levels) in request'
```
---
lib/active_merchant/net_http_ssl_connection.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/active_merchant/net_http_ssl_connection.rb b/lib/active_merchant/net_http_ssl_connection.rb
index d0764cbc615..c0ae5ce1080 100644
--- a/lib/active_merchant/net_http_ssl_connection.rb
+++ b/lib/active_merchant/net_http_ssl_connection.rb
@@ -3,7 +3,7 @@
module NetHttpSslConnection
refine Net::HTTP do
def ssl_connection
- return {} unless @socket.present?
+ return {} unless use_ssl? && @socket.present?
{ version: @socket.io.ssl_version, cipher: @socket.io.cipher[0] }
end
end
From 85c57a6c2d15ae86ab3713120bf9d2277260cd26 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 30 Aug 2018 11:51:29 -0400
Subject: [PATCH 0058/2234] PayU Latam: add partial capture support
Note that PayU Latam's sandbox does not support capture, so while I
added remote tests, they're more...let's call it hypothetical.
Failing remote tests are unrelated to this change
Unit: 28 tests, 104 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote: 30 tests, 68 assertions, 4 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
86.6667% passed
---
CHANGELOG | 1 +
.../billing/gateways/payu_latam.rb | 11 ++++++-
.../remote/gateways/remote_payu_latam_test.rb | 30 ++++++++++++++++++-
test/unit/gateways/payu_latam_test.rb | 8 +++++
4 files changed, 48 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index a2d8271ef2a..4e989e3cd3c 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
= ActiveMerchant CHANGELOG
== HEAD
+* PayU Latam: support partial captures [bpollack] #2974
== Version 1.83.0 (August 30, 2018)
* CT Payment: Update How Address is Passed [nfarve] #2960
diff --git a/lib/active_merchant/billing/gateways/payu_latam.rb b/lib/active_merchant/billing/gateways/payu_latam.rb
index a3192fe79e7..5d3dc1af6b5 100644
--- a/lib/active_merchant/billing/gateways/payu_latam.rb
+++ b/lib/active_merchant/billing/gateways/payu_latam.rb
@@ -52,6 +52,11 @@ def capture(amount, authorization, options={})
add_transaction_elements(post, 'CAPTURE', options)
add_reference(post, authorization)
+ if !amount.nil? && amount.to_f != 0.0
+ post[:transaction][:additionalValues] ||= {}
+ post[:transaction][:additionalValues][:TX_VALUE] = invoice_for(amount, options)[:TX_VALUE]
+ end
+
commit('capture', post)
end
@@ -220,6 +225,10 @@ def shipping_address_fields(options)
end
def add_invoice(post, money, options)
+ post[:transaction][:order][:additionalValues] = invoice_for(money, options)
+ end
+
+ def invoice_for(money, options)
tx_value = {}
tx_value[:value] = amount(money)
tx_value[:currency] = options[:currency] || currency(money)
@@ -237,7 +246,7 @@ def add_invoice(post, money, options)
additional_values[:TX_TAX] = tx_tax if @options[:payment_country] == 'CO'
additional_values[:TX_TAX_RETURN_BASE] = tx_tax_return_base if @options[:payment_country] == 'CO'
- post[:transaction][:order][:additionalValues] = additional_values
+ additional_values
end
def add_signature(post)
diff --git a/test/remote/gateways/remote_payu_latam_test.rb b/test/remote/gateways/remote_payu_latam_test.rb
index a33a22558dd..316aaee30a4 100644
--- a/test/remote/gateways/remote_payu_latam_test.rb
+++ b/test/remote/gateways/remote_payu_latam_test.rb
@@ -251,6 +251,34 @@ def test_failed_authorize_with_specified_language
assert_equal 'Credenciales inválidas', response.message
end
+ # As noted above, capture transactions are currently not supported, but in the hope
+ # they will one day be, here you go
+
+ # def test_successful_capture
+ # response = @gateway.authorize(@amount, @credit_card, @options)
+ # assert_success response
+ # assert_equal 'APPROVED', response.message
+ # assert_match %r(^\d+\|(\w|-)+$), response.authorization
+
+ # capture = @gateway.capture(@amount, response.authorization, @options)
+ # assert_success capture
+ # assert_equal 'APPROVED', response.message
+ # assert response.test?
+ # end
+
+ # def test_successful_partial_capture
+ # response = @gateway.authorize(@amount, @credit_card, @options)
+ # assert_success response
+ # assert_equal 'APPROVED', response.message
+ # assert_match %r(^\d+\|(\w|-)+$), response.authorization
+
+ # capture = @gateway.capture(@amount - 1, response.authorization, @options)
+ # assert_success capture
+ # assert_equal 'APPROVED', response.message
+ # assert_equal '39.99', response.params['TX_VALUE']['value']
+ # assert response.test?
+ # end
+
def test_well_formed_refund_fails_as_expected
purchase = @gateway.purchase(@amount, @credit_card, @options)
assert_success purchase
@@ -298,7 +326,7 @@ def test_unsupported_test_capture_fails_as_expected
auth = @gateway.authorize(@amount, @credit_card, @options)
assert_success auth
- assert capture = @gateway.capture(@amount, auth.authorization)
+ assert capture = @gateway.capture(@amount, auth.authorization, @options)
assert_failure capture
assert_equal 'Internal payment provider error. ', capture.message
end
diff --git a/test/unit/gateways/payu_latam_test.rb b/test/unit/gateways/payu_latam_test.rb
index 897cf82be56..68e76b9ef2e 100644
--- a/test/unit/gateways/payu_latam_test.rb
+++ b/test/unit/gateways/payu_latam_test.rb
@@ -207,6 +207,14 @@ def test_successful_capture_with_specified_language
end.respond_with(successful_purchase_response)
end
+ def test_successful_partial_capture
+ stub_comms do
+ @gateway.capture(@amount - 1, '4000|authorization', @options)
+ end.check_request do |endpoint, data, headers|
+ assert_equal '39.99', JSON.parse(data)['transaction']['additionalValues']['TX_VALUE']['value']
+ end.respond_with(successful_purchase_response)
+ end
+
def test_failed_capture
@gateway.expects(:ssl_post).returns(failed_void_response)
From bd4c616348e208ad28fa7b0204e2de0136e1ca2a Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 30 Aug 2018 16:38:04 -0400
Subject: [PATCH 0059/2234] Rubocop: fix Layout/ClosingParenthesisIndentation
---
.rubocop_todo.yml | 5 ----
.../billing/gateways/balanced.rb | 12 +++++-----
.../billing/gateways/braintree_blue.rb | 6 +++--
.../billing/gateways/card_stream.rb | 15 ++++++------
.../billing/gateways/global_collect.rb | 12 +++++-----
.../billing/gateways/modern_payments_cim.rb | 2 +-
.../billing/gateways/paystation.rb | 4 ++--
.../billing/gateways/quantum.rb | 8 +++----
lib/active_merchant/billing/gateways/sage.rb | 9 ++++---
.../billing/gateways/trexle.rb | 10 ++++----
.../gateways/remote_authorize_net_cim_test.rb | 14 +++++------
.../remote_barclaycard_smartpay_test.rb | 6 ++---
.../gateways/remote_braintree_blue_test.rb | 2 +-
test/remote/gateways/remote_card_save_test.rb | 4 ++--
test/remote/gateways/remote_jetpay_v2_test.rb | 2 +-
test/remote/gateways/remote_litle_test.rb | 21 ++++++++--------
.../remote/gateways/remote_payflow_uk_test.rb | 16 ++++++-------
test/remote/gateways/remote_quickpay_test.rb | 4 ++--
.../gateways/remote_quickpay_v4_test.rb | 4 ++--
.../gateways/remote_quickpay_v5_test.rb | 4 ++--
.../gateways/remote_quickpay_v6_test.rb | 4 ++--
.../gateways/remote_quickpay_v7_test.rb | 4 ++--
test/remote/gateways/remote_sage_pay_test.rb | 2 +-
test/unit/gateways/authorize_net_arb_test.rb | 2 +-
test/unit/gateways/blue_pay_test.rb | 2 +-
test/unit/gateways/kushki_test.rb | 24 +++++++++----------
test/unit/gateways/linkpoint_test.rb | 9 ++++---
test/unit/gateways/opp_test.rb | 8 +++----
test/unit/gateways/optimal_payment_test.rb | 10 ++++----
test/unit/gateways/paybox_direct_test.rb | 2 +-
test/unit/gateways/payflow_test.rb | 7 +++---
test/unit/gateways/sage_pay_test.rb | 2 +-
32 files changed, 120 insertions(+), 116 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index b5e9ff77717..8713b83ec64 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -42,11 +42,6 @@ Layout/CaseIndentation:
Layout/ClosingHeredocIndentation:
Enabled: false
-# Offense count: 35
-# Cop supports --auto-correct.
-Layout/ClosingParenthesisIndentation:
- Enabled: false
-
# Offense count: 20
# Cop supports --auto-correct.
Layout/CommentIndentation:
diff --git a/lib/active_merchant/billing/gateways/balanced.rb b/lib/active_merchant/billing/gateways/balanced.rb
index 50a3dfcd2c0..c755bedf209 100644
--- a/lib/active_merchant/billing/gateways/balanced.rb
+++ b/lib/active_merchant/billing/gateways/balanced.rb
@@ -236,12 +236,12 @@ def post_data(params)
def headers
@@ua ||= JSON.dump(
- bindings_version: ActiveMerchant::VERSION,
- lang: 'ruby',
- lang_version: "#{RUBY_VERSION} p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE})",
- lib_version: BalancedGateway::VERSION,
- platform: RUBY_PLATFORM,
- publisher: 'active_merchant'
+ bindings_version: ActiveMerchant::VERSION,
+ lang: 'ruby',
+ lang_version: "#{RUBY_VERSION} p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE})",
+ lib_version: BalancedGateway::VERSION,
+ platform: RUBY_PLATFORM,
+ publisher: 'active_merchant'
)
{
diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb
index 7f0dbcaacbf..25043306b51 100644
--- a/lib/active_merchant/billing/gateways/braintree_blue.rb
+++ b/lib/active_merchant/billing/gateways/braintree_blue.rb
@@ -347,10 +347,12 @@ def message_from_result(result)
end
def response_from_result(result)
- Response.new(result.success?, message_from_result(result),
+ Response.new(
+ result.success?,
+ message_from_result(result),
{ braintree_transaction: transaction_hash(result) },
{ authorization: (result.transaction.id if result.transaction) }
- )
+ )
end
def response_params(result)
diff --git a/lib/active_merchant/billing/gateways/card_stream.rb b/lib/active_merchant/billing/gateways/card_stream.rb
index dd929a56d2e..3659ef360a9 100644
--- a/lib/active_merchant/billing/gateways/card_stream.rb
+++ b/lib/active_merchant/billing/gateways/card_stream.rb
@@ -327,13 +327,14 @@ def commit(action, parameters)
response = parse(ssl_post(self.live_url, post_data(action, parameters)))
- Response.new(response[:responseCode] == '0',
- response[:responseCode] == '0' ? 'APPROVED' : response[:responseMessage],
- response,
- :test => test?,
- :authorization => response[:xref],
- :cvv_result => CVV_CODE[response[:avscv2ResponseCode].to_s[0, 1]],
- :avs_result => avs_from(response)
+ Response.new(
+ response[:responseCode] == '0',
+ response[:responseCode] == '0' ? 'APPROVED' : response[:responseMessage],
+ response,
+ :test => test?,
+ :authorization => response[:xref],
+ :cvv_result => CVV_CODE[response[:avscv2ResponseCode].to_s[0, 1]],
+ :avs_result => avs_from(response)
)
end
diff --git a/lib/active_merchant/billing/gateways/global_collect.rb b/lib/active_merchant/billing/gateways/global_collect.rb
index 7942dbcec76..66f4634841d 100644
--- a/lib/active_merchant/billing/gateways/global_collect.rb
+++ b/lib/active_merchant/billing/gateways/global_collect.rb
@@ -239,12 +239,12 @@ def commit(action, post, authorization = nil)
succeeded = success_from(response)
Response.new(
- succeeded,
- message_from(succeeded, response),
- response,
- authorization: authorization_from(succeeded, response),
- error_code: error_code_from(succeeded, response),
- test: test?
+ succeeded,
+ message_from(succeeded, response),
+ response,
+ authorization: authorization_from(succeeded, response),
+ error_code: error_code_from(succeeded, response),
+ test: test?
)
end
diff --git a/lib/active_merchant/billing/gateways/modern_payments_cim.rb b/lib/active_merchant/billing/gateways/modern_payments_cim.rb
index 688598fd8d9..7939387dd00 100644
--- a/lib/active_merchant/billing/gateways/modern_payments_cim.rb
+++ b/lib/active_merchant/billing/gateways/modern_payments_cim.rb
@@ -148,7 +148,7 @@ def commit(action, params)
data = ssl_post(url(action), build_request(action, params),
{ 'Content-Type' =>'text/xml; charset=utf-8',
'SOAPAction' => "#{xmlns(action)}#{action}" }
- )
+ )
response = parse(action, data)
Response.new(successful?(action, response), message_from(action, response), response,
diff --git a/lib/active_merchant/billing/gateways/paystation.rb b/lib/active_merchant/billing/gateways/paystation.rb
index da9ff63c15d..44d64dce8ae 100644
--- a/lib/active_merchant/billing/gateways/paystation.rb
+++ b/lib/active_merchant/billing/gateways/paystation.rb
@@ -179,8 +179,8 @@ def commit(post)
message = message_from(response)
PaystationResponse.new(success?(response), message, response,
- :test => (response[:tm] && response[:tm].downcase == 't'),
- :authorization => response[:paystation_transaction_id]
+ :test => (response[:tm] && response[:tm].downcase == 't'),
+ :authorization => response[:paystation_transaction_id]
)
end
diff --git a/lib/active_merchant/billing/gateways/quantum.rb b/lib/active_merchant/billing/gateways/quantum.rb
index 65e7b9e6dcb..280bdcd87c8 100644
--- a/lib/active_merchant/billing/gateways/quantum.rb
+++ b/lib/active_merchant/billing/gateways/quantum.rb
@@ -216,10 +216,10 @@ def commit(request, options)
end
Response.new(success, message, response,
- :test => test?,
- :authorization => authorization,
- :avs_result => { :code => response[:AVSResponseCode] },
- :cvv_result => response[:CVV2ResponseCode]
+ :test => test?,
+ :authorization => authorization,
+ :avs_result => { :code => response[:AVSResponseCode] },
+ :cvv_result => response[:CVV2ResponseCode]
)
end
diff --git a/lib/active_merchant/billing/gateways/sage.rb b/lib/active_merchant/billing/gateways/sage.rb
index f4a029284dc..7a83ede6731 100644
--- a/lib/active_merchant/billing/gateways/sage.rb
+++ b/lib/active_merchant/billing/gateways/sage.rb
@@ -364,9 +364,12 @@ def exp_date(credit_card)
end
def commit(action, request)
- response = parse(@gateway.ssl_post(@live_url,
- build_soap_request(action, request),
- build_headers(action))
+ response = parse(
+ @gateway.ssl_post(
+ @live_url,
+ build_soap_request(action, request),
+ build_headers(action)
+ )
)
case action
diff --git a/lib/active_merchant/billing/gateways/trexle.rb b/lib/active_merchant/billing/gateways/trexle.rb
index b4601860b27..2be948b4940 100644
--- a/lib/active_merchant/billing/gateways/trexle.rb
+++ b/lib/active_merchant/billing/gateways/trexle.rb
@@ -170,11 +170,11 @@ def success_response(body)
response = body['response']
Response.new(
- true,
- response['status_message'],
- body,
- authorization: token(response),
- test: test?
+ true,
+ response['status_message'],
+ body,
+ authorization: token(response),
+ test: test?
)
end
diff --git a/test/remote/gateways/remote_authorize_net_cim_test.rb b/test/remote/gateways/remote_authorize_net_cim_test.rb
index 8f7f000b54a..545a9f96942 100644
--- a/test/remote/gateways/remote_authorize_net_cim_test.rb
+++ b/test/remote/gateways/remote_authorize_net_cim_test.rb
@@ -850,17 +850,17 @@ def get_and_validate_auth_only_response
assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
@customer_payment_profile_id = response.params['profile']['payment_profiles']['customer_payment_profile_id']
assert response = @gateway.create_customer_profile_transaction(
- :transaction => {
- :customer_profile_id => @customer_profile_id,
- :customer_payment_profile_id => @customer_payment_profile_id,
- :type => :auth_only,
- :order => {
+ :transaction => {
+ :customer_profile_id => @customer_profile_id,
+ :customer_payment_profile_id => @customer_payment_profile_id,
+ :type => :auth_only,
+ :order => {
:invoice_number => key.to_s,
:description => "Test Order Description #{key.to_s}",
:purchase_order_number => key.to_s
},
- :amount => @amount
- }
+ :amount => @amount
+ }
)
assert response.test?
diff --git a/test/remote/gateways/remote_barclaycard_smartpay_test.rb b/test/remote/gateways/remote_barclaycard_smartpay_test.rb
index 104808183d1..01dc18c8609 100644
--- a/test/remote/gateways/remote_barclaycard_smartpay_test.rb
+++ b/test/remote/gateways/remote_barclaycard_smartpay_test.rb
@@ -261,9 +261,9 @@ def test_unsuccessful_verify
def test_invalid_login
gateway = BarclaycardSmartpayGateway.new(
- company: '',
- merchant: '',
- password: ''
+ company: '',
+ merchant: '',
+ password: ''
)
response = gateway.purchase(@amount, @credit_card, @options)
assert_failure response
diff --git a/test/remote/gateways/remote_braintree_blue_test.rb b/test/remote/gateways/remote_braintree_blue_test.rb
index 5f48f9ee313..16ef4891a3d 100644
--- a/test/remote/gateways/remote_braintree_blue_test.rb
+++ b/test/remote/gateways/remote_braintree_blue_test.rb
@@ -371,7 +371,7 @@ def test_successful_purchase_with_addresses
def test_successful_purchase_with_three_d_secure_pass_thru
three_d_secure_params = { eci: '05', cavv: 'cavv', xid: 'xid' }
assert response = @gateway.purchase(@amount, @credit_card,
- three_d_secure: three_d_secure_params
+ three_d_secure: three_d_secure_params
)
assert_success response
end
diff --git a/test/remote/gateways/remote_card_save_test.rb b/test/remote/gateways/remote_card_save_test.rb
index 5774414fc17..23af62ab582 100644
--- a/test/remote/gateways/remote_card_save_test.rb
+++ b/test/remote/gateways/remote_card_save_test.rb
@@ -49,8 +49,8 @@ def test_failed_capture
def test_invalid_login
gateway = CardSaveGateway.new(
- :login => '',
- :password => ''
+ :login => '',
+ :password => ''
)
assert response = gateway.purchase(@amount, @credit_card, @options)
assert_failure response
diff --git a/test/remote/gateways/remote_jetpay_v2_test.rb b/test/remote/gateways/remote_jetpay_v2_test.rb
index aa01fb19c6b..cffb44cafe6 100644
--- a/test/remote/gateways/remote_jetpay_v2_test.rb
+++ b/test/remote/gateways/remote_jetpay_v2_test.rb
@@ -49,7 +49,7 @@ def test_successful_purchase_with_additional_options
ud_field_1: 'Value1',
ud_field_2: 'Value2',
ud_field_3: 'Value3'
- )
+ )
assert response = @gateway.purchase(@amount_approved, @credit_card, options)
assert_success response
end
diff --git a/test/remote/gateways/remote_litle_test.rb b/test/remote/gateways/remote_litle_test.rb
index 966acfc125e..b4b2e1dccb2 100644
--- a/test/remote/gateways/remote_litle_test.rb
+++ b/test/remote/gateways/remote_litle_test.rb
@@ -199,17 +199,16 @@ def test_successful_purchase_with_echeck
def test_unsuccessful_purchase
assert response = @gateway.purchase(60060, @credit_card2, {
- :order_id=>'6',
- :billing_address=>{
- :name => 'Joe Green',
- :address1 => '6 Main St.',
- :city => 'Derry',
- :state => 'NH',
- :zip => '03038',
- :country => 'US'
- },
- }
- )
+ :order_id=>'6',
+ :billing_address=>{
+ :name => 'Joe Green',
+ :address1 => '6 Main St.',
+ :city => 'Derry',
+ :state => 'NH',
+ :zip => '03038',
+ :country => 'US'
+ },
+ })
assert_failure response
assert_equal 'Insufficient Funds', response.message
end
diff --git a/test/remote/gateways/remote_payflow_uk_test.rb b/test/remote/gateways/remote_payflow_uk_test.rb
index ae2eafd0caa..3cf7d5ede1d 100644
--- a/test/remote/gateways/remote_payflow_uk_test.rb
+++ b/test/remote/gateways/remote_payflow_uk_test.rb
@@ -28,14 +28,14 @@ def setup
)
@switch = CreditCard.new(
- :brand => 'switch',
- :number => '5641820000000005',
- :verification_value => '000',
- :month => 1,
- :year => 2008,
- :first_name => 'Fred',
- :last_name => 'Brooks'
- )
+ :brand => 'switch',
+ :number => '5641820000000005',
+ :verification_value => '000',
+ :month => 1,
+ :year => 2008,
+ :first_name => 'Fred',
+ :last_name => 'Brooks'
+ )
@options = {
:billing_address => {
diff --git a/test/remote/gateways/remote_quickpay_test.rb b/test/remote/gateways/remote_quickpay_test.rb
index c7c9c22cc1f..760c71f096e 100644
--- a/test/remote/gateways/remote_quickpay_test.rb
+++ b/test/remote/gateways/remote_quickpay_test.rb
@@ -188,8 +188,8 @@ def test_failed_store
def test_invalid_login
gateway = QuickpayGateway.new(
- :login => '',
- :password => ''
+ :login => '',
+ :password => ''
)
assert response = gateway.purchase(@amount, @visa, @options)
assert_equal 'Invalid merchant id', response.message
diff --git a/test/remote/gateways/remote_quickpay_v4_test.rb b/test/remote/gateways/remote_quickpay_v4_test.rb
index 06fab13d6e8..8e1035c8c61 100644
--- a/test/remote/gateways/remote_quickpay_v4_test.rb
+++ b/test/remote/gateways/remote_quickpay_v4_test.rb
@@ -199,8 +199,8 @@ def test_successful_store_and_reference_purchase
def test_invalid_login
gateway = QuickpayGateway.new(
- :login => '999999999',
- :password => ''
+ :login => '999999999',
+ :password => ''
)
assert response = gateway.purchase(@amount, @visa, @options)
assert_equal 'Invalid merchant id', response.message
diff --git a/test/remote/gateways/remote_quickpay_v5_test.rb b/test/remote/gateways/remote_quickpay_v5_test.rb
index 4d458e47a66..83ea83bb645 100644
--- a/test/remote/gateways/remote_quickpay_v5_test.rb
+++ b/test/remote/gateways/remote_quickpay_v5_test.rb
@@ -199,8 +199,8 @@ def test_successful_store_and_reference_purchase
def test_invalid_login
gateway = QuickpayGateway.new(
- :login => '999999999',
- :password => ''
+ :login => '999999999',
+ :password => ''
)
assert response = gateway.purchase(@amount, @visa, @options)
assert_equal 'Invalid merchant id', response.message
diff --git a/test/remote/gateways/remote_quickpay_v6_test.rb b/test/remote/gateways/remote_quickpay_v6_test.rb
index 7e4d31cde22..6566f5a0900 100644
--- a/test/remote/gateways/remote_quickpay_v6_test.rb
+++ b/test/remote/gateways/remote_quickpay_v6_test.rb
@@ -199,8 +199,8 @@ def test_successful_store_and_reference_purchase
def test_invalid_login
gateway = QuickpayGateway.new(
- :login => '999999999',
- :password => ''
+ :login => '999999999',
+ :password => ''
)
assert response = gateway.purchase(@amount, @visa, @options)
assert_equal 'Invalid merchant id', response.message
diff --git a/test/remote/gateways/remote_quickpay_v7_test.rb b/test/remote/gateways/remote_quickpay_v7_test.rb
index 9edfc2189b2..8b8def4f168 100644
--- a/test/remote/gateways/remote_quickpay_v7_test.rb
+++ b/test/remote/gateways/remote_quickpay_v7_test.rb
@@ -219,8 +219,8 @@ def test_successful_store_sans_description
def test_invalid_login
gateway = QuickpayGateway.new(
- :login => '999999999',
- :password => ''
+ :login => '999999999',
+ :password => ''
)
assert response = gateway.purchase(@amount, @visa, @options)
assert_equal 'Invalid merchant id', response.message
diff --git a/test/remote/gateways/remote_sage_pay_test.rb b/test/remote/gateways/remote_sage_pay_test.rb
index d4450ecda49..3abd17c88d5 100644
--- a/test/remote/gateways/remote_sage_pay_test.rb
+++ b/test/remote/gateways/remote_sage_pay_test.rb
@@ -331,7 +331,7 @@ def test_invalid_login
message = SagePayGateway.simulate ? 'VSP Simulator cannot find your vendor name. Ensure you have have supplied a Vendor field with your VSP Vendor name assigned to it.' : '3034 : The Vendor or VendorName value is required.'
gateway = SagePayGateway.new(
- :login => ''
+ :login => ''
)
assert response = gateway.purchase(@amount, @mastercard, @options)
assert_equal message, response.message
diff --git a/test/unit/gateways/authorize_net_arb_test.rb b/test/unit/gateways/authorize_net_arb_test.rb
index 1757c7c74b6..5c18ff468ff 100644
--- a/test/unit/gateways/authorize_net_arb_test.rb
+++ b/test/unit/gateways/authorize_net_arb_test.rb
@@ -28,7 +28,7 @@ def test_successful_recurring
:start_date => Time.now.strftime('%Y-%m-%d'),
:occurrences => 30
}
- )
+ )
assert_instance_of Response, response
assert response.success?
diff --git a/test/unit/gateways/blue_pay_test.rb b/test/unit/gateways/blue_pay_test.rb
index ce498445007..811b121450e 100644
--- a/test/unit/gateways/blue_pay_test.rb
+++ b/test/unit/gateways/blue_pay_test.rb
@@ -197,7 +197,7 @@ def test_successful_recurring
:rebill_expression => '14 DAYS',
:rebill_cycles => '24',
:rebill_amount => @amount * 4
- )
+ )
end
assert_instance_of Response, response
diff --git a/test/unit/gateways/kushki_test.rb b/test/unit/gateways/kushki_test.rb
index 4020f3cbf6f..861d82f8354 100644
--- a/test/unit/gateways/kushki_test.rb
+++ b/test/unit/gateways/kushki_test.rb
@@ -60,10 +60,10 @@ def test_taxes_are_excluded_when_not_provided
}
amount = 100 * (
- options[:amount][:subtotal_iva_0].to_f +
- options[:amount][:subtotal_iva].to_f +
- options[:amount][:iva].to_f +
- options[:amount][:ice].to_f
+ options[:amount][:subtotal_iva_0].to_f +
+ options[:amount][:subtotal_iva].to_f +
+ options[:amount][:iva].to_f +
+ options[:amount][:ice].to_f
)
response = stub_comms do
@@ -93,10 +93,10 @@ def test_partial_taxes_do_not_error
}
amount = 100 * (
- options[:amount][:subtotal_iva_0].to_f +
- options[:amount][:subtotal_iva].to_f +
- options[:amount][:iva].to_f +
- options[:amount][:ice].to_f
+ options[:amount][:subtotal_iva_0].to_f +
+ options[:amount][:subtotal_iva].to_f +
+ options[:amount][:iva].to_f +
+ options[:amount][:ice].to_f
)
response = stub_comms do
@@ -130,10 +130,10 @@ def test_taxes_are_included_when_provided
}
amount = 100 * (
- options[:amount][:subtotal_iva_0].to_f +
- options[:amount][:subtotal_iva].to_f +
- options[:amount][:iva].to_f +
- options[:amount][:ice].to_f
+ options[:amount][:subtotal_iva_0].to_f +
+ options[:amount][:subtotal_iva].to_f +
+ options[:amount][:iva].to_f +
+ options[:amount][:ice].to_f
)
response = stub_comms do
diff --git a/test/unit/gateways/linkpoint_test.rb b/test/unit/gateways/linkpoint_test.rb
index 71d5e683317..8de27a522f8 100644
--- a/test/unit/gateways/linkpoint_test.rb
+++ b/test/unit/gateways/linkpoint_test.rb
@@ -79,7 +79,8 @@ def test_amount_style
end
def test_purchase_is_valid_xml
- @gateway.send(:parameters, 1000, @credit_card, :ordertype => 'SALE', :order_id => 1004,
+ @gateway.send(
+ :parameters, 1000, @credit_card, :ordertype => 'SALE', :order_id => 1004,
:billing_address => {
:address1 => '1313 lucky lane',
:city => 'Lost Angeles',
@@ -93,7 +94,8 @@ def test_purchase_is_valid_xml
end
def test_recurring_is_valid_xml
- @gateway.send(:parameters, 1000, @credit_card, :ordertype => 'SALE', :action => 'SUBMIT', :installments => 12, :startdate => 'immediate', :periodicity => 'monthly', :order_id => 1006,
+ @gateway.send(
+ :parameters, 1000, @credit_card, :ordertype => 'SALE', :action => 'SUBMIT', :installments => 12, :startdate => 'immediate', :periodicity => 'monthly', :order_id => 1006,
:billing_address => {
:address1 => '1313 lucky lane',
:city => 'Lost Angeles',
@@ -125,7 +127,8 @@ def test_line_items_are_valid_xml
def test_declined_purchase_is_valid_xml
@gateway = LinkpointGateway.new(:login => 123123, :pem => 'PEM')
- @gateway.send(:parameters, 1000, @credit_card, :ordertype => 'SALE', :order_id => 1005,
+ @gateway.send(
+ :parameters, 1000, @credit_card, :ordertype => 'SALE', :order_id => 1005,
:billing_address => {
:address1 => '1313 lucky lane',
:city => 'Lost Angeles',
diff --git a/test/unit/gateways/opp_test.rb b/test/unit/gateways/opp_test.rb
index c955eb75d1e..e74552d7ade 100644
--- a/test/unit/gateways/opp_test.rb
+++ b/test/unit/gateways/opp_test.rb
@@ -188,10 +188,10 @@ def post_scrubbed
def successful_response(type, id)
OppMockResponse.new(200,
- JSON.generate({'id' => id,'paymentType' => type,'paymentBrand' => 'VISA','amount' => '1.00','currency' => 'EUR',"des
- criptor" => '5410.9959.0306 OPP_Channel ','result' => {'code' => '000.100.110','description' => "Request successfully processed in 'Merchant in Integrator Test Mode'"},'card' => {"bin
- " => '420000','last4Digits' => '0000','holder' => 'Longbob Longsen','expiryMonth' => '05','expiryYear' => '2018'},'buildNumber' => '20150618-111601.r185004.opp-tags-20150618_stage',"time
- stamp" => '2015-06-20 19:31:01+0000','ndc' => '8a8294174b7ecb28014b9699220015ca_4453edbc001f405da557c05cb3c3add9'})
+ JSON.generate({'id' => id,'paymentType' => type,'paymentBrand' => 'VISA','amount' => '1.00','currency' => 'EUR',"des
+ criptor" => '5410.9959.0306 OPP_Channel ','result' => {'code' => '000.100.110','description' => "Request successfully processed in 'Merchant in Integrator Test Mode'"},'card' => {"bin
+ " => '420000','last4Digits' => '0000','holder' => 'Longbob Longsen','expiryMonth' => '05','expiryYear' => '2018'},'buildNumber' => '20150618-111601.r185004.opp-tags-20150618_stage',"time
+ stamp" => '2015-06-20 19:31:01+0000','ndc' => '8a8294174b7ecb28014b9699220015ca_4453edbc001f405da557c05cb3c3add9'})
)
end
diff --git a/test/unit/gateways/optimal_payment_test.rb b/test/unit/gateways/optimal_payment_test.rb
index d2c255dfe61..f2c10a753a3 100644
--- a/test/unit/gateways/optimal_payment_test.rb
+++ b/test/unit/gateways/optimal_payment_test.rb
@@ -175,11 +175,11 @@ def test_in_production_with_test_param_sends_request_to_test_server
begin
ActiveMerchant::Billing::Base.mode = :production
@gateway = OptimalPaymentGateway.new(
- :account_number => '12345678',
- :store_id => 'login',
- :password => 'password',
- :test => true
- )
+ :account_number => '12345678',
+ :store_id => 'login',
+ :password => 'password',
+ :test => true
+ )
@gateway.expects(:ssl_post).with('https://webservices.test.optimalpayments.com/creditcardWS/CreditCardServlet/v1', anything).returns(successful_purchase_response)
assert response = @gateway.purchase(@amount, @credit_card, @options)
diff --git a/test/unit/gateways/paybox_direct_test.rb b/test/unit/gateways/paybox_direct_test.rb
index 23ec8124b59..89f5f7d435b 100644
--- a/test/unit/gateways/paybox_direct_test.rb
+++ b/test/unit/gateways/paybox_direct_test.rb
@@ -10,7 +10,7 @@ def setup
)
@credit_card = credit_card('1111222233334444',
- :brand => 'visa'
+ :brand => 'visa'
)
@amount = 100
diff --git a/test/unit/gateways/payflow_test.rb b/test/unit/gateways/payflow_test.rb
index b85956a69b5..2c7c86c9095 100644
--- a/test/unit/gateways/payflow_test.rb
+++ b/test/unit/gateways/payflow_test.rb
@@ -379,9 +379,10 @@ def test_format_issue_number
def test_add_credit_card_with_three_d_secure
xml = Builder::XmlMarkup.new
- credit_card = credit_card('5641820000000005',
- :brand => 'switch',
- :issue_number => 1
+ credit_card = credit_card(
+ '5641820000000005',
+ :brand => 'switch',
+ :issue_number => 1
)
@gateway.send(:add_credit_card, xml, credit_card, @options.merge(three_d_secure_option))
diff --git a/test/unit/gateways/sage_pay_test.rb b/test/unit/gateways/sage_pay_test.rb
index 256af606eff..aae37768a48 100644
--- a/test/unit/gateways/sage_pay_test.rb
+++ b/test/unit/gateways/sage_pay_test.rb
@@ -319,7 +319,7 @@ def test_successful_authorization_and_capture_and_refund
@gateway.refund(@amount, capture.authorization,
order_id: generate_unique_id,
description: 'Refund txn'
- )
+ )
end.respond_with(successful_refund_response)
assert_success refund
end
From e46fbafbce4eb1e26faee2457d8ae4c095bf700a Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 30 Aug 2018 16:40:56 -0400
Subject: [PATCH 0060/2234] Rubocop: fix Layout/DefEndAlignment
---
.rubocop_todo.yml | 11 -----------
test/remote/gateways/remote_moneris_test.rb | 2 +-
test/remote/gateways/remote_pay_conex_test.rb | 2 +-
test/remote/gateways/remote_payflow_uk_test.rb | 2 +-
4 files changed, 3 insertions(+), 14 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 8713b83ec64..12207a15850 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -57,17 +57,6 @@ Layout/CommentIndentation:
- 'test/unit/gateways/eway_managed_test.rb'
- 'test/unit/gateways/opp_test.rb'
-# Offense count: 4
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyleAlignWith, AutoCorrect, Severity.
-# SupportedStylesAlignWith: start_of_line, def
-Layout/DefEndAlignment:
- Exclude:
- - 'test/remote/gateways/remote_moneris_test.rb'
- - 'test/remote/gateways/remote_pay_conex_test.rb'
- - 'test/remote/gateways/remote_payflow_uk_test.rb'
- - 'test/unit/gateways/optimal_payment_test.rb'
-
# Offense count: 513
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
diff --git a/test/remote/gateways/remote_moneris_test.rb b/test/remote/gateways/remote_moneris_test.rb
index 6cd0cd8e993..060ad177255 100644
--- a/test/remote/gateways/remote_moneris_test.rb
+++ b/test/remote/gateways/remote_moneris_test.rb
@@ -233,7 +233,7 @@ def test_avs_result_nil_when_efraud_disabled
})
end
- def test_purchase_scrubbing
+ def test_purchase_scrubbing
transcript = capture_transcript(@gateway) do
@gateway.purchase(@amount, @credit_card, @options)
end
diff --git a/test/remote/gateways/remote_pay_conex_test.rb b/test/remote/gateways/remote_pay_conex_test.rb
index 0299a43c0f0..22ed010bcbd 100644
--- a/test/remote/gateways/remote_pay_conex_test.rb
+++ b/test/remote/gateways/remote_pay_conex_test.rb
@@ -27,7 +27,7 @@ def test_transcript_scrubbing
assert_scrubbed(@credit_card.number, transcript)
assert_scrubbed(@credit_card.verification_value, transcript)
assert_scrubbed(@gateway.options[:api_accesskey], transcript)
- end
+ end
def test_successful_purchase
response = @gateway.purchase(@amount, @credit_card, @options)
diff --git a/test/remote/gateways/remote_payflow_uk_test.rb b/test/remote/gateways/remote_payflow_uk_test.rb
index 3cf7d5ede1d..5db52700d1b 100644
--- a/test/remote/gateways/remote_payflow_uk_test.rb
+++ b/test/remote/gateways/remote_payflow_uk_test.rb
@@ -72,7 +72,7 @@ def test_successful_purchase_solo
assert_success response
assert response.test?
assert_not_nil response.authorization
- end
+ end
def test_no_card_issue_or_card_start_with_switch
assert response = @gateway.purchase(100000, @switch, @options)
From af23389934f424f8404ede0781301c75a38175d5 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 30 Aug 2018 16:49:47 -0400
Subject: [PATCH 0061/2234] Rubocop: fix several empty line issues
In particular, this fixes:
Layout/EmptyLineAfterMagicComment
Layout/EmptyLinesAroundArguments
Layout/EmptyLinesAroundBlockBody
Layout/EmptyLinesAroundExceptionHandlingKeywords
Layout/EmptyLinesAroundModuleBody
---
.rubocop_todo.yml | 76 -------------------
.../billing/credit_card_formatting.rb | 1 -
.../billing/gateways/barclaycard_smartpay.rb | 1 -
.../gateways/beanstream/beanstream_core.rb | 1 -
lib/active_merchant/billing/gateways/cc5.rb | 1 -
.../billing/gateways/cecabank.rb | 1 -
.../billing/gateways/data_cash.rb | 1 -
.../billing/gateways/efsnet.rb | 3 -
lib/active_merchant/billing/gateways/exact.rb | 1 -
lib/active_merchant/billing/gateways/ezic.rb | 1 -
.../billing/gateways/linkpoint.rb | 1 -
.../billing/gateways/mastercard.rb | 2 -
.../billing/gateways/moneris.rb | 1 -
.../billing/gateways/moneris_us.rb | 1 -
lib/active_merchant/billing/gateways/ogone.rb | 1 +
.../billing/gateways/pay_conex.rb | 1 -
.../billing/gateways/payflow_express.rb | 1 -
.../billing/gateways/payment_express.rb | 1 -
lib/active_merchant/billing/gateways/pin.rb | 1 -
.../gateways/quickpay/quickpay_common.rb | 2 -
.../billing/gateways/quickpay/quickpay_v10.rb | 2 -
.../billing/gateways/redsys.rb | 1 +
.../billing/gateways/sage_pay.rb | 1 -
lib/active_merchant/billing/gateways/telr.rb | 1 -
.../billing/gateways/trans_first.rb | 1 -
.../billing/gateways/usa_epay_transaction.rb | 1 -
lib/active_merchant/billing/gateways/wepay.rb | 1 -
.../billing/gateways/worldpay.rb | 1 -
.../gateways/worldpay_online_payments.rb | 1 -
lib/active_merchant/connection.rb | 1 -
lib/active_merchant/posts_data.rb | 2 -
test/remote/gateways/remote_banwire_test.rb | 1 +
.../remote_barclays_epdq_extra_plus_test.rb | 1 +
.../remote/gateways/remote_finansbank_test.rb | 1 +
test/remote/gateways/remote_ogone_test.rb | 1 +
.../remote/gateways/remote_paystation_test.rb | 8 +-
test/remote/gateways/remote_realex_test.rb | 6 --
test/remote/gateways/remote_webpay_test.rb | 1 +
test/remote/gateways/remote_wirecard_test.rb | 1 +
test/unit/gateways/cardknox_test.rb | 2 -
test/unit/gateways/finansbank_test.rb | 1 +
test/unit/gateways/usa_epay_advanced_test.rb | 1 +
.../gateways/usa_epay_transaction_test.rb | 2 -
test/unit/gateways/wirecard_test.rb | 1 +
test/unit/gateways/worldpay_test.rb | 1 -
45 files changed, 14 insertions(+), 126 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 12207a15850..5ddf8499436 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -82,22 +82,6 @@ Layout/ElseAlignment:
- 'lib/active_merchant/billing/gateways/trust_commerce.rb'
- 'lib/active_merchant/billing/response.rb'
-# Offense count: 11
-# Cop supports --auto-correct.
-Layout/EmptyLineAfterMagicComment:
- Exclude:
- - 'lib/active_merchant/billing/gateways/ogone.rb'
- - 'lib/active_merchant/billing/gateways/redsys.rb'
- - 'test/remote/gateways/remote_banwire_test.rb'
- - 'test/remote/gateways/remote_barclays_epdq_extra_plus_test.rb'
- - 'test/remote/gateways/remote_finansbank_test.rb'
- - 'test/remote/gateways/remote_ogone_test.rb'
- - 'test/remote/gateways/remote_webpay_test.rb'
- - 'test/remote/gateways/remote_wirecard_test.rb'
- - 'test/unit/gateways/finansbank_test.rb'
- - 'test/unit/gateways/usa_epay_advanced_test.rb'
- - 'test/unit/gateways/wirecard_test.rb'
-
# Offense count: 66
# Cop supports --auto-correct.
# Configuration parameters: AllowAdjacentOneLineDefs, NumberOfEmptyLines.
@@ -114,29 +98,6 @@ Layout/EmptyLines:
Layout/EmptyLinesAroundAccessModifier:
Enabled: false
-# Offense count: 2
-# Cop supports --auto-correct.
-Layout/EmptyLinesAroundArguments:
- Exclude:
- - 'test/unit/gateways/cardknox_test.rb'
- - 'test/unit/gateways/usa_epay_transaction_test.rb'
-
-# Offense count: 15
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle.
-# SupportedStyles: empty_lines, no_empty_lines
-Layout/EmptyLinesAroundBlockBody:
- Exclude:
- - 'lib/active_merchant/billing/gateways/cc5.rb'
- - 'lib/active_merchant/billing/gateways/data_cash.rb'
- - 'lib/active_merchant/billing/gateways/efsnet.rb'
- - 'lib/active_merchant/billing/gateways/payflow_express.rb'
- - 'lib/active_merchant/billing/gateways/telr.rb'
- - 'test/remote/gateways/remote_paystation_test.rb'
- - 'test/remote/gateways/remote_realex_test.rb'
- - 'test/unit/gateways/cardknox_test.rb'
- - 'test/unit/gateways/usa_epay_transaction_test.rb'
-
# Offense count: 165
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
@@ -144,48 +105,11 @@ Layout/EmptyLinesAroundBlockBody:
Layout/EmptyLinesAroundClassBody:
Enabled: false
-# Offense count: 10
-# Cop supports --auto-correct.
-Layout/EmptyLinesAroundExceptionHandlingKeywords:
- Exclude:
- - 'lib/active_merchant/billing/gateways/barclaycard_smartpay.rb'
- - 'lib/active_merchant/billing/gateways/cecabank.rb'
- - 'lib/active_merchant/billing/gateways/exact.rb'
- - 'lib/active_merchant/billing/gateways/pay_conex.rb'
- - 'lib/active_merchant/billing/gateways/pin.rb'
- - 'lib/active_merchant/billing/gateways/wepay.rb'
- - 'lib/active_merchant/billing/gateways/worldpay.rb'
- - 'lib/active_merchant/billing/gateways/worldpay_online_payments.rb'
- - 'lib/active_merchant/connection.rb'
- - 'test/unit/gateways/worldpay_test.rb'
-
# Offense count: 64
# Cop supports --auto-correct.
Layout/EmptyLinesAroundMethodBody:
Enabled: false
-# Offense count: 18
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle.
-# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines
-Layout/EmptyLinesAroundModuleBody:
- Exclude:
- - 'lib/active_merchant/billing/credit_card_formatting.rb'
- - 'lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb'
- - 'lib/active_merchant/billing/gateways/efsnet.rb'
- - 'lib/active_merchant/billing/gateways/ezic.rb'
- - 'lib/active_merchant/billing/gateways/linkpoint.rb'
- - 'lib/active_merchant/billing/gateways/mastercard.rb'
- - 'lib/active_merchant/billing/gateways/moneris.rb'
- - 'lib/active_merchant/billing/gateways/moneris_us.rb'
- - 'lib/active_merchant/billing/gateways/payment_express.rb'
- - 'lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb'
- - 'lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb'
- - 'lib/active_merchant/billing/gateways/sage_pay.rb'
- - 'lib/active_merchant/billing/gateways/trans_first.rb'
- - 'lib/active_merchant/billing/gateways/usa_epay_transaction.rb'
- - 'lib/active_merchant/posts_data.rb'
-
# Offense count: 40
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleAlignWith, AutoCorrect, Severity.
diff --git a/lib/active_merchant/billing/credit_card_formatting.rb b/lib/active_merchant/billing/credit_card_formatting.rb
index 65078d04e6f..74837bebac0 100644
--- a/lib/active_merchant/billing/credit_card_formatting.rb
+++ b/lib/active_merchant/billing/credit_card_formatting.rb
@@ -1,7 +1,6 @@
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
module CreditCardFormatting
-
def expdate(credit_card)
"#{format(credit_card.month, :two_digits)}#{format(credit_card.year, :two_digits)}"
end
diff --git a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb
index 33e4945a434..5a639ecd2b6 100644
--- a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb
+++ b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb
@@ -141,7 +141,6 @@ def commit(action, post)
avs_result: AVSResult.new(:code => parse_avs_code(response)),
authorization: response['recurringDetailReference'] || authorization_from(post, response)
)
-
rescue ResponseError => e
case e.response.code
when '401'
diff --git a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb
index 3a8a36fc8de..2800effb333 100644
--- a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb
+++ b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb
@@ -467,7 +467,6 @@ def post_data(params, use_profile_api)
params.reject{|k, v| v.blank?}.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
end
-
end
end
end
diff --git a/lib/active_merchant/billing/gateways/cc5.rb b/lib/active_merchant/billing/gateways/cc5.rb
index 869296dcfb9..e9c5dac6e00 100644
--- a/lib/active_merchant/billing/gateways/cc5.rb
+++ b/lib/active_merchant/billing/gateways/cc5.rb
@@ -70,7 +70,6 @@ def build_sale_request(type, money, creditcard, options = {})
add_address(xml, address)
end
end
-
end
xml.target!
diff --git a/lib/active_merchant/billing/gateways/cecabank.rb b/lib/active_merchant/billing/gateways/cecabank.rb
index 8bb644aa847..ea93d83e973 100644
--- a/lib/active_merchant/billing/gateways/cecabank.rb
+++ b/lib/active_merchant/billing/gateways/cecabank.rb
@@ -152,7 +152,6 @@ def parse(body)
end
return response
-
rescue REXML::ParseException => e
response[:success] = false
response[:message] = 'Unable to parse the response.'
diff --git a/lib/active_merchant/billing/gateways/data_cash.rb b/lib/active_merchant/billing/gateways/data_cash.rb
index 5c94454e2ad..5c628a1343a 100644
--- a/lib/active_merchant/billing/gateways/data_cash.rb
+++ b/lib/active_merchant/billing/gateways/data_cash.rb
@@ -216,7 +216,6 @@ def add_authentication(xml)
def add_credit_card(xml, credit_card, address)
xml.tag! :Card do
-
# DataCash calls the CC number 'pan'
xml.tag! :pan, credit_card.number
xml.tag! :expirydate, format_date(credit_card.month, credit_card.year)
diff --git a/lib/active_merchant/billing/gateways/efsnet.rb b/lib/active_merchant/billing/gateways/efsnet.rb
index da3d95ae0be..e9785556819 100644
--- a/lib/active_merchant/billing/gateways/efsnet.rb
+++ b/lib/active_merchant/billing/gateways/efsnet.rb
@@ -2,7 +2,6 @@
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
-
class EfsnetGateway < Gateway
self.supported_countries = ['US']
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
@@ -169,9 +168,7 @@ def parse(xml)
xml = REXML::Document.new(xml)
xml.elements.each('//Reply//TransactionReply/*') do |node|
-
response[node.name.underscore.to_sym] = normalize(node.text)
-
end unless xml.root.nil?
response
diff --git a/lib/active_merchant/billing/gateways/exact.rb b/lib/active_merchant/billing/gateways/exact.rb
index f72ba4247af..a5d073a76ab 100644
--- a/lib/active_merchant/billing/gateways/exact.rb
+++ b/lib/active_merchant/billing/gateways/exact.rb
@@ -169,7 +169,6 @@ def commit(action, request)
:avs_result => { :code => response[:avs] },
:cvv_result => response[:cvv2]
)
-
rescue ResponseError => e
case e.response.code
when '401'
diff --git a/lib/active_merchant/billing/gateways/ezic.rb b/lib/active_merchant/billing/gateways/ezic.rb
index 15f81847ef4..3bfe469c857 100644
--- a/lib/active_merchant/billing/gateways/ezic.rb
+++ b/lib/active_merchant/billing/gateways/ezic.rb
@@ -191,6 +191,5 @@ def headers
}
end
end
-
end
end
diff --git a/lib/active_merchant/billing/gateways/linkpoint.rb b/lib/active_merchant/billing/gateways/linkpoint.rb
index 9c63d503254..5b0553c3dfd 100644
--- a/lib/active_merchant/billing/gateways/linkpoint.rb
+++ b/lib/active_merchant/billing/gateways/linkpoint.rb
@@ -2,7 +2,6 @@
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
-
# Initialization Options
# :login Your store number
# :pem The text of your linkpoint PEM file. Note
diff --git a/lib/active_merchant/billing/gateways/mastercard.rb b/lib/active_merchant/billing/gateways/mastercard.rb
index d15bb6cbfc6..10fb51ba589 100644
--- a/lib/active_merchant/billing/gateways/mastercard.rb
+++ b/lib/active_merchant/billing/gateways/mastercard.rb
@@ -1,7 +1,6 @@
module ActiveMerchant
module Billing
module MastercardGateway
-
def initialize(options={})
requires!(options, :userid, :password)
super
@@ -262,7 +261,6 @@ def next_authorization(authorization)
next_transactionid = SecureRandom.uuid
[orderid, next_transactionid, prev_transactionid]
end
-
end
end
end
diff --git a/lib/active_merchant/billing/gateways/moneris.rb b/lib/active_merchant/billing/gateways/moneris.rb
index 5ce35929532..2a632811ed5 100644
--- a/lib/active_merchant/billing/gateways/moneris.rb
+++ b/lib/active_merchant/billing/gateways/moneris.rb
@@ -2,7 +2,6 @@
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
-
# To learn more about the Moneris gateway, please contact
# eselectplus@moneris.com for a copy of their integration guide. For
# information on remote testing, please see "Test Environment Penny Value
diff --git a/lib/active_merchant/billing/gateways/moneris_us.rb b/lib/active_merchant/billing/gateways/moneris_us.rb
index e9e5ed3d476..35696ea43b5 100644
--- a/lib/active_merchant/billing/gateways/moneris_us.rb
+++ b/lib/active_merchant/billing/gateways/moneris_us.rb
@@ -2,7 +2,6 @@
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
-
# To learn more about the Moneris (US) gateway, please contact
# ussales@moneris.com for a copy of their integration guide. For
# information on remote testing, please see "Test Environment Penny Value
diff --git a/lib/active_merchant/billing/gateways/ogone.rb b/lib/active_merchant/billing/gateways/ogone.rb
index ef81e22b14e..882dacf5f12 100644
--- a/lib/active_merchant/billing/gateways/ogone.rb
+++ b/lib/active_merchant/billing/gateways/ogone.rb
@@ -1,4 +1,5 @@
# coding: utf-8
+
require 'rexml/document'
module ActiveMerchant #:nodoc:
diff --git a/lib/active_merchant/billing/gateways/pay_conex.rb b/lib/active_merchant/billing/gateways/pay_conex.rb
index bb97a65cde7..0095bcfc29b 100644
--- a/lib/active_merchant/billing/gateways/pay_conex.rb
+++ b/lib/active_merchant/billing/gateways/pay_conex.rb
@@ -213,7 +213,6 @@ def commit(action, params)
:cvv_result => CVVResult.new(response['cvv2_response']),
test: test?
)
-
rescue JSON::ParserError
unparsable_response(raw_response)
end
diff --git a/lib/active_merchant/billing/gateways/payflow_express.rb b/lib/active_merchant/billing/gateways/payflow_express.rb
index a8fee1d6476..4a967812181 100644
--- a/lib/active_merchant/billing/gateways/payflow_express.rb
+++ b/lib/active_merchant/billing/gateways/payflow_express.rb
@@ -180,7 +180,6 @@ def add_pay_data(xml, money, options)
end
xml.tag! 'DiscountAmt', amount(options[:discount]) if options[:discount]
xml.tag! 'TotalAmt', amount(money), 'Currency' => options[:currency] || currency(money)
-
end
xml.tag! 'Tender' do
diff --git a/lib/active_merchant/billing/gateways/payment_express.rb b/lib/active_merchant/billing/gateways/payment_express.rb
index 688a49a3001..3495c029fca 100644
--- a/lib/active_merchant/billing/gateways/payment_express.rb
+++ b/lib/active_merchant/billing/gateways/payment_express.rb
@@ -2,7 +2,6 @@
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
-
# In NZ DPS supports ANZ, Westpac, National Bank, ASB and BNZ.
# In Australia DPS supports ANZ, NAB, Westpac, CBA, St George and Bank of South Australia.
# The Maybank in Malaysia is supported and the Citibank for Singapore.
diff --git a/lib/active_merchant/billing/gateways/pin.rb b/lib/active_merchant/billing/gateways/pin.rb
index 3d8af8a56b1..a7e11dd16bb 100644
--- a/lib/active_merchant/billing/gateways/pin.rb
+++ b/lib/active_merchant/billing/gateways/pin.rb
@@ -173,7 +173,6 @@ def commit(method, action, params, options)
elsif body['error']
error_response(body)
end
-
rescue JSON::ParserError
return unparsable_response(raw_response)
end
diff --git a/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb b/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb
index b1b2c5e0099..50d0fb44932 100644
--- a/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb
+++ b/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb
@@ -1,6 +1,5 @@
module QuickpayCommon
-
MD5_CHECK_FIELDS = {
3 => {
:authorize => %w(protocol msgtype merchant ordernumber amount
@@ -184,5 +183,4 @@ def expdate(credit_card)
"#{year}#{month}"
end
-
end
diff --git a/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb b/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb
index f321a7c33b8..ce4fec9a480 100644
--- a/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb
+++ b/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb
@@ -292,8 +292,6 @@ def json_error(raw_response)
def synchronized_path(path)
"#{path}?synchronized"
end
-
end
-
end
end
diff --git a/lib/active_merchant/billing/gateways/redsys.rb b/lib/active_merchant/billing/gateways/redsys.rb
index 2fb8ecfcd02..8fbe07af636 100644
--- a/lib/active_merchant/billing/gateways/redsys.rb
+++ b/lib/active_merchant/billing/gateways/redsys.rb
@@ -1,4 +1,5 @@
# coding: utf-8
+
require 'nokogiri'
module ActiveMerchant #:nodoc:
diff --git a/lib/active_merchant/billing/gateways/sage_pay.rb b/lib/active_merchant/billing/gateways/sage_pay.rb
index 97282fc835f..b78c2d6f6b6 100644
--- a/lib/active_merchant/billing/gateways/sage_pay.rb
+++ b/lib/active_merchant/billing/gateways/sage_pay.rb
@@ -436,6 +436,5 @@ def past_purchase_reference?(payment_method)
payment_method.split(';').last == 'purchase'
end
end
-
end
end
diff --git a/lib/active_merchant/billing/gateways/telr.rb b/lib/active_merchant/billing/gateways/telr.rb
index 9d8085fb175..7a31114f364 100644
--- a/lib/active_merchant/billing/gateways/telr.rb
+++ b/lib/active_merchant/billing/gateways/telr.rb
@@ -190,7 +190,6 @@ def root_attributes
def build_xml_request
builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
xml.remote do |doc|
-
add_authentication(doc)
yield(doc)
end
diff --git a/lib/active_merchant/billing/gateways/trans_first.rb b/lib/active_merchant/billing/gateways/trans_first.rb
index 337a4f03d9b..8b2c579683f 100644
--- a/lib/active_merchant/billing/gateways/trans_first.rb
+++ b/lib/active_merchant/billing/gateways/trans_first.rb
@@ -1,5 +1,4 @@
module ActiveMerchant #:nodoc:
-
module Billing #:nodoc:
class TransFirstGateway < Gateway
self.test_url = 'https://ws.cert.transfirst.com'
diff --git a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb
index b2f4a7fb590..83ac01b3cc9 100644
--- a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb
+++ b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb
@@ -1,6 +1,5 @@
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
-
class UsaEpayTransactionGateway < Gateway
self.live_url = 'https://www.usaepay.com/gate'
self.test_url = 'https://sandbox.usaepay.com/gate'
diff --git a/lib/active_merchant/billing/gateways/wepay.rb b/lib/active_merchant/billing/gateways/wepay.rb
index 4ae60420421..9ec05da7f7f 100644
--- a/lib/active_merchant/billing/gateways/wepay.rb
+++ b/lib/active_merchant/billing/gateways/wepay.rb
@@ -190,7 +190,6 @@ def commit(action, params, options={})
authorization: authorization_from(response, params),
test: test?
)
-
rescue JSON::ParserError
return unparsable_response(response)
end
diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb
index 4ef6f38eb1a..10ea603a8ff 100644
--- a/lib/active_merchant/billing/gateways/worldpay.rb
+++ b/lib/active_merchant/billing/gateways/worldpay.rb
@@ -362,7 +362,6 @@ def commit(action, request, *success_criteria, options)
:authorization => authorization_from(raw),
:error_code => error_code_from(success, raw),
:test => test?)
-
rescue ActiveMerchant::ResponseError => e
if e.response.code.to_s == '401'
return Response.new(false, 'Invalid credentials', {}, :test => test?)
diff --git a/lib/active_merchant/billing/gateways/worldpay_online_payments.rb b/lib/active_merchant/billing/gateways/worldpay_online_payments.rb
index 4d4490efb9e..a4a61f1483b 100644
--- a/lib/active_merchant/billing/gateways/worldpay_online_payments.rb
+++ b/lib/active_merchant/billing/gateways/worldpay_online_payments.rb
@@ -160,7 +160,6 @@ def commit(method, url, parameters=nil, options = {}, type = false)
success = true
response = {}
end
-
rescue ResponseError => e
raw_response = e.response.body
response = response_error(raw_response)
diff --git a/lib/active_merchant/connection.rb b/lib/active_merchant/connection.rb
index 5df801ca301..489130ee1b9 100644
--- a/lib/active_merchant/connection.rb
+++ b/lib/active_merchant/connection.rb
@@ -117,7 +117,6 @@ def request(method, body, headers = {})
result
end
end
-
ensure
info 'connection_request_total_time=%.4fs' % [Process.clock_gettime(Process::CLOCK_MONOTONIC) - request_start], tag
http.finish if http.started?
diff --git a/lib/active_merchant/posts_data.rb b/lib/active_merchant/posts_data.rb
index 9930f2635e4..857efa9b162 100644
--- a/lib/active_merchant/posts_data.rb
+++ b/lib/active_merchant/posts_data.rb
@@ -1,6 +1,5 @@
module ActiveMerchant #:nodoc:
module PostsData #:nodoc:
-
def self.included(base)
base.class_attribute :ssl_strict
base.ssl_strict = true
@@ -89,6 +88,5 @@ def handle_response(response)
raise ResponseError.new(response)
end
end
-
end
end
diff --git a/test/remote/gateways/remote_banwire_test.rb b/test/remote/gateways/remote_banwire_test.rb
index 2f908d3ea9f..0bac529ec67 100644
--- a/test/remote/gateways/remote_banwire_test.rb
+++ b/test/remote/gateways/remote_banwire_test.rb
@@ -1,4 +1,5 @@
# encoding: utf-8
+
require 'test_helper'
class RemoteBanwireTest < Test::Unit::TestCase
diff --git a/test/remote/gateways/remote_barclays_epdq_extra_plus_test.rb b/test/remote/gateways/remote_barclays_epdq_extra_plus_test.rb
index 5996436a96a..dd06e16d724 100644
--- a/test/remote/gateways/remote_barclays_epdq_extra_plus_test.rb
+++ b/test/remote/gateways/remote_barclays_epdq_extra_plus_test.rb
@@ -1,4 +1,5 @@
# coding: utf-8
+
require 'test_helper'
class RemoteBarclaysEpdqExtraPlusTest < Test::Unit::TestCase
diff --git a/test/remote/gateways/remote_finansbank_test.rb b/test/remote/gateways/remote_finansbank_test.rb
index a59bac99a27..753df513fe9 100644
--- a/test/remote/gateways/remote_finansbank_test.rb
+++ b/test/remote/gateways/remote_finansbank_test.rb
@@ -1,4 +1,5 @@
# encoding: utf-8
+
require 'test_helper'
class RemoteFinansbankTest < Test::Unit::TestCase
diff --git a/test/remote/gateways/remote_ogone_test.rb b/test/remote/gateways/remote_ogone_test.rb
index 6f62cd8f0ce..3d2b878db33 100644
--- a/test/remote/gateways/remote_ogone_test.rb
+++ b/test/remote/gateways/remote_ogone_test.rb
@@ -1,4 +1,5 @@
# coding: utf-8
+
require 'test_helper'
class RemoteOgoneTest < Test::Unit::TestCase
diff --git a/test/remote/gateways/remote_paystation_test.rb b/test/remote/gateways/remote_paystation_test.rb
index 0225ee25e4c..84285905003 100644
--- a/test/remote/gateways/remote_paystation_test.rb
+++ b/test/remote/gateways/remote_paystation_test.rb
@@ -40,11 +40,9 @@ def test_failed_purchases
['expired_card', @expired_card_amount, 'Expired Card'],
['bank_error', @bank_error_amount, 'Error Communicating with Bank']
].each do |name, amount, message|
-
- assert response = @gateway.purchase(amount, @credit_card, @options)
- assert_failure response
- assert_equal message, response.message
-
+ assert response = @gateway.purchase(amount, @credit_card, @options)
+ assert_failure response
+ assert_equal message, response.message
end
end
diff --git a/test/remote/gateways/remote_realex_test.rb b/test/remote/gateways/remote_realex_test.rb
index 0e9c466fbc3..5549f5715df 100644
--- a/test/remote/gateways/remote_realex_test.rb
+++ b/test/remote/gateways/remote_realex_test.rb
@@ -40,7 +40,6 @@ def card_fixtures(name)
def test_realex_purchase
[ @visa, @mastercard ].each do |card|
-
response = @gateway.purchase(@amount, card,
:order_id => generate_unique_id,
:description => 'Test Realex Purchase',
@@ -96,7 +95,6 @@ def test_realex_purchase_with_apple_pay
def test_realex_purchase_declined
[ @visa_declined, @mastercard_declined ].each do |card|
-
response = @gateway.purchase(@amount, card,
:order_id => generate_unique_id,
:description => 'Test Realex purchase declined'
@@ -120,7 +118,6 @@ def test_realex_purchase_with_apple_pay_declined
def test_realex_purchase_referral_b
[ @visa_referral_b, @mastercard_referral_b ].each do |card|
-
response = @gateway.purchase(@amount, card,
:order_id => generate_unique_id,
:description => 'Test Realex Referral B'
@@ -135,7 +132,6 @@ def test_realex_purchase_referral_b
def test_realex_purchase_referral_a
[ @visa_referral_a, @mastercard_referral_a ].each do |card|
-
response = @gateway.purchase(@amount, card,
:order_id => generate_unique_id,
:description => 'Test Realex Rqeferral A'
@@ -150,7 +146,6 @@ def test_realex_purchase_referral_a
def test_realex_purchase_coms_error
[ @visa_coms_error, @mastercard_coms_error ].each do |card|
-
response = @gateway.purchase(@amount, card,
:order_id => generate_unique_id,
:description => 'Test Realex coms error'
@@ -338,7 +333,6 @@ def test_realex_purchase_then_refund
def test_maps_avs_and_cvv_response_codes
[ @visa, @mastercard ].each do |card|
-
response = @gateway.purchase(@amount, card,
:order_id => generate_unique_id,
:description => 'Test Realex Purchase',
diff --git a/test/remote/gateways/remote_webpay_test.rb b/test/remote/gateways/remote_webpay_test.rb
index 26e084f49e0..3b0e099ea33 100644
--- a/test/remote/gateways/remote_webpay_test.rb
+++ b/test/remote/gateways/remote_webpay_test.rb
@@ -1,4 +1,5 @@
# coding: utf-8
+
require 'test_helper'
class RemoteWebpayTest < Test::Unit::TestCase
diff --git a/test/remote/gateways/remote_wirecard_test.rb b/test/remote/gateways/remote_wirecard_test.rb
index f47eff22762..15783d552d5 100644
--- a/test/remote/gateways/remote_wirecard_test.rb
+++ b/test/remote/gateways/remote_wirecard_test.rb
@@ -1,4 +1,5 @@
# encoding: UTF-8
+
require 'test_helper'
class RemoteWirecardTest < Test::Unit::TestCase
diff --git a/test/unit/gateways/cardknox_test.rb b/test/unit/gateways/cardknox_test.rb
index e4270ba97b2..cbddf0b4d46 100644
--- a/test/unit/gateways/cardknox_test.rb
+++ b/test/unit/gateways/cardknox_test.rb
@@ -67,10 +67,8 @@ def test_manual_entry_is_properly_indicated_on_purchase
response = stub_comms do
@gateway.purchase(@amount, @credit_card, @options)
end.check_request do |endpoint, data, headers|
-
assert_match %r{xCardNum=4242424242424242}, data
assert_match %r{xCardPresent=true}, data
-
end.respond_with(successful_purchase_response)
assert_success response
diff --git a/test/unit/gateways/finansbank_test.rb b/test/unit/gateways/finansbank_test.rb
index 4d4553366fd..9cb280aac30 100644
--- a/test/unit/gateways/finansbank_test.rb
+++ b/test/unit/gateways/finansbank_test.rb
@@ -1,4 +1,5 @@
# encoding: utf-8
+
require 'test_helper'
class FinansbankTest < Test::Unit::TestCase
diff --git a/test/unit/gateways/usa_epay_advanced_test.rb b/test/unit/gateways/usa_epay_advanced_test.rb
index ad96353bc4e..24220cf514f 100644
--- a/test/unit/gateways/usa_epay_advanced_test.rb
+++ b/test/unit/gateways/usa_epay_advanced_test.rb
@@ -1,4 +1,5 @@
# encoding: utf-8
+
require 'test_helper'
require 'logger'
diff --git a/test/unit/gateways/usa_epay_transaction_test.rb b/test/unit/gateways/usa_epay_transaction_test.rb
index 7138a6e5b52..d8eb617c41b 100644
--- a/test/unit/gateways/usa_epay_transaction_test.rb
+++ b/test/unit/gateways/usa_epay_transaction_test.rb
@@ -396,10 +396,8 @@ def test_manual_entry_is_properly_indicated_on_purchase
response = stub_comms do
@gateway.purchase(@amount, @credit_card, @options)
end.check_request do |endpoint, data, headers|
-
assert_match %r{UMcard=4242424242424242}, data
assert_match %r{UMcardpresent=true}, data
-
end.respond_with(successful_purchase_response)
assert_success response
diff --git a/test/unit/gateways/wirecard_test.rb b/test/unit/gateways/wirecard_test.rb
index b5ee72ebbc7..5ae3f487d86 100644
--- a/test/unit/gateways/wirecard_test.rb
+++ b/test/unit/gateways/wirecard_test.rb
@@ -1,4 +1,5 @@
# encoding: UTF-8
+
require 'test_helper'
class WirecardTest < Test::Unit::TestCase
diff --git a/test/unit/gateways/worldpay_test.rb b/test/unit/gateways/worldpay_test.rb
index 02a6eca5834..d73a991418f 100644
--- a/test/unit/gateways/worldpay_test.rb
+++ b/test/unit/gateways/worldpay_test.rb
@@ -437,7 +437,6 @@ def test_request_respects_test_mode_on_gateway_instance
end.check_request do |endpoint, data, headers|
assert_equal WorldpayGateway.test_url, endpoint
end.respond_with(successful_authorize_response, successful_capture_response)
-
ensure
ActiveMerchant::Billing::Base.mode = :test
end
From 8d488568aa5bec467f994d22cf8fa47807242073 Mon Sep 17 00:00:00 2001
From: David Perry
Date: Fri, 31 Aug 2018 15:30:33 -0400
Subject: [PATCH 0062/2234] FirstPay: Expose error code
Closes #2979
Remote:
14 tests, 33 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
13 tests, 122 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/first_pay.rb | 5 ++++
test/remote/gateways/remote_first_pay_test.rb | 1 +
test/unit/gateways/first_pay_test.rb | 23 +++++++++++++++++++
4 files changed, 30 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index 4e989e3cd3c..01cafca1b66 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,7 @@
== HEAD
* PayU Latam: support partial captures [bpollack] #2974
+* FirstPay: Expose error code [curiousepic] #2979
== Version 1.83.0 (August 30, 2018)
* CT Payment: Update How Address is Passed [nfarve] #2960
diff --git a/lib/active_merchant/billing/gateways/first_pay.rb b/lib/active_merchant/billing/gateways/first_pay.rb
index 08b4f417986..9a21f24562d 100644
--- a/lib/active_merchant/billing/gateways/first_pay.rb
+++ b/lib/active_merchant/billing/gateways/first_pay.rb
@@ -134,6 +134,7 @@ def commit(action, parameters)
message_from(response),
response,
authorization: authorization_from(response),
+ error_code: error_code_from(response),
test: test?
)
end
@@ -151,6 +152,10 @@ def message_from(response)
msg.downcase.capitalize if msg
end
+ def error_code_from(response)
+ response['error']
+ end
+
def authorization_from(response)
response['reference_number'] || response['reference_number1']
end
diff --git a/test/remote/gateways/remote_first_pay_test.rb b/test/remote/gateways/remote_first_pay_test.rb
index 3edab642a57..f30fc4223b0 100644
--- a/test/remote/gateways/remote_first_pay_test.rb
+++ b/test/remote/gateways/remote_first_pay_test.rb
@@ -108,6 +108,7 @@ def test_invalid_login
)
response = gateway.purchase(@amount, @credit_card, @options)
assert_failure response
+ assert_match /Merchant: 1234 has encountered error #DTO-200-TC./, response.error_code
end
def test_recurring_payment
diff --git a/test/unit/gateways/first_pay_test.rb b/test/unit/gateways/first_pay_test.rb
index 1e0bab16e96..b761e884938 100644
--- a/test/unit/gateways/first_pay_test.rb
+++ b/test/unit/gateways/first_pay_test.rb
@@ -199,6 +199,14 @@ def test_recurring_payments
assert_success response
end
+ def test_error_message
+ @gateway.stubs(:ssl_post).returns(failed_login_response)
+ response = @gateway.void('1')
+
+ assert_failure response
+ assert response.error_code.include?('Merchant: 1234 has encountered error #DTO-200-TC.')
+ end
+
def test_scrub
assert @gateway.supports_scrubbing?
assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed
@@ -370,6 +378,21 @@ def failed_void_response
)
end
+ def failed_login_response
+ %(
+
+ 0
+
+
+
+
+
+ a0d2560dda18631ce325c07dcbda2a9880fd17fb344fd233
+ Merchant: 1234 has encountered error #DTO-200-TC. Please call 888-638-7867 if you feel this is in error.
+
+)
+ end
+
def pre_scrubbed
%(
From d2c8199ca04279fac928a74af044e013e033b868 Mon Sep 17 00:00:00 2001
From: dtykocki
Date: Wed, 5 Sep 2018 10:58:07 -0400
Subject: [PATCH 0063/2234] Barclaycard: Pass device_fingerprint when specified
Unit:
25 tests, 115 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
30 tests, 63 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/barclaycard_smartpay.rb | 1 +
test/remote/gateways/remote_barclaycard_smartpay_test.rb | 6 ++++++
test/unit/gateways/barclaycard_smartpay_test.rb | 3 ++-
4 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 01cafca1b66..49dc4840a87 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -3,6 +3,7 @@
== HEAD
* PayU Latam: support partial captures [bpollack] #2974
* FirstPay: Expose error code [curiousepic] #2979
+* Barclaycard Smartpay: Pass device_fingerprint when specified [dtykocki] #2981
== Version 1.83.0 (August 30, 2018)
* CT Payment: Update How Address is Passed [nfarve] #2960
diff --git a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb
index 5a639ecd2b6..6df4b68ecfa 100644
--- a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb
+++ b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb
@@ -307,6 +307,7 @@ def payment_request(money, options)
hash[:shopperIP] = options[:ip] if options[:ip]
hash[:shopperReference] = options[:customer] if options[:customer]
hash[:shopperInteraction] = options[:shopper_interaction] if options[:shopper_interaction]
+ hash[:deviceFingerprint] = options[:device_fingerprint] if options[:device_fingerprint]
hash.keep_if { |_, v| v }
end
diff --git a/test/remote/gateways/remote_barclaycard_smartpay_test.rb b/test/remote/gateways/remote_barclaycard_smartpay_test.rb
index 01dc18c8609..d605c62f4c1 100644
--- a/test/remote/gateways/remote_barclaycard_smartpay_test.rb
+++ b/test/remote/gateways/remote_barclaycard_smartpay_test.rb
@@ -159,6 +159,12 @@ def test_successful_purchase_with_shopper_interaction
assert_equal '[capture-received]', response.message
end
+ def test_successful_purchase_with_device_fingerprint
+ response = @gateway.purchase(@amount, @credit_card, @options.merge(device_fingerprint: 'abcde1123'))
+ assert_success response
+ assert_equal '[capture-received]', response.message
+ end
+
def test_successful_authorize_with_3ds
assert response = @gateway.authorize(@amount, @three_ds_enrolled_card, @options.merge(execute_threed: true))
assert_equal 'RedirectShopper', response.message
diff --git a/test/unit/gateways/barclaycard_smartpay_test.rb b/test/unit/gateways/barclaycard_smartpay_test.rb
index 08d4f38efb0..bac4a277b3e 100644
--- a/test/unit/gateways/barclaycard_smartpay_test.rb
+++ b/test/unit/gateways/barclaycard_smartpay_test.rb
@@ -159,9 +159,10 @@ def test_successful_authorize_with_shipping_house_number_and_street
def test_successful_authorize_with_extra_options
response = stub_comms do
- @gateway.authorize(@amount, @credit_card, @options.merge(shopper_interaction: 'ContAuth'))
+ @gateway.authorize(@amount, @credit_card, @options.merge(shopper_interaction: 'ContAuth', device_fingerprint: 'abcde123'))
end.check_request do |endpoint, data, headers|
assert_match(/shopperInteraction=ContAuth/, data)
+ assert_match(/deviceFingerprint=abcde123/, data)
end.respond_with(successful_authorize_response)
assert_success response
From 7aa9bda55c6fb874e004c07be60da78e2ec08b0e Mon Sep 17 00:00:00 2001
From: Michael Elfassy
Date: Wed, 5 Sep 2018 12:57:50 -0400
Subject: [PATCH 0064/2234] reflect correct test mode in braintree responses
(#2980)
---
CHANGELOG | 1 +
.../billing/gateways/braintree_blue.rb | 8 +++-
test/unit/gateways/braintree_blue_test.rb | 45 ++++++++++++++++++-
3 files changed, 50 insertions(+), 4 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 49dc4840a87..9aa0f8d7686 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,7 @@
== HEAD
* PayU Latam: support partial captures [bpollack] #2974
+* Braintree: Reflect correct test mode in Braintree responses [elfassy] [#2980]
* FirstPay: Expose error code [curiousepic] #2979
* Barclaycard Smartpay: Pass device_fingerprint when specified [dtykocki] #2981
diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb
index 25043306b51..b6fe5e8e431 100644
--- a/lib/active_merchant/billing/gateways/braintree_blue.rb
+++ b/lib/active_merchant/billing/gateways/braintree_blue.rb
@@ -347,11 +347,14 @@ def message_from_result(result)
end
def response_from_result(result)
+ response_hash = { braintree_transaction: transaction_hash(result) }
+
Response.new(
result.success?,
message_from_result(result),
- { braintree_transaction: transaction_hash(result) },
- { authorization: (result.transaction.id if result.transaction) }
+ response_hash,
+ authorization: (result.transaction.id if result.transaction),
+ test: test?
)
end
@@ -369,6 +372,7 @@ def response_options(result)
options[:avs_result] = { code: avs_code_from(result.transaction) }
options[:cvv_result] = result.transaction.cvv_response_code
end
+ options[:test] = test?
options
end
diff --git a/test/unit/gateways/braintree_blue_test.rb b/test/unit/gateways/braintree_blue_test.rb
index 194c7552176..721ec2f5e9e 100644
--- a/test/unit/gateways/braintree_blue_test.rb
+++ b/test/unit/gateways/braintree_blue_test.rb
@@ -7,7 +7,8 @@ def setup
@gateway = BraintreeBlueGateway.new(
:merchant_id => 'test',
:public_key => 'test',
- :private_key => 'test'
+ :private_key => 'test',
+ :test => true
)
@internal_gateway = @gateway.instance_variable_get( :@braintree_gateway )
@@ -63,13 +64,53 @@ def test_transaction_uses_payment_method_nonce_when_option
assert_success response
end
+ def test_authorize_transaction
+ Braintree::TransactionGateway.any_instance.expects(:sale).
+ returns(braintree_result)
+
+ response = @gateway.authorize(100, credit_card('41111111111111111111'))
+
+ assert_equal 'transaction_id', response.authorization
+ assert_equal true, response.test
+ end
+
+ def test_purchase_transaction
+ Braintree::TransactionGateway.any_instance.expects(:sale).
+ returns(braintree_result)
+
+ response = @gateway.purchase(100, credit_card('41111111111111111111'))
+
+ assert_equal 'transaction_id', response.authorization
+ assert_equal true, response.test
+ end
+
+ def test_capture_transaction
+ Braintree::TransactionGateway.any_instance.expects(:submit_for_settlement).
+ returns(braintree_result(:id => 'capture_transaction_id'))
+
+ response = @gateway.capture(100, 'transaction_id')
+
+ assert_equal 'capture_transaction_id', response.authorization
+ assert_equal true, response.test
+ end
+
+ def test_refund_transaction
+ Braintree::TransactionGateway.any_instance.expects(:refund).
+ returns(braintree_result(:id => 'refund_transaction_id'))
+
+ response = @gateway.refund(1000, 'transaction_id')
+ assert_equal 'refund_transaction_id', response.authorization
+ assert_equal true, response.test
+ end
+
def test_void_transaction
Braintree::TransactionGateway.any_instance.expects(:void).
with('transaction_id').
returns(braintree_result(:id => 'void_transaction_id'))
- response = @gateway.void('transaction_id', :test => true)
+ response = @gateway.void('transaction_id')
assert_equal 'void_transaction_id', response.authorization
+ assert_equal true, response.test
end
def test_verify_good_credentials
From e93070c32534c7c4aa44419b9081fef9173c0305 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Fri, 31 Aug 2018 13:00:08 -0400
Subject: [PATCH 0065/2234] RuboCop: fix Layout/RescueEnsureAlignment
---
.rubocop_todo.yml | 7 -------
.../billing/gateways/checkout_v2.rb | 10 +++++-----
.../billing/gateways/mundipagg.rb | 18 +++++++++---------
3 files changed, 14 insertions(+), 21 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 5ddf8499436..f9b05ac9482 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -241,13 +241,6 @@ Layout/MultilineOperationIndentation:
- 'test/unit/gateways/ogone_test.rb'
- 'test/unit/gateways/skip_jack_test.rb'
-# Offense count: 2
-# Cop supports --auto-correct.
-Layout/RescueEnsureAlignment:
- Exclude:
- - 'lib/active_merchant/billing/gateways/checkout_v2.rb'
- - 'lib/active_merchant/billing/gateways/mundipagg.rb'
-
# Offense count: 2
# Cop supports --auto-correct.
Layout/SpaceAfterColon:
diff --git a/lib/active_merchant/billing/gateways/checkout_v2.rb b/lib/active_merchant/billing/gateways/checkout_v2.rb
index 7d1f688f971..93a5c9f69d8 100644
--- a/lib/active_merchant/billing/gateways/checkout_v2.rb
+++ b/lib/active_merchant/billing/gateways/checkout_v2.rb
@@ -180,11 +180,11 @@ def cvv_result(response)
def parse(body)
JSON.parse(body)
- rescue JSON::ParserError
- {
- 'message' => 'Invalid JSON response received from CheckoutV2Gateway. Please contact CheckoutV2Gateway if you continue to receive this message.',
- 'raw_response' => scrub(body)
- }
+ rescue JSON::ParserError
+ {
+ 'message' => 'Invalid JSON response received from CheckoutV2Gateway. Please contact CheckoutV2Gateway if you continue to receive this message.',
+ 'raw_response' => scrub(body)
+ }
end
def success_from(response)
diff --git a/lib/active_merchant/billing/gateways/mundipagg.rb b/lib/active_merchant/billing/gateways/mundipagg.rb
index 7aefce004e4..89d895cea7b 100644
--- a/lib/active_merchant/billing/gateways/mundipagg.rb
+++ b/lib/active_merchant/billing/gateways/mundipagg.rb
@@ -247,15 +247,15 @@ def commit(action, parameters, auth = nil)
test: test?,
error_code: error_code_from(response)
)
- rescue ResponseError => e
- message = get_error_message(e)
- return Response.new(
- false,
- "#{STANDARD_ERROR_MESSAGE_MAPPING[e.response.code]} #{message}",
- parse(e.response.body),
- test: test?,
- error_code: STANDARD_ERROR_CODE_MAPPING[e.response.code],
- )
+ rescue ResponseError => e
+ message = get_error_message(e)
+ return Response.new(
+ false,
+ "#{STANDARD_ERROR_MESSAGE_MAPPING[e.response.code]} #{message}",
+ parse(e.response.body),
+ test: test?,
+ error_code: STANDARD_ERROR_CODE_MAPPING[e.response.code],
+ )
end
def success_from(response)
From 602359fe48314a598717fdabd55f97a973eb1cd2 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Fri, 31 Aug 2018 13:20:04 -0400
Subject: [PATCH 0066/2234] RuboCop: fix Layout/MultilineMethodCallIndentation
---
.rubocop_todo.yml | 17 ----------------
.../billing/gateways/balanced.rb | 4 ++--
lib/active_merchant/billing/gateways/ogone.rb | 8 ++++----
.../billing/gateways/realex.rb | 4 ++--
lib/active_merchant/billing/gateways/sage.rb | 20 +++++++++----------
lib/active_merchant/billing/gateways/telr.rb | 6 +++---
test/unit/connection_test.rb | 9 ++++++---
test/unit/gateways/braintree_blue_test.rb | 4 ++--
test/unit/gateways/jetpay_v2_test.rb | 10 +++++-----
test/unit/gateways/wirecard_test.rb | 9 +++++----
test/unit/network_connection_retries_test.rb | 9 ++++++---
11 files changed, 45 insertions(+), 55 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index f9b05ac9482..d998631ae7f 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -206,23 +206,6 @@ Layout/MultilineHashBraceLayout:
Layout/MultilineMethodCallBraceLayout:
Enabled: false
-# Offense count: 34
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle, IndentationWidth.
-# SupportedStyles: aligned, indented, indented_relative_to_receiver
-Layout/MultilineMethodCallIndentation:
- Exclude:
- - 'lib/active_merchant/billing/gateways/balanced.rb'
- - 'lib/active_merchant/billing/gateways/ogone.rb'
- - 'lib/active_merchant/billing/gateways/realex.rb'
- - 'lib/active_merchant/billing/gateways/sage.rb'
- - 'lib/active_merchant/billing/gateways/telr.rb'
- - 'test/unit/connection_test.rb'
- - 'test/unit/gateways/braintree_blue_test.rb'
- - 'test/unit/gateways/jetpay_v2_test.rb'
- - 'test/unit/gateways/wirecard_test.rb'
- - 'test/unit/network_connection_retries_test.rb'
-
# Offense count: 35
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth.
diff --git a/lib/active_merchant/billing/gateways/balanced.rb b/lib/active_merchant/billing/gateways/balanced.rb
index c755bedf209..e5629dd7820 100644
--- a/lib/active_merchant/billing/gateways/balanced.rb
+++ b/lib/active_merchant/billing/gateways/balanced.rb
@@ -117,8 +117,8 @@ def reference_identifier_from(identifier)
case identifier
when %r{\|}
uri = identifier.
- split('|').
- detect{|part| part.size > 0}
+ split('|').
+ detect{|part| part.size > 0}
uri.split('/')[2]
when %r{\/}
identifier.split('/')[5]
diff --git a/lib/active_merchant/billing/gateways/ogone.rb b/lib/active_merchant/billing/gateways/ogone.rb
index 882dacf5f12..d3906c1e1c9 100644
--- a/lib/active_merchant/billing/gateways/ogone.rb
+++ b/lib/active_merchant/billing/gateways/ogone.rb
@@ -227,10 +227,10 @@ def supports_scrubbing?
def scrub(transcript)
transcript.
- gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
- gsub(%r((&?cardno=)[^&]*)i, '\1[FILTERED]').
- gsub(%r((&?cvc=)[^&]*)i, '\1[FILTERED]').
- gsub(%r((&?pswd=)[^&]*)i, '\1[FILTERED]')
+ gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
+ gsub(%r((&?cardno=)[^&]*)i, '\1[FILTERED]').
+ gsub(%r((&?cvc=)[^&]*)i, '\1[FILTERED]').
+ gsub(%r((&?pswd=)[^&]*)i, '\1[FILTERED]')
end
private
diff --git a/lib/active_merchant/billing/gateways/realex.rb b/lib/active_merchant/billing/gateways/realex.rb
index 08280b4b76b..feec62cb5b1 100644
--- a/lib/active_merchant/billing/gateways/realex.rb
+++ b/lib/active_merchant/billing/gateways/realex.rb
@@ -89,8 +89,8 @@ def supports_scrubbing
def scrub(transcript)
transcript.
- gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
- gsub(%r(()\d+())i, '\1[FILTERED]\2')
+ gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
+ gsub(%r(()\d+())i, '\1[FILTERED]\2')
end
private
diff --git a/lib/active_merchant/billing/gateways/sage.rb b/lib/active_merchant/billing/gateways/sage.rb
index 7a83ede6731..2c44e92eeed 100644
--- a/lib/active_merchant/billing/gateways/sage.rb
+++ b/lib/active_merchant/billing/gateways/sage.rb
@@ -98,16 +98,16 @@ def supports_scrubbing?
def scrub(transcript)
force_utf8(transcript).
- gsub(%r((M_id=)[^&]*), '\1[FILTERED]').
- gsub(%r((M_key=)[^&]*), '\1[FILTERED]').
- gsub(%r((C_cardnumber=)[^&]*), '\1[FILTERED]').
- gsub(%r((C_cvv=)[^&]*), '\1[FILTERED]').
- gsub(%r((C_rte=)[^&]*), '\1[FILTERED]').
- gsub(%r((C_acct=)[^&]*), '\1[FILTERED]').
- gsub(%r((C_ssn=)[^&]*), '\1[FILTERED]').
- gsub(%r(().+()), '\1[FILTERED]\2').
- gsub(%r(().+()), '\1[FILTERED]\2').
- gsub(%r(().+()), '\1[FILTERED]\2')
+ gsub(%r((M_id=)[^&]*), '\1[FILTERED]').
+ gsub(%r((M_key=)[^&]*), '\1[FILTERED]').
+ gsub(%r((C_cardnumber=)[^&]*), '\1[FILTERED]').
+ gsub(%r((C_cvv=)[^&]*), '\1[FILTERED]').
+ gsub(%r((C_rte=)[^&]*), '\1[FILTERED]').
+ gsub(%r((C_acct=)[^&]*), '\1[FILTERED]').
+ gsub(%r((C_ssn=)[^&]*), '\1[FILTERED]').
+ gsub(%r(().+()), '\1[FILTERED]\2').
+ gsub(%r(().+()), '\1[FILTERED]\2').
+ gsub(%r(().+()), '\1[FILTERED]\2')
end
private
diff --git a/lib/active_merchant/billing/gateways/telr.rb b/lib/active_merchant/billing/gateways/telr.rb
index 7a31114f364..f1c34063c9a 100644
--- a/lib/active_merchant/billing/gateways/telr.rb
+++ b/lib/active_merchant/billing/gateways/telr.rb
@@ -87,9 +87,9 @@ def supports_scrubbing?
def scrub(transcript)
transcript.
- gsub(%r(()[^<]+(<))i, '\1[FILTERED]\2').
- gsub(%r(()[^<]+(<))i, '\1[FILTERED]\2').
- gsub(%r(()[^<]+(<))i, '\1[FILTERED]\2')
+ gsub(%r(()[^<]+(<))i, '\1[FILTERED]\2').
+ gsub(%r(()[^<]+(<))i, '\1[FILTERED]\2').
+ gsub(%r(()[^<]+(<))i, '\1[FILTERED]\2')
end
private
diff --git a/test/unit/connection_test.rb b/test/unit/connection_test.rb
index c33797de2a0..ac8c29a4f1d 100644
--- a/test/unit/connection_test.rb
+++ b/test/unit/connection_test.rb
@@ -215,9 +215,12 @@ def test_failure_then_success_with_retry_safe_enabled
end
def test_mixture_of_failures_with_retry_safe_enabled
- Net::HTTP.any_instance.expects(:start).times(3).raises(Errno::ECONNRESET).
- raises(Errno::ECONNREFUSED).
- raises(EOFError)
+ Net::HTTP.any_instance.
+ expects(:start).
+ times(3).
+ raises(Errno::ECONNRESET).
+ raises(Errno::ECONNREFUSED).
+ raises(EOFError)
@connection.retry_safe = true
diff --git a/test/unit/gateways/braintree_blue_test.rb b/test/unit/gateways/braintree_blue_test.rb
index 721ec2f5e9e..e6986cae2c5 100644
--- a/test/unit/gateways/braintree_blue_test.rb
+++ b/test/unit/gateways/braintree_blue_test.rb
@@ -562,8 +562,8 @@ def test_three_d_secure_pass_thru_handling
cavv: 'cavv',
eci_flag: 'eci',
xid: 'xid',
- })).
- returns(braintree_result)
+ })).
+ returns(braintree_result)
@gateway.purchase(100, credit_card('41111111111111111111'), three_d_secure: {cavv: 'cavv', eci: 'eci', xid: 'xid'})
end
diff --git a/test/unit/gateways/jetpay_v2_test.rb b/test/unit/gateways/jetpay_v2_test.rb
index d135ddc7f0a..8129bf5eb11 100644
--- a/test/unit/gateways/jetpay_v2_test.rb
+++ b/test/unit/gateways/jetpay_v2_test.rb
@@ -163,11 +163,11 @@ def test_transcript_scrubbing
def test_purchase_sends_additional_options
@gateway.expects(:ssl_post).
- with(anything, regexp_matches(/777<\/TaxAmount>/)).
- with(anything, regexp_matches(/Value1<\/UDField1>/)).
- with(anything, regexp_matches(/Value2<\/UDField2>/)).
- with(anything, regexp_matches(/Value3<\/UDField3>/)).
- returns(successful_purchase_response)
+ with(anything, regexp_matches(/777<\/TaxAmount>/)).
+ with(anything, regexp_matches(/Value1<\/UDField1>/)).
+ with(anything, regexp_matches(/Value2<\/UDField2>/)).
+ with(anything, regexp_matches(/Value3<\/UDField3>/)).
+ returns(successful_purchase_response)
@gateway.purchase(@amount, @credit_card, {:tax => '777', :ud_field_1 => 'Value1', :ud_field_2 => 'Value2', :ud_field_3 => 'Value3'})
end
diff --git a/test/unit/gateways/wirecard_test.rb b/test/unit/gateways/wirecard_test.rb
index 5ae3f487d86..03b82b41b98 100644
--- a/test/unit/gateways/wirecard_test.rb
+++ b/test/unit/gateways/wirecard_test.rb
@@ -368,10 +368,11 @@ def wrong_creditcard_authorization_response
XML
result_node = ''
auth = 'AuthorizationCode'
- successful_authorization_response.gsub('ACK', 'NOK') \
- .gsub(result_node, result_node + error) \
- .gsub(/<#{auth}>\w+<\/#{auth}>/, "<#{auth}><\/#{auth}>") \
- .gsub(/.+<\/Info>/, '')
+ successful_authorization_response.
+ gsub('ACK', 'NOK').
+ gsub(result_node, result_node + error).
+ gsub(/<#{auth}>\w+<\/#{auth}>/, "<#{auth}><\/#{auth}>").
+ gsub(/.+<\/Info>/, '')
end
# Capture success
diff --git a/test/unit/network_connection_retries_test.rb b/test/unit/network_connection_retries_test.rb
index 84fbfac2c08..b071c4e9ede 100644
--- a/test/unit/network_connection_retries_test.rb
+++ b/test/unit/network_connection_retries_test.rb
@@ -133,9 +133,12 @@ def test_failure_then_success_logs_success
end
def test_mixture_of_failures_with_retry_safe_enabled
- @requester.expects(:post).times(3).raises(Errno::ECONNRESET).
- raises(Errno::ECONNREFUSED).
- raises(EOFError)
+ @requester.
+ expects(:post).
+ times(3).
+ raises(Errno::ECONNRESET).
+ raises(Errno::ECONNREFUSED).
+ raises(EOFError)
assert_raises(ActiveMerchant::ConnectionError) do
retry_exceptions :retry_safe => true do
From 8db0ba8ce8e742b28080b0dd64eb17f3bd0284ec Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Fri, 31 Aug 2018 14:09:33 -0400
Subject: [PATCH 0067/2234] RuboCop: fix Layout/SpaceAfterColon
---
.rubocop_todo.yml | 7 -------
test/remote/gateways/remote_micropayment_test.rb | 2 +-
test/remote/gateways/remote_payu_latam_test.rb | 2 +-
3 files changed, 2 insertions(+), 9 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index d998631ae7f..c4387d3f797 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -224,13 +224,6 @@ Layout/MultilineOperationIndentation:
- 'test/unit/gateways/ogone_test.rb'
- 'test/unit/gateways/skip_jack_test.rb'
-# Offense count: 2
-# Cop supports --auto-correct.
-Layout/SpaceAfterColon:
- Exclude:
- - 'test/remote/gateways/remote_micropayment_test.rb'
- - 'test/remote/gateways/remote_payu_latam_test.rb'
-
# Offense count: 315
# Cop supports --auto-correct.
Layout/SpaceAfterComma:
diff --git a/test/remote/gateways/remote_micropayment_test.rb b/test/remote/gateways/remote_micropayment_test.rb
index 29b3a3fdcd1..fb4589e7d71 100644
--- a/test/remote/gateways/remote_micropayment_test.rb
+++ b/test/remote/gateways/remote_micropayment_test.rb
@@ -16,7 +16,7 @@ def setup
end
def test_invalid_login
- gateway = MicropaymentGateway.new(access_key: 'invalid', api_key:'invalid')
+ gateway = MicropaymentGateway.new(access_key: 'invalid', api_key: 'invalid')
response = gateway.purchase(@amount, @credit_card, @options)
assert_failure response
assert_equal 'Authorization failed - Reason: api accesskey wrong', response.message
diff --git a/test/remote/gateways/remote_payu_latam_test.rb b/test/remote/gateways/remote_payu_latam_test.rb
index 316aaee30a4..b15d9fce5c1 100644
--- a/test/remote/gateways/remote_payu_latam_test.rb
+++ b/test/remote/gateways/remote_payu_latam_test.rb
@@ -118,7 +118,7 @@ def test_successful_purchase_brazil
zip: '01019-030',
phone: '(11)756312633'
),
- buyer:{
+ buyer: {
cnpj: '32593371000110'
}
}
From aec3b8e4c1f18d5bd6c91f88f8204ce6556b2b2d Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Fri, 31 Aug 2018 14:20:30 -0400
Subject: [PATCH 0068/2234] RuboCop: fix interpolation and quoting
These correspond to Style/UnneededInterpolation and
Style/UnneededPercentQ. I lumped them together because they are hitting
on the same basic issue of not interpolating when we don't need to.
Unit: 3922 tests, 68179 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications
100% passed
---
.rubocop_todo.yml | 33 ------------
lib/active_merchant/billing/base.rb | 2 +-
lib/active_merchant/billing/compatibility.rb | 2 +-
.../billing/gateways/banwire.rb | 2 +-
.../billing/gateways/cardknox.rb | 2 +-
.../billing/gateways/conekta.rb | 4 +-
.../billing/gateways/digitzs.rb | 2 +-
.../billing/gateways/eway_managed.rb | 4 +-
.../billing/gateways/first_giving.rb | 4 +-
.../billing/gateways/merchant_one.rb | 2 +-
.../billing/gateways/openpay.rb | 4 +-
.../billing/gateways/pay_junction_v2.rb | 2 +-
.../billing/gateways/safe_charge.rb | 2 +-
lib/active_merchant/billing/gateways/telr.rb | 2 +-
lib/support/gateway_support.rb | 6 +--
.../gateways/remote_cyber_source_test.rb | 6 +--
test/unit/gateways/clearhaus_test.rb | 2 +-
test/unit/gateways/forte_test.rb | 48 ++++++++---------
test/unit/gateways/merchant_warrior_test.rb | 4 +-
test/unit/gateways/nmi_test.rb | 8 +--
test/unit/gateways/orbital_test.rb | 6 +--
test/unit/gateways/payex_test.rb | 52 +++++++++----------
test/unit/gateways/paymentez_test.rb | 32 ++++++------
test/unit/gateways/world_net_test.rb | 52 +++++++++----------
24 files changed, 125 insertions(+), 158 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index c4387d3f797..a14183adddd 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -1533,39 +1533,6 @@ Style/TrailingCommaInHashLiteral:
Style/TrailingUnderscoreVariable:
Enabled: false
-# Offense count: 26
-# Cop supports --auto-correct.
-Style/UnneededInterpolation:
- Exclude:
- - 'lib/active_merchant/billing/base.rb'
- - 'lib/active_merchant/billing/compatibility.rb'
- - 'lib/active_merchant/billing/gateways/banwire.rb'
- - 'lib/active_merchant/billing/gateways/cardknox.rb'
- - 'lib/active_merchant/billing/gateways/conekta.rb'
- - 'lib/active_merchant/billing/gateways/digitzs.rb'
- - 'lib/active_merchant/billing/gateways/eway_managed.rb'
- - 'lib/active_merchant/billing/gateways/first_giving.rb'
- - 'lib/active_merchant/billing/gateways/merchant_one.rb'
- - 'lib/active_merchant/billing/gateways/openpay.rb'
- - 'lib/active_merchant/billing/gateways/pay_junction_v2.rb'
- - 'lib/active_merchant/billing/gateways/safe_charge.rb'
- - 'lib/active_merchant/billing/gateways/telr.rb'
- - 'lib/support/gateway_support.rb'
- - 'test/remote/gateways/remote_cyber_source_test.rb'
-
-# Offense count: 54
-# Cop supports --auto-correct.
-Style/UnneededPercentQ:
- Exclude:
- - 'test/unit/gateways/clearhaus_test.rb'
- - 'test/unit/gateways/forte_test.rb'
- - 'test/unit/gateways/merchant_warrior_test.rb'
- - 'test/unit/gateways/nmi_test.rb'
- - 'test/unit/gateways/orbital_test.rb'
- - 'test/unit/gateways/payex_test.rb'
- - 'test/unit/gateways/paymentez_test.rb'
- - 'test/unit/gateways/world_net_test.rb'
-
# Offense count: 117
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, MinSize, WordRegex.
diff --git a/lib/active_merchant/billing/base.rb b/lib/active_merchant/billing/base.rb
index 2248e6f9c39..5392189e46b 100644
--- a/lib/active_merchant/billing/base.rb
+++ b/lib/active_merchant/billing/base.rb
@@ -49,7 +49,7 @@ def self.gateway(name)
# notification = chronopay.notification(raw_post)
#
def self.integration(name)
- Billing::Integrations.const_get("#{name.to_s.downcase}".camelize)
+ Billing::Integrations.const_get(name.to_s.downcase.camelize)
end
# A check to see if we're in test mode
diff --git a/lib/active_merchant/billing/compatibility.rb b/lib/active_merchant/billing/compatibility.rb
index b32cb6ca4f4..740cc3d0906 100644
--- a/lib/active_merchant/billing/compatibility.rb
+++ b/lib/active_merchant/billing/compatibility.rb
@@ -102,7 +102,7 @@ def full_messages
self.each do |key, messages|
next unless(messages && !messages.empty?)
if key == 'base'
- result << "#{messages.first}"
+ result << messages.first.to_s
else
result << "#{Compatibility.humanize(key)} #{messages.first}"
end
diff --git a/lib/active_merchant/billing/gateways/banwire.rb b/lib/active_merchant/billing/gateways/banwire.rb
index 09aeb583fe2..d0e23302c00 100644
--- a/lib/active_merchant/billing/gateways/banwire.rb
+++ b/lib/active_merchant/billing/gateways/banwire.rb
@@ -63,7 +63,7 @@ def add_creditcard(post, creditcard)
post[:card_num] = creditcard.number
post[:card_name] = creditcard.name
post[:card_type] = card_brand(creditcard)
- post[:card_exp] = "#{sprintf("%02d", creditcard.month)}/#{"#{creditcard.year}"[-2, 2]}"
+ post[:card_exp] = "#{sprintf("%02d", creditcard.month)}/#{creditcard.year.to_s[-2, 2]}"
post[:card_ccv2] = creditcard.verification_value
end
diff --git a/lib/active_merchant/billing/gateways/cardknox.rb b/lib/active_merchant/billing/gateways/cardknox.rb
index afafc938d9e..f133cf33c41 100644
--- a/lib/active_merchant/billing/gateways/cardknox.rb
+++ b/lib/active_merchant/billing/gateways/cardknox.rb
@@ -312,7 +312,7 @@ def post_data(command, parameters = {})
Key: @options[:api_key],
Version: '4.5.4',
SoftwareName: 'Active Merchant',
- SoftwareVersion: "#{ActiveMerchant::VERSION}",
+ SoftwareVersion: ActiveMerchant::VERSION.to_s,
Command: command,
}
diff --git a/lib/active_merchant/billing/gateways/conekta.rb b/lib/active_merchant/billing/gateways/conekta.rb
index 6b3dccd915e..2e38d54c43c 100644
--- a/lib/active_merchant/billing/gateways/conekta.rb
+++ b/lib/active_merchant/billing/gateways/conekta.rb
@@ -162,8 +162,8 @@ def add_payment_source(post, payment_source, options)
post[:card][:name] = payment_source.name
post[:card][:cvc] = payment_source.verification_value
post[:card][:number] = payment_source.number
- post[:card][:exp_month] = "#{sprintf("%02d", payment_source.month)}"
- post[:card][:exp_year] = "#{"#{payment_source.year}"[-2, 2]}"
+ post[:card][:exp_month] = sprintf('%02d', payment_source.month)
+ post[:card][:exp_year] = payment_source.year.to_s[-2, 2]
add_address(post[:card], options)
end
end
diff --git a/lib/active_merchant/billing/gateways/digitzs.rb b/lib/active_merchant/billing/gateways/digitzs.rb
index 80510bf8e0a..b8b7d96fcb5 100644
--- a/lib/active_merchant/billing/gateways/digitzs.rb
+++ b/lib/active_merchant/billing/gateways/digitzs.rb
@@ -163,7 +163,7 @@ def create_customer_request(payment, options)
post[:data][:attributes] = {
merchantId: options[:merchant_id],
name: payment.name,
- externalId: "#{SecureRandom.hex(16)}"
+ externalId: SecureRandom.hex(16)
}
post
diff --git a/lib/active_merchant/billing/gateways/eway_managed.rb b/lib/active_merchant/billing/gateways/eway_managed.rb
index 72e45021922..c08ebcd4285 100644
--- a/lib/active_merchant/billing/gateways/eway_managed.rb
+++ b/lib/active_merchant/billing/gateways/eway_managed.rb
@@ -253,9 +253,9 @@ def soap_request(arguments, action)
end
end
xml.tag! 'soap12:Body' do |x|
- x.tag! "#{action}", {'xmlns' => 'https://www.eway.com.au/gateway/managedpayment'} do |y|
+ x.tag! action, {'xmlns' => 'https://www.eway.com.au/gateway/managedpayment'} do |y|
post.each do |key, value|
- y.tag! "#{key}", "#{value}"
+ y.tag! key, value
end
end
end
diff --git a/lib/active_merchant/billing/gateways/first_giving.rb b/lib/active_merchant/billing/gateways/first_giving.rb
index 3adb5ab8d85..29514f4334f 100644
--- a/lib/active_merchant/billing/gateways/first_giving.rb
+++ b/lib/active_merchant/billing/gateways/first_giving.rb
@@ -133,8 +133,8 @@ def creditcard_brand(brand)
def headers
{
'User-Agent' => "ActiveMerchantBindings/#{ActiveMerchant::VERSION}",
- 'JG_APPLICATIONKEY' => "#{@options[:application_key]}",
- 'JG_SECURITYTOKEN' => "#{@options[:security_token]}"
+ 'JG_APPLICATIONKEY' => @options[:application_key].to_s,
+ 'JG_SECURITYTOKEN' => @options[:security_token].to_s
}
end
end
diff --git a/lib/active_merchant/billing/gateways/merchant_one.rb b/lib/active_merchant/billing/gateways/merchant_one.rb
index 1a2c457fec5..c65149bed62 100644
--- a/lib/active_merchant/billing/gateways/merchant_one.rb
+++ b/lib/active_merchant/billing/gateways/merchant_one.rb
@@ -77,7 +77,7 @@ def add_address(post, creditcard, options)
def add_creditcard(post, creditcard)
post['cvv'] = creditcard.verification_value
post['ccnumber'] = creditcard.number
- post['ccexp'] = "#{sprintf("%02d", creditcard.month)}#{"#{creditcard.year}"[-2, 2]}"
+ post['ccexp'] = "#{sprintf("%02d", creditcard.month)}#{creditcard.year.to_s[-2, 2]}"
end
def commit(action, money, parameters={})
diff --git a/lib/active_merchant/billing/gateways/openpay.rb b/lib/active_merchant/billing/gateways/openpay.rb
index 42db1200b97..83c64de6258 100644
--- a/lib/active_merchant/billing/gateways/openpay.rb
+++ b/lib/active_merchant/billing/gateways/openpay.rb
@@ -126,8 +126,8 @@ def add_creditcard(post, creditcard, options)
elsif creditcard.respond_to?(:number)
card = {
card_number: creditcard.number,
- expiration_month: "#{sprintf("%02d", creditcard.month)}",
- expiration_year: "#{"#{creditcard.year}"[-2, 2]}",
+ expiration_month: sprintf('%02d', creditcard.month),
+ expiration_year: creditcard.year.to_s[-2, 2],
cvv2: creditcard.verification_value,
holder_name: creditcard.name
}
diff --git a/lib/active_merchant/billing/gateways/pay_junction_v2.rb b/lib/active_merchant/billing/gateways/pay_junction_v2.rb
index 9cac25e238a..f05d335b8e8 100644
--- a/lib/active_merchant/billing/gateways/pay_junction_v2.rb
+++ b/lib/active_merchant/billing/gateways/pay_junction_v2.rb
@@ -141,7 +141,7 @@ def headers
'Authorization' => 'Basic ' + Base64.encode64("#{@options[:api_login]}:#{@options[:api_password]}").strip,
'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8',
'Accept' => 'application/json',
- 'X-PJ-Application-Key' => "#{@options[:api_key]}"
+ 'X-PJ-Application-Key' => @options[:api_key].to_s
}
end
diff --git a/lib/active_merchant/billing/gateways/safe_charge.rb b/lib/active_merchant/billing/gateways/safe_charge.rb
index 684f1c3d468..82aab0e2113 100644
--- a/lib/active_merchant/billing/gateways/safe_charge.rb
+++ b/lib/active_merchant/billing/gateways/safe_charge.rb
@@ -181,7 +181,7 @@ def childnode_to_response(response, childnode)
end
def element_name_to_symbol(response, childnode)
- name = "#{childnode.name.downcase}"
+ name = childnode.name.downcase
response[name.to_sym] = childnode.text
end
diff --git a/lib/active_merchant/billing/gateways/telr.rb b/lib/active_merchant/billing/gateways/telr.rb
index f1c34063c9a..b7cff295ac8 100644
--- a/lib/active_merchant/billing/gateways/telr.rb
+++ b/lib/active_merchant/billing/gateways/telr.rb
@@ -219,7 +219,7 @@ def parse(xml)
response[node.name.downcase.to_sym] = node.text
else
node.elements.each do |childnode|
- name = "#{childnode.name.downcase}"
+ name = childnode.name.downcase
response[name.to_sym] = childnode.text
end
end
diff --git a/lib/support/gateway_support.rb b/lib/support/gateway_support.rb
index 29b3fc05a8e..c811e7d04fe 100644
--- a/lib/support/gateway_support.rb
+++ b/lib/support/gateway_support.rb
@@ -32,13 +32,13 @@ def features
width = 15
print 'Name'.center(width + 20)
- ACTIONS.each{|f| print "#{f.to_s.capitalize.center(width)}" }
+ ACTIONS.each{|f| print f.to_s.capitalize.center(width) }
puts
each_gateway do |g|
- print "#{g.display_name.ljust(width + 20)}"
+ print g.display_name.ljust(width + 20)
ACTIONS.each do |f|
- print "#{(g.instance_methods.include?(f.to_s) ? "Y" : "N").center(width)}"
+ print((g.instance_methods.include?(f.to_s) ? 'Y' : 'N').center(width))
end
puts
end
diff --git a/test/remote/gateways/remote_cyber_source_test.rb b/test/remote/gateways/remote_cyber_source_test.rb
index 106a3cf3a0d..48fc84c0443 100644
--- a/test/remote/gateways/remote_cyber_source_test.rb
+++ b/test/remote/gateways/remote_cyber_source_test.rb
@@ -12,19 +12,19 @@ def setup
@three_ds_unenrolled_card = credit_card('4000000000000051',
verification_value: '321',
month: '12',
- year: "#{Time.now.year + 2}",
+ year: (Time.now.year + 2).to_s,
brand: :visa
)
@three_ds_enrolled_card = credit_card('4000000000000002',
verification_value: '321',
month: '12',
- year: "#{Time.now.year + 2}",
+ year: (Time.now.year + 2).to_s,
brand: :visa
)
@three_ds_invalid_card = credit_card('4000000000000010',
verification_value: '321',
month: '12',
- year: "#{Time.now.year + 2}",
+ year: (Time.now.year + 2).to_s,
brand: :visa
)
diff --git a/test/unit/gateways/clearhaus_test.rb b/test/unit/gateways/clearhaus_test.rb
index a30a5b3894c..0794d356bdc 100644
--- a/test/unit/gateways/clearhaus_test.rb
+++ b/test/unit/gateways/clearhaus_test.rb
@@ -355,7 +355,7 @@ def post_scrubbed
end
def test_private_key
- %Q{-----BEGIN RSA PRIVATE KEY-----\nMIIBOwIBAAJBALYK0zmwuYkH3YWcFNLLddx5cwDxEY7Gi1xITuQqRrU4yD3uSw+J\nWYKknb4Tbndb6iEHY+e6gIGD+49TojnNeIUCAwEAAQJARyuYRRe4kcBHdPL+mSL+\nY0IAGkAlUyKAXYXPghidKD/v/oLrFaZWALGM2clv6UoYYpPnInSgbcud4sTcfeUm\nQQIhAN2JZ2qv0WGcbIopBpwpQ5jDxMGVkmkVVUEWWABGF8+pAiEA0lySxTELZm8b\nGx9UEDRghN+Qv/OuIKFldu1Ba4f8W30CIQCaQFIBtunTTVdF28r+cLzgYW9eWwbW\npEP4TdZ4WlW6AQIhAMDCTUdeUpjxlH/87BXROORozAXocBW8bvJUI486U5ctAiAd\nInviQqJd1KTGRDmWIGrE5YACVmW2JSszD9t5VKxkAA==\n-----END RSA PRIVATE KEY-----}
+ "-----BEGIN RSA PRIVATE KEY-----\nMIIBOwIBAAJBALYK0zmwuYkH3YWcFNLLddx5cwDxEY7Gi1xITuQqRrU4yD3uSw+J\nWYKknb4Tbndb6iEHY+e6gIGD+49TojnNeIUCAwEAAQJARyuYRRe4kcBHdPL+mSL+\nY0IAGkAlUyKAXYXPghidKD/v/oLrFaZWALGM2clv6UoYYpPnInSgbcud4sTcfeUm\nQQIhAN2JZ2qv0WGcbIopBpwpQ5jDxMGVkmkVVUEWWABGF8+pAiEA0lySxTELZm8b\nGx9UEDRghN+Qv/OuIKFldu1Ba4f8W30CIQCaQFIBtunTTVdF28r+cLzgYW9eWwbW\npEP4TdZ4WlW6AQIhAMDCTUdeUpjxlH/87BXROORozAXocBW8bvJUI486U5ctAiAd\nInviQqJd1KTGRDmWIGrE5YACVmW2JSszD9t5VKxkAA==\n-----END RSA PRIVATE KEY-----"
end
def failed_purchase_response
diff --git a/test/unit/gateways/forte_test.rb b/test/unit/gateways/forte_test.rb
index 124d2b3a17f..c7ca564cc65 100644
--- a/test/unit/gateways/forte_test.rb
+++ b/test/unit/gateways/forte_test.rb
@@ -193,7 +193,7 @@ def post_scrubbed
end
def successful_purchase_response
- %q(
+ '
{
"transaction_id":"trn_bb7687a7-3d3a-40c2-8fa9-90727a814249",
"account_id":"act_300111",
@@ -227,11 +227,11 @@ def successful_purchase_response
"settlements":"https://sandbox.forte.net/API/v2/transactions/trn_bb7687a7-3d3a-40c2-8fa9-90727a814249/settlements"
}
}
- )
+ '
end
def failed_purchase_response
- %q(
+ '
{
"transaction_id":"trn_e9ea64c4-5c2c-43dd-9138-f2661b59947c",
"account_id":"act_300111",
@@ -261,11 +261,11 @@ def failed_purchase_response
"settlements":"https://sandbox.forte.net/API/v2/transactions/trn_e9ea64c4-5c2c-43dd-9138-f2661b59947c/settlements"
}
}
- )
+ '
end
def successful_echeck_purchase_response
- %q(
+ '
{
"transaction_id":"trn_bb7687a7-3d3a-40c2-8fa9-90727a814249",
"account_id":"act_300111",
@@ -306,11 +306,11 @@ def successful_echeck_purchase_response
"settlements":"https://sandbox.forte.net/API/v2/transactions/trn_bb7687a7-3d3a-40c2-8fa9-90727a814249/settlements"
}
}
- )
+ '
end
def failed_echeck_purchase_response
- %q(
+ '
{
"transaction_id":"trn_bb7687a7-3d3a-40c2-8fa9-90727a814249",
"account_id":"act_300111",
@@ -348,11 +348,11 @@ def failed_echeck_purchase_response
"settlements":"https://sandbox.forte.net/API/v2/transactions/trn_bb7687a7-3d3a-40c2-8fa9-90727a814249/settlements"
}
}
- )
+ '
end
def successful_authorize_response
- %q(
+ '
{
"transaction_id":"trn_527fdc8a-d3d0-4680-badc-bfa784c63c13",
"account_id":"act_300111",
@@ -386,11 +386,11 @@ def successful_authorize_response
"settlements":"https://sandbox.forte.net/API/v2/transactions/trn_527fdc8a-d3d0-4680-badc-bfa784c63c13/settlements"
}
}
- )
+ '
end
def failed_authorize_response
- %q(
+ '
{
"transaction_id":"trn_7c045645-98b3-4c8a-88d6-e8d686884564",
"account_id":"act_300111",
@@ -420,11 +420,11 @@ def failed_authorize_response
"settlements":"https://sandbox.forte.net/API/v2/transactions/trn_7c045645-98b3-4c8a-88d6-e8d686884564/settlements"
}
}
- )
+ '
end
def successful_capture_response
- %q(
+ '
{
"transaction_id":"trn_94a04a97-c847-4420-820b-fb153a1f0f64",
"account_id":"act_300111",
@@ -444,11 +444,11 @@ def successful_capture_response
"settlements":"https://sandbox.forte.net/API/v2/transactions/trn_94a04a97-c847-4420-820b-fb153a1f0f64/settlements"
}
}
- )
+ '
end
def failed_capture_response
- %q(
+ '
{
"account_id":"act_300111",
"location_id":"loc_176008",
@@ -459,11 +459,11 @@ def failed_capture_response
"response_desc":"The field transaction_id is required."
}
}
- )
+ '
end
def successful_credit_response
- %q(
+ '
{
"transaction_id":"trn_357b284e-1dde-42ba-b0a5-5f66e08c7d9f",
"account_id":"act_300111",
@@ -497,11 +497,11 @@ def successful_credit_response
"settlements":"https://sandbox.forte.net/API/v2/transactions/trn_357b284e-1dde-42ba-b0a5-5f66e08c7d9f/settlements"
}
}
- )
+ '
end
def failed_credit_response
- %q(
+ '
{
"transaction_id":"trn_ce70ce9a-6265-4892-9a83-5825cb869ed5",
"account_id":"act_300111",
@@ -523,11 +523,11 @@ def failed_credit_response
"settlements":"https://sandbox.forte.net/API/v2/transactions/trn_ce70ce9a-6265-4892-9a83-5825cb869ed5/settlements"
}
}
- )
+ '
end
def successful_void_response
- %q(
+ '
{
"transaction_id":"trn_6c9d049e-1971-45fb-a4da-a0c35c4ed274",
"account_id":"act_300111",
@@ -546,11 +546,11 @@ def successful_void_response
"settlements":"https://sandbox.forte.net/API/v2/transactions/trn_6c9d049e-1971-45fb-a4da-a0c35c4ed274/settlements"
}
}
- )
+ '
end
def failed_void_response
- %q(
+ '
{
"account_id":"act_300111",
"location_id":"loc_176008",
@@ -561,7 +561,7 @@ def failed_void_response
"response_desc":"The field transaction_id is required."
}
}
- )
+ '
end
def successful_refund_response
diff --git a/test/unit/gateways/merchant_warrior_test.rb b/test/unit/gateways/merchant_warrior_test.rb
index 8eb0e1e85f2..2d718e7da74 100644
--- a/test/unit/gateways/merchant_warrior_test.rb
+++ b/test/unit/gateways/merchant_warrior_test.rb
@@ -223,10 +223,10 @@ def successful_store_response
end
def pre_scrubbed
- %q(transactionAmount=1.00&transactionCurrency=AUD&hash=adb50f6ff360f861e6f525e8daae76b5&transactionProduct=98fc25d40a47f3d24da460c0ca307c&customerName=Longbob+Longsen&customerCountry=AU&customerState=Queensland&customerCity=Brisbane&customerAddress=123+test+st&customerPostCode=4000&customerIP=&customerPhone=&customerEmail=&paymentCardNumber=5123456789012346&paymentCardName=Longbob+Longsen&paymentCardExpiry=0520&paymentCardCSC=123&merchantUUID=51f7da294af8f&apiKey=nooudtd0&method=processCard)
+ 'transactionAmount=1.00&transactionCurrency=AUD&hash=adb50f6ff360f861e6f525e8daae76b5&transactionProduct=98fc25d40a47f3d24da460c0ca307c&customerName=Longbob+Longsen&customerCountry=AU&customerState=Queensland&customerCity=Brisbane&customerAddress=123+test+st&customerPostCode=4000&customerIP=&customerPhone=&customerEmail=&paymentCardNumber=5123456789012346&paymentCardName=Longbob+Longsen&paymentCardExpiry=0520&paymentCardCSC=123&merchantUUID=51f7da294af8f&apiKey=nooudtd0&method=processCard'
end
def post_scrubbed
- %q(transactionAmount=1.00&transactionCurrency=AUD&hash=adb50f6ff360f861e6f525e8daae76b5&transactionProduct=98fc25d40a47f3d24da460c0ca307c&customerName=Longbob+Longsen&customerCountry=AU&customerState=Queensland&customerCity=Brisbane&customerAddress=123+test+st&customerPostCode=4000&customerIP=&customerPhone=&customerEmail=&paymentCardNumber=[FILTERED]&paymentCardName=Longbob+Longsen&paymentCardExpiry=0520&paymentCardCSC=[FILTERED]&merchantUUID=51f7da294af8f&apiKey=[FILTERED]&method=processCard)
+ 'transactionAmount=1.00&transactionCurrency=AUD&hash=adb50f6ff360f861e6f525e8daae76b5&transactionProduct=98fc25d40a47f3d24da460c0ca307c&customerName=Longbob+Longsen&customerCountry=AU&customerState=Queensland&customerCity=Brisbane&customerAddress=123+test+st&customerPostCode=4000&customerIP=&customerPhone=&customerEmail=&paymentCardNumber=[FILTERED]&paymentCardName=Longbob+Longsen&paymentCardExpiry=0520&paymentCardCSC=[FILTERED]&merchantUUID=51f7da294af8f&apiKey=[FILTERED]&method=processCard'
end
end
diff --git a/test/unit/gateways/nmi_test.rb b/test/unit/gateways/nmi_test.rb
index 8512e3d9ba1..f7f7d3c0030 100644
--- a/test/unit/gateways/nmi_test.rb
+++ b/test/unit/gateways/nmi_test.rb
@@ -444,20 +444,20 @@ def successful_echeck_store_response
end
def transcript
- %q(
+ '
amount=1.00&orderid=c9f2fb356d2a839d315aa6e8d7ed2404&orderdescription=Store+purchase¤cy=USD&payment=creditcard&firstname=Longbob&lastname=Longsen&ccnumber=4111111111111111&cvv=917&ccexp=0916&email=&ipaddress=&company=Widgets+Inc&address1=456+My+Street&address2=Apt+1&city=Ottawa&state=ON&country=CA&zip=K1C2N6&phone=%28555%29555-5555&type=sale&username=demo&password=password
response=1&responsetext=SUCCESS&authcode=123456&transactionid=2767466670&avsresponse=N&cvvresponse=N&orderid=c9f2fb356d2a839d315aa6e8d7ed2404&type=sale&response_code=100
amount=1.00&orderid=e88df316d8ba3c8c6b98aa93b78facc0&orderdescription=Store+purchase¤cy=USD&payment=check&checkname=Jim+Smith&checkaba=123123123&checkaccount=123123123&account_holder_type=personal&account_type=checking&sec_code=WEB&email=&ipaddress=&company=Widgets+Inc&address1=456+My+Street&address2=Apt+1&city=Ottawa&state=ON&country=CA&zip=K1C2N6&phone=%28555%29555-5555&type=sale&username=demo&password=password
response=1&responsetext=SUCCESS&authcode=123456&transactionid=2767467157&avsresponse=&cvvresponse=&orderid=e88df316d8ba3c8c6b98aa93b78facc0&type=sale&response_code=100
- )
+ '
end
def scrubbed_transcript
- %q(
+ '
amount=1.00&orderid=c9f2fb356d2a839d315aa6e8d7ed2404&orderdescription=Store+purchase¤cy=USD&payment=creditcard&firstname=Longbob&lastname=Longsen&ccnumber=[FILTERED]&cvv=[FILTERED]&ccexp=0916&email=&ipaddress=&company=Widgets+Inc&address1=456+My+Street&address2=Apt+1&city=Ottawa&state=ON&country=CA&zip=K1C2N6&phone=%28555%29555-5555&type=sale&username=demo&password=[FILTERED]
response=1&responsetext=SUCCESS&authcode=123456&transactionid=2767466670&avsresponse=N&cvvresponse=N&orderid=c9f2fb356d2a839d315aa6e8d7ed2404&type=sale&response_code=100
amount=1.00&orderid=e88df316d8ba3c8c6b98aa93b78facc0&orderdescription=Store+purchase¤cy=USD&payment=check&checkname=Jim+Smith&checkaba=[FILTERED]&checkaccount=[FILTERED]&account_holder_type=personal&account_type=checking&sec_code=WEB&email=&ipaddress=&company=Widgets+Inc&address1=456+My+Street&address2=Apt+1&city=Ottawa&state=ON&country=CA&zip=K1C2N6&phone=%28555%29555-5555&type=sale&username=demo&password=[FILTERED]
response=1&responsetext=SUCCESS&authcode=123456&transactionid=2767467157&avsresponse=&cvvresponse=&orderid=e88df316d8ba3c8c6b98aa93b78facc0&type=sale&response_code=100
- )
+ '
end
end
diff --git a/test/unit/gateways/orbital_test.rb b/test/unit/gateways/orbital_test.rb
index aac02cff291..5a23c6d072c 100644
--- a/test/unit/gateways/orbital_test.rb
+++ b/test/unit/gateways/orbital_test.rb
@@ -753,15 +753,15 @@ def successful_purchase_response(resp_code = '00')
end
def failed_purchase_response
- %q{AC700000000000001VI400030001111222014A5398CF9B87744GG84A1D30F2F2321C6624941600005G NDo Not HonorAUTH DECLINED 1200105NN150214}
+ 'AC700000000000001VI400030001111222014A5398CF9B87744GG84A1D30F2F2321C6624941600005G NDo Not HonorAUTH DECLINED 1200105NN150214'
end
def successful_profile_response
- %q{000001700000000000Longbob LongsenABCCREATE0Profile Request ProcessedCCA4111111111111111}
+ '000001700000000000Longbob LongsenABCCREATE0Profile Request ProcessedCCA4111111111111111'
end
def successful_void_response
- %q{700000208761001250FB1C41FEC9D016FF0BEBAD0884B174AD0853B010001192013172049}
+ '700000208761001250FB1C41FEC9D016FF0BEBAD0884B174AD0853B010001192013172049'
end
def pre_scrubbed
diff --git a/test/unit/gateways/payex_test.rb b/test/unit/gateways/payex_test.rb
index c948304954a..a567c1a08c1 100644
--- a/test/unit/gateways/payex_test.rb
+++ b/test/unit/gateways/payex_test.rb
@@ -125,7 +125,7 @@ def test_successful_purchase_with_stored_card
private
def successful_initialize_response
- %q{
+ '
@@ -133,12 +133,12 @@ def successful_initialize_response
- }
+ '
end
# Place raw successful response from gateway here
def successful_purchase_response
- %q{
+ '
@@ -146,11 +146,11 @@ def successful_purchase_response
- }
+ '
end
def failed_purchase_response
- %q{
+ '
@@ -159,11 +159,11 @@ def failed_purchase_response
- }
+ '
end
def successful_authorize_response
- %q{
+ '
@@ -171,11 +171,11 @@ def successful_authorize_response
- }
+ '
end
def successful_capture_response
- %q{
+ '
@@ -183,11 +183,11 @@ def successful_capture_response
- }
+ '
end
def failed_capture_response
- %q{
+ '
@@ -195,11 +195,11 @@ def failed_capture_response
- }
+ '
end
def successful_void_response
- %q{
+ '
@@ -207,11 +207,11 @@ def successful_void_response
- }
+ '
end
def unsuccessful_void_response
- %q{
+ '
@@ -219,11 +219,11 @@ def unsuccessful_void_response
- }
+ '
end
def successful_refund_response
- %q{
+ '
@@ -231,11 +231,11 @@ def successful_refund_response
- }
+ '
end
def unsuccessful_refund_response
- %q{
+ '
@@ -243,11 +243,11 @@ def unsuccessful_refund_response
- }
+ '
end
def successful_store_response
- %q{
+ '
@@ -255,11 +255,11 @@ def successful_store_response
- }
+ '
end
def successful_unstore_response
- %q{
+ '
@@ -267,11 +267,11 @@ def successful_unstore_response
- }
+ '
end
def successful_autopay_response
- %q{
+ '
@@ -279,6 +279,6 @@ def successful_autopay_response
- }
+ '
end
end
diff --git a/test/unit/gateways/paymentez_test.rb b/test/unit/gateways/paymentez_test.rb
index 166ab7ebcf0..331c283b417 100644
--- a/test/unit/gateways/paymentez_test.rb
+++ b/test/unit/gateways/paymentez_test.rb
@@ -226,7 +226,7 @@ def post_scrubbed
end
def successful_purchase_response
- %q(
+ '
{
"transaction": {
"status": "success",
@@ -249,11 +249,11 @@ def successful_purchase_response
"number": "1111"
}
}
- )
+ '
end
def failed_purchase_response
- %q(
+ '
{
"transaction": {
"status": "failure",
@@ -276,11 +276,11 @@ def failed_purchase_response
"number": "4242"
}
}
- )
+ '
end
def successful_authorize_response
- %q(
+ '
{
"transaction": {
"status": "success",
@@ -305,11 +305,11 @@ def successful_authorize_response
"number": "1111"
}
}
- )
+ '
end
def failed_authorize_response
- %q(
+ '
{
"transaction": {
"status": "failure",
@@ -335,11 +335,11 @@ def failed_authorize_response
"origin": "Paymentez"
}
}
- )
+ '
end
def successful_capture_response
- %q(
+ '
{
"transaction": {
"status": "success",
@@ -364,7 +364,7 @@ def successful_capture_response
"number": "1111"
}
}
- )
+ '
end
def failed_capture_response
@@ -395,7 +395,7 @@ def successful_store_response
end
def failed_store_response
- %q(
+ '
{
"card": {
"bin": "424242",
@@ -409,11 +409,11 @@ def failed_store_response
"number": "4242"
}
}
- )
+ '
end
def expired_card_response
- %q(
+ '
{
"transaction":{
"status":"failure",
@@ -437,11 +437,11 @@ def expired_card_response
"origin":"Paymentez"
}
}
- )
+ '
end
def crash_response
- %q(
+ '
Internal Server Error
@@ -451,6 +451,6 @@ def crash_response
- )
+ '
end
end
diff --git a/test/unit/gateways/world_net_test.rb b/test/unit/gateways/world_net_test.rb
index d668b615cf6..c32728f69b9 100644
--- a/test/unit/gateways/world_net_test.rb
+++ b/test/unit/gateways/world_net_test.rb
@@ -191,70 +191,70 @@ def post_scrubbed
end
def successful_purchase_response
- %q(
-GZG6IG6VXIAAPPROVAL4753182015-09-14T21:22:12XMf8642d613c56628371a579443ce8d895)
+ '
+GZG6IG6VXIAAPPROVAL4753182015-09-14T21:22:12XMf8642d613c56628371a579443ce8d895'
end
def failed_purchase_response
- %q(
-JQU1810S4EDDECLINED2015-09-14T21:40:07c0ba33a10a6388b12c8fad79a107f2b5)
+ '
+JQU1810S4EDDECLINED2015-09-14T21:40:07c0ba33a10a6388b12c8fad79a107f2b5'
end
def successful_authorize_response
- %q(
-BF4CNN6WXPAAPPROVAL4508482015-09-14T21:53:10e80c52476af1dd969f3bf89ed02fe16f)
+ '
+BF4CNN6WXPAAPPROVAL4508482015-09-14T21:53:10e80c52476af1dd969f3bf89ed02fe16f'
end
def failed_authorize_response
- %q(
-IP0PUDDXG5DDECLINED2015-09-15T14:21:3705dfa85163ee8d8afa8711019f64acb3)
+ '
+IP0PUDDXG5DDECLINED2015-09-15T14:21:3705dfa85163ee8d8afa8711019f64acb3'
end
def successful_capture_response
- %q(
-BF4CNN6WXPAAPPROVAL4508482015-09-14T21:53:10e80c52476af1dd969f3bf89ed02fe16f)
+ '
+BF4CNN6WXPAAPPROVAL4508482015-09-14T21:53:10e80c52476af1dd969f3bf89ed02fe16f'
end
def failed_capture_response
- %q(
-cvc-minLength-valid: Value '' with length = '0' is not facet-valid with respect to minLength '10' for type 'UID'.)
+ '
+cvc-minLength-valid: Value '' with length = '0' is not facet-valid with respect to minLength '10' for type 'UID'.'
end
def successful_refund_response
- %q(
-ASUCCESSGIOH10II2J15-09-2015:14:44:17:999aebd69e9db6e4b0db7ecbae79a2970a0)
+ '
+ASUCCESSGIOH10II2J15-09-2015:14:44:17:999aebd69e9db6e4b0db7ecbae79a2970a0'
end
def failed_refund_response
- %q(
-cvc-minLength-valid: Value '' with length = '0' is not facet-valid with respect to minLength '10' for type 'UID'.)
+ '
+cvc-minLength-valid: Value '' with length = '0' is not facet-valid with respect to minLength '10' for type 'UID'.'
end
def successful_void_response
end
def successful_store_response
- %q(
-146304412401296753095641903312-05-2016:10:08:46:269b2e497d14014ad9f4770edbf7716435e)
+ '
+146304412401296753095641903312-05-2016:10:08:46:269b2e497d14014ad9f4770edbf7716435e'
end
def failed_store_response
- %q(
-E11INVALID CARDEXPIRY)
+ '
+E11INVALID CARDEXPIRY'
end
def successful_unstore_response
- %q(
-14630441240112-05-2016:10:08:48:3997f755e185be8066a535699755f709646)
+ '
+14630441240112-05-2016:10:08:48:3997f755e185be8066a535699755f709646'
end
def failed_unstore_response
- %q(
-E04INVALID REFERENCE DETAILS)
+ '
+E04INVALID REFERENCE DETAILS'
end
def failed_void_response
- %q(
-cvc-elt.1: Cannot find the declaration of element 'VOID'.)
+ '
+cvc-elt.1: Cannot find the declaration of element 'VOID'.'
end
end
From 32121207d636bd3f2095a26ca092b4b64b68fad2 Mon Sep 17 00:00:00 2001
From: "shingo.miyazawa"
Date: Fri, 14 Sep 2018 11:17:29 +0900
Subject: [PATCH 0069/2234] Modify Komoju gateway test url
Komoju abolished the sandbox environment, but instead supports a test
mode in their production environment. Change the URL appropriately.
Closes #2987
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/komoju.rb | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 9aa0f8d7686..db43b145c8c 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -5,6 +5,7 @@
* Braintree: Reflect correct test mode in Braintree responses [elfassy] [#2980]
* FirstPay: Expose error code [curiousepic] #2979
* Barclaycard Smartpay: Pass device_fingerprint when specified [dtykocki] #2981
+* Komoju: remove no-longer-relevant sandbox URL [miyazawadegica] #2987
== Version 1.83.0 (August 30, 2018)
* CT Payment: Update How Address is Passed [nfarve] #2960
diff --git a/lib/active_merchant/billing/gateways/komoju.rb b/lib/active_merchant/billing/gateways/komoju.rb
index 8aa3fc1b636..d53ab5f5165 100644
--- a/lib/active_merchant/billing/gateways/komoju.rb
+++ b/lib/active_merchant/billing/gateways/komoju.rb
@@ -3,7 +3,7 @@
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
class KomojuGateway < Gateway
- self.test_url = 'https://sandbox.komoju.com/api/v1'
+ self.test_url = 'https://komoju.com/api/v1'
self.live_url = 'https://komoju.com/api/v1'
self.supported_countries = ['JP']
self.default_currency = 'JPY'
From a2e4dcbf794bb80a03667e546600c72029bd06ec Mon Sep 17 00:00:00 2001
From: Niaja
Date: Wed, 12 Sep 2018 16:17:17 -0400
Subject: [PATCH 0070/2234] Rubocop changes that effect the indention of
comments
---
.rubocop_todo.yml | 15 --
.../billing/gateways/firstdata_e4.rb | 4 +-
lib/active_merchant/billing/gateways/ogone.rb | 10 +-
lib/active_merchant/billing/gateways/opp.rb | 212 +++++++++---------
.../billing/gateways/payflow_express.rb | 106 ++++-----
test/remote/gateways/remote_itransact_test.rb | 40 ++--
test/remote/gateways/remote_opp_test.rb | 10 +-
test/remote/gateways/remote_paypal_test.rb | 2 +-
test/remote/gateways/remote_world_net_test.rb | 6 +-
test/unit/gateways/eway_managed_test.rb | 2 +-
test/unit/gateways/opp_test.rb | 8 +-
11 files changed, 199 insertions(+), 216 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index a14183adddd..b31f60d0e0d 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -42,21 +42,6 @@ Layout/CaseIndentation:
Layout/ClosingHeredocIndentation:
Enabled: false
-# Offense count: 20
-# Cop supports --auto-correct.
-Layout/CommentIndentation:
- Exclude:
- - 'lib/active_merchant/billing/gateways/firstdata_e4.rb'
- - 'lib/active_merchant/billing/gateways/ogone.rb'
- - 'lib/active_merchant/billing/gateways/opp.rb'
- - 'lib/active_merchant/billing/gateways/payflow_express.rb'
- - 'test/remote/gateways/remote_itransact_test.rb'
- - 'test/remote/gateways/remote_opp_test.rb'
- - 'test/remote/gateways/remote_paypal_test.rb'
- - 'test/remote/gateways/remote_world_net_test.rb'
- - 'test/unit/gateways/eway_managed_test.rb'
- - 'test/unit/gateways/opp_test.rb'
-
# Offense count: 513
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
diff --git a/lib/active_merchant/billing/gateways/firstdata_e4.rb b/lib/active_merchant/billing/gateways/firstdata_e4.rb
index 58d18a49a52..b18bbfb1294 100755
--- a/lib/active_merchant/billing/gateways/firstdata_e4.rb
+++ b/lib/active_merchant/billing/gateways/firstdata_e4.rb
@@ -43,7 +43,7 @@ class FirstdataE4Gateway < Gateway
self.display_name = 'FirstData Global Gateway e4'
STANDARD_ERROR_CODE_MAPPING = {
- # Bank error codes: https://firstdata.zendesk.com/entries/471297-First-Data-Global-Gateway-e4-Bank-Response-Codes
+ # Bank error codes: https://firstdata.zendesk.com/entries/471297-First-Data-Global-Gateway-e4-Bank-Response-Codes
'201' => STANDARD_ERROR_CODE[:incorrect_number],
'531' => STANDARD_ERROR_CODE[:invalid_cvc],
'503' => STANDARD_ERROR_CODE[:invalid_cvc],
@@ -55,7 +55,7 @@ class FirstdataE4Gateway < Gateway
'401' => STANDARD_ERROR_CODE[:call_issuer],
'402' => STANDARD_ERROR_CODE[:call_issuer],
'501' => STANDARD_ERROR_CODE[:pickup_card],
- # Ecommerce error codes -- https://firstdata.zendesk.com/entries/451980-ecommerce-response-codes-etg-codes
+ # Ecommerce error codes -- https://firstdata.zendesk.com/entries/451980-ecommerce-response-codes-etg-codes
'22' => STANDARD_ERROR_CODE[:invalid_number],
'25' => STANDARD_ERROR_CODE[:invalid_expiry_date],
'31' => STANDARD_ERROR_CODE[:incorrect_cvc],
diff --git a/lib/active_merchant/billing/gateways/ogone.rb b/lib/active_merchant/billing/gateways/ogone.rb
index d3906c1e1c9..0ac3b015f75 100644
--- a/lib/active_merchant/billing/gateways/ogone.rb
+++ b/lib/active_merchant/billing/gateways/ogone.rb
@@ -122,12 +122,10 @@ class OgoneGateway < Gateway
SUCCESS_MESSAGE = 'The transaction was successful'
- THREE_D_SECURE_DISPLAY_WAYS = { :main_window => 'MAINW', # display the identification page in the main window
- # (default value).
- :pop_up => 'POPUP', # display the identification page in a pop-up window
- # and return to the main window at the end.
- :pop_ix => 'POPIX' } # display the identification page in a pop-up window
- # and remain in the pop-up window.
+ THREE_D_SECURE_DISPLAY_WAYS = { :main_window => 'MAINW', # display the identification page in the main window (default value).
+
+ :pop_up => 'POPUP', # display the identification page in a pop-up window and return to the main window at the end.
+ :pop_ix => 'POPIX' } # display the identification page in a pop-up window and remain in the pop-up window.
OGONE_NO_SIGNATURE_DEPRECATION_MESSAGE = 'Signature usage will be the default for a future release of ActiveMerchant. You should either begin using it, or update your configuration to explicitly disable it (signature_encryptor: none)'
OGONE_STORE_OPTION_DEPRECATION_MESSAGE = "The 'store' option has been renamed to 'billing_id', and its usage is deprecated."
diff --git a/lib/active_merchant/billing/gateways/opp.rb b/lib/active_merchant/billing/gateways/opp.rb
index f685d70ee9b..956fcec81cc 100644
--- a/lib/active_merchant/billing/gateways/opp.rb
+++ b/lib/active_merchant/billing/gateways/opp.rb
@@ -1,112 +1,112 @@
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
class OppGateway < Gateway
- # = Open Payment Platform
- #
- # The Open Payment Platform includes a powerful omni-channel transaction processing API,
- # enabling you to quickly and flexibly build new applications and services on the platform.
- #
- # This plugin enables connectivity to the Open Payment Platform for activemerchant.
- #
- # For any questions or comments please contact support@payon.com
- #
- # == Usage
- #
- # gateway = ActiveMerchant::Billing::OppGateway.new(
- # user_id: 'merchant user id',
- # password: 'password',
- # entity_id: 'entity id',
- # )
- #
- # # set up credit card object as in main ActiveMerchant example
- # creditcard = ActiveMerchant::Billing::CreditCard.new(
- # :type => 'visa',
- # :number => '4242424242424242',
- # :month => 8,
- # :year => 2009,
- # :first_name => 'Bob',
- # :last_name => 'Bobsen'
- # :verification_value: '123')
- #
- # # Request: complete example, including address, billing address, shipping address
- # complete_request_options = {
- # order_id: "your merchant/shop order id", # alternative is to set merchantInvoiceId
- # merchant_transaction_id: "your merchant/shop transaction id",
- # address: address,
- # description: 'Store Purchase - Books',
- # risk_workflow: false,
- # test_mode: 'EXTERNAL' # or 'INTERNAL', valid only for test system
- # create_registration: false, # payment details will be stored on the server an latter can be referenced
- #
- # billing_address: {
- # address1: '123 Test Street',
- # city: 'Test',
- # state: 'TE',
- # zip: 'AB12CD',
- # country: 'GB',
- # },
- # shipping_address: {
- # name: 'Muton DeMicelis',
- # address1: 'My Street On Upiter, Apt 3.14/2.78',
- # city: 'Munich',
- # state: 'Bov',
- # zip: '81675',
- # country: 'DE',
- # },
- # customer: {
- # merchant_customer_id: "your merchant/customer id",
- # givenname: 'Jane',
- # surname: 'Jones',
- # birth_date: '1965-05-01',
- # phone: '(?!?)555-5555',
- # mobile: '(?!?)234-23423',
- # email: 'jane@jones.com',
- # company_name: 'JJ Ltd.',
- # identification_doctype: 'PASSPORT',
- # identification_docid: 'FakeID2342431234123',
- # ip: 101.102.103.104,
- # },
- # }
- #
- # # Request: minimal example
- # minimal_request_options = {
- # order_id: "your merchant/shop order id", # alternative is to set merchantInvoiceId
- # description: 'Store Purchase - Books',
- # }
- #
- # options =
- # # run request
- # response = gateway.purchase(754, creditcard, options) # charge 7,54 EUR
- #
- # response.success? # Check whether the transaction was successful
- # response.error_code # Retrieve the error message - it's mapped to Gateway::STANDARD_ERROR_CODE
- # response.message # Retrieve the message returned by opp
- # response.authorization # Retrieve the unique transaction ID returned by opp
- # response.params['result']['code'] # Retrieve original return code returned by opp server
- #
- # == Errors
- # If transaction is not successful, response.error_code contains mapped to Gateway::STANDARD_ERROR_CODE error message.
- # Complete list of opp error codes can be viewed on https://docs.oppwa.com/
- # Because this list is much bigger than Gateway::STANDARD_ERROR_CODE, only fraction is mapped to Gateway::STANDARD_ERROR_CODE.
- # All other codes are mapped as Gateway::STANDARD_ERROR_CODE[:processing_error], so if this is the case,
- # you may check the original result code from OPP that can be found in response.params['result']['code']
- #
- # == Special features
- # For purchase method risk check can be forced when options[:risk_workflow] = true
- # This will split (on OPP server side) the transaction into two separate transactions: authorize and capture,
- # but capture will be executed only if risk checks are successful.
- #
- # For testing you may use the test account details listed fixtures.yml under opp. It is important to note that there are two test modes available:
- # options[:test_mode]='EXTERNAL' causes test transactions to be forwarded to the processor's test system for 'end-to-end' testing
- # options[:test_mode]='INTERNAL' causes transactions to be sent to opp simulators, which is useful when switching to the live endpoint for connectivity testing.
- # If no test_mode parameter is sent, test_mode=INTERNAL is the default behaviour.
- #
- # Billing Address, Shipping Address, Custom Parameters are supported as described under https://docs.oppwa.com/parameters
- # See complete example above for details.
- #
- # == Tokenization
- # When create_registration is set to true, the payment details will be stored and a token will be returned in registrationId response field,
- # which can subsequently be used to reference the stored payment.
+ # = Open Payment Platform
+ #
+ # The Open Payment Platform includes a powerful omni-channel transaction processing API,
+ # enabling you to quickly and flexibly build new applications and services on the platform.
+ #
+ # This plugin enables connectivity to the Open Payment Platform for activemerchant.
+ #
+ # For any questions or comments please contact support@payon.com
+ #
+ # == Usage
+ #
+ # gateway = ActiveMerchant::Billing::OppGateway.new(
+ # user_id: 'merchant user id',
+ # password: 'password',
+ # entity_id: 'entity id',
+ # )
+ #
+ # # set up credit card object as in main ActiveMerchant example
+ # creditcard = ActiveMerchant::Billing::CreditCard.new(
+ # :type => 'visa',
+ # :number => '4242424242424242',
+ # :month => 8,
+ # :year => 2009,
+ # :first_name => 'Bob',
+ # :last_name => 'Bobsen'
+ # :verification_value: '123')
+ #
+ # # Request: complete example, including address, billing address, shipping address
+ # complete_request_options = {
+ # order_id: "your merchant/shop order id", # alternative is to set merchantInvoiceId
+ # merchant_transaction_id: "your merchant/shop transaction id",
+ # address: address,
+ # description: 'Store Purchase - Books',
+ # risk_workflow: false,
+ # test_mode: 'EXTERNAL' # or 'INTERNAL', valid only for test system
+ # create_registration: false, # payment details will be stored on the server an latter can be referenced
+ #
+ # billing_address: {
+ # address1: '123 Test Street',
+ # city: 'Test',
+ # state: 'TE',
+ # zip: 'AB12CD',
+ # country: 'GB',
+ # },
+ # shipping_address: {
+ # name: 'Muton DeMicelis',
+ # address1: 'My Street On Upiter, Apt 3.14/2.78',
+ # city: 'Munich',
+ # state: 'Bov',
+ # zip: '81675',
+ # country: 'DE',
+ # },
+ # customer: {
+ # merchant_customer_id: "your merchant/customer id",
+ # givenname: 'Jane',
+ # surname: 'Jones',
+ # birth_date: '1965-05-01',
+ # phone: '(?!?)555-5555',
+ # mobile: '(?!?)234-23423',
+ # email: 'jane@jones.com',
+ # company_name: 'JJ Ltd.',
+ # identification_doctype: 'PASSPORT',
+ # identification_docid: 'FakeID2342431234123',
+ # ip: 101.102.103.104,
+ # },
+ # }
+ #
+ # # Request: minimal example
+ # minimal_request_options = {
+ # order_id: "your merchant/shop order id", # alternative is to set merchantInvoiceId
+ # description: 'Store Purchase - Books',
+ # }
+ #
+ # options =
+ # # run request
+ # response = gateway.purchase(754, creditcard, options) # charge 7,54 EUR
+ #
+ # response.success? # Check whether the transaction was successful
+ # response.error_code # Retrieve the error message - it's mapped to Gateway::STANDARD_ERROR_CODE
+ # response.message # Retrieve the message returned by opp
+ # response.authorization # Retrieve the unique transaction ID returned by opp
+ # response.params['result']['code'] # Retrieve original return code returned by opp server
+ #
+ # == Errors
+ # If transaction is not successful, response.error_code contains mapped to Gateway::STANDARD_ERROR_CODE error message.
+ # Complete list of opp error codes can be viewed on https://docs.oppwa.com/
+ # Because this list is much bigger than Gateway::STANDARD_ERROR_CODE, only fraction is mapped to Gateway::STANDARD_ERROR_CODE.
+ # All other codes are mapped as Gateway::STANDARD_ERROR_CODE[:processing_error], so if this is the case,
+ # you may check the original result code from OPP that can be found in response.params['result']['code']
+ #
+ # == Special features
+ # For purchase method risk check can be forced when options[:risk_workflow] = true
+ # This will split (on OPP server side) the transaction into two separate transactions: authorize and capture,
+ # but capture will be executed only if risk checks are successful.
+ #
+ # For testing you may use the test account details listed fixtures.yml under opp. It is important to note that there are two test modes available:
+ # options[:test_mode]='EXTERNAL' causes test transactions to be forwarded to the processor's test system for 'end-to-end' testing
+ # options[:test_mode]='INTERNAL' causes transactions to be sent to opp simulators, which is useful when switching to the live endpoint for connectivity testing.
+ # If no test_mode parameter is sent, test_mode=INTERNAL is the default behaviour.
+ #
+ # Billing Address, Shipping Address, Custom Parameters are supported as described under https://docs.oppwa.com/parameters
+ # See complete example above for details.
+ #
+ # == Tokenization
+ # When create_registration is set to true, the payment details will be stored and a token will be returned in registrationId response field,
+ # which can subsequently be used to reference the stored payment.
self.test_url = 'https://test.oppwa.com/v1/payments'
self.live_url = 'https://oppwa.com/v1/payments'
diff --git a/lib/active_merchant/billing/gateways/payflow_express.rb b/lib/active_merchant/billing/gateways/payflow_express.rb
index 4a967812181..a5061c6a931 100644
--- a/lib/active_merchant/billing/gateways/payflow_express.rb
+++ b/lib/active_merchant/billing/gateways/payflow_express.rb
@@ -4,59 +4,59 @@
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
- # ==General Parameters
- # The following parameters are supported for #setup_authorization, #setup_purchase, #authorize and #purchase transactions. I've read
- # in the docs that they recommend you pass the exact same parameters to both setup and authorize/purchase.
- #
- # This information was gleaned from a mix of:
- # * {PayFlow documentation}[https://developer.paypal.com/docs/classic/payflow/integration-guide/]
- # * previous ActiveMerchant code
- # * trial & error
- #
- # The following parameters are currently supported.
- # [:ip] (opt) Customer IP Address
- # [:order_id] (opt) An order or invoice number. This will be passed through to the Payflow backend at manager.paypal.com, and show up as "Supplier Reference #"
- # [:description] (opt) Order description, shown to buyer (after redirected to PayPal). If Order Line Items are used (see below), then the description is suppressed. This will not be passed through to the Payflow backend.
- # [:billing_address] (opt) See ActiveMerchant::Billing::Gateway for details
- # [:shipping_address] (opt) See ActiveMerchant::Billing::Gateway for details
- # [:currency] (req) Currency of transaction, will be set to USD by default for PayFlow Express if not specified
- # [:email] (opt) Email of buyer; used to pre-fill PayPal login screen
- # [:payer_id] (opt) Unique PayPal buyer account identification number, as returned by details_for request
- # [:token] (req for #authorize & #purchase) Token returned by setup transaction
- # [:no_shipping] (opt) Boolean for whether or not to display shipping address to buyer
- # [:address_override] (opt) Boolean. If true, display shipping address passed by parameters, rather than shipping address on file with PayPal
- # [:allow_note] (opt) Boolean for permitting buyer to add note during checkout. Note contents can be retrieved with details_for transaction
- # [:return_url] (req) URL to which the buyer’s browser is returned after choosing to pay.
- # [:cancel_return_url] (req) URL to which the buyer is returned if the buyer cancels the order.
- # [:notify_url] (opt) Your URL for receiving Instant Payment Notification (IPN) about this transaction.
- # [:comment] (opt) Comment field which will be reported to Payflow backend (at manager.paypal.com) as Comment1
- # [:comment2] (opt) Comment field which will be reported to Payflow backend (at manager.paypal.com) as Comment2
- # [:discount] (opt) Total discounts in cents
- #
- # ==Line Items
- # Support for order line items is available, but has to be enabled on the PayFlow backend. This is what I was told by Todd Sieber at Technical Support:
- #
- # You will need to call Payflow Support at 1-888-883-9770, choose option #2. Request that they update your account in "Pandora" under Product Settings >> PayPal Mark and update the Features Bitmap to 1111111111111112. This is 15 ones and a two.
- #
- # See here[https://www.x.com/message/206214#206214] for the forum discussion (requires login to {x.com}[https://x.com]
- #
- # [:items] (opt) Array of Order Line Items hashes. These are shown to the buyer after redirect to PayPal.
- #
- #
- #
- # The following keys are supported for line items:
- # [:name] Name of line item
- # [:description] Description of line item
- # [:amount] Line Item Amount in Cents (as Integer)
- # [:quantity] Line Item Quantity (default to 1 if left blank)
- #
- # ====Customization of Payment Page
- # [:page_style] (opt) Your URL for receiving Instant Payment Notification (IPN) about this transaction.
- # [:header_image] (opt) Your URL for receiving Instant Payment Notification (IPN) about this transaction.
- # [:background_color] (opt) Your URL for receiving Instant Payment Notification (IPN) about this transaction.
- # ====Additional options for old Checkout Experience, being phased out in 2010 and 2011
- # [:header_background_color] (opt) Your URL for receiving Instant Payment Notification (IPN) about this transaction.
- # [:header_border_color] (opt) Your URL for receiving Instant Payment Notification (IPN) about this transaction.
+ # ==General Parameters
+ # The following parameters are supported for #setup_authorization, #setup_purchase, #authorize and #purchase transactions. I've read
+ # in the docs that they recommend you pass the exact same parameters to both setup and authorize/purchase.
+ #
+ # This information was gleaned from a mix of:
+ # * {PayFlow documentation}[https://developer.paypal.com/docs/classic/payflow/integration-guide/]
+ # * previous ActiveMerchant code
+ # * trial & error
+ #
+ # The following parameters are currently supported.
+ # [:ip] (opt) Customer IP Address
+ # [:order_id] (opt) An order or invoice number. This will be passed through to the Payflow backend at manager.paypal.com, and show up as "Supplier Reference #"
+ # [:description] (opt) Order description, shown to buyer (after redirected to PayPal). If Order Line Items are used (see below), then the description is suppressed. This will not be passed through to the Payflow backend.
+ # [:billing_address] (opt) See ActiveMerchant::Billing::Gateway for details
+ # [:shipping_address] (opt) See ActiveMerchant::Billing::Gateway for details
+ # [:currency] (req) Currency of transaction, will be set to USD by default for PayFlow Express if not specified
+ # [:email] (opt) Email of buyer; used to pre-fill PayPal login screen
+ # [:payer_id] (opt) Unique PayPal buyer account identification number, as returned by details_for request
+ # [:token] (req for #authorize & #purchase) Token returned by setup transaction
+ # [:no_shipping] (opt) Boolean for whether or not to display shipping address to buyer
+ # [:address_override] (opt) Boolean. If true, display shipping address passed by parameters, rather than shipping address on file with PayPal
+ # [:allow_note] (opt) Boolean for permitting buyer to add note during checkout. Note contents can be retrieved with details_for transaction
+ # [:return_url] (req) URL to which the buyer’s browser is returned after choosing to pay.
+ # [:cancel_return_url] (req) URL to which the buyer is returned if the buyer cancels the order.
+ # [:notify_url] (opt) Your URL for receiving Instant Payment Notification (IPN) about this transaction.
+ # [:comment] (opt) Comment field which will be reported to Payflow backend (at manager.paypal.com) as Comment1
+ # [:comment2] (opt) Comment field which will be reported to Payflow backend (at manager.paypal.com) as Comment2
+ # [:discount] (opt) Total discounts in cents
+ #
+ # ==Line Items
+ # Support for order line items is available, but has to be enabled on the PayFlow backend. This is what I was told by Todd Sieber at Technical Support:
+ #
+ # You will need to call Payflow Support at 1-888-883-9770, choose option #2. Request that they update your account in "Pandora" under Product Settings >> PayPal Mark and update the Features Bitmap to 1111111111111112. This is 15 ones and a two.
+ #
+ # See here[https://www.x.com/message/206214#206214] for the forum discussion (requires login to {x.com}[https://x.com]
+ #
+ # [:items] (opt) Array of Order Line Items hashes. These are shown to the buyer after redirect to PayPal.
+ #
+ #
+ #
+ # The following keys are supported for line items:
+ # [:name] Name of line item
+ # [:description] Description of line item
+ # [:amount] Line Item Amount in Cents (as Integer)
+ # [:quantity] Line Item Quantity (default to 1 if left blank)
+ #
+ # ====Customization of Payment Page
+ # [:page_style] (opt) Your URL for receiving Instant Payment Notification (IPN) about this transaction.
+ # [:header_image] (opt) Your URL for receiving Instant Payment Notification (IPN) about this transaction.
+ # [:background_color] (opt) Your URL for receiving Instant Payment Notification (IPN) about this transaction.
+ # ====Additional options for old Checkout Experience, being phased out in 2010 and 2011
+ # [:header_background_color] (opt) Your URL for receiving Instant Payment Notification (IPN) about this transaction.
+ # [:header_border_color] (opt) Your URL for receiving Instant Payment Notification (IPN) about this transaction.
class PayflowExpressGateway < Gateway
diff --git a/test/remote/gateways/remote_itransact_test.rb b/test/remote/gateways/remote_itransact_test.rb
index 3ec0172e6b8..6456398e292 100644
--- a/test/remote/gateways/remote_itransact_test.rb
+++ b/test/remote/gateways/remote_itransact_test.rb
@@ -23,14 +23,14 @@ def test_successful_purchase
assert_nil response.message
end
-# As of March 8, 2012, iTransact does not provide a way to generate unsuccessful transactions through use of a
-# production gateway account in test mode.
-# def test_unsuccessful_purchase
-# assert response = @gateway.purchase(@amount, @credit_card, @options)
-# assert_failure response
-# assert_equal 'DECLINE', response.params['error_category']
-# assert_equal 'Code: NBE001 Your credit card was declined by the credit card processing network. Please use another card and resubmit your transaction.', response.message
-# end
+ # As of March 8, 2012, iTransact does not provide a way to generate unsuccessful transactions through use of a
+ # production gateway account in test mode.
+ # def test_unsuccessful_purchase
+ # assert response = @gateway.purchase(@amount, @credit_card, @options)
+ # assert_failure response
+ # assert_equal 'DECLINE', response.params['error_category']
+ # assert_equal 'Code: NBE001 Your credit card was declined by the credit card processing network. Please use another card and resubmit your transaction.', response.message
+ # end
def test_authorize_and_capture
amount = @amount
@@ -42,13 +42,13 @@ def test_authorize_and_capture
assert_success capture
end
-# As of March 8, 2012, iTransact does not provide a way to generate unsuccessful transactions through use of a
-# production gateway account in test mode.
-# def test_failed_capture
-# assert response = @gateway.capture(@amount, '9999999999')
-# assert_failure response
-# assert_equal 'REPLACE WITH GATEWAY FAILURE MESSAGE', response.message
-# end
+ # As of March 8, 2012, iTransact does not provide a way to generate unsuccessful transactions through use of a
+ # production gateway account in test mode.
+ # def test_failed_capture
+ # assert response = @gateway.capture(@amount, '9999999999')
+ # assert_failure response
+ # assert_equal 'REPLACE WITH GATEWAY FAILURE MESSAGE', response.message
+ # end
def test_authorize_and_void
amount = @amount
@@ -65,11 +65,11 @@ def test_void
assert_success void
end
-# As of Sep 19, 2012, iTransact REQUIRES the total amount for the refund.
-# def test_refund
-# assert refund = @gateway.refund(nil, '9999999999')
-# assert_success refund
-# end
+ # As of Sep 19, 2012, iTransact REQUIRES the total amount for the refund.
+ # def test_refund
+ # assert refund = @gateway.refund(nil, '9999999999')
+ # assert_success refund
+ # end
def test_refund_partial
assert refund = @gateway.refund(555, '9999999999') # $5.55 in cents
diff --git a/test/remote/gateways/remote_opp_test.rb b/test/remote/gateways/remote_opp_test.rb
index 2652c756ad4..8dbdd9d3970 100644
--- a/test/remote/gateways/remote_opp_test.rb
+++ b/test/remote/gateways/remote_opp_test.rb
@@ -18,8 +18,8 @@ def setup
merchant_transaction_id: "active_merchant_test_complete #{time}",
address: address,
description: 'Store Purchase - Books',
-# riskWorkflow: true,
-# testMode: 'EXTERNAL' # or 'INTERNAL', valid only for test system
+ # riskWorkflow: true,
+ # testMode: 'EXTERNAL' # or 'INTERNAL', valid only for test system
billing_address: {
address1: '123 Test Street',
@@ -67,7 +67,7 @@ def setup
@options = @complete_request_options if request_type == 'complete'
end
-# ****************************************** SUCCESSFUL TESTS ******************************************
+ # ****************************************** SUCCESSFUL TESTS ******************************************
def test_successful_purchase
@options[:description] = __method__
@@ -162,7 +162,7 @@ def test_successful_verify
assert_match %r{Request successfully processed}, response.message
end
-# ****************************************** FAILURE TESTS ******************************************
+ # ****************************************** FAILURE TESTS ******************************************
def test_failed_purchase
@options[:description] = __method__
@@ -199,7 +199,7 @@ def test_failed_void
assert_match %r{reversal needs at least one successful transaction}, response.message
end
-# ************************************** TRANSCRIPT SCRUB ******************************************
+ # ************************************** TRANSCRIPT SCRUB ******************************************
def test_transcript_scrubbing
assert @gateway.supports_scrubbing?
diff --git a/test/remote/gateways/remote_paypal_test.rb b/test/remote/gateways/remote_paypal_test.rb
index 0e07e911d9f..44ef35493fb 100644
--- a/test/remote/gateways/remote_paypal_test.rb
+++ b/test/remote/gateways/remote_paypal_test.rb
@@ -194,7 +194,7 @@ def test_successful_transfer
end
def test_failed_transfer
- # paypal allows a max transfer of $10,000
+ # paypal allows a max transfer of $10,000
response = @gateway.transfer(1000001, 'joe@example.com')
assert_failure response
end
diff --git a/test/remote/gateways/remote_world_net_test.rb b/test/remote/gateways/remote_world_net_test.rb
index ece5f935926..14986a28487 100644
--- a/test/remote/gateways/remote_world_net_test.rb
+++ b/test/remote/gateways/remote_world_net_test.rb
@@ -110,9 +110,9 @@ def test_successful_void
assert_success auth
assert void = @gateway.void(auth.authorization)
- # UNSUPPORTED
- # assert_success void
- # assert_equal 'REPLACE WITH SUCCESSFUL VOID MESSAGE', response.message
+ # UNSUPPORTED
+ # assert_success void
+ # assert_equal 'REPLACE WITH SUCCESSFUL VOID MESSAGE', response.message
end
def test_failed_void
diff --git a/test/unit/gateways/eway_managed_test.rb b/test/unit/gateways/eway_managed_test.rb
index 5e8c914b611..abcfa3dd6e0 100644
--- a/test/unit/gateways/eway_managed_test.rb
+++ b/test/unit/gateways/eway_managed_test.rb
@@ -396,7 +396,7 @@ def expected_purchase_request
XML
end
- # Documented here: https://www.eway.com.au/gateway/ManagedPaymentService/managedCreditCardPayment.asmx?op=QueryCustomer
+ # Documented here: https://www.eway.com.au/gateway/ManagedPaymentService/managedCreditCardPayment.asmx?op=QueryCustomer
def expected_retrieve_request
<<-XML
diff --git a/test/unit/gateways/opp_test.rb b/test/unit/gateways/opp_test.rb
index e74552d7ade..5b830c28faa 100644
--- a/test/unit/gateways/opp_test.rb
+++ b/test/unit/gateways/opp_test.rb
@@ -18,8 +18,8 @@ def setup
merchant_transaction_id: "active_merchant_test_complete #{time}",
address: address,
description: 'Store Purchase - Books',
-# risk_workflow: true,
-# test_mode: 'EXTERNAL' # or 'INTERNAL', valid only for test system
+ # risk_workflow: true,
+ # test_mode: 'EXTERNAL' # or 'INTERNAL', valid only for test system
billing_address: {
name: 'Billy Billing',
@@ -67,7 +67,7 @@ def setup
@options = @complete_request_options if request_type == 'complete'
end
-# ****************************************** SUCCESSFUL TESTS ******************************************
+ # ****************************************** SUCCESSFUL TESTS ******************************************
def test_successful_purchase
@gateway.expects(:raw_ssl_request).returns(successful_response('DB', @test_success_id))
response = @gateway.purchase(@amount, @valid_card, @options)
@@ -121,7 +121,7 @@ def test_successful_void
assert void.test?
end
-# ****************************************** FAILURE TESTS ******************************************
+ # ****************************************** FAILURE TESTS ******************************************
def test_failed_purchase
@gateway.expects(:raw_ssl_request).returns(failed_response('DB', @test_failure_id))
response = @gateway.purchase(@amount, @invalid_card, @options)
From c8a8d954ab72c13e94efc601b868568ca06b51bf Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 6 Sep 2018 17:00:43 -0400
Subject: [PATCH 0071/2234] Decide CC brand by lambda, not regex
Previously, we were using pure regexes to determine a credit card brand
based on its BIN. The problem is that you can't reliably determine
BINs based on regexes: Maestro overlaps with MasterCard, Electron just
has a pile of buckets, and so on.
As a first step, remove any reliance on raw regexes, and instead switch
to using lambdas. For now, this is functionally equivalent, but will
allow more precise brand determination in a follow-up commit.
Unit: 3927 tests, 68196 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications
100% passed
---
lib/active_merchant/billing/credit_card.rb | 2 +-
.../billing/credit_card_methods.rb | 52 ++++++++++---------
.../billing/gateways/inspire.rb | 2 +-
.../billing/gateways/smart_ps.rb | 2 +-
4 files changed, 30 insertions(+), 28 deletions(-)
diff --git a/lib/active_merchant/billing/credit_card.rb b/lib/active_merchant/billing/credit_card.rb
index 5a808b6b5b5..caf0903cdf2 100644
--- a/lib/active_merchant/billing/credit_card.rb
+++ b/lib/active_merchant/billing/credit_card.rb
@@ -350,7 +350,7 @@ def validate_card_brand_and_number #:nodoc:
errors = []
if !empty?(brand)
- errors << [:brand, 'is invalid'] if !CreditCard.card_companies.keys.include?(brand)
+ errors << [:brand, 'is invalid'] if !CreditCard.card_companies.include?(brand)
end
if empty?(number)
diff --git a/lib/active_merchant/billing/credit_card_methods.rb b/lib/active_merchant/billing/credit_card_methods.rb
index e61ee859070..4498e68f05e 100644
--- a/lib/active_merchant/billing/credit_card_methods.rb
+++ b/lib/active_merchant/billing/credit_card_methods.rb
@@ -2,21 +2,21 @@ module ActiveMerchant #:nodoc:
module Billing #:nodoc:
# Convenience methods that can be included into a custom Credit Card object, such as an ActiveRecord based Credit Card object.
module CreditCardMethods
- CARD_COMPANIES = {
- 'visa' => /^4\d{12}(\d{3})?(\d{3})?$/,
- 'master' => /^(5[1-5]\d{4}|677189|222[1-9]\d{2}|22[3-9]\d{3}|2[3-6]\d{4}|27[01]\d{3}|2720\d{2})\d{10}$/,
- 'discover' => /^(6011|65\d{2}|64[4-9]\d)\d{12}|(62\d{14})$/,
- 'american_express' => /^3[47]\d{13}$/,
- 'diners_club' => /^3(0[0-5]|[68]\d)\d{11}$/,
- 'jcb' => /^35(28|29|[3-8]\d)\d{12}$/,
- 'switch' => /^6759\d{12}(\d{2,3})?$/,
- 'solo' => /^6767\d{12}(\d{2,3})?$/,
- 'dankort' => /^5019\d{12}$/,
- 'maestro' => /^(5[06-8]|6\d)\d{10,17}$/,
- 'forbrugsforeningen' => /^600722\d{10}$/,
- 'laser' => /^(6304|6706|6709|6771(?!89))\d{8}(\d{4}|\d{6,7})?$/,
- 'sodexo' => /^(606071|603389|606070|606069|606068|600818)\d{8}$/,
- 'vr' => /^(627416|637036)\d{8}$/
+ CARD_COMPANY_DETECTORS = {
+ 'visa' => ->(num) { num =~ /^4\d{12}(\d{3})?(\d{3})?$/ },
+ 'master' => ->(num) { num =~ /^(5[1-5]\d{4}|677189|222[1-9]\d{2}|22[3-9]\d{3}|2[3-6]\d{4}|27[01]\d{3}|2720\d{2})\d{10}$/ },
+ 'discover' => ->(num) { num =~ /^(6011|65\d{2}|64[4-9]\d)\d{12}|(62\d{14})$/ },
+ 'american_express' => ->(num) { num =~ /^3[47]\d{13}$/ },
+ 'diners_club' => ->(num) { num =~ /^3(0[0-5]|[68]\d)\d{11}$/ },
+ 'jcb' => ->(num) { num =~ /^35(28|29|[3-8]\d)\d{12}$/ },
+ 'switch' => ->(num) { num =~ /^6759\d{12}(\d{2,3})?$/ },
+ 'solo' => ->(num) { num =~ /^6767\d{12}(\d{2,3})?$/ },
+ 'dankort' => ->(num) { num =~ /^5019\d{12}$/ },
+ 'maestro' => ->(num) { num =~ /^(5[06-8]|6\d)\d{10,17}$/ },
+ 'forbrugsforeningen' => ->(num) { num =~ /^600722\d{10}$/ },
+ 'laser' => ->(num) { num =~ /^(6304|6706|6709|6771(?!89))\d{8}(\d{4}|\d{6,7})?$/ },
+ 'sodexo' => ->(num) { num =~ /^(606071|603389|606070|606069|606068|600818)\d{8}$/ },
+ 'vr' => ->(num) { num =~ /^(627416|637036)\d{8}$/ }
}
# http://www.barclaycard.co.uk/business/files/bin_rules.pdf
@@ -77,7 +77,14 @@ def valid_card_verification_value?(cvv, brand)
end
def card_verification_value_length(brand)
- brand == 'american_express' ? 4 : 3
+ case brand
+ when 'american_express'
+ 4
+ when 'maestro'
+ 0
+ else
+ 3
+ end
end
def valid_issue_number?(number)
@@ -103,13 +110,8 @@ def valid_number?(number)
valid_checksum?(number)
end
- # Regular expressions for the known card companies.
- #
- # References:
- # - http://en.wikipedia.org/wiki/Credit_card_number
- # - http://www.barclaycardbusiness.co.uk/information_zone/processing/bin_rules.html
def card_companies
- CARD_COMPANIES
+ CARD_COMPANY_DETECTORS.keys
end
# Returns a string containing the brand of card from the list of known information below.
@@ -128,11 +130,11 @@ def card_companies
def brand?(number)
return 'bogus' if valid_test_mode_card_number?(number)
- card_companies.reject { |c,p| c == 'maestro' }.each do |company, pattern|
- return company.dup if number =~ pattern
+ CARD_COMPANY_DETECTORS.reject { |c, f| c == 'maestro' }.each do |company, func|
+ return company.dup if func.call(number)
end
- return 'maestro' if number =~ card_companies['maestro']
+ return 'maestro' if CARD_COMPANY_DETECTORS['maestro'].call(number)
return nil
end
diff --git a/lib/active_merchant/billing/gateways/inspire.rb b/lib/active_merchant/billing/gateways/inspire.rb
index 52122d4d0b6..6c9fae8e265 100644
--- a/lib/active_merchant/billing/gateways/inspire.rb
+++ b/lib/active_merchant/billing/gateways/inspire.rb
@@ -208,7 +208,7 @@ def post_data(action, parameters = {})
def determine_funding_source(source)
case
when source.is_a?(String) then :vault
- when CreditCard.card_companies.keys.include?(card_brand(source)) then :credit_card
+ when CreditCard.card_companies.include?(card_brand(source)) then :credit_card
when card_brand(source) == 'check' then :check
else raise ArgumentError, 'Unsupported funding source provided'
end
diff --git a/lib/active_merchant/billing/gateways/smart_ps.rb b/lib/active_merchant/billing/gateways/smart_ps.rb
index 2b572aaa9d5..b95c4d685e7 100644
--- a/lib/active_merchant/billing/gateways/smart_ps.rb
+++ b/lib/active_merchant/billing/gateways/smart_ps.rb
@@ -272,7 +272,7 @@ def post_data(action, parameters = {})
def determine_funding_source(source)
case
when source.is_a?(String) then :vault
- when CreditCard.card_companies.keys.include?(card_brand(source)) then :credit_card
+ when CreditCard.card_companies.include?(card_brand(source)) then :credit_card
when card_brand(source) == 'check' then :check
else raise ArgumentError, 'Unsupported funding source provided'
end
From 7d1adde3f773382265c21c42f60a15b4e6ba01a6 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Fri, 7 Sep 2018 09:37:25 -0400
Subject: [PATCH 0072/2234] Remove support for Laser
Laser has been shuttered since 2014, and its BIN ranges overlap with
mdoern Maestro and MasterCard ranges. In prep for fixing up those
ranges, remove support for Laser entirely.
---
lib/active_merchant/billing/credit_card.rb | 2 --
.../billing/credit_card_methods.rb | 1 -
.../billing/gateways/citrus_pay.rb | 2 +-
.../billing/gateways/data_cash.rb | 2 +-
.../billing/gateways/realex.rb | 3 +-
lib/active_merchant/billing/gateways/tns.rb | 2 +-
.../billing/gateways/worldpay.rb | 3 +-
.../gateways/worldpay_online_payments.rb | 2 +-
test/unit/credit_card_methods_test.rb | 29 -------------------
test/unit/gateways/data_cash_test.rb | 2 +-
test/unit/gateways/realex_test.rb | 2 +-
11 files changed, 8 insertions(+), 42 deletions(-)
diff --git a/lib/active_merchant/billing/credit_card.rb b/lib/active_merchant/billing/credit_card.rb
index caf0903cdf2..bfbd7875b16 100644
--- a/lib/active_merchant/billing/credit_card.rb
+++ b/lib/active_merchant/billing/credit_card.rb
@@ -20,7 +20,6 @@ module Billing #:nodoc:
# * Dankort
# * Maestro
# * Forbrugsforeningen
- # * Laser
#
# For testing purposes, use the 'bogus' credit card brand. This skips the vast majority of
# validations, allowing you to focus on your core concerns until you're ready to be more concerned
@@ -93,7 +92,6 @@ def number=(value)
# * +'dankort'+
# * +'maestro'+
# * +'forbrugsforeningen'+
- # * +'laser'+
#
# Or, if you wish to test your implementation, +'bogus'+.
#
diff --git a/lib/active_merchant/billing/credit_card_methods.rb b/lib/active_merchant/billing/credit_card_methods.rb
index 4498e68f05e..5ea809ee412 100644
--- a/lib/active_merchant/billing/credit_card_methods.rb
+++ b/lib/active_merchant/billing/credit_card_methods.rb
@@ -14,7 +14,6 @@ module CreditCardMethods
'dankort' => ->(num) { num =~ /^5019\d{12}$/ },
'maestro' => ->(num) { num =~ /^(5[06-8]|6\d)\d{10,17}$/ },
'forbrugsforeningen' => ->(num) { num =~ /^600722\d{10}$/ },
- 'laser' => ->(num) { num =~ /^(6304|6706|6709|6771(?!89))\d{8}(\d{4}|\d{6,7})?$/ },
'sodexo' => ->(num) { num =~ /^(606071|603389|606070|606069|606068|600818)\d{8}$/ },
'vr' => ->(num) { num =~ /^(627416|637036)\d{8}$/ }
}
diff --git a/lib/active_merchant/billing/gateways/citrus_pay.rb b/lib/active_merchant/billing/gateways/citrus_pay.rb
index f8661e23e1d..3b12c5deaf6 100644
--- a/lib/active_merchant/billing/gateways/citrus_pay.rb
+++ b/lib/active_merchant/billing/gateways/citrus_pay.rb
@@ -15,7 +15,7 @@ class CitrusPayGateway < Gateway
self.homepage_url = 'http://www.citruspay.com/'
self.supported_countries = %w(AR AU BR FR DE HK MX NZ SG GB US)
self.default_currency = 'USD'
- self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro, :laser]
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro]
end
end
diff --git a/lib/active_merchant/billing/gateways/data_cash.rb b/lib/active_merchant/billing/gateways/data_cash.rb
index 5c628a1343a..307495c1f3a 100644
--- a/lib/active_merchant/billing/gateways/data_cash.rb
+++ b/lib/active_merchant/billing/gateways/data_cash.rb
@@ -6,7 +6,7 @@ class DataCashGateway < Gateway
self.default_currency = 'GBP'
self.supported_countries = ['GB']
- self.supported_cardtypes = [ :visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro, :switch, :solo, :laser ]
+ self.supported_cardtypes = [ :visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro, :switch, :solo ]
self.homepage_url = 'http://www.datacash.com/'
self.display_name = 'DataCash'
diff --git a/lib/active_merchant/billing/gateways/realex.rb b/lib/active_merchant/billing/gateways/realex.rb
index feec62cb5b1..31ad1aee6d3 100644
--- a/lib/active_merchant/billing/gateways/realex.rb
+++ b/lib/active_merchant/billing/gateways/realex.rb
@@ -28,13 +28,12 @@ class RealexGateway < Gateway
'diners_club' => 'DINERS',
'switch' => 'SWITCH',
'solo' => 'SWITCH',
- 'laser' => 'LASER',
'maestro' => 'MC'
}
self.money_format = :cents
self.default_currency = 'EUR'
- self.supported_cardtypes = [ :visa, :master, :american_express, :diners_club, :switch, :solo, :laser ]
+ self.supported_cardtypes = [ :visa, :master, :american_express, :diners_club, :switch, :solo ]
self.supported_countries = %w(IE GB FR BE NL LU IT US CA ES)
self.homepage_url = 'http://www.realexpayments.com/'
self.display_name = 'Realex'
diff --git a/lib/active_merchant/billing/gateways/tns.rb b/lib/active_merchant/billing/gateways/tns.rb
index 0aa15904050..25ed79306a9 100644
--- a/lib/active_merchant/billing/gateways/tns.rb
+++ b/lib/active_merchant/billing/gateways/tns.rb
@@ -15,7 +15,7 @@ class TnsGateway < Gateway
self.homepage_url = 'http://www.tnsi.com/'
self.supported_countries = %w(AR AU BR FR DE HK MX NZ SG GB US)
self.default_currency = 'USD'
- self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro, :laser]
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro]
end
end
diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb
index 10ea603a8ff..2fe80cf9691 100644
--- a/lib/active_merchant/billing/gateways/worldpay.rb
+++ b/lib/active_merchant/billing/gateways/worldpay.rb
@@ -7,7 +7,7 @@ class WorldpayGateway < Gateway
self.default_currency = 'GBP'
self.money_format = :cents
self.supported_countries = %w(HK GB AU AD AR BE BR CA CH CN CO CR CY CZ DE DK ES FI FR GI GR HU IE IN IT JP LI LU MC MT MY MX NL NO NZ PA PE PL PT SE SG SI SM TR UM VA)
- self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :maestro, :laser, :switch]
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :maestro, :switch]
self.currencies_without_fractions = %w(HUF IDR ISK JPY KRW)
self.currencies_with_three_decimal_places = %w(BHD KWD OMR RSD TND)
self.homepage_url = 'http://www.worldpay.com/'
@@ -20,7 +20,6 @@ class WorldpayGateway < Gateway
'american_express' => 'AMEX-SSL',
'jcb' => 'JCB-SSL',
'maestro' => 'MAESTRO-SSL',
- 'laser' => 'LASER-SSL',
'diners_club' => 'DINERS-SSL',
'switch' => 'MAESTRO-SSL'
}
diff --git a/lib/active_merchant/billing/gateways/worldpay_online_payments.rb b/lib/active_merchant/billing/gateways/worldpay_online_payments.rb
index a4a61f1483b..af7b2bd7aec 100644
--- a/lib/active_merchant/billing/gateways/worldpay_online_payments.rb
+++ b/lib/active_merchant/billing/gateways/worldpay_online_payments.rb
@@ -8,7 +8,7 @@ class WorldpayOnlinePaymentsGateway < Gateway
self.money_format = :cents
self.supported_countries = %w(HK US GB BE CH CZ DE DK ES FI FR GR HU IE IT LU MT NL NO PL PT SE SG TR)
- self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :maestro, :laser, :switch]
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :maestro, :switch]
self.homepage_url = 'http://online.worldpay.com'
self.display_name = 'Worldpay Online Payments'
diff --git a/test/unit/credit_card_methods_test.rb b/test/unit/credit_card_methods_test.rb
index 0854a059065..03dc41f78f2 100644
--- a/test/unit/credit_card_methods_test.rb
+++ b/test/unit/credit_card_methods_test.rb
@@ -125,35 +125,6 @@ def test_should_detect_forbrugsforeningen
assert_equal 'forbrugsforeningen', CreditCard.brand?('6007221000000000')
end
- def test_should_detect_laser_card
- # 16 digits
- assert_equal 'laser', CreditCard.brand?('6304985028090561')
-
- # 18 digits
- assert_equal 'laser', CreditCard.brand?('630498502809056151')
-
- # 19 digits
- assert_equal 'laser', CreditCard.brand?('6304985028090561515')
-
- # 17 digits
- assert_not_equal 'laser', CreditCard.brand?('63049850280905615')
-
- # 15 digits
- assert_not_equal 'laser', CreditCard.brand?('630498502809056')
-
- # Alternate format
- assert_equal 'laser', CreditCard.brand?('6706950000000000000')
-
- # Alternate format (16 digits)
- assert_equal 'laser', CreditCard.brand?('6706123456789012')
-
- # New format (16 digits)
- assert_equal 'laser', CreditCard.brand?('6709123456789012')
-
- # Ulster bank (Ireland) with 12 digits
- assert_equal 'laser', CreditCard.brand?('677117111234')
- end
-
def test_should_detect_sodexo_card
assert_equal 'sodexo', CreditCard.brand?('60606944957644')
end
diff --git a/test/unit/gateways/data_cash_test.rb b/test/unit/gateways/data_cash_test.rb
index 58049ea6724..d5f31a3079d 100644
--- a/test/unit/gateways/data_cash_test.rb
+++ b/test/unit/gateways/data_cash_test.rb
@@ -83,7 +83,7 @@ def test_supported_countries
end
def test_supported_card_types
- assert_equal [ :visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro, :switch, :solo, :laser ], DataCashGateway.supported_cardtypes
+ assert_equal [ :visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro, :switch, :solo ], DataCashGateway.supported_cardtypes
end
def test_purchase_with_missing_order_id_option
diff --git a/test/unit/gateways/realex_test.rb b/test/unit/gateways/realex_test.rb
index 4830137b271..5671331fc0d 100644
--- a/test/unit/gateways/realex_test.rb
+++ b/test/unit/gateways/realex_test.rb
@@ -99,7 +99,7 @@ def test_supported_countries
end
def test_supported_card_types
- assert_equal [ :visa, :master, :american_express, :diners_club, :switch, :solo, :laser ], RealexGateway.supported_cardtypes
+ assert_equal [ :visa, :master, :american_express, :diners_club, :switch, :solo ], RealexGateway.supported_cardtypes
end
def test_avs_result_not_supported
From 5d9291cb226a82543afa73f349ad9e078438b923 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Fri, 7 Sep 2018 09:40:41 -0400
Subject: [PATCH 0073/2234] Fix Maestro and MasterCard detection
There are two pieces to this. First, some of the old Maestro range
is simply wrong at this point (the 50 BIN appears dead), so remove tests
for those ranges and alter the detection not to pick them up. Secondly,
as continuing prep for adding new card types and handling BIN detection
better, convert both MasterCard and Maestro over to proper range
detection, rather than some overly exciting regexes.
Source: https://www.mastercard.us/content/dam/mccom/global/documents/mastercard-rules.pdf,
page 73.
Unit: 3926 tests, 68184 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications
100% passed
---
.../billing/credit_card_methods.rb | 41 +++++++++++--------
test/unit/credit_card_methods_test.rb | 13 +++---
2 files changed, 29 insertions(+), 25 deletions(-)
diff --git a/lib/active_merchant/billing/credit_card_methods.rb b/lib/active_merchant/billing/credit_card_methods.rb
index 5ea809ee412..10878af0395 100644
--- a/lib/active_merchant/billing/credit_card_methods.rb
+++ b/lib/active_merchant/billing/credit_card_methods.rb
@@ -4,7 +4,7 @@ module Billing #:nodoc:
module CreditCardMethods
CARD_COMPANY_DETECTORS = {
'visa' => ->(num) { num =~ /^4\d{12}(\d{3})?(\d{3})?$/ },
- 'master' => ->(num) { num =~ /^(5[1-5]\d{4}|677189|222[1-9]\d{2}|22[3-9]\d{3}|2[3-6]\d{4}|27[01]\d{3}|2720\d{2})\d{10}$/ },
+ 'master' => ->(num) { num.to_s.size == 16 && in_bin_range?(num.to_s.slice(0, 6), MASTERCARD_RANGES) },
'discover' => ->(num) { num =~ /^(6011|65\d{2}|64[4-9]\d)\d{12}|(62\d{14})$/ },
'american_express' => ->(num) { num =~ /^3[47]\d{13}$/ },
'diners_club' => ->(num) { num =~ /^3(0[0-5]|[68]\d)\d{11}$/ },
@@ -12,7 +12,7 @@ module CreditCardMethods
'switch' => ->(num) { num =~ /^6759\d{12}(\d{2,3})?$/ },
'solo' => ->(num) { num =~ /^6767\d{12}(\d{2,3})?$/ },
'dankort' => ->(num) { num =~ /^5019\d{12}$/ },
- 'maestro' => ->(num) { num =~ /^(5[06-8]|6\d)\d{10,17}$/ },
+ 'maestro' => ->(num) { (12..19).include?(num.to_s.size) && in_bin_range?(num.to_s.slice(0, 6), MAESTRO_RANGES) },
'forbrugsforeningen' => ->(num) { num =~ /^600722\d{10}$/ },
'sodexo' => ->(num) { num =~ /^(606071|603389|606070|606069|606068|600818)\d{8}$/ },
'vr' => ->(num) { num =~ /^(627416|637036)\d{8}$/ }
@@ -38,12 +38,31 @@ module CreditCardMethods
(491730..491759),
]
+ # https://www.mastercard.us/content/dam/mccom/global/documents/mastercard-rules.pdf, page 73
+ MASTERCARD_RANGES = [
+ (222100..272099),
+ (510000..559999),
+ ]
+
+ # https://www.mastercard.us/content/dam/mccom/global/documents/mastercard-rules.pdf, page 73
+ MAESTRO_RANGES = [
+ (639000..639099),
+ (670000..679999),
+ ]
+
def self.included(base)
base.extend(ClassMethods)
end
+ def self.in_bin_range?(number, ranges)
+ bin = number.to_i
+ ranges.any? do |range|
+ range.cover?(bin)
+ end
+ end
+
def valid_month?(month)
- (1..12).include?(month.to_i)
+ (1..12).cover?(month.to_i)
end
def credit_card?
@@ -114,27 +133,13 @@ def card_companies
end
# Returns a string containing the brand of card from the list of known information below.
- # Need to check the cards in a particular order, as there is some overlap of the allowable ranges
- #--
- # TODO Refactor this method. We basically need to tighten up the Maestro Regexp.
- #
- # Right now the Maestro regexp overlaps with the MasterCard regexp (IIRC). If we can tighten
- # things up, we can boil this whole thing down to something like...
- #
- # def brand?(number)
- # return 'visa' if valid_test_mode_card_number?(number)
- # card_companies.find([nil]) { |brand, regexp| number =~ regexp }.first.dup
- # end
- #
def brand?(number)
return 'bogus' if valid_test_mode_card_number?(number)
- CARD_COMPANY_DETECTORS.reject { |c, f| c == 'maestro' }.each do |company, func|
+ CARD_COMPANY_DETECTORS.each do |company, func|
return company.dup if func.call(number)
end
- return 'maestro' if CARD_COMPANY_DETECTORS['maestro'].call(number)
-
return nil
end
diff --git a/test/unit/credit_card_methods_test.rb b/test/unit/credit_card_methods_test.rb
index 03dc41f78f2..52ace9f1e9c 100644
--- a/test/unit/credit_card_methods_test.rb
+++ b/test/unit/credit_card_methods_test.rb
@@ -9,9 +9,8 @@ class CreditCard
def maestro_card_numbers
%w[
- 5000000000000000 5099999999999999 5600000000000000
- 5899999999999999 6000000000000000 6999999999999999
- 6761999999999999 6763000000000000 5038999999999999
+ 6390000000000000 6390700000000000 6390990000000000
+ 6761999999999999 6763000000000000 6799999999999999
]
end
@@ -110,14 +109,14 @@ def test_should_detect_maestro_dk_as_maestro
end
def test_should_detect_maestro_cards
- assert_equal 'maestro', CreditCard.brand?('5020100000000000')
+ assert_equal 'maestro', CreditCard.brand?('675675000000000')
maestro_card_numbers.each { |number| assert_equal 'maestro', CreditCard.brand?(number) }
non_maestro_card_numbers.each { |number| assert_not_equal 'maestro', CreditCard.brand?(number) }
end
def test_should_detect_mastercard
- assert_equal 'master', CreditCard.brand?('6771890000000000')
+ assert_equal 'master', CreditCard.brand?('2720890000000000')
assert_equal 'master', CreditCard.brand?('5413031000000000')
end
@@ -139,14 +138,14 @@ def test_should_detect_when_an_argument_brand_does_not_match_calculated_brand
end
def test_detecting_full_range_of_maestro_card_numbers
- maestro = '50000000000'
+ maestro = '63900000000'
assert_equal 11, maestro.length
assert_not_equal 'maestro', CreditCard.brand?(maestro)
while maestro.length < 19
maestro << '0'
- assert_equal 'maestro', CreditCard.brand?(maestro)
+ assert_equal 'maestro', CreditCard.brand?(maestro), "Failed for bin #{maestro}"
end
assert_equal 19, maestro.length
From b4cff8afbf243bca012e6223cc9e9bebaa36ca14 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Mon, 17 Sep 2018 10:22:01 -0400
Subject: [PATCH 0074/2234] Add CHANGELOGs for new credit card behavior
---
CHANGELOG | 3 +++
1 file changed, 3 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index db43b145c8c..9dcf9eb4e7b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -6,6 +6,9 @@
* FirstPay: Expose error code [curiousepic] #2979
* Barclaycard Smartpay: Pass device_fingerprint when specified [dtykocki] #2981
* Komoju: remove no-longer-relevant sandbox URL [miyazawadegica] #2987
+* [POSSIBLE BREAKAGE] Determine credit cards via functions [bpollack] #2983
+* Drop support for Laser cards [bpollack] #2983
+* Improve Maestro card detection [bpollack] #2983
== Version 1.83.0 (August 30, 2018)
* CT Payment: Update How Address is Passed [nfarve] #2960
From 26f1fe5e65c383e6962e2eae4008ee9873b6490a Mon Sep 17 00:00:00 2001
From: dtykocki
Date: Mon, 17 Sep 2018 11:43:49 -0400
Subject: [PATCH 0075/2234] Add ROU alpha3 code for Romania
---
CHANGELOG | 1 +
lib/active_merchant/country.rb | 1 +
test/unit/country_test.rb | 8 ++++++++
3 files changed, 10 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index 9dcf9eb4e7b..8673884f165 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -9,6 +9,7 @@
* [POSSIBLE BREAKAGE] Determine credit cards via functions [bpollack] #2983
* Drop support for Laser cards [bpollack] #2983
* Improve Maestro card detection [bpollack] #2983
+* Add ROU alpha3 code for Romania [dtykocki] #2989
== Version 1.83.0 (August 30, 2018)
* CT Payment: Update How Address is Passed [nfarve] #2960
diff --git a/lib/active_merchant/country.rb b/lib/active_merchant/country.rb
index 46349e63123..82c333fef74 100644
--- a/lib/active_merchant/country.rb
+++ b/lib/active_merchant/country.rb
@@ -246,6 +246,7 @@ def to_s
{ alpha2: 'QA', name: 'Qatar', alpha3: 'QAT', numeric: '634' },
{ alpha2: 'RE', name: 'Reunion', alpha3: 'REU', numeric: '638' },
{ alpha2: 'RO', name: 'Romania', alpha3: 'ROM', numeric: '642' },
+ { alpha2: 'RO', name: 'Romania', alpha3: 'ROU', numeric: '642' },
{ alpha2: 'RU', name: 'Russian Federation', alpha3: 'RUS', numeric: '643' },
{ alpha2: 'RW', name: 'Rwanda', alpha3: 'RWA', numeric: '646' },
{ alpha2: 'BL', name: 'Saint Barthélemy', alpha3: 'BLM', numeric: '652' },
diff --git a/test/unit/country_test.rb b/test/unit/country_test.rb
index a48e73fa36f..3fce8ff16c5 100644
--- a/test/unit/country_test.rb
+++ b/test/unit/country_test.rb
@@ -59,6 +59,14 @@ def test_find_united_kingdom
assert_equal 'GB', country.code(:alpha2).value
end
+ def test_find_romania
+ country = ActiveMerchant::Country.find('ROM')
+ assert_equal 'RO', country.code(:alpha2).value
+
+ country = ActiveMerchant::Country.find('ROU')
+ assert_equal 'RO', country.code(:alpha2).value
+ end
+
def test_raise_on_nil_name
assert_raises(ActiveMerchant::InvalidCountryCodeError) do
ActiveMerchant::Country.find(nil)
From fa8b8ba5776b841c462449de3015d826beb66c9b Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Mon, 17 Sep 2018 13:35:03 -0400
Subject: [PATCH 0076/2234] Begin removing Solo and Switch
Both Switch[1] and Solo[2] were purchased by Maestro, and haven't been
issued since 2002 and 2011, respectively. That's good, because their
old bin ranges overlap with Maestro's current ones (surprise).
We should fully remove Solo and Switch, but some oddities about them
(such as having start dates) has special handling in AM. Some gateways
also run remote tests with old Switch/Solo cards. As a result, fully
removing all Solo and Switch support *immediately* is counterproductive.
This is the minimal amount of change required to properly handle modern
Maestro cards.
[1]: https://en.wikipedia.org/wiki/Switch_(debit_card)
[2]: https://en.wikipedia.org/wiki/Solo_(debit_card)
3922 tests, 68171 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications
100% passed
---
.../billing/credit_card_methods.rb | 2 -
test/unit/credit_card_methods_test.rb | 6 +--
test/unit/credit_card_test.rb | 54 ++-----------------
3 files changed, 8 insertions(+), 54 deletions(-)
diff --git a/lib/active_merchant/billing/credit_card_methods.rb b/lib/active_merchant/billing/credit_card_methods.rb
index 10878af0395..75ce78d25b1 100644
--- a/lib/active_merchant/billing/credit_card_methods.rb
+++ b/lib/active_merchant/billing/credit_card_methods.rb
@@ -9,8 +9,6 @@ module CreditCardMethods
'american_express' => ->(num) { num =~ /^3[47]\d{13}$/ },
'diners_club' => ->(num) { num =~ /^3(0[0-5]|[68]\d)\d{11}$/ },
'jcb' => ->(num) { num =~ /^35(28|29|[3-8]\d)\d{12}$/ },
- 'switch' => ->(num) { num =~ /^6759\d{12}(\d{2,3})?$/ },
- 'solo' => ->(num) { num =~ /^6767\d{12}(\d{2,3})?$/ },
'dankort' => ->(num) { num =~ /^5019\d{12}$/ },
'maestro' => ->(num) { (12..19).include?(num.to_s.size) && in_bin_range?(num.to_s.slice(0, 6), MAESTRO_RANGES) },
'forbrugsforeningen' => ->(num) { num =~ /^600722\d{10}$/ },
diff --git a/test/unit/credit_card_methods_test.rb b/test/unit/credit_card_methods_test.rb
index 52ace9f1e9c..829eb0214c2 100644
--- a/test/unit/credit_card_methods_test.rb
+++ b/test/unit/credit_card_methods_test.rb
@@ -172,19 +172,19 @@ def test_matching_invalid_card
def test_16_digit_maestro_uk
number = '6759000000000000'
assert_equal 16, number.length
- assert_equal 'switch', CreditCard.brand?(number)
+ assert_equal 'maestro', CreditCard.brand?(number)
end
def test_18_digit_maestro_uk
number = '675900000000000000'
assert_equal 18, number.length
- assert_equal 'switch', CreditCard.brand?(number)
+ assert_equal 'maestro', CreditCard.brand?(number)
end
def test_19_digit_maestro_uk
number = '6759000000000000000'
assert_equal 19, number.length
- assert_equal 'switch', CreditCard.brand?(number)
+ assert_equal 'maestro', CreditCard.brand?(number)
end
def test_electron_cards
diff --git a/test/unit/credit_card_test.rb b/test/unit/credit_card_test.rb
index b39600376c9..eb3c77d648b 100644
--- a/test/unit/credit_card_test.rb
+++ b/test/unit/credit_card_test.rb
@@ -3,8 +3,8 @@
class CreditCardTest < Test::Unit::TestCase
def setup
CreditCard.require_verification_value = false
- @visa = credit_card('4779139500118580', :brand => 'visa')
- @solo = credit_card('676700000000000000', :brand => 'solo', :issue_number => '01')
+ @visa = credit_card('4779139500118580', brand: 'visa')
+ @maestro = credit_card('676700000000000000', brand: 'maestro', verification_value: '')
end
def teardown
@@ -32,8 +32,8 @@ def test_should_be_a_valid_visa_card
assert_valid @visa
end
- def test_should_be_a_valid_solo_card
- assert_valid @solo
+ def test_should_be_a_valid_maestro_card
+ assert_valid @maestro
end
def test_cards_with_empty_names_should_not_be_valid
@@ -167,12 +167,6 @@ def test_expired_card_should_have_one_error_on_year
assert_match(/expired/, errors[:year].first)
end
- def test_should_be_valid_with_start_month_and_year_as_string
- @solo.start_month = '2'
- @solo.start_year = '2007'
- assert_valid @solo
- end
-
def test_should_identify_wrong_card_brand
c = credit_card(:brand => 'master')
assert_not_valid c
@@ -242,44 +236,6 @@ def test_bogus_cards_are_not_valid_without_verification_value
assert_not_valid card
end
- def test_should_require_valid_start_date_for_solo_or_switch
- @solo.start_month = nil
- @solo.start_year = nil
- @solo.issue_number = nil
-
- errors = assert_not_valid @solo
- assert errors[:start_month]
- assert errors[:start_year]
- assert errors[:issue_number]
-
- @solo.start_month = 2
- @solo.start_year = 2007
- assert_valid @solo
- end
-
- def test_should_require_a_valid_issue_number_for_solo_or_switch
- @solo.start_month = nil
- @solo.start_year = 2005
- @solo.issue_number = nil
-
- errors = assert_not_valid @solo
- assert errors[:start_month]
- assert_equal ['cannot be empty'], errors[:issue_number]
-
- @solo.issue_number = 3
- assert_valid @solo
- end
-
- def test_should_require_a_validate_non_empty_issue_number_for_solo_or_switch
- @solo.issue_number = 'invalid'
-
- errors = assert_not_valid @solo
- assert_equal ['is invalid'], errors[:issue_number]
-
- @solo.issue_number = 3
- assert_valid @solo
- end
-
def test_should_return_last_four_digits_of_card_number
ccn = CreditCard.new(:number => '4779139500118580')
assert_equal '8580', ccn.last_digits
@@ -437,7 +393,7 @@ def test_brand_is_aliased_as_type
assert_equal @visa.type, @visa.brand
end
assert_deprecation_warning('CreditCard#type is deprecated and will be removed from a future release of ActiveMerchant. Please use CreditCard#brand instead.') do
- assert_equal @solo.type, @solo.brand
+ assert_equal @maestro.type, @maestro.brand
end
end
From 094c141dd15c538f423c8532229e9f602b22c6a8 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Mon, 17 Sep 2018 13:51:20 -0400
Subject: [PATCH 0077/2234] Remove the rest of Solo and Sripe support
3922 tests, 68169 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/credit_card.rb | 32 +------------------
.../billing/gateways/axcessms.rb | 2 +-
.../billing/gateways/card_save.rb | 2 +-
.../billing/gateways/card_stream.rb | 2 +-
.../billing/gateways/data_cash.rb | 12 +------
lib/active_merchant/billing/gateways/dibs.rb | 4 ---
.../billing/gateways/iridium.rb | 2 +-
.../billing/gateways/optimal_payment.rb | 4 +--
.../gateways/payflow/payflow_common_api.rb | 2 --
.../billing/gateways/payflow_uk.rb | 2 +-
.../billing/gateways/paypal.rb | 8 -----
.../billing/gateways/psl_card.rb | 4 +--
.../billing/gateways/realex.rb | 6 ++--
.../billing/gateways/sage_pay.rb | 4 +--
.../billing/gateways/so_easy_pay.rb | 2 +-
lib/active_merchant/billing/gateways/telr.rb | 2 +-
.../remote/gateways/remote_payflow_uk_test.rb | 20 ------------
test/unit/credit_card_test.rb | 5 ---
test/unit/gateways/data_cash_test.rb | 2 +-
test/unit/gateways/payflow_test.rb | 16 +---------
test/unit/gateways/payflow_uk_test.rb | 2 +-
test/unit/gateways/payment_express_test.rb | 2 +-
test/unit/gateways/psl_card_test.rb | 2 +-
test/unit/gateways/realex_test.rb | 2 +-
25 files changed, 22 insertions(+), 120 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 8673884f165..6ddf07f77f4 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -10,6 +10,7 @@
* Drop support for Laser cards [bpollack] #2983
* Improve Maestro card detection [bpollack] #2983
* Add ROU alpha3 code for Romania [dtykocki] #2989
+* [POSSIBLE BREAKAGE] Drop support for Solo and Switch cards [bpollack] #2991
== Version 1.83.0 (August 30, 2018)
* CT Payment: Update How Address is Passed [nfarve] #2960
diff --git a/lib/active_merchant/billing/credit_card.rb b/lib/active_merchant/billing/credit_card.rb
index bfbd7875b16..98ca5a522cc 100644
--- a/lib/active_merchant/billing/credit_card.rb
+++ b/lib/active_merchant/billing/credit_card.rb
@@ -15,8 +15,6 @@ module Billing #:nodoc:
# * American Express
# * Diner's Club
# * JCB
- # * Switch
- # * Solo
# * Dankort
# * Maestro
# * Forbrugsforeningen
@@ -87,8 +85,6 @@ def number=(value)
# * +'american_express'+
# * +'diners_club'+
# * +'jcb'+
- # * +'switch'+
- # * +'solo'+
# * +'dankort'+
# * +'maestro'+
# * +'forbrugsforeningen'+
@@ -119,10 +115,6 @@ def brand=(value)
# @return [String]
attr_accessor :last_name
- # Required for Switch / Solo cards
- attr_reader :start_month, :start_year
- attr_accessor :issue_number
-
# Returns or sets the card verification value.
#
# This attribute is optional but recommended. The verification value is
@@ -301,8 +293,7 @@ def validate
errors_hash(
errors +
- validate_card_brand_and_number +
- validate_switch_or_solo_attributes
+ validate_card_brand_and_number
)
end
@@ -377,27 +368,6 @@ def validate_verification_value #:nodoc:
errors
end
- def validate_switch_or_solo_attributes #:nodoc:
- errors = []
-
- if %w[switch solo].include?(brand)
- valid_start_month = valid_month?(start_month)
- valid_start_year = valid_start_year?(start_year)
-
- if((!valid_start_month || !valid_start_year) && !valid_issue_number?(issue_number))
- if empty?(issue_number)
- errors << [:issue_number, 'cannot be empty']
- errors << [:start_month, 'is invalid'] if !valid_start_month
- errors << [:start_year, 'is invalid'] if !valid_start_year
- else
- errors << [:issue_number, 'is invalid'] if !valid_issue_number?(issue_number)
- end
- end
- end
-
- errors
- end
-
class ExpiryDate #:nodoc:
attr_reader :month, :year
def initialize(month, year)
diff --git a/lib/active_merchant/billing/gateways/axcessms.rb b/lib/active_merchant/billing/gateways/axcessms.rb
index d45dde62713..59c8edaa4ea 100644
--- a/lib/active_merchant/billing/gateways/axcessms.rb
+++ b/lib/active_merchant/billing/gateways/axcessms.rb
@@ -8,7 +8,7 @@ class AxcessmsGateway < Gateway
GI GR HR HU IE IL IM IS IT LI LT LU LV MC MT MX NL
NO PL PT RO RU SE SI SK TR US VA)
- self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :maestro, :solo]
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :maestro]
self.homepage_url = 'http://www.axcessms.com/'
self.display_name = 'Axcess MS'
diff --git a/lib/active_merchant/billing/gateways/card_save.rb b/lib/active_merchant/billing/gateways/card_save.rb
index 7bd9ee8e4d2..2e7b29b304d 100644
--- a/lib/active_merchant/billing/gateways/card_save.rb
+++ b/lib/active_merchant/billing/gateways/card_save.rb
@@ -6,7 +6,7 @@ class CardSaveGateway < IridiumGateway
self.money_format = :cents
self.default_currency = 'GBP'
- self.supported_cardtypes = [ :visa, :switch, :maestro, :master, :solo, :american_express, :jcb ]
+ self.supported_cardtypes = [ :visa, :switch, :maestro, :master, :american_express, :jcb ]
self.supported_countries = [ 'GB' ]
self.homepage_url = 'http://www.cardsave.net/'
self.display_name = 'CardSave'
diff --git a/lib/active_merchant/billing/gateways/card_stream.rb b/lib/active_merchant/billing/gateways/card_stream.rb
index 3659ef360a9..32766f81ddb 100644
--- a/lib/active_merchant/billing/gateways/card_stream.rb
+++ b/lib/active_merchant/billing/gateways/card_stream.rb
@@ -8,7 +8,7 @@ class CardStreamGateway < Gateway
self.money_format = :cents
self.default_currency = 'GBP'
self.supported_countries = ['GB', 'US', 'CH', 'SE', 'SG', 'NO', 'JP', 'IS', 'HK', 'NL', 'CZ', 'CA', 'AU']
- self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :discover, :jcb, :maestro, :solo, :switch]
+ self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :discover, :jcb, :maestro]
self.homepage_url = 'http://www.cardstream.com/'
self.display_name = 'CardStream'
diff --git a/lib/active_merchant/billing/gateways/data_cash.rb b/lib/active_merchant/billing/gateways/data_cash.rb
index 307495c1f3a..179aa12e194 100644
--- a/lib/active_merchant/billing/gateways/data_cash.rb
+++ b/lib/active_merchant/billing/gateways/data_cash.rb
@@ -6,7 +6,7 @@ class DataCashGateway < Gateway
self.default_currency = 'GBP'
self.supported_countries = ['GB']
- self.supported_cardtypes = [ :visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro, :switch, :solo ]
+ self.supported_cardtypes = [ :visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro ]
self.homepage_url = 'http://www.datacash.com/'
self.display_name = 'DataCash'
@@ -220,16 +220,6 @@ def add_credit_card(xml, credit_card, address)
xml.tag! :pan, credit_card.number
xml.tag! :expirydate, format_date(credit_card.month, credit_card.year)
- # optional values - for Solo etc
- if [ 'switch', 'solo' ].include?(card_brand(credit_card).to_s)
-
- xml.tag! :issuenumber, credit_card.issue_number unless credit_card.issue_number.blank?
-
- if !credit_card.start_month.blank? && !credit_card.start_year.blank?
- xml.tag! :startdate, format_date(credit_card.start_month, credit_card.start_year)
- end
- end
-
xml.tag! :Cv2Avs do
xml.tag! :cv2, credit_card.verification_value if credit_card.verification_value?
if address
diff --git a/lib/active_merchant/billing/gateways/dibs.rb b/lib/active_merchant/billing/gateways/dibs.rb
index ef5dfd425c2..5505a34f774 100644
--- a/lib/active_merchant/billing/gateways/dibs.rb
+++ b/lib/active_merchant/billing/gateways/dibs.rb
@@ -110,10 +110,6 @@ def add_payment_method(post, payment_method, options)
post[:cvc] = payment_method.verification_value if payment_method.verification_value
post[:expYear] = format(payment_method.year, :two_digits)
post[:expMonth] = payment_method.month
-
- post[:startMonth] = payment_method.start_month if payment_method.start_month
- post[:startYear] = payment_method.start_year if payment_method.start_year
- post[:issueNumber] = payment_method.issue_number if payment_method.issue_number
post[:clientIp] = options[:ip] || '127.0.0.1'
post[:test] = true if test?
end
diff --git a/lib/active_merchant/billing/gateways/iridium.rb b/lib/active_merchant/billing/gateways/iridium.rb
index 102a1677029..95c25379ec3 100644
--- a/lib/active_merchant/billing/gateways/iridium.rb
+++ b/lib/active_merchant/billing/gateways/iridium.rb
@@ -15,7 +15,7 @@ class IridiumGateway < Gateway
self.money_format = :cents
# The card types supported by the payment gateway
- self.supported_cardtypes = [:visa, :master, :american_express, :discover, :maestro, :jcb, :solo, :diners_club]
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :maestro, :jcb, :diners_club]
# The homepage URL of the gateway
self.homepage_url = 'http://www.iridiumcorp.co.uk/'
diff --git a/lib/active_merchant/billing/gateways/optimal_payment.rb b/lib/active_merchant/billing/gateways/optimal_payment.rb
index 2641cf7994a..c4ff212c018 100644
--- a/lib/active_merchant/billing/gateways/optimal_payment.rb
+++ b/lib/active_merchant/billing/gateways/optimal_payment.rb
@@ -10,7 +10,7 @@ class OptimalPaymentGateway < Gateway
'NL', 'NO', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE', 'CH']
# The card types supported by the payment gateway
- self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :solo] # :switch?
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club]
# The homepage URL of the gateway
self.homepage_url = 'http://www.optimalpayments.com/'
@@ -320,8 +320,6 @@ def card_type(key)
'american_express'=> 'AM',
'discover' => 'DI',
'diners_club' => 'DC',
- #'switch' => '',
- 'solo' => 'SO'
}[key]
end
diff --git a/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb b/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb
index e8258844aec..8aec158e79c 100644
--- a/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb
+++ b/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb
@@ -43,8 +43,6 @@ def self.included(base)
:american_express => 'Amex',
:jcb => 'JCB',
:diners_club => 'DinersClub',
- :switch => 'Switch',
- :solo => 'Solo'
}
TRANSACTIONS = {
diff --git a/lib/active_merchant/billing/gateways/payflow_uk.rb b/lib/active_merchant/billing/gateways/payflow_uk.rb
index b8c3a711a44..7d67610438f 100644
--- a/lib/active_merchant/billing/gateways/payflow_uk.rb
+++ b/lib/active_merchant/billing/gateways/payflow_uk.rb
@@ -11,7 +11,7 @@ def express
@express ||= PayflowExpressUkGateway.new(@options)
end
- self.supported_cardtypes = [:visa, :master, :american_express, :discover, :solo, :switch]
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover]
self.supported_countries = ['GB']
self.homepage_url = 'https://www.paypal.com/uk/webapps/mpp/pro'
self.display_name = 'PayPal Payments Pro (UK)'
diff --git a/lib/active_merchant/billing/gateways/paypal.rb b/lib/active_merchant/billing/gateways/paypal.rb
index 4ca95d13f48..74769690810 100644
--- a/lib/active_merchant/billing/gateways/paypal.rb
+++ b/lib/active_merchant/billing/gateways/paypal.rb
@@ -81,12 +81,6 @@ def add_credit_card(xml, credit_card, address, options)
xml.tag! 'n2:ExpYear', format(credit_card.year, :four_digits)
xml.tag! 'n2:CVV2', credit_card.verification_value unless credit_card.verification_value.blank?
- if [ 'switch', 'solo' ].include?(card_brand(credit_card).to_s)
- xml.tag! 'n2:StartMonth', format(credit_card.start_month, :two_digits) unless credit_card.start_month.blank?
- xml.tag! 'n2:StartYear', format(credit_card.start_year, :four_digits) unless credit_card.start_year.blank?
- xml.tag! 'n2:IssueNumber', format(credit_card.issue_number, :two_digits) unless credit_card.issue_number.blank?
- end
-
xml.tag! 'n2:CardOwner' do
xml.tag! 'n2:PayerName' do
xml.tag! 'n2:FirstName', credit_card.first_name
@@ -110,8 +104,6 @@ def credit_card_type(type)
when 'master' then 'MasterCard'
when 'discover' then 'Discover'
when 'american_express' then 'Amex'
- when 'switch' then 'Switch'
- when 'solo' then 'Solo'
end
end
diff --git a/lib/active_merchant/billing/gateways/psl_card.rb b/lib/active_merchant/billing/gateways/psl_card.rb
index 4bd7f56f977..78fa1a97c60 100644
--- a/lib/active_merchant/billing/gateways/psl_card.rb
+++ b/lib/active_merchant/billing/gateways/psl_card.rb
@@ -17,11 +17,11 @@ class PslCardGateway < Gateway
self.default_currency = 'GBP'
self.supported_countries = ['GB']
- # Visa Credit, Visa Debit, Mastercard, Maestro, Solo, Electron,
+ # Visa Credit, Visa Debit, Mastercard, Maestro, Electron,
# American Express, Diners Club, JCB, International Maestro,
# Style, Clydesdale Financial Services, Other
- self.supported_cardtypes = [ :visa, :master, :american_express, :diners_club, :jcb, :switch, :solo, :maestro ]
+ self.supported_cardtypes = [ :visa, :master, :american_express, :diners_club, :jcb, :maestro ]
self.homepage_url = 'http://www.paymentsolutionsltd.com/'
self.display_name = 'PSL Payment Solutions'
diff --git a/lib/active_merchant/billing/gateways/realex.rb b/lib/active_merchant/billing/gateways/realex.rb
index 31ad1aee6d3..deb1e2556a3 100644
--- a/lib/active_merchant/billing/gateways/realex.rb
+++ b/lib/active_merchant/billing/gateways/realex.rb
@@ -26,14 +26,12 @@ class RealexGateway < Gateway
'visa' => 'VISA',
'american_express' => 'AMEX',
'diners_club' => 'DINERS',
- 'switch' => 'SWITCH',
- 'solo' => 'SWITCH',
'maestro' => 'MC'
}
self.money_format = :cents
self.default_currency = 'EUR'
- self.supported_cardtypes = [ :visa, :master, :american_express, :diners_club, :switch, :solo ]
+ self.supported_cardtypes = [ :visa, :master, :american_express, :diners_club ]
self.supported_countries = %w(IE GB FR BE NL LU IT US CA ES)
self.homepage_url = 'http://www.realexpayments.com/'
self.display_name = 'Realex'
@@ -244,7 +242,7 @@ def add_card(xml, credit_card)
xml.tag! 'expdate', expiry_date(credit_card)
xml.tag! 'chname', credit_card.name
xml.tag! 'type', CARD_MAPPING[card_brand(credit_card).to_s]
- xml.tag! 'issueno', credit_card.issue_number
+ xml.tag! 'issueno', ''
xml.tag! 'cvn' do
xml.tag! 'number', credit_card.verification_value
xml.tag! 'presind', (options['presind'] || (credit_card.verification_value? ? 1 : nil))
diff --git a/lib/active_merchant/billing/gateways/sage_pay.rb b/lib/active_merchant/billing/gateways/sage_pay.rb
index b78c2d6f6b6..d46d338a741 100644
--- a/lib/active_merchant/billing/gateways/sage_pay.rb
+++ b/lib/active_merchant/billing/gateways/sage_pay.rb
@@ -28,8 +28,6 @@ class SagePayGateway < Gateway
:visa => 'VISA',
:master => 'MC',
:delta => 'DELTA',
- :solo => 'SOLO',
- :switch => 'MAESTRO',
:maestro => 'MAESTRO',
:american_express => 'AMEX',
:electron => 'UKE',
@@ -71,7 +69,7 @@ class SagePayGateway < Gateway
recipient_dob: :FIRecipientDoB
}
- self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :switch, :solo, :maestro, :diners_club]
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :maestro, :diners_club]
self.supported_countries = ['GB', 'IE']
self.default_currency = 'GBP'
diff --git a/lib/active_merchant/billing/gateways/so_easy_pay.rb b/lib/active_merchant/billing/gateways/so_easy_pay.rb
index cb80073bff0..5cc6eeaa1c6 100644
--- a/lib/active_merchant/billing/gateways/so_easy_pay.rb
+++ b/lib/active_merchant/billing/gateways/so_easy_pay.rb
@@ -10,7 +10,7 @@ class SoEasyPayGateway < Gateway
'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE', 'GB',
'IS', 'NO', 'CH'
]
- self.supported_cardtypes = [:visa, :master, :american_express, :discover, :maestro, :jcb, :solo, :diners_club]
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :maestro, :jcb, :diners_club]
self.homepage_url = 'http://www.soeasypay.com/'
self.display_name = 'SoEasyPay'
diff --git a/lib/active_merchant/billing/gateways/telr.rb b/lib/active_merchant/billing/gateways/telr.rb
index b7cff295ac8..f1a38ef889d 100644
--- a/lib/active_merchant/billing/gateways/telr.rb
+++ b/lib/active_merchant/billing/gateways/telr.rb
@@ -11,7 +11,7 @@ class TelrGateway < Gateway
self.supported_countries = ['AE', 'IN', 'SA']
self.default_currency = 'AED'
self.money_format = :dollars
- self.supported_cardtypes = [:visa, :master, :american_express, :maestro, :solo, :jcb]
+ self.supported_cardtypes = [:visa, :master, :american_express, :maestro, :jcb]
CVC_CODE_TRANSLATOR = {
'Y' => 'M',
diff --git a/test/remote/gateways/remote_payflow_uk_test.rb b/test/remote/gateways/remote_payflow_uk_test.rb
index 5db52700d1b..5242f8f813a 100644
--- a/test/remote/gateways/remote_payflow_uk_test.rb
+++ b/test/remote/gateways/remote_payflow_uk_test.rb
@@ -16,26 +16,6 @@ def setup
:verification_value => '000',
:brand => 'master'
)
-
- @solo = CreditCard.new(
- :brand => 'solo',
- :number => '6334900000000005',
- :month => Time.now.month,
- :year => Time.now.year + 1,
- :first_name => 'Test',
- :last_name => 'Mensch',
- :issue_number => '01'
- )
-
- @switch = CreditCard.new(
- :brand => 'switch',
- :number => '5641820000000005',
- :verification_value => '000',
- :month => 1,
- :year => 2008,
- :first_name => 'Fred',
- :last_name => 'Brooks'
- )
@options = {
:billing_address => {
diff --git a/test/unit/credit_card_test.rb b/test/unit/credit_card_test.rb
index eb3c77d648b..5c2f1eb6b50 100644
--- a/test/unit/credit_card_test.rb
+++ b/test/unit/credit_card_test.rb
@@ -414,11 +414,6 @@ def test_month_and_year_are_immediately_converted_to_integers
assert_nil card.month
card.year = nil
assert_nil card.year
-
- card.start_month = '1'
- assert_equal 1, card.start_month
- card.start_year = '1'
- assert_equal 1, card.start_year
end
def test_should_report_as_emv_if_icc_data_present
diff --git a/test/unit/gateways/data_cash_test.rb b/test/unit/gateways/data_cash_test.rb
index d5f31a3079d..e7443c2d195 100644
--- a/test/unit/gateways/data_cash_test.rb
+++ b/test/unit/gateways/data_cash_test.rb
@@ -83,7 +83,7 @@ def test_supported_countries
end
def test_supported_card_types
- assert_equal [ :visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro, :switch, :solo ], DataCashGateway.supported_cardtypes
+ assert_equal [ :visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro ], DataCashGateway.supported_cardtypes
end
def test_purchase_with_missing_order_id_option
diff --git a/test/unit/gateways/payflow_test.rb b/test/unit/gateways/payflow_test.rb
index 2c7c86c9095..ef6e449fbce 100644
--- a/test/unit/gateways/payflow_test.rb
+++ b/test/unit/gateways/payflow_test.rb
@@ -364,25 +364,11 @@ def test_recurring_profile_payment_history_inquiry_contains_the_proper_xml
assert_match %r(Y 'switch',
- :issue_number => 1
- )
-
- @gateway.send(:add_credit_card, xml, credit_card)
- doc = REXML::Document.new(xml.target!)
- node = REXML::XPath.first(doc, '/Card/ExtData')
- assert_equal '01', node.attributes['Value']
- end
-
def test_add_credit_card_with_three_d_secure
xml = Builder::XmlMarkup.new
credit_card = credit_card(
'5641820000000005',
- :brand => 'switch',
- :issue_number => 1
+ :brand => 'maestro'
)
@gateway.send(:add_credit_card, xml, credit_card, @options.merge(three_d_secure_option))
diff --git a/test/unit/gateways/payflow_uk_test.rb b/test/unit/gateways/payflow_uk_test.rb
index 53c41fcfd20..e7adc1b7fd9 100644
--- a/test/unit/gateways/payflow_uk_test.rb
+++ b/test/unit/gateways/payflow_uk_test.rb
@@ -25,6 +25,6 @@ def test_supported_countries
end
def test_supported_card_types
- assert_equal [:visa, :master, :american_express, :discover, :solo, :switch], PayflowUkGateway.supported_cardtypes
+ assert_equal [:visa, :master, :american_express, :discover], PayflowUkGateway.supported_cardtypes
end
end
diff --git a/test/unit/gateways/payment_express_test.rb b/test/unit/gateways/payment_express_test.rb
index 5b8b9dfbebe..54489838560 100644
--- a/test/unit/gateways/payment_express_test.rb
+++ b/test/unit/gateways/payment_express_test.rb
@@ -11,7 +11,7 @@ def setup
@visa = credit_card
- @solo = credit_card('6334900000000005', :brand => 'solo', :issue_number => '01')
+ @solo = credit_card('6334900000000005', :brand => 'maestro')
@options = {
:order_id => generate_unique_id,
diff --git a/test/unit/gateways/psl_card_test.rb b/test/unit/gateways/psl_card_test.rb
index 64d62400301..c37f92531ed 100644
--- a/test/unit/gateways/psl_card_test.rb
+++ b/test/unit/gateways/psl_card_test.rb
@@ -36,7 +36,7 @@ def test_supported_countries
end
def test_supported_card_types
- assert_equal [ :visa, :master, :american_express, :diners_club, :jcb, :switch, :solo, :maestro ], PslCardGateway.supported_cardtypes
+ assert_equal [ :visa, :master, :american_express, :diners_club, :jcb, :maestro ], PslCardGateway.supported_cardtypes
end
def test_avs_result
diff --git a/test/unit/gateways/realex_test.rb b/test/unit/gateways/realex_test.rb
index 5671331fc0d..abb11a2c16b 100644
--- a/test/unit/gateways/realex_test.rb
+++ b/test/unit/gateways/realex_test.rb
@@ -99,7 +99,7 @@ def test_supported_countries
end
def test_supported_card_types
- assert_equal [ :visa, :master, :american_express, :diners_club, :switch, :solo ], RealexGateway.supported_cardtypes
+ assert_equal [ :visa, :master, :american_express, :diners_club ], RealexGateway.supported_cardtypes
end
def test_avs_result_not_supported
From 2bc749340f8988adaa8a7c90db5dd81d413a2a5e Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Mon, 17 Sep 2018 11:31:53 -0400
Subject: [PATCH 0078/2234] Assume CC numbers are strings
We honestly should be doing this anyway; now, enforce it, and take
advantage of it to cut down on string conversions.
Follow-up to conversation in #2983
3926 tests, 68184 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications
100% passed
---
.../billing/credit_card_methods.rb | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/lib/active_merchant/billing/credit_card_methods.rb b/lib/active_merchant/billing/credit_card_methods.rb
index 75ce78d25b1..032514bac57 100644
--- a/lib/active_merchant/billing/credit_card_methods.rb
+++ b/lib/active_merchant/billing/credit_card_methods.rb
@@ -4,13 +4,13 @@ module Billing #:nodoc:
module CreditCardMethods
CARD_COMPANY_DETECTORS = {
'visa' => ->(num) { num =~ /^4\d{12}(\d{3})?(\d{3})?$/ },
- 'master' => ->(num) { num.to_s.size == 16 && in_bin_range?(num.to_s.slice(0, 6), MASTERCARD_RANGES) },
+ 'master' => ->(num) { num&.size == 16 && in_bin_range?(num.slice(0, 6), MASTERCARD_RANGES) },
'discover' => ->(num) { num =~ /^(6011|65\d{2}|64[4-9]\d)\d{12}|(62\d{14})$/ },
'american_express' => ->(num) { num =~ /^3[47]\d{13}$/ },
'diners_club' => ->(num) { num =~ /^3(0[0-5]|[68]\d)\d{11}$/ },
'jcb' => ->(num) { num =~ /^35(28|29|[3-8]\d)\d{12}$/ },
'dankort' => ->(num) { num =~ /^5019\d{12}$/ },
- 'maestro' => ->(num) { (12..19).include?(num.to_s.size) && in_bin_range?(num.to_s.slice(0, 6), MAESTRO_RANGES) },
+ 'maestro' => ->(num) { (12..19).include?(num&.size) && in_bin_range?(num.slice(0, 6), MAESTRO_RANGES) },
'forbrugsforeningen' => ->(num) { num =~ /^600722\d{10}$/ },
'sodexo' => ->(num) { num =~ /^(606071|603389|606070|606069|606068|600818)\d{8}$/ },
'vr' => ->(num) { num =~ /^(627416|637036)\d{8}$/ }
@@ -158,11 +158,12 @@ def type?(number)
end
def first_digits(number)
- number.to_s.slice(0,6)
+ number.slice(0,6)
end
def last_digits(number)
- number.to_s.length <= 4 ? number : number.to_s.slice(-4..-1)
+ return '' if number.nil?
+ number.length <= 4 ? number : number.slice(-4..-1)
end
def mask(number)
@@ -182,16 +183,16 @@ def matching_type?(number, brand)
private
def valid_card_number_length?(number) #:nodoc:
- number.to_s.length >= 12
+ number.length >= 12
end
def valid_card_number_characters?(number) #:nodoc:
- !number.to_s.match(/\D/)
+ !number.match(/\D/)
end
def valid_test_mode_card_number?(number) #:nodoc:
ActiveMerchant::Billing::Base.test? &&
- %w[1 2 3 success failure error].include?(number.to_s)
+ %w[1 2 3 success failure error].include?(number)
end
ODD_LUHN_VALUE = {
From fce72791585a21deb68a914c856c86d6fd9ad458 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Mon, 17 Sep 2018 11:51:37 -0400
Subject: [PATCH 0079/2234] Add support for Carnet
Carnet is only used in Mexico, and the only test number I could find
I found by googling pictures of Carnet cards until I found someone who
didn't blur out the number (although the test number here was mutated
to be in the same bin range but have different subsequent digits). So
there are definitely fewer test numbers than I'd like.
3927 tests, 68186 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/credit_card_methods.rb | 20 ++++++++++++++++++-
test/unit/credit_card_methods_test.rb | 13 ++++++++++++
3 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 6ddf07f77f4..1129d82ac34 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -11,6 +11,7 @@
* Improve Maestro card detection [bpollack] #2983
* Add ROU alpha3 code for Romania [dtykocki] #2989
* [POSSIBLE BREAKAGE] Drop support for Solo and Switch cards [bpollack] #2991
+* Add support for Carnet cards [bpollack] #2992
== Version 1.83.0 (August 30, 2018)
* CT Payment: Update How Address is Passed [nfarve] #2960
diff --git a/lib/active_merchant/billing/credit_card_methods.rb b/lib/active_merchant/billing/credit_card_methods.rb
index 032514bac57..1d79d9a2e1c 100644
--- a/lib/active_merchant/billing/credit_card_methods.rb
+++ b/lib/active_merchant/billing/credit_card_methods.rb
@@ -13,7 +13,13 @@ module CreditCardMethods
'maestro' => ->(num) { (12..19).include?(num&.size) && in_bin_range?(num.slice(0, 6), MAESTRO_RANGES) },
'forbrugsforeningen' => ->(num) { num =~ /^600722\d{10}$/ },
'sodexo' => ->(num) { num =~ /^(606071|603389|606070|606069|606068|600818)\d{8}$/ },
- 'vr' => ->(num) { num =~ /^(627416|637036)\d{8}$/ }
+ 'vr' => ->(num) { num =~ /^(627416|637036)\d{8}$/ },
+ 'carnet' => lambda { |num|
+ num&.size == 16 && (
+ in_bin_range?(num.slice(0, 6), CARNET_RANGES) ||
+ CARNET_BINS.any? { |bin| num.slice(0, bin.size) == bin }
+ )
+ }
}
# http://www.barclaycard.co.uk/business/files/bin_rules.pdf
@@ -36,6 +42,18 @@ module CreditCardMethods
(491730..491759),
]
+ CARNET_RANGES = [
+ (506199..506499),
+ ]
+
+ CARNET_BINS = Set.new(
+ [
+ '286900', '502275', '606333', '627535', '636318', '636379', '639388',
+ '639484', '639559', '50633601', '50633606', '58877274', '62753500',
+ '60462203', '60462204', '588772'
+ ]
+ )
+
# https://www.mastercard.us/content/dam/mccom/global/documents/mastercard-rules.pdf, page 73
MASTERCARD_RANGES = [
(222100..272099),
diff --git a/test/unit/credit_card_methods_test.rb b/test/unit/credit_card_methods_test.rb
index 829eb0214c2..e38775a135e 100644
--- a/test/unit/credit_card_methods_test.rb
+++ b/test/unit/credit_card_methods_test.rb
@@ -187,6 +187,19 @@ def test_19_digit_maestro_uk
assert_equal 'maestro', CreditCard.brand?(number)
end
+ def test_carnet_cards
+ numbers = [
+ '5062280000000000',
+ '6046220312312312',
+ '6393889871239871',
+ '5022751231231231',
+ ]
+ numbers.each do |num|
+ assert_equal 16, num.length
+ assert_equal 'carnet', CreditCard.brand?(num)
+ end
+ end
+
def test_electron_cards
# return the card number so assert failures are easy to isolate
electron_test = Proc.new do |card_number|
From 5ad6212b708abaae6ea7cb788f54098f38b786e6 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Tue, 18 Sep 2018 15:00:29 -0400
Subject: [PATCH 0080/2234] Fix build breakage from RuboCop
---
test/unit/credit_card_methods_test.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/unit/credit_card_methods_test.rb b/test/unit/credit_card_methods_test.rb
index e38775a135e..831359b9636 100644
--- a/test/unit/credit_card_methods_test.rb
+++ b/test/unit/credit_card_methods_test.rb
@@ -192,7 +192,7 @@ def test_carnet_cards
'5062280000000000',
'6046220312312312',
'6393889871239871',
- '5022751231231231',
+ '5022751231231231'
]
numbers.each do |num|
assert_equal 16, num.length
From 1ec4f30937396b284a20988d199cde591ef9c6bc Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 20 Sep 2018 07:55:01 -0400
Subject: [PATCH 0081/2234] Remove Switch from the last few gateways
I missed a couple gateways in the last patch series (specifically, ones
that only had Switch, not both Switch and Solo). Remove Switch from
those as well.
---
lib/active_merchant/billing/gateways/card_save.rb | 2 +-
lib/active_merchant/billing/gateways/cyber_source.rb | 3 +--
lib/active_merchant/billing/gateways/wirecard.rb | 2 +-
lib/active_merchant/billing/gateways/worldpay.rb | 3 +--
.../billing/gateways/worldpay_online_payments.rb | 2 +-
5 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/card_save.rb b/lib/active_merchant/billing/gateways/card_save.rb
index 2e7b29b304d..633ad3ea7cc 100644
--- a/lib/active_merchant/billing/gateways/card_save.rb
+++ b/lib/active_merchant/billing/gateways/card_save.rb
@@ -6,7 +6,7 @@ class CardSaveGateway < IridiumGateway
self.money_format = :cents
self.default_currency = 'GBP'
- self.supported_cardtypes = [ :visa, :switch, :maestro, :master, :american_express, :jcb ]
+ self.supported_cardtypes = [ :visa, :maestro, :master, :american_express, :jcb ]
self.supported_countries = [ 'GB' ]
self.homepage_url = 'http://www.cardsave.net/'
self.display_name = 'CardSave'
diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb
index 02e81821aed..190094e838a 100644
--- a/lib/active_merchant/billing/gateways/cyber_source.rb
+++ b/lib/active_merchant/billing/gateways/cyber_source.rb
@@ -26,7 +26,7 @@ class CyberSourceGateway < Gateway
XSD_VERSION = '1.121'
- self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb, :switch, :dankort, :maestro]
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb, :dankort, :maestro]
self.supported_countries = %w(US BR CA CN DK FI FR DE JP MX NO SE GB SG LB)
self.default_currency = 'USD'
@@ -42,7 +42,6 @@ class CyberSourceGateway < Gateway
:discover => '004',
:diners_club => '005',
:jcb => '007',
- :switch => '024',
:dankort => '034',
:maestro => '042'
}
diff --git a/lib/active_merchant/billing/gateways/wirecard.rb b/lib/active_merchant/billing/gateways/wirecard.rb
index 321cd379565..4b964770e15 100644
--- a/lib/active_merchant/billing/gateways/wirecard.rb
+++ b/lib/active_merchant/billing/gateways/wirecard.rb
@@ -26,7 +26,7 @@ class WirecardGateway < Gateway
# number 5551234 within area code 202 (country code 1).
VALID_PHONE_FORMAT = /\+\d{1,3}(\(?\d{3}\)?)?\d{3}-\d{4}-\d{3}/
- self.supported_cardtypes = [ :visa, :master, :american_express, :diners_club, :jcb, :switch ]
+ self.supported_cardtypes = [ :visa, :master, :american_express, :diners_club, :jcb ]
self.supported_countries = %w(AD CY GI IM MT RO CH AT DK GR IT MC SM TR BE EE HU LV NL SK GB BG FI IS LI NO SI VA FR IL LT PL ES CZ DE IE LU PT SE)
self.homepage_url = 'http://www.wirecard.com'
self.display_name = 'Wirecard'
diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb
index 2fe80cf9691..7d817e61a9b 100644
--- a/lib/active_merchant/billing/gateways/worldpay.rb
+++ b/lib/active_merchant/billing/gateways/worldpay.rb
@@ -7,7 +7,7 @@ class WorldpayGateway < Gateway
self.default_currency = 'GBP'
self.money_format = :cents
self.supported_countries = %w(HK GB AU AD AR BE BR CA CH CN CO CR CY CZ DE DK ES FI FR GI GR HU IE IN IT JP LI LU MC MT MY MX NL NO NZ PA PE PL PT SE SG SI SM TR UM VA)
- self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :maestro, :switch]
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :maestro]
self.currencies_without_fractions = %w(HUF IDR ISK JPY KRW)
self.currencies_with_three_decimal_places = %w(BHD KWD OMR RSD TND)
self.homepage_url = 'http://www.worldpay.com/'
@@ -21,7 +21,6 @@ class WorldpayGateway < Gateway
'jcb' => 'JCB-SSL',
'maestro' => 'MAESTRO-SSL',
'diners_club' => 'DINERS-SSL',
- 'switch' => 'MAESTRO-SSL'
}
def initialize(options = {})
diff --git a/lib/active_merchant/billing/gateways/worldpay_online_payments.rb b/lib/active_merchant/billing/gateways/worldpay_online_payments.rb
index af7b2bd7aec..a23f3f041a0 100644
--- a/lib/active_merchant/billing/gateways/worldpay_online_payments.rb
+++ b/lib/active_merchant/billing/gateways/worldpay_online_payments.rb
@@ -8,7 +8,7 @@ class WorldpayOnlinePaymentsGateway < Gateway
self.money_format = :cents
self.supported_countries = %w(HK US GB BE CH CZ DE DK ES FI FR GR HU IE IT LU MT NL NO PL PT SE SG TR)
- self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :maestro, :switch]
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :maestro]
self.homepage_url = 'http://online.worldpay.com'
self.display_name = 'Worldpay Online Payments'
From aa572339863aaa51e817f07223c71f5eefe983e1 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 20 Sep 2018 07:55:38 -0400
Subject: [PATCH 0082/2234] Remove last bits of Switch and Solo functionality
---
lib/active_merchant/billing/gateway.rb | 7 -------
lib/active_merchant/billing/gateways/card_stream.rb | 9 ---------
lib/active_merchant/billing/gateways/payflow.rb | 4 ----
lib/active_merchant/billing/gateways/payment_express.rb | 5 -----
lib/active_merchant/billing/gateways/psl_card.rb | 6 ------
lib/active_merchant/billing/gateways/sage_pay.rb | 5 -----
6 files changed, 36 deletions(-)
diff --git a/lib/active_merchant/billing/gateway.rb b/lib/active_merchant/billing/gateway.rb
index d6596a810e9..c3f3ba2c90c 100644
--- a/lib/active_merchant/billing/gateway.rb
+++ b/lib/active_merchant/billing/gateway.rb
@@ -56,8 +56,6 @@ class Gateway
include PostsData
include CreditCardFormatting
- DEBIT_CARDS = [ :switch, :solo ]
-
CREDIT_DEPRECATION_MESSAGE = 'Support for using credit to refund existing transactions is deprecated and will be removed from a future release of ActiveMerchant. Please use the refund method instead.'
RECURRING_DEPRECATION_MESSAGE = 'Recurring functionality in ActiveMerchant is deprecated and will be removed in a future version. Please contact the ActiveMerchant maintainers if you have an interest in taking ownership of a separate gem that continues support for it.'
@@ -305,11 +303,6 @@ def split_names(full_name)
[first_name, last_name]
end
- def requires_start_date_or_issue_number?(credit_card)
- return false if card_brand(credit_card).blank?
- DEBIT_CARDS.include?(card_brand(credit_card).to_sym)
- end
-
def requires!(hash, *params)
params.each do |param|
if param.is_a?(Array)
diff --git a/lib/active_merchant/billing/gateways/card_stream.rb b/lib/active_merchant/billing/gateways/card_stream.rb
index 32766f81ddb..993c61f027a 100644
--- a/lib/active_merchant/billing/gateways/card_stream.rb
+++ b/lib/active_merchant/billing/gateways/card_stream.rb
@@ -272,17 +272,8 @@ def add_reference(post, reference)
def add_credit_card(post, credit_card)
add_pair(post, :customerName, credit_card.name, :required => true)
add_pair(post, :cardNumber, credit_card.number, :required => true)
-
add_pair(post, :cardExpiryMonth, format(credit_card.month, :two_digits), :required => true)
add_pair(post, :cardExpiryYear, format(credit_card.year, :two_digits), :required => true)
-
- if requires_start_date_or_issue_number?(credit_card)
- add_pair(post, :cardStartMonth, format(credit_card.start_month, :two_digits))
- add_pair(post, :cardStartYear, format(credit_card.start_year, :two_digits))
-
- add_pair(post, :cardIssueNumber, credit_card.issue_number)
- end
-
add_pair(post, :cardCVV, credit_card.verification_value)
end
diff --git a/lib/active_merchant/billing/gateways/payflow.rb b/lib/active_merchant/billing/gateways/payflow.rb
index da13e3a1d40..db7ac1cbe11 100644
--- a/lib/active_merchant/billing/gateways/payflow.rb
+++ b/lib/active_merchant/billing/gateways/payflow.rb
@@ -237,10 +237,6 @@ def add_credit_card(xml, credit_card, options = {})
end
end
- if requires_start_date_or_issue_number?(credit_card)
- xml.tag!('ExtData', 'Name' => 'CardStart', 'Value' => startdate(credit_card)) unless credit_card.start_month.blank? || credit_card.start_year.blank?
- xml.tag!('ExtData', 'Name' => 'CardIssue', 'Value' => format(credit_card.issue_number, :two_digits)) unless credit_card.issue_number.blank?
- end
xml.tag! 'ExtData', 'Name' => 'LASTNAME', 'Value' => credit_card.last_name
end
end
diff --git a/lib/active_merchant/billing/gateways/payment_express.rb b/lib/active_merchant/billing/gateways/payment_express.rb
index 3495c029fca..f0ce2bb5556 100644
--- a/lib/active_merchant/billing/gateways/payment_express.rb
+++ b/lib/active_merchant/billing/gateways/payment_express.rb
@@ -193,11 +193,6 @@ def add_credit_card(xml, credit_card)
xml.add_element('Cvc2').text = credit_card.verification_value
xml.add_element('Cvc2Presence').text = '1'
end
-
- if requires_start_date_or_issue_number?(credit_card)
- xml.add_element('DateStart').text = format_date(credit_card.start_month, credit_card.start_year) unless credit_card.start_month.blank? || credit_card.start_year.blank?
- xml.add_element('IssueNumber').text = credit_card.issue_number unless credit_card.issue_number.blank?
- end
end
def add_billing_token(xml, token)
diff --git a/lib/active_merchant/billing/gateways/psl_card.rb b/lib/active_merchant/billing/gateways/psl_card.rb
index 78fa1a97c60..9a213ea4088 100644
--- a/lib/active_merchant/billing/gateways/psl_card.rb
+++ b/lib/active_merchant/billing/gateways/psl_card.rb
@@ -174,12 +174,6 @@ def add_credit_card(post, credit_card)
post[:ExpMonth] = credit_card.month
post[:ExpYear] = credit_card.year
- if requires_start_date_or_issue_number?(credit_card)
- post[:IssueNumber] = credit_card.issue_number unless credit_card.issue_number.blank?
- post[:StartMonth] = credit_card.start_month unless credit_card.start_month.blank?
- post[:StartYear] = credit_card.start_year unless credit_card.start_year.blank?
- end
-
# CV2 check
post[:AVSCV2Check] = credit_card.verification_value? ? 'YES' : 'NO'
post[:CV2] = credit_card.verification_value if credit_card.verification_value?
diff --git a/lib/active_merchant/billing/gateways/sage_pay.rb b/lib/active_merchant/billing/gateways/sage_pay.rb
index d46d338a741..313bdb88c72 100644
--- a/lib/active_merchant/billing/gateways/sage_pay.rb
+++ b/lib/active_merchant/billing/gateways/sage_pay.rb
@@ -289,11 +289,6 @@ def add_credit_card(post, credit_card)
add_pair(post, :CardNumber, credit_card.number, :required => true)
add_pair(post, :ExpiryDate, format_date(credit_card.month, credit_card.year), :required => true)
-
- if requires_start_date_or_issue_number?(credit_card)
- add_pair(post, :StartDate, format_date(credit_card.start_month, credit_card.start_year))
- add_pair(post, :IssueNumber, credit_card.issue_number)
- end
add_pair(post, :CardType, map_card_type(credit_card))
add_pair(post, :CV2, credit_card.verification_value)
From 19b45172ca2307e8c4512368e42b946689e5fc13 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Tue, 18 Sep 2018 11:50:18 -0400
Subject: [PATCH 0083/2234] RuboCop: fix Style/TrailingCommaInArguments
---
.rubocop_todo.yml | 7 -------
lib/active_merchant/billing/gateways/balanced.rb | 2 +-
lib/active_merchant/billing/gateways/blue_snap.rb | 2 +-
lib/active_merchant/billing/gateways/braintree_blue.rb | 2 +-
lib/active_merchant/billing/gateways/first_giving.rb | 2 +-
lib/active_merchant/billing/gateways/ipp.rb | 2 +-
lib/active_merchant/billing/gateways/mundipagg.rb | 2 +-
lib/active_merchant/billing/gateways/opp.rb | 2 +-
test/remote/gateways/remote_bank_frick_test.rb | 2 +-
test/remote/gateways/remote_ipp_test.rb | 2 +-
test/remote/gateways/remote_litle_test.rb | 2 +-
test/remote/gateways/remote_paybox_direct_test.rb | 2 +-
test/unit/gateways/authorize_net_test.rb | 6 +++---
test/unit/gateways/bank_frick_test.rb | 2 +-
test/unit/gateways/beanstream_test.rb | 2 +-
test/unit/gateways/checkout_v2_test.rb | 2 +-
test/unit/gateways/firstdata_e4_test.rb | 6 +++---
test/unit/gateways/firstdata_e4_v27_test.rb | 6 +++---
test/unit/gateways/ipp_test.rb | 2 +-
test/unit/gateways/merchant_e_solutions_test.rb | 2 +-
test/unit/gateways/omise_test.rb | 2 +-
test/unit/gateways/orbital_test.rb | 2 +-
test/unit/gateways/quickbooks_test.rb | 2 +-
test/unit/gateways/securion_pay_test.rb | 2 +-
test/unit/gateways/transact_pro_test.rb | 2 +-
25 files changed, 30 insertions(+), 37 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index b31f60d0e0d..b458e40724c 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -1487,13 +1487,6 @@ Style/TernaryParentheses:
- 'lib/active_merchant/billing/gateways/payeezy.rb'
- 'lib/active_merchant/billing/gateways/visanet_peru.rb'
-# Offense count: 27
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyleForMultiline.
-# SupportedStylesForMultiline: comma, consistent_comma, no_comma
-Style/TrailingCommaInArguments:
- Enabled: false
-
# Offense count: 7
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleForMultiline.
diff --git a/lib/active_merchant/billing/gateways/balanced.rb b/lib/active_merchant/billing/gateways/balanced.rb
index e5629dd7820..dcc931d7e45 100644
--- a/lib/active_merchant/billing/gateways/balanced.rb
+++ b/lib/active_merchant/billing/gateways/balanced.rb
@@ -172,7 +172,7 @@ def commit(entity_name, path, post, method=:post)
message_from(raw_response),
raw_response,
authorization: authorization_from(entity_name, raw_response),
- test: test?,
+ test: test?
)
end
diff --git a/lib/active_merchant/billing/gateways/blue_snap.rb b/lib/active_merchant/billing/gateways/blue_snap.rb
index 95cab53ca27..cfd9d210434 100644
--- a/lib/active_merchant/billing/gateways/blue_snap.rb
+++ b/lib/active_merchant/billing/gateways/blue_snap.rb
@@ -258,7 +258,7 @@ def commit(action, verb = :post)
avs_result: avs_result(parsed),
cvv_result: cvv_result(parsed),
error_code: error_code_from(parsed),
- test: test?,
+ test: test?
)
end
diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb
index b6fe5e8e431..ca663c05d58 100644
--- a/lib/active_merchant/billing/gateways/braintree_blue.rb
+++ b/lib/active_merchant/billing/gateways/braintree_blue.rb
@@ -66,7 +66,7 @@ def initialize(options = {})
:private_key => options[:private_key],
:environment => (options[:environment] || (test? ? :sandbox : :production)).to_sym,
:custom_user_agent => "ActiveMerchant #{ActiveMerchant::VERSION}",
- :logger => options[:logger] || logger,
+ :logger => options[:logger] || logger
)
@braintree_gateway = Braintree::Gateway.new( @configuration )
diff --git a/lib/active_merchant/billing/gateways/first_giving.rb b/lib/active_merchant/billing/gateways/first_giving.rb
index 29514f4334f..65bd5256104 100644
--- a/lib/active_merchant/billing/gateways/first_giving.rb
+++ b/lib/active_merchant/billing/gateways/first_giving.rb
@@ -107,7 +107,7 @@ def commit(action, post=nil)
(response['friendlyErrorMessage'] || response['verboseErrorMessage'] || response['acknowledgement']),
response,
authorization: response['transactionId'],
- test: test?,
+ test: test?
)
end
diff --git a/lib/active_merchant/billing/gateways/ipp.rb b/lib/active_merchant/billing/gateways/ipp.rb
index a7595b82388..7813de28e1c 100644
--- a/lib/active_merchant/billing/gateways/ipp.rb
+++ b/lib/active_merchant/billing/gateways/ipp.rb
@@ -130,7 +130,7 @@ def commit(action, &block)
response,
authorization: authorization_from(response),
error_code: error_code_from(response),
- test: test?,
+ test: test?
)
end
diff --git a/lib/active_merchant/billing/gateways/mundipagg.rb b/lib/active_merchant/billing/gateways/mundipagg.rb
index 89d895cea7b..fc8b10982e2 100644
--- a/lib/active_merchant/billing/gateways/mundipagg.rb
+++ b/lib/active_merchant/billing/gateways/mundipagg.rb
@@ -254,7 +254,7 @@ def commit(action, parameters, auth = nil)
"#{STANDARD_ERROR_MESSAGE_MAPPING[e.response.code]} #{message}",
parse(e.response.body),
test: test?,
- error_code: STANDARD_ERROR_CODE_MAPPING[e.response.code],
+ error_code: STANDARD_ERROR_CODE_MAPPING[e.response.code]
)
end
diff --git a/lib/active_merchant/billing/gateways/opp.rb b/lib/active_merchant/billing/gateways/opp.rb
index 956fcec81cc..ebc3a5bc959 100644
--- a/lib/active_merchant/billing/gateways/opp.rb
+++ b/lib/active_merchant/billing/gateways/opp.rb
@@ -313,7 +313,7 @@ def commit(post, authorization, options)
response,
authorization: authorization_from(response),
test: test?,
- error_code: success ? nil : error_code_from(response),
+ error_code: success ? nil : error_code_from(response)
)
end
diff --git a/test/remote/gateways/remote_bank_frick_test.rb b/test/remote/gateways/remote_bank_frick_test.rb
index a7202c677d4..d1bb6447d4e 100644
--- a/test/remote/gateways/remote_bank_frick_test.rb
+++ b/test/remote/gateways/remote_bank_frick_test.rb
@@ -123,7 +123,7 @@ def test_invalid_login
sender: '',
channel: '',
userid: '',
- userpwd: '',
+ userpwd: ''
)
response = gateway.purchase(@amount, @credit_card, @options)
assert_failure response
diff --git a/test/remote/gateways/remote_ipp_test.rb b/test/remote/gateways/remote_ipp_test.rb
index 16e17ce473b..f7e62cad46b 100644
--- a/test/remote/gateways/remote_ipp_test.rb
+++ b/test/remote/gateways/remote_ipp_test.rb
@@ -76,7 +76,7 @@ def test_failed_refund
def test_invalid_login
gateway = IppGateway.new(
username: '',
- password: '',
+ password: ''
)
response = gateway.purchase(200, @credit_card, @options)
assert_failure response
diff --git a/test/remote/gateways/remote_litle_test.rb b/test/remote/gateways/remote_litle_test.rb
index b4b2e1dccb2..73d71064585 100644
--- a/test/remote/gateways/remote_litle_test.rb
+++ b/test/remote/gateways/remote_litle_test.rb
@@ -398,7 +398,7 @@ def test_unsuccessful_verify
def test_successful_purchase_with_dynamic_descriptors
assert response = @gateway.purchase(10010, @credit_card1, @options.merge(
descriptor_name: 'SuperCompany',
- descriptor_phone: '9193341121',
+ descriptor_phone: '9193341121'
))
assert_success response
assert_equal 'Approved', response.message
diff --git a/test/remote/gateways/remote_paybox_direct_test.rb b/test/remote/gateways/remote_paybox_direct_test.rb
index e1d718056bb..8ee4639b8fb 100644
--- a/test/remote/gateways/remote_paybox_direct_test.rb
+++ b/test/remote/gateways/remote_paybox_direct_test.rb
@@ -103,7 +103,7 @@ def test_invalid_login
def test_invalid_login_without_rang
gateway = PayboxDirectGateway.new(
login: '199988899',
- password: '1999888F',
+ password: '1999888F'
)
assert response = gateway.purchase(@amount, @credit_card, @options)
assert_failure response
diff --git a/test/unit/gateways/authorize_net_test.rb b/test/unit/gateways/authorize_net_test.rb
index 3c7eac296e5..f80be4fbb8f 100644
--- a/test/unit/gateways/authorize_net_test.rb
+++ b/test/unit/gateways/authorize_net_test.rb
@@ -1031,7 +1031,7 @@ def test_includes_shipping_name_when_passed_as_options
def test_truncation
card = credit_card('4242424242424242',
first_name: 'a' * 51,
- last_name: 'a' * 51,
+ last_name: 'a' * 51
)
options = {
@@ -1043,7 +1043,7 @@ def test_truncation
city: 'a' * 41,
state: 'a' * 41,
zip: 'a' * 21,
- country: 'a' * 61,
+ country: 'a' * 61
),
shipping_address: address(
name: ['a' * 51, 'a' * 51].join(' '),
@@ -1052,7 +1052,7 @@ def test_truncation
city: 'a' * 41,
state: 'a' * 41,
zip: 'a' * 21,
- country: 'a' * 61,
+ country: 'a' * 61
)
}
diff --git a/test/unit/gateways/bank_frick_test.rb b/test/unit/gateways/bank_frick_test.rb
index 8ab20b5e9be..4c49abc68c5 100644
--- a/test/unit/gateways/bank_frick_test.rb
+++ b/test/unit/gateways/bank_frick_test.rb
@@ -6,7 +6,7 @@ def setup
sender: 'sender-uuid',
channel: 'channel-uuid',
userid: 'user-uuid',
- userpwd: 'password',
+ userpwd: 'password'
)
@credit_card = credit_card
diff --git a/test/unit/gateways/beanstream_test.rb b/test/unit/gateways/beanstream_test.rb
index 37787acfc7c..92866caab82 100644
--- a/test/unit/gateways/beanstream_test.rb
+++ b/test/unit/gateways/beanstream_test.rb
@@ -22,7 +22,7 @@ def setup
number: '4030000010001234',
payment_cryptogram: 'cryptogram goes here',
eci: 'an ECI value',
- transaction_id: 'transaction ID',
+ transaction_id: 'transaction ID'
)
@check = check(
diff --git a/test/unit/gateways/checkout_v2_test.rb b/test/unit/gateways/checkout_v2_test.rb
index d6189454c5f..bb3f1eda89a 100644
--- a/test/unit/gateways/checkout_v2_test.rb
+++ b/test/unit/gateways/checkout_v2_test.rb
@@ -5,7 +5,7 @@ class CheckoutV2Test < Test::Unit::TestCase
def setup
@gateway = CheckoutV2Gateway.new(
- secret_key: '1111111111111',
+ secret_key: '1111111111111'
)
@credit_card = credit_card
diff --git a/test/unit/gateways/firstdata_e4_test.rb b/test/unit/gateways/firstdata_e4_test.rb
index e7e6e6c9fc4..5a5258ba58e 100755
--- a/test/unit/gateways/firstdata_e4_test.rb
+++ b/test/unit/gateways/firstdata_e4_test.rb
@@ -225,7 +225,7 @@ def test_network_tokenization_requests_with_amex
brand: 'american_express',
transaction_id: '123',
eci: '05',
- payment_cryptogram: 'whatever_the_cryptogram_of_at_least_20_characters_is',
+ payment_cryptogram: 'whatever_the_cryptogram_of_at_least_20_characters_is'
)
@gateway.purchase(@amount, credit_card, @options)
@@ -244,7 +244,7 @@ def test_network_tokenization_requests_with_discover
brand: 'discover',
transaction_id: '123',
eci: '05',
- payment_cryptogram: 'whatever_the_cryptogram_is',
+ payment_cryptogram: 'whatever_the_cryptogram_is'
)
@gateway.purchase(@amount, credit_card, @options)
@@ -264,7 +264,7 @@ def test_network_tokenization_requests_with_other_brands
brand: brand,
transaction_id: '123',
eci: '05',
- payment_cryptogram: 'whatever_the_cryptogram_is',
+ payment_cryptogram: 'whatever_the_cryptogram_is'
)
@gateway.purchase(@amount, credit_card, @options)
diff --git a/test/unit/gateways/firstdata_e4_v27_test.rb b/test/unit/gateways/firstdata_e4_v27_test.rb
index 305faf51efb..fbee6ed84cf 100644
--- a/test/unit/gateways/firstdata_e4_v27_test.rb
+++ b/test/unit/gateways/firstdata_e4_v27_test.rb
@@ -207,7 +207,7 @@ def test_network_tokenization_requests_with_amex
brand: 'american_express',
transaction_id: '123',
eci: '05',
- payment_cryptogram: 'whatever_the_cryptogram_of_at_least_20_characters_is',
+ payment_cryptogram: 'whatever_the_cryptogram_of_at_least_20_characters_is'
)
@gateway.purchase(@amount, credit_card, @options)
@@ -226,7 +226,7 @@ def test_network_tokenization_requests_with_discover
brand: 'discover',
transaction_id: '123',
eci: '05',
- payment_cryptogram: 'whatever_the_cryptogram_is',
+ payment_cryptogram: 'whatever_the_cryptogram_is'
)
@gateway.purchase(@amount, credit_card, @options)
@@ -246,7 +246,7 @@ def test_network_tokenization_requests_with_other_brands
brand: brand,
transaction_id: '123',
eci: '05',
- payment_cryptogram: 'whatever_the_cryptogram_is',
+ payment_cryptogram: 'whatever_the_cryptogram_is'
)
@gateway.purchase(@amount, credit_card, @options)
diff --git a/test/unit/gateways/ipp_test.rb b/test/unit/gateways/ipp_test.rb
index f338efad9e8..40b8035b37b 100644
--- a/test/unit/gateways/ipp_test.rb
+++ b/test/unit/gateways/ipp_test.rb
@@ -6,7 +6,7 @@ class IppTest < Test::Unit::TestCase
def setup
@gateway = IppGateway.new(
username: 'username',
- password: 'password',
+ password: 'password'
)
@amount = 100
diff --git a/test/unit/gateways/merchant_e_solutions_test.rb b/test/unit/gateways/merchant_e_solutions_test.rb
index 26b932d25a0..9e073026c41 100644
--- a/test/unit/gateways/merchant_e_solutions_test.rb
+++ b/test/unit/gateways/merchant_e_solutions_test.rb
@@ -42,7 +42,7 @@ def test_purchase_with_long_order_id_truncates_id
@gateway.expects(:ssl_post).with(
anything,
all_of(
- includes('invoice_number=thisislongerthan1'),
+ includes('invoice_number=thisislongerthan1')
)
).returns(successful_purchase_response)
assert response = @gateway.purchase(@amount, @credit_card, options)
diff --git a/test/unit/gateways/omise_test.rb b/test/unit/gateways/omise_test.rb
index 52eb9cd22e0..c3e99f0d83c 100644
--- a/test/unit/gateways/omise_test.rb
+++ b/test/unit/gateways/omise_test.rb
@@ -4,7 +4,7 @@ class OmiseTest < Test::Unit::TestCase
def setup
@gateway = OmiseGateway.new(
public_key: 'pkey_test_abc',
- secret_key: 'skey_test_123',
+ secret_key: 'skey_test_123'
)
@credit_card = credit_card
diff --git a/test/unit/gateways/orbital_test.rb b/test/unit/gateways/orbital_test.rb
index 5a23c6d072c..bc8e811be61 100644
--- a/test/unit/gateways/orbital_test.rb
+++ b/test/unit/gateways/orbital_test.rb
@@ -237,7 +237,7 @@ def test_address_format
:dest_address2 => 'L%u%xury S|u^i\\t/e',
:dest_city => '/Winn/i%p|e^g\\',
:dest_zip => 'A1A 2B2',
- :dest_state => '^MB',
+ :dest_state => '^MB'
)
response = stub_comms do
diff --git a/test/unit/gateways/quickbooks_test.rb b/test/unit/gateways/quickbooks_test.rb
index bf6bc9d2017..7d59f157ba5 100644
--- a/test/unit/gateways/quickbooks_test.rb
+++ b/test/unit/gateways/quickbooks_test.rb
@@ -9,7 +9,7 @@ def setup
consumer_secret: 'consumer_secret',
access_token: 'access_token',
token_secret: 'token_secret',
- realm: 'realm_ID',
+ realm: 'realm_ID'
)
@credit_card = credit_card
diff --git a/test/unit/gateways/securion_pay_test.rb b/test/unit/gateways/securion_pay_test.rb
index ea2a5d85025..2880ca98a15 100644
--- a/test/unit/gateways/securion_pay_test.rb
+++ b/test/unit/gateways/securion_pay_test.rb
@@ -5,7 +5,7 @@ class SecurionPayTest < Test::Unit::TestCase
def setup
@gateway = SecurionPayGateway.new(
- secret_key: 'pr_test_SyMyCpIJosFIAESEsZUd3TgN',
+ secret_key: 'pr_test_SyMyCpIJosFIAESEsZUd3TgN'
)
@credit_card = credit_card
diff --git a/test/unit/gateways/transact_pro_test.rb b/test/unit/gateways/transact_pro_test.rb
index 6590b82cb2a..6323dc78536 100644
--- a/test/unit/gateways/transact_pro_test.rb
+++ b/test/unit/gateways/transact_pro_test.rb
@@ -5,7 +5,7 @@ def setup
@gateway = TransactProGateway.new(
guid: 'login',
password: 'password',
- terminal: 'terminal',
+ terminal: 'terminal'
)
@credit_card = credit_card
From 2dc98f37eb681b751d054495a74d9e592212d332 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Tue, 18 Sep 2018 11:54:41 -0400
Subject: [PATCH 0084/2234] RuboCop: fix Style/SymbolProc
---
.rubocop_todo.yml | 16 ----------------
lib/active_merchant/billing/compatibility.rb | 4 +---
.../billing/gateways/braintree_blue.rb | 2 +-
lib/active_merchant/billing/gateways/cenpos.rb | 2 +-
.../billing/gateways/checkout_v2.rb | 2 +-
.../billing/gateways/creditcall.rb | 2 +-
lib/active_merchant/billing/gateways/mercury.rb | 2 +-
.../billing/gateways/payflow/payflow_response.rb | 2 +-
lib/active_merchant/billing/gateways/psl_card.rb | 2 +-
lib/active_merchant/billing/gateways/realex.rb | 2 +-
10 files changed, 9 insertions(+), 27 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index b458e40724c..0302cacdff1 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -1453,22 +1453,6 @@ Style/StringLiteralsInInterpolation:
Style/SymbolArray:
Enabled: false
-# Offense count: 9
-# Cop supports --auto-correct.
-# Configuration parameters: IgnoredMethods.
-# IgnoredMethods: respond_to, define_method
-Style/SymbolProc:
- Exclude:
- - 'lib/active_merchant/billing/compatibility.rb'
- - 'lib/active_merchant/billing/gateways/braintree_blue.rb'
- - 'lib/active_merchant/billing/gateways/cenpos.rb'
- - 'lib/active_merchant/billing/gateways/checkout_v2.rb'
- - 'lib/active_merchant/billing/gateways/creditcall.rb'
- - 'lib/active_merchant/billing/gateways/mercury.rb'
- - 'lib/active_merchant/billing/gateways/payflow/payflow_response.rb'
- - 'lib/active_merchant/billing/gateways/psl_card.rb'
- - 'lib/active_merchant/billing/gateways/realex.rb'
-
# Offense count: 15
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, AllowSafeAssignment.
diff --git a/lib/active_merchant/billing/compatibility.rb b/lib/active_merchant/billing/compatibility.rb
index 740cc3d0906..8161ef320f0 100644
--- a/lib/active_merchant/billing/compatibility.rb
+++ b/lib/active_merchant/billing/compatibility.rb
@@ -29,9 +29,7 @@ def self.humanize(lower_case_and_underscored_word)
result = lower_case_and_underscored_word.to_s.dup
result.gsub!(/_id$/, '')
result.gsub!(/_/, ' ')
- result.gsub(/([a-z\d]*)/i) { |match|
- match.downcase
- }.gsub(/^\w/) { $&.upcase }
+ result.gsub(/([a-z\d]*)/i, &:downcase).gsub(/^\w/) { $&.upcase }
end
end
end
diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb
index ca663c05d58..1f3726827bf 100644
--- a/lib/active_merchant/billing/gateways/braintree_blue.rb
+++ b/lib/active_merchant/billing/gateways/braintree_blue.rb
@@ -140,7 +140,7 @@ def store(creditcard, options = {})
def update(vault_id, creditcard, options = {})
braintree_credit_card = nil
commit do
- braintree_credit_card = @braintree_gateway.customer.find(vault_id).credit_cards.detect { |cc| cc.default? }
+ braintree_credit_card = @braintree_gateway.customer.find(vault_id).credit_cards.detect(&:default?)
return Response.new(false, 'Braintree::NotFoundError') if braintree_credit_card.nil?
options.merge!(:update_existing_token => braintree_credit_card.token)
diff --git a/lib/active_merchant/billing/gateways/cenpos.rb b/lib/active_merchant/billing/gateways/cenpos.rb
index f6030e64f5c..2a36063982f 100644
--- a/lib/active_merchant/billing/gateways/cenpos.rb
+++ b/lib/active_merchant/billing/gateways/cenpos.rb
@@ -313,7 +313,7 @@ def validation_result_element(xml, name)
def validation_result_element_text(element)
result_text = element.elements.detect { |elem|
elem.name == 'Result'
- }.children.detect { |elem| elem.text }.text
+ }.children.detect(&:text).text
result_text.split(';').collect(&:strip)
end
diff --git a/lib/active_merchant/billing/gateways/checkout_v2.rb b/lib/active_merchant/billing/gateways/checkout_v2.rb
index 93a5c9f69d8..6289c2a0811 100644
--- a/lib/active_merchant/billing/gateways/checkout_v2.rb
+++ b/lib/active_merchant/billing/gateways/checkout_v2.rb
@@ -22,7 +22,7 @@ def purchase(amount, payment_method, options={})
r.process { capture(amount, r.authorization, options) }
end
- merged_params = multi.responses.map { |r| r.params }.reduce({}, :merge)
+ merged_params = multi.responses.map(&:params).reduce({}, :merge)
succeeded = success_from(merged_params)
response(:purchase, succeeded, merged_params)
diff --git a/lib/active_merchant/billing/gateways/creditcall.rb b/lib/active_merchant/billing/gateways/creditcall.rb
index f55c4960812..a140cbfa4a2 100644
--- a/lib/active_merchant/billing/gateways/creditcall.rb
+++ b/lib/active_merchant/billing/gateways/creditcall.rb
@@ -52,7 +52,7 @@ def purchase(money, payment_method, options={})
r.process { capture(money, r.authorization, options) }
end
- merged_params = multi_response.responses.map { |r| r.params }.reduce({}, :merge)
+ merged_params = multi_response.responses.map(&:params).reduce({}, :merge)
Response.new(
multi_response.primary_response.success?,
diff --git a/lib/active_merchant/billing/gateways/mercury.rb b/lib/active_merchant/billing/gateways/mercury.rb
index 090ffaad3f1..1a8fbe6be57 100644
--- a/lib/active_merchant/billing/gateways/mercury.rb
+++ b/lib/active_merchant/billing/gateways/mercury.rb
@@ -319,7 +319,7 @@ def message_from(response)
end
def authorization_from(response)
- dollars, cents = (response[:purchase] || '').split('.').collect{|e| e.to_i}
+ dollars, cents = (response[:purchase] || '').split('.').collect(&:to_i)
dollars ||= 0
cents ||= 0
[
diff --git a/lib/active_merchant/billing/gateways/payflow/payflow_response.rb b/lib/active_merchant/billing/gateways/payflow/payflow_response.rb
index d2b6e670009..21f6b5cb868 100644
--- a/lib/active_merchant/billing/gateways/payflow/payflow_response.rb
+++ b/lib/active_merchant/billing/gateways/payflow/payflow_response.rb
@@ -6,7 +6,7 @@ def profile_id
end
def payment_history
- @payment_history ||= @params['rp_payment_result'].collect{ |result| result.stringify_keys } rescue []
+ @payment_history ||= @params['rp_payment_result'].collect(&:stringify_keys) rescue []
end
end
end
diff --git a/lib/active_merchant/billing/gateways/psl_card.rb b/lib/active_merchant/billing/gateways/psl_card.rb
index 9a213ea4088..1abe0b9e55e 100644
--- a/lib/active_merchant/billing/gateways/psl_card.rb
+++ b/lib/active_merchant/billing/gateways/psl_card.rb
@@ -183,7 +183,7 @@ def add_address(post, options)
address = options[:billing_address] || options[:address]
return if address.nil?
- post[:QAAddress] = [:address1, :address2, :city, :state].collect{|a| address[a]}.reject{|a| a.blank?}.join(' ')
+ post[:QAAddress] = [:address1, :address2, :city, :state].collect{|a| address[a]}.reject(&:blank?).join(' ')
post[:QAPostcode] = address[:zip]
end
diff --git a/lib/active_merchant/billing/gateways/realex.rb b/lib/active_merchant/billing/gateways/realex.rb
index deb1e2556a3..3b5c86b1b52 100644
--- a/lib/active_merchant/billing/gateways/realex.rb
+++ b/lib/active_merchant/billing/gateways/realex.rb
@@ -264,7 +264,7 @@ def add_network_tokenization_card(xml, payment)
def format_address_code(address)
code = [address[:zip].to_s, address[:address1].to_s + address[:address2].to_s]
- code.collect{|e| e.gsub(/\D/, '')}.reject{|e| e.empty?}.join('|')
+ code.collect{|e| e.gsub(/\D/, '')}.reject(&:empty?).join('|')
end
def new_timestamp
From 65921608b6e6edbd27403a08d12bae700f968552 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Tue, 18 Sep 2018 12:04:58 -0400
Subject: [PATCH 0085/2234] RuboCop: fix Style/RedundantConditional
---
.rubocop_todo.yml | 8 --------
lib/active_merchant/billing/gateways/pin.rb | 2 +-
lib/active_merchant/billing/gateways/usa_epay_advanced.rb | 2 +-
.../billing/gateways/worldpay_online_payments.rb | 2 +-
4 files changed, 3 insertions(+), 11 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 0302cacdff1..2d5dea1d4a1 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -1339,14 +1339,6 @@ Style/RandomWithOffset:
Style/RedundantBegin:
Enabled: false
-# Offense count: 3
-# Cop supports --auto-correct.
-Style/RedundantConditional:
- Exclude:
- - 'lib/active_merchant/billing/gateways/pin.rb'
- - 'lib/active_merchant/billing/gateways/usa_epay_advanced.rb'
- - 'lib/active_merchant/billing/gateways/worldpay_online_payments.rb'
-
# Offense count: 1
# Cop supports --auto-correct.
Style/RedundantException:
diff --git a/lib/active_merchant/billing/gateways/pin.rb b/lib/active_merchant/billing/gateways/pin.rb
index a7e11dd16bb..289e8e33501 100644
--- a/lib/active_merchant/billing/gateways/pin.rb
+++ b/lib/active_merchant/billing/gateways/pin.rb
@@ -120,7 +120,7 @@ def add_invoice(post, options)
def add_capture(post, options)
capture = options[:capture]
- post[:capture] = capture == false ? false : true
+ post[:capture] = capture != false
end
def add_creditcard(post, creditcard)
diff --git a/lib/active_merchant/billing/gateways/usa_epay_advanced.rb b/lib/active_merchant/billing/gateways/usa_epay_advanced.rb
index d831807ec29..1db1f42a779 100644
--- a/lib/active_merchant/billing/gateways/usa_epay_advanced.rb
+++ b/lib/active_merchant/billing/gateways/usa_epay_advanced.rb
@@ -1568,7 +1568,7 @@ def parse(action, soap)
if response.respond_to?(:[]) && p = response["#{action}_return"]
if p.respond_to?(:key?) && p.key?('result_code')
- success = p['result_code'] == 'A' ? true : false
+ success = p['result_code'] == 'A'
authorization = p['ref_num']
avs = AVS_RESULTS[p['avs_result_code']]
cvv = p['card_code_result_code']
diff --git a/lib/active_merchant/billing/gateways/worldpay_online_payments.rb b/lib/active_merchant/billing/gateways/worldpay_online_payments.rb
index a23f3f041a0..c8b985a334a 100644
--- a/lib/active_merchant/billing/gateways/worldpay_online_payments.rb
+++ b/lib/active_merchant/billing/gateways/worldpay_online_payments.rb
@@ -187,7 +187,7 @@ def commit(method, url, parameters=nil, options = {}, type = false)
end
def test?
- @service_key[0]=='T' ? true : false
+ @service_key[0] == 'T'
end
def response_error(raw_response)
From ada8f128547f92f1cb9647c4eae03e6caaae7ba5 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Tue, 18 Sep 2018 12:07:58 -0400
Subject: [PATCH 0086/2234] RuboCop: fix Style/RedundantParentheses
---
.rubocop_todo.yml | 5 -----
lib/active_merchant/billing/gateways/blue_snap.rb | 2 +-
lib/active_merchant/billing/gateways/ct_payment.rb | 2 +-
lib/active_merchant/billing/gateways/dibs.rb | 2 +-
lib/active_merchant/billing/gateways/element.rb | 2 +-
.../billing/gateways/federated_canada.rb | 2 +-
lib/active_merchant/billing/gateways/iveri.rb | 2 +-
lib/active_merchant/billing/gateways/litle.rb | 2 +-
lib/active_merchant/billing/gateways/moneris_us.rb | 2 +-
lib/active_merchant/billing/gateways/money_movers.rb | 2 +-
lib/active_merchant/billing/gateways/nmi.rb | 2 +-
lib/active_merchant/billing/gateways/orbital.rb | 2 +-
lib/active_merchant/billing/gateways/safe_charge.rb | 6 +++---
lib/active_merchant/billing/gateways/skip_jack.rb | 4 ++--
lib/active_merchant/billing/gateways/spreedly_core.rb | 2 +-
.../billing/gateways/usa_epay_advanced.rb | 2 +-
lib/active_merchant/billing/gateways/vanco.rb | 2 +-
test/remote/gateways/remote_payu_latam_test.rb | 10 +++++-----
test/unit/gateways/optimal_payment_test.rb | 4 ++--
19 files changed, 26 insertions(+), 31 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 2d5dea1d4a1..8edb950986b 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -1345,11 +1345,6 @@ Style/RedundantException:
Exclude:
- 'lib/active_merchant/billing/gateway.rb'
-# Offense count: 27
-# Cop supports --auto-correct.
-Style/RedundantParentheses:
- Enabled: false
-
# Offense count: 87
# Cop supports --auto-correct.
# Configuration parameters: AllowMultipleReturnValues.
diff --git a/lib/active_merchant/billing/gateways/blue_snap.rb b/lib/active_merchant/billing/gateways/blue_snap.rb
index cfd9d210434..d79f6ac4a7d 100644
--- a/lib/active_merchant/billing/gateways/blue_snap.rb
+++ b/lib/active_merchant/billing/gateways/blue_snap.rb
@@ -215,7 +215,7 @@ def parse(response)
parsed = {}
doc = Nokogiri::XML(response.body)
doc.root.xpath('*').each do |node|
- if (node.elements.empty?)
+ if node.elements.empty?
parsed[node.name.downcase] = node.text
else
node.elements.each do |childnode|
diff --git a/lib/active_merchant/billing/gateways/ct_payment.rb b/lib/active_merchant/billing/gateways/ct_payment.rb
index 18b111f0a12..c29f8c30630 100644
--- a/lib/active_merchant/billing/gateways/ct_payment.rb
+++ b/lib/active_merchant/billing/gateways/ct_payment.rb
@@ -172,7 +172,7 @@ def add_customer_data(post, options)
def add_address(post, creditcard, options)
if address = options[:billing_address] || options[:address]
- post[:CardHolderAddress] = ("#{address[:address1]} #{address[:address2]} #{address[:city]} #{address[:state]}").rjust(20, ' ')
+ post[:CardHolderAddress] = "#{address[:address1]} #{address[:address2]} #{address[:city]} #{address[:state]}".rjust(20, ' ')
post[:CardHolderPostalCode] = address[:zip].gsub(/\s+/, '').rjust(9, ' ')
end
end
diff --git a/lib/active_merchant/billing/gateways/dibs.rb b/lib/active_merchant/billing/gateways/dibs.rb
index 5505a34f774..5379b738107 100644
--- a/lib/active_merchant/billing/gateways/dibs.rb
+++ b/lib/active_merchant/billing/gateways/dibs.rb
@@ -27,7 +27,7 @@ def authorize(amount, payment_method, options={})
post = {}
add_amount(post, amount)
add_invoice(post, amount, options)
- if (payment_method.respond_to?(:number))
+ if payment_method.respond_to?(:number)
add_payment_method(post, payment_method, options)
commit(:authorize, post)
else
diff --git a/lib/active_merchant/billing/gateways/element.rb b/lib/active_merchant/billing/gateways/element.rb
index 163402df436..248626e5802 100644
--- a/lib/active_merchant/billing/gateways/element.rb
+++ b/lib/active_merchant/billing/gateways/element.rb
@@ -251,7 +251,7 @@ def parse(xml)
end
root.each do |node|
- if (node.elements.empty?)
+ if node.elements.empty?
response[node.name.downcase] = node.text
else
node_name = node.name.downcase
diff --git a/lib/active_merchant/billing/gateways/federated_canada.rb b/lib/active_merchant/billing/gateways/federated_canada.rb
index d434f8307d2..404e8bebd60 100644
--- a/lib/active_merchant/billing/gateways/federated_canada.rb
+++ b/lib/active_merchant/billing/gateways/federated_canada.rb
@@ -134,7 +134,7 @@ def success?(response)
end
def test?
- (@options[:login].eql?('demo')) && (@options[:password].eql?('password'))
+ @options[:login].eql?('demo') && @options[:password].eql?('password')
end
def message_from(response)
diff --git a/lib/active_merchant/billing/gateways/iveri.rb b/lib/active_merchant/billing/gateways/iveri.rb
index 64f08999b39..808966879c2 100644
--- a/lib/active_merchant/billing/gateways/iveri.rb
+++ b/lib/active_merchant/billing/gateways/iveri.rb
@@ -187,7 +187,7 @@ def parse(body)
vxml = Nokogiri::XML(body).remove_namespaces!.xpath('//Envelope/Body/ExecuteResponse/ExecuteResult').inner_text
doc = Nokogiri::XML(vxml)
doc.xpath('*').each do |node|
- if (node.elements.empty?)
+ if node.elements.empty?
parsed[underscore(node.name)] = node.text
else
node.elements.each do |childnode|
diff --git a/lib/active_merchant/billing/gateways/litle.rb b/lib/active_merchant/billing/gateways/litle.rb
index e702dc297ed..4365a3884c5 100644
--- a/lib/active_merchant/billing/gateways/litle.rb
+++ b/lib/active_merchant/billing/gateways/litle.rb
@@ -364,7 +364,7 @@ def parse(kind, xml)
doc = Nokogiri::XML(xml).remove_namespaces!
doc.xpath("//litleOnlineResponse/#{kind}Response/*").each do |node|
- if (node.elements.empty?)
+ if node.elements.empty?
parsed[node.name.to_sym] = node.text
else
node.elements.each do |childnode|
diff --git a/lib/active_merchant/billing/gateways/moneris_us.rb b/lib/active_merchant/billing/gateways/moneris_us.rb
index 35696ea43b5..dd625fe0a96 100644
--- a/lib/active_merchant/billing/gateways/moneris_us.rb
+++ b/lib/active_merchant/billing/gateways/moneris_us.rb
@@ -57,7 +57,7 @@ def authorize(money, creditcard_or_datakey, options = {})
post[:order_id] = options[:order_id]
post[:address] = options[:billing_address] || options[:address]
post[:crypt_type] = options[:crypt_type] || @options[:crypt_type]
- action = (post[:data_key].blank?) ? 'us_preauth' : 'us_res_preauth_cc'
+ action = post[:data_key].blank? ? 'us_preauth' : 'us_res_preauth_cc'
commit(action, post)
end
diff --git a/lib/active_merchant/billing/gateways/money_movers.rb b/lib/active_merchant/billing/gateways/money_movers.rb
index 95165a42479..a41b57abeb5 100644
--- a/lib/active_merchant/billing/gateways/money_movers.rb
+++ b/lib/active_merchant/billing/gateways/money_movers.rb
@@ -126,7 +126,7 @@ def success?(response)
end
def test?
- (@options[:login].eql?('demo')) && (@options[:password].eql?('password'))
+ @options[:login].eql?('demo') && @options[:password].eql?('password')
end
def message_from(response)
diff --git a/lib/active_merchant/billing/gateways/nmi.rb b/lib/active_merchant/billing/gateways/nmi.rb
index 7ed61265c54..63180931889 100644
--- a/lib/active_merchant/billing/gateways/nmi.rb
+++ b/lib/active_merchant/billing/gateways/nmi.rb
@@ -140,7 +140,7 @@ def add_invoice(post, money, options)
def add_payment_method(post, payment_method, options)
if(payment_method.is_a?(String))
post[:customer_vault_id] = payment_method
- elsif (payment_method.is_a?(NetworkTokenizationCreditCard))
+ elsif payment_method.is_a?(NetworkTokenizationCreditCard)
post[:ccnumber] = payment_method.number
post[:ccexp] = exp_date(payment_method)
post[:token_cryptogram] = payment_method.payment_cryptogram
diff --git a/lib/active_merchant/billing/gateways/orbital.rb b/lib/active_merchant/billing/gateways/orbital.rb
index 27402de05be..9f0ba09eca7 100644
--- a/lib/active_merchant/billing/gateways/orbital.rb
+++ b/lib/active_merchant/billing/gateways/orbital.rb
@@ -398,7 +398,7 @@ def add_address(xml, creditcard, options)
end
xml.tag! :AVSname, ((creditcard && creditcard.name) ? creditcard.name[0..29] : nil)
- xml.tag! :AVScountryCode, (avs_supported ? (byte_limit(format_address_field(address[:country]), 2)) : '')
+ xml.tag! :AVScountryCode, (avs_supported ? byte_limit(format_address_field(address[:country]), 2) : '')
# Needs to come after AVScountryCode
add_destination_address(xml, address) if avs_supported
diff --git a/lib/active_merchant/billing/gateways/safe_charge.rb b/lib/active_merchant/billing/gateways/safe_charge.rb
index 82aab0e2113..7a3c64f7a27 100644
--- a/lib/active_merchant/billing/gateways/safe_charge.rb
+++ b/lib/active_merchant/billing/gateways/safe_charge.rb
@@ -43,7 +43,7 @@ def authorize(money, payment, options={})
def capture(money, authorization, options={})
post = {}
auth, transaction_id, token, exp_month, exp_year, _, original_currency = authorization.split('|')
- add_transaction_data('Settle', post, money, (options.merge!({currency: original_currency})))
+ add_transaction_data('Settle', post, money, options.merge!({currency: original_currency}))
post[:sg_AuthCode] = auth
post[:sg_TransactionID] = transaction_id
post[:sg_CCToken] = token
@@ -56,7 +56,7 @@ def capture(money, authorization, options={})
def refund(money, authorization, options={})
post = {}
auth, transaction_id, token, exp_month, exp_year, _, original_currency = authorization.split('|')
- add_transaction_data('Credit', post, money, (options.merge!({currency: original_currency})))
+ add_transaction_data('Credit', post, money, options.merge!({currency: original_currency}))
post[:sg_CreditType] = 2
post[:sg_AuthCode] = auth
post[:sg_TransactionID] = transaction_id
@@ -79,7 +79,7 @@ def credit(money, payment, options={})
def void(authorization, options={})
post = {}
auth, transaction_id, token, exp_month, exp_year, original_amount, original_currency = authorization.split('|')
- add_transaction_data('Void', post, (original_amount.to_f * 100), (options.merge!({currency: original_currency})))
+ add_transaction_data('Void', post, (original_amount.to_f * 100), options.merge!({currency: original_currency}))
post[:sg_CreditType] = 2
post[:sg_AuthCode] = auth
post[:sg_TransactionID] = transaction_id
diff --git a/lib/active_merchant/billing/gateways/skip_jack.rb b/lib/active_merchant/billing/gateways/skip_jack.rb
index 6de7356d1de..563a169ba8d 100644
--- a/lib/active_merchant/billing/gateways/skip_jack.rb
+++ b/lib/active_merchant/billing/gateways/skip_jack.rb
@@ -318,7 +318,7 @@ def split_line(line)
def authorize_response_map(body)
lines = split_lines(body)
keys, values = split_line(lines[0]), split_line(lines[1])
- Hash[*(keys.zip(values).flatten)].symbolize_keys
+ Hash[*keys.zip(values).flatten].symbolize_keys
end
def parse_authorization_response(body)
@@ -333,7 +333,7 @@ def parse_status_response(body, response_keys)
keys = [ :szSerialNumber, :szErrorCode, :szNumberRecords]
values = split_line(lines[0])[0..2]
- result = Hash[*(keys.zip(values).flatten)]
+ result = Hash[*keys.zip(values).flatten]
result[:szErrorMessage] = ''
result[:success] = (result[:szErrorCode] == '0')
diff --git a/lib/active_merchant/billing/gateways/spreedly_core.rb b/lib/active_merchant/billing/gateways/spreedly_core.rb
index 20a92886494..7c365fb2f68 100644
--- a/lib/active_merchant/billing/gateways/spreedly_core.rb
+++ b/lib/active_merchant/billing/gateways/spreedly_core.rb
@@ -231,7 +231,7 @@ def parse(xml)
doc = Nokogiri::XML(xml)
doc.root.xpath('*').each do |node|
- if (node.elements.empty?)
+ if node.elements.empty?
response[node.name.downcase.to_sym] = node.text
else
node.elements.each do |childnode|
diff --git a/lib/active_merchant/billing/gateways/usa_epay_advanced.rb b/lib/active_merchant/billing/gateways/usa_epay_advanced.rb
index 1db1f42a779..1744dcc1306 100644
--- a/lib/active_merchant/billing/gateways/usa_epay_advanced.rb
+++ b/lib/active_merchant/billing/gateways/usa_epay_advanced.rb
@@ -1563,7 +1563,7 @@ def parse(action, soap)
success, message, authorization, avs, cvv = false, FAILURE_MESSAGE, nil, nil, nil
- fault = (!response) || (response.length < 1) || response.has_key?('faultcode')
+ fault = !response || (response.length < 1) || response.has_key?('faultcode')
return [response, success, response['faultstring'], authorization, avs, cvv] if fault
if response.respond_to?(:[]) && p = response["#{action}_return"]
diff --git a/lib/active_merchant/billing/gateways/vanco.rb b/lib/active_merchant/billing/gateways/vanco.rb
index 8f9925bb946..38e2f2aef87 100644
--- a/lib/active_merchant/billing/gateways/vanco.rb
+++ b/lib/active_merchant/billing/gateways/vanco.rb
@@ -52,7 +52,7 @@ def parse(xml)
doc = Nokogiri::XML(xml)
doc.root.xpath('*').each do |node|
- if (node.elements.empty?)
+ if node.elements.empty?
response[node.name.downcase.to_sym] = node.text
else
node.elements.each do |childnode|
diff --git a/test/remote/gateways/remote_payu_latam_test.rb b/test/remote/gateways/remote_payu_latam_test.rb
index b15d9fce5c1..e1fa12362d6 100644
--- a/test/remote/gateways/remote_payu_latam_test.rb
+++ b/test/remote/gateways/remote_payu_latam_test.rb
@@ -290,13 +290,13 @@ def test_well_formed_refund_fails_as_expected
def test_failed_refund
response = @gateway.refund(@amount, '')
assert_failure response
- assert_match (/property: parentTransactionId, message: must not be null/), response.message
+ assert_match /property: parentTransactionId, message: must not be null/, response.message
end
def test_failed_refund_with_specified_language
response = @gateway.refund(@amount, '', language: 'es')
assert_failure response
- assert_match (/property: parentTransactionId, message: No puede ser vacio/), response.message
+ assert_match /property: parentTransactionId, message: No puede ser vacio/, response.message
end
# If this test fails, support for void may have been added to the sandbox
@@ -312,13 +312,13 @@ def test_unsupported_test_void_fails_as_expected
def test_failed_void
response = @gateway.void('')
assert_failure response
- assert_match (/property: parentTransactionId, message: must not be null/), response.message
+ assert_match /property: parentTransactionId, message: must not be null/, response.message
end
def test_failed_void_with_specified_language
response = @gateway.void('', language: 'es')
assert_failure response
- assert_match (/property: parentTransactionId, message: No puede ser vacio/), response.message
+ assert_match /property: parentTransactionId, message: No puede ser vacio/, response.message
end
# If this test fails, support for captures may have been added to the sandbox
@@ -334,7 +334,7 @@ def test_unsupported_test_capture_fails_as_expected
def test_failed_capture
response = @gateway.capture(@amount, '')
assert_failure response
- assert_match (/must not be null/), response.message
+ assert_match /must not be null/, response.message
end
def test_verify_credentials
diff --git a/test/unit/gateways/optimal_payment_test.rb b/test/unit/gateways/optimal_payment_test.rb
index f2c10a753a3..35faf61a2b4 100644
--- a/test/unit/gateways/optimal_payment_test.rb
+++ b/test/unit/gateways/optimal_payment_test.rb
@@ -132,7 +132,7 @@ def test_cvd_fields_pass_correctly
stub_comms do
@gateway.purchase(@amount, @credit_card, @options)
end.check_request do |endpoint, data, headers|
- assert_match (/cvdIndicator%3E1%3C\/cvdIndicator%3E%0A%20%20%20%20%3Ccvd%3E123%3C\/cvd/), data
+ assert_match(/cvdIndicator%3E1%3C\/cvdIndicator%3E%0A%20%20%20%20%3Ccvd%3E123%3C\/cvd/, data)
end.respond_with(successful_purchase_response)
credit_card = CreditCard.new(
@@ -147,7 +147,7 @@ def test_cvd_fields_pass_correctly
stub_comms do
@gateway.purchase(@amount, credit_card, @options)
end.check_request do |endpoint, data, headers|
- assert_match (/cvdIndicator%3E0%3C\/cvdIndicator%3E%0A%20%20%3C\/card/), data
+ assert_match(/cvdIndicator%3E0%3C\/cvdIndicator%3E%0A%20%20%3C\/card/, data)
end.respond_with(failed_purchase_response)
end
From e5a75456e6cfab301d14984db0d29f0cc4dfdcbf Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Tue, 18 Sep 2018 12:09:42 -0400
Subject: [PATCH 0087/2234] RuboCop: fix Style/RedundantException
---
.rubocop_todo.yml | 6 ------
lib/active_merchant/billing/gateway.rb | 2 +-
2 files changed, 1 insertion(+), 7 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 8edb950986b..3910dab8e6b 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -1339,12 +1339,6 @@ Style/RandomWithOffset:
Style/RedundantBegin:
Enabled: false
-# Offense count: 1
-# Cop supports --auto-correct.
-Style/RedundantException:
- Exclude:
- - 'lib/active_merchant/billing/gateway.rb'
-
# Offense count: 87
# Cop supports --auto-correct.
# Configuration parameters: AllowMultipleReturnValues.
diff --git a/lib/active_merchant/billing/gateway.rb b/lib/active_merchant/billing/gateway.rb
index c3f3ba2c90c..9db7133d6b2 100644
--- a/lib/active_merchant/billing/gateway.rb
+++ b/lib/active_merchant/billing/gateway.rb
@@ -193,7 +193,7 @@ def supports_scrubbing?
end
def scrub(transcript)
- raise RuntimeError.new('This gateway does not support scrubbing.')
+ raise 'This gateway does not support scrubbing.'
end
def supports_network_tokenization?
From 2fcf51d140a02c09bd172f485cf4b5559793f148 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Tue, 18 Sep 2018 12:43:37 -0400
Subject: [PATCH 0088/2234] RuboCop: fix Style/RedundantBegin
---
.rubocop_todo.yml | 5 --
lib/active_merchant/billing/credit_card.rb | 8 +--
.../billing/gateways/blue_snap.rb | 8 +--
.../billing/gateways/conekta.rb | 8 +--
lib/active_merchant/billing/gateways/culqi.rb | 18 +++---
.../billing/gateways/fat_zebra.rb | 20 +++---
.../billing/gateways/kushki.rb | 16 +++--
.../billing/gateways/latitude19.rb | 62 +++++++++----------
.../billing/gateways/openpay.rb | 8 +--
lib/active_merchant/billing/gateways/opp.rb | 8 +--
.../billing/gateways/pagarme.rb | 8 +--
.../billing/gateways/pay_junction_v2.rb | 20 +++---
.../billing/gateways/payu_latam.rb | 58 ++++++++---------
.../billing/gateways/quickpay/quickpay_v10.rb | 8 +--
.../billing/gateways/securion_pay.rb | 8 +--
.../billing/gateways/stripe.rb | 8 +--
.../billing/gateways/visanet_peru.rb | 60 +++++++++---------
.../gateways/worldpay_online_payments.rb | 8 +--
test/unit/gateways/optimal_payment_test.rb | 32 +++++-----
19 files changed, 162 insertions(+), 209 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 3910dab8e6b..46332a97372 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -1334,11 +1334,6 @@ Style/RandomWithOffset:
- 'test/remote/gateways/remote_pay_junction_test.rb'
- 'test/unit/gateways/beanstream_test.rb'
-# Offense count: 21
-# Cop supports --auto-correct.
-Style/RedundantBegin:
- Enabled: false
-
# Offense count: 87
# Cop supports --auto-correct.
# Configuration parameters: AllowMultipleReturnValues.
diff --git a/lib/active_merchant/billing/credit_card.rb b/lib/active_merchant/billing/credit_card.rb
index 98ca5a522cc..4d1afcae1bf 100644
--- a/lib/active_merchant/billing/credit_card.rb
+++ b/lib/active_merchant/billing/credit_card.rb
@@ -380,11 +380,9 @@ def expired? #:nodoc:
end
def expiration #:nodoc:
- begin
- Time.utc(year, month, month_days, 23, 59, 59)
- rescue ArgumentError
- Time.at(0).utc
- end
+ Time.utc(year, month, month_days, 23, 59, 59)
+ rescue ArgumentError
+ Time.at(0).utc
end
private
diff --git a/lib/active_merchant/billing/gateways/blue_snap.rb b/lib/active_merchant/billing/gateways/blue_snap.rb
index d79f6ac4a7d..441d0e4b763 100644
--- a/lib/active_merchant/billing/gateways/blue_snap.rb
+++ b/lib/active_merchant/billing/gateways/blue_snap.rb
@@ -237,11 +237,9 @@ def parse_element(parsed, node)
end
def api_request(action, request, verb)
- begin
- ssl_request(verb, url(action), request, headers)
- rescue ResponseError => e
- e.response
- end
+ ssl_request(verb, url(action), request, headers)
+ rescue ResponseError => e
+ e.response
end
def commit(action, verb = :post)
diff --git a/lib/active_merchant/billing/gateways/conekta.rb b/lib/active_merchant/billing/gateways/conekta.rb
index 2e38d54c43c..dfa9d484a20 100644
--- a/lib/active_merchant/billing/gateways/conekta.rb
+++ b/lib/active_merchant/billing/gateways/conekta.rb
@@ -211,11 +211,9 @@ def commit(method, url, parameters, options = {})
end
def response_error(raw_response)
- begin
- parse(raw_response)
- rescue JSON::ParserError
- json_error(raw_response)
- end
+ parse(raw_response)
+ rescue JSON::ParserError
+ json_error(raw_response)
end
def json_error(raw_response)
diff --git a/lib/active_merchant/billing/gateways/culqi.rb b/lib/active_merchant/billing/gateways/culqi.rb
index d7dde785353..7b0e078207a 100644
--- a/lib/active_merchant/billing/gateways/culqi.rb
+++ b/lib/active_merchant/billing/gateways/culqi.rb
@@ -243,16 +243,14 @@ def url
end
def parse(body)
- begin
- JSON.parse(body)
- rescue JSON::ParserError
- message = 'Invalid JSON response received from CulqiGateway. Please contact CulqiGateway if you continue to receive this message.'
- message += "(The raw response returned by the API was #{body.inspect})"
- {
- 'status' => 'N',
- 'statusdescription' => message
- }
- end
+ JSON.parse(body)
+ rescue JSON::ParserError
+ message = 'Invalid JSON response received from CulqiGateway. Please contact CulqiGateway if you continue to receive this message.'
+ message += "(The raw response returned by the API was #{body.inspect})"
+ {
+ 'status' => 'N',
+ 'statusdescription' => message
+ }
end
def success_from(response)
diff --git a/lib/active_merchant/billing/gateways/fat_zebra.rb b/lib/active_merchant/billing/gateways/fat_zebra.rb
index aa64f4dad68..93d25df692a 100644
--- a/lib/active_merchant/billing/gateways/fat_zebra.rb
+++ b/lib/active_merchant/billing/gateways/fat_zebra.rb
@@ -172,17 +172,15 @@ def message_from(response)
end
def parse(response)
- begin
- JSON.parse(response)
- rescue JSON::ParserError
- msg = 'Invalid JSON response received from Fat Zebra. Please contact support@fatzebra.com.au if you continue to receive this message.'
- msg += " (The raw response returned by the API was #{response.inspect})"
- {
- 'successful' => false,
- 'response' => {},
- 'errors' => [msg]
- }
- end
+ JSON.parse(response)
+ rescue JSON::ParserError
+ msg = 'Invalid JSON response received from Fat Zebra. Please contact support@fatzebra.com.au if you continue to receive this message.'
+ msg += " (The raw response returned by the API was #{response.inspect})"
+ {
+ 'successful' => false,
+ 'response' => {},
+ 'errors' => [msg]
+ }
end
def get_url(uri)
diff --git a/lib/active_merchant/billing/gateways/kushki.rb b/lib/active_merchant/billing/gateways/kushki.rb
index 14598237a74..c97bd2e6f38 100644
--- a/lib/active_merchant/billing/gateways/kushki.rb
+++ b/lib/active_merchant/billing/gateways/kushki.rb
@@ -186,15 +186,13 @@ def url(action, params)
end
def parse(body)
- begin
- JSON.parse(body)
- rescue JSON::ParserError
- message = 'Invalid JSON response received from KushkiGateway. Please contact KushkiGateway if you continue to receive this message.'
- message += " (The raw response returned by the API was #{body.inspect})"
- {
- 'message' => message
- }
- end
+ JSON.parse(body)
+ rescue JSON::ParserError
+ message = 'Invalid JSON response received from KushkiGateway. Please contact KushkiGateway if you continue to receive this message.'
+ message += " (The raw response returned by the API was #{body.inspect})"
+ {
+ 'message' => message
+ }
end
def success_from(response)
diff --git a/lib/active_merchant/billing/gateways/latitude19.rb b/lib/active_merchant/billing/gateways/latitude19.rb
index b380d1a1c17..f430f16f852 100644
--- a/lib/active_merchant/billing/gateways/latitude19.rb
+++ b/lib/active_merchant/billing/gateways/latitude19.rb
@@ -302,27 +302,25 @@ def reverse_or_void(method, pgwTID, options={})
end
def commit(endpoint, post)
- begin
- raw_response = ssl_post(url() + endpoint, post_data(post), headers)
- response = parse(raw_response)
- rescue ResponseError => e
- raw_response = e.response.body
- response_error(raw_response)
- rescue JSON::ParserError
- unparsable_response(raw_response)
- else
- success = success_from(response)
- Response.new(
- success,
- message_from(response),
- response,
- authorization: success ? authorization_from(response, post[:method]) : nil,
- avs_result: success ? avs_from(response) : nil,
- cvv_result: success ? cvv_from(response) : nil,
- error_code: success ? nil : error_from(response),
- test: test?
- )
- end
+ raw_response = ssl_post(url() + endpoint, post_data(post), headers)
+ response = parse(raw_response)
+ rescue ResponseError => e
+ raw_response = e.response.body
+ response_error(raw_response)
+ rescue JSON::ParserError
+ unparsable_response(raw_response)
+ else
+ success = success_from(response)
+ Response.new(
+ success,
+ message_from(response),
+ response,
+ authorization: success ? authorization_from(response, post[:method]) : nil,
+ avs_result: success ? avs_from(response) : nil,
+ cvv_result: success ? cvv_from(response) : nil,
+ error_code: success ? nil : error_from(response),
+ test: test?
+ )
end
def headers
@@ -392,18 +390,16 @@ def cvv_from(response)
end
def response_error(raw_response)
- begin
- response = parse(raw_response)
- rescue JSON::ParserError
- unparsable_response(raw_response)
- else
- return Response.new(
- false,
- message_from(response),
- response,
- :test => test?
- )
- end
+ response = parse(raw_response)
+ rescue JSON::ParserError
+ unparsable_response(raw_response)
+ else
+ return Response.new(
+ false,
+ message_from(response),
+ response,
+ :test => test?
+ )
end
def unparsable_response(raw_response)
diff --git a/lib/active_merchant/billing/gateways/openpay.rb b/lib/active_merchant/billing/gateways/openpay.rb
index 83c64de6258..fda4d7801ff 100644
--- a/lib/active_merchant/billing/gateways/openpay.rb
+++ b/lib/active_merchant/billing/gateways/openpay.rb
@@ -208,11 +208,9 @@ def error?(response)
end
def response_error(raw_response)
- begin
- parse(raw_response)
- rescue JSON::ParserError
- json_error(raw_response)
- end
+ parse(raw_response)
+ rescue JSON::ParserError
+ json_error(raw_response)
end
def json_error(raw_response)
diff --git a/lib/active_merchant/billing/gateways/opp.rb b/lib/active_merchant/billing/gateways/opp.rb
index ebc3a5bc959..11f8c4c8efa 100644
--- a/lib/active_merchant/billing/gateways/opp.rb
+++ b/lib/active_merchant/billing/gateways/opp.rb
@@ -318,11 +318,9 @@ def commit(post, authorization, options)
end
def parse(body)
- begin
- JSON.parse(body)
- rescue JSON::ParserError
- json_error(body)
- end
+ JSON.parse(body)
+ rescue JSON::ParserError
+ json_error(body)
end
def json_error(body)
diff --git a/lib/active_merchant/billing/gateways/pagarme.rb b/lib/active_merchant/billing/gateways/pagarme.rb
index 77786486739..7dfabd6f56d 100644
--- a/lib/active_merchant/billing/gateways/pagarme.rb
+++ b/lib/active_merchant/billing/gateways/pagarme.rb
@@ -175,11 +175,9 @@ def commit(method, url, parameters, options = {})
end
def response_error(raw_response)
- begin
- parse(raw_response)
- rescue JSON::ParserError
- json_error(raw_response)
- end
+ parse(raw_response)
+ rescue JSON::ParserError
+ json_error(raw_response)
end
def json_error(raw_response)
diff --git a/lib/active_merchant/billing/gateways/pay_junction_v2.rb b/lib/active_merchant/billing/gateways/pay_junction_v2.rb
index f05d335b8e8..f453d1b5e75 100644
--- a/lib/active_merchant/billing/gateways/pay_junction_v2.rb
+++ b/lib/active_merchant/billing/gateways/pay_junction_v2.rb
@@ -154,17 +154,15 @@ def url(params={})
end
def parse(body)
- begin
- JSON.parse(body)
- rescue JSON::ParserError
- message = 'Invalid JSON response received from PayJunctionV2Gateway. Please contact PayJunctionV2Gateway if you continue to receive this message.'
- message += " (The raw response returned by the API was #{body.inspect})"
- {
- 'errors' => [{
- 'message' => message
- }]
- }
- end
+ JSON.parse(body)
+ rescue JSON::ParserError
+ message = 'Invalid JSON response received from PayJunctionV2Gateway. Please contact PayJunctionV2Gateway if you continue to receive this message.'
+ message += " (The raw response returned by the API was #{body.inspect})"
+ {
+ 'errors' => [{
+ 'message' => message
+ }]
+ }
end
def success_from(response)
diff --git a/lib/active_merchant/billing/gateways/payu_latam.rb b/lib/active_merchant/billing/gateways/payu_latam.rb
index 5d3dc1af6b5..bb5d16e085b 100644
--- a/lib/active_merchant/billing/gateways/payu_latam.rb
+++ b/lib/active_merchant/billing/gateways/payu_latam.rb
@@ -319,25 +319,23 @@ def add_payment_method_to_be_tokenized(post, payment_method)
end
def commit(action, params)
- begin
- raw_response = ssl_post(url, post_data(params), headers)
- response = parse(raw_response)
- rescue ResponseError => e
- raw_response = e.response.body
- response_error(raw_response)
- rescue JSON::ParserError
- unparsable_response(raw_response)
- else
- success = success_from(action, response)
- Response.new(
- success,
- message_from(action, success, response),
- response,
- authorization: success ? authorization_from(action, response) : nil,
- error_code: success ? nil : error_from(action, response),
- test: test?
- )
- end
+ raw_response = ssl_post(url, post_data(params), headers)
+ response = parse(raw_response)
+ rescue ResponseError => e
+ raw_response = e.response.body
+ response_error(raw_response)
+ rescue JSON::ParserError
+ unparsable_response(raw_response)
+ else
+ success = success_from(action, response)
+ Response.new(
+ success,
+ message_from(action, success, response),
+ response,
+ authorization: success ? authorization_from(action, response) : nil,
+ error_code: success ? nil : error_from(action, response),
+ test: test?
+ )
end
def headers
@@ -425,18 +423,16 @@ def error_from(action, response)
end
def response_error(raw_response)
- begin
- response = parse(raw_response)
- rescue JSON::ParserError
- unparsable_response(raw_response)
- else
- return Response.new(
- false,
- message_from('', false, response),
- response,
- :test => test?
- )
- end
+ response = parse(raw_response)
+ rescue JSON::ParserError
+ unparsable_response(raw_response)
+ else
+ return Response.new(
+ false,
+ message_from('', false, response),
+ response,
+ :test => test?
+ )
end
def unparsable_response(raw_response)
diff --git a/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb b/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb
index ce4fec9a480..f26ed7eda57 100644
--- a/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb
+++ b/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb
@@ -276,11 +276,9 @@ def headers
end
def response_error(raw_response)
- begin
- parse(raw_response)
- rescue JSON::ParserError
- json_error(raw_response)
- end
+ parse(raw_response)
+ rescue JSON::ParserError
+ json_error(raw_response)
end
def json_error(raw_response)
diff --git a/lib/active_merchant/billing/gateways/securion_pay.rb b/lib/active_merchant/billing/gateways/securion_pay.rb
index 4d3035d3336..c883c938230 100644
--- a/lib/active_merchant/billing/gateways/securion_pay.rb
+++ b/lib/active_merchant/billing/gateways/securion_pay.rb
@@ -205,11 +205,9 @@ def headers(options = {})
end
def response_error(raw_response)
- begin
- parse(raw_response)
- rescue JSON::ParserError
- json_error(raw_response)
- end
+ parse(raw_response)
+ rescue JSON::ParserError
+ json_error(raw_response)
end
def post_data(params)
diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb
index d680dfaf353..4f6dd03fe3b 100644
--- a/lib/active_merchant/billing/gateways/stripe.rb
+++ b/lib/active_merchant/billing/gateways/stripe.rb
@@ -589,11 +589,9 @@ def success_from(response)
end
def response_error(raw_response)
- begin
- parse(raw_response)
- rescue JSON::ParserError
- json_error(raw_response)
- end
+ parse(raw_response)
+ rescue JSON::ParserError
+ json_error(raw_response)
end
def json_error(raw_response)
diff --git a/lib/active_merchant/billing/gateways/visanet_peru.rb b/lib/active_merchant/billing/gateways/visanet_peru.rb
index cc84e95f9c1..c8ba88f8b16 100644
--- a/lib/active_merchant/billing/gateways/visanet_peru.rb
+++ b/lib/active_merchant/billing/gateways/visanet_peru.rb
@@ -140,24 +140,22 @@ def split_authorization(authorization)
end
def commit(action, params, options={})
- begin
- raw_response = ssl_request(method(action), url(action, params, options), params.to_json, headers)
- response = parse(raw_response)
- rescue ResponseError => e
- raw_response = e.response.body
- response_error(raw_response, options, action)
- rescue JSON::ParserError
- unparsable_response(raw_response)
- else
- Response.new(
- success_from(response),
- message_from(response, options, action),
- response,
- :test => test?,
- :authorization => authorization_from(params, response, options),
- :error_code => response['errorCode']
- )
- end
+ raw_response = ssl_request(method(action), url(action, params, options), params.to_json, headers)
+ response = parse(raw_response)
+ rescue ResponseError => e
+ raw_response = e.response.body
+ response_error(raw_response, options, action)
+ rescue JSON::ParserError
+ unparsable_response(raw_response)
+ else
+ Response.new(
+ success_from(response),
+ message_from(response, options, action),
+ response,
+ :test => test?,
+ :authorization => authorization_from(params, response, options),
+ :error_code => response['errorCode']
+ )
end
def headers
@@ -211,20 +209,18 @@ def message_from(response, options, action)
end
def response_error(raw_response, options, action)
- begin
- response = parse(raw_response)
- rescue JSON::ParserError
- unparsable_response(raw_response)
- else
- return Response.new(
- false,
- message_from(response, options, action),
- response,
- :test => test?,
- :authorization => response['transactionUUID'],
- :error_code => response['errorCode']
- )
- end
+ response = parse(raw_response)
+ rescue JSON::ParserError
+ unparsable_response(raw_response)
+ else
+ return Response.new(
+ false,
+ message_from(response, options, action),
+ response,
+ :test => test?,
+ :authorization => response['transactionUUID'],
+ :error_code => response['errorCode']
+ )
end
def unparsable_response(raw_response)
diff --git a/lib/active_merchant/billing/gateways/worldpay_online_payments.rb b/lib/active_merchant/billing/gateways/worldpay_online_payments.rb
index c8b985a334a..519bef0b41a 100644
--- a/lib/active_merchant/billing/gateways/worldpay_online_payments.rb
+++ b/lib/active_merchant/billing/gateways/worldpay_online_payments.rb
@@ -191,11 +191,9 @@ def test?
end
def response_error(raw_response)
- begin
- parse(raw_response)
- rescue JSON::ParserError
- json_error(raw_response)
- end
+ parse(raw_response)
+ rescue JSON::ParserError
+ json_error(raw_response)
end
def json_error(raw_response)
diff --git a/test/unit/gateways/optimal_payment_test.rb b/test/unit/gateways/optimal_payment_test.rb
index 35faf61a2b4..7f1eceb5a08 100644
--- a/test/unit/gateways/optimal_payment_test.rb
+++ b/test/unit/gateways/optimal_payment_test.rb
@@ -172,23 +172,21 @@ def test_unsuccessful_request
end
def test_in_production_with_test_param_sends_request_to_test_server
- begin
- ActiveMerchant::Billing::Base.mode = :production
- @gateway = OptimalPaymentGateway.new(
- :account_number => '12345678',
- :store_id => 'login',
- :password => 'password',
- :test => true
- )
- @gateway.expects(:ssl_post).with('https://webservices.test.optimalpayments.com/creditcardWS/CreditCardServlet/v1', anything).returns(successful_purchase_response)
-
- assert response = @gateway.purchase(@amount, @credit_card, @options)
- assert_instance_of Response, response
- assert_success response
- assert response.test?
- ensure
- ActiveMerchant::Billing::Base.mode = :test
- end
+ ActiveMerchant::Billing::Base.mode = :production
+ @gateway = OptimalPaymentGateway.new(
+ :account_number => '12345678',
+ :store_id => 'login',
+ :password => 'password',
+ :test => true
+ )
+ @gateway.expects(:ssl_post).with('https://webservices.test.optimalpayments.com/creditcardWS/CreditCardServlet/v1', anything).returns(successful_purchase_response)
+
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
+ assert_instance_of Response, response
+ assert_success response
+ assert response.test?
+ ensure
+ ActiveMerchant::Billing::Base.mode = :test
end
def test_avs_result_in_response
From cf70eb87b41a987c54f807c3c15e9755a82f316e Mon Sep 17 00:00:00 2001
From: Niaja
Date: Thu, 20 Sep 2018 10:30:54 -0400
Subject: [PATCH 0089/2234] Rubocop: Layout/AlignParameters Set standard for
indention.
---
.rubocop.yml | 4 +++
.rubocop_todo.yml | 7 -----
lib/active_merchant/billing/check.rb | 4 +--
.../billing/gateways/banwire.rb | 8 ++---
.../billing/gateways/card_connect.rb | 4 +--
.../billing/gateways/cardknox.rb | 14 ++++-----
.../billing/gateways/data_cash.rb | 30 +++++++++----------
lib/active_merchant/billing/gateways/epay.rb | 16 +++++-----
.../billing/gateways/garanti.rb | 8 ++---
.../billing/gateways/iats_payments.rb | 2 +-
.../billing/gateways/iridium.rb | 4 +--
.../billing/gateways/merchant_ware.rb | 6 ++--
.../gateways/merchant_ware_version_four.rb | 6 ++--
.../billing/gateways/modern_payments_cim.rb | 6 ++--
lib/active_merchant/billing/gateways/payex.rb | 10 +++----
.../billing/gateways/so_easy_pay.rb | 8 ++---
.../remote_barclaycard_smartpay_test.rb | 18 +++++------
.../gateways/remote_braintree_blue_test.rb | 4 +--
.../remote_merchant_ware_version_four_test.rb | 4 +--
.../gateways/remote_net_registry_test.rb | 4 +--
.../gateways/remote_pay_junction_test.rb | 14 ++++-----
test/remote/gateways/remote_realex_test.rb | 14 ++++-----
test/remote/gateways/remote_skipjack_test.rb | 4 +--
test/unit/gateways/banwire_test.rb | 14 ++++-----
.../gateways/barclaycard_smartpay_test.rb | 8 ++---
test/unit/gateways/blue_pay_test.rb | 2 +-
test/unit/gateways/epay_test.rb | 4 +--
test/unit/gateways/exact_test.rb | 2 +-
test/unit/gateways/firstdata_e4_test.rb | 2 +-
test/unit/gateways/orbital_test.rb | 10 +++----
test/unit/gateways/paybox_direct_test.rb | 4 +--
.../gateways/paypal/paypal_common_api_test.rb | 6 ++--
test/unit/gateways/paypal_express_test.rb | 18 +++++------
test/unit/gateways/worldpay_test.rb | 8 ++---
34 files changed, 137 insertions(+), 140 deletions(-)
diff --git a/.rubocop.yml b/.rubocop.yml
index bf6cd8ae418..e4141aba185 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -23,3 +23,7 @@ Metrics/ClassLength:
Metrics/ModuleLength:
Enabled: false
+
+
+Layout/AlignParameters:
+ EnforcedStyle: with_fixed_indentation
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 46332a97372..fb937502eb4 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -23,13 +23,6 @@ Gemspec/OrderedDependencies:
Layout/AlignHash:
Enabled: false
-# Offense count: 275
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle, IndentationWidth.
-# SupportedStyles: with_first_parameter, with_fixed_indentation
-Layout/AlignParameters:
- Enabled: false
-
# Offense count: 113
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentOneStep, IndentationWidth.
diff --git a/lib/active_merchant/billing/check.rb b/lib/active_merchant/billing/check.rb
index 561f7b54615..410359c41b6 100644
--- a/lib/active_merchant/billing/check.rb
+++ b/lib/active_merchant/billing/check.rb
@@ -7,8 +7,8 @@ module Billing #:nodoc:
# You may use Check in place of CreditCard with any gateway that supports it.
class Check < Model
attr_accessor :first_name, :last_name,
- :bank_name, :routing_number, :account_number,
- :account_holder_type, :account_type, :number
+ :bank_name, :routing_number, :account_number,
+ :account_holder_type, :account_type, :number
# Used for Canadian bank accounts
attr_accessor :institution_number, :transit_number
diff --git a/lib/active_merchant/billing/gateways/banwire.rb b/lib/active_merchant/billing/gateways/banwire.rb
index d0e23302c00..99d3e683e34 100644
--- a/lib/active_merchant/billing/gateways/banwire.rb
+++ b/lib/active_merchant/billing/gateways/banwire.rb
@@ -90,10 +90,10 @@ def commit(money, parameters)
end
Response.new(success?(response),
- response['message'],
- response,
- :test => test?,
- :authorization => response['code_auth'])
+ response['message'],
+ response,
+ :test => test?,
+ :authorization => response['code_auth'])
end
def success?(response)
diff --git a/lib/active_merchant/billing/gateways/card_connect.rb b/lib/active_merchant/billing/gateways/card_connect.rb
index 40444cade8c..6c4e8064c55 100644
--- a/lib/active_merchant/billing/gateways/card_connect.rb
+++ b/lib/active_merchant/billing/gateways/card_connect.rb
@@ -141,8 +141,8 @@ def store(payment, options = {})
def unstore(authorization, options = {})
account_id, profile_id = authorization.split('|')
commit('profile', {},
- verb: :delete,
- path: "/#{profile_id}/#{account_id}/#{@options[:merchant_id]}")
+ verb: :delete,
+ path: "/#{profile_id}/#{account_id}/#{@options[:merchant_id]}")
end
def supports_scrubbing?
diff --git a/lib/active_merchant/billing/gateways/cardknox.rb b/lib/active_merchant/billing/gateways/cardknox.rb
index f133cf33c41..0345173d4f6 100644
--- a/lib/active_merchant/billing/gateways/cardknox.rb
+++ b/lib/active_merchant/billing/gateways/cardknox.rb
@@ -284,13 +284,13 @@ def commit(action, source_type, parameters)
response = parse(ssl_post(live_url, post_data(COMMANDS[source_type][action], parameters)))
Response.new(
- (response[:status] == 'Approved'),
- message_from(response),
- response,
- authorization: authorization_from(response, source_type),
- avs_result: { code: response[:avs_result_code] },
- cvv_result: response[:cvv_result_code]
- )
+ (response[:status] == 'Approved'),
+ message_from(response),
+ response,
+ authorization: authorization_from(response, source_type),
+ avs_result: { code: response[:avs_result_code] },
+ cvv_result: response[:cvv_result_code]
+ )
end
def message_from(response)
diff --git a/lib/active_merchant/billing/gateways/data_cash.rb b/lib/active_merchant/billing/gateways/data_cash.rb
index 179aa12e194..1e31db78dc5 100644
--- a/lib/active_merchant/billing/gateways/data_cash.rb
+++ b/lib/active_merchant/billing/gateways/data_cash.rb
@@ -238,23 +238,23 @@ def add_credit_card(xml, credit_card, address)
# a predefined one
xml.tag! :ExtendedPolicy do
xml.tag! :cv2_policy,
- :notprovided => POLICY_REJECT,
- :notchecked => POLICY_REJECT,
- :matched => POLICY_ACCEPT,
- :notmatched => POLICY_REJECT,
- :partialmatch => POLICY_REJECT
+ :notprovided => POLICY_REJECT,
+ :notchecked => POLICY_REJECT,
+ :matched => POLICY_ACCEPT,
+ :notmatched => POLICY_REJECT,
+ :partialmatch => POLICY_REJECT
xml.tag! :postcode_policy,
- :notprovided => POLICY_ACCEPT,
- :notchecked => POLICY_ACCEPT,
- :matched => POLICY_ACCEPT,
- :notmatched => POLICY_REJECT,
- :partialmatch => POLICY_ACCEPT
+ :notprovided => POLICY_ACCEPT,
+ :notchecked => POLICY_ACCEPT,
+ :matched => POLICY_ACCEPT,
+ :notmatched => POLICY_REJECT,
+ :partialmatch => POLICY_ACCEPT
xml.tag! :address_policy,
- :notprovided => POLICY_ACCEPT,
- :notchecked => POLICY_ACCEPT,
- :matched => POLICY_ACCEPT,
- :notmatched => POLICY_REJECT,
- :partialmatch => POLICY_ACCEPT
+ :notprovided => POLICY_ACCEPT,
+ :notchecked => POLICY_ACCEPT,
+ :matched => POLICY_ACCEPT,
+ :notmatched => POLICY_REJECT,
+ :partialmatch => POLICY_ACCEPT
end
end
end
diff --git a/lib/active_merchant/billing/gateways/epay.rb b/lib/active_merchant/billing/gateways/epay.rb
index 937589eda90..19ddbf5365a 100644
--- a/lib/active_merchant/billing/gateways/epay.rb
+++ b/lib/active_merchant/billing/gateways/epay.rb
@@ -164,16 +164,16 @@ def commit(action, params)
if action == :authorize
Response.new response['accept'].to_i == 1,
- response['errortext'],
- response,
- :test => test?,
- :authorization => response['tid']
+ response['errortext'],
+ response,
+ :test => test?,
+ :authorization => response['tid']
else
Response.new response['result'] == 'true',
- messages(response['epay'], response['pbs']),
- response,
- :test => test?,
- :authorization => params[:transaction]
+ messages(response['epay'], response['pbs']),
+ response,
+ :test => test?,
+ :authorization => params[:transaction]
end
end
diff --git a/lib/active_merchant/billing/gateways/garanti.rb b/lib/active_merchant/billing/gateways/garanti.rb
index cd567c73d6c..eb77b969a47 100644
--- a/lib/active_merchant/billing/gateways/garanti.rb
+++ b/lib/active_merchant/billing/gateways/garanti.rb
@@ -223,10 +223,10 @@ def commit(money,request)
success = success?(response)
Response.new(success,
- success ? 'Approved' : "Declined (Reason: #{response[:reason_code]} - #{response[:error_msg]} - #{response[:sys_err_msg]})",
- response,
- :test => test?,
- :authorization => response[:order_id])
+ success ? 'Approved' : "Declined (Reason: #{response[:reason_code]} - #{response[:error_msg]} - #{response[:sys_err_msg]})",
+ response,
+ :test => test?,
+ :authorization => response[:order_id])
end
def parse(body)
diff --git a/lib/active_merchant/billing/gateways/iats_payments.rb b/lib/active_merchant/billing/gateways/iats_payments.rb
index dcc43765847..c2d4505dfb9 100644
--- a/lib/active_merchant/billing/gateways/iats_payments.rb
+++ b/lib/active_merchant/billing/gateways/iats_payments.rb
@@ -165,7 +165,7 @@ def creditcard_brand(brand)
def commit(action, parameters)
response = parse(ssl_post(url(action), post_data(action, parameters),
- { 'Content-Type' => 'application/soap+xml; charset=utf-8'}))
+ { 'Content-Type' => 'application/soap+xml; charset=utf-8'}))
Response.new(
success_from(response),
diff --git a/lib/active_merchant/billing/gateways/iridium.rb b/lib/active_merchant/billing/gateways/iridium.rb
index 95c25379ec3..3723f287e43 100644
--- a/lib/active_merchant/billing/gateways/iridium.rb
+++ b/lib/active_merchant/billing/gateways/iridium.rb
@@ -377,8 +377,8 @@ def add_merchant_data(xml, options)
def commit(request, options)
requires!(options, :action)
response = parse(ssl_post(test? ? self.test_url : self.live_url, request,
- {'SOAPAction' => 'https://www.thepaymentgateway.net/' + options[:action],
- 'Content-Type' => 'text/xml; charset=utf-8' }))
+ {'SOAPAction' => 'https://www.thepaymentgateway.net/' + options[:action],
+ 'Content-Type' => 'text/xml; charset=utf-8' }))
success = response[:transaction_result][:status_code] == '0'
message = response[:transaction_result][:message]
diff --git a/lib/active_merchant/billing/gateways/merchant_ware.rb b/lib/active_merchant/billing/gateways/merchant_ware.rb
index 3b8d4a20b0e..a6d73a2130c 100644
--- a/lib/active_merchant/billing/gateways/merchant_ware.rb
+++ b/lib/active_merchant/billing/gateways/merchant_ware.rb
@@ -293,9 +293,9 @@ def url(v4 = false)
def commit(action, request, v4 = false)
begin
data = ssl_post(url(v4), request,
- 'Content-Type' => 'text/xml; charset=utf-8',
- 'SOAPAction' => soap_action(action, v4)
- )
+ 'Content-Type' => 'text/xml; charset=utf-8',
+ 'SOAPAction' => soap_action(action, v4)
+ )
response = parse(action, data)
rescue ActiveMerchant::ResponseError => e
response = parse_error(e.response)
diff --git a/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb b/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb
index 109d00fce00..4b1667334a4 100644
--- a/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb
+++ b/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb
@@ -262,9 +262,9 @@ def url
def commit(action, request)
begin
data = ssl_post(url, request,
- 'Content-Type' => 'text/xml; charset=utf-8',
- 'SOAPAction' => soap_action(action)
- )
+ 'Content-Type' => 'text/xml; charset=utf-8',
+ 'SOAPAction' => soap_action(action)
+ )
response = parse(action, data)
rescue ActiveMerchant::ResponseError => e
response = parse_error(e.response, action)
diff --git a/lib/active_merchant/billing/gateways/modern_payments_cim.rb b/lib/active_merchant/billing/gateways/modern_payments_cim.rb
index 7939387dd00..1f1e5beb04b 100644
--- a/lib/active_merchant/billing/gateways/modern_payments_cim.rb
+++ b/lib/active_merchant/billing/gateways/modern_payments_cim.rb
@@ -146,9 +146,9 @@ def url(action)
def commit(action, params)
data = ssl_post(url(action), build_request(action, params),
- { 'Content-Type' =>'text/xml; charset=utf-8',
- 'SOAPAction' => "#{xmlns(action)}#{action}" }
- )
+ { 'Content-Type' =>'text/xml; charset=utf-8',
+ 'SOAPAction' => "#{xmlns(action)}#{action}" }
+ )
response = parse(action, data)
Response.new(successful?(action, response), message_from(action, response), response,
diff --git a/lib/active_merchant/billing/gateways/payex.rb b/lib/active_merchant/billing/gateways/payex.rb
index 3a63f379872..22478d87d2a 100644
--- a/lib/active_merchant/billing/gateways/payex.rb
+++ b/lib/active_merchant/billing/gateways/payex.rb
@@ -387,11 +387,11 @@ def commit(soap_action, request)
}
response = parse(ssl_post(url, request, headers))
Response.new(success?(response),
- message_from(response),
- response,
- test: test?,
- authorization: build_authorization(response)
- )
+ message_from(response),
+ response,
+ test: test?,
+ authorization: build_authorization(response)
+ )
end
def build_authorization(response)
diff --git a/lib/active_merchant/billing/gateways/so_easy_pay.rb b/lib/active_merchant/billing/gateways/so_easy_pay.rb
index 5cc6eeaa1c6..7b5198b7be7 100644
--- a/lib/active_merchant/billing/gateways/so_easy_pay.rb
+++ b/lib/active_merchant/billing/gateways/so_easy_pay.rb
@@ -162,10 +162,10 @@ def commit(soap_action, soap, options)
response_string = ssl_post(test? ? self.test_url : self.live_url, soap, headers)
response = parse(response_string, soap_action)
return Response.new(response['errorcode'] == '000',
- response['errormessage'],
- response,
- :test => test?,
- :authorization => response['transaction_id'])
+ response['errormessage'],
+ response,
+ :test => test?,
+ :authorization => response['transaction_id'])
end
def build_soap(request)
diff --git a/test/remote/gateways/remote_barclaycard_smartpay_test.rb b/test/remote/gateways/remote_barclaycard_smartpay_test.rb
index d605c62f4c1..eaa3f7288ae 100644
--- a/test/remote/gateways/remote_barclaycard_smartpay_test.rb
+++ b/test/remote/gateways/remote_barclaycard_smartpay_test.rb
@@ -97,9 +97,9 @@ def setup
}
@avs_credit_card = credit_card('4400000000000008',
- :month => 8,
- :year => 2018,
- :verification_value => 737)
+ :month => 8,
+ :year => 2018,
+ :verification_value => 737)
@avs_address = @options.clone
@avs_address.update(billing_address: {
@@ -131,24 +131,24 @@ def test_failed_purchase
def test_successful_purchase_with_unusual_address
response = @gateway.purchase(@amount,
- @credit_card,
- @options_with_alternate_address)
+ @credit_card,
+ @options_with_alternate_address)
assert_success response
assert_equal '[capture-received]', response.message
end
def test_successful_purchase_with_house_number_and_street
response = @gateway.purchase(@amount,
- @credit_card,
- @options.merge(street: 'Top Level Drive', house_number: '100'))
+ @credit_card,
+ @options.merge(street: 'Top Level Drive', house_number: '100'))
assert_success response
assert_equal '[capture-received]', response.message
end
def test_successful_purchase_with_no_address
response = @gateway.purchase(@amount,
- @credit_card,
- @options_with_no_address)
+ @credit_card,
+ @options_with_no_address)
assert_success response
assert_equal '[capture-received]', response.message
end
diff --git a/test/remote/gateways/remote_braintree_blue_test.rb b/test/remote/gateways/remote_braintree_blue_test.rb
index 16ef4891a3d..27bf4083ff4 100644
--- a/test/remote/gateways/remote_braintree_blue_test.rb
+++ b/test/remote/gateways/remote_braintree_blue_test.rb
@@ -371,8 +371,8 @@ def test_successful_purchase_with_addresses
def test_successful_purchase_with_three_d_secure_pass_thru
three_d_secure_params = { eci: '05', cavv: 'cavv', xid: 'xid' }
assert response = @gateway.purchase(@amount, @credit_card,
- three_d_secure: three_d_secure_params
- )
+ three_d_secure: three_d_secure_params
+ )
assert_success response
end
diff --git a/test/remote/gateways/remote_merchant_ware_version_four_test.rb b/test/remote/gateways/remote_merchant_ware_version_four_test.rb
index f1c538cc470..98bb62a166d 100644
--- a/test/remote/gateways/remote_merchant_ware_version_four_test.rb
+++ b/test/remote/gateways/remote_merchant_ware_version_four_test.rb
@@ -70,8 +70,8 @@ def test_purchase_and_reference_purchase
assert purchase.authorization
assert reference_purchase = @gateway.purchase(@amount,
- purchase.authorization,
- @reference_purchase_options)
+ purchase.authorization,
+ @reference_purchase_options)
assert_success reference_purchase
assert_not_nil reference_purchase.authorization
end
diff --git a/test/remote/gateways/remote_net_registry_test.rb b/test/remote/gateways/remote_net_registry_test.rb
index c97ddc7dd91..aeadc59b83d 100644
--- a/test/remote/gateways/remote_net_registry_test.rb
+++ b/test/remote/gateways/remote_net_registry_test.rb
@@ -58,8 +58,8 @@ def test_successful_authorization_and_capture
assert_match(/\A\d{6}\z/, response.authorization)
response = @gateway.capture(@amount,
- response.authorization,
- :credit_card => @valid_creditcard)
+ response.authorization,
+ :credit_card => @valid_creditcard)
assert_success response
assert_equal 'approved', response.params['status']
end
diff --git a/test/remote/gateways/remote_pay_junction_test.rb b/test/remote/gateways/remote_pay_junction_test.rb
index bd0ff583733..79cea0c85b4 100644
--- a/test/remote/gateways/remote_pay_junction_test.rb
+++ b/test/remote/gateways/remote_pay_junction_test.rb
@@ -72,7 +72,7 @@ def test_successful_capture
assert_success response
assert_equal 'capture', response.params['posture'], 'Should be a capture'
assert_equal auth.authorization, response.authorization,
- 'Should maintain transaction ID across request'
+ 'Should maintain transaction ID across request'
end
def test_successful_credit
@@ -94,7 +94,7 @@ def test_successful_void
assert_success response
assert_equal 'void', response.params['posture'], 'Should be a capture'
assert_equal purchase.authorization, response.authorization,
- 'Should maintain transaction ID across request'
+ 'Should maintain transaction ID across request'
end
def test_successful_instant_purchase
@@ -111,17 +111,17 @@ def test_successful_instant_purchase
assert_equal 'capture', response.params['posture'], 'Should be captured funds'
assert_equal 'charge', response.params['transaction_action']
assert_not_equal purchase.authorization, response.authorization,
- 'Should have recieved new transaction ID'
+ 'Should have recieved new transaction ID'
assert_success response
end
def test_successful_recurring
assert response = @gateway.recurring(AMOUNT, @credit_card,
- :periodicity => :monthly,
- :payments => 12,
- :order_id => generate_unique_id[0..15]
- )
+ :periodicity => :monthly,
+ :payments => 12,
+ :order_id => generate_unique_id[0..15]
+ )
assert_equal PayJunctionGateway::SUCCESS_MESSAGE, response.message
assert_equal 'charge', response.params['transaction_action']
diff --git a/test/remote/gateways/remote_realex_test.rb b/test/remote/gateways/remote_realex_test.rb
index 5549f5715df..7cff61befad 100644
--- a/test/remote/gateways/remote_realex_test.rb
+++ b/test/remote/gateways/remote_realex_test.rb
@@ -351,13 +351,13 @@ def test_maps_avs_and_cvv_response_codes
def test_transcript_scrubbing
transcript = capture_transcript(@gateway) do
@gateway.purchase(@amount, @visa_declined,
- :order_id => generate_unique_id,
- :description => 'Test Realex Purchase',
- :billing_address => {
- :zip => '90210',
- :country => 'US'
- }
- )
+ :order_id => generate_unique_id,
+ :description => 'Test Realex Purchase',
+ :billing_address => {
+ :zip => '90210',
+ :country => 'US'
+ }
+ )
end
clean_transcript = @gateway.scrub(transcript)
diff --git a/test/remote/gateways/remote_skipjack_test.rb b/test/remote/gateways/remote_skipjack_test.rb
index 2c8d070dcbf..d8ec78f732b 100644
--- a/test/remote/gateways/remote_skipjack_test.rb
+++ b/test/remote/gateways/remote_skipjack_test.rb
@@ -7,8 +7,8 @@ def setup
@gateway = SkipJackGateway.new(fixtures(:skip_jack))
@credit_card = credit_card('4445999922225',
- :verification_value => '999'
- )
+ :verification_value => '999'
+ )
@amount = 100
diff --git a/test/unit/gateways/banwire_test.rb b/test/unit/gateways/banwire_test.rb
index e7466ba51bc..7f65c6c7277 100644
--- a/test/unit/gateways/banwire_test.rb
+++ b/test/unit/gateways/banwire_test.rb
@@ -9,9 +9,9 @@ def setup
:currency => 'MXN')
@credit_card = credit_card('5204164299999999',
- :month => 11,
- :year => 2012,
- :verification_value => '999')
+ :month => 11,
+ :year => 2012,
+ :verification_value => '999')
@amount = 100
@options = {
@@ -22,10 +22,10 @@ def setup
}
@amex_credit_card = credit_card('375932134599999',
- :month => 3,
- :year => 2017,
- :first_name => 'Banwire',
- :last_name => 'Test Card')
+ :month => 3,
+ :year => 2017,
+ :first_name => 'Banwire',
+ :last_name => 'Test Card')
@amex_options = {
:order_id => '2',
:email => 'test@email.com',
diff --git a/test/unit/gateways/barclaycard_smartpay_test.rb b/test/unit/gateways/barclaycard_smartpay_test.rb
index bac4a277b3e..4763dfa6813 100644
--- a/test/unit/gateways/barclaycard_smartpay_test.rb
+++ b/test/unit/gateways/barclaycard_smartpay_test.rb
@@ -128,8 +128,8 @@ def test_successful_authorize_with_alternate_address
def test_successful_authorize_with_house_number_and_street
response = stub_comms do
@gateway.authorize(@amount,
- @credit_card,
- @options_with_house_number_and_street)
+ @credit_card,
+ @options_with_house_number_and_street)
end.check_request do |endpoint, data, headers|
assert_match(/billingAddress.street=Top\+Level\+Drive/, data)
assert_match(/billingAddress.houseNumberOrName=1000/, data)
@@ -143,8 +143,8 @@ def test_successful_authorize_with_house_number_and_street
def test_successful_authorize_with_shipping_house_number_and_street
response = stub_comms do
@gateway.authorize(@amount,
- @credit_card,
- @options_with_shipping_house_number_and_shipping_street)
+ @credit_card,
+ @options_with_shipping_house_number_and_shipping_street)
end.check_request do |endpoint, data, headers|
assert_match(/billingAddress.street=Top\+Level\+Drive/, data)
assert_match(/billingAddress.houseNumberOrName=1000/, data)
diff --git a/test/unit/gateways/blue_pay_test.rb b/test/unit/gateways/blue_pay_test.rb
index 811b121450e..713b387278c 100644
--- a/test/unit/gateways/blue_pay_test.rb
+++ b/test/unit/gateways/blue_pay_test.rb
@@ -183,7 +183,7 @@ def get_msg(query)
end
assert_equal 'CVV does not match', get_msg('STATUS=2&CVV2=N&AVS=A&MESSAGE=FAILURE')
assert_equal 'Street address matches, but 5-digit and 9-digit postal code do not match.',
- get_msg('STATUS=2&CVV2=M&AVS=A&MESSAGE=FAILURE')
+ get_msg('STATUS=2&CVV2=M&AVS=A&MESSAGE=FAILURE')
end
# Recurring Billing Unit Tests
diff --git a/test/unit/gateways/epay_test.rb b/test/unit/gateways/epay_test.rb
index 462ecf1cbf4..6c4554f5969 100644
--- a/test/unit/gateways/epay_test.rb
+++ b/test/unit/gateways/epay_test.rb
@@ -26,7 +26,7 @@ def test_failed_purchase
assert response = @gateway.authorize(100, @credit_card)
assert_failure response
assert_equal 'The payment was declined. Try again in a moment or try with another credit card.',
- response.message
+ response.message
end
def test_invalid_characters_in_response
@@ -35,7 +35,7 @@ def test_invalid_characters_in_response
assert response = @gateway.authorize(100, @credit_card)
assert_failure response
assert_equal 'The payment was declined of unknown reasons. For more information contact the bank. E.g. try with another credit card.
Denied - Call your bank for information',
- response.message
+ response.message
end
def test_failed_response_on_purchase
diff --git a/test/unit/gateways/exact_test.rb b/test/unit/gateways/exact_test.rb
index 0c33fd415c3..1566816809e 100644
--- a/test/unit/gateways/exact_test.rb
+++ b/test/unit/gateways/exact_test.rb
@@ -52,7 +52,7 @@ def test_failed_purchase
def test_expdate
assert_equal( '%02d%s' % [ @credit_card.month,
@credit_card.year.to_s[-2..-1] ],
- @gateway.send(:expdate, @credit_card) )
+ @gateway.send(:expdate, @credit_card) )
end
def test_soap_fault
diff --git a/test/unit/gateways/firstdata_e4_test.rb b/test/unit/gateways/firstdata_e4_test.rb
index 5a5258ba58e..a970aaccff8 100755
--- a/test/unit/gateways/firstdata_e4_test.rb
+++ b/test/unit/gateways/firstdata_e4_test.rb
@@ -64,7 +64,7 @@ def test_successful_purchase_with_specified_currency_and_token
options_with_specified_currency = @options.merge({currency: 'GBP'})
@gateway.expects(:ssl_post).returns(successful_purchase_with_specified_currency_response)
assert response = @gateway.purchase(@amount, '8938737759041111;visa;Longbob;Longsen;9;2014',
- options_with_specified_currency)
+ options_with_specified_currency)
assert_success response
assert_equal 'GBP', response.params['currency']
end
diff --git a/test/unit/gateways/orbital_test.rb b/test/unit/gateways/orbital_test.rb
index bc8e811be61..8bcffb2ccc5 100644
--- a/test/unit/gateways/orbital_test.rb
+++ b/test/unit/gateways/orbital_test.rb
@@ -181,8 +181,8 @@ def test_truncates_address
def test_truncates_name
card = credit_card('4242424242424242',
- :first_name => 'John',
- :last_name => 'Jacob Jingleheimer Smith-Jones')
+ :first_name => 'John',
+ :last_name => 'Jacob Jingleheimer Smith-Jones')
response = stub_comms do
@gateway.purchase(50, card, :order_id => 1, :billing_address => address)
@@ -270,8 +270,8 @@ def test_address_format
def test_truncates_by_byte_length
card = credit_card('4242424242424242',
- :first_name => 'John',
- :last_name => 'Jacob Jingleheimer Smith-Jones')
+ :first_name => 'John',
+ :last_name => 'Jacob Jingleheimer Smith-Jones')
long_address = address(
:address1 => '456 Stréêt Name is Really Long',
@@ -689,7 +689,7 @@ def test_cc_account_num_is_removed_from_response
assert_deprecation_warning do
response = @gateway.add_customer_profile(credit_card,
- :billing_address => address)
+ :billing_address => address)
end
assert_instance_of Response, response
diff --git a/test/unit/gateways/paybox_direct_test.rb b/test/unit/gateways/paybox_direct_test.rb
index 89f5f7d435b..e6e29d1ad93 100644
--- a/test/unit/gateways/paybox_direct_test.rb
+++ b/test/unit/gateways/paybox_direct_test.rb
@@ -10,8 +10,8 @@ def setup
)
@credit_card = credit_card('1111222233334444',
- :brand => 'visa'
- )
+ :brand => 'visa'
+ )
@amount = 100
@options = {
diff --git a/test/unit/gateways/paypal/paypal_common_api_test.rb b/test/unit/gateways/paypal/paypal_common_api_test.rb
index 7428848a955..2f53c97fad3 100644
--- a/test/unit/gateways/paypal/paypal_common_api_test.rb
+++ b/test/unit/gateways/paypal/paypal_common_api_test.rb
@@ -153,9 +153,9 @@ def test_build_reference_transaction_request
def test_build_reference_transaction_gets_ip
request = REXML::Document.new(@gateway.send(:build_reference_transaction_request,
- 100,
- :reference_id => 'id',
- :ip => '127.0.0.1'))
+ 100,
+ :reference_id => 'id',
+ :ip => '127.0.0.1'))
assert_equal '100', REXML::XPath.first(request, '//n2:PaymentDetails/n2:OrderTotal').text
assert_equal 'id', REXML::XPath.first(request, '//DoReferenceTransactionReq/DoReferenceTransactionRequest/n2:DoReferenceTransactionRequestDetails/n2:ReferenceID').text
assert_equal '127.0.0.1', REXML::XPath.first(request, '//DoReferenceTransactionReq/DoReferenceTransactionRequest/n2:DoReferenceTransactionRequestDetails/n2:IPAddress').text
diff --git a/test/unit/gateways/paypal_express_test.rb b/test/unit/gateways/paypal_express_test.rb
index 6ac936f3023..445dace38f4 100644
--- a/test/unit/gateways/paypal_express_test.rb
+++ b/test/unit/gateways/paypal_express_test.rb
@@ -508,18 +508,18 @@ def test_reference_transaction_requires_fields
def test_error_code_for_single_error
@gateway.expects(:ssl_post).returns(response_with_error)
response = @gateway.setup_authorization(100,
- :return_url => 'http://example.com',
- :cancel_return_url => 'http://example.com'
- )
+ :return_url => 'http://example.com',
+ :cancel_return_url => 'http://example.com'
+ )
assert_equal '10736', response.params['error_codes']
end
def test_ensure_only_unique_error_codes
@gateway.expects(:ssl_post).returns(response_with_duplicate_errors)
response = @gateway.setup_authorization(100,
- :return_url => 'http://example.com',
- :cancel_return_url => 'http://example.com'
- )
+ :return_url => 'http://example.com',
+ :cancel_return_url => 'http://example.com'
+ )
assert_equal '10736' , response.params['error_codes']
end
@@ -527,9 +527,9 @@ def test_ensure_only_unique_error_codes
def test_error_codes_for_multiple_errors
@gateway.expects(:ssl_post).returns(response_with_errors)
response = @gateway.setup_authorization(100,
- :return_url => 'http://example.com',
- :cancel_return_url => 'http://example.com'
- )
+ :return_url => 'http://example.com',
+ :cancel_return_url => 'http://example.com'
+ )
assert_equal ['10736', '10002'] , response.params['error_codes'].split(',')
end
diff --git a/test/unit/gateways/worldpay_test.rb b/test/unit/gateways/worldpay_test.rb
index d73a991418f..37fcef0e548 100644
--- a/test/unit/gateways/worldpay_test.rb
+++ b/test/unit/gateways/worldpay_test.rb
@@ -209,7 +209,7 @@ def test_capture_time
if data =~ /capture/
t = Time.now
assert_tag_with_attributes 'date',
- {'dayOfMonth' => t.day.to_s, 'month' => t.month.to_s, 'year' => t.year.to_s},
+ {'dayOfMonth' => t.day.to_s, 'month' => t.month.to_s, 'year' => t.year.to_s},
data
end
end.respond_with(successful_inquiry_response, successful_capture_response)
@@ -220,7 +220,7 @@ def test_amount_handling
@gateway.authorize(100, @credit_card, @options)
end.check_request do |endpoint, data, headers|
assert_tag_with_attributes 'amount',
- {'value' => '100', 'exponent' => '2', 'currencyCode' => 'GBP'},
+ {'value' => '100', 'exponent' => '2', 'currencyCode' => 'GBP'},
data
end.respond_with(successful_authorize_response)
end
@@ -230,7 +230,7 @@ def test_currency_exponent_handling
@gateway.authorize(10000, @credit_card, @options.merge(currency: :JPY))
end.check_request do |endpoint, data, headers|
assert_tag_with_attributes 'amount',
- {'value' => '100', 'exponent' => '0', 'currencyCode' => 'JPY'},
+ {'value' => '100', 'exponent' => '0', 'currencyCode' => 'JPY'},
data
end.respond_with(successful_authorize_response)
@@ -238,7 +238,7 @@ def test_currency_exponent_handling
@gateway.authorize(10000, @credit_card, @options.merge(currency: :OMR))
end.check_request do |endpoint, data, headers|
assert_tag_with_attributes 'amount',
- {'value' => '10000', 'exponent' => '3', 'currencyCode' => 'OMR'},
+ {'value' => '10000', 'exponent' => '3', 'currencyCode' => 'OMR'},
data
end.respond_with(successful_authorize_response)
end
From 385ddd19eab4caf373e90dabbb7daae9b75f5539 Mon Sep 17 00:00:00 2001
From: David Whitby
Date: Mon, 27 Mar 2017 12:57:15 +0100
Subject: [PATCH 0090/2234] Stripe: support reason for voiding
Closes #2378
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/stripe.rb | 1 +
test/remote/gateways/remote_stripe_test.rb | 11 +++++++++++
test/unit/gateways/stripe_test.rb | 9 +++++++++
4 files changed, 22 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index 1129d82ac34..29d3b368ef3 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -12,6 +12,7 @@
* Add ROU alpha3 code for Romania [dtykocki] #2989
* [POSSIBLE BREAKAGE] Drop support for Solo and Switch cards [bpollack] #2991
* Add support for Carnet cards [bpollack] #2992
+* Stripe: support a reason for voiding a transaction [whitby3001] #2378
== Version 1.83.0 (August 30, 2018)
* CT Payment: Update How Address is Passed [nfarve] #2960
diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb
index 4f6dd03fe3b..2e80ab70041 100644
--- a/lib/active_merchant/billing/gateways/stripe.rb
+++ b/lib/active_merchant/billing/gateways/stripe.rb
@@ -136,6 +136,7 @@ def capture(money, authorization, options = {})
def void(identification, options = {})
post = {}
post[:metadata] = options[:metadata] if options[:metadata]
+ post[:reason] = options[:reason] if options[:reason]
post[:expand] = [:charge]
commit(:post, "charges/#{CGI.escape(identification)}/refunds", post, options)
end
diff --git a/test/remote/gateways/remote_stripe_test.rb b/test/remote/gateways/remote_stripe_test.rb
index 3d34ae2c75a..cf1948cb7a0 100644
--- a/test/remote/gateways/remote_stripe_test.rb
+++ b/test/remote/gateways/remote_stripe_test.rb
@@ -194,6 +194,17 @@ def test_successful_void_with_metadata
assert_equal '123', void.params['metadata']['test_metadata']
end
+ def test_successful_void_with_reason
+ assert response = @gateway.authorize(@amount, @credit_card, @options)
+ assert_success response
+ assert response.authorization
+
+ assert void = @gateway.void(response.authorization, reason: 'fraudulent')
+ assert void.test?
+ assert_success void
+ assert_equal 'fraudulent', void.params['reason']
+ end
+
def test_unsuccessful_void
assert void = @gateway.void('active_merchant_fake_charge')
assert_failure void
diff --git a/test/unit/gateways/stripe_test.rb b/test/unit/gateways/stripe_test.rb
index 4839433bd48..8708f9b4867 100644
--- a/test/unit/gateways/stripe_test.rb
+++ b/test/unit/gateways/stripe_test.rb
@@ -537,6 +537,15 @@ def test_successful_void_with_metadata
assert_success response
end
+ def test_successful_void_with_reason
+ @gateway.expects(:ssl_request).with do |_, _, post, _|
+ post.include?('reason=fraudulent')
+ end.returns(successful_purchase_response(true))
+
+ assert response = @gateway.void('ch_test_charge', {reason: 'fraudulent'})
+ assert_success response
+ end
+
def test_successful_refund
@gateway.expects(:ssl_request).returns(successful_partially_refunded_response)
From 3ca6b05fd192711a5b81c26611cd370e31d3cab5 Mon Sep 17 00:00:00 2001
From: dtykocki
Date: Fri, 21 Sep 2018 06:21:05 -0400
Subject: [PATCH 0091/2234] Payeezy: Add reversal_id in support of timeout
reversals
The `reversal_id` field can be added to any auth or purchase
transaction. In the event of a timeout, the same `reversal_id` can then
be specified via `void` to reverse the transaction. According to
Payeezy's documentation, this API is only available in production, but
the remote tests demonstrate that the API may function on the sandbox.
Ref: https://developer.payeezy.com/payeezy-api/apis/post/transactions-1
Unit:
33 tests, 156 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
33 tests, 131 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/payeezy.rb | 19 +++++++++---
test/remote/gateways/remote_payeezy_test.rb | 31 +++++++++++++++++++
test/unit/gateways/payeezy_test.rb | 19 ++++++++++--
4 files changed, 64 insertions(+), 6 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 29d3b368ef3..c0ecdcfe057 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -13,6 +13,7 @@
* [POSSIBLE BREAKAGE] Drop support for Solo and Switch cards [bpollack] #2991
* Add support for Carnet cards [bpollack] #2992
* Stripe: support a reason for voiding a transaction [whitby3001] #2378
+* Payeezy: Add reversal_id in support of timeout reversals [dtykocki] #2997
== Version 1.83.0 (August 30, 2018)
* CT Payment: Update How Address is Passed [nfarve] #2960
diff --git a/lib/active_merchant/billing/gateways/payeezy.rb b/lib/active_merchant/billing/gateways/payeezy.rb
index fb8609b526a..dad7cbebd69 100644
--- a/lib/active_merchant/billing/gateways/payeezy.rb
+++ b/lib/active_merchant/billing/gateways/payeezy.rb
@@ -34,6 +34,7 @@ def purchase(amount, payment_method, options = {})
params = payment_method.is_a?(String) ? { transaction_type: 'recurring' } : { transaction_type: 'purchase' }
add_invoice(params, options)
+ add_reversal_id(params, options)
add_payment_method(params, payment_method, options)
add_address(params, options)
add_amount(params, amount, options)
@@ -46,6 +47,7 @@ def authorize(amount, payment_method, options = {})
params = {transaction_type: 'authorize'}
add_invoice(params, options)
+ add_reversal_id(params, options)
add_payment_method(params, payment_method, options)
add_address(params, options)
add_amount(params, amount, options)
@@ -84,7 +86,7 @@ def store(payment_method, options = {})
def void(authorization, options = {})
params = {transaction_type: 'void'}
- add_authorization_info(params, authorization)
+ add_authorization_info(params, authorization, options)
add_amount(params, amount_from_authorization(authorization), options)
commit(params, options)
@@ -123,15 +125,24 @@ def add_invoice(params, options)
params[:merchant_ref] = options[:order_id]
end
+ def add_reversal_id(params, options)
+ params[:reversal_id] = options[:reversal_id] if options[:reversal_id]
+ end
+
def amount_from_authorization(authorization)
authorization.split('|').last.to_i
end
- def add_authorization_info(params, authorization)
+ def add_authorization_info(params, authorization, options = {})
transaction_id, transaction_tag, method, _ = authorization.split('|')
- params[:transaction_id] = transaction_id
- params[:transaction_tag] = transaction_tag
params[:method] = (method == 'token') ? 'credit_card' : method
+
+ if options[:reversal_id]
+ params[:reversal_id] = options[:reversal_id]
+ else
+ params[:transaction_id] = transaction_id
+ params[:transaction_tag] = transaction_tag
+ end
end
def add_creditcard_for_tokenization(params, payment_method, options)
diff --git a/test/remote/gateways/remote_payeezy_test.rb b/test/remote/gateways/remote_payeezy_test.rb
index 497332317ac..2580c070dbe 100644
--- a/test/remote/gateways/remote_payeezy_test.rb
+++ b/test/remote/gateways/remote_payeezy_test.rb
@@ -7,6 +7,7 @@ def setup
@bad_credit_card = credit_card('4111111111111113')
@check = check
@amount = 100
+ @reversal_id = "REV-#{SecureRandom.random_number(1000000)}"
@options = {
:billing_address => address,
:merchant_ref => 'Store Purchase',
@@ -178,6 +179,36 @@ def test_successful_void
assert_equal 'Transaction Normal - Approved', void.message
end
+ def test_successful_auth_void_with_reversal_id
+ auth = @gateway.authorize(@amount, @credit_card, @options.merge(reversal_id: @reversal_id))
+ assert_success auth
+
+ assert void = @gateway.void(auth.authorization, reversal_id: @reversal_id)
+ assert_success void
+ assert_equal 'Transaction Normal - Approved', void.message
+ end
+
+ def test_successful_void_purchase_with_reversal_id
+ response = @gateway.purchase(@amount, @credit_card, @options.merge(reversal_id: @reversal_id))
+ assert_success response
+
+ assert void = @gateway.void(response.authorization, reversal_id: @reversal_id)
+ assert_success void
+ assert_equal 'Transaction Normal - Approved', void.message
+ end
+
+ def test_successful_void_with_stored_card_and_reversal_id
+ response = @gateway.store(@credit_card, @options)
+ assert_success response
+
+ auth = @gateway.authorize(@amount, response.authorization, @options.merge(reversal_id: @reversal_id))
+ assert_success auth
+
+ assert void = @gateway.void(auth.authorization, reversal_id: @reversal_id)
+ assert_success void
+ assert_equal 'Transaction Normal - Approved', void.message
+ end
+
def test_successful_void_with_stored_card
response = @gateway.store(@credit_card, @options)
assert_success response
diff --git a/test/unit/gateways/payeezy_test.rb b/test/unit/gateways/payeezy_test.rb
index 87c61922b34..6d95954c196 100644
--- a/test/unit/gateways/payeezy_test.rb
+++ b/test/unit/gateways/payeezy_test.rb
@@ -16,6 +16,7 @@ def setup
:ta_token => '123'
}
@authorization = 'ET1700|106625152|credit_card|4738'
+ @reversal_id = SecureRandom.random_number(1000000).to_s
end
def test_invalid_credentials
@@ -174,11 +175,25 @@ def test_failed_refund
end
def test_successful_void
- @gateway.expects(:ssl_post).returns(successful_void_response)
- assert response = @gateway.void(@authorization, @options)
+ response = stub_comms do
+ @gateway.void(@authorization, @options)
+ end.check_request do |endpoint, data, headers|
+ json = '{"transaction_type":"void","method":"credit_card","transaction_tag":"106625152","currency_code":"USD","amount":"4738"}'
+ assert_match json, data
+ end.respond_with(successful_void_response)
+
assert_success response
end
+ def test_successful_void_with_reversal_id
+ stub_comms do
+ @gateway.void(@authorization, @options.merge(reversal_id: @reversal_id))
+ end.check_request do |endpoint, data, headers|
+ json = "{\"transaction_type\":\"void\",\"method\":\"credit_card\",\"reversal_id\":\"#{@reversal_id}\",\"currency_code\":\"USD\",\"amount\":\"4738\"}"
+ assert_match json, data
+ end.respond_with(successful_void_response)
+ end
+
def test_failed_void
@gateway.expects(:ssl_post).raises(failed_void_response)
assert response = @gateway.void(@authorization, @options)
From 5850497a01d7d08dbfddcaf00f25659196ff3fde Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 20 Sep 2018 16:00:39 -0400
Subject: [PATCH 0092/2234] Stripe: handle much more complicated post
structures
Previously, we couldn't handle Stripe endpoints that had arrays of
hashes, among other things. This fixes that. In the process, this also
switches from implicit to explicit array indices, which allows
supporting an upcoming feature.
Unit: 129 tests, 682 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote: 65 tests, 298 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
.../billing/gateways/stripe.rb | 34 +++++++++++++------
test/unit/gateways/stripe_test.rb | 18 +++++-----
2 files changed, 34 insertions(+), 18 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb
index 2e80ab70041..5aeaadc7d35 100644
--- a/lib/active_merchant/billing/gateways/stripe.rb
+++ b/lib/active_merchant/billing/gateways/stripe.rb
@@ -491,25 +491,39 @@ def parse(body)
def post_data(params)
return nil unless params
+ flatten_params([], params).join('&')
+ end
- params.map do |key, value|
+ def flatten_params(flattened, params, prefix = nil)
+ params.each do |key, value|
next if value != false && value.blank?
+ flattened_key = prefix.nil? ? key : "#{prefix}[#{key}]"
if value.is_a?(Hash)
- h = {}
- value.each do |k, v|
- h["#{key}[#{k}]"] = v unless v.blank?
- end
- post_data(h)
+ flatten_params(flattened, value, flattened_key)
elsif value.is_a?(Array)
- value.map { |v| "#{key}[]=#{CGI.escape(v.to_s)}" }.join('&')
+ flatten_array(flattened, value, flattened_key)
+ else
+ flattened << "#{flattened_key}=#{CGI.escape(value.to_s)}"
+ end
+ end
+ flattened
+ end
+
+ def flatten_array(flattened, array, prefix)
+ array.each_with_index do |item, idx|
+ key = "#{prefix}[#{idx}]"
+ if item.is_a?(Hash)
+ flatten_params(flattened, item, key)
+ elsif item.is_a?(Array)
+ flatten_array(flattened, item, key)
else
- "#{key}=#{CGI.escape(value.to_s)}"
+ flattened << "#{key}=#{CGI.escape(item.to_s)}"
end
- end.compact.join('&')
+ end
end
def headers(options = {})
- key = options[:key] || @api_key
+ key = options[:key] || @api_key
idempotency_key = options[:idempotency_key]
headers = {
diff --git a/test/unit/gateways/stripe_test.rb b/test/unit/gateways/stripe_test.rb
index 8708f9b4867..0315822770e 100644
--- a/test/unit/gateways/stripe_test.rb
+++ b/test/unit/gateways/stripe_test.rb
@@ -501,7 +501,7 @@ def test_successful_void
def test_void_contains_charge_expand
@gateway.expects(:ssl_request).with do |_, _, post, _|
- post.include?('expand[]=charge')
+ post.include?('expand[0]=charge')
end.returns(successful_purchase_response(true))
assert response = @gateway.void('ch_test_charge')
@@ -511,7 +511,8 @@ def test_void_contains_charge_expand
def test_void_with_additional_expand_contains_two_expands
@gateway.expects(:ssl_request).with do |_, _, post, _|
parsed = CGI.parse(post)
- parsed['expand[]'].sort == ['balance_transaction', 'charge'].sort
+ parsed['expand[0]'] = 'balance_transaction'
+ parsed['expand[1]'] = 'charge'
end.returns(successful_purchase_response(true))
assert response = @gateway.void('ch_test_charge', expand: :balance_transaction)
@@ -521,7 +522,7 @@ def test_void_with_additional_expand_contains_two_expands
def test_void_with_expand_charge_only_sends_one_charge_expand
@gateway.expects(:ssl_request).with do |_, _, post, _|
parsed = CGI.parse(post)
- parsed['expand[]'] == ['charge']
+ parsed['expand[0]'] == ['charge']
end.returns(successful_purchase_response(true))
assert response = @gateway.void('ch_test_charge', expand: ['charge'])
@@ -573,7 +574,7 @@ def test_successful_refund_with_refund_application_fee
def test_refund_contains_charge_expand
@gateway.expects(:ssl_request).with do |_, _, post, _|
- post.include?('expand[]=charge')
+ post.include?('expand[0]=charge')
end.returns(successful_partially_refunded_response)
assert response = @gateway.refund(@refund_amount, 'ch_test_charge')
@@ -583,7 +584,8 @@ def test_refund_contains_charge_expand
def test_refund_with_additional_expand_contains_two_expands
@gateway.expects(:ssl_request).with do |_, _, post, _|
parsed = CGI.parse(post)
- parsed['expand[]'].sort == ['balance_transaction', 'charge'].sort
+ parsed['expand[0]'] = 'balance_transaction'
+ parsed['expand[1]'] = 'charge'
end.returns(successful_partially_refunded_response)
assert response = @gateway.refund(@refund_amount, 'ch_test_charge', expand: :balance_transaction)
@@ -593,7 +595,7 @@ def test_refund_with_additional_expand_contains_two_expands
def test_refund_with_expand_charge_only_sends_one_charge_expand
@gateway.expects(:ssl_request).with do |_, _, post, _|
parsed = CGI.parse(post)
- parsed['expand[]'] == ['charge']
+ parsed['expand[0]'] == ['charge']
end.returns(successful_partially_refunded_response)
assert response = @gateway.refund(@refund_amount, 'ch_test_charge', expand: ['charge'])
@@ -1152,7 +1154,7 @@ def generate_options_should_allow_key
def test_passing_expand_parameters
@gateway.expects(:ssl_request).with do |method, url, post, headers|
- post.include?('expand[]=balance_transaction')
+ post.include?('expand[0]=balance_transaction')
end.returns(successful_authorization_response)
@options.merge!(:expand => :balance_transaction)
@@ -1162,7 +1164,7 @@ def test_passing_expand_parameters
def test_passing_expand_parameters_as_array
@gateway.expects(:ssl_request).with do |method, url, post, headers|
- post.include?('expand[]=balance_transaction&expand[]=customer')
+ post.include?('expand[0]=balance_transaction&expand[1]=customer')
end.returns(successful_authorization_response)
@options.merge!(:expand => [:balance_transaction, :customer])
From 3348aca387ebbf646f59d015af3d0fd808ef0258 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 20 Sep 2018 17:51:00 -0400
Subject: [PATCH 0093/2234] Stripe: add full Level 3 support
Unit: 129 tests, 693 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote: 66 tests, 305 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/stripe.rb | 32 +++++++++++++++
test/remote/gateways/remote_stripe_test.rb | 32 +++++++++++++++
test/unit/gateways/stripe_test.rb | 40 +++++++++++++++++++
4 files changed, 105 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index c0ecdcfe057..7394938edba 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -14,6 +14,7 @@
* Add support for Carnet cards [bpollack] #2992
* Stripe: support a reason for voiding a transaction [whitby3001] #2378
* Payeezy: Add reversal_id in support of timeout reversals [dtykocki] #2997
+* Stripe: support Level 3 transaction fields [bpollack] #2996
== Version 1.83.0 (August 30, 2018)
* CT Payment: Update How Address is Passed [nfarve] #2960
diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb
index 5aeaadc7d35..49c7077a2a8 100644
--- a/lib/active_merchant/billing/gateways/stripe.rb
+++ b/lib/active_merchant/billing/gateways/stripe.rb
@@ -324,6 +324,7 @@ def create_post_for_auth_or_purchase(money, payment, options)
add_application_fee(post, options)
add_exchange_rate(post, options)
add_destination(post, options)
+ add_level_three(post, options)
post
end
@@ -349,6 +350,21 @@ def add_destination(post, options)
end
end
+ def add_level_three(post, options)
+ level_three = {}
+
+ copy_when_present(level_three, [:merchant_reference], options)
+ copy_when_present(level_three, [:customer_reference], options)
+ copy_when_present(level_three, [:shipping_address_zip], options)
+ copy_when_present(level_three, [:shipping_from_zip], options)
+ copy_when_present(level_three, [:shipping_amount], options)
+ copy_when_present(level_three, [:line_items], options)
+
+ unless level_three.empty?
+ post[:level3] = level_three
+ end
+ end
+
def add_expand_parameters(post, options)
post[:expand] ||= []
post[:expand].concat(Array.wrap(options[:expand]).map(&:to_sym)).uniq!
@@ -695,6 +711,22 @@ def auth_minimum_amount(options)
return 100 unless options[:currency]
return MINIMUM_AUTHORIZE_AMOUNTS[options[:currency].upcase] || 100
end
+
+ def copy_when_present(dest, dest_path, source, source_path = nil)
+ source_path ||= dest_path
+ source_path.each do |key|
+ return nil unless source[key]
+ source = source[key]
+ end
+
+ if source
+ dest_path.first(dest_path.size - 1).each do |key|
+ dest[key] ||= {}
+ dest = dest[key]
+ end
+ dest[dest_path.last] = source
+ end
+ end
end
end
end
diff --git a/test/remote/gateways/remote_stripe_test.rb b/test/remote/gateways/remote_stripe_test.rb
index cf1948cb7a0..cbc94e8ab52 100644
--- a/test/remote/gateways/remote_stripe_test.rb
+++ b/test/remote/gateways/remote_stripe_test.rb
@@ -90,6 +90,38 @@ def test_successful_purchase_with_destination_and_amount
assert_equal 'wow@example.com', response.params['metadata']['email']
end
+ def test_successful_purchase_with_level3_data
+ @options[:merchant_reference] = 123
+ @options[:customer_reference] = 456
+ @options[:shipping_address_zip] = 98765
+ @options[:shipping_from_zip] = 54321
+ @options[:shipping_amount] = 10
+ @options[:line_items] = [
+ {
+ 'product_code' => 1234,
+ 'product_description' => 'An item',
+ 'unit_cost' => 15,
+ 'quantity' => 2,
+ 'tax_amount' => 0
+ },
+ {
+ 'product_code' => 999,
+ 'product_description' => 'A totes different item',
+ 'tax_amount' => 10,
+ 'unit_cost' => 50,
+ 'quantity' => 1,
+ }
+ ]
+
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
+ assert_success response
+ assert_equal 'charge', response.params['object']
+ assert_equal response.authorization, response.params['id']
+ assert response.params['paid']
+ assert_equal 'ActiveMerchant Test Purchase', response.params['description']
+ assert_equal 'wow@example.com', response.params['metadata']['email']
+ end
+
def test_unsuccessful_purchase
assert response = @gateway.purchase(@amount, @declined_card, @options)
assert_failure response
diff --git a/test/unit/gateways/stripe_test.rb b/test/unit/gateways/stripe_test.rb
index 0315822770e..f6a99162f3b 100644
--- a/test/unit/gateways/stripe_test.rb
+++ b/test/unit/gateways/stripe_test.rb
@@ -429,6 +429,46 @@ def test_successful_purchase_with_apple_pay_token_exchange
assert response.test?
end
+ def test_successful_purchase_with_level3_data
+ @gateway.expects(:add_creditcard)
+
+ @options[:merchant_reference] = 123
+ @options[:customer_reference] = 456
+ @options[:shipping_address_zip] = 98765
+ @options[:shipping_from_zip] = 54321
+ @options[:shipping_amount] = 40
+ @options[:line_items] = [
+ {
+ 'product_code' => 1234,
+ 'product_description' => 'An item',
+ 'unit_cost' => 60,
+ 'quantity' => 7,
+ 'tax_amount' => 0
+ },
+ {
+ 'product_code' => 999,
+ 'tax_amount' => 888
+ }
+ ]
+
+ response = stub_comms(@gateway, :ssl_request) do
+ @gateway.purchase(@amount, @credit_card, @options)
+ end.check_request do |_method, endpoint, data, _headers|
+ if %r{/charges} =~ endpoint
+ assert_match('level3[merchant_reference]=123', data)
+ assert_match('level3[customer_reference]=456', data)
+ assert_match('level3[shipping_address_zip]=98765', data)
+ assert_match('level3[shipping_amount]=40', data)
+ assert_match('level3[shipping_from_zip]=54321', data)
+ assert_match('level3[line_items][0][product_description]=An+item', data)
+ assert_match('level3[line_items][1][product_code]=999', data)
+ end
+ end.respond_with(successful_purchase_response)
+
+ assert_success response
+ assert response.test?
+ end
+
def test_amount_localization
@gateway.expects(:ssl_request).returns(successful_purchase_response(true))
@gateway.expects(:post_data).with do |params|
From d4d927e42a6ac7c0ce15be7e9a14f6c2f00a0ff5 Mon Sep 17 00:00:00 2001
From: David Whitby
Date: Mon, 27 Mar 2017 16:49:52 +0100
Subject: [PATCH 0094/2234] Stripe: support shipping info in purchases
Closes #2379
---
CHANGELOG | 1 +
.../billing/gateways/stripe.rb | 23 +++++++++++++++++++
test/remote/gateways/remote_stripe_test.rb | 18 +++++++++++++++
test/unit/gateways/stripe_test.rb | 20 +++++++++++++++-
4 files changed, 61 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 7394938edba..66a94d43280 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -15,6 +15,7 @@
* Stripe: support a reason for voiding a transaction [whitby3001] #2378
* Payeezy: Add reversal_id in support of timeout reversals [dtykocki] #2997
* Stripe: support Level 3 transaction fields [bpollack] #2996
+* Stripe: support passing shipping info for purchases [whitby3001] #2379
== Version 1.83.0 (August 30, 2018)
* CT Payment: Update How Address is Passed [nfarve] #2960
diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb
index 49c7077a2a8..0424cde6b42 100644
--- a/lib/active_merchant/billing/gateways/stripe.rb
+++ b/lib/active_merchant/billing/gateways/stripe.rb
@@ -321,6 +321,7 @@ def create_post_for_auth_or_purchase(money, payment, options)
end
add_metadata(post, options)
+ add_shipping_info(post, options)
add_application_fee(post, options)
add_exchange_rate(post, options)
add_destination(post, options)
@@ -489,6 +490,28 @@ def add_emv_metadata(post, creditcard)
post[:metadata] ||= {}
post[:metadata][:card_read_method] = creditcard.read_method if creditcard.respond_to?(:read_method)
end
+
+ def add_shipping_info(post, options = {})
+ post[:shipping] = {}
+
+ if address = options[:shipping_address]
+ address_params = {}
+ address_params[:line1] = address[:address1] if address[:address1]
+ address_params[:line2] = address[:address2] if address[:address2]
+ address_params[:city] = address[:city] if address[:city]
+ address_params[:state] = address[:state] if address[:state]
+ address_params[:postal_code] = address[:zip] if address[:zip]
+ address_params[:country] = address[:country] if address[:country]
+ post[:shipping][:address] = address_params unless address_params.empty?
+ post[:shipping][:name] = address[:name] if address[:name]
+ post[:shipping][:phone] = address[:phone] if address[:phone]
+ end
+
+ post[:shipping][:carrier] = options[:carrier] if options[:carrier]
+ post[:shipping][:tracking_number] = options[:tracking_number] if options[:tracking_number]
+
+ post.delete(:shipping) if post[:shipping].empty?
+ end
def fetch_application_fee(identification, options = {})
options.merge!(:key => @fee_refund_api_key)
diff --git a/test/remote/gateways/remote_stripe_test.rb b/test/remote/gateways/remote_stripe_test.rb
index cbc94e8ab52..3fecb1ba64d 100644
--- a/test/remote/gateways/remote_stripe_test.rb
+++ b/test/remote/gateways/remote_stripe_test.rb
@@ -122,6 +122,24 @@ def test_successful_purchase_with_level3_data
assert_equal 'wow@example.com', response.params['metadata']['email']
end
+ def test_successful_purchase_with_shipping_info
+ custom_options = @options.merge(:shipping_address => address(), :carrier => 'UPS', :tracking_number => '12345')
+ assert response = @gateway.purchase(@amount, @credit_card, custom_options)
+ assert_success response
+ assert_equal 'charge', response.params['object']
+ assert response.params['paid']
+ assert_equal custom_options[:shipping_address][:name], response.params['shipping']['name']
+ assert_equal custom_options[:shipping_address][:address1], response.params['shipping']['address']['line1']
+ assert_equal custom_options[:shipping_address][:address2], response.params['shipping']['address']['line2']
+ assert_equal custom_options[:shipping_address][:city], response.params['shipping']['address']['city']
+ assert_equal custom_options[:shipping_address][:state], response.params['shipping']['address']['state']
+ assert_equal custom_options[:shipping_address][:zip], response.params['shipping']['address']['postal_code']
+ assert_equal custom_options[:shipping_address][:country], response.params['shipping']['address']['country']
+ assert_equal custom_options[:shipping_address][:phone], response.params['shipping']['phone']
+ assert_equal custom_options[:carrier], response.params['shipping']['carrier']
+ assert_equal custom_options[:tracking_number], response.params['shipping']['tracking_number']
+ end
+
def test_unsuccessful_purchase
assert response = @gateway.purchase(@amount, @declined_card, @options)
assert_failure response
diff --git a/test/unit/gateways/stripe_test.rb b/test/unit/gateways/stripe_test.rb
index f6a99162f3b..84c43f52a05 100644
--- a/test/unit/gateways/stripe_test.rb
+++ b/test/unit/gateways/stripe_test.rb
@@ -13,7 +13,10 @@ def setup
@options = {
:billing_address => address(),
:statement_address => statement_address(),
- :description => 'Test Purchase'
+ :description => 'Test Purchase',
+ :shipping_address => address(),
+ :carrier => 'UPS',
+ :tracking_number => '12345'
}
@apple_pay_payment_token = apple_pay_payment_token
@@ -1060,6 +1063,21 @@ def test_add_statement_address_returns_nil_if_required_fields_missing
end
end
+ def test_add_shipping_info
+ post = {:card => {}}
+ @gateway.send(:add_shipping_info, post, @options)
+ assert_equal @options[:shipping_address][:zip], post[:shipping][:address][:postal_code]
+ assert_equal @options[:shipping_address][:state], post[:shipping][:address][:state]
+ assert_equal @options[:shipping_address][:address1], post[:shipping][:address][:line1]
+ assert_equal @options[:shipping_address][:address2], post[:shipping][:address][:line2]
+ assert_equal @options[:shipping_address][:country], post[:shipping][:address][:country]
+ assert_equal @options[:shipping_address][:city], post[:shipping][:address][:city]
+ assert_equal @options[:shipping_address][:name], post[:shipping][:name]
+ assert_equal @options[:shipping_address][:phone], post[:shipping][:phone]
+ assert_equal @options[:carrier], post[:shipping][:carrier]
+ assert_equal @options[:tracking_number], post[:shipping][:tracking_number]
+ end
+
def test_ensure_does_not_respond_to_credit
assert !@gateway.respond_to?(:credit)
end
From c45a369fe02f69cd6847198c6a4808f3a0587539 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Fri, 21 Sep 2018 13:50:02 -0400
Subject: [PATCH 0095/2234] RuboCop: fix most EmptyLines* rules
This explicitly skips Layout/EmptyLinesAroundClassBody because it needs
some discussion. The rest is straightforward and are pretty solid
readability improvements.
---
.rubocop_todo.yml | 21 -------------------
lib/active_merchant/billing/check.rb | 1 +
lib/active_merchant/billing/credit_card.rb | 1 +
lib/active_merchant/billing/gateways/adyen.rb | 1 -
.../billing/gateways/allied_wallet.rb | 1 -
.../billing/gateways/authorize_net.rb | 1 -
.../billing/gateways/beanstream.rb | 1 +
.../billing/gateways/bridge_pay.rb | 1 -
.../billing/gateways/card_stream.rb | 1 -
.../billing/gateways/cardknox.rb | 1 -
.../billing/gateways/commercegate.rb | 1 -
.../billing/gateways/creditcall.rb | 1 -
.../billing/gateways/data_cash.rb | 2 --
lib/active_merchant/billing/gateways/dibs.rb | 2 --
.../billing/gateways/efsnet.rb | 1 -
lib/active_merchant/billing/gateways/epay.rb | 1 -
lib/active_merchant/billing/gateways/eway.rb | 1 +
.../billing/gateways/eway_managed.rb | 1 -
lib/active_merchant/billing/gateways/exact.rb | 1 -
.../billing/gateways/garanti.rb | 1 -
.../billing/gateways/global_collect.rb | 1 -
.../billing/gateways/inspire.rb | 2 +-
.../billing/gateways/latitude19.rb | 1 -
.../billing/gateways/linkpoint.rb | 3 +--
.../billing/gateways/mastercard.rb | 1 +
.../billing/gateways/mercado_pago.rb | 1 -
.../billing/gateways/merchant_e_solutions.rb | 1 -
.../billing/gateways/micropayment.rb | 2 --
.../billing/gateways/modern_payments.rb | 1 +
.../billing/gateways/modern_payments_cim.rb | 1 +
.../billing/gateways/nab_transact.rb | 1 -
.../billing/gateways/net_registry.rb | 1 +
lib/active_merchant/billing/gateways/nmi.rb | 1 -
.../billing/gateways/openpay.rb | 1 +
.../billing/gateways/optimal_payment.rb | 1 -
.../billing/gateways/orbital.rb | 1 -
.../billing/gateways/pay_secure.rb | 2 +-
.../billing/gateways/paybox_direct.rb | 1 -
lib/active_merchant/billing/gateways/payex.rb | 1 -
.../gateways/payflow/payflow_common_api.rb | 1 +
.../billing/gateways/payflow_express.rb | 2 +-
.../billing/gateways/paymill.rb | 2 --
.../billing/gateways/payscout.rb | 1 -
lib/active_merchant/billing/gateways/pin.rb | 1 +
.../billing/gateways/plugnpay.rb | 1 +
.../billing/gateways/psl_card.rb | 1 -
.../gateways/quickpay/quickpay_common.rb | 1 -
.../billing/gateways/realex.rb | 1 +
lib/active_merchant/billing/gateways/s5.rb | 1 -
.../billing/gateways/sage_pay.rb | 1 +
.../billing/gateways/secure_net.rb | 1 -
.../billing/gateways/securion_pay.rb | 1 -
.../billing/gateways/smart_ps.rb | 4 +---
.../billing/gateways/spreedly_core.rb | 1 -
.../billing/gateways/trexle.rb | 1 +
.../billing/gateways/trust_commerce.rb | 1 +
.../billing/gateways/viaklix.rb | 1 +
.../billing/gateways/wirecard.rb | 1 +
lib/active_merchant/connection.rb | 1 -
.../network_connection_retries.rb | 1 +
lib/active_merchant/post_data.rb | 1 +
lib/support/gateway_support.rb | 1 -
lib/support/ssl_verify.rb | 1 -
.../remote_authorize_net_apple_pay_test.rb | 1 -
.../gateways/remote_authorize_net_cim_test.rb | 1 -
test/remote/gateways/remote_banwire_test.rb | 1 -
test/remote/gateways/remote_blue_snap_test.rb | 1 -
.../gateways/remote_braintree_blue_test.rb | 2 +-
test/remote/gateways/remote_cardknox_test.rb | 1 -
test/remote/gateways/remote_cecabank_test.rb | 1 -
.../remote/gateways/remote_creditcall_test.rb | 1 -
.../gateways/remote_cyber_source_test.rb | 1 -
.../gateways/remote_first_giving_test.rb | 1 -
test/remote/gateways/remote_forte_test.rb | 1 -
test/remote/gateways/remote_iveri_test.rb | 1 -
test/remote/gateways/remote_jetpay_test.rb | 2 --
test/remote/gateways/remote_jetpay_v2_test.rb | 1 -
test/remote/gateways/remote_linkpoint_test.rb | 1 -
.../remote_litle_certification_test.rb | 3 ---
.../gateways/remote_modern_payments_test.rb | 1 -
test/remote/gateways/remote_nmi_test.rb | 1 -
.../gateways/remote_pay_junction_test.rb | 1 +
test/remote/gateways/remote_payscout_test.rb | 2 --
.../gateways/remote_quickpay_v4_test.rb | 2 --
.../gateways/remote_quickpay_v5_test.rb | 2 --
.../gateways/remote_quickpay_v6_test.rb | 2 --
test/remote/gateways/remote_realex_test.rb | 3 ---
.../gateways/remote_redsys_sha256_test.rb | 1 +
test/remote/gateways/remote_redsys_test.rb | 1 +
.../gateways/remote_so_easy_pay_test.rb | 1 -
...te_trans_first_transaction_express_test.rb | 1 -
test/remote/gateways/remote_worldpay_test.rb | 1 -
test/test_helper.rb | 4 +++-
test/unit/gateways/allied_wallet_test.rb | 2 --
test/unit/gateways/authorize_net_test.rb | 2 --
test/unit/gateways/balanced_test.rb | 1 -
test/unit/gateways/banwire_test.rb | 1 -
test/unit/gateways/beanstream_test.rb | 1 -
test/unit/gateways/blue_pay_test.rb | 2 --
test/unit/gateways/card_connect_test.rb | 1 -
test/unit/gateways/card_stream_test.rb | 1 -
test/unit/gateways/cashnet_test.rb | 1 +
test/unit/gateways/cecabank_test.rb | 1 -
test/unit/gateways/cenpos_test.rb | 1 -
test/unit/gateways/commercegate_test.rb | 1 -
test/unit/gateways/cyber_source_test.rb | 1 -
test/unit/gateways/data_cash_test.rb | 1 +
test/unit/gateways/digitzs_test.rb | 1 -
test/unit/gateways/efsnet_test.rb | 2 +-
test/unit/gateways/element_test.rb | 1 +
test/unit/gateways/eway_managed_test.rb | 1 -
test/unit/gateways/eway_test.rb | 1 +
test/unit/gateways/exact_test.rb | 4 ++--
test/unit/gateways/fat_zebra_test.rb | 1 +
test/unit/gateways/federated_canada_test.rb | 6 ++----
test/unit/gateways/firstdata_e4_test.rb | 3 +++
test/unit/gateways/gateway_test.rb | 1 -
test/unit/gateways/iridium_test.rb | 3 ---
test/unit/gateways/jetpay_test.rb | 1 +
test/unit/gateways/linkpoint_test.rb | 2 +-
test/unit/gateways/litle_test.rb | 1 -
test/unit/gateways/maxipago_test.rb | 1 -
test/unit/gateways/merchant_partners_test.rb | 1 -
test/unit/gateways/metrics_global_test.rb | 1 -
test/unit/gateways/moneris_us_test.rb | 3 ---
test/unit/gateways/ncr_secure_pay_test.rb | 8 -------
test/unit/gateways/net_registry_test.rb | 1 +
test/unit/gateways/netbanx_test.rb | 1 -
test/unit/gateways/netbilling_test.rb | 1 +
test/unit/gateways/netpay_test.rb | 1 -
test/unit/gateways/optimal_payment_test.rb | 1 -
test/unit/gateways/pay_gate_xml_test.rb | 2 --
test/unit/gateways/pay_junction_test.rb | 3 +--
test/unit/gateways/pay_secure_test.rb | 1 +
test/unit/gateways/payflow_express_uk_test.rb | 1 +
test/unit/gateways/paymill_test.rb | 1 +
.../gateways/paypal/paypal_common_api_test.rb | 3 ++-
.../gateways/paypal_digital_goods_test.rb | 3 ---
test/unit/gateways/paypal_express_test.rb | 4 ----
test/unit/gateways/paypal_test.rb | 1 -
test/unit/gateways/payscout_test.rb | 1 -
test/unit/gateways/paystation_test.rb | 2 --
test/unit/gateways/payway_test.rb | 1 -
test/unit/gateways/plugnpay_test.rb | 2 +-
test/unit/gateways/psl_card_test.rb | 1 +
test/unit/gateways/realex_test.rb | 3 ---
test/unit/gateways/sage_pay_test.rb | 2 --
test/unit/gateways/sage_test.rb | 1 +
test/unit/gateways/secure_pay_au_test.rb | 1 -
test/unit/gateways/secure_pay_tech_test.rb | 1 +
test/unit/gateways/secure_pay_test.rb | 1 -
test/unit/gateways/skip_jack_test.rb | 2 +-
test/unit/gateways/stripe_test.rb | 1 -
.../gateways/usa_epay_transaction_test.rb | 1 -
test/unit/gateways/verifi_test.rb | 2 --
test/unit/gateways/wirecard_test.rb | 1 -
.../gateways/worldpay_online_payments_test.rb | 2 ++
test/unit/network_connection_retries_test.rb | 1 -
158 files changed, 62 insertions(+), 185 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index fb937502eb4..99cea84dfd4 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -60,22 +60,6 @@ Layout/ElseAlignment:
- 'lib/active_merchant/billing/gateways/trust_commerce.rb'
- 'lib/active_merchant/billing/response.rb'
-# Offense count: 66
-# Cop supports --auto-correct.
-# Configuration parameters: AllowAdjacentOneLineDefs, NumberOfEmptyLines.
-Layout/EmptyLineBetweenDefs:
- Enabled: false
-
-# Offense count: 97
-# Cop supports --auto-correct.
-Layout/EmptyLines:
- Enabled: false
-
-# Offense count: 49
-# Cop supports --auto-correct.
-Layout/EmptyLinesAroundAccessModifier:
- Enabled: false
-
# Offense count: 165
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
@@ -83,11 +67,6 @@ Layout/EmptyLinesAroundAccessModifier:
Layout/EmptyLinesAroundClassBody:
Enabled: false
-# Offense count: 64
-# Cop supports --auto-correct.
-Layout/EmptyLinesAroundMethodBody:
- Enabled: false
-
# Offense count: 40
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleAlignWith, AutoCorrect, Severity.
diff --git a/lib/active_merchant/billing/check.rb b/lib/active_merchant/billing/check.rb
index 410359c41b6..9d73819560a 100644
--- a/lib/active_merchant/billing/check.rb
+++ b/lib/active_merchant/billing/check.rb
@@ -53,6 +53,7 @@ def type
def credit_card?
false
end
+
# Routing numbers may be validated by calculating a checksum and dividing it by 10. The
# formula is:
# (3(d1 + d4 + d7) + 7(d2 + d5 + d8) + 1(d3 + d6 + d9))mod 10 = 0
diff --git a/lib/active_merchant/billing/credit_card.rb b/lib/active_merchant/billing/credit_card.rb
index 4d1afcae1bf..19dcbec394a 100644
--- a/lib/active_merchant/billing/credit_card.rb
+++ b/lib/active_merchant/billing/credit_card.rb
@@ -386,6 +386,7 @@ def expiration #:nodoc:
end
private
+
def month_days
mdays = [nil,31,28,31,30,31,30,31,31,30,31,30,31]
mdays[2] = 29 if Date.leap?(year)
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index d7fb3a94042..c73db70be52 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -249,7 +249,6 @@ def commit(action, parameters)
test: test?,
error_code: success ? nil : error_code_from(response)
)
-
end
def url
diff --git a/lib/active_merchant/billing/gateways/allied_wallet.rb b/lib/active_merchant/billing/gateways/allied_wallet.rb
index a7f359849c1..55181e90d30 100644
--- a/lib/active_merchant/billing/gateways/allied_wallet.rb
+++ b/lib/active_merchant/billing/gateways/allied_wallet.rb
@@ -128,7 +128,6 @@ def add_reference(post, authorization, action)
post[transactions[action]] = authorization
end
-
ACTIONS = {
purchase: 'SALE',
authorize: 'AUTHORIZE',
diff --git a/lib/active_merchant/billing/gateways/authorize_net.rb b/lib/active_merchant/billing/gateways/authorize_net.rb
index 12df74d02bc..db7367210b4 100644
--- a/lib/active_merchant/billing/gateways/authorize_net.rb
+++ b/lib/active_merchant/billing/gateways/authorize_net.rb
@@ -604,7 +604,6 @@ def add_shipping_address(xml, options, root_node='shipTo')
xml.zip(truncate(address[:zip], 20))
xml.country(truncate(address[:country], 60))
end
-
end
def add_order_id(xml, options)
diff --git a/lib/active_merchant/billing/gateways/beanstream.rb b/lib/active_merchant/billing/gateways/beanstream.rb
index 3530ddfd167..d42209db38d 100644
--- a/lib/active_merchant/billing/gateways/beanstream.rb
+++ b/lib/active_merchant/billing/gateways/beanstream.rb
@@ -205,6 +205,7 @@ def scrub(transcript)
end
private
+
def build_response(*args)
Response.new(*args)
end
diff --git a/lib/active_merchant/billing/gateways/bridge_pay.rb b/lib/active_merchant/billing/gateways/bridge_pay.rb
index 091d8ac1a65..ae2e653f4b6 100644
--- a/lib/active_merchant/billing/gateways/bridge_pay.rb
+++ b/lib/active_merchant/billing/gateways/bridge_pay.rb
@@ -13,7 +13,6 @@ class BridgePayGateway < Gateway
self.default_currency = 'USD'
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb]
-
def initialize(options={})
requires!(options, :user_name, :password)
super
diff --git a/lib/active_merchant/billing/gateways/card_stream.rb b/lib/active_merchant/billing/gateways/card_stream.rb
index 993c61f027a..c049b2dff57 100644
--- a/lib/active_merchant/billing/gateways/card_stream.rb
+++ b/lib/active_merchant/billing/gateways/card_stream.rb
@@ -350,7 +350,6 @@ def avs_from(response)
})
end
-
def currency_code(currency)
CURRENCY_CODES[currency]
end
diff --git a/lib/active_merchant/billing/gateways/cardknox.rb b/lib/active_merchant/billing/gateways/cardknox.rb
index 0345173d4f6..aa61d77dc77 100644
--- a/lib/active_merchant/billing/gateways/cardknox.rb
+++ b/lib/active_merchant/billing/gateways/cardknox.rb
@@ -279,7 +279,6 @@ def parse(body)
}.delete_if{|k, v| v.nil?}
end
-
def commit(action, source_type, parameters)
response = parse(ssl_post(live_url, post_data(COMMANDS[source_type][action], parameters)))
diff --git a/lib/active_merchant/billing/gateways/commercegate.rb b/lib/active_merchant/billing/gateways/commercegate.rb
index 77aede1e9de..c831141b0c8 100644
--- a/lib/active_merchant/billing/gateways/commercegate.rb
+++ b/lib/active_merchant/billing/gateways/commercegate.rb
@@ -76,7 +76,6 @@ def add_auth_purchase_options(post, money, options)
post[:email] = options[:email] || 'unknown@example.com'
post[:currencyCode]= options[:currency] || currency(money)
post[:merchAcct] = options[:merchant]
-
end
def add_creditcard(params, creditcard)
diff --git a/lib/active_merchant/billing/gateways/creditcall.rb b/lib/active_merchant/billing/gateways/creditcall.rb
index a140cbfa4a2..4ce8a1f916d 100644
--- a/lib/active_merchant/billing/gateways/creditcall.rb
+++ b/lib/active_merchant/billing/gateways/creditcall.rb
@@ -214,7 +214,6 @@ def parse(body)
end
end
-
response
end
diff --git a/lib/active_merchant/billing/gateways/data_cash.rb b/lib/active_merchant/billing/gateways/data_cash.rb
index 1e31db78dc5..f943a330d01 100644
--- a/lib/active_merchant/billing/gateways/data_cash.rb
+++ b/lib/active_merchant/billing/gateways/data_cash.rb
@@ -214,7 +214,6 @@ def add_authentication(xml)
end
def add_credit_card(xml, credit_card, address)
-
xml.tag! :Card do
# DataCash calls the CC number 'pan'
xml.tag! :pan, credit_card.number
@@ -274,7 +273,6 @@ def format_date(month, year)
end
def parse(body)
-
response = {}
xml = REXML::Document.new(body)
root = REXML::XPath.first(xml, '//Response')
diff --git a/lib/active_merchant/billing/gateways/dibs.rb b/lib/active_merchant/billing/gateways/dibs.rb
index 5379b738107..647d749bdae 100644
--- a/lib/active_merchant/billing/gateways/dibs.rb
+++ b/lib/active_merchant/billing/gateways/dibs.rb
@@ -34,7 +34,6 @@ def authorize(amount, payment_method, options={})
add_ticket_id(post, payment_method)
commit(:authorize_ticket, post)
end
-
end
def capture(amount, authorization, options={})
@@ -114,7 +113,6 @@ def add_payment_method(post, payment_method, options)
post[:test] = true if test?
end
-
def add_reference(post, authorization)
post[:transactionId] = authorization
end
diff --git a/lib/active_merchant/billing/gateways/efsnet.rb b/lib/active_merchant/billing/gateways/efsnet.rb
index e9785556819..a7e428b1eff 100644
--- a/lib/active_merchant/billing/gateways/efsnet.rb
+++ b/lib/active_merchant/billing/gateways/efsnet.rb
@@ -142,7 +142,6 @@ def add_creditcard(post, creditcard)
post[:expiration_year] = sprintf('%.4i', creditcard.year)[-2..-1]
end
-
def commit(action, parameters)
response = parse(ssl_post(test? ? self.test_url : self.live_url, post_data(action, parameters), 'Content-Type' => 'text/xml'))
diff --git a/lib/active_merchant/billing/gateways/epay.rb b/lib/active_merchant/billing/gateways/epay.rb
index 19ddbf5365a..7f351623253 100644
--- a/lib/active_merchant/billing/gateways/epay.rb
+++ b/lib/active_merchant/billing/gateways/epay.rb
@@ -120,7 +120,6 @@ def scrub(transcript)
gsub(%r((&?cvc=)\d*(&?)), '\1[FILTERED]\2')
end
-
private
def add_amount(post, money, options)
diff --git a/lib/active_merchant/billing/gateways/eway.rb b/lib/active_merchant/billing/gateways/eway.rb
index 1c24fb8032f..a45db4bf881 100644
--- a/lib/active_merchant/billing/gateways/eway.rb
+++ b/lib/active_merchant/billing/gateways/eway.rb
@@ -64,6 +64,7 @@ def scrub(transcript)
end
private
+
def requires_address!(options)
raise ArgumentError.new('Missing eWay required parameters: address or billing_address') unless (options.has_key?(:address) or options.has_key?(:billing_address))
end
diff --git a/lib/active_merchant/billing/gateways/eway_managed.rb b/lib/active_merchant/billing/gateways/eway_managed.rb
index c08ebcd4285..bd5281511c3 100644
--- a/lib/active_merchant/billing/gateways/eway_managed.rb
+++ b/lib/active_merchant/billing/gateways/eway_managed.rb
@@ -136,7 +136,6 @@ def add_invoice(post, options)
post[:invoiceDescription] = options[:description]
end
-
# add credit card details to be stored by eway. NOTE eway requires "title" field
def add_creditcard(post, creditcard)
post[:CCNumber] = creditcard.number
diff --git a/lib/active_merchant/billing/gateways/exact.rb b/lib/active_merchant/billing/gateways/exact.rb
index a5d073a76ab..915a1a82c5d 100644
--- a/lib/active_merchant/billing/gateways/exact.rb
+++ b/lib/active_merchant/billing/gateways/exact.rb
@@ -13,7 +13,6 @@ class ExactGateway < Gateway
:capture => '32',
:credit => '34' }
-
ENVELOPE_NAMESPACES = { 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema',
'xmlns:env' => 'http://schemas.xmlsoap.org/soap/envelope/',
'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance'
diff --git a/lib/active_merchant/billing/gateways/garanti.rb b/lib/active_merchant/billing/gateways/garanti.rb
index eb77b969a47..fbd202ceee6 100644
--- a/lib/active_merchant/billing/gateways/garanti.rb
+++ b/lib/active_merchant/billing/gateways/garanti.rb
@@ -30,7 +30,6 @@ class GarantiGateway < Gateway
'JPY' => 392
}
-
def initialize(options = {})
requires!(options, :login, :password, :terminal_id, :merchant_id)
super
diff --git a/lib/active_merchant/billing/gateways/global_collect.rb b/lib/active_merchant/billing/gateways/global_collect.rb
index 66f4634841d..6a82e2807e5 100644
--- a/lib/active_merchant/billing/gateways/global_collect.rb
+++ b/lib/active_merchant/billing/gateways/global_collect.rb
@@ -246,7 +246,6 @@ def commit(action, post, authorization = nil)
error_code: error_code_from(succeeded, response),
test: test?
)
-
end
def headers(action, post, authorization = nil)
diff --git a/lib/active_merchant/billing/gateways/inspire.rb b/lib/active_merchant/billing/gateways/inspire.rb
index 6c9fae8e265..324f1f8bb5f 100644
--- a/lib/active_merchant/billing/gateways/inspire.rb
+++ b/lib/active_merchant/billing/gateways/inspire.rb
@@ -99,6 +99,7 @@ def store(creditcard, options = {})
alias_method :unstore, :delete
private
+
def add_customer_data(post, options)
if options.has_key? :email
post[:email] = options[:email]
@@ -181,7 +182,6 @@ def commit(action, money, parameters)
:cvv_result => response['cvvresponse'],
:avs_result => { :code => response['avsresponse'] }
)
-
end
def message_from(response)
diff --git a/lib/active_merchant/billing/gateways/latitude19.rb b/lib/active_merchant/billing/gateways/latitude19.rb
index f430f16f852..89d3d8f50df 100644
--- a/lib/active_merchant/billing/gateways/latitude19.rb
+++ b/lib/active_merchant/billing/gateways/latitude19.rb
@@ -147,7 +147,6 @@ def scrub(transcript)
gsub(%r((\"cvv\\\":\\\")\d+), '\1[FILTERED]')
end
-
private
def add_request_id(post)
diff --git a/lib/active_merchant/billing/gateways/linkpoint.rb b/lib/active_merchant/billing/gateways/linkpoint.rb
index 5b0553c3dfd..cf4d3cf28de 100644
--- a/lib/active_merchant/billing/gateways/linkpoint.rb
+++ b/lib/active_merchant/billing/gateways/linkpoint.rb
@@ -258,6 +258,7 @@ def scrub(transcript)
end
private
+
# Commit the transaction by posting the XML file to the LinkPoint server
def commit(money, creditcard, options = {})
response = parse(ssl_post(test? ? self.test_url : self.live_url, post_data(money, creditcard, options)))
@@ -323,7 +324,6 @@ def build_items(element, items)
# Set up the parameters hash just once so we don't have to do it
# for every action.
def parameters(money, creditcard, options = {})
-
params = {
:payment => {
:subtotal => amount(options[:subtotal]),
@@ -417,7 +417,6 @@ def parameters(money, creditcard, options = {})
end
def parse(xml)
-
# For reference, a typical response...
#
#
diff --git a/lib/active_merchant/billing/gateways/mastercard.rb b/lib/active_merchant/billing/gateways/mastercard.rb
index 10fb51ba589..609039cb9e3 100644
--- a/lib/active_merchant/billing/gateways/mastercard.rb
+++ b/lib/active_merchant/billing/gateways/mastercard.rb
@@ -80,6 +80,7 @@ def scrub(transcript)
end
private
+
def new_post
{
order: {},
diff --git a/lib/active_merchant/billing/gateways/mercado_pago.rb b/lib/active_merchant/billing/gateways/mercado_pago.rb
index ad5f4a555d8..ad6f931aade 100644
--- a/lib/active_merchant/billing/gateways/mercado_pago.rb
+++ b/lib/active_merchant/billing/gateways/mercado_pago.rb
@@ -119,7 +119,6 @@ def add_additional_data(post, options)
ip_address: options[:ip_address]
}.merge(options[:additional_info] || {})
-
add_address(post, options)
add_shipping_address(post, options)
end
diff --git a/lib/active_merchant/billing/gateways/merchant_e_solutions.rb b/lib/active_merchant/billing/gateways/merchant_e_solutions.rb
index 8af50c307e6..f1306ce3db9 100644
--- a/lib/active_merchant/billing/gateways/merchant_e_solutions.rb
+++ b/lib/active_merchant/billing/gateways/merchant_e_solutions.rb
@@ -158,7 +158,6 @@ def commit(action, money, parameters)
url = test? ? self.test_url : self.live_url
parameters[:transaction_amount] = amount(money) if money unless action == 'V'
-
response = begin
parse( ssl_post(url, post_data(action,parameters)) )
rescue ActiveMerchant::ResponseError => e
diff --git a/lib/active_merchant/billing/gateways/micropayment.rb b/lib/active_merchant/billing/gateways/micropayment.rb
index 3172e3ec4f1..17a3750fb95 100644
--- a/lib/active_merchant/billing/gateways/micropayment.rb
+++ b/lib/active_merchant/billing/gateways/micropayment.rb
@@ -12,7 +12,6 @@ class MicropaymentGateway < Gateway
self.money_format = :cents
self.supported_cardtypes = [:visa, :master, :american_express]
-
def initialize(options={})
requires!(options, :access_key)
super
@@ -57,7 +56,6 @@ def refund(amount, authorization, options={})
end
def verify(credit_card, options={})
-
MultiResponse.run(:use_first_response) do |r|
r.process { authorize(250, credit_card, options) }
r.process(:ignore_result) { void(r.authorization, options) }
diff --git a/lib/active_merchant/billing/gateways/modern_payments.rb b/lib/active_merchant/billing/gateways/modern_payments.rb
index 340e3e7a0c7..d94d12cb6d9 100644
--- a/lib/active_merchant/billing/gateways/modern_payments.rb
+++ b/lib/active_merchant/billing/gateways/modern_payments.rb
@@ -28,6 +28,7 @@ def purchase(money, credit_card, options = {})
end
private
+
def cim
@cim ||= ModernPaymentsCimGateway.new(@options)
end
diff --git a/lib/active_merchant/billing/gateways/modern_payments_cim.rb b/lib/active_merchant/billing/gateways/modern_payments_cim.rb
index 1f1e5beb04b..7420ff6cd23 100644
--- a/lib/active_merchant/billing/gateways/modern_payments_cim.rb
+++ b/lib/active_merchant/billing/gateways/modern_payments_cim.rb
@@ -66,6 +66,7 @@ def create_payment(customer_id, amount, options = {})
end
private
+
def add_payment_details(post, options)
post[:pmtDate] = (options[:payment_date] || Time.now.utc).strftime('%Y-%m-%dT%H:%M:%SZ')
post[:pmtType] = PAYMENT_METHOD[options[:payment_method] || :credit_card]
diff --git a/lib/active_merchant/billing/gateways/nab_transact.rb b/lib/active_merchant/billing/gateways/nab_transact.rb
index 85123a13ebd..389653cf523 100644
--- a/lib/active_merchant/billing/gateways/nab_transact.rb
+++ b/lib/active_merchant/billing/gateways/nab_transact.rb
@@ -41,7 +41,6 @@ class NabTransactGateway < Gateway
SUCCESS_CODES = [ '00', '08', '11', '16', '77' ]
-
def initialize(options = {})
requires!(options, :login, :password)
super
diff --git a/lib/active_merchant/billing/gateways/net_registry.rb b/lib/active_merchant/billing/gateways/net_registry.rb
index f3767e1be66..a1e4ee183ef 100644
--- a/lib/active_merchant/billing/gateways/net_registry.rb
+++ b/lib/active_merchant/billing/gateways/net_registry.rb
@@ -122,6 +122,7 @@ def status(identification)
end
private
+
def add_request_details(params, options)
params['COMMENT'] = options[:description] unless options[:description].blank?
end
diff --git a/lib/active_merchant/billing/gateways/nmi.rb b/lib/active_merchant/billing/gateways/nmi.rb
index 63180931889..0b6910ba82a 100644
--- a/lib/active_merchant/billing/gateways/nmi.rb
+++ b/lib/active_merchant/billing/gateways/nmi.rb
@@ -214,7 +214,6 @@ def exp_date(payment_method)
end
def commit(action, params)
-
params[action == 'add_customer' ? :customer_vault : :type] = action
params[:username] = @options[:login]
params[:password] = @options[:password]
diff --git a/lib/active_merchant/billing/gateways/openpay.rb b/lib/active_merchant/billing/gateways/openpay.rb
index fda4d7801ff..1d44beb6036 100644
--- a/lib/active_merchant/billing/gateways/openpay.rb
+++ b/lib/active_merchant/billing/gateways/openpay.rb
@@ -104,6 +104,7 @@ def scrub(transcript)
gsub(%r((cvv2\\?":\\?")\\?"), '\1[BLANK]"').
gsub(%r((cvv2\\?":\\?")\s+), '\1[BLANK]')
end
+
private
def create_post_for_auth_or_purchase(money, creditcard, options)
diff --git a/lib/active_merchant/billing/gateways/optimal_payment.rb b/lib/active_merchant/billing/gateways/optimal_payment.rb
index c4ff212c018..2684c76e84f 100644
--- a/lib/active_merchant/billing/gateways/optimal_payment.rb
+++ b/lib/active_merchant/billing/gateways/optimal_payment.rb
@@ -19,7 +19,6 @@ class OptimalPaymentGateway < Gateway
self.display_name = 'Optimal Payments'
def initialize(options = {})
-
if(options[:login])
ActiveMerchant.deprecated("The 'login' option is deprecated in favor of 'store_id' and will be removed in a future version.")
options[:store_id] = options[:login]
diff --git a/lib/active_merchant/billing/gateways/orbital.rb b/lib/active_merchant/billing/gateways/orbital.rb
index 9f0ba09eca7..f41a9801775 100644
--- a/lib/active_merchant/billing/gateways/orbital.rb
+++ b/lib/active_merchant/billing/gateways/orbital.rb
@@ -251,7 +251,6 @@ def void(authorization, options = {}, deprecated = {})
commit(order, :void, options[:trace_number])
end
-
# ==== Customer Profiles
# :customer_ref_num should be set unless you're happy with Orbital providing one
#
diff --git a/lib/active_merchant/billing/gateways/pay_secure.rb b/lib/active_merchant/billing/gateways/pay_secure.rb
index 10dcbfbed57..72be0071d10 100644
--- a/lib/active_merchant/billing/gateways/pay_secure.rb
+++ b/lib/active_merchant/billing/gateways/pay_secure.rb
@@ -39,6 +39,7 @@ def purchase(money, credit_card, options = {})
end
private
+
# Used for capturing, which is currently not supported.
def add_reference(post, identification)
auth, trans_id = identification.split(';')
@@ -71,7 +72,6 @@ def commit(action, money, parameters)
:test => test_response?(response),
:authorization => authorization_from(response)
)
-
end
def successful?(response)
diff --git a/lib/active_merchant/billing/gateways/paybox_direct.rb b/lib/active_merchant/billing/gateways/paybox_direct.rb
index 4e51c84ba0c..c66933c5baa 100644
--- a/lib/active_merchant/billing/gateways/paybox_direct.rb
+++ b/lib/active_merchant/billing/gateways/paybox_direct.rb
@@ -174,7 +174,6 @@ def message_from(response)
end
def post_data(action, parameters = {})
-
parameters.update(
:version => API_VERSION,
:type => TRANSACTIONS[action.to_sym],
diff --git a/lib/active_merchant/billing/gateways/payex.rb b/lib/active_merchant/billing/gateways/payex.rb
index 22478d87d2a..b35038ca239 100644
--- a/lib/active_merchant/billing/gateways/payex.rb
+++ b/lib/active_merchant/billing/gateways/payex.rb
@@ -70,7 +70,6 @@ def authorize(amount, payment_method, options = {})
# stored authorization
send_autopay(amount, payment_method, true, options)
end
-
end
# Public: Send a purchase Payex request
diff --git a/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb b/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb
index 8aec158e79c..319c56bb64b 100644
--- a/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb
+++ b/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb
@@ -78,6 +78,7 @@ def void(authorization, options = {})
end
private
+
def build_request(body, options = {})
xml = Builder::XmlMarkup.new
xml.instruct!
diff --git a/lib/active_merchant/billing/gateways/payflow_express.rb b/lib/active_merchant/billing/gateways/payflow_express.rb
index a5061c6a931..c2970b6e052 100644
--- a/lib/active_merchant/billing/gateways/payflow_express.rb
+++ b/lib/active_merchant/billing/gateways/payflow_express.rb
@@ -58,7 +58,6 @@ module Billing #:nodoc:
# [:header_background_color] (opt) Your URL for receiving Instant Payment Notification (IPN) about this transaction.
# [:header_border_color] (opt) Your URL for receiving Instant Payment Notification (IPN) about this transaction.
-
class PayflowExpressGateway < Gateway
include PayflowCommonAPI
include PaypalExpressCommon
@@ -109,6 +108,7 @@ def details_for(token)
end
private
+
def build_get_express_details_request(token)
xml = Builder::XmlMarkup.new :indent => 2
xml.tag! 'GetExpressCheckout' do
diff --git a/lib/active_merchant/billing/gateways/paymill.rb b/lib/active_merchant/billing/gateways/paymill.rb
index 95b4028b670..ff2f8268484 100644
--- a/lib/active_merchant/billing/gateways/paymill.rb
+++ b/lib/active_merchant/billing/gateways/paymill.rb
@@ -240,7 +240,6 @@ def transaction_id(authorization)
31203 => 'Pending due to currency conflict (accept manually)',
31204 => 'Pending due to fraud filters (accept manually)',
-
40000 => 'Problem with transaction data',
40001 => 'Problem with payment data',
40002 => 'Invalid checksum',
@@ -321,7 +320,6 @@ def response_message(parsed_response)
RESPONSE_CODES[code] || code.to_s
end
-
class ResponseParser
attr_reader :raw_response, :parsed, :succeeded, :message, :options
diff --git a/lib/active_merchant/billing/gateways/payscout.rb b/lib/active_merchant/billing/gateways/payscout.rb
index f0f9602e4fc..108d8725aa7 100644
--- a/lib/active_merchant/billing/gateways/payscout.rb
+++ b/lib/active_merchant/billing/gateways/payscout.rb
@@ -41,7 +41,6 @@ def capture(money, authorization, options = {})
commit('capture', money, post)
end
-
def refund(money, authorization, options = {})
post = {}
post[:transactionid] = authorization
diff --git a/lib/active_merchant/billing/gateways/pin.rb b/lib/active_merchant/billing/gateways/pin.rb
index 289e8e33501..676ffb6f7af 100644
--- a/lib/active_merchant/billing/gateways/pin.rb
+++ b/lib/active_merchant/billing/gateways/pin.rb
@@ -84,6 +84,7 @@ def scrub(transcript)
gsub(/(number\\?":\\?")(\d*)/, '\1[FILTERED]').
gsub(/(cvc\\?":\\?")(\d*)/, '\1[FILTERED]')
end
+
private
def add_amount(post, money, options)
diff --git a/lib/active_merchant/billing/gateways/plugnpay.rb b/lib/active_merchant/billing/gateways/plugnpay.rb
index 1b78b25c299..634c1294189 100644
--- a/lib/active_merchant/billing/gateways/plugnpay.rb
+++ b/lib/active_merchant/billing/gateways/plugnpay.rb
@@ -172,6 +172,7 @@ def refund(money, reference, options = {})
end
private
+
def commit(action, post)
response = parse( ssl_post(self.live_url, post_data(action, post)) )
success = SUCCESS_CODES.include?(response[:finalstatus])
diff --git a/lib/active_merchant/billing/gateways/psl_card.rb b/lib/active_merchant/billing/gateways/psl_card.rb
index 1abe0b9e55e..8154add4944 100644
--- a/lib/active_merchant/billing/gateways/psl_card.rb
+++ b/lib/active_merchant/billing/gateways/psl_card.rb
@@ -240,7 +240,6 @@ def currency_code(currency)
# -a hash with all of the values returned in the PSL response
#
def parse(body)
-
fields = {}
for line in body.split('&')
key, value = *line.scan( %r{^(\w+)\=(.*)$} ).flatten
diff --git a/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb b/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb
index 50d0fb44932..43545c02294 100644
--- a/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb
+++ b/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb
@@ -174,7 +174,6 @@ def self.included(base)
base.supported_countries = ['DE', 'DK', 'ES', 'FI', 'FR', 'FO', 'GB', 'IS', 'NO', 'SE']
base.homepage_url = 'http://quickpay.net/'
base.display_name = 'QuickPay'
-
end
def expdate(credit_card)
diff --git a/lib/active_merchant/billing/gateways/realex.rb b/lib/active_merchant/billing/gateways/realex.rb
index 3b5c86b1b52..cb97ac7bb87 100644
--- a/lib/active_merchant/billing/gateways/realex.rb
+++ b/lib/active_merchant/billing/gateways/realex.rb
@@ -91,6 +91,7 @@ def scrub(transcript)
end
private
+
def commit(request)
response = parse(ssl_post(self.live_url, request))
diff --git a/lib/active_merchant/billing/gateways/s5.rb b/lib/active_merchant/billing/gateways/s5.rb
index 6e5ec5e80a7..2be4007ba63 100644
--- a/lib/active_merchant/billing/gateways/s5.rb
+++ b/lib/active_merchant/billing/gateways/s5.rb
@@ -96,7 +96,6 @@ def verify(credit_card, options={})
end
end
-
def supports_scrubbing?
true
end
diff --git a/lib/active_merchant/billing/gateways/sage_pay.rb b/lib/active_merchant/billing/gateways/sage_pay.rb
index 313bdb88c72..4eee27bb932 100644
--- a/lib/active_merchant/billing/gateways/sage_pay.rb
+++ b/lib/active_merchant/billing/gateways/sage_pay.rb
@@ -181,6 +181,7 @@ def scrub(transcript)
end
private
+
def truncate(value, max_size)
return nil unless value
return value.to_s if CGI.escape(value.to_s).length <= max_size
diff --git a/lib/active_merchant/billing/gateways/secure_net.rb b/lib/active_merchant/billing/gateways/secure_net.rb
index 0bf4f8ff55b..66ccc07dc00 100644
--- a/lib/active_merchant/billing/gateways/secure_net.rb
+++ b/lib/active_merchant/billing/gateways/secure_net.rb
@@ -189,7 +189,6 @@ def add_address(xml, creditcard, options)
xml.tag!('CUSTOMER_SHIP', NIL_ATTRIBUTE) do
end
end
-
end
def add_merchant_key(xml, options)
diff --git a/lib/active_merchant/billing/gateways/securion_pay.rb b/lib/active_merchant/billing/gateways/securion_pay.rb
index c883c938230..3c56fce55ad 100644
--- a/lib/active_merchant/billing/gateways/securion_pay.rb
+++ b/lib/active_merchant/billing/gateways/securion_pay.rb
@@ -4,7 +4,6 @@ class SecurionPayGateway < Gateway
self.test_url = 'https://api.securionpay.com/'
self.live_url = 'https://api.securionpay.com/'
-
self.supported_countries = %w(AL AD AT BY BE BG HR CY CZ RE DK EE IS FI FR DE GI GR HU IS IE IT IL LV LI LT LU
MK MT MD MC NL NO PL PT RO RU MA RS SK SI ES SE CH UA GB KI CI ME)
diff --git a/lib/active_merchant/billing/gateways/smart_ps.rb b/lib/active_merchant/billing/gateways/smart_ps.rb
index b95c4d685e7..0b9841189e9 100644
--- a/lib/active_merchant/billing/gateways/smart_ps.rb
+++ b/lib/active_merchant/billing/gateways/smart_ps.rb
@@ -106,7 +106,6 @@ def amend(auth, options = {})
commit('update', nil, post)
end
-
def delete(vault_id)
post = {}
post[:customer_vault] = 'delete_customer'
@@ -128,6 +127,7 @@ def store(payment_source, options = {})
alias_method :unstore, :delete
private
+
def add_customer_data(post, options)
if options.has_key? :email
post[:email] = options[:email]
@@ -237,7 +237,6 @@ def commit(action, money, parameters)
:cvv_result => response['cvvresponse'],
:avs_result => { :code => response['avsresponse'] }
)
-
end
def expdate(creditcard)
@@ -247,7 +246,6 @@ def expdate(creditcard)
"#{month}#{year[-2..-1]}"
end
-
def message_from(response)
case response['responsetext']
when 'SUCCESS', 'Approved', nil # This is dubious, but responses from UPDATE are nil.
diff --git a/lib/active_merchant/billing/gateways/spreedly_core.rb b/lib/active_merchant/billing/gateways/spreedly_core.rb
index 7c365fb2f68..d3d3e91af87 100644
--- a/lib/active_merchant/billing/gateways/spreedly_core.rb
+++ b/lib/active_merchant/billing/gateways/spreedly_core.rb
@@ -88,7 +88,6 @@ def void(authorization, options={})
commit("transactions/#{authorization}/void.xml", '')
end
-
# Public: Determine whether a credit card is chargeable card and available for purchases.
#
# payment_method - The CreditCard or the Spreedly payment method token.
diff --git a/lib/active_merchant/billing/gateways/trexle.rb b/lib/active_merchant/billing/gateways/trexle.rb
index 2be948b4940..f7f98e21766 100644
--- a/lib/active_merchant/billing/gateways/trexle.rb
+++ b/lib/active_merchant/billing/gateways/trexle.rb
@@ -90,6 +90,7 @@ def scrub(transcript)
gsub(/(number\\?":\\?")(\d*)/, '\1[FILTERED]').
gsub(/(cvc\\?":\\?")(\d*)/, '\1[FILTERED]')
end
+
private
def add_amount(post, money, options)
diff --git a/lib/active_merchant/billing/gateways/trust_commerce.rb b/lib/active_merchant/billing/gateways/trust_commerce.rb
index 87872c59122..4908df12cde 100644
--- a/lib/active_merchant/billing/gateways/trust_commerce.rb
+++ b/lib/active_merchant/billing/gateways/trust_commerce.rb
@@ -304,6 +304,7 @@ def scrub(transcript)
end
private
+
def add_payment_source(params, source)
if source.is_a?(String)
add_billing_id(params, source)
diff --git a/lib/active_merchant/billing/gateways/viaklix.rb b/lib/active_merchant/billing/gateways/viaklix.rb
index c2e800b9b4c..4e82980e7f1 100644
--- a/lib/active_merchant/billing/gateways/viaklix.rb
+++ b/lib/active_merchant/billing/gateways/viaklix.rb
@@ -63,6 +63,7 @@ def credit(money, creditcard, options = {})
end
private
+
def add_test_mode(form, options)
form[:test_mode] = 'TRUE' if options[:test_mode]
end
diff --git a/lib/active_merchant/billing/gateways/wirecard.rb b/lib/active_merchant/billing/gateways/wirecard.rb
index 4b964770e15..d04ddc569e5 100644
--- a/lib/active_merchant/billing/gateways/wirecard.rb
+++ b/lib/active_merchant/billing/gateways/wirecard.rb
@@ -138,6 +138,7 @@ def scrub(transcript)
end
private
+
def clean_description(description)
description.to_s.slice(0,32).encode('US-ASCII', invalid: :replace, undef: :replace, replace: '?')
end
diff --git a/lib/active_merchant/connection.rb b/lib/active_merchant/connection.rb
index 489130ee1b9..d7067b98636 100644
--- a/lib/active_merchant/connection.rb
+++ b/lib/active_merchant/connection.rb
@@ -161,7 +161,6 @@ def configure_ssl(http)
else
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
end
-
end
def configure_cert(http)
diff --git a/lib/active_merchant/network_connection_retries.rb b/lib/active_merchant/network_connection_retries.rb
index 772e8617936..db0187ffa33 100644
--- a/lib/active_merchant/network_connection_retries.rb
+++ b/lib/active_merchant/network_connection_retries.rb
@@ -69,6 +69,7 @@ def self.log(logger, level, message, tag=nil)
end
private
+
def log_with_retry_details(logger, attempts, time, message, tag)
NetworkConnectionRetries.log(logger, :info, 'connection_attempt=%d connection_request_time=%.4fs connection_msg="%s"' % [attempts, time, message], tag)
end
diff --git a/lib/active_merchant/post_data.rb b/lib/active_merchant/post_data.rb
index b1c715b0108..c95b85244d2 100644
--- a/lib/active_merchant/post_data.rb
+++ b/lib/active_merchant/post_data.rb
@@ -17,6 +17,7 @@ def to_post_data
alias_method :to_s, :to_post_data
private
+
def required?(key)
required_fields.include?(key)
end
diff --git a/lib/support/gateway_support.rb b/lib/support/gateway_support.rb
index c811e7d04fe..1ae661a6375 100644
--- a/lib/support/gateway_support.rb
+++ b/lib/support/gateway_support.rb
@@ -2,7 +2,6 @@
require 'active_support'
require 'active_merchant'
-
class GatewaySupport #:nodoc:
ACTIONS = [:purchase, :authorize, :capture, :void, :credit, :recurring]
diff --git a/lib/support/ssl_verify.rb b/lib/support/ssl_verify.rb
index 94dbf618695..28189db7837 100644
--- a/lib/support/ssl_verify.rb
+++ b/lib/support/ssl_verify.rb
@@ -60,7 +60,6 @@ def test_gateways
puts d.name
end
end
-
end
def try_host(http, path)
diff --git a/test/remote/gateways/remote_authorize_net_apple_pay_test.rb b/test/remote/gateways/remote_authorize_net_apple_pay_test.rb
index 6b8a632743f..cf430b4a975 100644
--- a/test/remote/gateways/remote_authorize_net_apple_pay_test.rb
+++ b/test/remote/gateways/remote_authorize_net_apple_pay_test.rb
@@ -60,7 +60,6 @@ def test_failed_apple_pay_purchase
assert_equal 'processing_error', response.error_code
end
-
private
def apple_pay_payment_token(options = {})
diff --git a/test/remote/gateways/remote_authorize_net_cim_test.rb b/test/remote/gateways/remote_authorize_net_cim_test.rb
index 545a9f96942..bbd6d60eea4 100644
--- a/test/remote/gateways/remote_authorize_net_cim_test.rb
+++ b/test/remote/gateways/remote_authorize_net_cim_test.rb
@@ -873,5 +873,4 @@ def get_and_validate_auth_only_response
return response
end
-
end
diff --git a/test/remote/gateways/remote_banwire_test.rb b/test/remote/gateways/remote_banwire_test.rb
index 0bac529ec67..cb8331a5661 100644
--- a/test/remote/gateways/remote_banwire_test.rb
+++ b/test/remote/gateways/remote_banwire_test.rb
@@ -37,7 +37,6 @@ def test_successful_purchase_with_extra_options
assert_success response
end
-
def test_unsuccessful_purchase
assert response = @gateway.purchase(@amount, @declined_card, @options)
assert_failure response
diff --git a/test/remote/gateways/remote_blue_snap_test.rb b/test/remote/gateways/remote_blue_snap_test.rb
index 8530b92dba5..9934855f3de 100644
--- a/test/remote/gateways/remote_blue_snap_test.rb
+++ b/test/remote/gateways/remote_blue_snap_test.rb
@@ -196,7 +196,6 @@ def test_verify_credentials
assert !gateway.verify_credentials
end
-
def test_transcript_scrubbing
transcript = capture_transcript(@gateway) do
@gateway.purchase(@amount, @credit_card, @options)
diff --git a/test/remote/gateways/remote_braintree_blue_test.rb b/test/remote/gateways/remote_braintree_blue_test.rb
index 27bf4083ff4..46a6610cc6f 100644
--- a/test/remote/gateways/remote_braintree_blue_test.rb
+++ b/test/remote/gateways/remote_braintree_blue_test.rb
@@ -705,8 +705,8 @@ def test_verify_credentials
assert !gateway.verify_credentials
end
-
private
+
def assert_avs(address1, zip, expected_avs_code)
response = @gateway.purchase(@amount, @credit_card, billing_address: {address1: address1, zip: zip})
diff --git a/test/remote/gateways/remote_cardknox_test.rb b/test/remote/gateways/remote_cardknox_test.rb
index e3c375aa324..457c0928f27 100644
--- a/test/remote/gateways/remote_cardknox_test.rb
+++ b/test/remote/gateways/remote_cardknox_test.rb
@@ -149,7 +149,6 @@ def test_failed_credit_card_authorize_partial_refund
assert refund = @gateway.refund(@amount-1, auth.authorization)
assert_failure refund
assert_equal 'Refund not allowed on non-captured auth.', refund.message
-
end
def test_failed_partial_check_refund # the gate way does not support this transaction
diff --git a/test/remote/gateways/remote_cecabank_test.rb b/test/remote/gateways/remote_cecabank_test.rb
index 1a6c0131cd2..108fb3ea106 100644
--- a/test/remote/gateways/remote_cecabank_test.rb
+++ b/test/remote/gateways/remote_cecabank_test.rb
@@ -26,7 +26,6 @@ def test_unsuccessful_purchase
assert_equal 'ERROR', response.message
end
-
def test_successful_refund
purchase = @gateway.purchase(@amount, @credit_card, @options)
assert_success purchase
diff --git a/test/remote/gateways/remote_creditcall_test.rb b/test/remote/gateways/remote_creditcall_test.rb
index d84c8695f10..527d60979a6 100644
--- a/test/remote/gateways/remote_creditcall_test.rb
+++ b/test/remote/gateways/remote_creditcall_test.rb
@@ -167,6 +167,5 @@ def test_transcript_scrubbing
assert_scrubbed(@credit_card.number, transcript)
assert_scrubbed(@credit_card.verification_value, transcript)
assert_scrubbed(@gateway.options[:transaction_key], transcript)
-
end
end
diff --git a/test/remote/gateways/remote_cyber_source_test.rb b/test/remote/gateways/remote_cyber_source_test.rb
index 48fc84c0443..d3af9274365 100644
--- a/test/remote/gateways/remote_cyber_source_test.rb
+++ b/test/remote/gateways/remote_cyber_source_test.rb
@@ -300,7 +300,6 @@ def test_successful_subscription_purchase
assert response.test?
end
-
def test_successful_subscription_credit
assert response = @gateway.store(@credit_card, @subscription_options)
assert_equal 'Successful transaction', response.message
diff --git a/test/remote/gateways/remote_first_giving_test.rb b/test/remote/gateways/remote_first_giving_test.rb
index f884bcc8c04..9c689eb81c1 100644
--- a/test/remote/gateways/remote_first_giving_test.rb
+++ b/test/remote/gateways/remote_first_giving_test.rb
@@ -2,7 +2,6 @@
class RemoteFirstGivingTest < Test::Unit::TestCase
-
def setup
@gateway = FirstGivingGateway.new(fixtures(:first_giving))
diff --git a/test/remote/gateways/remote_forte_test.rb b/test/remote/gateways/remote_forte_test.rb
index 4fdc41bb801..4be212bd5c7 100644
--- a/test/remote/gateways/remote_forte_test.rb
+++ b/test/remote/gateways/remote_forte_test.rb
@@ -24,7 +24,6 @@ def setup
description: 'Store Purchase',
order_id: '1'
}
-
end
def test_invalid_login
diff --git a/test/remote/gateways/remote_iveri_test.rb b/test/remote/gateways/remote_iveri_test.rb
index 11935d75858..16733284a46 100644
--- a/test/remote/gateways/remote_iveri_test.rb
+++ b/test/remote/gateways/remote_iveri_test.rb
@@ -48,7 +48,6 @@ def test_successful_purchase_with_3ds_params
assert_equal 'Succeeded', response.message
end
-
def test_failed_purchase
response = @gateway.purchase(@amount, @bad_card, @options)
assert_failure response
diff --git a/test/remote/gateways/remote_jetpay_test.rb b/test/remote/gateways/remote_jetpay_test.rb
index 29f0c40b01b..d5d331a72f1 100644
--- a/test/remote/gateways/remote_jetpay_test.rb
+++ b/test/remote/gateways/remote_jetpay_test.rb
@@ -75,7 +75,6 @@ def test_ud_fields_on_capture
assert_success capture
end
-
def test_void
# must void a valid auth
assert auth = @gateway.authorize(9900, @credit_card, @options)
@@ -84,7 +83,6 @@ def test_void
assert_not_nil auth.authorization
assert_not_nil auth.params['approval']
-
assert void = @gateway.void(auth.authorization)
assert_success void
end
diff --git a/test/remote/gateways/remote_jetpay_v2_test.rb b/test/remote/gateways/remote_jetpay_v2_test.rb
index cffb44cafe6..10f1ea6322f 100644
--- a/test/remote/gateways/remote_jetpay_v2_test.rb
+++ b/test/remote/gateways/remote_jetpay_v2_test.rb
@@ -100,7 +100,6 @@ def test_successful_void
assert_not_nil auth.authorization
assert_not_nil auth.params['approval']
-
assert void = @gateway.void(auth.authorization, @options)
assert_success void
end
diff --git a/test/remote/gateways/remote_linkpoint_test.rb b/test/remote/gateways/remote_linkpoint_test.rb
index d7a14b214f7..3b2e78e9fb6 100644
--- a/test/remote/gateways/remote_linkpoint_test.rb
+++ b/test/remote/gateways/remote_linkpoint_test.rb
@@ -96,7 +96,6 @@ def test_successfull_purchase_with_item_entity
{:id => '111', :description => 'keychain', :price => '3.00', :quantity => '1'}]})
assert purchase = @gateway.purchase(1500, @credit_card, @options)
assert_success purchase
-
end
def test_successful_recurring_payment
diff --git a/test/remote/gateways/remote_litle_certification_test.rb b/test/remote/gateways/remote_litle_certification_test.rb
index 94ed48e24e9..90335ac3a7b 100644
--- a/test/remote/gateways/remote_litle_certification_test.rb
+++ b/test/remote/gateways/remote_litle_certification_test.rb
@@ -170,13 +170,11 @@ def test6
assert_equal 'P', response.cvv_result['code']
puts "Test #{options[:order_id]} Sale: #{txn_id(response)}"
-
# 6A. void
assert response = @gateway.void(response.authorization, {:order_id => '6A'})
assert_equal '360', response.params['response']
assert_equal 'No transaction found with specified transaction Id', response.message
puts "Test #{options[:order_id]}A: #{txn_id(response)}"
-
end
def test7
@@ -1208,7 +1206,6 @@ def sale_assertions(amount, card, options, assertions={})
assert_equal auth_code(options[:order_id]), response.params['authCode']
puts "Test #{options[:order_id]} Sale: #{txn_id(response)}"
-
# 1B: credit
assert response = @gateway.credit(amount, response.authorization, {:id => transaction_id})
assert_equal 'Approved', response.message
diff --git a/test/remote/gateways/remote_modern_payments_test.rb b/test/remote/gateways/remote_modern_payments_test.rb
index c0ec1040d63..cb5d594afa7 100644
--- a/test/remote/gateways/remote_modern_payments_test.rb
+++ b/test/remote/gateways/remote_modern_payments_test.rb
@@ -14,7 +14,6 @@ def setup
:billing_address => address,
:description => 'Store Purchase'
}
-
end
def test_successful_purchase
diff --git a/test/remote/gateways/remote_nmi_test.rb b/test/remote/gateways/remote_nmi_test.rb
index c98b29dcaac..e6d3701994a 100644
--- a/test/remote/gateways/remote_nmi_test.rb
+++ b/test/remote/gateways/remote_nmi_test.rb
@@ -160,7 +160,6 @@ def test_successful_refund_with_echeck
assert_equal 'Succeeded', response.message
end
-
def test_successful_credit
response = @gateway.credit(@amount, @credit_card, @options)
assert_success response
diff --git a/test/remote/gateways/remote_pay_junction_test.rb b/test/remote/gateways/remote_pay_junction_test.rb
index 79cea0c85b4..7514b3c8a5a 100644
--- a/test/remote/gateways/remote_pay_junction_test.rb
+++ b/test/remote/gateways/remote_pay_junction_test.rb
@@ -136,6 +136,7 @@ def test_should_send_invoice
end
private
+
def success_price
200 + rand(200)
end
diff --git a/test/remote/gateways/remote_payscout_test.rb b/test/remote/gateways/remote_payscout_test.rb
index d212f32845b..ce0a0768a1e 100644
--- a/test/remote/gateways/remote_payscout_test.rb
+++ b/test/remote/gateways/remote_payscout_test.rb
@@ -21,13 +21,11 @@ def test_cvv_fail_purchase
@credit_card = credit_card('4111111111111111')
assert response = @gateway.purchase(@amount, @credit_card, @options)
-
assert_success response
assert_equal 'The transaction has been approved', response.message
assert_equal 'N', response.cvv_result['code']
end
-
def test_approved_purchase
assert response = @gateway.purchase(@amount, @credit_card, @options)
assert_success response
diff --git a/test/remote/gateways/remote_quickpay_v4_test.rb b/test/remote/gateways/remote_quickpay_v4_test.rb
index 8e1035c8c61..9eb4ca69970 100644
--- a/test/remote/gateways/remote_quickpay_v4_test.rb
+++ b/test/remote/gateways/remote_quickpay_v4_test.rb
@@ -51,8 +51,6 @@ def test_successful_purchase_with_all_fraud_parameters
assert !response.authorization.blank?
end
-
-
def test_successful_usd_purchase
assert response = @gateway.purchase(@amount, @visa, @options.update(:currency => 'USD'))
assert_equal 'OK', response.message
diff --git a/test/remote/gateways/remote_quickpay_v5_test.rb b/test/remote/gateways/remote_quickpay_v5_test.rb
index 83ea83bb645..02838bf2bb8 100644
--- a/test/remote/gateways/remote_quickpay_v5_test.rb
+++ b/test/remote/gateways/remote_quickpay_v5_test.rb
@@ -51,8 +51,6 @@ def test_successful_purchase_with_all_fraud_parameters
assert !response.authorization.blank?
end
-
-
def test_successful_usd_purchase
assert response = @gateway.purchase(@amount, @visa, @options.update(:currency => 'USD'))
assert_equal 'OK', response.message
diff --git a/test/remote/gateways/remote_quickpay_v6_test.rb b/test/remote/gateways/remote_quickpay_v6_test.rb
index 6566f5a0900..2d113657c0c 100644
--- a/test/remote/gateways/remote_quickpay_v6_test.rb
+++ b/test/remote/gateways/remote_quickpay_v6_test.rb
@@ -51,8 +51,6 @@ def test_successful_purchase_with_all_fraud_parameters
assert !response.authorization.blank?
end
-
-
def test_successful_usd_purchase
assert response = @gateway.purchase(@amount, @visa, @options.update(:currency => 'USD'))
assert_equal 'OK', response.message
diff --git a/test/remote/gateways/remote_realex_test.rb b/test/remote/gateways/remote_realex_test.rb
index 7cff61befad..73ec653e86f 100644
--- a/test/remote/gateways/remote_realex_test.rb
+++ b/test/remote/gateways/remote_realex_test.rb
@@ -105,7 +105,6 @@ def test_realex_purchase_declined
assert_equal '101', response.params['result']
assert_equal response.params['message'], response.message
end
-
end
def test_realex_purchase_with_apple_pay_declined
@@ -141,7 +140,6 @@ def test_realex_purchase_referral_a
assert_equal '103', response.params['result']
assert_equal RealexGateway::DECLINED, response.message
end
-
end
def test_realex_purchase_coms_error
@@ -157,7 +155,6 @@ def test_realex_purchase_coms_error
assert_equal '200', response.params['result']
assert_equal RealexGateway::BANK_ERROR, response.message
end
-
end
def test_realex_expiry_month_error
diff --git a/test/remote/gateways/remote_redsys_sha256_test.rb b/test/remote/gateways/remote_redsys_sha256_test.rb
index 28e95aad071..8d3a2bbf8f1 100644
--- a/test/remote/gateways/remote_redsys_sha256_test.rb
+++ b/test/remote/gateways/remote_redsys_sha256_test.rb
@@ -177,6 +177,7 @@ def test_whitespace_string_cvv_transcript_scrubbing
assert_equal clean_transcript.include?('[BLANK]'), true
end
+
private
def generate_order_id
diff --git a/test/remote/gateways/remote_redsys_test.rb b/test/remote/gateways/remote_redsys_test.rb
index 5cc9ae08273..0dcaf5a017e 100644
--- a/test/remote/gateways/remote_redsys_test.rb
+++ b/test/remote/gateways/remote_redsys_test.rb
@@ -179,6 +179,7 @@ def test_whitespace_string_cvv_transcript_scrubbing
assert_equal clean_transcript.include?('[BLANK]'), true
end
+
private
def generate_order_id
diff --git a/test/remote/gateways/remote_so_easy_pay_test.rb b/test/remote/gateways/remote_so_easy_pay_test.rb
index 8803620f610..791a5343505 100644
--- a/test/remote/gateways/remote_so_easy_pay_test.rb
+++ b/test/remote/gateways/remote_so_easy_pay_test.rb
@@ -2,7 +2,6 @@
class RemoteSoEasyPayTest < Test::Unit::TestCase
-
def setup
@gateway = SoEasyPayGateway.new(fixtures(:so_easy_pay))
diff --git a/test/remote/gateways/remote_trans_first_transaction_express_test.rb b/test/remote/gateways/remote_trans_first_transaction_express_test.rb
index ed32f7e9f1d..f2045dcd4e1 100644
--- a/test/remote/gateways/remote_trans_first_transaction_express_test.rb
+++ b/test/remote/gateways/remote_trans_first_transaction_express_test.rb
@@ -76,7 +76,6 @@ def test_successful_purchase_with_only_required
assert_equal 'CVV matches', response.cvv_result['message']
end
-
def test_successful_purchase_without_cvv
credit_card_opts = {
:number => 4485896261017708,
diff --git a/test/remote/gateways/remote_worldpay_test.rb b/test/remote/gateways/remote_worldpay_test.rb
index ae768a760d5..f32933a1010 100644
--- a/test/remote/gateways/remote_worldpay_test.rb
+++ b/test/remote/gateways/remote_worldpay_test.rb
@@ -240,7 +240,6 @@ def test_transcript_scrubbing
assert_scrubbed(@credit_card.verification_value.to_s, clean_transcript)
end
-
# Worldpay has a delay between asking for a transaction to be captured and actually marking it as captured
# These 2 tests work if you get authorizations from a purchase, wait some time and then perform the refund/void operation.
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 1f1159493c5..dbfeb798930 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -127,6 +127,7 @@ def assert_scrubbed(unexpected_value, transcript)
end
private
+
def clean_backtrace(&block)
yield
rescue AssertionClass => e
@@ -141,6 +142,7 @@ module Fixtures
DEFAULT_CREDENTIALS = File.join(File.dirname(__FILE__), 'fixtures.yml') unless defined?(DEFAULT_CREDENTIALS)
private
+
def default_expiration_date
@default_expiration_date ||= Date.new((Time.now.year + 1), 9, 30)
end
@@ -325,12 +327,12 @@ def url_for(options, *parameters_for_method_reference)
end
protected
+
def protect_against_forgery?
false
end
end
-
class MockResponse
attr_reader :code, :body, :message
attr_accessor :headers
diff --git a/test/unit/gateways/allied_wallet_test.rb b/test/unit/gateways/allied_wallet_test.rb
index c3d1d390fd9..fb291c7c4b4 100644
--- a/test/unit/gateways/allied_wallet_test.rb
+++ b/test/unit/gateways/allied_wallet_test.rb
@@ -278,7 +278,6 @@ def failed_refund_response
)
end
-
def empty_purchase_response
%(
{
@@ -297,7 +296,6 @@ def invalid_json_response
)
end
-
def transcript
%(
<- "POST /merchants/10090/SALEtransactions HTTP/1.1\r\nContent-Type: application/json\r\nAuthorization: Bearer AAEAAHwXaLTYs2APKJW_4TpTDwCw_h9oDx9rA58FR78AFuYCX82Izes1nz9qGBXELGUN_EukKcP5T78Th5guDz4Rw5dQ4Gf0suKw7pz9vWrqa1NpZhrD9Lj9T-SFtOJgfodiwVaBBeSgbJLKA7MOzC9q2dv91HBNP69DygL1oX2L2mtt8fWlKSWhQmtG040E1I43jTueX3L3L9YA7iO6pIwO7CGybE5LnjkQ65KB2K4oYKfXRZosF77hgMJIh-KprFy9cYY3EjfupHeLon9im1BGafrda2N5wj_A_LvdMzfLAD1l1dgj82KlvM_gAzNJ4S19gAicRo9zIbsq36Apt-8jFjS0AQAAAAEAAA9Zr_lVLKMmmtKSo6T_9ulzMCRbYs798EpFD2wMlkb1NCQtA65VrNcM20Ka2FjNQfwOcSMWqDl9zFQhPyFl-npsG1Ww2oyyavA6HSe1HLRLtE_1hNBAlTBPQnLJ6hBf8eR_NTiVa-aQdV2l92-eSwCS59CzrOYGGCY1pLdNMDr_r66kg9l-l94154kRoMBRQSCqZV9iM9M-f3adLJqG6Q79zz1oJpGrH-Zv1kuv8eLaJJNOEFYARb0JbnAC5G1l9-aqxGvBrNkd4sAJIe23XrRx2XJCBIABxuGSQ1xJBTINVlXBXq1mvvd8B1uiYiDNia3c_vIGuSGIjZE0VbUN3oJppfCt1joGdePeUaC2Pyb2vuUN00EBEOaD9RF8IBWMLVJaF9cW2OewDOfBQg94MuOKLdXB_IisRx1ed25VQDVyv0f0CxmkAidvoDN0vvRIJZJr-bgBuL5FZM7gETAeYeiGlh7-Mf2Hzgy7236YNxcC9OnWFEcKEU50nlqog1bJnk8wJgoJWNqG0NUEK4DUzYqknmZ98qQv6rYrg5V-Hey-jAQp_KNf3h-vFHVZdP26Yg\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: api.alliedwallet.com\r\nContent-Length: 464\r\n\r\n"
diff --git a/test/unit/gateways/authorize_net_test.rb b/test/unit/gateways/authorize_net_test.rb
index f80be4fbb8f..1ceaefd3d56 100644
--- a/test/unit/gateways/authorize_net_test.rb
+++ b/test/unit/gateways/authorize_net_test.rb
@@ -879,7 +879,6 @@ def test_avs_result
assert_equal 'Y', response.avs_result['street_match']
assert_equal 'Y', response.avs_result['postal_match']
-
@gateway.expects(:ssl_post).returns(address_not_provided_avs_response)
response = @gateway.purchase(@amount, @credit_card)
@@ -2209,7 +2208,6 @@ def failed_refund_using_stored_card_response
eos
-
end
def successful_void_using_stored_card_response
diff --git a/test/unit/gateways/balanced_test.rb b/test/unit/gateways/balanced_test.rb
index 652b27fd084..f405a513edf 100644
--- a/test/unit/gateways/balanced_test.rb
+++ b/test/unit/gateways/balanced_test.rb
@@ -539,7 +539,6 @@ def authorized_partial_debits_response
RESPONSE
end
-
def declined_response
<<-RESPONSE
{
diff --git a/test/unit/gateways/banwire_test.rb b/test/unit/gateways/banwire_test.rb
index 7f65c6c7277..77207753a74 100644
--- a/test/unit/gateways/banwire_test.rb
+++ b/test/unit/gateways/banwire_test.rb
@@ -89,7 +89,6 @@ def test_transcript_scrubbing
assert_equal scrubbed_transcript, @gateway.scrub(transcript)
end
-
private
def failed_purchase_response
diff --git a/test/unit/gateways/beanstream_test.rb b/test/unit/gateways/beanstream_test.rb
index 92866caab82..a140fed4317 100644
--- a/test/unit/gateways/beanstream_test.rb
+++ b/test/unit/gateways/beanstream_test.rb
@@ -162,7 +162,6 @@ def test_failed_verify
assert_equal 'DECLINE', response.message
end
-
# Testing Non-American countries
def test_german_address_sets_state_to_the_required_dummy_value
diff --git a/test/unit/gateways/blue_pay_test.rb b/test/unit/gateways/blue_pay_test.rb
index 713b387278c..089efee347b 100644
--- a/test/unit/gateways/blue_pay_test.rb
+++ b/test/unit/gateways/blue_pay_test.rb
@@ -68,7 +68,6 @@ def test_add_address
assert_equal 'AK', result[:STATE]
assert_equal '123 Test St.', result[:ADDR1]
assert_equal 'US', result[:COUNTRY]
-
end
def test_name_comes_from_payment_method
@@ -177,7 +176,6 @@ def test_cvv_result
end
def test_message_from
-
def get_msg(query)
@gateway.send(:parse, query).message
end
diff --git a/test/unit/gateways/card_connect_test.rb b/test/unit/gateways/card_connect_test.rb
index 704a89ec6ef..d0e424e7be2 100644
--- a/test/unit/gateways/card_connect_test.rb
+++ b/test/unit/gateways/card_connect_test.rb
@@ -192,7 +192,6 @@ def test_successful_unstore
end
def test_failed_unstore
-
end
def test_scrub
diff --git a/test/unit/gateways/card_stream_test.rb b/test/unit/gateways/card_stream_test.rb
index 8eab0ad4030..340f954a5e7 100644
--- a/test/unit/gateways/card_stream_test.rb
+++ b/test/unit/gateways/card_stream_test.rb
@@ -196,7 +196,6 @@ def test_failed_verify
end
def test_purchase_options
-
# Default
purchase = stub_comms do
@gateway.purchase(142, @visacreditcard, @visacredit_options)
diff --git a/test/unit/gateways/cashnet_test.rb b/test/unit/gateways/cashnet_test.rb
index a3e00477a0e..af7ab9fa0bd 100644
--- a/test/unit/gateways/cashnet_test.rb
+++ b/test/unit/gateways/cashnet_test.rb
@@ -147,6 +147,7 @@ def test_scrub
end
private
+
def expected_expiration_date
'%02d%02d' % [@credit_card.month, @credit_card.year.to_s[2..4]]
end
diff --git a/test/unit/gateways/cecabank_test.rb b/test/unit/gateways/cecabank_test.rb
index e21446ea95e..3ed551400fe 100644
--- a/test/unit/gateways/cecabank_test.rb
+++ b/test/unit/gateways/cecabank_test.rb
@@ -77,7 +77,6 @@ def test_transcript_scrubbing
assert_equal scrubbed_transcript, @gateway.scrub(transcript)
end
-
private
def successful_purchase_response
diff --git a/test/unit/gateways/cenpos_test.rb b/test/unit/gateways/cenpos_test.rb
index e43caa1a1a4..950701578bd 100644
--- a/test/unit/gateways/cenpos_test.rb
+++ b/test/unit/gateways/cenpos_test.rb
@@ -307,7 +307,6 @@ def failed_refund_response
)
end
-
def successful_credit_response
%(
Approved091.13VISA0091.13160999621100
diff --git a/test/unit/gateways/commercegate_test.rb b/test/unit/gateways/commercegate_test.rb
index 5fe0e065ba0..eeb2f2e13ea 100644
--- a/test/unit/gateways/commercegate_test.rb
+++ b/test/unit/gateways/commercegate_test.rb
@@ -59,7 +59,6 @@ def test_successful_refund
assert_equal 'EUR', response.params['currencyCode']
end
-
def test_successful_void
@gateway.expects(:ssl_post).returns(successful_void_response)
assert response = @gateway.void('100130291412', @options)
diff --git a/test/unit/gateways/cyber_source_test.rb b/test/unit/gateways/cyber_source_test.rb
index e0765ea00fa..96dce2add49 100644
--- a/test/unit/gateways/cyber_source_test.rb
+++ b/test/unit/gateways/cyber_source_test.rb
@@ -88,7 +88,6 @@ def test_authorize_includes_mdd_fields
end.respond_with(successful_authorization_response)
end
-
def test_successful_check_purchase
@gateway.expects(:ssl_post).returns(successful_purchase_response)
diff --git a/test/unit/gateways/data_cash_test.rb b/test/unit/gateways/data_cash_test.rb
index e7443c2d195..a4f24b4a457 100644
--- a/test/unit/gateways/data_cash_test.rb
+++ b/test/unit/gateways/data_cash_test.rb
@@ -122,6 +122,7 @@ def test_capture_method_is_ecomm
end
private
+
def failed_purchase_response
<<-XML
diff --git a/test/unit/gateways/digitzs_test.rb b/test/unit/gateways/digitzs_test.rb
index ede14ff24f2..99b57ddc432 100644
--- a/test/unit/gateways/digitzs_test.rb
+++ b/test/unit/gateways/digitzs_test.rb
@@ -231,7 +231,6 @@ def successful_split_purchase_response
)
end
-
def failed_purchase_response
%(
{\"meta\":{},\"errors\":[{\"status\":\"400\",\"source\":{\"pointer\":\"/payments\"},\"title\":\"Bad Request\",\"detail\":\"Partner error: Credit card declined (transaction element shows reason for decline)\",\"code\":\"58\",\"meta\":{\"debug\":{\"message\":\"Include debug info with support request.\",\"resource\":\"/payments POST\",\"log\":\"2017/02/02/[23]eb325f3ca78b4f7eb2178a0d1e635a0e\",\"request\":\"73c22dc3-e980-11e6-9390-69c24d5ed1f4\"},\"transaction\":{\"code\":\"51\",\"message\":\"Insufficient funds\",\"invoice\":\"3d1f247d9112349e3db252f9f3327047\",\"authCode\":\"A11111\",\"avsResult\":\"T\"}}}]}
diff --git a/test/unit/gateways/efsnet_test.rb b/test/unit/gateways/efsnet_test.rb
index 1a3528186ef..e437e2aa422 100644
--- a/test/unit/gateways/efsnet_test.rb
+++ b/test/unit/gateways/efsnet_test.rb
@@ -22,7 +22,6 @@ def test_successful_purchase
assert response.test?
assert_equal '100018347764;1.00', response.authorization
assert_equal 'Approved', response.message
-
end
def test_unsuccessful_purchase
@@ -92,6 +91,7 @@ def test_cvv_result
end
private
+
def successful_purchase_response
<<-XML
diff --git a/test/unit/gateways/element_test.rb b/test/unit/gateways/element_test.rb
index c731345435d..253cfcdccbf 100644
--- a/test/unit/gateways/element_test.rb
+++ b/test/unit/gateways/element_test.rb
@@ -61,6 +61,7 @@ def test_failed_purchase_with_payment_account_token
response = @gateway.purchase(@amount, 'bad-payment-account-token-id', @options)
assert_failure response
end
+
def test_successful_authorize
@gateway.expects(:ssl_post).returns(successful_authorize_response)
diff --git a/test/unit/gateways/eway_managed_test.rb b/test/unit/gateways/eway_managed_test.rb
index abcfa3dd6e0..b8f0f421e7a 100644
--- a/test/unit/gateways/eway_managed_test.rb
+++ b/test/unit/gateways/eway_managed_test.rb
@@ -125,7 +125,6 @@ def test_purchase_invoice_reference_comes_from_order_id_or_invoice
request_hash['Envelope']['Body']['ProcessPayment']['invoiceReference'] == 'order_id'
}.returns(successful_purchase_response)
@gateway.purchase(@amount, @valid_customer_id, options)
-
end
def test_invalid_customer_id
diff --git a/test/unit/gateways/eway_test.rb b/test/unit/gateways/eway_test.rb
index 5dbe984051a..bae6c709504 100644
--- a/test/unit/gateways/eway_test.rb
+++ b/test/unit/gateways/eway_test.rb
@@ -97,6 +97,7 @@ def test_transcript_scrubbing
end
private
+
def successful_purchase_response
<<-XML
diff --git a/test/unit/gateways/exact_test.rb b/test/unit/gateways/exact_test.rb
index 1566816809e..b48a4170d74 100644
--- a/test/unit/gateways/exact_test.rb
+++ b/test/unit/gateways/exact_test.rb
@@ -48,7 +48,6 @@ def test_failed_purchase
assert_failure response
end
-
def test_expdate
assert_equal( '%02d%s' % [ @credit_card.month,
@credit_card.year.to_s[-2..-1] ],
@@ -85,8 +84,8 @@ def test_cvv_result
assert_equal 'M', response.cvv_result['code']
end
-
private
+
def successful_purchase_response
<<-RESPONSE
A00427-01#######00104242424242424242106625152ET17000909Longbob Longsen123100001Store Purchase0Processed by:
@@ -122,6 +121,7 @@ def successful_purchase_response
RESPONSE
end
+
def successful_refund_response
<<-RESPONSE
A00427-01#######00104242424242424242106625152ET17000909Longbob Longsen123100001Store Purchase0Processed by:
diff --git a/test/unit/gateways/fat_zebra_test.rb b/test/unit/gateways/fat_zebra_test.rb
index 2251655ff70..e802111c648 100644
--- a/test/unit/gateways/fat_zebra_test.rb
+++ b/test/unit/gateways/fat_zebra_test.rb
@@ -236,6 +236,7 @@ def post_scrubbed
Conn close
POST_SCRUBBED
end
+
# Place raw successful response from gateway here
def successful_purchase_response
{
diff --git a/test/unit/gateways/federated_canada_test.rb b/test/unit/gateways/federated_canada_test.rb
index 2e7daeb5718..0e9497ae03c 100644
--- a/test/unit/gateways/federated_canada_test.rb
+++ b/test/unit/gateways/federated_canada_test.rb
@@ -26,8 +26,7 @@ def test_successful_authorization
assert_success response
assert_equal '1355694937', response.authorization
assert_equal 'auth', response.params['type']
- end
-
+ end
def test_successful_purchase
@gateway.expects(:ssl_post).returns(successful_purchase_response)
@@ -69,8 +68,7 @@ def test_purchase_is_valid_csv
assert data = @gateway.send(:post_data, 'auth', params)
assert_equal post_data_fixture.size, data.size
- end
-
+ end
def test_purchase_meets_minimum_requirements
params = {:amount => @amount}
diff --git a/test/unit/gateways/firstdata_e4_test.rb b/test/unit/gateways/firstdata_e4_test.rb
index a970aaccff8..7758d68a0e1 100755
--- a/test/unit/gateways/firstdata_e4_test.rb
+++ b/test/unit/gateways/firstdata_e4_test.rb
@@ -481,6 +481,7 @@ def successful_purchase_response
RESPONSE
end
+
def successful_purchase_with_specified_currency_response
<<-RESPONSE
@@ -569,6 +570,7 @@ def successful_purchase_with_specified_currency_response
RESPONSE
end
+
def successful_purchase_response_without_transarmor
<<-RESPONSE
@@ -657,6 +659,7 @@ def successful_purchase_response_without_transarmor
RESPONSE
end
+
def successful_refund_response
<<-RESPONSE
diff --git a/test/unit/gateways/gateway_test.rb b/test/unit/gateways/gateway_test.rb
index 3334a916a07..f8f29c235be 100644
--- a/test/unit/gateways/gateway_test.rb
+++ b/test/unit/gateways/gateway_test.rb
@@ -116,7 +116,6 @@ def test_split_names_with_empty_names
assert_equal [nil, nil], @gateway.send(:split_names, ' ')
end
-
def test_supports_scrubbing?
gateway = Gateway.new
refute gateway.supports_scrubbing?
diff --git a/test/unit/gateways/iridium_test.rb b/test/unit/gateways/iridium_test.rb
index b772f91408e..055afb50653 100644
--- a/test/unit/gateways/iridium_test.rb
+++ b/test/unit/gateways/iridium_test.rb
@@ -36,7 +36,6 @@ def test_unsuccessful_request
assert response.test?
end
-
def test_successful_authorize
@gateway.expects(:ssl_post).returns(successful_authorize_response)
@@ -110,12 +109,10 @@ def test_use_ducktyping_for_credit_card
end
end
-
def test_transcript_scrubbing
assert_equal post_scrubbed, @gateway.scrub(pre_scrubbed)
end
-
private
# Place raw successful response from gateway here
diff --git a/test/unit/gateways/jetpay_test.rb b/test/unit/gateways/jetpay_test.rb
index aafc7966e83..91069432c3e 100644
--- a/test/unit/gateways/jetpay_test.rb
+++ b/test/unit/gateways/jetpay_test.rb
@@ -141,6 +141,7 @@ def test_purchase_sends_order_origin
end
private
+
def successful_purchase_response
<<-EOF
diff --git a/test/unit/gateways/linkpoint_test.rb b/test/unit/gateways/linkpoint_test.rb
index 8de27a522f8..9cbbd9897b0 100644
--- a/test/unit/gateways/linkpoint_test.rb
+++ b/test/unit/gateways/linkpoint_test.rb
@@ -119,7 +119,6 @@ def test_line_items_are_valid_xml
'12.00', :quantity => '1', :options => [{:name => 'Color', :value =>
'Red'}, {:name => 'Size', :value => 'XL'}]},{:id => '111', :description => 'keychain', :price => '3.00', :quantity => '1'}]}
-
assert data = @gateway.send(:post_data, @amount, @credit_card, options)
assert REXML::Document.new(data)
end
@@ -191,6 +190,7 @@ def test_transcript_scrubbing
end
private
+
def successful_authorization_response
'CSISun Jan 6 21:41:31 200800044861821000APPROVED1234560004486182:NNNM:100018312899:1199680890APPROVEDNNNM'
end
diff --git a/test/unit/gateways/litle_test.rb b/test/unit/gateways/litle_test.rb
index 59cd7af5969..652ea34eb84 100644
--- a/test/unit/gateways/litle_test.rb
+++ b/test/unit/gateways/litle_test.rb
@@ -396,7 +396,6 @@ def test_supports_scrubbing?
assert @gateway.supports_scrubbing?
end
-
private
def successful_purchase_response
diff --git a/test/unit/gateways/maxipago_test.rb b/test/unit/gateways/maxipago_test.rb
index 04215332445..b437bcda00a 100644
--- a/test/unit/gateways/maxipago_test.rb
+++ b/test/unit/gateways/maxipago_test.rb
@@ -74,7 +74,6 @@ def test_successful_void
void = @gateway.void(auth.authorization)
assert_success void
assert_equal 'VOIDED', void.params['response_message']
-
end
def test_failed_void
diff --git a/test/unit/gateways/merchant_partners_test.rb b/test/unit/gateways/merchant_partners_test.rb
index 77930e9830d..3307fa37d61 100644
--- a/test/unit/gateways/merchant_partners_test.rb
+++ b/test/unit/gateways/merchant_partners_test.rb
@@ -628,7 +628,6 @@ def failed_credit_response
)
end
-
def successful_store_response
%(
diff --git a/test/unit/gateways/metrics_global_test.rb b/test/unit/gateways/metrics_global_test.rb
index e16afd5dd8f..5082a40facc 100644
--- a/test/unit/gateways/metrics_global_test.rb
+++ b/test/unit/gateways/metrics_global_test.rb
@@ -61,7 +61,6 @@ def test_add_address
assert_equal 'CO', result[:state]
assert_equal '164 Waverley Street', result[:address]
assert_equal 'US', result[:country]
-
end
def test_add_invoice
diff --git a/test/unit/gateways/moneris_us_test.rb b/test/unit/gateways/moneris_us_test.rb
index 9d358635147..46aa128e20b 100644
--- a/test/unit/gateways/moneris_us_test.rb
+++ b/test/unit/gateways/moneris_us_test.rb
@@ -98,7 +98,6 @@ def test_amount_style
end
def test_preauth_is_valid_xml
-
params = {
:order_id => 'order1',
:amount => '1.01',
@@ -113,7 +112,6 @@ def test_preauth_is_valid_xml
end
def test_purchase_is_valid_xml
-
params = {
:order_id => 'order1',
:amount => '1.01',
@@ -128,7 +126,6 @@ def test_purchase_is_valid_xml
end
def test_capture_is_valid_xml
-
params = {
:order_id => 'order1',
:amount => '1.01',
diff --git a/test/unit/gateways/ncr_secure_pay_test.rb b/test/unit/gateways/ncr_secure_pay_test.rb
index f1b8de1eccd..4fabb3b8779 100644
--- a/test/unit/gateways/ncr_secure_pay_test.rb
+++ b/test/unit/gateways/ncr_secure_pay_test.rb
@@ -16,7 +16,6 @@ def setup
end
def test_successful_purchase
-
response = stub_comms do
@gateway.purchase(@amount, @credit_card, @options)
end.check_request do |endpoint, data, headers|
@@ -42,7 +41,6 @@ def test_failed_purchase
end
def test_successful_authorize
-
response = stub_comms do
@gateway.authorize(@amount, @credit_card, @options)
end.check_request do |endpoint, data, headers|
@@ -67,7 +65,6 @@ def test_failed_authorize
end
def test_successful_capture
-
response = stub_comms do
@gateway.capture(@amount, '12345', @options)
end.check_request do |endpoint, data, headers|
@@ -91,7 +88,6 @@ def test_failed_capture
end
def test_successful_refund
-
response = stub_comms do
@gateway.refund(@amount, '12345', @options)
end.check_request do |endpoint, data, headers|
@@ -115,7 +111,6 @@ def test_failed_refund
end
def test_successful_void
-
response = stub_comms do
@gateway.void('12345', @options)
end.check_request do |endpoint, data, headers|
@@ -138,7 +133,6 @@ def test_failed_void
end
def test_successful_verify
-
response = stub_comms do
@gateway.verify(@credit_card, @options)
end.respond_with(successful_authorize_response, successful_void_response)
@@ -148,7 +142,6 @@ def test_successful_verify
end
def test_successful_verify_with_failed_void
-
response = stub_comms do
@gateway.verify(@credit_card, @options)
end.respond_with(successful_authorize_response, failed_void_response)
@@ -158,7 +151,6 @@ def test_successful_verify_with_failed_void
end
def test_failed_verify
-
response = stub_comms do
@gateway.verify(@credit_card, @options)
end.respond_with(failed_authorize_response, failed_void_response)
diff --git a/test/unit/gateways/net_registry_test.rb b/test/unit/gateways/net_registry_test.rb
index e478e8d6151..0d6c50e2f63 100644
--- a/test/unit/gateways/net_registry_test.rb
+++ b/test/unit/gateways/net_registry_test.rb
@@ -105,6 +105,7 @@ def test_bad_login
end
private
+
def successful_purchase_response
<<-RESPONSE
approved
diff --git a/test/unit/gateways/netbanx_test.rb b/test/unit/gateways/netbanx_test.rb
index 56a74c156aa..ba464b8eac2 100644
--- a/test/unit/gateways/netbanx_test.rb
+++ b/test/unit/gateways/netbanx_test.rb
@@ -151,7 +151,6 @@ def test_successful_unstore
assert response.test?
end
-
def test_scrub
assert @gateway.supports_scrubbing?
assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed
diff --git a/test/unit/gateways/netbilling_test.rb b/test/unit/gateways/netbilling_test.rb
index 1230046dfe1..724e3037542 100644
--- a/test/unit/gateways/netbilling_test.rb
+++ b/test/unit/gateways/netbilling_test.rb
@@ -114,6 +114,7 @@ def test_transcript_scrubbing
end
private
+
def successful_purchase_response
'avs_code=X&cvv2_code=M&status_code=1&auth_code=999999&trans_id=110270311543&auth_msg=TEST+APPROVED&auth_date=2008-01-25+16:43:54'
end
diff --git a/test/unit/gateways/netpay_test.rb b/test/unit/gateways/netpay_test.rb
index 42a47d8b3da..6b107d2e9f5 100644
--- a/test/unit/gateways/netpay_test.rb
+++ b/test/unit/gateways/netpay_test.rb
@@ -76,7 +76,6 @@ def test_unsuccessful_purchase
assert response.test?
end
-
def test_successful_authorize
@gateway.expects(:ssl_post).with(
anything,
diff --git a/test/unit/gateways/optimal_payment_test.rb b/test/unit/gateways/optimal_payment_test.rb
index 7f1eceb5a08..b88d15665f7 100644
--- a/test/unit/gateways/optimal_payment_test.rb
+++ b/test/unit/gateways/optimal_payment_test.rb
@@ -212,7 +212,6 @@ def test_avs_results_not_in_response
end
def test_deprecated_options
-
assert_deprecation_warning("The 'account' option is deprecated in favor of 'account_number' and will be removed in a future version.") do
@gateway = OptimalPaymentGateway.new(
:account => '12345678',
diff --git a/test/unit/gateways/pay_gate_xml_test.rb b/test/unit/gateways/pay_gate_xml_test.rb
index c8ee14c5e70..157cd2bd89b 100644
--- a/test/unit/gateways/pay_gate_xml_test.rb
+++ b/test/unit/gateways/pay_gate_xml_test.rb
@@ -30,7 +30,6 @@ def test_successful_authorization
assert response.test?
end
-
def test_successful_settlement
@gateway.expects(:ssl_post).returns(successful_settlement_response)
@@ -103,5 +102,4 @@ def successful_refund_response
ENDOFXML
end
-
end
diff --git a/test/unit/gateways/pay_junction_test.rb b/test/unit/gateways/pay_junction_test.rb
index 1a94fd2a77b..16a3139be79 100644
--- a/test/unit/gateways/pay_junction_test.rb
+++ b/test/unit/gateways/pay_junction_test.rb
@@ -20,7 +20,6 @@ def setup
@amount = 100
end
-
def test_detect_test_credentials_when_in_production
Base.mode = :production
@@ -95,8 +94,8 @@ def test_add_creditcard_with_track_data
end.respond_with(successful_authorization_response)
end
-
private
+
def successful_authorization_response
<<-RESPONSE
dc_merchant_name=PayJunction - (demo)dc_merchant_address=3 W. Carrillodc_merchant_city=Santa Barbaradc_merchant_state=CAdc_merchant_zip=93101dc_merchant_phone=800-601-0230dc_device_id=1174dc_transaction_date=2007-11-28 19:22:33.791634dc_transaction_action=chargedc_approval_code=TAS193dc_response_code=00dc_response_message=APPROVAL TAS193 dc_transaction_id=3144302dc_posture=holddc_invoice_number=9f76c4e4bd66a36dc5aeb4bd7b3a02fadc_notes=--START QUICK-LINK DEBUG--
diff --git a/test/unit/gateways/pay_secure_test.rb b/test/unit/gateways/pay_secure_test.rb
index 78ea5b7b56f..32ba6132b64 100644
--- a/test/unit/gateways/pay_secure_test.rb
+++ b/test/unit/gateways/pay_secure_test.rb
@@ -49,6 +49,7 @@ def test_cvv_result_not_supported
end
private
+
def successful_purchase_response
<<-RESPONSE
Status: Accepted
diff --git a/test/unit/gateways/payflow_express_uk_test.rb b/test/unit/gateways/payflow_express_uk_test.rb
index 6c40fa8aca9..60a18a88be8 100644
--- a/test/unit/gateways/payflow_express_uk_test.rb
+++ b/test/unit/gateways/payflow_express_uk_test.rb
@@ -63,6 +63,7 @@ def test_get_express_details_with_ship_to_name
end
private
+
def successful_get_express_details_response
<<-RESPONSE
diff --git a/test/unit/gateways/paymill_test.rb b/test/unit/gateways/paymill_test.rb
index 816b6198213..546a98b9125 100644
--- a/test/unit/gateways/paymill_test.rb
+++ b/test/unit/gateways/paymill_test.rb
@@ -224,6 +224,7 @@ def test_transcript_scrubbing
end
private
+
def successful_store_response
MockResponse.new 200, %[jsonPFunction({"transaction":{"mode":"CONNECTOR_TEST","channel":"57313835619696ac361dc591bc973626","response":"SYNC","payment":{"code":"CC.DB"},"processing":{"code":"CC.DB.90.00","reason":{"code":"00","message":"Successful Processing"},"result":"ACK","return":{"code":"000.100.112","message":"Request successfully processed in 'Merchant in Connector Test Mode'"},"timestamp":"2013-02-12 21:33:43"},"identification":{"shortId":"1998.1832.1612","uniqueId":"tok_4f9a571b39bd8d0b4db5"}}})]
end
diff --git a/test/unit/gateways/paypal/paypal_common_api_test.rb b/test/unit/gateways/paypal/paypal_common_api_test.rb
index 2f53c97fad3..93ecc4ce2f2 100644
--- a/test/unit/gateways/paypal/paypal_common_api_test.rb
+++ b/test/unit/gateways/paypal/paypal_common_api_test.rb
@@ -6,7 +6,9 @@
class CommonPaypalGateway < ActiveMerchant::Billing::Gateway
include ActiveMerchant::Billing::PaypalCommonAPI
def currency(code); 'USD'; end
+
def localized_amount(num, code); num; end
+
def commit(a, b); end
end
@@ -120,7 +122,6 @@ def test_build_do_authorize_request
assert_equal '1.00', REXML::XPath.first(request, '//DoAuthorizationReq/DoAuthorizationRequest/Amount').text
end
-
def test_build_manage_pending_transaction_status_request
request = REXML::Document.new(@gateway.send(:build_manage_pending_transaction_status,123, 'Accept'))
assert_equal '123', REXML::XPath.first(request, '//ManagePendingTransactionStatusReq/ManagePendingTransactionStatusRequest/TransactionID').text
diff --git a/test/unit/gateways/paypal_digital_goods_test.rb b/test/unit/gateways/paypal_digital_goods_test.rb
index ba8e05f12a8..cef8d773b49 100644
--- a/test/unit/gateways/paypal_digital_goods_test.rb
+++ b/test/unit/gateways/paypal_digital_goods_test.rb
@@ -74,7 +74,6 @@ def test_setup_request_invalid_requests
end
end
-
def test_build_setup_request_valid
@gateway.expects(:ssl_post).returns(successful_setup_response)
@@ -89,10 +88,8 @@ def test_build_setup_request_valid
:amount => 100,
:description => 'Description',
:category => 'Digital' } ] )
-
end
-
private
def successful_setup_response
diff --git a/test/unit/gateways/paypal_express_test.rb b/test/unit/gateways/paypal_express_test.rb
index 445dace38f4..c88f0291630 100644
--- a/test/unit/gateways/paypal_express_test.rb
+++ b/test/unit/gateways/paypal_express_test.rb
@@ -374,7 +374,6 @@ def test_items_are_included_if_specified_in_build_sale_or_authorization_request
{:name => 'item two', :description => 'item two description', :amount => 20000, :number => 2, :quantity => 4}
]}))
-
assert_equal 'item one', REXML::XPath.first(xml, '//n2:PaymentDetails/n2:PaymentDetailsItem/n2:Name').text
assert_equal 'item one description', REXML::XPath.first(xml, '//n2:PaymentDetails/n2:PaymentDetailsItem/n2:Description').text
assert_equal '100.00', REXML::XPath.first(xml, '//n2:PaymentDetails/n2:PaymentDetailsItem/n2:Amount').text
@@ -447,7 +446,6 @@ def test_agreement_details_failure
assert_equal '11451', response.params['error_codes']
end
-
def test_build_reference_transaction_test
PaypalExpressGateway.application_id = 'ActiveMerchant_FOO'
xml = REXML::Document.new(@gateway.send(:build_reference_transaction_request, 'Sale', 2000, {
@@ -666,7 +664,6 @@ def successful_create_billing_agreement_response
RESPONSE
end
-
def successful_authorize_reference_transaction_response
<<-RESPONSE
@@ -763,7 +760,6 @@ def successful_reference_transaction_response
RESPONSE
end
-
def successful_details_response
<<-RESPONSE
diff --git a/test/unit/gateways/paypal_test.rb b/test/unit/gateways/paypal_test.rb
index 0dc0926f0ca..1b129b30330 100644
--- a/test/unit/gateways/paypal_test.rb
+++ b/test/unit/gateways/paypal_test.rb
@@ -1380,7 +1380,6 @@ def successful_details_response
RESPONSE
end
-
def successful_update_recurring_payment_profile_response
<<-RESPONSE
diff --git a/test/unit/gateways/payscout_test.rb b/test/unit/gateways/payscout_test.rb
index 7e84b6e4b29..fcf69767329 100644
--- a/test/unit/gateways/payscout_test.rb
+++ b/test/unit/gateways/payscout_test.rb
@@ -214,7 +214,6 @@ def test_shipping_address
assert_equal address[:email], post[:shipping_email]
end
-
def test_add_currency_from_options
post = {}
@gateway.send(:add_currency, post, 100, { currency: 'CAD' })
diff --git a/test/unit/gateways/paystation_test.rb b/test/unit/gateways/paystation_test.rb
index f49d013b5ce..1ed768b1186 100644
--- a/test/unit/gateways/paystation_test.rb
+++ b/test/unit/gateways/paystation_test.rb
@@ -3,7 +3,6 @@
class PaystationTest < Test::Unit::TestCase
include CommStub
def setup
-
@gateway = PaystationGateway.new(
:paystation_id => 'some_id_number',
:gateway_id => 'another_id_number'
@@ -80,7 +79,6 @@ def test_successful_capture
end
def test_successful_refund
-
response = stub_comms do
@gateway.purchase(@amount, @credit_card, @options)
end.respond_with(successful_purchase_response)
diff --git a/test/unit/gateways/payway_test.rb b/test/unit/gateways/payway_test.rb
index 86ae5139140..d72f7a849b0 100644
--- a/test/unit/gateways/payway_test.rb
+++ b/test/unit/gateways/payway_test.rb
@@ -50,7 +50,6 @@ def test_succesful_purchase_visa_from_register_user
assert_match '0', response.params['summary_code']
assert_match '08', response.params['response_code']
assert_match 'VISA', response.params['card_scheme_name']
-
end
def test_successful_purchase_master_card
diff --git a/test/unit/gateways/plugnpay_test.rb b/test/unit/gateways/plugnpay_test.rb
index 5591e435414..c815b9fe251 100644
--- a/test/unit/gateways/plugnpay_test.rb
+++ b/test/unit/gateways/plugnpay_test.rb
@@ -80,7 +80,6 @@ def test_add_address_outsite_north_america
assert_equal result[:card_address1], '164 Waverley Street'
assert_equal result[:card_country], 'DE'
-
end
def test_add_address
@@ -108,6 +107,7 @@ def test_cvv_result
end
private
+
def successful_purchase_response
"FinalStatus=success&IPaddress=72%2e138%2e32%2e216&MStatus=success&User_Agent=&acct_code3=newcard&address1=1234%20My%20Street&address2=Apt%201&app_level=5&auth_code=TSTAUT&auth_date=20080125&auth_msg=%20&authtype=authpostauth&avs_code=X&card_address1=1234%20My%20Street&card_amount=1%2e00&card_city=Ottawa&card_country=CA&card_name=Longbob%20Longsen&card_state=ON&card_type=VISA&card_zip=K1C2N6&city=Ottawa&convert=underscores&country=CA¤cy=usd&cvvresp=M&dontsndmail=yes&easycart=0&merchant=pnpdemo2&merchfraudlev=&mode=auth&orderID=2008012522252119738&phone=555%2d555%2d5555&publisher_email=trash%40plugnpay%2ecom&publisher_name=pnpdemo2&publisher_password=pnpdemo222&resp_code=00&shipinfo=0&shipname=Jim%20Smith&sresp=A&state=ON&success=yes&zip=K1C2N6&a=b\n"
end
diff --git a/test/unit/gateways/psl_card_test.rb b/test/unit/gateways/psl_card_test.rb
index c37f92531ed..8e31f389338 100644
--- a/test/unit/gateways/psl_card_test.rb
+++ b/test/unit/gateways/psl_card_test.rb
@@ -54,6 +54,7 @@ def test_cvv_result
end
private
+
def successful_purchase_response
'ResponseCode=00&Message=AUTHCODE:01256&CrossReference=08012522454901256086&First4=4543&Last4=9982&ExpMonth=12&ExpYear=2010&AVSCV2Check=ALL MATCH&Amount=1000&QAAddress=76 Roseby Avenue Manchester&QAPostcode=M63X 7TH&MerchantName=Merchant Name&QAName=John Smith'
end
diff --git a/test/unit/gateways/realex_test.rb b/test/unit/gateways/realex_test.rb
index abb11a2c16b..e30172fa1ed 100644
--- a/test/unit/gateways/realex_test.rb
+++ b/test/unit/gateways/realex_test.rb
@@ -242,7 +242,6 @@ def test_refund_xml
SRC
assert_xml_equal valid_refund_request_xml, @gateway.build_refund_request(@amount, '1;4321;1234', {})
-
end
def test_refund_with_rebate_secret_xml
@@ -265,7 +264,6 @@ def test_refund_with_rebate_secret_xml
SRC
assert_xml_equal valid_refund_request_xml, gateway.build_refund_request(@amount, '1;4321;1234', {})
-
end
def test_auth_with_address
@@ -283,7 +281,6 @@ def test_auth_with_address
assert_instance_of Response, response
assert_success response
assert response.test?
-
end
def test_zip_in_shipping_address
diff --git a/test/unit/gateways/sage_pay_test.rb b/test/unit/gateways/sage_pay_test.rb
index aae37768a48..da8ed24674b 100644
--- a/test/unit/gateways/sage_pay_test.rb
+++ b/test/unit/gateways/sage_pay_test.rb
@@ -470,7 +470,6 @@ def transcript
ExpiryDate=0616
BankAuthCode=999777
TRANSCRIPT
-
end
def scrubbed_transcript
@@ -492,6 +491,5 @@ def scrubbed_transcript
ExpiryDate=0616
BankAuthCode=999777
TRANSCRIPT
-
end
end
diff --git a/test/unit/gateways/sage_test.rb b/test/unit/gateways/sage_test.rb
index 9d7b2707929..b6faa1761c6 100644
--- a/test/unit/gateways/sage_test.rb
+++ b/test/unit/gateways/sage_test.rb
@@ -324,6 +324,7 @@ def test_supports_scrubbing?
end
private
+
def successful_authorization_response
"\002A911911APPROVED 00MX001234567890\0341000\0340\034\003"
end
diff --git a/test/unit/gateways/secure_pay_au_test.rb b/test/unit/gateways/secure_pay_au_test.rb
index 163c41fe0fa..e99997f6d4e 100644
--- a/test/unit/gateways/secure_pay_au_test.rb
+++ b/test/unit/gateways/secure_pay_au_test.rb
@@ -27,7 +27,6 @@ def test_supported_card_types
assert_equal [:visa, :master, :american_express, :diners_club, :jcb], SecurePayAuGateway.supported_cardtypes
end
-
def test_successful_purchase_with_live_data
@gateway.expects(:ssl_post).returns(successful_live_purchase_response)
diff --git a/test/unit/gateways/secure_pay_tech_test.rb b/test/unit/gateways/secure_pay_tech_test.rb
index 008f447cbc7..90847f8e9d6 100644
--- a/test/unit/gateways/secure_pay_tech_test.rb
+++ b/test/unit/gateways/secure_pay_tech_test.rb
@@ -34,6 +34,7 @@ def test_unsuccessful_purchase
end
private
+
def successful_purchase_response
"1,4--120119220646821,000000014511,23284,014511,20080125\r\n"
end
diff --git a/test/unit/gateways/secure_pay_test.rb b/test/unit/gateways/secure_pay_test.rb
index 2a897b6a2fd..0fdc3b08493 100644
--- a/test/unit/gateways/secure_pay_test.rb
+++ b/test/unit/gateways/secure_pay_test.rb
@@ -48,7 +48,6 @@ def test_successful_purchase
assert response.authorization
end
-
def test_avs_result
@gateway.expects(:ssl_post).returns(successful_purchase_response)
diff --git a/test/unit/gateways/skip_jack_test.rb b/test/unit/gateways/skip_jack_test.rb
index 10cc562bbfa..d1faca21da2 100644
--- a/test/unit/gateways/skip_jack_test.rb
+++ b/test/unit/gateways/skip_jack_test.rb
@@ -193,7 +193,6 @@ def test_paymentech_authorization_failure
assert_failure response
end
-
def test_serial_number_is_added_before_developer_serial_number_for_authorization
expected ="Year=#{Time.now.year + 1}&TransactionAmount=1.00&ShipToPhone=&SerialNumber=X&SJName=Longbob+Longsen&OrderString=1~None~0.00~0~N~%7C%7C&OrderNumber=1&OrderDescription=&Month=9&InvoiceNumber=&Email=cody%40example.com&DeveloperSerialNumber=Y&CustomerCode=&CVV2=123&AccountNumber=4242424242424242"
expected = expected.gsub('~', '%7E') if RUBY_VERSION < '2.5.0'
@@ -235,6 +234,7 @@ def test_dont_send_blank_state
end
private
+
def successful_authorization_response
<<-CSV
"AUTHCODE","szSerialNumber","szTransactionAmount","szAuthorizationDeclinedMessage","szAVSResponseCode","szAVSResponseMessage","szOrderNumber","szAuthorizationResponseCode","szIsApproved","szCVV2ResponseCode","szCVV2ResponseMessage","szReturnCode","szTransactionFileName","szCAVVResponseCode"
diff --git a/test/unit/gateways/stripe_test.rb b/test/unit/gateways/stripe_test.rb
index 84c43f52a05..e3b9d93af5f 100644
--- a/test/unit/gateways/stripe_test.rb
+++ b/test/unit/gateways/stripe_test.rb
@@ -1413,7 +1413,6 @@ def test_authorization_with_emv_payment_application_fee_included
assert_success response
end
-
def test_passing_stripe_account_header
@gateway.expects(:ssl_request).with do |method, url, post, headers|
headers.include?('Stripe-Account')
diff --git a/test/unit/gateways/usa_epay_transaction_test.rb b/test/unit/gateways/usa_epay_transaction_test.rb
index d8eb617c41b..e80a0323cc5 100644
--- a/test/unit/gateways/usa_epay_transaction_test.rb
+++ b/test/unit/gateways/usa_epay_transaction_test.rb
@@ -493,7 +493,6 @@ def successful_void_response_echeck
'UMversion=2.9&UMstatus=Approved&UMauthCode=TM80A5&UMrefNum=133134971&UMavsResult=No%20AVS%20response%20%28Typically%20no%20AVS%20data%20sent%20or%20swiped%20transaction%29&UMavsResultCode=&UMcvv2Result=No%20CVV2%2FCVC%20data%20available%20for%20transaction.&UMcvv2ResultCode=&UMresult=A&UMvpasResultCode=&UMerror=&UMerrorcode=00000&UMcustnum=&UMbatch=&UMbatchRefNum=&UMisDuplicate=N&UMconvertedAmount=&UMconvertedAmountCurrency=840&UMconversionRate=&UMcustReceiptResult=No%20Receipt%20Sent&UMprocRefNum=&UMcardLevelResult=&UMauthAmount=&UMfiller=filled'
end
-
def pre_scrubbed
<<-EOS
opening connection to sandbox.usaepay.com:443...
diff --git a/test/unit/gateways/verifi_test.rb b/test/unit/gateways/verifi_test.rb
index 028c623a996..7debaabf3cd 100644
--- a/test/unit/gateways/verifi_test.rb
+++ b/test/unit/gateways/verifi_test.rb
@@ -69,7 +69,6 @@ def test_add_description
result = {}
@gateway.send(:add_invoice_data, result, :description => 'My Purchase is great')
assert_equal 'My Purchase is great', result[:orderdescription]
-
end
def test_purchase_meets_minimum_requirements
@@ -83,7 +82,6 @@ def test_purchase_meets_minimum_requirements
minimum_requirements.each do |key|
assert_not_nil(data =~ /#{key}=/)
end
-
end
def test_avs_result
diff --git a/test/unit/gateways/wirecard_test.rb b/test/unit/gateways/wirecard_test.rb
index 03b82b41b98..f8f3e2d2b90 100644
--- a/test/unit/gateways/wirecard_test.rb
+++ b/test/unit/gateways/wirecard_test.rb
@@ -579,7 +579,6 @@ def failed_void_response
XML
end
-
# Purchase failure
def wrong_creditcard_purchase_response
<<-XML
diff --git a/test/unit/gateways/worldpay_online_payments_test.rb b/test/unit/gateways/worldpay_online_payments_test.rb
index e97d3b457e0..697ac11aba0 100644
--- a/test/unit/gateways/worldpay_online_payments_test.rb
+++ b/test/unit/gateways/worldpay_online_payments_test.rb
@@ -198,9 +198,11 @@ def test_invalid_login
def successful_token_response
%({"token": "TEST_RU_8fcc4f2f-8c0d-483d-a0a3-eaad7356623e","paymentMethod": {"type": "ObfuscatedCard","name": "Longbob Longsen","expiryMonth": 10,"expiryYear": 2016,"cardType": "VISA","maskedCardNumber": "**** **** **** 1111"},"reusable": true})
end
+
def successful_authorize_response
%({"orderCode": "a46502d0-80ba-425b-a6db-2c57e9de91da","token": "TEST_RU_8fcc4f2f-8c0d-483d-a0a3-eaad7356623e","orderDescription": "Test Purchase","amount": 0,"currencyCode": "GBP","authorizeOnly": true,"paymentStatus": "AUTHORIZED","paymentResponse": {"type": "ObfuscatedCard","name": "Longbob Longsen","expiryMonth": 10,"expiryYear": 2016,"cardType": "VISA_CREDIT","maskedCardNumber": "**** **** **** 1111"},"environment": "TEST","authorizedAmount": 1000})
end
+
def failed_authorize_response
%({"httpStatusCode":400,"customCode":"BAD_REQUEST","message":"CVC can't be null/empty","description":"Some of request parameters are invalid, please check your request. For more information please refer to Json schema.","errorHelpUrl":null,"originalRequest":"{'reusable':false,'paymentMethod':{'type':'Card','name':'Example Name','expiryMonth':'**','expiryYear':'****','cardNumber':'**** **** **** 1111','cvc':''},'clientKey':'T_C_845d39f4-f33c-430c-8fca-ad89bf1e5810'}"} )
end
diff --git a/test/unit/network_connection_retries_test.rb b/test/unit/network_connection_retries_test.rb
index b071c4e9ede..49ce4b3d8e6 100644
--- a/test/unit/network_connection_retries_test.rb
+++ b/test/unit/network_connection_retries_test.rb
@@ -67,7 +67,6 @@ def test_ssl_errors_raise_correctly
end
end
-
def test_invalid_response_error
assert_raises(ActiveMerchant::InvalidResponseError) do
retry_exceptions do
From 28eb2a8113653b8b0e0f283f95ede6e3f18c99f4 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Mon, 24 Sep 2018 10:21:50 -0400
Subject: [PATCH 0096/2234] Revert "Stripe: support shipping info in purchases"
This reverts commit d4d927e42a6ac7c0ce15be7e9a14f6c2f00a0ff5.
As-written, this could cause transaction to fail in some situations:
Stripe will validate *all* shipping parameters if *any* are present, so
attempting a purchase with some but not all shipping params could cause
the entire purchase to be rejected. The proper fix is to not include
any shipping details unless all are present, but for now, simply remove
the functionality entirely.
---
CHANGELOG | 1 -
.../billing/gateways/stripe.rb | 23 -------------------
test/remote/gateways/remote_stripe_test.rb | 18 ---------------
test/unit/gateways/stripe_test.rb | 20 +---------------
4 files changed, 1 insertion(+), 61 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 66a94d43280..7394938edba 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -15,7 +15,6 @@
* Stripe: support a reason for voiding a transaction [whitby3001] #2378
* Payeezy: Add reversal_id in support of timeout reversals [dtykocki] #2997
* Stripe: support Level 3 transaction fields [bpollack] #2996
-* Stripe: support passing shipping info for purchases [whitby3001] #2379
== Version 1.83.0 (August 30, 2018)
* CT Payment: Update How Address is Passed [nfarve] #2960
diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb
index 0424cde6b42..49c7077a2a8 100644
--- a/lib/active_merchant/billing/gateways/stripe.rb
+++ b/lib/active_merchant/billing/gateways/stripe.rb
@@ -321,7 +321,6 @@ def create_post_for_auth_or_purchase(money, payment, options)
end
add_metadata(post, options)
- add_shipping_info(post, options)
add_application_fee(post, options)
add_exchange_rate(post, options)
add_destination(post, options)
@@ -490,28 +489,6 @@ def add_emv_metadata(post, creditcard)
post[:metadata] ||= {}
post[:metadata][:card_read_method] = creditcard.read_method if creditcard.respond_to?(:read_method)
end
-
- def add_shipping_info(post, options = {})
- post[:shipping] = {}
-
- if address = options[:shipping_address]
- address_params = {}
- address_params[:line1] = address[:address1] if address[:address1]
- address_params[:line2] = address[:address2] if address[:address2]
- address_params[:city] = address[:city] if address[:city]
- address_params[:state] = address[:state] if address[:state]
- address_params[:postal_code] = address[:zip] if address[:zip]
- address_params[:country] = address[:country] if address[:country]
- post[:shipping][:address] = address_params unless address_params.empty?
- post[:shipping][:name] = address[:name] if address[:name]
- post[:shipping][:phone] = address[:phone] if address[:phone]
- end
-
- post[:shipping][:carrier] = options[:carrier] if options[:carrier]
- post[:shipping][:tracking_number] = options[:tracking_number] if options[:tracking_number]
-
- post.delete(:shipping) if post[:shipping].empty?
- end
def fetch_application_fee(identification, options = {})
options.merge!(:key => @fee_refund_api_key)
diff --git a/test/remote/gateways/remote_stripe_test.rb b/test/remote/gateways/remote_stripe_test.rb
index 3fecb1ba64d..cbc94e8ab52 100644
--- a/test/remote/gateways/remote_stripe_test.rb
+++ b/test/remote/gateways/remote_stripe_test.rb
@@ -122,24 +122,6 @@ def test_successful_purchase_with_level3_data
assert_equal 'wow@example.com', response.params['metadata']['email']
end
- def test_successful_purchase_with_shipping_info
- custom_options = @options.merge(:shipping_address => address(), :carrier => 'UPS', :tracking_number => '12345')
- assert response = @gateway.purchase(@amount, @credit_card, custom_options)
- assert_success response
- assert_equal 'charge', response.params['object']
- assert response.params['paid']
- assert_equal custom_options[:shipping_address][:name], response.params['shipping']['name']
- assert_equal custom_options[:shipping_address][:address1], response.params['shipping']['address']['line1']
- assert_equal custom_options[:shipping_address][:address2], response.params['shipping']['address']['line2']
- assert_equal custom_options[:shipping_address][:city], response.params['shipping']['address']['city']
- assert_equal custom_options[:shipping_address][:state], response.params['shipping']['address']['state']
- assert_equal custom_options[:shipping_address][:zip], response.params['shipping']['address']['postal_code']
- assert_equal custom_options[:shipping_address][:country], response.params['shipping']['address']['country']
- assert_equal custom_options[:shipping_address][:phone], response.params['shipping']['phone']
- assert_equal custom_options[:carrier], response.params['shipping']['carrier']
- assert_equal custom_options[:tracking_number], response.params['shipping']['tracking_number']
- end
-
def test_unsuccessful_purchase
assert response = @gateway.purchase(@amount, @declined_card, @options)
assert_failure response
diff --git a/test/unit/gateways/stripe_test.rb b/test/unit/gateways/stripe_test.rb
index e3b9d93af5f..0dd7f51097c 100644
--- a/test/unit/gateways/stripe_test.rb
+++ b/test/unit/gateways/stripe_test.rb
@@ -13,10 +13,7 @@ def setup
@options = {
:billing_address => address(),
:statement_address => statement_address(),
- :description => 'Test Purchase',
- :shipping_address => address(),
- :carrier => 'UPS',
- :tracking_number => '12345'
+ :description => 'Test Purchase'
}
@apple_pay_payment_token = apple_pay_payment_token
@@ -1063,21 +1060,6 @@ def test_add_statement_address_returns_nil_if_required_fields_missing
end
end
- def test_add_shipping_info
- post = {:card => {}}
- @gateway.send(:add_shipping_info, post, @options)
- assert_equal @options[:shipping_address][:zip], post[:shipping][:address][:postal_code]
- assert_equal @options[:shipping_address][:state], post[:shipping][:address][:state]
- assert_equal @options[:shipping_address][:address1], post[:shipping][:address][:line1]
- assert_equal @options[:shipping_address][:address2], post[:shipping][:address][:line2]
- assert_equal @options[:shipping_address][:country], post[:shipping][:address][:country]
- assert_equal @options[:shipping_address][:city], post[:shipping][:address][:city]
- assert_equal @options[:shipping_address][:name], post[:shipping][:name]
- assert_equal @options[:shipping_address][:phone], post[:shipping][:phone]
- assert_equal @options[:carrier], post[:shipping][:carrier]
- assert_equal @options[:tracking_number], post[:shipping][:tracking_number]
- end
-
def test_ensure_does_not_respond_to_credit
assert !@gateway.respond_to?(:credit)
end
From 668432c33efc8c7828b356b837aa993888e6170f Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Mon, 24 Sep 2018 09:48:34 -0400
Subject: [PATCH 0097/2234] Enable Carnet for Conekta and Openpay
Unit: 3927 tests, 68207 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications
100% passed
---
CHANGELOG | 2 ++
lib/active_merchant/billing/gateways/conekta.rb | 2 +-
lib/active_merchant/billing/gateways/openpay.rb | 2 +-
3 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 7394938edba..72ee8ab8fd0 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -15,6 +15,8 @@
* Stripe: support a reason for voiding a transaction [whitby3001] #2378
* Payeezy: Add reversal_id in support of timeout reversals [dtykocki] #2997
* Stripe: support Level 3 transaction fields [bpollack] #2996
+* Conekta: support Carnet cards [bpollack] #2999
+* Openpay: support Carnet cards [bpollack] #2999
== Version 1.83.0 (August 30, 2018)
* CT Payment: Update How Address is Passed [nfarve] #2960
diff --git a/lib/active_merchant/billing/gateways/conekta.rb b/lib/active_merchant/billing/gateways/conekta.rb
index dfa9d484a20..06aad777b09 100644
--- a/lib/active_merchant/billing/gateways/conekta.rb
+++ b/lib/active_merchant/billing/gateways/conekta.rb
@@ -4,7 +4,7 @@ class ConektaGateway < Gateway
self.live_url = 'https://api.conekta.io/'
self.supported_countries = ['MX']
- self.supported_cardtypes = [:visa, :master, :american_express]
+ self.supported_cardtypes = [:visa, :master, :american_express, :carnet]
self.homepage_url = 'https://conekta.io/'
self.display_name = 'Conekta Gateway'
self.money_format = :cents
diff --git a/lib/active_merchant/billing/gateways/openpay.rb b/lib/active_merchant/billing/gateways/openpay.rb
index 1d44beb6036..778729f4cbd 100644
--- a/lib/active_merchant/billing/gateways/openpay.rb
+++ b/lib/active_merchant/billing/gateways/openpay.rb
@@ -5,7 +5,7 @@ class OpenpayGateway < Gateway
self.test_url = 'https://sandbox-api.openpay.mx/v1/'
self.supported_countries = ['MX']
- self.supported_cardtypes = [:visa, :master, :american_express]
+ self.supported_cardtypes = [:visa, :master, :american_express, :carnet]
self.homepage_url = 'http://www.openpay.mx/'
self.display_name = 'Openpay'
self.default_currency = 'MXN'
From a168b2440fee70dc8549875c4d36b7dbe7d1fce7 Mon Sep 17 00:00:00 2001
From: Anna Gyergyai
Date: Thu, 27 Sep 2018 11:42:52 -0400
Subject: [PATCH 0098/2234] Release v1.84.0
---
CHANGELOG | 4 +++-
lib/active_merchant/version.rb | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 72ee8ab8fd0..1b989f251b4 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,8 @@
= ActiveMerchant CHANGELOG
== HEAD
+
+== Version 1.84.0 (September 27, 2018)
* PayU Latam: support partial captures [bpollack] #2974
* Braintree: Reflect correct test mode in Braintree responses [elfassy] [#2980]
* FirstPay: Expose error code [curiousepic] #2979
@@ -17,6 +19,7 @@
* Stripe: support Level 3 transaction fields [bpollack] #2996
* Conekta: support Carnet cards [bpollack] #2999
* Openpay: support Carnet cards [bpollack] #2999
+* Adyen: Add support for GooglePay [dtykocki] #2971
== Version 1.83.0 (August 30, 2018)
* CT Payment: Update How Address is Passed [nfarve] #2960
@@ -31,7 +34,6 @@
* Adyen: allow overriding card brands [bpollack] #2968
* Adyen: allow custom routing [bpollack] #2969
* First Pay: Adds scrubbing [deedeelavinder] #2972
-* Adyen: Add support for GooglePay [dtykocki] #2971
== Version 1.82.0 (August 13, 2018)
* FirstData: add support for WalletProviderID in v27 gateway [bpollack] #2946
diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb
index e0f40471379..df77bd3ec8f 100644
--- a/lib/active_merchant/version.rb
+++ b/lib/active_merchant/version.rb
@@ -1,3 +1,3 @@
module ActiveMerchant
- VERSION = '1.83.0'
+ VERSION = '1.84.0'
end
From f360cf6cf6fc71f94334942dabcd2f784a019224 Mon Sep 17 00:00:00 2001
From: David Perry
Date: Thu, 27 Sep 2018 14:56:22 -0400
Subject: [PATCH 0099/2234] Authorize.Net: Support custom delimiter for cim
By default, cim transaction responses have a field delimiter of ',' but
fields themselves can easily contain unescaped commas, causing bad
parsing. Providing a custom delimiter option can prevent this.
Remote:
68 tests, 234 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
93 tests, 536 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/authorize_net.rb | 40 +++++++++++--------
.../gateways/remote_authorize_net_test.rb | 10 +++++
test/unit/gateways/authorize_net_test.rb | 35 ++++++++++++++++
4 files changed, 70 insertions(+), 16 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 1b989f251b4..e2a2d1cfd1b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
= ActiveMerchant CHANGELOG
== HEAD
+* Authorize.Net: Support custom delimiter for cim [curiousepic] [#3001]
== Version 1.84.0 (September 27, 2018)
* PayU Latam: support partial captures [bpollack] #2974
diff --git a/lib/active_merchant/billing/gateways/authorize_net.rb b/lib/active_merchant/billing/gateways/authorize_net.rb
index db7367210b4..0c4c4c0c8a0 100644
--- a/lib/active_merchant/billing/gateways/authorize_net.rb
+++ b/lib/active_merchant/billing/gateways/authorize_net.rb
@@ -101,7 +101,7 @@ def initialize(options={})
def purchase(amount, payment, options = {})
if payment.is_a?(String)
- commit(:cim_purchase) do |xml|
+ commit(:cim_purchase, options) do |xml|
add_cim_auth_purchase(xml, 'profileTransAuthCapture', amount, payment, options)
end
else
@@ -113,7 +113,7 @@ def purchase(amount, payment, options = {})
def authorize(amount, payment, options={})
if payment.is_a?(String)
- commit(:cim_authorize) do |xml|
+ commit(:cim_authorize, options) do |xml|
add_cim_auth_purchase(xml, 'profileTransAuthOnly', amount, payment, options)
end
else
@@ -273,10 +273,11 @@ def add_cim_auth_purchase(xml, transaction_type, amount, payment, options)
add_tax_exempt_status(xml, options)
end
end
+ add_extra_options_for_cim(xml, options)
end
def cim_capture(amount, authorization, options)
- commit(:cim_capture) do |xml|
+ commit(:cim_capture, options) do |xml|
add_order_id(xml, options)
xml.transaction do
xml.profileTransPriorAuthCapture do
@@ -287,6 +288,7 @@ def cim_capture(amount, authorization, options)
xml.transId(transaction_id_from(authorization))
end
end
+ add_extra_options_for_cim(xml, options)
end
end
@@ -311,7 +313,7 @@ def normal_capture(amount, authorization, options)
def cim_refund(amount, authorization, options)
transaction_id, card_number, _ = split_authorization(authorization)
- commit(:cim_refund) do |xml|
+ commit(:cim_refund, options) do |xml|
add_order_id(xml, options)
xml.transaction do
xml.profileTransRefund do
@@ -324,6 +326,7 @@ def cim_refund(amount, authorization, options)
xml.transId(transaction_id)
end
end
+ add_extra_options_for_cim(xml, options)
end
end
@@ -355,13 +358,14 @@ def normal_refund(amount, authorization, options)
end
def cim_void(authorization, options)
- commit(:cim_void) do |xml|
+ commit(:cim_void, options) do |xml|
add_order_id(xml, options)
xml.transaction do
xml.profileTransVoid do
xml.transId(transaction_id_from(authorization))
end
end
+ add_extra_options_for_cim(xml, options)
end
end
@@ -672,8 +676,12 @@ def add_po_number(xml, options)
xml.poNumber(options[:po_number]) if options[:po_number]
end
+ def add_extra_options_for_cim(xml, options)
+ xml.extraOptions("x_delim_char=#{options[:delimiter]}") if options[:delimiter]
+ end
+
def create_customer_payment_profile(credit_card, options)
- commit(:cim_store_update) do |xml|
+ commit(:cim_store_update, options) do |xml|
xml.customerProfileId options[:customer_profile_id]
xml.paymentProfile do
add_billing_address(xml, credit_card, options)
@@ -689,7 +697,7 @@ def create_customer_payment_profile(credit_card, options)
end
def create_customer_profile(credit_card, options)
- commit(:cim_store) do |xml|
+ commit(:cim_store, options) do |xml|
xml.profile do
xml.merchantCustomerId(truncate(options[:merchant_customer_id], 20) || SecureRandom.hex(10))
xml.description(truncate(options[:description], 255)) unless empty?(options[:description])
@@ -712,7 +720,7 @@ def create_customer_profile(credit_card, options)
end
def delete_customer_profile(customer_profile_id)
- commit(:cim_store_delete_customer) do |xml|
+ commit(:cim_store_delete_customer, options) do |xml|
xml.customerProfileId(customer_profile_id)
end
end
@@ -742,17 +750,17 @@ def url
test? ? test_url : live_url
end
- def parse(action, raw_response)
+ def parse(action, raw_response, options = {})
if is_cim_action?(action) || action == :verify_credentials
- parse_cim(raw_response)
+ parse_cim(raw_response, options)
else
parse_normal(action, raw_response)
end
end
- def commit(action, &payload)
+ def commit(action, options = {}, &payload)
raw_response = ssl_post(url, post_data(action, &payload), headers)
- response = parse(action, raw_response)
+ response = parse(action, raw_response, options)
avs_result_code = response[:avs_result_code].upcase if response[:avs_result_code]
avs_result = AVSResult.new(code: STANDARD_AVS_CODE_MAPPING[avs_result_code])
@@ -869,7 +877,7 @@ def parse_normal(action, body)
response
end
- def parse_cim(body)
+ def parse_cim(body, options)
response = {}
doc = Nokogiri::XML(body).remove_namespaces!
@@ -904,7 +912,7 @@ def parse_cim(body)
(empty?(element.content) ? nil : element.content)
end
- response.merge!(parse_direct_response_elements(response))
+ response.merge!(parse_direct_response_elements(response, options))
response
end
@@ -967,11 +975,11 @@ def auth_was_for_cim?(authorization)
action && is_cim_action?(action)
end
- def parse_direct_response_elements(response)
+ def parse_direct_response_elements(response, options)
params = response[:direct_response]
return {} unless params
- parts = params.split(',')
+ parts = params.split(options[:delimiter] || ',')
{
response_code: parts[0].to_i,
response_subcode: parts[1],
diff --git a/test/remote/gateways/remote_authorize_net_test.rb b/test/remote/gateways/remote_authorize_net_test.rb
index 57b24453e07..034e0f92cc8 100644
--- a/test/remote/gateways/remote_authorize_net_test.rb
+++ b/test/remote/gateways/remote_authorize_net_test.rb
@@ -322,6 +322,16 @@ def test_successful_purchase_using_stored_card
assert_equal 'This transaction has been approved.', response.message
end
+ def test_successful_purchase_using_stored_card_with_delimiter
+ response = @gateway.store(@credit_card, @options.merge(delimiter: '|'))
+ assert_success response
+
+ response = @gateway.purchase(@amount, response.authorization, @options.merge(delimiter: '|', description: 'description, with, commas'))
+ assert_success response
+ assert_equal 'This transaction has been approved.', response.message
+ assert_equal 'description, with, commas', response.params['order_description']
+ end
+
def test_failed_purchase_using_stored_card
response = @gateway.store(@declined_card)
assert_success response
diff --git a/test/unit/gateways/authorize_net_test.rb b/test/unit/gateways/authorize_net_test.rb
index 1ceaefd3d56..358124ae04f 100644
--- a/test/unit/gateways/authorize_net_test.rb
+++ b/test/unit/gateways/authorize_net_test.rb
@@ -394,6 +394,24 @@ def test_successful_purchase_using_stored_card
assert_equal 'Street address and 5-digit postal code match.', response.avs_result['message']
end
+ def test_successful_purchase_using_stored_card_and_custom_delimiter
+ @gateway.expects(:ssl_post).returns(successful_store_response)
+ store = @gateway.store(@credit_card, @options)
+ assert_success store
+
+ @gateway.expects(:ssl_post).returns(successful_purchase_using_stored_card_response_with_pipe_delimiter)
+
+ response = @gateway.purchase(@amount, store.authorization, {delimiter: '|', description: 'description, with, commas'})
+ assert_success response
+
+ assert_equal '2235700270#XXXX2224#cim_purchase', response.authorization
+ assert_equal 'Y', response.avs_result['code']
+ assert response.avs_result['street_match']
+ assert response.avs_result['postal_match']
+ assert_equal 'Street address and 5-digit postal code match.', response.avs_result['message']
+ assert_equal 'description, with, commas', response.params['order_description']
+ end
+
def test_failed_purchase_using_stored_card
@gateway.expects(:ssl_post).returns(successful_store_response)
store = @gateway.store(@credit_card, @options)
@@ -2109,6 +2127,23 @@ def successful_purchase_using_stored_card_response
eos
end
+ def successful_purchase_using_stored_card_response_with_pipe_delimiter
+ <<-eos
+
+
+ 1
+
+ Ok
+
+ I00001
+ Successful.
+
+
+ 1|1|1|This transaction has been approved.|8HUT72|Y|2235700270|1|description, with, commas|1.01|CC|auth_capture|e385c780422f4bd182c4|Longbob|Longsen||||n/a|||||||||||||||||||4A20EEAF89018FF075899DDB332E9D35||2|||||||||||XXXX2224|Visa||||||||||||||||
+
+ eos
+ end
+
def failed_purchase_using_stored_card_response
<<-eos
From a6a2e5e7e1a0a7abcfc8e06edb58f1baa5c3a6f1 Mon Sep 17 00:00:00 2001
From: Filipe Costa
Date: Fri, 28 Sep 2018 10:21:34 -0400
Subject: [PATCH 0100/2234] Release v1.85.0
---
CHANGELOG | 1 +
lib/active_merchant/version.rb | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index e2a2d1cfd1b..f0ec80bccb2 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
= ActiveMerchant CHANGELOG
== HEAD
+== Version 1.85.0 (September 28, 2018)
* Authorize.Net: Support custom delimiter for cim [curiousepic] [#3001]
== Version 1.84.0 (September 27, 2018)
diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb
index df77bd3ec8f..6f6f680ff1c 100644
--- a/lib/active_merchant/version.rb
+++ b/lib/active_merchant/version.rb
@@ -1,3 +1,3 @@
module ActiveMerchant
- VERSION = '1.84.0'
+ VERSION = '1.85.0'
end
From 7f134e4e7d747a9d057b40c76ff8f9ae9d78ae92 Mon Sep 17 00:00:00 2001
From: dtykocki
Date: Fri, 28 Sep 2018 09:27:24 -0400
Subject: [PATCH 0101/2234] UsaEpayTransaction: Support UMcheckformat option
for echecks
Remote:
26 tests, 101 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
46 tests, 270 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 2 ++
.../billing/gateways/usa_epay_transaction.rb | 5 +++--
.../gateways/remote_usa_epay_transaction_test.rb | 7 +++++++
test/unit/gateways/usa_epay_transaction_test.rb | 13 +++++++++++++
4 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index f0ec80bccb2..f62c0e12f1f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,8 @@
= ActiveMerchant CHANGELOG
== HEAD
+* UsaEpayTransaction: Support UMcheckformat option for echecks [dtykocki] [#3002]
+
== Version 1.85.0 (September 28, 2018)
* Authorize.Net: Support custom delimiter for cim [curiousepic] [#3001]
diff --git a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb
index 83ac01b3cc9..bb9b41d7fcb 100644
--- a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb
+++ b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb
@@ -64,7 +64,7 @@ def purchase(money, payment, options = {})
add_amount(post, money)
add_invoice(post, options)
- add_payment(post, payment)
+ add_payment(post, payment, options)
unless payment.respond_to?(:track_data) && payment.track_data.present?
add_address(post, payment, options)
add_customer_data(post, options)
@@ -195,8 +195,9 @@ def add_invoice(post, options)
post[:description] = options[:description]
end
- def add_payment(post, payment)
+ def add_payment(post, payment, options={})
if payment.respond_to?(:routing_number)
+ post[:checkformat] = options[:check_format] if options[:check_format]
post[:account] = payment.account_number
post[:routing] = payment.routing_number
post[:name] = payment.name unless payment.name.blank?
diff --git a/test/remote/gateways/remote_usa_epay_transaction_test.rb b/test/remote/gateways/remote_usa_epay_transaction_test.rb
index ac553b144de..b4760f3f387 100644
--- a/test/remote/gateways/remote_usa_epay_transaction_test.rb
+++ b/test/remote/gateways/remote_usa_epay_transaction_test.rb
@@ -29,6 +29,13 @@ def test_successful_purchase_with_echeck
assert_success response
end
+ def test_successful_purchase_with_echeck_and_extra_options
+ extra_options = @options.merge(check_format: 'ARC')
+ assert response = @gateway.purchase(@amount, @check, extra_options)
+ assert_equal 'Success', response.message
+ assert_success response
+ end
+
def test_successful_authorization_with_manual_entry
@credit_card.manual_entry = true
assert response = @gateway.authorize(@amount, @credit_card, @options)
diff --git a/test/unit/gateways/usa_epay_transaction_test.rb b/test/unit/gateways/usa_epay_transaction_test.rb
index e80a0323cc5..753e74ba13b 100644
--- a/test/unit/gateways/usa_epay_transaction_test.rb
+++ b/test/unit/gateways/usa_epay_transaction_test.rb
@@ -53,6 +53,19 @@ def test_successful_request_with_echeck
assert response.test?
end
+ def test_successful_purchase_with_echeck_and_extra_options
+ response = stub_comms do
+ @gateway.purchase(@amount, @check, @options.merge(check_format: 'ARC'))
+ end.check_request do |endpoint, data, headers|
+ assert_match(/UMcheckformat=ARC/, data)
+ end.respond_with(successful_purchase_response_echeck)
+
+ assert_equal 'Success', response.message
+ assert_equal '133134803', response.authorization
+ assert_success response
+ assert response.test?
+ end
+
def test_unsuccessful_request
@gateway.expects(:ssl_post).returns(unsuccessful_purchase_response)
From 39602f2276ff490c1a8e82869f9c4625046e2845 Mon Sep 17 00:00:00 2001
From: molbrown
Date: Thu, 27 Sep 2018 14:56:38 -0400
Subject: [PATCH 0102/2234] Global Collect: handle internal server errors
Ingenico returns HTML when it has a 500 error, which this gateway has
not handled and would crash on a JSON parse error. New rescue provides a
more informative error and prevents crashing in this situation.
Remote:
16 tests, 38 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
19 tests, 85 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Closes #3005
---
.rubocop_todo.yml | 6 ++
CHANGELOG | 1 +
.../billing/gateways/global_collect.rb | 27 +++++++--
test/unit/gateways/global_collect_test.rb | 57 +++++++++++++++++++
4 files changed, 85 insertions(+), 6 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 99cea84dfd4..989a1398236 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -1394,6 +1394,10 @@ Style/SpecialGlobalVars:
Style/StringLiteralsInInterpolation:
Enabled: false
+Style/StringLiterals:
+ Exclude:
+ - 'test/unit/gateways/global_collect_test.rb'
+
# Offense count: 307
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, MinSize.
@@ -1460,3 +1464,5 @@ Style/ZeroLengthPredicate:
# URISchemes: http, https
Metrics/LineLength:
Max: 2484
+ Exclude:
+ - 'test/unit/gateways/global_collect_test.rb'
diff --git a/CHANGELOG b/CHANGELOG
index f62c0e12f1f..e3f05b6311b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,7 @@
== HEAD
* UsaEpayTransaction: Support UMcheckformat option for echecks [dtykocki] [#3002]
+* Global Collect: handle internal server errors [molbrown] [#3005]
== Version 1.85.0 (September 28, 2018)
* Authorize.Net: Support custom delimiter for cim [curiousepic] [#3001]
diff --git a/lib/active_merchant/billing/gateways/global_collect.rb b/lib/active_merchant/billing/gateways/global_collect.rb
index 6a82e2807e5..a6f0135921e 100644
--- a/lib/active_merchant/billing/gateways/global_collect.rb
+++ b/lib/active_merchant/billing/gateways/global_collect.rb
@@ -72,8 +72,8 @@ def supports_scrubbing?
def scrub(transcript)
transcript.
gsub(%r((Authorization: )[^\\]*)i, '\1[FILTERED]').
- gsub(%r(("cardNumber\\":\\")\d+), '\1[FILTERED]').
- gsub(%r(("cvv\\":\\")\d+), '\1[FILTERED]')
+ gsub(%r(("cardNumber\\+":\\+")\d+), '\1[FILTERED]').
+ gsub(%r(("cvv\\+":\\+")\d+), '\1[FILTERED]')
end
private
@@ -230,11 +230,14 @@ def uri(action, authorization)
def commit(action, post, authorization = nil)
begin
- response = parse(ssl_post(url(action, authorization), post.to_json, headers(action, post, authorization)))
+ raw_response = ssl_post(url(action, authorization), post.to_json, headers(action, post, authorization))
+ response = parse(raw_response)
rescue ResponseError => e
if e.response.code.to_i >= 400
response = parse(e.response.body)
end
+ rescue JSON::ParserError
+ response = json_error(raw_response)
end
succeeded = success_from(response)
@@ -248,6 +251,14 @@ def commit(action, post, authorization = nil)
)
end
+ def json_error(raw_response)
+ {
+ 'error_message' => 'Invalid response received from the Ingenico ePayments (formerly GlobalCollect) API. Please contact Ingenico ePayments if you continue to receive this message.' \
+ " (The raw response returned by the API was #{raw_response.inspect})",
+ 'status' => 'REJECTED'
+ }
+ end
+
def headers(action, post, authorization = nil)
{
'Content-Type' => content_type,
@@ -286,8 +297,10 @@ def message_from(succeeded, response)
else
if errors = response['errors']
errors.first.try(:[], 'message')
- elsif status = response['status']
- 'Status: ' + status
+ elsif response['error_message']
+ response['error_message']
+ elsif response['status']
+ 'Status: ' + response['status']
else
'No message available'
end
@@ -297,8 +310,10 @@ def message_from(succeeded, response)
def authorization_from(succeeded, response)
if succeeded
response['id'] || response['payment']['id'] || response['paymentResult']['payment']['id']
- else
+ elsif response['errorId']
response['errorId']
+ else
+ 'GATEWAY ERROR'
end
end
diff --git a/test/unit/gateways/global_collect_test.rb b/test/unit/gateways/global_collect_test.rb
index 5a5c7df22c4..8ad5d5a1c02 100644
--- a/test/unit/gateways/global_collect_test.rb
+++ b/test/unit/gateways/global_collect_test.rb
@@ -212,11 +212,28 @@ def test_rejected_refund
assert_equal 'Status: REJECTED', response.message
end
+ def test_invalid_raw_response
+ response = stub_comms do
+ @gateway.purchase(@accepted_amount, @credit_card, @options)
+ end.respond_with(invalid_json_response)
+
+ assert_failure response
+ assert_match %r{^Invalid response received from the Ingenico ePayments}, response.message
+ end
+
def test_scrub
assert @gateway.supports_scrubbing?
assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed
end
+ def test_scrub_invalid_response
+ response = stub_comms do
+ @gateway.purchase(@accepted_amount, @credit_card, @options)
+ end.respond_with(invalid_json_plus_card_data).message
+
+ assert_equal @gateway.scrub(response), scrubbed_invalid_json_plus
+ end
+
private
def pre_scrubbed
@@ -374,4 +391,44 @@ def successful_verify_response
def failed_verify_response
%({\n \"errorId\" : \"cee09c50-5d9d-41b8-b740-8c7bf06d2c66\",\n \"errors\" : [ {\n \"code\" : \"430330\",\n \"message\" : \"Not authorised\"\n } ],\n \"paymentResult\" : {\n \"creationOutput\" : {\n \"additionalReference\" : \"00000014280000000134\",\n \"externalReference\" : \"000000142800000000920000100001\"\n },\n \"payment\" : {\n \"id\" : \"000000142800000000920000100001\",\n \"paymentOutput\" : {\n \"amountOfMoney\" : {\n \"amount\" : 100,\n \"currencyCode\" : \"USD\"\n },\n \"references\" : {\n \"paymentReference\" : \"0\"\n },\n \"paymentMethod\" : \"card\",\n \"cardPaymentMethodSpecificOutput\" : {\n \"paymentProductId\" : 1\n }\n },\n \"status\" : \"REJECTED\",\n \"statusOutput\" : {\n \"errors\" : [ {\n \"code\" : \"430330\",\n \"requestId\" : \"64357\",\n \"message\" : \"Not authorised\"\n } ],\n \"isCancellable\" : false,\n \"statusCode\" : 100,\n \"statusCodeChangeDateTime\" : \"20160318170253\",\n \"isAuthorized\" : false\n }\n }\n }\n})
end
+
+ def invalid_json_response
+ '
+
+ 502 Proxy Error
+
+ Proxy Error
+ The proxy server received an invalid
+ response from an upstream server.
+ The proxy server could not handle the request POST /v1/9040/payments.
+ Reason: Error reading from remote server
+ '
+ end
+
+ def invalid_json_plus_card_data
+ %q(
+
+ 502 Proxy Error
+
+ opening connection to api-sandbox.globalcollect.com:443...
+ opened
+ starting SSL for api-sandbox.globalcollect.com:443...
+ SSL established
+ <- "POST //v1/1428/payments HTTP/1.1\r\nContent-Type: application/json\r\nAuthorization: GCS v1HMAC:96f16a41890565d0:Bqv5QtSXi+SdqXUyoBBeXUDlRvi5DzSm49zWuJTLX9s=\r\nDate: Tue, 15 Mar 2016 14:32:13 GMT\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: api-sandbox.globalcollect.com\r\nContent-Length: 560\r\n\r\n"
+ <- "{\"order\":{\"amountOfMoney\":{\"amount\":\"100\",\"currencyCode\":\"USD\"},\"customer\":{\"merchantCustomerId\":null,\"personalInformation\":{\"name\":{\"firstName\":null,\"surname\":null}},\"billingAddress\":{\"street\":\"456 My Street\",\"additionalInfo\":\"Apt 1\",\"zip\":\"K1C2N6\",\"city\":\"Ottawa\",\"state\":\"ON\",\"countryCode\":\"CA\"}},\"contactDetails\":{\"emailAddress\":null}},\"cardPaymentMethodSpecificInput\":{\"paymentProductId\":\"1\",\"skipAuthentication\":\"true\",\"skipFraudService\":\"true\",\"card\":{\"cvv\":\"123\",\"cardNumber\":\"4567350000427977\",\"expiryDate\":\"0917\",\"cardholderName\":\"Longbob Longsen\"}}}"
+ -> "HTTP/1.1 201 Created\r\n"
+ -> "Date: Tue, 15 Mar 2016 18:32:14 GMT\r\n"
+ -> "Server: Apache/2.4.16 (Unix) OpenSSL/1.0.1p\r\n"
+ -> "Location: https://api-sandbox.globalcollect.com:443/v1/1428/payments/000000142800000000300000100001\r\n"
+ -> "X-Powered-By: Servlet/3.0 JSP/2.2\r\n"
+ -> "Connection: close\r\n"
+ -> "Transfer-Encoding: chunked\r\n"
+ -> "Content-Type: application/json\r\n"
+ -> "\r\n"
+ -> "457\r\n")
+ end
+
+ def scrubbed_invalid_json_plus
+ "Invalid response received from the Ingenico ePayments (formerly GlobalCollect) API. Please contact Ingenico ePayments if you continue to receive this message. (The raw response returned by the API was \" \\n \\n 502 Proxy Error \\n \\n opening connection to api-sandbox.globalcollect.com:443...\\n opened\\n starting SSL for api-sandbox.globalcollect.com:443...\\n SSL established\\n <- \\\"POST //v1/1428/payments HTTP/1.1\\\\r\\\\nContent-Type: application/json\\\\r\\\\nAuthorization: [FILTERED]\\\\r\\\\nDate: Tue, 15 Mar 2016 14:32:13 GMT\\\\r\\\\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\\\\r\\\\nAccept: */*\\\\r\\\\nUser-Agent: Ruby\\\\r\\\\nConnection: close\\\\r\\\\nHost: api-sandbox.globalcollect.com\\\\r\\\\nContent-Length: 560\\\\r\\\\n\\\\r\\\\n\\\"\\n <- \\\"{\\\\\\\"order\\\\\\\":{\\\\\\\"amountOfMoney\\\\\\\":{\\\\\\\"amount\\\\\\\":\\\\\\\"100\\\\\\\",\\\\\\\"currencyCode\\\\\\\":\\\\\\\"USD\\\\\\\"},\\\\\\\"customer\\\\\\\":{\\\\\\\"merchantCustomerId\\\\\\\":null,\\\\\\\"personalInformation\\\\\\\":{\\\\\\\"name\\\\\\\":{\\\\\\\"firstName\\\\\\\":null,\\\\\\\"surname\\\\\\\":null}},\\\\\\\"billingAddress\\\\\\\":{\\\\\\\"street\\\\\\\":\\\\\\\"456 My Street\\\\\\\",\\\\\\\"additionalInfo\\\\\\\":\\\\\\\"Apt 1\\\\\\\",\\\\\\\"zip\\\\\\\":\\\\\\\"K1C2N6\\\\\\\",\\\\\\\"city\\\\\\\":\\\\\\\"Ottawa\\\\\\\",\\\\\\\"state\\\\\\\":\\\\\\\"ON\\\\\\\",\\\\\\\"countryCode\\\\\\\":\\\\\\\"CA\\\\\\\"}},\\\\\\\"contactDetails\\\\\\\":{\\\\\\\"emailAddress\\\\\\\":null}},\\\\\\\"cardPaymentMethodSpecificInput\\\\\\\":{\\\\\\\"paymentProductId\\\\\\\":\\\\\\\"1\\\\\\\",\\\\\\\"skipAuthentication\\\\\\\":\\\\\\\"true\\\\\\\",\\\\\\\"skipFraudService\\\\\\\":\\\\\\\"true\\\\\\\",\\\\\\\"card\\\\\\\":{\\\\\\\"cvv\\\\\\\":\\\\\\\"[FILTERED]\\\\\\\",\\\\\\\"cardNumber\\\\\\\":\\\\\\\"[FILTERED]\\\\\\\",\\\\\\\"expiryDate\\\\\\\":\\\\\\\"0917\\\\\\\",\\\\\\\"cardholderName\\\\\\\":\\\\\\\"Longbob Longsen\\\\\\\"}}}\\\"\\n -> \\\"HTTP/1.1 201 Created\\\\r\\\\n\\\"\\n -> \\\"Date: Tue, 15 Mar 2016 18:32:14 GMT\\\\r\\\\n\\\"\\n -> \\\"Server: Apache/2.4.16 (Unix) OpenSSL/1.0.1p\\\\r\\\\n\\\"\\n -> \\\"Location: https://api-sandbox.globalcollect.com:443/v1/1428/payments/000000142800000000300000100001\\\\r\\\\n\\\"\\n -> \\\"X-Powered-By: Servlet/3.0 JSP/2.2\\\\r\\\\n\\\"\\n -> \\\"Connection: close\\\\r\\\\n\\\"\\n -> \\\"Transfer-Encoding: chunked\\\\r\\\\n\\\"\\n -> \\\"Content-Type: application/json\\\\r\\\\n\\\"\\n -> \\\"\\\\r\\\\n\\\"\\n -> \\\"457\\\\r\\\\n\\\"\")"
+ end
end
From 74fe0b2cdbce0a6a87f90ad3db5f1c1919806849 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Wed, 25 Jul 2018 15:09:39 -0400
Subject: [PATCH 0103/2234] Barclaycard Smartpay: add third-party payout
support
This is fully opt-in and requires additional account parameters to
operate correctly.
Unit: 26 tests, 127 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote: 31 tests, 64 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/barclaycard_smartpay.rb | 67 +++++++++++++------
.../remote_barclaycard_smartpay_test.rb | 9 ++-
.../gateways/barclaycard_smartpay_test.rb | 29 ++++++++
4 files changed, 82 insertions(+), 24 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index e3f05b6311b..cfe49500d9b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -3,6 +3,7 @@
== HEAD
* UsaEpayTransaction: Support UMcheckformat option for echecks [dtykocki] [#3002]
* Global Collect: handle internal server errors [molbrown] [#3005]
+* Barclaycard Smartpay: allow third-party payouts for credits [bpollack] #3009
== Version 1.85.0 (September 28, 2018)
* Authorize.Net: Support custom delimiter for cim [curiousepic] [#3001]
diff --git a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb
index 6df4b68ecfa..1ea7ee14dce 100644
--- a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb
+++ b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb
@@ -68,7 +68,27 @@ def credit(money, creditcard, options = {})
post[:nationality] = options[:nationality] if options[:nationality]
post[:shopperName] = options[:shopper_name] if options[:shopper_name]
- commit('refundWithData', post)
+ if options[:third_party_payout]
+ post[:recurring] = options[:recurring_contract] || {contract: 'PAYOUT'}
+ MultiResponse.run do |r|
+ r.process {
+ commit(
+ 'storeDetailAndSubmitThirdParty',
+ post,
+ @options[:store_payout_account],
+ @options[:store_payout_password])
+ }
+ r.process {
+ commit(
+ 'confirmThirdParty',
+ modification_request(r.authorization, @options),
+ @options[:review_payout_account],
+ @options[:review_payout_password])
+ }
+ end
+ else
+ commit('refundWithData', post)
+ end
end
def void(identification, options = {})
@@ -128,9 +148,10 @@ def scrub(transcript)
'18' => 'I' # Neither postal code nor address were checked
}
- def commit(action, post)
+ def commit(action, post, account = 'ws', password = @options[:password])
request = post_data(flatten_hash(post))
- raw_response = ssl_post(build_url(action), request, headers)
+ request_headers = headers(account, password)
+ raw_response = ssl_post(build_url(action), request, request_headers)
response = parse(raw_response)
Response.new(
@@ -181,10 +202,10 @@ def flatten_hash(hash, prefix = nil)
flat_hash
end
- def headers
+ def headers(account, password)
{
'Content-Type' => 'application/x-www-form-urlencoded; charset=utf-8',
- 'Authorization' => 'Basic ' + Base64.strict_encode64("ws@Company.#{@options[:company]}:#{@options[:password]}").strip
+ 'Authorization' => 'Basic ' + Base64.strict_encode64("#{account}@Company.#{@options[:company]}:#{password}").strip
}
end
@@ -214,10 +235,10 @@ def message_from(response)
def success_from(response)
return true if response['result'] == 'Success'
- return true if response['resultCode'] == 'Authorised'
- return true if response['resultCode'] == 'Received'
- successful_responses = %w([capture-received] [cancel-received] [refund-received])
- successful_responses.include?(response['response'])
+
+ successful_results = %w(Authorised Received [payout-submit-received])
+ successful_responses = %w([capture-received] [cancel-received] [refund-received] [payout-confirm-received])
+ successful_results.include?(response['resultCode']) || successful_responses.include?(response['response'])
end
def build_url(action)
@@ -226,6 +247,8 @@ def build_url(action)
"#{test? ? self.test_url : self.live_url}/Recurring/#{API_VERSION}/storeToken"
when 'finalize3ds'
"#{test? ? self.test_url : self.live_url}/Payment/#{API_VERSION}/authorise3d"
+ when 'storeDetailAndSubmitThirdParty', 'confirmThirdParty'
+ "#{test? ? self.test_url : self.live_url}/Payout/#{API_VERSION}/#{action}"
else
"#{test? ? self.test_url : self.live_url}/Payment/#{API_VERSION}/#{action}"
end
@@ -263,11 +286,11 @@ def create_address_hash(address, house, street)
hash = {}
hash[:houseNumberOrName] = house
hash[:street] = street
- hash[:city] = address[:city] if address[:city]
- hash[:stateOrProvince] = address[:state] if address[:state]
- hash[:postalCode] = address[:zip] if address[:zip]
- hash[:country] = address[:country] if address[:country]
- hash
+ hash[:city] = address[:city]
+ hash[:stateOrProvince] = address[:state]
+ hash[:postalCode] = address[:zip]
+ hash[:country] = address[:country]
+ hash.keep_if { |_, v| v }
end
def amount_hash(money, currency)
@@ -301,20 +324,20 @@ def psp_reference_from(authorization)
def payment_request(money, options)
hash = {}
- hash[:merchantAccount] = @options[:merchant]
- hash[:reference] = options[:order_id] if options[:order_id]
- hash[:shopperEmail] = options[:email] if options[:email]
- hash[:shopperIP] = options[:ip] if options[:ip]
- hash[:shopperReference] = options[:customer] if options[:customer]
- hash[:shopperInteraction] = options[:shopper_interaction] if options[:shopper_interaction]
- hash[:deviceFingerprint] = options[:device_fingerprint] if options[:device_fingerprint]
+ hash[:merchantAccount] = @options[:merchant]
+ hash[:reference] = options[:order_id]
+ hash[:shopperEmail] = options[:email]
+ hash[:shopperIP] = options[:ip]
+ hash[:shopperReference] = options[:customer]
+ hash[:shopperInteraction] = options[:shopper_interaction]
+ hash[:deviceFingerprint] = options[:device_fingerprint]
hash.keep_if { |_, v| v }
end
def store_request(options)
hash = {}
hash[:merchantAccount] = @options[:merchant]
- hash[:shopperEmail] = options[:email] if options[:email]
+ hash[:shopperEmail] = options[:email]
hash[:shopperReference] = options[:customer] if options[:customer]
hash.keep_if { |_, v| v }
end
diff --git a/test/remote/gateways/remote_barclaycard_smartpay_test.rb b/test/remote/gateways/remote_barclaycard_smartpay_test.rb
index eaa3f7288ae..105166a2250 100644
--- a/test/remote/gateways/remote_barclaycard_smartpay_test.rb
+++ b/test/remote/gateways/remote_barclaycard_smartpay_test.rb
@@ -6,8 +6,8 @@ def setup
BarclaycardSmartpayGateway.ssl_strict = false
@amount = 100
- @credit_card = credit_card('4111111111111111', :month => 8, :year => 2018, :verification_value => 737)
- @declined_card = credit_card('4000300011112220', :month => 8, :year => 2018, :verification_value => 737)
+ @credit_card = credit_card('4111111111111111', :month => 10, :year => 2020, :verification_value => 737)
+ @declined_card = credit_card('4000300011112220', :month => 3, :year => 2030, :verification_value => 737)
@three_ds_enrolled_card = credit_card('4212345678901237', brand: :visa)
@options = {
@@ -238,6 +238,11 @@ def test_failed_credit_insufficient_validation
# assert_failure response
end
+ def test_successful_third_party_payout
+ response = @gateway.credit(@amount, @credit_card, @options_with_credit_fields.merge({third_party_payout: true}))
+ assert_success response
+ end
+
def test_successful_void
auth = @gateway.authorize(@amount, @credit_card, @options)
assert_success auth
diff --git a/test/unit/gateways/barclaycard_smartpay_test.rb b/test/unit/gateways/barclaycard_smartpay_test.rb
index 4763dfa6813..e88dd36bdea 100644
--- a/test/unit/gateways/barclaycard_smartpay_test.rb
+++ b/test/unit/gateways/barclaycard_smartpay_test.rb
@@ -263,6 +263,7 @@ def test_credit_contains_all_fields
response = stub_comms do
@gateway.credit(@amount, @credit_card, @options_with_credit_fields)
end.check_request do |endpoint, data, headers|
+ assert_match(%r{/refundWithData}, endpoint)
assert_match(/dateOfBirth=1990-10-11&/, data)
assert_match(/entityType=NaturalPerson&/, data)
assert_match(/nationality=US&/, data)
@@ -273,6 +274,26 @@ def test_credit_contains_all_fields
assert response.test?
end
+ def test_successful_third_party_payout
+ response = stub_comms do
+ @gateway.credit(@amount, @credit_card, @options_with_credit_fields.merge({third_party_payout: true}))
+ end.check_request do |endpoint, data, headers|
+ if /storeDetailAndSubmitThirdParty/ =~ endpoint
+ assert_match(%r{/storeDetailAndSubmitThirdParty}, endpoint)
+ assert_match(/dateOfBirth=1990-10-11&/, data)
+ assert_match(/entityType=NaturalPerson&/, data)
+ assert_match(/nationality=US&/, data)
+ assert_match(/shopperName.firstName=Longbob&/, data)
+ assert_match(/recurring\.contract=PAYOUT/, data)
+ else
+ assert_match(/originalReference=/, data)
+ end
+ end.respond_with(successful_payout_store_response, successful_payout_confirm_response)
+
+ assert_success response
+ assert response.test?
+ end
+
def test_successful_void
@gateway.expects(:ssl_post).returns(successful_void_response)
@@ -380,6 +401,14 @@ def successful_credit_response
'fraudResult.accountScore=70&fraudResult.results.0.accountScore=20&fraudResult.results.0.checkId=2&fraudResult.results.0.name=CardChunkUsage&fraudResult.results.1.accountScore=25&fraudResult.results.1.checkId=4&fraudResult.results.1.name=HolderNameUsage&fraudResult.results.2.accountScore=25&fraudResult.results.2.checkId=8&fraudResult.results.2.name=ShopperEmailUsage&fraudResult.results.3.accountScore=0&fraudResult.results.3.checkId=1&fraudResult.results.3.name=PaymentDetailRefCheck&fraudResult.results.4.accountScore=0&fraudResult.results.4.checkId=13&fraudResult.results.4.name=IssuerRefCheck&fraudResult.results.5.accountScore=0&fraudResult.results.5.checkId=15&fraudResult.results.5.name=IssuingCountryReferral&fraudResult.results.6.accountScore=0&fraudResult.results.6.checkId=26&fraudResult.results.6.name=ShopperEmailRefCheck&fraudResult.results.7.accountScore=0&fraudResult.results.7.checkId=27&fraudResult.results.7.name=PmOwnerRefCheck&fraudResult.results.8.accountScore=0&fraudResult.results.8.checkId=56&fraudResult.results.8.name=ShopperReferenceTrustCheck&fraudResult.results.9.accountScore=0&fraudResult.results.9.checkId=10&fraudResult.results.9.name=HolderNameContainsNumber&fraudResult.results.10.accountScore=0&fraudResult.results.10.checkId=11&fraudResult.results.10.name=HolderNameIsOneWord&fraudResult.results.11.accountScore=0&fraudResult.results.11.checkId=21&fraudResult.results.11.name=EmailDomainValidation&pspReference=8514743049239955&resultCode=Received'
end
+ def successful_payout_store_response
+ 'pspReference=8815391117417347&resultCode=%5Bpayout-submit-received%5D'
+ end
+
+ def successful_payout_confirm_response
+ 'pspReference=8815391117421182&response=%5Bpayout-confirm-received%5D'
+ end
+
def failed_credit_response
'errorType=validation&errorCode=137&message=Invalid+amount+specified&status=422'
end
From d62d60e356207e1c00f696b5d02985235f64c16e Mon Sep 17 00:00:00 2001
From: Niaja
Date: Tue, 2 Oct 2018 09:31:22 -0400
Subject: [PATCH 0104/2234] RuboCop: AlignHash
Rubocop fix to align all hashes.
---
.rubocop_todo.yml | 9 -
CHANGELOG | 1 +
.../billing/gateways/usa_epay_advanced.rb | 2 +-
.../gateways/worldpay_online_payments.rb | 30 +-
.../gateways/remote_firstdata_e4_v27_test.rb | 6 +-
test/remote/gateways/remote_opp_test.rb | 62 ++---
.../gateways/remote_payflow_express_test.rb | 105 ++++---
.../gateways/remote_paypal_express_test.rb | 16 +-
test/remote/gateways/remote_paypal_test.rb | 16 +-
.../remote/gateways/remote_secure_pay_test.rb | 3 +-
test/unit/gateways/cyber_source_test.rb | 36 +--
test/unit/gateways/eway_managed_test.rb | 33 +--
test/unit/gateways/linkpoint_test.rb | 52 +++-
test/unit/gateways/opp_test.rb | 2 +-
test/unit/gateways/orbital_test.rb | 18 +-
.../gateways/paypal/paypal_common_api_test.rb | 25 +-
test/unit/gateways/paypal_express_test.rb | 262 +++++++++++++-----
test/unit/gateways/quickpay_v10_test.rb | 12 +-
test/unit/gateways/sage_pay_test.rb | 4 +-
19 files changed, 438 insertions(+), 256 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 989a1398236..3e0bb88d4c3 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -14,15 +14,6 @@ Gemspec/OrderedDependencies:
Exclude:
- 'activemerchant.gemspec'
-# Offense count: 139
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
-# SupportedHashRocketStyles: key, separator, table
-# SupportedColonStyles: key, separator, table
-# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
-Layout/AlignHash:
- Enabled: false
-
# Offense count: 113
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentOneStep, IndentationWidth.
diff --git a/CHANGELOG b/CHANGELOG
index cfe49500d9b..471a6603a47 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -4,6 +4,7 @@
* UsaEpayTransaction: Support UMcheckformat option for echecks [dtykocki] [#3002]
* Global Collect: handle internal server errors [molbrown] [#3005]
* Barclaycard Smartpay: allow third-party payouts for credits [bpollack] #3009
+* RuboCop: AlignHash [nfarve] #3004
== Version 1.85.0 (September 28, 2018)
* Authorize.Net: Support custom delimiter for cim [curiousepic] [#3001]
diff --git a/lib/active_merchant/billing/gateways/usa_epay_advanced.rb b/lib/active_merchant/billing/gateways/usa_epay_advanced.rb
index 1744dcc1306..2f756c0979e 100644
--- a/lib/active_merchant/billing/gateways/usa_epay_advanced.rb
+++ b/lib/active_merchant/billing/gateways/usa_epay_advanced.rb
@@ -1310,7 +1310,7 @@ def build_customer_payments(soap, options)
if options[:payment_methods]
length = options[:payment_methods].length
soap.PaymentMethods 'SOAP-ENC:arrayType' => "ns1:PaymentMethod[#{length}]",
- 'xsi:type' =>'ns1:PaymentMethodArray' do
+ 'xsi:type' =>'ns1:PaymentMethodArray' do
build_customer_payment_methods soap, options
end
end
diff --git a/lib/active_merchant/billing/gateways/worldpay_online_payments.rb b/lib/active_merchant/billing/gateways/worldpay_online_payments.rb
index 519bef0b41a..ede932554ba 100644
--- a/lib/active_merchant/billing/gateways/worldpay_online_payments.rb
+++ b/lib/active_merchant/billing/gateways/worldpay_online_payments.rb
@@ -92,21 +92,21 @@ def create_token(reusable, name, exp_month, exp_year, number, cvc)
end
def create_post_for_auth_or_purchase(token, money, options)
- {
- 'token' => token,
- 'orderDescription' => options[:description] || 'Worldpay Order',
- 'amount' => money,
- 'currencyCode' => options[:currency] || default_currency,
- 'name' => options[:billing_address]&&options[:billing_address][:name] ? options[:billing_address][:name] : '',
- 'billingAddress' => {
- 'address1'=>options[:billing_address]&&options[:billing_address][:address1] ? options[:billing_address][:address1] : '',
- 'address2'=>options[:billing_address]&&options[:billing_address][:address2] ? options[:billing_address][:address2] : '',
- 'address3'=>'',
- 'postalCode'=>options[:billing_address]&&options[:billing_address][:zip] ? options[:billing_address][:zip] : '',
- 'city'=>options[:billing_address]&&options[:billing_address][:city] ? options[:billing_address][:city] : '',
- 'state'=>options[:billing_address]&&options[:billing_address][:state] ? options[:billing_address][:state] : '',
- 'countryCode'=>options[:billing_address]&&options[:billing_address][:country] ? options[:billing_address][:country] : ''
- },
+ {
+ 'token' => token,
+ 'orderDescription' => options[:description] || 'Worldpay Order',
+ 'amount' => money,
+ 'currencyCode' => options[:currency] || default_currency,
+ 'name' => options[:billing_address]&&options[:billing_address][:name] ? options[:billing_address][:name] : '',
+ 'billingAddress' => {
+ 'address1'=>options[:billing_address]&&options[:billing_address][:address1] ? options[:billing_address][:address1] : '',
+ 'address2'=>options[:billing_address]&&options[:billing_address][:address2] ? options[:billing_address][:address2] : '',
+ 'address3'=>'',
+ 'postalCode'=>options[:billing_address]&&options[:billing_address][:zip] ? options[:billing_address][:zip] : '',
+ 'city'=>options[:billing_address]&&options[:billing_address][:city] ? options[:billing_address][:city] : '',
+ 'state'=>options[:billing_address]&&options[:billing_address][:state] ? options[:billing_address][:state] : '',
+ 'countryCode'=>options[:billing_address]&&options[:billing_address][:country] ? options[:billing_address][:country] : ''
+ },
'customerOrderCode' => options[:order_id],
'orderType' => 'ECOM',
'authorizeOnly' => options[:authorizeOnly] ? true : false
diff --git a/test/remote/gateways/remote_firstdata_e4_v27_test.rb b/test/remote/gateways/remote_firstdata_e4_v27_test.rb
index 464f8d87f56..0832c159edc 100644
--- a/test/remote/gateways/remote_firstdata_e4_v27_test.rb
+++ b/test/remote/gateways/remote_firstdata_e4_v27_test.rb
@@ -160,9 +160,9 @@ def test_failed_verify
def test_invalid_login
gateway = FirstdataE4V27Gateway.new(:login => 'NotARealUser',
- :password => 'NotARealPassword',
- :key_id => 'NotARealKey',
- :hmac_key => 'NotARealHMAC' )
+ :password => 'NotARealPassword',
+ :key_id => 'NotARealKey',
+ :hmac_key => 'NotARealHMAC' )
assert response = gateway.purchase(@amount, @credit_card, @options)
assert_match %r{Unauthorized Request}, response.message
assert_failure response
diff --git a/test/remote/gateways/remote_opp_test.rb b/test/remote/gateways/remote_opp_test.rb
index 8dbdd9d3970..652059e87ad 100644
--- a/test/remote/gateways/remote_opp_test.rb
+++ b/test/remote/gateways/remote_opp_test.rb
@@ -18,37 +18,37 @@ def setup
merchant_transaction_id: "active_merchant_test_complete #{time}",
address: address,
description: 'Store Purchase - Books',
- # riskWorkflow: true,
- # testMode: 'EXTERNAL' # or 'INTERNAL', valid only for test system
-
- billing_address: {
- address1: '123 Test Street',
- city: 'Test',
- state: 'TE',
- zip: 'AB12CD',
- country: 'GB',
- },
- shipping_address: {
- name: 'Muton DeMicelis',
- address1: 'My Street On Upiter, Apt 3.14/2.78',
- city: 'Munich',
- state: 'Bov',
- zip: '81675',
- country: 'DE',
- },
- customer: {
- merchant_customer_id: 'your merchant/customer id',
- givenName: 'Jane',
- surname: 'Jones',
- birthDate: '1965-05-01',
- phone: '(?!?)555-5555',
- mobile: '(?!?)234-23423',
- email: 'jane@jones.com',
- company_name: 'JJ Ltd.',
- identification_doctype: 'PASSPORT',
- identification_docid: 'FakeID2342431234123',
- ip: ip,
- },
+ # riskWorkflow: true,
+ # testMode: 'EXTERNAL' # or 'INTERNAL', valid only for test system
+
+ billing_address: {
+ address1: '123 Test Street',
+ city: 'Test',
+ state: 'TE',
+ zip: 'AB12CD',
+ country: 'GB',
+ },
+ shipping_address: {
+ name: 'Muton DeMicelis',
+ address1: 'My Street On Upiter, Apt 3.14/2.78',
+ city: 'Munich',
+ state: 'Bov',
+ zip: '81675',
+ country: 'DE',
+ },
+ customer: {
+ merchant_customer_id: 'your merchant/customer id',
+ givenName: 'Jane',
+ surname: 'Jones',
+ birthDate: '1965-05-01',
+ phone: '(?!?)555-5555',
+ mobile: '(?!?)234-23423',
+ email: 'jane@jones.com',
+ company_name: 'JJ Ltd.',
+ identification_doctype: 'PASSPORT',
+ identification_docid: 'FakeID2342431234123',
+ ip: ip,
+ },
}
@minimal_request_options = {
diff --git a/test/remote/gateways/remote_payflow_express_test.rb b/test/remote/gateways/remote_payflow_express_test.rb
index c2a2cbfe2c0..b25c566df9a 100644
--- a/test/remote/gateways/remote_payflow_express_test.rb
+++ b/test/remote/gateways/remote_payflow_express_test.rb
@@ -6,17 +6,19 @@ def setup
@gateway = PayflowExpressGateway.new(fixtures(:payflow))
- @options = { :billing_address => {
- :name => 'Cody Fauser',
- :address1 => '1234 Shady Brook Lane',
- :city => 'Ottawa',
- :state => 'ON',
- :country => 'CA',
- :zip => '90210',
- :phone => '555-555-5555'
- },
- :email => 'cody@example.com'
- }
+ @options = {
+ :billing_address =>
+ {
+ :name => 'Cody Fauser',
+ :address1 => '1234 Shady Brook Lane',
+ :city => 'Ottawa',
+ :state => 'ON',
+ :country => 'CA',
+ :zip => '90210',
+ :phone => '555-555-5555'
+ },
+ :email => 'cody@example.com'
+ }
end
# Only works with a Payflow 2.0 account or by requesting the addition
@@ -50,7 +52,8 @@ def test_set_express_purchase
def test_setup_authorization_discount_taxes_included_free_shipping
amount = 2518
- options = {:ip=>'127.0.0.1',
+ options = {
+ :ip=>'127.0.0.1',
:return_url=>'http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?buyer_accepts_marketing=true&utm_nooverride=1',
:cancel_return_url=>'http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?utm_nooverride=1',
:customer=>'test6@test.com',
@@ -59,20 +62,25 @@ def test_setup_authorization_discount_taxes_included_free_shipping
:currency=>'USD',
:subtotal=>2798,
:items => [
- {:name => 'test4',
+ {
+ :name => 'test4',
:description => 'test4',
:quantity=>2 ,
:amount=> 1399 ,
- :url=>'http://localhost:3000/products/test4'}],
+ :url=>'http://localhost:3000/products/test4'
+ }
+ ],
:discount=>280,
- :no_shipping=>true}
+ :no_shipping=>true
+ }
response = @gateway.setup_authorization(amount, options)
assert response.success?, response.message
end
def test_setup_authorization_with_discount_taxes_additional
amount = 2518
- options = {:ip=>'127.0.0.1',
+ options = {
+ :ip=>'127.0.0.1',
:return_url=>'http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?buyer_accepts_marketing=true&utm_nooverride=1',
:cancel_return_url=>'http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?utm_nooverride=1',
:customer=>'test6@test.com',
@@ -81,20 +89,25 @@ def test_setup_authorization_with_discount_taxes_additional
:currency=>'USD',
:subtotal=>2798,
:items => [
- {:name => 'test4',
+ {
+ :name => 'test4',
:description => 'test4',
:quantity=>2 ,
:amount=> 1399 ,
- :url=>'http://localhost:3000/products/test4'}],
+ :url=>'http://localhost:3000/products/test4'
+ }
+ ],
:discount=>280,
- :no_shipping=>true}
+ :no_shipping=>true
+ }
response = @gateway.setup_authorization(amount, options)
assert response.success?, response.message
end
def test_setup_authorization_with_discount_taxes_and_shipping_addtiional
amount = 2518
- options = {:ip=>'127.0.0.1',
+ options = {
+ :ip=>'127.0.0.1',
:return_url=>'http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?buyer_accepts_marketing=true&utm_nooverride=1',
:cancel_return_url=>'http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?utm_nooverride=1',
:customer=>'test6@test.com',
@@ -103,13 +116,17 @@ def test_setup_authorization_with_discount_taxes_and_shipping_addtiional
:currency=>'USD',
:subtotal=>2798,
:items => [
- {:name => 'test4',
+ {
+ :name => 'test4',
:description => 'test4',
:quantity=>2 ,
:amount=> 1399 ,
- :url=>'http://localhost:3000/products/test4'}],
+ :url=>'http://localhost:3000/products/test4'
+ }
+ ],
:discount=>280,
- :no_shipping=>false}
+ :no_shipping=>false
+ }
response = @gateway.setup_authorization(amount, options)
assert response.success?, response.message
end
@@ -123,7 +140,8 @@ def setup
def test_setup_authorization_discount_taxes_included_free_shipping
amount = 2518
- options = {:ip=>'127.0.0.1',
+ options = {
+ :ip=>'127.0.0.1',
:return_url=>'http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?buyer_accepts_marketing=true&utm_nooverride=1',
:cancel_return_url=>'http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?utm_nooverride=1',
:customer=>'test6@test.com',
@@ -132,21 +150,25 @@ def test_setup_authorization_discount_taxes_included_free_shipping
:currency=>'GBP',
:subtotal=>2798,
:items=> [
- {:name=>'test4',
+ {
+ :name=>'test4',
:description=>'test4',
:quantity=>2,
:amount=>1399,
- :url=>'http://localhost:3000/products/test4'},
- ],
+ :url=>'http://localhost:3000/products/test4'
+ }
+ ],
:discount=>280,
- :no_shipping=>true}
+ :no_shipping=>true
+ }
response = @gateway.setup_authorization(amount, options)
assert response.success?, response.message
end
def test_setup_authorization_with_discount_taxes_additional
amount = 2518
- options = {:ip=>'127.0.0.1',
+ options = {
+ :ip=>'127.0.0.1',
:return_url=>'http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?buyer_accepts_marketing=true&utm_nooverride=1',
:cancel_return_url=>'http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?utm_nooverride=1',
:customer=>'test6@test.com',
@@ -155,21 +177,25 @@ def test_setup_authorization_with_discount_taxes_additional
:currency=>'GBP',
:subtotal=>2798,
:items=> [
- {:name=>'test4',
+ {
+ :name=>'test4',
:description=>'test4',
:quantity=>2,
:amount=>1399,
- :url=>'http://localhost:3000/products/test4'},
- ],
+ :url=>'http://localhost:3000/products/test4'
+ }
+ ],
:discount=>280,
- :no_shipping=>true}
+ :no_shipping=>true
+ }
response = @gateway.setup_authorization(amount, options)
assert response.success?, response.message
end
def test_setup_authorization_with_discount_taxes_and_shipping_addtiional
amount = 2518
- options = {:ip=>'127.0.0.1',
+ options = {
+ :ip=>'127.0.0.1',
:return_url=>'http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?buyer_accepts_marketing=true&utm_nooverride=1',
:cancel_return_url=>'http://localhost:3000/orders/1/8e06ea26f8add7608671d433f13c2193/commit_paypal?utm_nooverride=1',
:customer=>'test6@test.com',
@@ -178,14 +204,17 @@ def test_setup_authorization_with_discount_taxes_and_shipping_addtiional
:currency=>'GBP',
:subtotal=>2798,
:items=> [
- {:name=>'test4',
+ {
+ :name=>'test4',
:description=>'test4',
:quantity=>2,
:amount=>1399,
- :url=>'http://localhost:3000/products/test4'},
- ],
+ :url=>'http://localhost:3000/products/test4'
+ }
+ ],
:discount=>280,
- :no_shipping=>false}
+ :no_shipping=>false
+ }
response = @gateway.setup_authorization(amount, options)
assert response.success?, response.message
end
diff --git a/test/remote/gateways/remote_paypal_express_test.rb b/test/remote/gateways/remote_paypal_express_test.rb
index 938bd0f9c14..e5a4ff50364 100644
--- a/test/remote/gateways/remote_paypal_express_test.rb
+++ b/test/remote/gateways/remote_paypal_express_test.rb
@@ -9,13 +9,15 @@ def setup
@options = {
:order_id => '230000',
:email => 'buyer@jadedpallet.com',
- :billing_address => { :name => 'Fred Brooks',
- :address1 => '1234 Penny Lane',
- :city => 'Jonsetown',
- :state => 'NC',
- :country => 'US',
- :zip => '23456'
- } ,
+ :billing_address =>
+ {
+ :name => 'Fred Brooks',
+ :address1 => '1234 Penny Lane',
+ :city => 'Jonsetown',
+ :state => 'NC',
+ :country => 'US',
+ :zip => '23456'
+ } ,
:description => 'Stuff that you purchased, yo!',
:ip => '10.0.0.1',
:return_url => 'http://example.com/return',
diff --git a/test/remote/gateways/remote_paypal_test.rb b/test/remote/gateways/remote_paypal_test.rb
index 44ef35493fb..7901d34024a 100644
--- a/test/remote/gateways/remote_paypal_test.rb
+++ b/test/remote/gateways/remote_paypal_test.rb
@@ -10,13 +10,15 @@ def setup
@params = {
:order_id => generate_unique_id,
:email => 'buyer@jadedpallet.com',
- :billing_address => { :name => 'Longbob Longsen',
- :address1 => '4321 Penny Lane',
- :city => 'Jonsetown',
- :state => 'NC',
- :country => 'US',
- :zip => '23456'
- } ,
+ :billing_address =>
+ {
+ :name => 'Longbob Longsen',
+ :address1 => '4321 Penny Lane',
+ :city => 'Jonsetown',
+ :state => 'NC',
+ :country => 'US',
+ :zip => '23456'
+ },
:description => 'Stuff that you purchased, yo!',
:ip => '10.0.0.1'
}
diff --git a/test/remote/gateways/remote_secure_pay_test.rb b/test/remote/gateways/remote_secure_pay_test.rb
index 5806fd0ab72..c739e1cc9f4 100644
--- a/test/remote/gateways/remote_secure_pay_test.rb
+++ b/test/remote/gateways/remote_secure_pay_test.rb
@@ -10,7 +10,8 @@ def setup
:year => '2014'
)
- @options = { :order_id => generate_unique_id,
+ @options = {
+ :order_id => generate_unique_id,
:description => 'Store purchase',
:billing_address => address
}
diff --git a/test/unit/gateways/cyber_source_test.rb b/test/unit/gateways/cyber_source_test.rb
index 96dce2add49..82dbff6dd06 100644
--- a/test/unit/gateways/cyber_source_test.rb
+++ b/test/unit/gateways/cyber_source_test.rb
@@ -19,24 +19,24 @@ def setup
@check = check()
@options = {
- :ip => @customer_ip,
- :order_id => '1000',
- :line_items => [
- {
- :declared_value => @amount,
- :quantity => 2,
- :code => 'default',
- :description => 'Giant Walrus',
- :sku => 'WA323232323232323'
- },
- {
- :declared_value => @amount,
- :quantity => 2,
- :description => 'Marble Snowcone',
- :sku => 'FAKE1232132113123'
- }
- ],
- :currency => 'USD'
+ :ip => @customer_ip,
+ :order_id => '1000',
+ :line_items => [
+ {
+ :declared_value => @amount,
+ :quantity => 2,
+ :code => 'default',
+ :description => 'Giant Walrus',
+ :sku => 'WA323232323232323'
+ },
+ {
+ :declared_value => @amount,
+ :quantity => 2,
+ :description => 'Marble Snowcone',
+ :sku => 'FAKE1232132113123'
+ }
+ ],
+ :currency => 'USD'
}
@subscription_options = {
diff --git a/test/unit/gateways/eway_managed_test.rb b/test/unit/gateways/eway_managed_test.rb
index b8f0f421e7a..c322e223579 100644
--- a/test/unit/gateways/eway_managed_test.rb
+++ b/test/unit/gateways/eway_managed_test.rb
@@ -14,22 +14,23 @@ def setup
@amount = 100
- @options = { :billing_address => {
- :address1 => '1234 My Street',
- :address2 => 'Apt 1',
- :company => 'Widgets Inc',
- :city => 'Ottawa',
- :state => 'ON',
- :zip => 'K1C2N6',
- :country => 'au',
- :title => 'Mr.',
- :phone => '(555)555-5555'
- },
- :email => 'someguy1232@fakeemail.net',
- :order_id => '1000',
- :customer => 'mycustomerref',
- :description => 'My Description',
- :invoice => 'invoice-4567'
+ @options = {
+ :billing_address => {
+ :address1 => '1234 My Street',
+ :address2 => 'Apt 1',
+ :company => 'Widgets Inc',
+ :city => 'Ottawa',
+ :state => 'ON',
+ :zip => 'K1C2N6',
+ :country => 'au',
+ :title => 'Mr.',
+ :phone => '(555)555-5555'
+ },
+ :email => 'someguy1232@fakeemail.net',
+ :order_id => '1000',
+ :customer => 'mycustomerref',
+ :description => 'My Description',
+ :invoice => 'invoice-4567'
}
end
diff --git a/test/unit/gateways/linkpoint_test.rb b/test/unit/gateways/linkpoint_test.rb
index 9cbbd9897b0..50639eb460a 100644
--- a/test/unit/gateways/linkpoint_test.rb
+++ b/test/unit/gateways/linkpoint_test.rb
@@ -80,7 +80,9 @@ def test_amount_style
def test_purchase_is_valid_xml
@gateway.send(
- :parameters, 1000, @credit_card, :ordertype => 'SALE', :order_id => 1004,
+ :parameters, 1000, @credit_card,
+ :ordertype => 'SALE',
+ :order_id => 1004,
:billing_address => {
:address1 => '1313 lucky lane',
:city => 'Lost Angeles',
@@ -95,7 +97,13 @@ def test_purchase_is_valid_xml
def test_recurring_is_valid_xml
@gateway.send(
- :parameters, 1000, @credit_card, :ordertype => 'SALE', :action => 'SUBMIT', :installments => 12, :startdate => 'immediate', :periodicity => 'monthly', :order_id => 1006,
+ :parameters, 1000, @credit_card,
+ :ordertype => 'SALE',
+ :action => 'SUBMIT',
+ :installments => 12,
+ :startdate => 'immediate',
+ :periodicity => 'monthly',
+ :order_id => 1006,
:billing_address => {
:address1 => '1313 lucky lane',
:city => 'Lost Angeles',
@@ -108,16 +116,42 @@ def test_recurring_is_valid_xml
end
def test_line_items_are_valid_xml
- options = {:ordertype => 'SALE', :action => 'SUBMIT', :installments => 12, :startdate => 'immediate', :periodicity => 'monthly', :order_id => 1006,
+ options = {
+ :ordertype => 'SALE',
+ :action => 'SUBMIT',
+ :installments => 12,
+ :startdate => 'immediate',
+ :periodicity => 'monthly',
+ :order_id => 1006,
:billing_address => {
:address1 => '1313 lucky lane',
:city => 'Lost Angeles',
:state => 'CA',
:zip => '90210'
- },
- :line_items => [{:id => '123456', :description => 'Logo T-Shirt', :price =>
- '12.00', :quantity => '1', :options => [{:name => 'Color', :value =>
- 'Red'}, {:name => 'Size', :value => 'XL'}]},{:id => '111', :description => 'keychain', :price => '3.00', :quantity => '1'}]}
+ },
+ :line_items => [
+ {
+ :id => '123456',
+ :description => 'Logo T-Shirt',
+ :price => '12.00',
+ :quantity => '1',
+ :options => [
+ {
+ :name => 'Color',
+ :value => 'Red'},
+ {
+ :name => 'Size',
+ :value => 'XL'}
+ ]
+ },
+ {
+ :id => '111',
+ :description => 'keychain',
+ :price => '3.00',
+ :quantity => '1'
+ }
+ ]
+ }
assert data = @gateway.send(:post_data, @amount, @credit_card, options)
assert REXML::Document.new(data)
@@ -127,7 +161,9 @@ def test_declined_purchase_is_valid_xml
@gateway = LinkpointGateway.new(:login => 123123, :pem => 'PEM')
@gateway.send(
- :parameters, 1000, @credit_card, :ordertype => 'SALE', :order_id => 1005,
+ :parameters, 1000, @credit_card,
+ :ordertype => 'SALE',
+ :order_id => 1005,
:billing_address => {
:address1 => '1313 lucky lane',
:city => 'Lost Angeles',
diff --git a/test/unit/gateways/opp_test.rb b/test/unit/gateways/opp_test.rb
index 5b830c28faa..93d33190471 100644
--- a/test/unit/gateways/opp_test.rb
+++ b/test/unit/gateways/opp_test.rb
@@ -199,7 +199,7 @@ def failed_response(type, id, code='100.100.101')
OppMockResponse.new(400,
JSON.generate({'id' => id,'paymentType' => type,'paymentBrand' => 'VISA','result' => {'code' => code,"des
cription" => 'invalid creditcard, bank account number or bank name'},'card' => {'bin' => '444444','last4Digits' => '4444','holder' => 'Longbob Longsen','expiryMonth' => '05','expiryYear' => '2018'},
- 'buildNumber' => '20150618-111601.r185004.opp-tags-20150618_stage','timestamp' => '2015-06-20 20:40:26+0000','ndc' => '8a8294174b7ecb28014b9699220015ca_5200332e7d664412a84ed5f4777b3c7d'})
+ 'buildNumber' => '20150618-111601.r185004.opp-tags-20150618_stage','timestamp' => '2015-06-20 20:40:26+0000','ndc' => '8a8294174b7ecb28014b9699220015ca_5200332e7d664412a84ed5f4777b3c7d'})
)
end
diff --git a/test/unit/gateways/orbital_test.rb b/test/unit/gateways/orbital_test.rb
index 8bcffb2ccc5..b79fdac439e 100644
--- a/test/unit/gateways/orbital_test.rb
+++ b/test/unit/gateways/orbital_test.rb
@@ -242,7 +242,7 @@ def test_address_format
response = stub_comms do
@gateway.purchase(50, credit_card, :order_id => 1,
- :billing_address => address_with_invalid_chars)
+ :billing_address => address_with_invalid_chars)
end.check_request do |endpoint, data, headers|
assert_match(/456 Main Street, data)
assert_match(/Apt. Number One, data)
@@ -289,7 +289,7 @@ def test_truncates_by_byte_length
response = stub_comms do
@gateway.purchase(50, card, :order_id => 1,
- :billing_address => long_address)
+ :billing_address => long_address)
end.check_request do |endpoint, data, headers|
assert_match(/456 Stréêt Name is Really Lo, data)
assert_match(/Apårtmeñt 123456789012345678, data)
@@ -350,7 +350,7 @@ def test_dest_address
response = stub_comms do
@gateway.purchase(50, credit_card, :order_id => 1,
- :billing_address => billing_address)
+ :billing_address => billing_address)
end.check_request do |endpoint, data, headers|
assert_match(/90001/, data)
assert_match(/456 Main St./, data)
@@ -366,7 +366,7 @@ def test_dest_address
# non-AVS country
response = stub_comms do
@gateway.purchase(50, credit_card, :order_id => 1,
- :billing_address => billing_address.merge(:dest_country => 'BR'))
+ :billing_address => billing_address.merge(:dest_country => 'BR'))
end.check_request do |endpoint, data, headers|
assert_match(/, data)
end.respond_with(successful_purchase_response)
@@ -393,10 +393,12 @@ def test_managed_billing
response = stub_comms do
assert_deprecation_warning(Gateway::RECURRING_DEPRECATION_MESSAGE) do
assert_deprecation_warning do
- @gateway.add_customer_profile(credit_card, :managed_billing => {:start_date => '10-10-2014',
- :end_date => '10-10-2015',
- :max_dollar_value => 1500,
- :max_transactions => 12})
+ @gateway.add_customer_profile(credit_card,
+ :managed_billing => {
+ :start_date => '10-10-2014',
+ :end_date => '10-10-2015',
+ :max_dollar_value => 1500,
+ :max_transactions => 12})
end
end
end.check_request do |endpoint, data, headers|
diff --git a/test/unit/gateways/paypal/paypal_common_api_test.rb b/test/unit/gateways/paypal/paypal_common_api_test.rb
index 93ecc4ce2f2..5193e20846b 100644
--- a/test/unit/gateways/paypal/paypal_common_api_test.rb
+++ b/test/unit/gateways/paypal/paypal_common_api_test.rb
@@ -23,15 +23,16 @@ def setup
:pem => 'PEM'
)
- @address = { :address1 => '1234 My Street',
- :address2 => 'Apt 1',
- :company => 'Widgets Inc',
- :city => 'Ottawa',
- :state => 'ON',
- :zip => 'K1C2N6',
- :country => 'Canada',
- :phone => '(555)555-5555'
- }
+ @address = {
+ :address1 => '1234 My Street',
+ :address2 => 'Apt 1',
+ :company => 'Widgets Inc',
+ :city => 'Ottawa',
+ :state => 'ON',
+ :zip => 'K1C2N6',
+ :country => 'Canada',
+ :phone => '(555)555-5555'
+ }
end
def xml_builder
@@ -135,10 +136,12 @@ def test_transaction_search_requires
end
def test_build_transaction_search_request
- options = {:start_date => DateTime.new(2012, 2, 21, 0),
+ options = {
+ :start_date => DateTime.new(2012, 2, 21, 0),
:end_date => DateTime.new(2012, 3, 21, 0),
:receiver => 'foo@example.com',
- :first_name => 'Robert'}
+ :first_name => 'Robert'
+ }
request = REXML::Document.new(@gateway.send(:build_transaction_search, options))
assert_match %r{^2012-02-21T\d{2}:00:00Z$}, REXML::XPath.first(request, '//TransactionSearchReq/TransactionSearchRequest/StartDate').text
assert_match %r{^2012-03-21T\d{2}:00:00Z$}, REXML::XPath.first(request, '//TransactionSearchReq/TransactionSearchRequest/EndDate').text
diff --git a/test/unit/gateways/paypal_express_test.rb b/test/unit/gateways/paypal_express_test.rb
index c88f0291630..bed1c4be532 100644
--- a/test/unit/gateways/paypal_express_test.rb
+++ b/test/unit/gateways/paypal_express_test.rb
@@ -19,15 +19,16 @@ def setup
:pem => 'PEM'
)
- @address = { :address1 => '1234 My Street',
- :address2 => 'Apt 1',
- :company => 'Widgets Inc',
- :city => 'Ottawa',
- :state => 'ON',
- :zip => 'K1C2N6',
- :country => 'Canada',
- :phone => '(555)555-5555'
- }
+ @address = {
+ :address1 => '1234 My Street',
+ :address2 => 'Apt 1',
+ :company => 'Widgets Inc',
+ :city => 'Ottawa',
+ :state => 'ON',
+ :zip => 'K1C2N6',
+ :country => 'Canada',
+ :phone => '(555)555-5555'
+ }
Base.mode = :test
end
@@ -165,10 +166,24 @@ def test_does_not_include_items_if_not_specified
end
def test_items_are_included_if_specified_in_build_setup_request
- xml = REXML::Document.new(@gateway.send(:build_setup_request, 'SetExpressCheckout', 0, {:currency => 'GBP', :items => [
- {:name => 'item one', :description => 'item one description', :amount => 10000, :number => 1, :quantity => 3},
- {:name => 'item two', :description => 'item two description', :amount => 20000, :number => 2, :quantity => 4}
- ]}))
+ xml = REXML::Document.new(@gateway.send(:build_setup_request, 'SetExpressCheckout', 0, {
+ :currency => 'GBP',
+ :items => [
+ {
+ :name => 'item one',
+ :description => 'item one description',
+ :amount => 10000,
+ :number => 1,
+ :quantity => 3
+ },
+ { :name => 'item two',
+ :description => 'item two description',
+ :amount => 20000,
+ :number => 2,
+ :quantity => 4
+ }
+ ]
+ }))
assert_equal 'item one', REXML::XPath.first(xml, '//n2:PaymentDetails/n2:PaymentDetailsItem/n2:Name').text
assert_equal 'item one description', REXML::XPath.first(xml, '//n2:PaymentDetails/n2:PaymentDetailsItem/n2:Description').text
@@ -228,16 +243,22 @@ def test_does_not_include_flatrate_shipping_options_if_not_specified
end
def test_flatrate_shipping_options_are_included_if_specified_in_build_setup_request
- xml = REXML::Document.new(@gateway.send(:build_setup_request, 'SetExpressCheckout', 0, {:currency => 'AUD', :shipping_options => [
- {:default => true,
+ xml = REXML::Document.new(@gateway.send(:build_setup_request, 'SetExpressCheckout', 0,
+ {
+ :currency => 'AUD',
+ :shipping_options => [
+ {
+ :default => true,
:name => 'first one',
:amount => 1000
- },
- {:default => false,
- :name => 'second one',
- :amount => 2000
- }
- ]}))
+ },
+ {
+ :default => false,
+ :name => 'second one',
+ :amount => 2000
+ }
+ ]
+ }))
assert_equal 'true', REXML::XPath.first(xml, '//n2:FlatRateShippingOptions/n2:ShippingOptionIsDefault').text
assert_equal 'first one', REXML::XPath.first(xml, '//n2:FlatRateShippingOptions/n2:ShippingOptionName').text
@@ -251,14 +272,18 @@ def test_flatrate_shipping_options_are_included_if_specified_in_build_setup_requ
end
def test_address_is_included_if_specified
- xml = REXML::Document.new(@gateway.send(:build_setup_request, 'Sale', 0, {:currency => 'GBP', :address => {
- :name => 'John Doe',
- :address1 => '123 somewhere',
- :city => 'Townville',
- :country => 'Canada',
- :zip => 'k1l4p2',
- :phone => '1231231231'
- }}))
+ xml = REXML::Document.new(@gateway.send(:build_setup_request, 'Sale', 0,
+ {
+ :currency => 'GBP',
+ :address => {
+ :name => 'John Doe',
+ :address1 => '123 somewhere',
+ :city => 'Townville',
+ :country => 'Canada',
+ :zip => 'k1l4p2',
+ :phone => '1231231231'
+ }
+ }))
assert_equal 'John Doe', REXML::XPath.first(xml, '//n2:PaymentDetails/n2:ShipToAddress/n2:Name').text
assert_equal '123 somewhere', REXML::XPath.first(xml, '//n2:PaymentDetails/n2:ShipToAddress/n2:Street1').text
@@ -287,10 +312,30 @@ def test_removes_fractional_amounts_with_twd_currency
end
def test_fractional_discounts_are_correctly_calculated_with_jpy_currency
- xml = REXML::Document.new(@gateway.send(:build_setup_request, 'SetExpressCheckout', 14250, { :items =>
- [{:name => 'item one', :description => 'description', :amount => 15000, :number => 1, :quantity => 1},
- {:name => 'Discount', :description => 'Discount', :amount => -750, :number => 2, :quantity => 1}],
- :subtotal => 14250, :currency => 'JPY', :shipping => 0, :handling => 0, :tax => 0 }))
+ xml = REXML::Document.new(@gateway.send(:build_setup_request, 'SetExpressCheckout', 14250,
+ {
+ :items => [
+ {
+ :name => 'item one',
+ :description => 'description',
+ :amount => 15000,
+ :number => 1,
+ :quantity => 1
+ },
+ {
+ :name => 'Discount',
+ :description => 'Discount',
+ :amount => -750,
+ :number => 2,
+ :quantity => 1
+ }
+ ],
+ :subtotal => 14250,
+ :currency => 'JPY',
+ :shipping => 0,
+ :handling => 0,
+ :tax => 0
+ }))
assert_equal '142', REXML::XPath.first(xml, '//n2:OrderTotal').text
assert_equal '142', REXML::XPath.first(xml, '//n2:ItemTotal').text
@@ -300,10 +345,30 @@ def test_fractional_discounts_are_correctly_calculated_with_jpy_currency
end
def test_non_fractional_discounts_are_correctly_calculated_with_jpy_currency
- xml = REXML::Document.new(@gateway.send(:build_setup_request, 'SetExpressCheckout', 14300, { :items =>
- [{:name => 'item one', :description => 'description', :amount => 15000, :number => 1, :quantity => 1},
- {:name => 'Discount', :description => 'Discount', :amount => -700, :number => 2, :quantity => 1}],
- :subtotal => 14300, :currency => 'JPY', :shipping => 0, :handling => 0, :tax => 0 }))
+ xml = REXML::Document.new(@gateway.send(:build_setup_request, 'SetExpressCheckout', 14300,
+ {
+ :items => [
+ {
+ :name => 'item one',
+ :description => 'description',
+ :amount => 15000,
+ :number => 1,
+ :quantity => 1
+ },
+ {
+ :name => 'Discount',
+ :description => 'Discount',
+ :amount => -700,
+ :number => 2,
+ :quantity => 1
+ }
+ ],
+ :subtotal => 14300,
+ :currency => 'JPY',
+ :shipping => 0,
+ :handling => 0,
+ :tax => 0
+ }))
assert_equal '143', REXML::XPath.first(xml, '//n2:OrderTotal').text
assert_equal '143', REXML::XPath.first(xml, '//n2:ItemTotal').text
@@ -313,10 +378,30 @@ def test_non_fractional_discounts_are_correctly_calculated_with_jpy_currency
end
def test_fractional_discounts_are_correctly_calculated_with_usd_currency
- xml = REXML::Document.new(@gateway.send(:build_setup_request, 'SetExpressCheckout', 14250, { :items =>
- [{:name => 'item one', :description => 'description', :amount => 15000, :number => 1, :quantity => 1},
- {:name => 'Discount', :description => 'Discount', :amount => -750, :number => 2, :quantity => 1}],
- :subtotal => 14250, :currency => 'USD', :shipping => 0, :handling => 0, :tax => 0 }))
+ xml = REXML::Document.new(@gateway.send(:build_setup_request, 'SetExpressCheckout', 14250,
+ {
+ :items => [
+ {
+ :name => 'item one',
+ :description => 'description',
+ :amount => 15000,
+ :number => 1,
+ :quantity => 1
+ },
+ {
+ :name => 'Discount',
+ :description => 'Discount',
+ :amount => -750,
+ :number => 2,
+ :quantity => 1
+ }
+ ],
+ :subtotal => 14250,
+ :currency => 'USD',
+ :shipping => 0,
+ :handling => 0,
+ :tax => 0
+ }))
assert_equal '142.50', REXML::XPath.first(xml, '//n2:OrderTotal').text
assert_equal '142.50', REXML::XPath.first(xml, '//n2:ItemTotal').text
@@ -369,10 +454,25 @@ def test_button_source
end
def test_items_are_included_if_specified_in_build_sale_or_authorization_request
- xml = REXML::Document.new(@gateway.send(:build_sale_or_authorization_request, 'Sale', 100, {:items => [
- {:name => 'item one', :description => 'item one description', :amount => 10000, :number => 1, :quantity => 3},
- {:name => 'item two', :description => 'item two description', :amount => 20000, :number => 2, :quantity => 4}
- ]}))
+ xml = REXML::Document.new(@gateway.send(:build_sale_or_authorization_request, 'Sale', 100,
+ {
+ :items => [
+ {
+ :name => 'item one',
+ :description => 'item one description',
+ :amount => 10000,
+ :number => 1,
+ :quantity => 3
+ },
+ {
+ :name => 'item two',
+ :description => 'item two description',
+ :amount => 20000,
+ :number => 2,
+ :quantity => 4
+ }
+ ]
+ }))
assert_equal 'item one', REXML::XPath.first(xml, '//n2:PaymentDetails/n2:PaymentDetailsItem/n2:Name').text
assert_equal 'item one description', REXML::XPath.first(xml, '//n2:PaymentDetails/n2:PaymentDetailsItem/n2:Description').text
@@ -448,12 +548,14 @@ def test_agreement_details_failure
def test_build_reference_transaction_test
PaypalExpressGateway.application_id = 'ActiveMerchant_FOO'
- xml = REXML::Document.new(@gateway.send(:build_reference_transaction_request, 'Sale', 2000, {
- :reference_id => 'ref_id',
- :payment_type => 'Any',
- :invoice_id => 'invoice_id',
- :description => 'Description',
- :ip => '127.0.0.1' }))
+ xml = REXML::Document.new(@gateway.send(:build_reference_transaction_request, 'Sale', 2000,
+ {
+ :reference_id => 'ref_id',
+ :payment_type => 'Any',
+ :invoice_id => 'invoice_id',
+ :description => 'Description',
+ :ip => '127.0.0.1'
+ }))
assert_equal '124', REXML::XPath.first(xml, '//DoReferenceTransactionReq/DoReferenceTransactionRequest/n2:Version').text
assert_equal 'ref_id', REXML::XPath.first(xml, '//DoReferenceTransactionReq/DoReferenceTransactionRequest/n2:DoReferenceTransactionRequestDetails/n2:ReferenceID').text
@@ -475,12 +577,13 @@ def test_build_details_billing_agreement_request_test
def test_authorize_reference_transaction
@gateway.expects(:ssl_post).returns(successful_authorize_reference_transaction_response)
- response = @gateway.authorize_reference_transaction(2000, {
- :reference_id => 'ref_id',
- :payment_type => 'Any',
- :invoice_id => 'invoice_id',
- :description => 'Description',
- :ip => '127.0.0.1' })
+ response = @gateway.authorize_reference_transaction(2000,
+ {
+ :reference_id => 'ref_id',
+ :payment_type => 'Any',
+ :invoice_id => 'invoice_id',
+ :description => 'Description',
+ :ip => '127.0.0.1' })
assert_equal 'Success', response.params['ack']
assert_equal 'Success', response.message
@@ -598,27 +701,38 @@ def test_structure_correct
:handling => 0,
:tax => 5,
:total_type => 'EstimatedTotal',
- :items => [{:name => 'item one',
- :number => 'number 1',
- :quantity => 3,
- :amount => 35,
- :description => 'one description',
- :url => 'http://example.com/number_1'}],
- :address => {:name => 'John Doe',
- :address1 => 'Apartment 1',
- :address2 => '1 Road St',
- :city => 'First City',
- :state => 'NSW',
- :country => 'AU',
- :zip => '2000',
- :phone => '555 5555'},
+ :items => [
+ {
+ :name => 'item one',
+ :number => 'number 1',
+ :quantity => 3,
+ :amount => 35,
+ :description => 'one description',
+ :url => 'http://example.com/number_1'
+ }
+ ],
+ :address =>
+ {
+ :name => 'John Doe',
+ :address1 => 'Apartment 1',
+ :address2 => '1 Road St',
+ :city => 'First City',
+ :state => 'NSW',
+ :country => 'AU',
+ :zip => '2000',
+ :phone => '555 5555'
+ },
:callback_url => 'http://example.com/update_callback',
:callback_timeout => 2,
:callback_version => '53.0',
:funding_sources => {:source => 'BML'},
- :shipping_options => [{:default => true,
- :name => 'first one',
- :amount => 10}]
+ :shipping_options => [
+ {
+ :default => true,
+ :name => 'first one',
+ :amount => 10
+ }
+ ]
}
doc = Nokogiri::XML(@gateway.send(:build_setup_request, 'Sale', 10, all_options_enabled))
diff --git a/test/unit/gateways/quickpay_v10_test.rb b/test/unit/gateways/quickpay_v10_test.rb
index aac4bdb1e10..f2db1f727ec 100644
--- a/test/unit/gateways/quickpay_v10_test.rb
+++ b/test/unit/gateways/quickpay_v10_test.rb
@@ -182,9 +182,9 @@ def successful_authorization_response
'customer_ip' =>nil,
'customer_country' =>nil
},
- 'created_at' => '2015-03-30T16:56:17Z',
- 'balance' => 0,
- 'currency' => 'DKK'
+ 'created_at' => '2015-03-30T16:56:17Z',
+ 'balance' => 0,
+ 'currency' => 'DKK'
}.to_json
end
@@ -226,9 +226,9 @@ def succesful_refund_response
'customer_ip' =>nil,
'customer_country' =>nil
},
- 'created_at' =>'2015-03-30T16:56:17Z',
- 'balance' =>100,
- 'currency' =>'DKK'
+ 'created_at' =>'2015-03-30T16:56:17Z',
+ 'balance' =>100,
+ 'currency' =>'DKK'
}.to_json
end
diff --git a/test/unit/gateways/sage_pay_test.rb b/test/unit/gateways/sage_pay_test.rb
index da8ed24674b..034d563e448 100644
--- a/test/unit/gateways/sage_pay_test.rb
+++ b/test/unit/gateways/sage_pay_test.rb
@@ -223,8 +223,8 @@ def test_website_is_submitted
def test_FIxxxx_optional_fields_are_submitted
stub_comms(@gateway, :ssl_request) do
purchase_with_options(recipient_account_number: '1234567890',
- recipient_surname: 'Withnail', recipient_postcode: 'AB11AB',
- recipient_dob: '19701223')
+ recipient_surname: 'Withnail', recipient_postcode: 'AB11AB',
+ recipient_dob: '19701223')
end.check_request do |method, endpoint, data, headers|
assert_match(/FIRecipientAcctNumber=1234567890/, data)
assert_match(/FIRecipientSurname=Withnail/, data)
From bda5ba22360d9505587406193102396c1847b578 Mon Sep 17 00:00:00 2001
From: dtykocki
Date: Thu, 11 Oct 2018 15:15:55 -0400
Subject: [PATCH 0105/2234] Beanstream: Switch `recurringPayment` flag from
boolean to integer
Remote:
42 tests, 189 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
95.2381% passed
Unit:
23 tests, 108 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/beanstream/beanstream_core.rb | 2 +-
test/remote/gateways/remote_beanstream_test.rb | 8 +++++++-
test/unit/gateways/beanstream_test.rb | 4 ++--
4 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 471a6603a47..029ce1e6d0d 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -5,6 +5,7 @@
* Global Collect: handle internal server errors [molbrown] [#3005]
* Barclaycard Smartpay: allow third-party payouts for credits [bpollack] #3009
* RuboCop: AlignHash [nfarve] #3004
+* Beanstream: Switch `recurringPayment` flag from boolean to integer [dtykocki] #3011
== Version 1.85.0 (September 28, 2018)
* Authorize.Net: Support custom delimiter for cim [curiousepic] [#3001]
diff --git a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb
index 2800effb333..bbc548de702 100644
--- a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb
+++ b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb
@@ -266,7 +266,7 @@ def prepare_address_for_non_american_countries(options)
end
def add_recurring_payment(post, options)
- post[:recurringPayment] = true if options[:recurring].to_s == 'true'
+ post[:recurringPayment] = 1 if options[:recurring].to_s == 'true'
end
def add_invoice(post, options)
diff --git a/test/remote/gateways/remote_beanstream_test.rb b/test/remote/gateways/remote_beanstream_test.rb
index 67abd08ff7d..7041bd6ca9a 100644
--- a/test/remote/gateways/remote_beanstream_test.rb
+++ b/test/remote/gateways/remote_beanstream_test.rb
@@ -79,12 +79,18 @@ def test_successful_visa_purchase_with_recurring
end
def test_successful_visa_purchase_no_cvv
- assert response = @gateway.purchase(@amount, @visa_no_cvv, @options)
+ assert response = @gateway.purchase(@amount, @visa_no_cvv, @options.merge(recurring: true))
assert_success response
assert_false response.authorization.blank?
assert_equal 'Approved', response.message
end
+ def test_unsuccessful_visa_purchase_with_no_cvv
+ assert response = @gateway.purchase(@amount, @visa_no_cvv, @options)
+ assert_failure response
+ assert_equal 'Card CVD is invalid.', response.message
+ end
+
def test_unsuccessful_visa_purchase
assert response = @gateway.purchase(@amount, @declined_visa, @options)
assert_failure response
diff --git a/test/unit/gateways/beanstream_test.rb b/test/unit/gateways/beanstream_test.rb
index a140fed4317..985748dfd03 100644
--- a/test/unit/gateways/beanstream_test.rb
+++ b/test/unit/gateways/beanstream_test.rb
@@ -72,7 +72,7 @@ def test_successful_purchase_with_recurring
response = stub_comms(@gateway, :ssl_request) do
@gateway.purchase(@amount, @decrypted_credit_card, @options.merge(recurring: true))
end.check_request do |method, endpoint, data, headers|
- assert_match(/recurringPayment=true/, data)
+ assert_match(/recurringPayment=1/, data)
end.respond_with(successful_purchase_response)
assert_success response
@@ -82,7 +82,7 @@ def test_successful_authorize_with_recurring
response = stub_comms(@gateway, :ssl_request) do
@gateway.authorize(@amount, @decrypted_credit_card, @options.merge(recurring: true))
end.check_request do |method, endpoint, data, headers|
- assert_match(/recurringPayment=true/, data)
+ assert_match(/recurringPayment=1/, data)
end.respond_with(successful_purchase_response)
assert_success response
From 1c637d26080a86ddc8dc890b1ac67cf640fc78d2 Mon Sep 17 00:00:00 2001
From: Bart de Water
Date: Sat, 13 Oct 2018 20:19:20 -0400
Subject: [PATCH 0106/2234] Update Swipe HQ endpoints
---
.../billing/gateways/swipe_checkout.rb | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/swipe_checkout.rb b/lib/active_merchant/billing/gateways/swipe_checkout.rb
index 802a033188f..ea0bbc3b925 100644
--- a/lib/active_merchant/billing/gateways/swipe_checkout.rb
+++ b/lib/active_merchant/billing/gateways/swipe_checkout.rb
@@ -6,10 +6,7 @@ class SwipeCheckoutGateway < Gateway
TRANSACTION_APPROVED_MSG = 'Transaction approved'
TRANSACTION_DECLINED_MSG = 'Transaction declined'
- LIVE_URLS = {
- 'NZ' => 'https://api.swipehq.com',
- 'CA' => 'https://api.swipehq.ca'
- }
+ self.live_url = 'https://api.swipehq.com'
self.test_url = 'https://api.swipehq.com'
TRANSACTION_API = '/createShopifyTransaction.php'
@@ -135,11 +132,11 @@ def call_api(api, params=nil)
# ssl_post() returns the response body as a string on success,
# or raises a ResponseError exception on failure
- JSON.parse(ssl_post(url(@options[:region], api), params.to_query))
+ JSON.parse(ssl_post(url(api), params.to_query))
end
- def url(region, api)
- ((test? ? self.test_url : LIVE_URLS[region]) + api)
+ def url(api)
+ (test? ? self.test_url : self.live_url) + api
end
def build_error_response(message, params={})
From eab1096504695b9e529feb082fb1eb244f873541 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Mon, 15 Oct 2018 16:20:06 -0400
Subject: [PATCH 0107/2234] RuboCop: fix Layout/DotPosition
This is dramatically the smaller of the two possibilties.
trailing: 10 files changed, 43 insertions(+), 43 deletions(-)
leading: 127 files changed, 699 insertions(+), 699 deletions(-)
---
.rubocop.yml | 4 +++-
.rubocop_todo.yml | 7 -------
lib/active_merchant/billing/gateways/card_connect.rb | 12 ++++++------
lib/active_merchant/billing/gateways/cardprocess.rb | 8 ++++----
lib/active_merchant/billing/gateways/cashnet.rb | 8 ++++----
lib/active_merchant/billing/gateways/firstdata_e4.rb | 12 ++++++------
.../billing/gateways/firstdata_e4_v27.rb | 12 ++++++------
lib/active_merchant/billing/gateways/migs.rb | 10 +++++-----
lib/active_merchant/billing/gateways/mundipagg.rb | 8 ++++----
lib/active_merchant/billing/gateways/paymentez.rb | 8 ++++----
lib/active_merchant/billing/gateways/world_net.rb | 6 +++---
11 files changed, 45 insertions(+), 50 deletions(-)
diff --git a/.rubocop.yml b/.rubocop.yml
index e4141aba185..d101dfec1a3 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -24,6 +24,8 @@ Metrics/ClassLength:
Metrics/ModuleLength:
Enabled: false
-
Layout/AlignParameters:
EnforcedStyle: with_fixed_indentation
+
+Layout/DotPosition:
+ EnforcedStyle: trailing
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 3e0bb88d4c3..cf878044205 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -26,13 +26,6 @@ Layout/CaseIndentation:
Layout/ClosingHeredocIndentation:
Enabled: false
-# Offense count: 513
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle.
-# SupportedStyles: leading, trailing
-Layout/DotPosition:
- Enabled: false
-
# Offense count: 24
# Cop supports --auto-correct.
Layout/ElseAlignment:
diff --git a/lib/active_merchant/billing/gateways/card_connect.rb b/lib/active_merchant/billing/gateways/card_connect.rb
index 6c4e8064c55..c4630cf0697 100644
--- a/lib/active_merchant/billing/gateways/card_connect.rb
+++ b/lib/active_merchant/billing/gateways/card_connect.rb
@@ -150,12 +150,12 @@ def supports_scrubbing?
end
def scrub(transcript)
- transcript
- .gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]')
- .gsub(%r(("cvv2\\":\\")\d*), '\1[FILTERED]')
- .gsub(%r(("merchid\\":\\")\d*), '\1[FILTERED]')
- .gsub(%r((&?"account\\":\\")\d*), '\1[FILTERED]')
- .gsub(%r((&?"token\\":\\")\d*), '\1[FILTERED]')
+ transcript.
+ gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
+ gsub(%r(("cvv2\\":\\")\d*), '\1[FILTERED]').
+ gsub(%r(("merchid\\":\\")\d*), '\1[FILTERED]').
+ gsub(%r((&?"account\\":\\")\d*), '\1[FILTERED]').
+ gsub(%r((&?"token\\":\\")\d*), '\1[FILTERED]')
end
private
diff --git a/lib/active_merchant/billing/gateways/cardprocess.rb b/lib/active_merchant/billing/gateways/cardprocess.rb
index 020a39ec17f..42824ccf952 100644
--- a/lib/active_merchant/billing/gateways/cardprocess.rb
+++ b/lib/active_merchant/billing/gateways/cardprocess.rb
@@ -99,10 +99,10 @@ def supports_scrubbing?
end
def scrub(transcript)
- transcript
- .gsub(%r{(authentication\.[^=]+=)[^&]+}, '\1[FILTERED]')
- .gsub(%r{(card\.number=)\d+}, '\1[FILTERED]')
- .gsub(%r{(cvv=)\d{3,4}}, '\1[FILTERED]\2')
+ transcript.
+ gsub(%r{(authentication\.[^=]+=)[^&]+}, '\1[FILTERED]').
+ gsub(%r{(card\.number=)\d+}, '\1[FILTERED]').
+ gsub(%r{(cvv=)\d{3,4}}, '\1[FILTERED]\2')
end
private
diff --git a/lib/active_merchant/billing/gateways/cashnet.rb b/lib/active_merchant/billing/gateways/cashnet.rb
index f3ae7dc87f5..9632d273383 100644
--- a/lib/active_merchant/billing/gateways/cashnet.rb
+++ b/lib/active_merchant/billing/gateways/cashnet.rb
@@ -60,10 +60,10 @@ def supports_scrubbing?
end
def scrub(transcript)
- transcript
- .gsub(%r{(password=)[^&]+}, '\1[FILTERED]')
- .gsub(%r{(cardno=)[^&]+}, '\1[FILTERED]')
- .gsub(%r{(cid=)[^&]+}, '\1[FILTERED]')
+ transcript.
+ gsub(%r{(password=)[^&]+}, '\1[FILTERED]').
+ gsub(%r{(cardno=)[^&]+}, '\1[FILTERED]').
+ gsub(%r{(cid=)[^&]+}, '\1[FILTERED]')
end
private
diff --git a/lib/active_merchant/billing/gateways/firstdata_e4.rb b/lib/active_merchant/billing/gateways/firstdata_e4.rb
index b18bbfb1294..803f0c0a591 100755
--- a/lib/active_merchant/billing/gateways/firstdata_e4.rb
+++ b/lib/active_merchant/billing/gateways/firstdata_e4.rb
@@ -141,12 +141,12 @@ def supports_scrubbing?
end
def scrub(transcript)
- transcript
- .gsub(%r(().+()), '\1[FILTERED]\2')
- .gsub(%r(().+()), '\1[FILTERED]\2')
- .gsub(%r(().+())i, '\1[FILTERED]\2')
- .gsub(%r(().+()), '\1[FILTERED]\2')
- .gsub(%r((Card Number : ).*\d)i, '\1[FILTERED]')
+ transcript.
+ gsub(%r(().+()), '\1[FILTERED]\2').
+ gsub(%r(().+()), '\1[FILTERED]\2').
+ gsub(%r(().+())i, '\1[FILTERED]\2').
+ gsub(%r(().+()), '\1[FILTERED]\2').
+ gsub(%r((Card Number : ).*\d)i, '\1[FILTERED]')
end
def supports_network_tokenization?
diff --git a/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb b/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb
index 7f5fde83f3e..31c16f7d1e5 100644
--- a/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb
+++ b/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb
@@ -112,12 +112,12 @@ def supports_scrubbing?
end
def scrub(transcript)
- transcript
- .gsub(%r(().+()), '\1[FILTERED]\2')
- .gsub(%r(().+()), '\1[FILTERED]\2')
- .gsub(%r(().+())i, '\1[FILTERED]\2')
- .gsub(%r(().+()), '\1[FILTERED]\2')
- .gsub(%r((CARD NUMBER\s+: )#+\d+), '\1[FILTERED]')
+ transcript.
+ gsub(%r(().+()), '\1[FILTERED]\2').
+ gsub(%r(().+()), '\1[FILTERED]\2').
+ gsub(%r(().+())i, '\1[FILTERED]\2').
+ gsub(%r(().+()), '\1[FILTERED]\2').
+ gsub(%r((CARD NUMBER\s+: )#+\d+), '\1[FILTERED]')
end
def supports_network_tokenization?
diff --git a/lib/active_merchant/billing/gateways/migs.rb b/lib/active_merchant/billing/gateways/migs.rb
index d0fa0d72411..27c13eee3b6 100644
--- a/lib/active_merchant/billing/gateways/migs.rb
+++ b/lib/active_merchant/billing/gateways/migs.rb
@@ -314,11 +314,11 @@ def add_secure_hash(post)
end
def calculate_secure_hash(post, secure_hash)
- input = post
- .reject { |k| %i[SecureHash SecureHashType].include?(k) }
- .sort
- .map { |(k, v)| "vpc_#{k}=#{v}" }
- .join('&')
+ input = post.
+ reject { |k| %i[SecureHash SecureHashType].include?(k) }.
+ sort.
+ map { |(k, v)| "vpc_#{k}=#{v}" }.
+ join('&')
OpenSSL::HMAC.hexdigest('SHA256', [secure_hash].pack('H*'), input).upcase
end
end
diff --git a/lib/active_merchant/billing/gateways/mundipagg.rb b/lib/active_merchant/billing/gateways/mundipagg.rb
index fc8b10982e2..fa9c882c6d2 100644
--- a/lib/active_merchant/billing/gateways/mundipagg.rb
+++ b/lib/active_merchant/billing/gateways/mundipagg.rb
@@ -89,10 +89,10 @@ def supports_scrubbing?
end
def scrub(transcript)
- transcript
- .gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]')
- .gsub(%r(("cvv\\":\\")\d*), '\1[FILTERED]')
- .gsub(%r((card\\":{\\"number\\":\\")\d*), '\1[FILTERED]')
+ transcript.
+ gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
+ gsub(%r(("cvv\\":\\")\d*), '\1[FILTERED]').
+ gsub(%r((card\\":{\\"number\\":\\")\d*), '\1[FILTERED]')
end
private
diff --git a/lib/active_merchant/billing/gateways/paymentez.rb b/lib/active_merchant/billing/gateways/paymentez.rb
index db72d1da65e..af73e15b31c 100644
--- a/lib/active_merchant/billing/gateways/paymentez.rb
+++ b/lib/active_merchant/billing/gateways/paymentez.rb
@@ -119,10 +119,10 @@ def supports_scrubbing?
end
def scrub(transcript)
- transcript
- .gsub(%r{(\\?"number\\?":)(\\?"[^"]+\\?")}, '\1[FILTERED]')
- .gsub(%r{(\\?"cvc\\?":)(\\?"[^"]+\\?")}, '\1[FILTERED]')
- .gsub(%r{(Auth-Token: )([A-Za-z0-9=]+)}, '\1[FILTERED]')
+ transcript.
+ gsub(%r{(\\?"number\\?":)(\\?"[^"]+\\?")}, '\1[FILTERED]').
+ gsub(%r{(\\?"cvc\\?":)(\\?"[^"]+\\?")}, '\1[FILTERED]').
+ gsub(%r{(Auth-Token: )([A-Za-z0-9=]+)}, '\1[FILTERED]')
end
private
diff --git a/lib/active_merchant/billing/gateways/world_net.rb b/lib/active_merchant/billing/gateways/world_net.rb
index fc7eb38f9fc..70699b1a139 100644
--- a/lib/active_merchant/billing/gateways/world_net.rb
+++ b/lib/active_merchant/billing/gateways/world_net.rb
@@ -113,9 +113,9 @@ def supports_scrubbing?
end
def scrub(transcript)
- transcript
- .gsub(%r{(\d{6})\d+(\d{4})}, '\1...\2')
- .gsub(%r{()\d+(\d{6})\d+(\d{4})}, '\1...\2').
+ gsub(%r{()\d+(
Date: Tue, 16 Oct 2018 13:56:15 -0400
Subject: [PATCH 0108/2234] RuboCop: fix Layout/LeadingBlankLines
---
.rubocop_todo.yml | 7 -------
.../billing/gateways/quickpay/quickpay_common.rb | 1 -
test/unit/gateways/quickpay_test.rb | 1 -
3 files changed, 9 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index cf878044205..7d14df1557a 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -110,13 +110,6 @@ Layout/IndentationConsistency:
Layout/IndentationWidth:
Enabled: false
-# Offense count: 2
-# Cop supports --auto-correct.
-Layout/LeadingBlankLines:
- Exclude:
- - 'lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb'
- - 'test/unit/gateways/quickpay_test.rb'
-
# Offense count: 68
# Cop supports --auto-correct.
Layout/LeadingCommentSpace:
diff --git a/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb b/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb
index 43545c02294..904c03d8c26 100644
--- a/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb
+++ b/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb
@@ -1,4 +1,3 @@
-
module QuickpayCommon
MD5_CHECK_FIELDS = {
3 => {
diff --git a/test/unit/gateways/quickpay_test.rb b/test/unit/gateways/quickpay_test.rb
index 4eb99dcf7ed..3ce28fd9070 100644
--- a/test/unit/gateways/quickpay_test.rb
+++ b/test/unit/gateways/quickpay_test.rb
@@ -1,4 +1,3 @@
-
require 'test_helper'
class QuickpayTest < Test::Unit::TestCase
From c31b131503caffb92795c8446a0922eba10a9118 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 18 Oct 2018 13:39:04 -0400
Subject: [PATCH 0109/2234] RuboCop: fix Layout/IndentArray
---
.rubocop_todo.yml | 12 --------
.../billing/gateways/firstdata_e4.rb | 2 +-
test/remote/gateways/remote_linkpoint_test.rb | 10 ++++---
test/unit/gateways/paypal_express_test.rb | 28 +++++++++----------
4 files changed, 21 insertions(+), 31 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 7d14df1557a..d9f84e9857a 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -71,18 +71,6 @@ Layout/ExtraSpacing:
Layout/FirstParameterIndentation:
Enabled: false
-# Offense count: 13
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle, IndentationWidth.
-# SupportedStyles: special_inside_parentheses, consistent, align_brackets
-Layout/IndentArray:
- Exclude:
- - 'lib/active_merchant/billing/gateways/firstdata_e4.rb'
- - 'test/remote/gateways/remote_linkpoint_test.rb'
- - 'test/remote/gateways/remote_payflow_express_test.rb'
- - 'test/unit/gateways/cyber_source_test.rb'
- - 'test/unit/gateways/paypal_express_test.rb'
-
# Offense count: 253
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth.
diff --git a/lib/active_merchant/billing/gateways/firstdata_e4.rb b/lib/active_merchant/billing/gateways/firstdata_e4.rb
index 803f0c0a591..fa5781da07c 100755
--- a/lib/active_merchant/billing/gateways/firstdata_e4.rb
+++ b/lib/active_merchant/billing/gateways/firstdata_e4.rb
@@ -394,7 +394,7 @@ def store_authorization_from(response, credit_card)
credit_card.last_name,
credit_card.month,
credit_card.year
- ].map { |value| value.to_s.gsub(/;/, '') }.join(';')
+ ].map { |value| value.to_s.gsub(/;/, '') }.join(';')
else
raise StandardError, "TransArmor support is not enabled on your #{display_name} account"
end
diff --git a/test/remote/gateways/remote_linkpoint_test.rb b/test/remote/gateways/remote_linkpoint_test.rb
index 3b2e78e9fb6..722b17d6ef7 100644
--- a/test/remote/gateways/remote_linkpoint_test.rb
+++ b/test/remote/gateways/remote_linkpoint_test.rb
@@ -90,10 +90,12 @@ def test_successfull_purchase_and_credit
end
def test_successfull_purchase_with_item_entity
- @options.merge!({:line_items => [
- {:id => '123456', :description => 'Logo T-Shirt', :price => '12.00', :quantity => '1', :options =>
- [{:name => 'Color', :value => 'Red'}, {:name => 'Size', :value => 'XL'}]},
- {:id => '111', :description => 'keychain', :price => '3.00', :quantity => '1'}]})
+ @options.merge!({:line_items =>
+ [
+ {:id => '123456', :description => 'Logo T-Shirt', :price => '12.00', :quantity => '1',
+ :options => [{:name => 'Color', :value => 'Red'}, {:name => 'Size', :value => 'XL'}]},
+ {:id => '111', :description => 'keychain', :price => '3.00', :quantity => '1'}
+ ]})
assert purchase = @gateway.purchase(1500, @credit_card, @options)
assert_success purchase
end
diff --git a/test/unit/gateways/paypal_express_test.rb b/test/unit/gateways/paypal_express_test.rb
index bed1c4be532..6bd01c9eb93 100644
--- a/test/unit/gateways/paypal_express_test.rb
+++ b/test/unit/gateways/paypal_express_test.rb
@@ -169,20 +169,20 @@ def test_items_are_included_if_specified_in_build_setup_request
xml = REXML::Document.new(@gateway.send(:build_setup_request, 'SetExpressCheckout', 0, {
:currency => 'GBP',
:items => [
- {
- :name => 'item one',
- :description => 'item one description',
- :amount => 10000,
- :number => 1,
- :quantity => 3
- },
- { :name => 'item two',
- :description => 'item two description',
- :amount => 20000,
- :number => 2,
- :quantity => 4
- }
- ]
+ {
+ :name => 'item one',
+ :description => 'item one description',
+ :amount => 10000,
+ :number => 1,
+ :quantity => 3
+ },
+ { :name => 'item two',
+ :description => 'item two description',
+ :amount => 20000,
+ :number => 2,
+ :quantity => 4
+ }
+ ]
}))
assert_equal 'item one', REXML::XPath.first(xml, '//n2:PaymentDetails/n2:PaymentDetailsItem/n2:Name').text
From c95a15ea7a91e4771937e5998ba4b711f7293200 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 18 Oct 2018 13:46:53 -0400
Subject: [PATCH 0110/2234] RuboCop: fix Layout/SpaceBeforeFirstArg
---
.rubocop_todo.yml | 15 ---------------
lib/active_merchant/billing/gateways/checkout.rb | 16 ++++++++--------
.../billing/gateways/cyber_source.rb | 2 +-
lib/active_merchant/billing/gateways/s5.rb | 2 +-
.../gateways/remote_braintree_orange_test.rb | 2 +-
test/remote/gateways/remote_payflow_test.rb | 2 +-
test/unit/gateways/bogus_test.rb | 10 +++++-----
test/unit/gateways/instapay_test.rb | 4 ++--
test/unit/gateways/quickpay_v10_test.rb | 2 +-
test/unit/gateways/quickpay_v4to7_test.rb | 2 +-
10 files changed, 21 insertions(+), 36 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index d9f84e9857a..5bc923d347c 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -210,21 +210,6 @@ Layout/SpaceBeforeComment:
Exclude:
- 'test/remote/gateways/remote_usa_epay_advanced_test.rb'
-# Offense count: 16
-# Cop supports --auto-correct.
-# Configuration parameters: AllowForAlignment.
-Layout/SpaceBeforeFirstArg:
- Exclude:
- - 'lib/active_merchant/billing/gateways/checkout.rb'
- - 'lib/active_merchant/billing/gateways/cyber_source.rb'
- - 'lib/active_merchant/billing/gateways/s5.rb'
- - 'test/remote/gateways/remote_braintree_orange_test.rb'
- - 'test/remote/gateways/remote_payflow_test.rb'
- - 'test/unit/gateways/bogus_test.rb'
- - 'test/unit/gateways/instapay_test.rb'
- - 'test/unit/gateways/quickpay_v10_test.rb'
- - 'test/unit/gateways/quickpay_v4to7_test.rb'
-
# Offense count: 118
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets.
diff --git a/lib/active_merchant/billing/gateways/checkout.rb b/lib/active_merchant/billing/gateways/checkout.rb
index 51cf3919292..cd6692a37d8 100644
--- a/lib/active_merchant/billing/gateways/checkout.rb
+++ b/lib/active_merchant/billing/gateways/checkout.rb
@@ -125,13 +125,13 @@ def add_billing_info(xml, options)
def add_shipping_info(xml, options)
if options[:shipping_address]
- xml.ship_address_ options[:shipping_address][:address1]
- xml.ship_address2_ options[:shipping_address][:address2]
- xml.ship_city_ options[:shipping_address][:city]
- xml.ship_state_ options[:shipping_address][:state]
- xml.ship_postal_ options[:shipping_address][:zip]
- xml.ship_country_ options[:shipping_address][:country]
- xml.ship_phone_ options[:shipping_address][:phone]
+ xml.ship_address_ options[:shipping_address][:address1]
+ xml.ship_address2_ options[:shipping_address][:address2]
+ xml.ship_city_ options[:shipping_address][:city]
+ xml.ship_state_ options[:shipping_address][:state]
+ xml.ship_postal_ options[:shipping_address][:zip]
+ xml.ship_country_ options[:shipping_address][:country]
+ xml.ship_phone_ options[:shipping_address][:phone]
end
end
@@ -144,7 +144,7 @@ def add_user_defined_fields(xml, options)
end
def add_other_fields(xml, options)
- xml.bill_email_ options[:email]
+ xml.bill_email_ options[:email]
xml.bill_customerip_ options[:ip]
xml.merchantcustomerid_ options[:customer]
xml.descriptor_name options[:descriptor_name]
diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb
index 190094e838a..77c4dc03630 100644
--- a/lib/active_merchant/billing/gateways/cyber_source.rb
+++ b/lib/active_merchant/billing/gateways/cyber_source.rb
@@ -663,7 +663,7 @@ def add_payment_method_or_subscription(xml, money, payment_method_or_reference,
end
def add_validate_pinless_debit_service(xml)
- xml.tag!'pinlessDebitValidateService', {'run' => 'true'}
+ xml.tag! 'pinlessDebitValidateService', {'run' => 'true'}
end
def add_threeds_services(xml, options)
diff --git a/lib/active_merchant/billing/gateways/s5.rb b/lib/active_merchant/billing/gateways/s5.rb
index 2be4007ba63..9f36a91e54e 100644
--- a/lib/active_merchant/billing/gateways/s5.rb
+++ b/lib/active_merchant/billing/gateways/s5.rb
@@ -136,7 +136,7 @@ def add_account(xml, payment_method)
xml.Holder "#{payment_method.first_name} #{payment_method.last_name}"
xml.Brand payment_method.brand
xml.Expiry(year: payment_method.year, month: payment_method.month)
- xml.Verification payment_method.verification_value
+ xml.Verification payment_method.verification_value
end
end
end
diff --git a/test/remote/gateways/remote_braintree_orange_test.rb b/test/remote/gateways/remote_braintree_orange_test.rb
index 6f6fb6bd842..4f2b3f171f3 100644
--- a/test/remote/gateways/remote_braintree_orange_test.rb
+++ b/test/remote/gateways/remote_braintree_orange_test.rb
@@ -139,7 +139,7 @@ def test_authorize_and_void
def test_failed_capture
assert response = @gateway.capture(@amount, '')
assert_failure response
- assert response.message.match(/Invalid Transaction ID \/ Object ID specified:/)
+ assert response.message.match(/Invalid Transaction ID \/ Object ID specified:/)
end
def test_authorize_with_three_d_secure_pass_thru
diff --git a/test/remote/gateways/remote_payflow_test.rb b/test/remote/gateways/remote_payflow_test.rb
index 1ec03b627a2..6104f8e45bd 100644
--- a/test/remote/gateways/remote_payflow_test.rb
+++ b/test/remote/gateways/remote_payflow_test.rb
@@ -213,7 +213,7 @@ def test_duplicate_request_id
SecureRandom.expects(:hex).times(2).returns(request_id)
response1 = @gateway.purchase(100, @credit_card, @options)
- assert response1.success?
+ assert response1.success?
assert_nil response1.params['duplicate']
response2 = @gateway.purchase(100, @credit_card, @options)
diff --git a/test/unit/gateways/bogus_test.rb b/test/unit/gateways/bogus_test.rb
index ddd8a1dcd31..e6978d828e1 100644
--- a/test/unit/gateways/bogus_test.rb
+++ b/test/unit/gateways/bogus_test.rb
@@ -18,7 +18,7 @@ def setup
end
def test_authorize
- assert @gateway.authorize(1000, credit_card(CC_SUCCESS_PLACEHOLDER)).success?
+ assert @gateway.authorize(1000, credit_card(CC_SUCCESS_PLACEHOLDER)).success?
response = @gateway.authorize(1000, credit_card(CC_FAILURE_PLACEHOLDER))
refute response.success?
assert_equal Gateway::STANDARD_ERROR_CODE[:processing_error], response.error_code
@@ -34,7 +34,7 @@ def test_authorize_using_credit_card_token
end
def test_purchase
- assert @gateway.purchase(1000, credit_card(CC_SUCCESS_PLACEHOLDER)).success?
+ assert @gateway.purchase(1000, credit_card(CC_SUCCESS_PLACEHOLDER)).success?
response = @gateway.purchase(1000, credit_card(CC_FAILURE_PLACEHOLDER))
refute response.success?
assert_equal Gateway::STANDARD_ERROR_CODE[:processing_error], response.error_code
@@ -56,7 +56,7 @@ def test_capture
end
def test_credit
- assert @gateway.credit(1000, credit_card(CC_SUCCESS_PLACEHOLDER)).success?
+ assert @gateway.credit(1000, credit_card(CC_SUCCESS_PLACEHOLDER)).success?
response = @gateway.credit(1000, credit_card(CC_FAILURE_PLACEHOLDER))
refute response.success?
assert_equal Gateway::STANDARD_ERROR_CODE[:processing_error], response.error_code
@@ -97,7 +97,7 @@ def test_void
end
def test_store
- assert @gateway.store(credit_card(CC_SUCCESS_PLACEHOLDER)).success?
+ assert @gateway.store(credit_card(CC_SUCCESS_PLACEHOLDER)).success?
response = @gateway.store(credit_card(CC_FAILURE_PLACEHOLDER))
refute response.success?
assert_equal Gateway::STANDARD_ERROR_CODE[:processing_error], response.error_code
@@ -184,7 +184,7 @@ def test_authorize_emv
end
def test_purchase_emv
- assert @gateway.purchase(1000, credit_card('123', {icc_data: 'DEADBEEF'})).success?
+ assert @gateway.purchase(1000, credit_card('123', {icc_data: 'DEADBEEF'})).success?
response = @gateway.purchase(1005, credit_card('123', {icc_data: 'DEADBEEF'}))
refute response.success?
assert_equal Gateway::STANDARD_ERROR_CODE[:processing_error], response.error_code
diff --git a/test/unit/gateways/instapay_test.rb b/test/unit/gateways/instapay_test.rb
index 2f8af425809..acd35d3027b 100644
--- a/test/unit/gateways/instapay_test.rb
+++ b/test/unit/gateways/instapay_test.rb
@@ -11,7 +11,7 @@ def test_successful_purchase
@gateway.expects(:ssl_post).returns(successful_purchase_response)
assert response = @gateway.purchase(@amount, @credit_card)
- assert_instance_of Response, response
+ assert_instance_of Response, response
assert_success response
assert_equal '118583850', response.authorization
end
@@ -29,7 +29,7 @@ def test_successful_auth
@gateway.expects(:ssl_post).returns(successful_purchase_response)
assert response = @gateway.authorize(@amount, @credit_card)
- assert_instance_of Response, response
+ assert_instance_of Response, response
assert_success response
assert_equal '118583850', response.authorization
end
diff --git a/test/unit/gateways/quickpay_v10_test.rb b/test/unit/gateways/quickpay_v10_test.rb
index f2db1f727ec..8a5404a3207 100644
--- a/test/unit/gateways/quickpay_v10_test.rb
+++ b/test/unit/gateways/quickpay_v10_test.rb
@@ -129,7 +129,7 @@ def test_supported_countries
def test_supported_card_types
klass = @gateway.class
- assert_equal [:dankort, :forbrugsforeningen, :visa, :master, :american_express, :diners_club, :jcb, :maestro ], klass.supported_cardtypes
+ assert_equal [:dankort, :forbrugsforeningen, :visa, :master, :american_express, :diners_club, :jcb, :maestro ], klass.supported_cardtypes
end
def test_successful_capture
diff --git a/test/unit/gateways/quickpay_v4to7_test.rb b/test/unit/gateways/quickpay_v4to7_test.rb
index e666efbadb3..a01c4b5315c 100644
--- a/test/unit/gateways/quickpay_v4to7_test.rb
+++ b/test/unit/gateways/quickpay_v4to7_test.rb
@@ -129,7 +129,7 @@ def test_supported_countries
def test_supported_card_types
klass = @gateway.class
- assert_equal [ :dankort, :forbrugsforeningen, :visa, :master, :american_express, :diners_club, :jcb, :maestro ], klass.supported_cardtypes
+ assert_equal [ :dankort, :forbrugsforeningen, :visa, :master, :american_express, :diners_club, :jcb, :maestro ], klass.supported_cardtypes
end
def test_add_testmode_does_not_add_testmode_if_transaction_id_present
From b373b445c890696c291256e9c1e2635ecd02076f Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 18 Oct 2018 13:52:15 -0400
Subject: [PATCH 0111/2234] RuboCop: fix Layout/SpaceBeforeComma
Some of this was undoing attempted alignment in net_registry.rb,
but the keyword there is "attempted"; it didn't line up before this
patch, and fixing it would've had higher churn. Everything else seemed
like straight-up typos.
---
.rubocop_todo.yml | 18 -----------
.../billing/gateways/cyber_source.rb | 6 ++--
.../billing/gateways/instapay.rb | 2 +-
.../billing/gateways/net_registry.rb | 2 +-
.../billing/gateways/optimal_payment.rb | 32 +++++++++----------
.../billing/gateways/psigate.rb | 2 +-
.../billing/gateways/sage_pay.rb | 10 +++---
test/remote/gateways/remote_eway_test.rb | 2 +-
.../gateways/remote_payflow_express_test.rb | 12 +++----
.../gateways/remote_paypal_express_test.rb | 2 +-
test/unit/gateways/checkout_test.rb | 2 +-
test/unit/gateways/paypal_express_test.rb | 4 +--
12 files changed, 38 insertions(+), 56 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 5bc923d347c..dbfe421e0ce 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -186,24 +186,6 @@ Layout/SpaceAroundOperators:
Layout/SpaceBeforeBlockBraces:
Enabled: false
-# Offense count: 39
-# Cop supports --auto-correct.
-Layout/SpaceBeforeComma:
- Exclude:
- - 'lib/active_merchant/billing/gateways/cyber_source.rb'
- - 'lib/active_merchant/billing/gateways/ideal/ideal_base.rb'
- - 'lib/active_merchant/billing/gateways/instapay.rb'
- - 'lib/active_merchant/billing/gateways/net_registry.rb'
- - 'lib/active_merchant/billing/gateways/optimal_payment.rb'
- - 'lib/active_merchant/billing/gateways/psigate.rb'
- - 'lib/active_merchant/billing/gateways/sage_pay.rb'
- - 'test/remote/gateways/remote_eway_test.rb'
- - 'test/remote/gateways/remote_payflow_express_test.rb'
- - 'test/remote/gateways/remote_paypal_express_test.rb'
- - 'test/remote/gateways/remote_paypal_test.rb'
- - 'test/unit/gateways/checkout_test.rb'
- - 'test/unit/gateways/paypal_express_test.rb'
-
# Offense count: 1
# Cop supports --auto-correct.
Layout/SpaceBeforeComment:
diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb
index 77c4dc03630..0bc2693ff1e 100644
--- a/lib/active_merchant/billing/gateways/cyber_source.rb
+++ b/lib/active_merchant/billing/gateways/cyber_source.rb
@@ -48,7 +48,7 @@ class CyberSourceGateway < Gateway
@@response_codes = {
:r100 => 'Successful transaction',
- :r101 => 'Request is missing one or more required fields' ,
+ :r101 => 'Request is missing one or more required fields',
:r102 => 'One or more fields contains invalid data',
:r150 => 'General failure',
:r151 => 'The request was received but a server time-out occurred',
@@ -432,9 +432,9 @@ def add_line_item_data(xml, options)
def add_merchant_data(xml, options)
xml.tag! 'merchantID', @options[:login]
xml.tag! 'merchantReferenceCode', options[:order_id] || generate_unique_id
- xml.tag! 'clientLibrary' ,'Ruby Active Merchant'
+ xml.tag! 'clientLibrary','Ruby Active Merchant'
xml.tag! 'clientLibraryVersion', VERSION
- xml.tag! 'clientEnvironment' , RUBY_PLATFORM
+ xml.tag! 'clientEnvironment', RUBY_PLATFORM
end
def add_purchase_data(xml, money = 0, include_grand_total = false, options={})
diff --git a/lib/active_merchant/billing/gateways/instapay.rb b/lib/active_merchant/billing/gateways/instapay.rb
index 13a41a76593..d2ef3f9d13b 100644
--- a/lib/active_merchant/billing/gateways/instapay.rb
+++ b/lib/active_merchant/billing/gateways/instapay.rb
@@ -140,7 +140,7 @@ def commit(action, parameters)
data = ssl_post self.live_url, post_data(action, parameters)
response = parse(data)
- Response.new(response[:success] , response[:message], response,
+ Response.new(response[:success], response[:message], response,
:authorization => response[:transaction_id],
:avs_result => { :code => response[:avs_result] },
:cvv_result => response[:cvv_result]
diff --git a/lib/active_merchant/billing/gateways/net_registry.rb b/lib/active_merchant/billing/gateways/net_registry.rb
index a1e4ee183ef..62a2e8c9ba9 100644
--- a/lib/active_merchant/billing/gateways/net_registry.rb
+++ b/lib/active_merchant/billing/gateways/net_registry.rb
@@ -131,7 +131,7 @@ def add_request_details(params, options)
# format for a command.
def expiry(credit_card)
month = format(credit_card.month, :two_digits)
- year = format(credit_card.year , :two_digits)
+ year = format(credit_card.year, :two_digits)
"#{month}/#{year}"
end
diff --git a/lib/active_merchant/billing/gateways/optimal_payment.rb b/lib/active_merchant/billing/gateways/optimal_payment.rb
index 2684c76e84f..6a2716c2813 100644
--- a/lib/active_merchant/billing/gateways/optimal_payment.rb
+++ b/lib/active_merchant/billing/gateways/optimal_payment.rb
@@ -255,27 +255,27 @@ def schema
def build_merchant_account(xml)
xml.tag! 'merchantAccount' do
- xml.tag! 'accountNum' , @options[:account_number]
- xml.tag! 'storeID' , @options[:store_id]
- xml.tag! 'storePwd' , @options[:password]
+ xml.tag! 'accountNum', @options[:account_number]
+ xml.tag! 'storeID', @options[:store_id]
+ xml.tag! 'storePwd', @options[:password]
end
end
def build_card(xml, opts)
xml.tag! 'card' do
- xml.tag! 'cardNum' , @credit_card.number
+ xml.tag! 'cardNum', @credit_card.number
xml.tag! 'cardExpiry' do
- xml.tag! 'month' , @credit_card.month
- xml.tag! 'year' , @credit_card.year
+ xml.tag! 'month', @credit_card.month
+ xml.tag! 'year', @credit_card.year
end
if brand = card_type(@credit_card.brand)
- xml.tag! 'cardType' , brand
+ xml.tag! 'cardType', brand
end
if @credit_card.verification_value?
- xml.tag! 'cvdIndicator' , '1' # Value Provided
- xml.tag! 'cvd' , @credit_card.verification_value
+ xml.tag! 'cvdIndicator', '1' # Value Provided
+ xml.tag! 'cvd', @credit_card.verification_value
else
- xml.tag! 'cvdIndicator' , '0'
+ xml.tag! 'cvdIndicator', '0'
end
end
end
@@ -299,18 +299,18 @@ def build_address(xml, addr)
if addr[:name]
first_name, last_name = split_names(addr[:name])
xml.tag! 'firstName', first_name
- xml.tag! 'lastName' , last_name
+ xml.tag! 'lastName', last_name
end
- xml.tag! 'street' , addr[:address1] if addr[:address1].present?
+ xml.tag! 'street', addr[:address1] if addr[:address1].present?
xml.tag! 'street2', addr[:address2] if addr[:address2].present?
- xml.tag! 'city' , addr[:city] if addr[:city].present?
+ xml.tag! 'city', addr[:city] if addr[:city].present?
if addr[:state].present?
state_tag = %w(US CA).include?(addr[:country]) ? 'state' : 'region'
xml.tag! state_tag, addr[:state]
end
- xml.tag! 'country', addr[:country] if addr[:country].present?
- xml.tag! 'zip' , addr[:zip] if addr[:zip].present?
- xml.tag! 'phone' , addr[:phone] if addr[:phone].present?
+ xml.tag! 'country', addr[:country] if addr[:country].present?
+ xml.tag! 'zip', addr[:zip] if addr[:zip].present?
+ xml.tag! 'phone', addr[:phone] if addr[:phone].present?
end
def card_type(key)
diff --git a/lib/active_merchant/billing/gateways/psigate.rb b/lib/active_merchant/billing/gateways/psigate.rb
index e83b86c2c86..f8dfbc67a5c 100644
--- a/lib/active_merchant/billing/gateways/psigate.rb
+++ b/lib/active_merchant/billing/gateways/psigate.rb
@@ -104,7 +104,7 @@ def commit(money, creditcard, options = {})
Response.new(successful?(response), message_from(response), response,
:test => test?,
- :authorization => build_authorization(response) ,
+ :authorization => build_authorization(response),
:avs_result => { :code => response[:avsresult] },
:cvv_result => response[:cardidresult]
)
diff --git a/lib/active_merchant/billing/gateways/sage_pay.rb b/lib/active_merchant/billing/gateways/sage_pay.rb
index 4eee27bb932..81506b77007 100644
--- a/lib/active_merchant/billing/gateways/sage_pay.rb
+++ b/lib/active_merchant/billing/gateways/sage_pay.rb
@@ -52,8 +52,8 @@ class SagePayGateway < Gateway
OPTIONAL_REQUEST_FIELDS = {
paypal_callback_url: :PayPalCallbackURL,
basket: :Basket,
- gift_aid_payment: :GiftAidPayment ,
- apply_avscv2: :ApplyAVSCV2 ,
+ gift_aid_payment: :GiftAidPayment,
+ apply_avscv2: :ApplyAVSCV2,
apply_3d_secure: :Apply3DSecure,
account_type: :AccountType,
billing_agreement: :BillingAgreement,
@@ -63,9 +63,9 @@ class SagePayGateway < Gateway
vendor_data: :VendorData,
language: :Language,
website: :Website,
- recipient_account_number: :FIRecipientAcctNumber ,
- recipient_surname: :FIRecipientSurname ,
- recipient_postcode: :FIRecipientPostcode ,
+ recipient_account_number: :FIRecipientAcctNumber,
+ recipient_surname: :FIRecipientSurname,
+ recipient_postcode: :FIRecipientPostcode,
recipient_dob: :FIRecipientDoB
}
diff --git a/test/remote/gateways/remote_eway_test.rb b/test/remote/gateways/remote_eway_test.rb
index 693a51282e5..a8d7d583874 100644
--- a/test/remote/gateways/remote_eway_test.rb
+++ b/test/remote/gateways/remote_eway_test.rb
@@ -17,7 +17,7 @@ def setup
:state => 'WA',
:country => 'AU',
:zip => '2000'
- } ,
+ },
:description => 'purchased items'
}
end
diff --git a/test/remote/gateways/remote_payflow_express_test.rb b/test/remote/gateways/remote_payflow_express_test.rb
index b25c566df9a..5c8978d6802 100644
--- a/test/remote/gateways/remote_payflow_express_test.rb
+++ b/test/remote/gateways/remote_payflow_express_test.rb
@@ -65,8 +65,8 @@ def test_setup_authorization_discount_taxes_included_free_shipping
{
:name => 'test4',
:description => 'test4',
- :quantity=>2 ,
- :amount=> 1399 ,
+ :quantity=>2,
+ :amount=> 1399,
:url=>'http://localhost:3000/products/test4'
}
],
@@ -92,8 +92,8 @@ def test_setup_authorization_with_discount_taxes_additional
{
:name => 'test4',
:description => 'test4',
- :quantity=>2 ,
- :amount=> 1399 ,
+ :quantity=>2,
+ :amount=> 1399,
:url=>'http://localhost:3000/products/test4'
}
],
@@ -119,8 +119,8 @@ def test_setup_authorization_with_discount_taxes_and_shipping_addtiional
{
:name => 'test4',
:description => 'test4',
- :quantity=>2 ,
- :amount=> 1399 ,
+ :quantity=>2,
+ :amount=> 1399,
:url=>'http://localhost:3000/products/test4'
}
],
diff --git a/test/remote/gateways/remote_paypal_express_test.rb b/test/remote/gateways/remote_paypal_express_test.rb
index e5a4ff50364..c599649a814 100644
--- a/test/remote/gateways/remote_paypal_express_test.rb
+++ b/test/remote/gateways/remote_paypal_express_test.rb
@@ -17,7 +17,7 @@ def setup
:state => 'NC',
:country => 'US',
:zip => '23456'
- } ,
+ },
:description => 'Stuff that you purchased, yo!',
:ip => '10.0.0.1',
:return_url => 'http://example.com/return',
diff --git a/test/unit/gateways/checkout_test.rb b/test/unit/gateways/checkout_test.rb
index bc12cd16476..ab70056694e 100644
--- a/test/unit/gateways/checkout_test.rb
+++ b/test/unit/gateways/checkout_test.rb
@@ -55,7 +55,7 @@ def test_unsuccessful_authorize
def test_unsuccessful_capture
@gateway.expects(:ssl_post).returns(failed_capture_response)
- assert response = @gateway.capture(100, '||||' , @options)
+ assert response = @gateway.capture(100, '||||', @options)
assert_failure response
assert_equal 'EGP00173', response.params['error_code_tag']
assert response.test?
diff --git a/test/unit/gateways/paypal_express_test.rb b/test/unit/gateways/paypal_express_test.rb
index 6bd01c9eb93..67145530893 100644
--- a/test/unit/gateways/paypal_express_test.rb
+++ b/test/unit/gateways/paypal_express_test.rb
@@ -622,7 +622,7 @@ def test_ensure_only_unique_error_codes
:cancel_return_url => 'http://example.com'
)
- assert_equal '10736' , response.params['error_codes']
+ assert_equal '10736', response.params['error_codes']
end
def test_error_codes_for_multiple_errors
@@ -632,7 +632,7 @@ def test_error_codes_for_multiple_errors
:cancel_return_url => 'http://example.com'
)
- assert_equal ['10736', '10002'] , response.params['error_codes'].split(',')
+ assert_equal ['10736', '10002'], response.params['error_codes'].split(',')
end
def test_allow_guest_checkout
From c61df87dfee957ddb9f76c28fd523c21e4ac45e7 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 18 Oct 2018 14:14:42 -0400
Subject: [PATCH 0112/2234] RuboCop: fix Layout/SpaceBeforeComment
---
.rubocop_todo.yml | 6 ------
test/remote/gateways/remote_usa_epay_advanced_test.rb | 2 +-
2 files changed, 1 insertion(+), 7 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index dbfe421e0ce..6c559d1caca 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -186,12 +186,6 @@ Layout/SpaceAroundOperators:
Layout/SpaceBeforeBlockBraces:
Enabled: false
-# Offense count: 1
-# Cop supports --auto-correct.
-Layout/SpaceBeforeComment:
- Exclude:
- - 'test/remote/gateways/remote_usa_epay_advanced_test.rb'
-
# Offense count: 118
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets.
diff --git a/test/remote/gateways/remote_usa_epay_advanced_test.rb b/test/remote/gateways/remote_usa_epay_advanced_test.rb
index 2f7bc1fc264..01ec1523690 100644
--- a/test/remote/gateways/remote_usa_epay_advanced_test.rb
+++ b/test/remote/gateways/remote_usa_epay_advanced_test.rb
@@ -271,7 +271,7 @@ def test_run_customer_transaction
response = @gateway.add_customer(@options.merge(@customer_options))
customer_number = response.params['add_customer_return']
- response = @gateway.run_customer_transaction(:customer_number => customer_number,# :method_id => 0, # optional
+ response = @gateway.run_customer_transaction(:customer_number => customer_number, # :method_id => 0, # optional
:command => 'Sale', :amount => 3000)
assert response.params['run_customer_transaction_return']
end
From 2073abda0b6b4552dab58f0b235e5d09e3ad60f2 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 18 Oct 2018 14:17:08 -0400
Subject: [PATCH 0113/2234] RuboCop: fix Layout/SpaceAroundBlockParameters
---
.rubocop_todo.yml | 9 ---------
lib/active_merchant/billing/gateways/payscout.rb | 2 +-
test/unit/country_test.rb | 2 +-
3 files changed, 2 insertions(+), 11 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 6c559d1caca..bd3b97b53c2 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -151,15 +151,6 @@ Layout/MultilineOperationIndentation:
Layout/SpaceAfterComma:
Enabled: false
-# Offense count: 3
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyleInsidePipes.
-# SupportedStylesInsidePipes: space, no_space
-Layout/SpaceAroundBlockParameters:
- Exclude:
- - 'lib/active_merchant/billing/gateways/payscout.rb'
- - 'test/unit/country_test.rb'
-
# Offense count: 638
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
diff --git a/lib/active_merchant/billing/gateways/payscout.rb b/lib/active_merchant/billing/gateways/payscout.rb
index 108d8725aa7..7596dddccbc 100644
--- a/lib/active_merchant/billing/gateways/payscout.rb
+++ b/lib/active_merchant/billing/gateways/payscout.rb
@@ -102,7 +102,7 @@ def add_creditcard(post, creditcard)
end
def parse(body)
- Hash[body.split('&').map{|x|x.split('=')}]
+ Hash[body.split('&').map{|x| x.split('=')}]
end
def commit(action, money, parameters)
diff --git a/test/unit/country_test.rb b/test/unit/country_test.rb
index 3fce8ff16c5..d9dcae71b07 100644
--- a/test/unit/country_test.rb
+++ b/test/unit/country_test.rb
@@ -74,7 +74,7 @@ def test_raise_on_nil_name
end
def test_country_names_are_alphabetized
- country_names = ActiveMerchant::Country::COUNTRIES.map { | each | each[:name] }
+ country_names = ActiveMerchant::Country::COUNTRIES.map { |each| each[:name] }
assert_equal(country_names.sort, country_names)
end
From 3f6c3ab49543bde093cae0eed8c223c53b0d1978 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 18 Oct 2018 14:24:20 -0400
Subject: [PATCH 0114/2234] Remove a pile of bad/invalid/confusing comments
---
lib/active_merchant/billing/gateways/authorize_net_cim.rb | 1 -
lib/active_merchant/billing/gateways/netpay.rb | 1 -
lib/active_merchant/billing/gateways/opp.rb | 1 -
lib/active_merchant/billing/gateways/secure_pay_au.rb | 1 -
test/remote/gateways/remote_payment_express_test.rb | 2 +-
test/unit/gateways/blue_pay_test.rb | 1 -
6 files changed, 1 insertion(+), 6 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/authorize_net_cim.rb b/lib/active_merchant/billing/gateways/authorize_net_cim.rb
index bfde6385998..ca774b3f1c3 100644
--- a/lib/active_merchant/billing/gateways/authorize_net_cim.rb
+++ b/lib/active_merchant/billing/gateways/authorize_net_cim.rb
@@ -671,7 +671,6 @@ def add_transaction(xml, transaction)
tag_unless_blank(xml,'customerShippingAddressId', transaction[:customer_shipping_address_id])
xml.tag!('transId', transaction[:trans_id])
when :refund
- #TODO - add lineItems field
xml.tag!('amount', transaction[:amount])
tag_unless_blank(xml, 'customerProfileId', transaction[:customer_profile_id])
tag_unless_blank(xml, 'customerPaymentProfileId', transaction[:customer_payment_profile_id])
diff --git a/lib/active_merchant/billing/gateways/netpay.rb b/lib/active_merchant/billing/gateways/netpay.rb
index 5068fa894c6..7b660cefe98 100644
--- a/lib/active_merchant/billing/gateways/netpay.rb
+++ b/lib/active_merchant/billing/gateways/netpay.rb
@@ -110,7 +110,6 @@ def refund(money, authorization, options = {})
add_order_id(post, order_id_from(authorization))
add_amount(post, money, options)
- #commit('Refund', post, options)
commit('Credit', post, options)
end
diff --git a/lib/active_merchant/billing/gateways/opp.rb b/lib/active_merchant/billing/gateways/opp.rb
index 11f8c4c8efa..19d3a11477f 100644
--- a/lib/active_merchant/billing/gateways/opp.rb
+++ b/lib/active_merchant/billing/gateways/opp.rb
@@ -244,7 +244,6 @@ def add_invoice(post, money, options)
def add_payment_method(post, payment, options)
if options[:registrationId]
- #post[:recurringType] = 'REPEATED'
post[:card] = {
cvv: payment.verification_value,
}
diff --git a/lib/active_merchant/billing/gateways/secure_pay_au.rb b/lib/active_merchant/billing/gateways/secure_pay_au.rb
index f4e569253a3..3a6aa76775f 100644
--- a/lib/active_merchant/billing/gateways/secure_pay_au.rb
+++ b/lib/active_merchant/billing/gateways/secure_pay_au.rb
@@ -238,7 +238,6 @@ def build_periodic_request(body)
def commit_periodic(request)
my_request = build_periodic_request(request)
- #puts my_request
response = parse(ssl_post(test? ? self.test_periodic_url : self.live_periodic_url, my_request))
Response.new(success?(response), message_from(response), response,
diff --git a/test/remote/gateways/remote_payment_express_test.rb b/test/remote/gateways/remote_payment_express_test.rb
index 8fb5bfc22b7..cca036a49cb 100644
--- a/test/remote/gateways/remote_payment_express_test.rb
+++ b/test/remote/gateways/remote_payment_express_test.rb
@@ -88,7 +88,7 @@ def test_store_credit_card
end
def test_store_with_custom_token
- token = Time.now.to_i.to_s #hehe
+ token = Time.now.to_i.to_s
assert response = @gateway.store(@credit_card, :billing_id => token)
assert_success response
assert_equal 'The Transaction was approved', response.message
diff --git a/test/unit/gateways/blue_pay_test.rb b/test/unit/gateways/blue_pay_test.rb
index 089efee347b..b7947bfc02f 100644
--- a/test/unit/gateways/blue_pay_test.rb
+++ b/test/unit/gateways/blue_pay_test.rb
@@ -23,7 +23,6 @@ def setup
end
def test_successful_authorization
- #@gateway.expects(:ssl_post).returns(successful_authorization_response)
@gateway.expects(:ssl_post).returns(RSP[:approved_auth])
assert response = @gateway.authorize(@amount, @credit_card)
assert_instance_of Response, response
From 3894b87621a29a9d9ecc76bb6254d2d728673ef9 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 18 Oct 2018 14:24:29 -0400
Subject: [PATCH 0115/2234] RuboCop: fix Layout/LeadingCommentSpace
---
.rubocop_todo.yml | 5 -----
.../billing/gateways/beanstream.rb | 4 ++--
.../billing/gateways/card_save.rb | 4 ++--
lib/active_merchant/billing/gateways/cecabank.rb | 2 +-
.../billing/gateways/eway_managed.rb | 2 +-
.../billing/gateways/linkpoint.rb | 2 +-
lib/active_merchant/billing/gateways/mercury.rb | 2 +-
.../billing/gateways/nab_transact.rb | 16 ++++++++--------
lib/active_merchant/billing/gateways/omise.rb | 2 +-
.../billing/gateways/optimal_payment.rb | 6 +++---
.../billing/gateways/payment_express.rb | 2 +-
lib/active_merchant/billing/gateways/psl_card.rb | 12 ++++++------
.../billing/gateways/securion_pay.rb | 6 +++---
.../gateways/remote_authorize_net_cim_test.rb | 4 ++--
.../remote_ct_payment_certification_test.rb | 4 ++--
test/remote/gateways/remote_data_cash_test.rb | 14 +++++++-------
test/remote/gateways/remote_nab_transact_test.rb | 8 ++++----
test/remote/gateways/remote_paypal_test.rb | 4 ++--
.../remote/gateways/remote_secure_pay_au_test.rb | 8 ++++----
test/remote/gateways/remote_wirecard_test.rb | 2 +-
test/unit/gateways/authorize_net_cim_test.rb | 2 +-
test/unit/gateways/banwire_test.rb | 4 ++--
test/unit/gateways/garanti_test.rb | 2 +-
test/unit/gateways/iats_payments_test.rb | 2 +-
test/unit/gateways/paypal_express_test.rb | 2 +-
test/unit/gateways/usa_epay_advanced_test.rb | 10 +++++-----
26 files changed, 63 insertions(+), 68 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index bd3b97b53c2..b6411de3752 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -98,11 +98,6 @@ Layout/IndentationConsistency:
Layout/IndentationWidth:
Enabled: false
-# Offense count: 68
-# Cop supports --auto-correct.
-Layout/LeadingCommentSpace:
- Enabled: false
-
# Offense count: 6
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
diff --git a/lib/active_merchant/billing/gateways/beanstream.rb b/lib/active_merchant/billing/gateways/beanstream.rb
index d42209db38d..0c1b42ed7b4 100644
--- a/lib/active_merchant/billing/gateways/beanstream.rb
+++ b/lib/active_merchant/billing/gateways/beanstream.rb
@@ -167,8 +167,8 @@ def store(payment_method, options = {})
commit(post, true)
end
- #can't actually delete a secure profile with the supplicated API. This function sets the status of the profile to closed (C).
- #Closed profiles will have to removed manually.
+ # can't actually delete a secure profile with the supplicated API. This function sets the status of the profile to closed (C).
+ # Closed profiles will have to removed manually.
def delete(vault_id)
update(vault_id, false, {:status => 'C'})
end
diff --git a/lib/active_merchant/billing/gateways/card_save.rb b/lib/active_merchant/billing/gateways/card_save.rb
index 633ad3ea7cc..48c7decf336 100644
--- a/lib/active_merchant/billing/gateways/card_save.rb
+++ b/lib/active_merchant/billing/gateways/card_save.rb
@@ -1,8 +1,8 @@
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
class CardSaveGateway < IridiumGateway
- #CardSave lets you handle failovers on payments by providing 3 gateways in case one happens to be down
- #URLS = ['https://gw1.cardsaveonlinepayments.com:4430/','https://gw2.cardsaveonlinepayments.com:4430/','https://gw3.cardsaveonlinepayments.com:4430/']
+ # CardSave lets you handle failovers on payments by providing 3 gateways in case one happens to be down
+ # URLS = ['https://gw1.cardsaveonlinepayments.com:4430/','https://gw2.cardsaveonlinepayments.com:4430/','https://gw3.cardsaveonlinepayments.com:4430/']
self.money_format = :cents
self.default_currency = 'GBP'
diff --git a/lib/active_merchant/billing/gateways/cecabank.rb b/lib/active_merchant/billing/gateways/cecabank.rb
index ea93d83e973..0b7cf8bc86d 100644
--- a/lib/active_merchant/billing/gateways/cecabank.rb
+++ b/lib/active_merchant/billing/gateways/cecabank.rb
@@ -19,7 +19,7 @@ class CecabankGateway < Gateway
CECA_UI_LESS_LANGUAGE = 'XML'
CECA_UI_LESS_LANGUAGE_REFUND = '1'
CECA_UI_LESS_REFUND_PAGE = 'anulacion_xml'
- CECA_ACTION_REFUND = 'tpvanularparcialmente' #use partial refund's URL to avoid time frame limitations and decision logic on client side
+ CECA_ACTION_REFUND = 'tpvanularparcialmente' # use partial refund's URL to avoid time frame limitations and decision logic on client side
CECA_ACTION_PURCHASE = 'tpv'
CECA_CURRENCIES_DICTIONARY = {'EUR' => 978, 'USD' => 840, 'GBP' => 826}
diff --git a/lib/active_merchant/billing/gateways/eway_managed.rb b/lib/active_merchant/billing/gateways/eway_managed.rb
index bd5281511c3..85616ed0b74 100644
--- a/lib/active_merchant/billing/gateways/eway_managed.rb
+++ b/lib/active_merchant/billing/gateways/eway_managed.rb
@@ -12,7 +12,7 @@ class EwayManagedGateway < Gateway
self.default_currency = 'AUD'
- #accepted money format
+ # accepted money format
self.money_format = :cents
# The homepage URL of the gateway
diff --git a/lib/active_merchant/billing/gateways/linkpoint.rb b/lib/active_merchant/billing/gateways/linkpoint.rb
index cf4d3cf28de..79ac53d3298 100644
--- a/lib/active_merchant/billing/gateways/linkpoint.rb
+++ b/lib/active_merchant/billing/gateways/linkpoint.rb
@@ -340,7 +340,7 @@ def parameters(money, creditcard, options = {})
:terminaltype => options[:terminaltype],
:ip => options[:ip],
:reference_number => options[:reference_number],
- :recurring => options[:recurring] || 'NO', #DO NOT USE if you are using the periodic billing option.
+ :recurring => options[:recurring] || 'NO', # DO NOT USE if you are using the periodic billing option.
:tdate => options[:tdate]
},
:orderoptions => {
diff --git a/lib/active_merchant/billing/gateways/mercury.rb b/lib/active_merchant/billing/gateways/mercury.rb
index 1a8fbe6be57..9580630d773 100644
--- a/lib/active_merchant/billing/gateways/mercury.rb
+++ b/lib/active_merchant/billing/gateways/mercury.rb
@@ -212,7 +212,7 @@ def add_credit_card(xml, credit_card, action)
# Track 1 and 2 have identical end sentinels (ETX) of '?'
# Tracks may or may not have checksum (LRC) after the ETX
# If the track has no STX or is corrupt, we send it as track 1, to let Mercury
- #handle with the validation error as it sees fit.
+ # handle with the validation error as it sees fit.
# Track 2 requires having the STX and ETX stripped. Track 1 does not.
# Max-length track 1s require having the STX and ETX stripped. Max is 79 bytes including LRC.
is_track_2 = credit_card.track_data[0] == ';'
diff --git a/lib/active_merchant/billing/gateways/nab_transact.rb b/lib/active_merchant/billing/gateways/nab_transact.rb
index 389653cf523..d09cf7ffc9d 100644
--- a/lib/active_merchant/billing/gateways/nab_transact.rb
+++ b/lib/active_merchant/billing/gateways/nab_transact.rb
@@ -23,14 +23,14 @@ class NabTransactGateway < Gateway
self.money_format = :cents
self.default_currency = 'AUD'
- #Transactions currently accepted by NAB Transact XML API
+ # Transactions currently accepted by NAB Transact XML API
TRANSACTIONS = {
- :purchase => 0, #Standard Payment
- :refund => 4, #Refund
- :void => 6, #Client Reversal (Void)
- :unmatched_refund => 666, #Unmatched Refund
- :authorization => 10, #Preauthorise
- :capture => 11 #Preauthorise Complete (Advice)
+ :purchase => 0, # Standard Payment
+ :refund => 4, # Refund
+ :void => 6, # Client Reversal (Void)
+ :unmatched_refund => 666, # Unmatched Refund
+ :authorization => 10, # Preauthorise
+ :capture => 11 # Preauthorise Complete (Advice)
}
PERIODIC_TYPES = {
@@ -134,7 +134,7 @@ def build_reference_request(money, reference, options)
xml.target!
end
- #Generate payment request XML
+ # Generate payment request XML
# - API is set to allow multiple Txn's but currently only allows one
# - txnSource = 23 - (XML)
def build_request(action, body)
diff --git a/lib/active_merchant/billing/gateways/omise.rb b/lib/active_merchant/billing/gateways/omise.rb
index 2d37f1dd5de..30ff0845778 100644
--- a/lib/active_merchant/billing/gateways/omise.rb
+++ b/lib/active_merchant/billing/gateways/omise.rb
@@ -19,7 +19,7 @@ class OmiseGateway < Gateway
self.default_currency = 'THB'
self.money_format = :cents
- #Country supported by Omise
+ # Country supported by Omise
# * Thailand
self.supported_countries = %w( TH JP )
diff --git a/lib/active_merchant/billing/gateways/optimal_payment.rb b/lib/active_merchant/billing/gateways/optimal_payment.rb
index 6a2716c2813..d85b5cbdaa3 100644
--- a/lib/active_merchant/billing/gateways/optimal_payment.rb
+++ b/lib/active_merchant/billing/gateways/optimal_payment.rb
@@ -99,11 +99,11 @@ def commit(action, money, post)
cc_stored_data_request(money, post)
when 'ccAuthorizeReversal'
cc_auth_reversal_request(post)
- #when 'ccCancelSettle', 'ccCancelCredit', 'ccCancelPayment'
+ # when 'ccCancelSettle', 'ccCancelCredit', 'ccCancelPayment'
# cc_cancel_request(money, post)
- #when 'ccPayment'
+ # when 'ccPayment'
# cc_payment_request(money, post)
- #when 'ccAuthenticate'
+ # when 'ccAuthenticate'
# cc_authenticate_request(money, post)
else
raise 'Unknown Action'
diff --git a/lib/active_merchant/billing/gateways/payment_express.rb b/lib/active_merchant/billing/gateways/payment_express.rb
index f0ce2bb5556..347f423fac7 100644
--- a/lib/active_merchant/billing/gateways/payment_express.rb
+++ b/lib/active_merchant/billing/gateways/payment_express.rb
@@ -169,7 +169,7 @@ def build_capture_or_credit_request(money, identification, options)
def build_token_request(credit_card, options)
result = new_transaction
add_credit_card(result, credit_card)
- add_amount(result, 100, options) #need to make an auth request for $1
+ add_amount(result, 100, options) # need to make an auth request for $1
add_token_request(result, options)
add_optional_elements(result, options)
result
diff --git a/lib/active_merchant/billing/gateways/psl_card.rb b/lib/active_merchant/billing/gateways/psl_card.rb
index 8154add4944..827a5cc11a4 100644
--- a/lib/active_merchant/billing/gateways/psl_card.rb
+++ b/lib/active_merchant/billing/gateways/psl_card.rb
@@ -46,20 +46,20 @@ class PslCardGateway < Gateway
'USD' => 840
}
- #The terminal used - only for swipe transactions, so hard coded to 32 for online
+ # The terminal used - only for swipe transactions, so hard coded to 32 for online
EMV_TERMINAL_TYPE = 32
- #Different Dispatch types
+ # Different Dispatch types
DISPATCH_LATER = 'LATER'
DISPATCH_NOW = 'NOW'
# Return codes
APPROVED = '00'
- #Nominal amount to authorize for a 'dispatch later' type
- #The nominal amount is held straight away, when the goods are ready
- #to be dispatched, PSL is informed and the full amount is the
- #taken.
+ # Nominal amount to authorize for a 'dispatch later' type
+ # The nominal amount is held straight away, when the goods are ready
+ # to be dispatched, PSL is informed and the full amount is the
+ # taken.
NOMINAL_AMOUNT = 101
AVS_CODE = {
diff --git a/lib/active_merchant/billing/gateways/securion_pay.rb b/lib/active_merchant/billing/gateways/securion_pay.rb
index 3c56fce55ad..8624ca0a6b8 100644
--- a/lib/active_merchant/billing/gateways/securion_pay.rb
+++ b/lib/active_merchant/billing/gateways/securion_pay.rb
@@ -73,11 +73,11 @@ def verify(credit_card, options={})
def store(credit_card, options = {})
if options[:customer_id].blank?
MultiResponse.run() do |r|
- #create charge object
+ # create charge object
r.process { authorize(100, credit_card, options) }
- #create customer and save card
+ # create customer and save card
r.process { create_customer_add_card(r.authorization, options) }
- #void the charge
+ # void the charge
r.process(:ignore_result) { void(r.params['metadata']['chargeId'], options) }
end
else
diff --git a/test/remote/gateways/remote_authorize_net_cim_test.rb b/test/remote/gateways/remote_authorize_net_cim_test.rb
index bbd6d60eea4..b0c5e09f7d4 100644
--- a/test/remote/gateways/remote_authorize_net_cim_test.rb
+++ b/test/remote/gateways/remote_authorize_net_cim_test.rb
@@ -466,7 +466,7 @@ def test_successful_update_customer_payment_profile_request_with_credit_card_las
new_billing_address.update(:first_name => 'Frank', :last_name => 'Brown')
# Initialize credit card with only last 4 digits as the number
- last_four_credit_card = ActiveMerchant::Billing::CreditCard.new(:number => '4242') #Credit card with only last four digits
+ last_four_credit_card = ActiveMerchant::Billing::CreditCard.new(:number => '4242') # Credit card with only last four digits
# Update only the billing address with a card with the last 4 digits and expiration date
assert response = @gateway.update_customer_payment_profile(
@@ -515,7 +515,7 @@ def test_successful_update_customer_shipping_address_request
)
new_address.delete(:phone_number)
- #Update the shipping address
+ # Update the shipping address
assert response = @gateway.update_customer_shipping_address(
:customer_profile_id => @customer_profile_id,
:address => new_address
diff --git a/test/remote/gateways/remote_ct_payment_certification_test.rb b/test/remote/gateways/remote_ct_payment_certification_test.rb
index 97ac2d6073b..b2a9784e416 100644
--- a/test/remote/gateways/remote_ct_payment_certification_test.rb
+++ b/test/remote/gateways/remote_ct_payment_certification_test.rb
@@ -128,7 +128,7 @@ def test19
end
def test20
- #requires editing the model to run with a 3 digit expiration date
+ # requires editing the model to run with a 3 digit expiration date
@credit_card = credit_card('4501161107217214', month: '07', year: 2)
response = @gateway.purchase(@amount, @credit_card, @options)
print_result(20, response)
@@ -204,7 +204,7 @@ def test32
end
def test33
- #requires edit to model to make 3 digit expiration date
+ # requires edit to model to make 3 digit expiration date
@credit_card = credit_card('4501161107217214', month: '07', year: 2)
response = @gateway.credit(@amount, @credit_card, @options)
print_result(33, response)
diff --git a/test/remote/gateways/remote_data_cash_test.rb b/test/remote/gateways/remote_data_cash_test.rb
index 9ff6635e5f9..9fb77b19a6f 100644
--- a/test/remote/gateways/remote_data_cash_test.rb
+++ b/test/remote/gateways/remote_data_cash_test.rb
@@ -72,8 +72,8 @@ def test_successful_purchase
assert response.test?
end
- #the amount is changed to £1.99 - the DC test server won't check the
- #address details - this is more a check on the passed ExtendedPolicy
+ # the amount is changed to £1.99 - the DC test server won't check the
+ # address details - this is more a check on the passed ExtendedPolicy
def test_successful_purchase_without_address_check
response = @gateway.purchase(199, @mastercard, @params)
assert_success response
@@ -109,7 +109,7 @@ def test_successful_purchase_with_account_set_up_and_repeat_payments
assert !response.authorization.to_s.split(';')[2].blank?
assert response.test?
- #Make second payment on the continuous authorization that was set up in the first purchase
+ # Make second payment on the continuous authorization that was set up in the first purchase
second_order_params = { :order_id => generate_unique_id }
purchase = @gateway.purchase(201, response.authorization, second_order_params)
assert_success purchase
@@ -121,7 +121,7 @@ def test_successful_purchase_with_account_set_up_and_repeat_payments_with_visa_d
assert_success response
assert !response.authorization.to_s.split(';')[2].blank?
- #Make second payment on the continuous authorization that was set up in the first purchase
+ # Make second payment on the continuous authorization that was set up in the first purchase
second_order_params = { :order_id => generate_unique_id }
purchase = @gateway.purchase(201, response.authorization, second_order_params)
assert_success purchase
@@ -135,19 +135,19 @@ def test_purchase_with_account_set_up_for_repeat_payments_fails_for_solo_card
end
def test_successful_authorization_and_capture_with_account_set_up_and_second_purchase
- #Authorize first payment
+ # Authorize first payment
@params[:set_up_continuous_authority] = true
first_authorization = @gateway.authorize(@amount, @mastercard, @params)
assert_success first_authorization
assert !first_authorization.authorization.to_s.split(';')[2].blank?
assert first_authorization.test?
- #Capture first payment
+ # Capture first payment
capture = @gateway.capture(@amount, first_authorization.authorization, @params)
assert_success capture
assert capture.test?
- #Collect second purchase
+ # Collect second purchase
second_order_params = { :order_id => generate_unique_id }
purchase = @gateway.purchase(201, first_authorization.authorization, second_order_params)
assert_success purchase
diff --git a/test/remote/gateways/remote_nab_transact_test.rb b/test/remote/gateways/remote_nab_transact_test.rb
index 71cfe58cdb2..ce7ce019ec5 100644
--- a/test/remote/gateways/remote_nab_transact_test.rb
+++ b/test/remote/gateways/remote_nab_transact_test.rb
@@ -31,16 +31,16 @@ def test_successful_purchase
end
def test_unsuccessful_purchase_insufficient_funds
- #Any total not ending in 00/08/11/16
- failing_amount = 151 #Specifically tests 'Insufficient Funds'
+ # Any total not ending in 00/08/11/16
+ failing_amount = 151 # Specifically tests 'Insufficient Funds'
assert response = @gateway.purchase(failing_amount, @credit_card, @options)
assert_failure response
assert_equal 'Insufficient Funds', response.message
end
def test_unsuccessful_purchase_do_not_honour
- #Any total not ending in 00/08/11/16
- failing_amount = 105 #Specifically tests 'do not honour'
+ # Any total not ending in 00/08/11/16
+ failing_amount = 105 # Specifically tests 'do not honour'
assert response = @gateway.purchase(failing_amount, @credit_card, @options)
assert_failure response
assert_equal 'Do Not Honour', response.message
diff --git a/test/remote/gateways/remote_paypal_test.rb b/test/remote/gateways/remote_paypal_test.rb
index 7901d34024a..3cb88a8ed96 100644
--- a/test/remote/gateways/remote_paypal_test.rb
+++ b/test/remote/gateways/remote_paypal_test.rb
@@ -29,8 +29,8 @@ def setup
# each auth-id can only be reauthorized and tested once.
# leave it commented if you don't want to test reauthorization.
#
- #@three_days_old_auth_id = "9J780651TU4465545"
- #@three_days_old_auth_id2 = "62503445A3738160X"
+ # @three_days_old_auth_id = "9J780651TU4465545"
+ # @three_days_old_auth_id2 = "62503445A3738160X"
end
def test_transcript_scrubbing
diff --git a/test/remote/gateways/remote_secure_pay_au_test.rb b/test/remote/gateways/remote_secure_pay_au_test.rb
index 56958b29afd..fc99db2ef81 100644
--- a/test/remote/gateways/remote_secure_pay_au_test.rb
+++ b/test/remote/gateways/remote_secure_pay_au_test.rb
@@ -130,7 +130,7 @@ def test_successful_unstore
end
def test_repeat_unstore
- @gateway.unstore('test1234') rescue nil #Ensure it is already missing
+ @gateway.unstore('test1234') rescue nil # Ensure it is already missing
response = @gateway.unstore('test1234')
@@ -147,7 +147,7 @@ def test_successful_store
end
def test_failed_store
- @gateway.store(@credit_card, {:billing_id => 'test1234', :amount => 15000}) rescue nil #Ensure it already exists
+ @gateway.store(@credit_card, {:billing_id => 'test1234', :amount => 15000}) rescue nil # Ensure it already exists
assert response = @gateway.store(@credit_card, {:billing_id => 'test1234', :amount => 15000})
assert_failure response
@@ -156,7 +156,7 @@ def test_failed_store
end
def test_successful_triggered_payment
- @gateway.store(@credit_card, {:billing_id => 'test1234', :amount => 15000}) rescue nil #Ensure it already exists
+ @gateway.store(@credit_card, {:billing_id => 'test1234', :amount => 15000}) rescue nil # Ensure it already exists
assert response = @gateway.purchase(12300, 'test1234', @options)
assert_success response
@@ -166,7 +166,7 @@ def test_successful_triggered_payment
end
def test_failure_triggered_payment
- @gateway.unstore('test1234') rescue nil #Ensure its no longer there
+ @gateway.unstore('test1234') rescue nil # Ensure its no longer there
assert response = @gateway.purchase(12300, 'test1234', @options)
assert_failure response
diff --git a/test/remote/gateways/remote_wirecard_test.rb b/test/remote/gateways/remote_wirecard_test.rb
index 15783d552d5..b58b05ee05b 100644
--- a/test/remote/gateways/remote_wirecard_test.rb
+++ b/test/remote/gateways/remote_wirecard_test.rb
@@ -58,7 +58,7 @@ def test_successful_authorize_and_partial_capture
assert_match %r{THIS IS A DEMO}, auth.message
assert auth.authorization
- #Capture some of the authorized amount
+ # Capture some of the authorized amount
assert capture = @gateway.capture(@amount - 10, auth.authorization, @options)
assert_success capture
end
diff --git a/test/unit/gateways/authorize_net_cim_test.rb b/test/unit/gateways/authorize_net_cim_test.rb
index 64f09efd42f..1d9bd462192 100644
--- a/test/unit/gateways/authorize_net_cim_test.rb
+++ b/test/unit/gateways/authorize_net_cim_test.rb
@@ -420,7 +420,7 @@ def test_should_update_customer_payment_profile_request
end
def test_should_update_customer_payment_profile_request_with_last_four_digits
- last_four_credit_card = ActiveMerchant::Billing::CreditCard.new(:number => '4242') #Credit card with only last four digits
+ last_four_credit_card = ActiveMerchant::Billing::CreditCard.new(:number => '4242') # Credit card with only last four digits
response = stub_comms do
@gateway.update_customer_payment_profile(
diff --git a/test/unit/gateways/banwire_test.rb b/test/unit/gateways/banwire_test.rb
index 77207753a74..faa341c1f97 100644
--- a/test/unit/gateways/banwire_test.rb
+++ b/test/unit/gateways/banwire_test.rb
@@ -61,7 +61,7 @@ def test_invalid_json
assert_match %r{Invalid response received from the Banwire API}, response.message
end
- #American Express requires address and zipcode
+ # American Express requires address and zipcode
def test_successful_amex_purchase
response = stub_comms do
@gateway.purchase(@amount, @amex_credit_card, @amex_options)
@@ -75,7 +75,7 @@ def test_successful_amex_purchase
assert response.test?
end
- #American Express requires address and zipcode
+ # American Express requires address and zipcode
def test_unsuccessful_amex_request
@gateway.expects(:ssl_post).returns(failed_purchase_amex_response)
diff --git a/test/unit/gateways/garanti_test.rb b/test/unit/gateways/garanti_test.rb
index 5b8287bb018..46e7ce79e87 100644
--- a/test/unit/gateways/garanti_test.rb
+++ b/test/unit/gateways/garanti_test.rb
@@ -10,7 +10,7 @@ def setup
@gateway = GarantiGateway.new(:login => 'a', :password => 'b', :terminal_id => 'c', :merchant_id => 'd')
@credit_card = credit_card(4242424242424242)
- @amount = 1000 #1000 cents, 10$
+ @amount = 1000 # 1000 cents, 10$
@options = {
:order_id => 'db4af18c5222503d845180350fbda516',
diff --git a/test/unit/gateways/iats_payments_test.rb b/test/unit/gateways/iats_payments_test.rb
index 0a063e2d2b4..ac94ec90912 100644
--- a/test/unit/gateways/iats_payments_test.rb
+++ b/test/unit/gateways/iats_payments_test.rb
@@ -225,7 +225,7 @@ def test_region_urls
@gateway = IatsPaymentsGateway.new(
:agent_code => 'code',
:password => 'password',
- :region => 'na' #North america
+ :region => 'na' # North america
)
response = stub_comms do
diff --git a/test/unit/gateways/paypal_express_test.rb b/test/unit/gateways/paypal_express_test.rb
index 67145530893..0c4f89d6641 100644
--- a/test/unit/gateways/paypal_express_test.rb
+++ b/test/unit/gateways/paypal_express_test.rb
@@ -736,7 +736,7 @@ def test_structure_correct
}
doc = Nokogiri::XML(@gateway.send(:build_setup_request, 'Sale', 10, all_options_enabled))
- #Strip back to the SetExpressCheckoutRequestDetails element - this is where the base component xsd starts
+ # Strip back to the SetExpressCheckoutRequestDetails element - this is where the base component xsd starts
xml = doc.xpath('//base:SetExpressCheckoutRequestDetails', 'base' => 'urn:ebay:apis:eBLBaseComponents').first
sub_doc = Nokogiri::XML::Document.new
sub_doc.root = xml
diff --git a/test/unit/gateways/usa_epay_advanced_test.rb b/test/unit/gateways/usa_epay_advanced_test.rb
index 24220cf514f..5f37ec88899 100644
--- a/test/unit/gateways/usa_epay_advanced_test.rb
+++ b/test/unit/gateways/usa_epay_advanced_test.rb
@@ -79,7 +79,7 @@ def setup
@standard_transaction_options = {
:method_id => 0,
:command => 'Sale',
- :amount => 2000 #20.00
+ :amount => 2000 # 20.00
}
@get_payment_options = {
@@ -421,7 +421,7 @@ def test_successful_run_check_credit
end
# TODO get post_auth response
- #def test_successful_post_auth
+ # def test_successful_post_auth
# @options.merge!(:authorization_code => 'bogus')
# @gateway.expects(:ssl_post).returns(successful_post_auth_response)
@@ -433,7 +433,7 @@ def test_successful_run_check_credit
# #assert_equal '47568732', response.authorization
# puts response.inspect
- #end
+ # end
def test_successful_run_quick_sale
@options.merge!(@transaction_options)
@@ -495,7 +495,7 @@ def test_successful_refund_transaction
end
# TODO get override_transaction response
- #def test_successful_override_transaction
+ # def test_successful_override_transaction
# @gateway.expects(:ssl_post).returns(successful_override_transaction_response)
# assert response = @gateway.override_transaction(@options)
@@ -504,7 +504,7 @@ def test_successful_refund_transaction
# assert response.test?
# puts response.inspect
- #end
+ # end
# Transaction Status ================================================
From b9d58ea50723572210819aad864e51f37b09ccc9 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Fri, 19 Oct 2018 09:16:23 -0400
Subject: [PATCH 0116/2234] MercadoPago: fix remote tests
There are two main issues here: first, the behavior of failed refunds
has changed, potentially allowing the requests to appear successful
when they were not. Refunds are now checked for success against the
new behavior.
Second, failed captures and voids, which previously returned JSON, now
simply return an HTML page showing an HTTP 405 error code, which would
crash Active Merchant. The parse method now recovers from that situation
and generates a bogus return value.
Unit: 19 tests, 90 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote: 17 tests, 46 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
lib/active_merchant/billing/gateways/mercado_pago.rb | 8 +++++++-
test/remote/gateways/remote_mercado_pago_test.rb | 6 +++---
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/mercado_pago.rb b/lib/active_merchant/billing/gateways/mercado_pago.rb
index ad6f931aade..3c841fccc53 100644
--- a/lib/active_merchant/billing/gateways/mercado_pago.rb
+++ b/lib/active_merchant/billing/gateways/mercado_pago.rb
@@ -186,6 +186,12 @@ def add_payment(post, options)
def parse(body)
JSON.parse(body)
+ rescue JSON::ParserError
+ {
+ 'status' => 'error',
+ 'status_detail' => 'json_parse_error',
+ 'message' => "A non-JSON response was received from Mercado Pago where one was expected. The raw response was:\n\n#{body}"
+ }
end
def commit(action, path, parameters)
@@ -207,7 +213,7 @@ def commit(action, path, parameters)
def success_from(action, response)
if action == 'refund'
- response['error'].nil?
+ response['status'] != 404 && response['error'].nil?
else
['active', 'approved', 'authorized', 'cancelled', 'in_process'].include?(response['status'])
end
diff --git a/test/remote/gateways/remote_mercado_pago_test.rb b/test/remote/gateways/remote_mercado_pago_test.rb
index aeda0a15172..54ddaa50072 100644
--- a/test/remote/gateways/remote_mercado_pago_test.rb
+++ b/test/remote/gateways/remote_mercado_pago_test.rb
@@ -71,7 +71,7 @@ def test_partial_capture
def test_failed_capture
response = @gateway.capture(@amount, '')
assert_failure response
- assert_equal 'Method not allowed', response.message
+ assert_equal 'json_parse_error', response.message
end
def test_successful_refund
@@ -94,7 +94,7 @@ def test_partial_refund
def test_failed_refund
response = @gateway.refund(@amount, '')
assert_failure response
- assert_equal 'Resource /payments/refunds not found.', response.message
+ assert_equal 'Not Found', response.message
end
def test_successful_void
@@ -109,7 +109,7 @@ def test_successful_void
def test_failed_void
response = @gateway.void('')
assert_failure response
- assert_equal 'Method not allowed', response.message
+ assert_equal 'json_parse_error', response.message
end
def test_successful_verify
From 2feafae92919c014a40255b95eda6150ef21d662 Mon Sep 17 00:00:00 2001
From: DeeDee Lavinder
Date: Thu, 11 Oct 2018 16:34:37 -0400
Subject: [PATCH 0117/2234] Braintree: Adds device_data
According to Braintree docs, `device_data` can be sent as a top-level
parameter when creating a `transaction`, `payment_method`, or
`customer`. And after chatting with their support, there is no way to
test this from the server-side. Deploying this with the hope that a
customer will give us some feedback about its efficacy.
Unit tests:
54 tests, 137 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
Remote tests:
63 tests, 361 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
---
lib/active_merchant/billing/gateways/braintree_blue.rb | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb
index 1f3726827bf..b1bafda2fc3 100644
--- a/lib/active_merchant/billing/gateways/braintree_blue.rb
+++ b/lib/active_merchant/billing/gateways/braintree_blue.rb
@@ -159,7 +159,7 @@ def update(vault_id, creditcard, options = {})
:last_name => creditcard.last_name,
:email => scrub_email(options[:email]),
:phone => options[:phone] || (options[:billing_address][:phone] if options[:billing_address] &&
- options[:billing_address][:phone]),
+ options[:billing_address][:phone]),
:credit_card => credit_card_params
)
Response.new(result.success?, message_from_result(result),
@@ -233,6 +233,7 @@ def add_customer_with_credit_card(creditcard, options)
:phone => options[:phone] || (options[:billing_address][:phone] if options[:billing_address] &&
options[:billing_address][:phone]),
:id => options[:customer],
+ :device_data => options[:device_data],
}.merge credit_card_params
result = @braintree_gateway.customer.create(merge_credit_card_options(parameters, options))
Response.new(result.success?, message_from_result(result),
@@ -256,6 +257,7 @@ def add_credit_card_to_customer(credit_card, options)
cvv: credit_card.verification_value,
expiration_month: credit_card.month.to_s.rjust(2, '0'),
expiration_year: credit_card.year.to_s,
+ device_data: options[:device_data],
}
parameters[:billing_address] = map_address(options[:billing_address]) if options[:billing_address]
From cfce5f199c192458d0584978c275f8a486f5a7f9 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Mon, 22 Oct 2018 15:07:36 -0400
Subject: [PATCH 0118/2234] RuboCop: fix Style/SafeNavigation
---
.rubocop_todo.yml | 7 -------
lib/active_merchant/billing/compatibility.rb | 2 +-
lib/active_merchant/billing/gateways/adyen.rb | 2 +-
lib/active_merchant/billing/gateways/authorize_net_cim.rb | 2 +-
.../billing/gateways/beanstream/beanstream_core.rb | 8 +++-----
lib/active_merchant/billing/gateways/blue_pay.rb | 2 +-
lib/active_merchant/billing/gateways/braintree_blue.rb | 2 +-
lib/active_merchant/billing/gateways/bridge_pay.rb | 6 +++---
lib/active_merchant/billing/gateways/ct_payment.rb | 2 +-
lib/active_merchant/billing/gateways/cyber_source.rb | 2 +-
lib/active_merchant/billing/gateways/elavon.rb | 8 +++-----
lib/active_merchant/billing/gateways/first_pay.rb | 6 +++---
lib/active_merchant/billing/gateways/hps.rb | 2 +-
lib/active_merchant/billing/gateways/jetpay.rb | 2 +-
lib/active_merchant/billing/gateways/jetpay_v2.rb | 2 +-
lib/active_merchant/billing/gateways/linkpoint.rb | 4 ++--
lib/active_merchant/billing/gateways/litle.rb | 2 +-
lib/active_merchant/billing/gateways/optimal_payment.rb | 2 +-
lib/active_merchant/billing/gateways/orbital.rb | 2 +-
lib/active_merchant/billing/gateways/pay_junction_v2.rb | 2 +-
lib/active_merchant/billing/gateways/payeezy.rb | 2 +-
lib/active_merchant/billing/gateways/payex.rb | 4 ++--
lib/active_merchant/billing/gateways/quickbooks.rb | 2 +-
lib/active_merchant/billing/gateways/securion_pay.rb | 4 ++--
lib/active_merchant/billing/gateways/stripe.rb | 2 +-
lib/active_merchant/billing/gateways/telr.rb | 4 ++--
lib/active_merchant/connection.rb | 4 ++--
lib/active_merchant/network_connection_retries.rb | 2 +-
lib/active_merchant/posts_data.rb | 4 ++--
test/comm_stub.rb | 2 +-
30 files changed, 43 insertions(+), 54 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index b6411de3752..9be5fbc942b 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -1259,13 +1259,6 @@ Style/RescueStandardError:
Exclude:
- 'lib/active_merchant/billing/base.rb'
-# Offense count: 33
-# Cop supports --auto-correct.
-# Configuration parameters: ConvertCodeThatCanStartToReturnNil, Whitelist.
-# Whitelist: present?, blank?, presence, try, try!
-Style/SafeNavigation:
- Enabled: false
-
# Offense count: 2
# Cop supports --auto-correct.
Style/SelfAssignment:
diff --git a/lib/active_merchant/billing/compatibility.rb b/lib/active_merchant/billing/compatibility.rb
index 8161ef320f0..87b7790440f 100644
--- a/lib/active_merchant/billing/compatibility.rb
+++ b/lib/active_merchant/billing/compatibility.rb
@@ -75,7 +75,7 @@ def []=(key, value)
end
def empty?
- all?{|k, v| v && v.empty?}
+ all?{|k, v| v&.empty?}
end
def on(field)
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index c73db70be52..cef696b8d8f 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -135,7 +135,7 @@ def add_shopper_interaction(post, payment, options={})
end
def add_address(post, options)
- return unless post[:card] && post[:card].kind_of?(Hash)
+ return unless post[:card]&.kind_of?(Hash)
if (address = options[:billing_address] || options[:address]) && address[:country]
post[:card][:billingAddress] = {}
post[:card][:billingAddress][:street] = address[:address1] || 'N/A'
diff --git a/lib/active_merchant/billing/gateways/authorize_net_cim.rb b/lib/active_merchant/billing/gateways/authorize_net_cim.rb
index ca774b3f1c3..af7c4a769b1 100644
--- a/lib/active_merchant/billing/gateways/authorize_net_cim.rb
+++ b/lib/active_merchant/billing/gateways/authorize_net_cim.rb
@@ -878,7 +878,7 @@ def tag_unless_blank(xml, tag_name, data)
end
def format_extra_options(options)
- options.map{ |k, v| "#{k}=#{v}" }.join('&') unless options.nil?
+ options&.map{ |k, v| "#{k}=#{v}" }&.join('&')
end
def parse_direct_response(params)
diff --git a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb
index bbc548de702..d1d7b2b75c4 100644
--- a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb
+++ b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb
@@ -375,11 +375,9 @@ def interval(options)
def parse(body)
results = {}
- if !body.nil?
- body.split(/&/).each do |pair|
- key, val = pair.split(/\=/)
- results[key.to_sym] = val.nil? ? nil : CGI.unescape(val)
- end
+ body&.split(/&/)&.each do |pair|
+ key, val = pair.split(/\=/)
+ results[key.to_sym] = val.nil? ? nil : CGI.unescape(val)
end
# Clean up the message text if there is any
diff --git a/lib/active_merchant/billing/gateways/blue_pay.rb b/lib/active_merchant/billing/gateways/blue_pay.rb
index 5e708624538..063434a150f 100644
--- a/lib/active_merchant/billing/gateways/blue_pay.rb
+++ b/lib/active_merchant/billing/gateways/blue_pay.rb
@@ -173,7 +173,7 @@ def refund(money, identification, options = {})
end
def credit(money, payment_object, options = {})
- if(payment_object && payment_object.kind_of?(String))
+ if payment_object&.kind_of?(String)
ActiveMerchant.deprecated 'credit should only be used to credit a payment method'
return refund(money, payment_object, options)
end
diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb
index b1bafda2fc3..6295c80164c 100644
--- a/lib/active_merchant/billing/gateways/braintree_blue.rb
+++ b/lib/active_merchant/billing/gateways/braintree_blue.rb
@@ -355,7 +355,7 @@ def response_from_result(result)
result.success?,
message_from_result(result),
response_hash,
- authorization: (result.transaction.id if result.transaction),
+ authorization: result.transaction&.id,
test: test?
)
end
diff --git a/lib/active_merchant/billing/gateways/bridge_pay.rb b/lib/active_merchant/billing/gateways/bridge_pay.rb
index ae2e653f4b6..3e12f5b11d6 100644
--- a/lib/active_merchant/billing/gateways/bridge_pay.rb
+++ b/lib/active_merchant/billing/gateways/bridge_pay.rb
@@ -166,8 +166,8 @@ def parse(xml)
response = {}
doc = Nokogiri::XML(xml)
- doc.root.xpath('*').each do |node|
- if (node.elements.size == 0)
+ doc.root&.xpath('*')&.each do |node|
+ if node.elements.size == 0
response[node.name.downcase.to_sym] = node.text
else
node.elements.each do |childnode|
@@ -175,7 +175,7 @@ def parse(xml)
response[name.to_sym] = childnode.text
end
end
- end unless doc.root.nil?
+ end
response
end
diff --git a/lib/active_merchant/billing/gateways/ct_payment.rb b/lib/active_merchant/billing/gateways/ct_payment.rb
index c29f8c30630..dd0c1ae2599 100644
--- a/lib/active_merchant/billing/gateways/ct_payment.rb
+++ b/lib/active_merchant/billing/gateways/ct_payment.rb
@@ -242,7 +242,7 @@ def success_from(response)
end
def message_from(response)
- response['errorDescription'] || (response['terminalDisp'].strip if response['terminalDisp'])
+ response['errorDescription'] || response['terminalDisp']&.strip
end
def authorization_from(response)
diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb
index 0bc2693ff1e..60a0fd3caef 100644
--- a/lib/active_merchant/billing/gateways/cyber_source.rb
+++ b/lib/active_merchant/billing/gateways/cyber_source.rb
@@ -677,7 +677,7 @@ def add_threeds_services(xml, options)
def lookup_country_code(country_field)
country_code = Country.find(country_field) rescue nil
- country_code.code(:alpha2) if country_code
+ country_code&.code(:alpha2)
end
# Where we actually build the full SOAP request using builder
diff --git a/lib/active_merchant/billing/gateways/elavon.rb b/lib/active_merchant/billing/gateways/elavon.rb
index 9814d760966..1800d17b373 100644
--- a/lib/active_merchant/billing/gateways/elavon.rb
+++ b/lib/active_merchant/billing/gateways/elavon.rb
@@ -191,10 +191,8 @@ def add_customer_data(form, options)
form[:email] = truncate(options[:email], 100) unless empty?(options[:email])
form[:customer_code] = truncate(options[:customer], 10) unless empty?(options[:customer])
form[:customer_number] = options[:customer_number] unless empty?(options[:customer_number])
- if options[:custom_fields]
- options[:custom_fields].each do |key, value|
- form[key.to_s] = value
- end
+ options[:custom_fields]&.each do |key, value|
+ form[key.to_s] = value
end
end
@@ -283,7 +281,7 @@ def post_data_string(key, value, options)
end
def custom_field?(field_name, options)
- return true if options[:custom_fields] && options[:custom_fields].include?(field_name.to_sym)
+ return true if options[:custom_fields]&.include?(field_name.to_sym)
field_name == :customer_number
end
diff --git a/lib/active_merchant/billing/gateways/first_pay.rb b/lib/active_merchant/billing/gateways/first_pay.rb
index 9a21f24562d..3c197f0d79e 100644
--- a/lib/active_merchant/billing/gateways/first_pay.rb
+++ b/lib/active_merchant/billing/gateways/first_pay.rb
@@ -119,9 +119,9 @@ def parse(xml)
response = {}
doc = Nokogiri::XML(xml)
- doc.root.xpath('//RESPONSE/FIELDS/FIELD').each do |field|
+ doc.root&.xpath('//RESPONSE/FIELDS/FIELD')&.each do |field|
response[field['KEY']] = field.text
- end unless doc.root.nil?
+ end
response
end
@@ -149,7 +149,7 @@ def success_from(response)
def message_from(response)
# Silly inconsistent gateway. Always make capitalized (but not all caps)
msg = (response['auth_response'] || response['response1'])
- msg.downcase.capitalize if msg
+ msg&.downcase&.capitalize
end
def error_code_from(response)
diff --git a/lib/active_merchant/billing/gateways/hps.rb b/lib/active_merchant/billing/gateways/hps.rb
index 07f4fb26597..5572924d1c7 100644
--- a/lib/active_merchant/billing/gateways/hps.rb
+++ b/lib/active_merchant/billing/gateways/hps.rb
@@ -274,7 +274,7 @@ def authorization_from(response)
end
def test?
- (@options[:secret_api_key] && @options[:secret_api_key].include?('_cert_'))
+ @options[:secret_api_key]&.include?('_cert_')
end
ISSUER_MESSAGES = {
diff --git a/lib/active_merchant/billing/gateways/jetpay.rb b/lib/active_merchant/billing/gateways/jetpay.rb
index 948c4799941..f6c631c4421 100644
--- a/lib/active_merchant/billing/gateways/jetpay.rb
+++ b/lib/active_merchant/billing/gateways/jetpay.rb
@@ -395,7 +395,7 @@ def add_user_defined_fields(xml, options)
def lookup_country_code(code)
country = Country.find(code) rescue nil
- country && country.code(:alpha3)
+ country&.code(:alpha3)
end
end
end
diff --git a/lib/active_merchant/billing/gateways/jetpay_v2.rb b/lib/active_merchant/billing/gateways/jetpay_v2.rb
index 0eb900d2aea..ff136384912 100644
--- a/lib/active_merchant/billing/gateways/jetpay_v2.rb
+++ b/lib/active_merchant/billing/gateways/jetpay_v2.rb
@@ -430,7 +430,7 @@ def add_user_defined_fields(xml, options)
def lookup_country_code(code)
country = Country.find(code) rescue nil
- country && country.code(:alpha3)
+ country&.code(:alpha3)
end
end
end
diff --git a/lib/active_merchant/billing/gateways/linkpoint.rb b/lib/active_merchant/billing/gateways/linkpoint.rb
index 79ac53d3298..37f0b3ab0b5 100644
--- a/lib/active_merchant/billing/gateways/linkpoint.rb
+++ b/lib/active_merchant/billing/gateways/linkpoint.rb
@@ -434,9 +434,9 @@ def parse(xml)
response = {:message => 'Global Error Receipt', :complete => false}
xml = REXML::Document.new("#{xml}")
- xml.root.elements.each do |node|
+ xml.root&.elements&.each do |node|
response[node.name.downcase.sub(/^r_/, '').to_sym] = normalize(node.text)
- end unless xml.root.nil?
+ end
response
end
diff --git a/lib/active_merchant/billing/gateways/litle.rb b/lib/active_merchant/billing/gateways/litle.rb
index 4365a3884c5..61be3eedaa7 100644
--- a/lib/active_merchant/billing/gateways/litle.rb
+++ b/lib/active_merchant/billing/gateways/litle.rb
@@ -284,7 +284,7 @@ def add_payment_method(doc, payment_method, options)
doc.cardholderAuthentication do
doc.authenticationValue(payment_method.payment_cryptogram)
end
- elsif options[:order_source] && options[:order_source].start_with?('3ds')
+ elsif options[:order_source]&.start_with?('3ds')
doc.cardholderAuthentication do
doc.authenticationValue(options[:cavv]) if options[:cavv]
doc.authenticationTransactionId(options[:xid]) if options[:xid]
diff --git a/lib/active_merchant/billing/gateways/optimal_payment.rb b/lib/active_merchant/billing/gateways/optimal_payment.rb
index d85b5cbdaa3..7dd2427ac33 100644
--- a/lib/active_merchant/billing/gateways/optimal_payment.rb
+++ b/lib/active_merchant/billing/gateways/optimal_payment.rb
@@ -178,7 +178,7 @@ def xml_document(root_tag)
def get_text_from_document(document, node)
node = REXML::XPath.first(document, node)
- node && node.text
+ node&.text
end
def cc_auth_request(money, opts)
diff --git a/lib/active_merchant/billing/gateways/orbital.rb b/lib/active_merchant/billing/gateways/orbital.rb
index f41a9801775..53ac7b2ac25 100644
--- a/lib/active_merchant/billing/gateways/orbital.rb
+++ b/lib/active_merchant/billing/gateways/orbital.rb
@@ -396,7 +396,7 @@ def add_address(xml, creditcard, options)
xml.tag! :AVSphoneNum, (address[:phone] ? address[:phone].scan(/\d/).join.to_s[0..13] : nil)
end
- xml.tag! :AVSname, ((creditcard && creditcard.name) ? creditcard.name[0..29] : nil)
+ xml.tag! :AVSname, (creditcard&.name ? creditcard.name[0..29] : nil)
xml.tag! :AVScountryCode, (avs_supported ? byte_limit(format_address_field(address[:country]), 2) : '')
# Needs to come after AVScountryCode
diff --git a/lib/active_merchant/billing/gateways/pay_junction_v2.rb b/lib/active_merchant/billing/gateways/pay_junction_v2.rb
index f453d1b5e75..669188c9d48 100644
--- a/lib/active_merchant/billing/gateways/pay_junction_v2.rb
+++ b/lib/active_merchant/billing/gateways/pay_junction_v2.rb
@@ -173,7 +173,7 @@ def success_from(response)
def message_from(response)
return response['response']['message'] if response['response']
- response['errors'].inject(''){ |message,error| error['message'] + '|' + message } if response['errors']
+ response['errors']&.inject(''){ |message,error| error['message'] + '|' + message }
end
def authorization_from(response)
diff --git a/lib/active_merchant/billing/gateways/payeezy.rb b/lib/active_merchant/billing/gateways/payeezy.rb
index dad7cbebd69..fc14df47d07 100644
--- a/lib/active_merchant/billing/gateways/payeezy.rb
+++ b/lib/active_merchant/billing/gateways/payeezy.rb
@@ -374,7 +374,7 @@ def authorization_from(params, response)
response['transaction_id'],
response['transaction_tag'],
params[:method],
- (response['amount'] && response['amount'].to_i)
+ response['amount']&.to_i
].join('|')
end
end
diff --git a/lib/active_merchant/billing/gateways/payex.rb b/lib/active_merchant/billing/gateways/payex.rb
index b35038ca239..82a40a46ab9 100644
--- a/lib/active_merchant/billing/gateways/payex.rb
+++ b/lib/active_merchant/billing/gateways/payex.rb
@@ -363,7 +363,7 @@ def parse(xml)
doc = Nokogiri::XML(body)
- doc.root.xpath('*').each do |node|
+ doc.root&.xpath('*')&.each do |node|
if (node.elements.size == 0)
response[node.name.downcase.to_sym] = node.text
else
@@ -372,7 +372,7 @@ def parse(xml)
response[name.to_sym] = childnode.text
end
end
- end unless doc.root.nil?
+ end
response
end
diff --git a/lib/active_merchant/billing/gateways/quickbooks.rb b/lib/active_merchant/billing/gateways/quickbooks.rb
index ed51d7266dd..c81ab1deeda 100644
--- a/lib/active_merchant/billing/gateways/quickbooks.rb
+++ b/lib/active_merchant/billing/gateways/quickbooks.rb
@@ -118,7 +118,7 @@ def add_charge_data(post, payment, options = {})
end
def add_address(post, options)
- return unless post[:card] && post[:card].kind_of?(Hash)
+ return unless post[:card]&.kind_of?(Hash)
card_address = {}
if address = options[:billing_address] || options[:address]
diff --git a/lib/active_merchant/billing/gateways/securion_pay.rb b/lib/active_merchant/billing/gateways/securion_pay.rb
index 8624ca0a6b8..c59370bad4d 100644
--- a/lib/active_merchant/billing/gateways/securion_pay.rb
+++ b/lib/active_merchant/billing/gateways/securion_pay.rb
@@ -165,7 +165,7 @@ def add_creditcard(post, creditcard, options)
end
def add_address(post, options)
- return unless post[:card] && post[:card].kind_of?(Hash)
+ return unless post[:card]&.kind_of?(Hash)
if address = options[:billing_address]
post[:card][:addressLine1] = address[:address1] if address[:address1]
post[:card][:addressLine2] = address[:address2] if address[:address2]
@@ -257,7 +257,7 @@ def json_error(raw_response)
end
def test?
- (@options[:secret_key] && @options[:secret_key].include?('_test_'))
+ (@options[:secret_key]&.include?('_test_'))
end
end
end
diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb
index 49c7077a2a8..81c2fd982cc 100644
--- a/lib/active_merchant/billing/gateways/stripe.rb
+++ b/lib/active_merchant/billing/gateways/stripe.rb
@@ -386,7 +386,7 @@ def add_customer_data(post, options)
end
def add_address(post, options)
- return unless post[:card] && post[:card].kind_of?(Hash)
+ return unless post[:card]&.kind_of?(Hash)
if address = options[:billing_address] || options[:address]
post[:card][:address_line1] = address[:address1] if address[:address1]
post[:card][:address_line2] = address[:address2] if address[:address2]
diff --git a/lib/active_merchant/billing/gateways/telr.rb b/lib/active_merchant/billing/gateways/telr.rb
index f1a38ef889d..f3938d89c9a 100644
--- a/lib/active_merchant/billing/gateways/telr.rb
+++ b/lib/active_merchant/billing/gateways/telr.rb
@@ -214,7 +214,7 @@ def parse(xml)
response = {}
doc = Nokogiri::XML(xml)
- doc.root.xpath('*').each do |node|
+ doc.root&.xpath('*')&.each do |node|
if (node.elements.size == 0)
response[node.name.downcase.to_sym] = node.text
else
@@ -223,7 +223,7 @@ def parse(xml)
response[name.to_sym] = childnode.text
end
end
- end unless doc.root.nil?
+ end
response
end
diff --git a/lib/active_merchant/connection.rb b/lib/active_merchant/connection.rb
index d7067b98636..e6731ed8566 100644
--- a/lib/active_merchant/connection.rb
+++ b/lib/active_merchant/connection.rb
@@ -61,7 +61,7 @@ def initialize(endpoint)
end
def wiredump_device=(device)
- raise ArgumentError, "can't wiredump to frozen #{device.class}" if device && device.frozen?
+ raise ArgumentError, "can't wiredump to frozen #{device.class}" if device&.frozen?
@wiredump_device = device
end
@@ -189,7 +189,7 @@ def error(message, tag = nil)
def log(level, message, tag)
message = "[#{tag}] #{message}" if tag
- logger.send(level, message) if logger
+ logger&.send(level, message)
end
end
end
diff --git a/lib/active_merchant/network_connection_retries.rb b/lib/active_merchant/network_connection_retries.rb
index db0187ffa33..0bce98f7619 100644
--- a/lib/active_merchant/network_connection_retries.rb
+++ b/lib/active_merchant/network_connection_retries.rb
@@ -65,7 +65,7 @@ def retry_network_exceptions(options = {})
def self.log(logger, level, message, tag=nil)
tag ||= self.class.to_s
message = "[#{tag}] #{message}"
- logger.send(level, message) if logger
+ logger&.send(level, message)
end
private
diff --git a/lib/active_merchant/posts_data.rb b/lib/active_merchant/posts_data.rb
index 857efa9b162..15446c09fd8 100644
--- a/lib/active_merchant/posts_data.rb
+++ b/lib/active_merchant/posts_data.rb
@@ -45,8 +45,8 @@ def ssl_request(method, endpoint, data, headers)
end
def raw_ssl_request(method, endpoint, data, headers = {})
- logger.warn "#{self.class} using ssl_strict=false, which is insecure" if logger unless ssl_strict
- logger.warn "#{self.class} posting to plaintext endpoint, which is insecure" if logger unless endpoint.to_s =~ /^https:/
+ logger&.warn "#{self.class} using ssl_strict=false, which is insecure" unless ssl_strict
+ logger&.warn "#{self.class} posting to plaintext endpoint, which is insecure" unless endpoint.to_s =~ /^https:/
connection = new_connection(endpoint)
connection.open_timeout = open_timeout
diff --git a/test/comm_stub.rb b/test/comm_stub.rb
index 2d4c95013b4..9293ef77955 100644
--- a/test/comm_stub.rb
+++ b/test/comm_stub.rb
@@ -19,7 +19,7 @@ def respond_with(*responses)
singleton_class = (class << @gateway; self; end)
singleton_class.send(:undef_method, @method_to_stub)
singleton_class.send(:define_method, @method_to_stub) do |*args|
- check.call(*args) if check
+ check&.call(*args)
(responses.size == 1 ? responses.last : responses.shift)
end
@action.call
From 17271aef2caff95820472e23f0ad393af55351e9 Mon Sep 17 00:00:00 2001
From: Filipe Costa
Date: Mon, 22 Oct 2018 22:50:15 -0400
Subject: [PATCH 0119/2234] [Payflow Express] Use phone returned from payload
on Response (#3003)
---
CHANGELOG | 1 +
.../billing/gateways/payflow/payflow_express_response.rb | 6 +++++-
test/unit/gateways/payflow_express_test.rb | 6 ++++--
3 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 029ce1e6d0d..a80da434731 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -6,6 +6,7 @@
* Barclaycard Smartpay: allow third-party payouts for credits [bpollack] #3009
* RuboCop: AlignHash [nfarve] #3004
* Beanstream: Switch `recurringPayment` flag from boolean to integer [dtykocki] #3011
+* Payflow Express: Add phone to returned Response [filipebarcos] [#3003]
== Version 1.85.0 (September 28, 2018)
* Authorize.Net: Support custom delimiter for cim [curiousepic] [#3001]
diff --git a/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb b/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb
index 0c01ee481b2..3c43642265f 100644
--- a/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb
+++ b/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb
@@ -22,6 +22,10 @@ def payer_country
address['country']
end
+ def phone
+ @params['phone']
+ end
+
def address
{ 'name' => @params['shiptoname'] || full_name,
'company' => nil,
@@ -31,7 +35,7 @@ def address
'state' => @params['state'],
'country' => @params['country'],
'zip' => @params['zip'],
- 'phone' => nil
+ 'phone' => phone,
}
end
end
diff --git a/test/unit/gateways/payflow_express_test.rb b/test/unit/gateways/payflow_express_test.rb
index a78238a6a3a..ef8fab1fcb4 100644
--- a/test/unit/gateways/payflow_express_test.rb
+++ b/test/unit/gateways/payflow_express_test.rb
@@ -114,7 +114,7 @@ def test_get_express_details
assert_equal 'CA', address['state']
assert_equal '95100', address['zip']
assert_equal 'US', address['country']
- assert_nil address['phone']
+ assert_equal '555-555-5555', address['phone']
end
def test_get_express_details_with_ship_to_name
@@ -139,7 +139,7 @@ def test_get_express_details_with_ship_to_name
assert_equal 'CA', address['state']
assert_equal '95100', address['zip']
assert_equal 'US', address['country']
- assert_nil address['phone']
+ assert_equal '555-555-5555', address['phone']
end
def test_get_express_details_with_invalid_xml
@@ -179,6 +179,7 @@ def successful_get_express_details_response(options={:street => '111 Main St.'})
0
verified
Joe
+ 555-555-5555
#{options[:street]}
@@ -215,6 +216,7 @@ def successful_get_express_details_response_with_ship_to_name
0
verified
Joe
+ 555-555-5555
111 Main St.
From 8d47d02a628abefa642a043b4ecf327528992abe Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Tue, 23 Oct 2018 09:12:36 -0400
Subject: [PATCH 0120/2234] Mercado Pago: tighten brand testing in unit tests
This patch as-is amounts to a no-op, but is getting added so that the
subsequent patch will *fail*, making it clearer what the upcoming patch
does.
Unit: 19 tests, 92 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
test/unit/gateways/mercado_pago_test.rb | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/test/unit/gateways/mercado_pago_test.rb b/test/unit/gateways/mercado_pago_test.rb
index 1f6d043b612..7b29e5252c8 100644
--- a/test/unit/gateways/mercado_pago_test.rb
+++ b/test/unit/gateways/mercado_pago_test.rb
@@ -155,8 +155,8 @@ def test_sends_american_express_as_amex
response = stub_comms do
@gateway.purchase(@amount, credit_card, @options)
end.check_request do |endpoint, data, headers|
- if data =~ /"payment_method_id"/
- assert_match(%r(amex), data)
+ if endpoint =~ /payments/
+ assert_match(%r("payment_method_id":"amex"), data)
end
end.respond_with(successful_purchase_response)
@@ -170,8 +170,8 @@ def test_sends_diners_club_as_diners
response = stub_comms do
@gateway.purchase(@amount, credit_card, @options)
end.check_request do |endpoint, data, headers|
- if data =~ /"payment_method_id"/
- assert_match(%r(diners), data)
+ if endpoint =~ /payments/
+ assert_match(%r("payment_method_id":"diners"), data)
end
end.respond_with(successful_purchase_response)
@@ -185,8 +185,8 @@ def test_sends_mastercard_as_master
response = stub_comms do
@gateway.purchase(@amount, credit_card, @options)
end.check_request do |endpoint, data, headers|
- if data =~ /"payment_method_id"/
- assert_match(%r(master), data)
+ if endpoint =~ /payments/
+ assert_match(%r("payment_method_id":"master"), data)
end
end.respond_with(successful_purchase_response)
From d9c5a1a011263c5677e7d0dc084d5fc2d16193ff Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Fri, 19 Oct 2018 12:22:18 -0400
Subject: [PATCH 0121/2234] Mercado Pago: do not infer card type
Allow the card type to be passed in explicitly instead via the
:payment_method_id option. Additionally, allow sending the :issuer_id.
Unit: 19 tests, 93 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote: 17 tests, 46 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
.../billing/gateways/mercado_pago.rb | 10 +----
test/unit/gateways/mercado_pago_test.rb | 38 +++++++++----------
2 files changed, 20 insertions(+), 28 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/mercado_pago.rb b/lib/active_merchant/billing/gateways/mercado_pago.rb
index 3c841fccc53..51aafc8f457 100644
--- a/lib/active_merchant/billing/gateways/mercado_pago.rb
+++ b/lib/active_merchant/billing/gateways/mercado_pago.rb
@@ -10,11 +10,6 @@ class MercadoPagoGateway < Gateway
self.display_name = 'Mercado Pago'
self.money_format = :dollars
- CARD_BRAND = {
- 'american_express' => 'amex',
- 'diners_club' => 'diners'
- }
-
def initialize(options={})
requires!(options, :access_token)
super
@@ -23,7 +18,6 @@ def initialize(options={})
def purchase(money, payment, options={})
MultiResponse.run do |r|
r.process { commit('tokenize', 'card_tokens', card_token_request(money, payment, options)) }
- options.merge!(card_brand: (CARD_BRAND[payment.brand] || payment.brand))
options.merge!(card_token: r.authorization.split('|').first)
r.process { commit('purchase', 'payments', purchase_request(money, payment, options) ) }
end
@@ -32,7 +26,6 @@ def purchase(money, payment, options={})
def authorize(money, payment, options={})
MultiResponse.run do |r|
r.process { commit('tokenize', 'card_tokens', card_token_request(money, payment, options)) }
- options.merge!(card_brand: (CARD_BRAND[payment.brand] || payment.brand))
options.merge!(card_token: r.authorization.split('|').first)
r.process { commit('authorize', 'payments', authorize_request(money, payment, options) ) }
end
@@ -181,7 +174,8 @@ def add_invoice(post, money, options)
def add_payment(post, options)
post[:token] = options[:card_token]
- post[:payment_method_id] = options[:card_brand]
+ post[:issuer_id] = options[:issuer_id] if options[:issuer_id]
+ post[:payment_method_id] = options[:payment_method_id] if options[:payment_method_id]
end
def parse(body)
diff --git a/test/unit/gateways/mercado_pago_test.rb b/test/unit/gateways/mercado_pago_test.rb
index 7b29e5252c8..1e53016dde3 100644
--- a/test/unit/gateways/mercado_pago_test.rb
+++ b/test/unit/gateways/mercado_pago_test.rb
@@ -149,14 +149,14 @@ def test_scrub
assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed
end
- def test_sends_american_express_as_amex
+ def test_does_not_send_brand
credit_card = credit_card('378282246310005', brand: 'american_express')
response = stub_comms do
@gateway.purchase(@amount, credit_card, @options)
end.check_request do |endpoint, data, headers|
if endpoint =~ /payments/
- assert_match(%r("payment_method_id":"amex"), data)
+ assert_not_match(%r("payment_method_id":"amex"), data)
end
end.respond_with(successful_purchase_response)
@@ -164,11 +164,11 @@ def test_sends_american_express_as_amex
assert_equal '4141491|1.0', response.authorization
end
- def test_sends_diners_club_as_diners
- credit_card = credit_card('30569309025904', brand: 'diners_club')
+ def test_sends_payment_method_id
+ credit_card = credit_card('30569309025904')
response = stub_comms do
- @gateway.purchase(@amount, credit_card, @options)
+ @gateway.purchase(@amount, credit_card, @options.merge(payment_method_id: 'diners'))
end.check_request do |endpoint, data, headers|
if endpoint =~ /payments/
assert_match(%r("payment_method_id":"diners"), data)
@@ -179,21 +179,6 @@ def test_sends_diners_club_as_diners
assert_equal '4141491|1.0', response.authorization
end
- def test_sends_mastercard_as_master
- credit_card = credit_card('5555555555554444', brand: 'master')
-
- response = stub_comms do
- @gateway.purchase(@amount, credit_card, @options)
- end.check_request do |endpoint, data, headers|
- if endpoint =~ /payments/
- assert_match(%r("payment_method_id":"master"), data)
- end
- end.respond_with(successful_purchase_response)
-
- assert_success response
- assert_equal '4141491|1.0', response.authorization
- end
-
def test_includes_deviceid_header
@options[:device_id] = '1a2b3c'
@gateway.expects(:ssl_post).with(anything, anything, headers = {'Content-Type' => 'application/json'}).returns(successful_purchase_response)
@@ -217,6 +202,19 @@ def test_includes_additional_data
assert_success response
end
+ def test_includes_issuer_id
+ response = stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options.merge(issuer_id: '1a2b3c4d'))
+ end.check_request do |endpoint, data, headers|
+ if endpoint =~ /payments/
+ assert_match(%r("issuer_id":"1a2b3c4d"), data)
+ end
+ end.respond_with(successful_purchase_response)
+
+ assert_success response
+ assert_equal '4141491|1.0', response.authorization
+ end
+
private
def pre_scrubbed
From 7b4d1ac805d3396a8cb8b37a4d82735dbf7df311 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Mon, 22 Oct 2018 16:35:20 -0400
Subject: [PATCH 0122/2234] RuboCop: fix Layout/TrailingBlankLines
---
.rubocop_todo.yml | 7 -------
lib/active_merchant/billing/compatibility.rb | 1 -
lib/active_merchant/billing/gateways/beanstream_interac.rb | 1 -
lib/active_merchant/billing/gateways/card_save.rb | 1 -
lib/active_merchant/billing/gateways/citrus_pay.rb | 1 -
lib/active_merchant/billing/gateways/exact.rb | 1 -
lib/active_merchant/billing/gateways/federated_canada.rb | 1 -
lib/active_merchant/billing/gateways/finansbank.rb | 1 -
lib/active_merchant/billing/gateways/first_giving.rb | 1 -
lib/active_merchant/billing/gateways/garanti.rb | 1 -
lib/active_merchant/billing/gateways/hdfc.rb | 1 -
lib/active_merchant/billing/gateways/inspire.rb | 1 -
lib/active_merchant/billing/gateways/instapay.rb | 1 -
lib/active_merchant/billing/gateways/itransact.rb | 1 -
lib/active_merchant/billing/gateways/merchant_one.rb | 1 -
lib/active_merchant/billing/gateways/modern_payments.rb | 1 -
.../billing/gateways/modern_payments_cim.rb | 1 -
lib/active_merchant/billing/gateways/money_movers.rb | 1 -
lib/active_merchant/billing/gateways/netaxept.rb | 1 -
lib/active_merchant/billing/gateways/network_merchants.rb | 1 -
lib/active_merchant/billing/gateways/pac_net_raven.rb | 1 -
lib/active_merchant/billing/gateways/pay_gate_xml.rb | 2 +-
lib/active_merchant/billing/gateways/pay_secure.rb | 1 -
lib/active_merchant/billing/gateways/payex.rb | 1 -
.../billing/gateways/payflow/payflow_response.rb | 2 +-
lib/active_merchant/billing/gateways/payflow_express_uk.rb | 1 -
lib/active_merchant/billing/gateways/payflow_uk.rb | 1 -
lib/active_merchant/billing/gateways/payscout.rb | 1 -
lib/active_merchant/billing/gateways/quickpay.rb | 1 -
.../billing/gateways/quickpay/quickpay_v4to7.rb | 1 -
lib/active_merchant/billing/gateways/sallie_mae.rb | 1 -
lib/active_merchant/billing/gateways/secure_pay.rb | 1 -
lib/active_merchant/billing/gateways/secure_pay_tech.rb | 1 -
lib/active_merchant/billing/gateways/smart_ps.rb | 1 -
lib/active_merchant/billing/gateways/swipe_checkout.rb | 1 -
lib/active_merchant/billing/gateways/transax.rb | 1 -
lib/active_merchant/billing/gateways/transnational.rb | 1 -
lib/activemerchant.rb | 2 +-
lib/support/gateway_support.rb | 1 -
test/remote/gateways/remote_inspire_test.rb | 2 --
test/remote/gateways/remote_so_easy_pay_test.rb | 1 -
test/remote/gateways/remote_stripe_android_pay_test.rb | 2 +-
test/remote/gateways/remote_stripe_apple_pay_test.rb | 1 -
test/remote/gateways/remote_viaklix_test.rb | 2 +-
test/unit/cvv_result_test.rb | 2 +-
test/unit/expiry_date_test.rb | 2 +-
test/unit/gateways/in_context_paypal_express_test.rb | 1 -
test/unit/gateways/inspire_test.rb | 1 -
test/unit/gateways/instapay_test.rb | 1 -
test/unit/gateways/opp_test.rb | 1 -
test/unit/gateways/paypal_digital_goods_test.rb | 1 -
test/unit/gateways/psl_card_test.rb | 2 +-
test/unit/gateways/quickpay_test.rb | 1 -
test/unit/gateways/skip_jack_test.rb | 1 -
test/unit/gateways/so_easy_pay_test.rb | 1 -
test/unit/gateways/viaklix_test.rb | 2 +-
56 files changed, 9 insertions(+), 63 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 9be5fbc942b..ba51669d47e 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -252,13 +252,6 @@ Layout/Tab:
- 'lib/active_merchant/billing/gateways/trust_commerce.rb'
- 'test/remote/gateways/remote_orbital_test.rb'
-# Offense count: 57
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle.
-# SupportedStyles: final_newline, final_blank_line
-Layout/TrailingBlankLines:
- Enabled: false
-
# Offense count: 357
# Cop supports --auto-correct.
# Configuration parameters: AllowInHeredoc.
diff --git a/lib/active_merchant/billing/compatibility.rb b/lib/active_merchant/billing/compatibility.rb
index 87b7790440f..df999f60ed3 100644
--- a/lib/active_merchant/billing/compatibility.rb
+++ b/lib/active_merchant/billing/compatibility.rb
@@ -115,4 +115,3 @@ def full_messages
Compatibility::Model.send(:include, Rails::Model)
end
end
-
diff --git a/lib/active_merchant/billing/gateways/beanstream_interac.rb b/lib/active_merchant/billing/gateways/beanstream_interac.rb
index 836f686607d..37ca7595a31 100644
--- a/lib/active_merchant/billing/gateways/beanstream_interac.rb
+++ b/lib/active_merchant/billing/gateways/beanstream_interac.rb
@@ -55,4 +55,3 @@ def build_response(*args)
end
end
end
-
diff --git a/lib/active_merchant/billing/gateways/card_save.rb b/lib/active_merchant/billing/gateways/card_save.rb
index 48c7decf336..821ba3c3b6a 100644
--- a/lib/active_merchant/billing/gateways/card_save.rb
+++ b/lib/active_merchant/billing/gateways/card_save.rb
@@ -20,4 +20,3 @@ def initialize(options={})
end
end
end
-
diff --git a/lib/active_merchant/billing/gateways/citrus_pay.rb b/lib/active_merchant/billing/gateways/citrus_pay.rb
index 3b12c5deaf6..00ab762d196 100644
--- a/lib/active_merchant/billing/gateways/citrus_pay.rb
+++ b/lib/active_merchant/billing/gateways/citrus_pay.rb
@@ -20,4 +20,3 @@ class CitrusPayGateway < Gateway
end
end
end
-
diff --git a/lib/active_merchant/billing/gateways/exact.rb b/lib/active_merchant/billing/gateways/exact.rb
index 915a1a82c5d..6858ef98aa6 100644
--- a/lib/active_merchant/billing/gateways/exact.rb
+++ b/lib/active_merchant/billing/gateways/exact.rb
@@ -222,4 +222,3 @@ def parse_elements(response, root)
end
end
end
-
diff --git a/lib/active_merchant/billing/gateways/federated_canada.rb b/lib/active_merchant/billing/gateways/federated_canada.rb
index 404e8bebd60..639fd3a3aff 100644
--- a/lib/active_merchant/billing/gateways/federated_canada.rb
+++ b/lib/active_merchant/billing/gateways/federated_canada.rb
@@ -157,4 +157,3 @@ def post_data(action, parameters = {})
end
end
end
-
diff --git a/lib/active_merchant/billing/gateways/finansbank.rb b/lib/active_merchant/billing/gateways/finansbank.rb
index 144f798abfe..5f496570853 100644
--- a/lib/active_merchant/billing/gateways/finansbank.rb
+++ b/lib/active_merchant/billing/gateways/finansbank.rb
@@ -20,4 +20,3 @@ class FinansbankGateway < CC5Gateway
end
end
end
-
diff --git a/lib/active_merchant/billing/gateways/first_giving.rb b/lib/active_merchant/billing/gateways/first_giving.rb
index 65bd5256104..975409638d7 100644
--- a/lib/active_merchant/billing/gateways/first_giving.rb
+++ b/lib/active_merchant/billing/gateways/first_giving.rb
@@ -140,4 +140,3 @@ def headers
end
end
end
-
diff --git a/lib/active_merchant/billing/gateways/garanti.rb b/lib/active_merchant/billing/gateways/garanti.rb
index fbd202ceee6..5a95e3383db 100644
--- a/lib/active_merchant/billing/gateways/garanti.rb
+++ b/lib/active_merchant/billing/gateways/garanti.rb
@@ -257,4 +257,3 @@ def strip_invalid_xml_chars(xml)
end
end
end
-
diff --git a/lib/active_merchant/billing/gateways/hdfc.rb b/lib/active_merchant/billing/gateways/hdfc.rb
index 01404cd8d00..f10438b0b47 100644
--- a/lib/active_merchant/billing/gateways/hdfc.rb
+++ b/lib/active_merchant/billing/gateways/hdfc.rb
@@ -204,4 +204,3 @@ def escape(string, max_length=250)
end
end
end
-
diff --git a/lib/active_merchant/billing/gateways/inspire.rb b/lib/active_merchant/billing/gateways/inspire.rb
index 324f1f8bb5f..f7ee068cdf0 100644
--- a/lib/active_merchant/billing/gateways/inspire.rb
+++ b/lib/active_merchant/billing/gateways/inspire.rb
@@ -216,4 +216,3 @@ def determine_funding_source(source)
end
end
end
-
diff --git a/lib/active_merchant/billing/gateways/instapay.rb b/lib/active_merchant/billing/gateways/instapay.rb
index d2ef3f9d13b..7d18c8da05b 100644
--- a/lib/active_merchant/billing/gateways/instapay.rb
+++ b/lib/active_merchant/billing/gateways/instapay.rb
@@ -160,4 +160,3 @@ def post_data(action, parameters = {})
end
end
end
-
diff --git a/lib/active_merchant/billing/gateways/itransact.rb b/lib/active_merchant/billing/gateways/itransact.rb
index 0d96f7556e6..b0329417f44 100644
--- a/lib/active_merchant/billing/gateways/itransact.rb
+++ b/lib/active_merchant/billing/gateways/itransact.rb
@@ -445,4 +445,3 @@ def sign_payload(payload)
end
end
end
-
diff --git a/lib/active_merchant/billing/gateways/merchant_one.rb b/lib/active_merchant/billing/gateways/merchant_one.rb
index c65149bed62..a514a9e6107 100644
--- a/lib/active_merchant/billing/gateways/merchant_one.rb
+++ b/lib/active_merchant/billing/gateways/merchant_one.rb
@@ -111,4 +111,3 @@ def parse(data)
end
end
end
-
diff --git a/lib/active_merchant/billing/gateways/modern_payments.rb b/lib/active_merchant/billing/gateways/modern_payments.rb
index d94d12cb6d9..c5846f7a079 100644
--- a/lib/active_merchant/billing/gateways/modern_payments.rb
+++ b/lib/active_merchant/billing/gateways/modern_payments.rb
@@ -35,4 +35,3 @@ def cim
end
end
end
-
diff --git a/lib/active_merchant/billing/gateways/modern_payments_cim.rb b/lib/active_merchant/billing/gateways/modern_payments_cim.rb
index 7420ff6cd23..0d9ef36fc3e 100644
--- a/lib/active_merchant/billing/gateways/modern_payments_cim.rb
+++ b/lib/active_merchant/billing/gateways/modern_payments_cim.rb
@@ -215,4 +215,3 @@ def parse_element(response, node)
end
end
end
-
diff --git a/lib/active_merchant/billing/gateways/money_movers.rb b/lib/active_merchant/billing/gateways/money_movers.rb
index a41b57abeb5..870b47d2ac4 100644
--- a/lib/active_merchant/billing/gateways/money_movers.rb
+++ b/lib/active_merchant/billing/gateways/money_movers.rb
@@ -149,4 +149,3 @@ def post_data(action, parameters = {})
end
end
end
-
diff --git a/lib/active_merchant/billing/gateways/netaxept.rb b/lib/active_merchant/billing/gateways/netaxept.rb
index b3f1652c662..f142ce5a968 100644
--- a/lib/active_merchant/billing/gateways/netaxept.rb
+++ b/lib/active_merchant/billing/gateways/netaxept.rb
@@ -178,4 +178,3 @@ def encode(hash)
end
end
end
-
diff --git a/lib/active_merchant/billing/gateways/network_merchants.rb b/lib/active_merchant/billing/gateways/network_merchants.rb
index b684e92c5a8..aadc09d425f 100644
--- a/lib/active_merchant/billing/gateways/network_merchants.rb
+++ b/lib/active_merchant/billing/gateways/network_merchants.rb
@@ -239,4 +239,3 @@ def parse(raw_response)
end
end
end
-
diff --git a/lib/active_merchant/billing/gateways/pac_net_raven.rb b/lib/active_merchant/billing/gateways/pac_net_raven.rb
index 1fd15b5c0ae..631e1441175 100644
--- a/lib/active_merchant/billing/gateways/pac_net_raven.rb
+++ b/lib/active_merchant/billing/gateways/pac_net_raven.rb
@@ -204,4 +204,3 @@ def signature(action, post, parameters = {})
end
end
end
-
diff --git a/lib/active_merchant/billing/gateways/pay_gate_xml.rb b/lib/active_merchant/billing/gateways/pay_gate_xml.rb
index 55c9b7b67af..572ae9d7066 100644
--- a/lib/active_merchant/billing/gateways/pay_gate_xml.rb
+++ b/lib/active_merchant/billing/gateways/pay_gate_xml.rb
@@ -274,4 +274,4 @@ def message_from(response)
end
end
end
-end
\ No newline at end of file
+end
diff --git a/lib/active_merchant/billing/gateways/pay_secure.rb b/lib/active_merchant/billing/gateways/pay_secure.rb
index 72be0071d10..bbdfc2bacf9 100644
--- a/lib/active_merchant/billing/gateways/pay_secure.rb
+++ b/lib/active_merchant/billing/gateways/pay_secure.rb
@@ -109,4 +109,3 @@ def post_data(action, parameters = {})
end
end
end
-
diff --git a/lib/active_merchant/billing/gateways/payex.rb b/lib/active_merchant/billing/gateways/payex.rb
index 82a40a46ab9..03aa3f24a9b 100644
--- a/lib/active_merchant/billing/gateways/payex.rb
+++ b/lib/active_merchant/billing/gateways/payex.rb
@@ -408,4 +408,3 @@ def message_from(response)
end
end
end
-
diff --git a/lib/active_merchant/billing/gateways/payflow/payflow_response.rb b/lib/active_merchant/billing/gateways/payflow/payflow_response.rb
index 21f6b5cb868..e888ea2fec1 100644
--- a/lib/active_merchant/billing/gateways/payflow/payflow_response.rb
+++ b/lib/active_merchant/billing/gateways/payflow/payflow_response.rb
@@ -10,4 +10,4 @@ def payment_history
end
end
end
-end
\ No newline at end of file
+end
diff --git a/lib/active_merchant/billing/gateways/payflow_express_uk.rb b/lib/active_merchant/billing/gateways/payflow_express_uk.rb
index 79bf204de91..a314bad48c4 100644
--- a/lib/active_merchant/billing/gateways/payflow_express_uk.rb
+++ b/lib/active_merchant/billing/gateways/payflow_express_uk.rb
@@ -12,4 +12,3 @@ class PayflowExpressUkGateway < PayflowExpressGateway
end
end
end
-
diff --git a/lib/active_merchant/billing/gateways/payflow_uk.rb b/lib/active_merchant/billing/gateways/payflow_uk.rb
index 7d67610438f..e963c152ef0 100644
--- a/lib/active_merchant/billing/gateways/payflow_uk.rb
+++ b/lib/active_merchant/billing/gateways/payflow_uk.rb
@@ -18,4 +18,3 @@ def express
end
end
end
-
diff --git a/lib/active_merchant/billing/gateways/payscout.rb b/lib/active_merchant/billing/gateways/payscout.rb
index 7596dddccbc..88fb8624655 100644
--- a/lib/active_merchant/billing/gateways/payscout.rb
+++ b/lib/active_merchant/billing/gateways/payscout.rb
@@ -158,4 +158,3 @@ def post_data(action, parameters = {})
end
end
end
-
diff --git a/lib/active_merchant/billing/gateways/quickpay.rb b/lib/active_merchant/billing/gateways/quickpay.rb
index 34d36f93196..5c1f6fb33bb 100644
--- a/lib/active_merchant/billing/gateways/quickpay.rb
+++ b/lib/active_merchant/billing/gateways/quickpay.rb
@@ -23,4 +23,3 @@ def self.new(options = {})
end
end
end
-
diff --git a/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb b/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb
index 95fae367036..a43fb085838 100644
--- a/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb
+++ b/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb
@@ -224,4 +224,3 @@ def format_order_number(number)
end
end
end
-
diff --git a/lib/active_merchant/billing/gateways/sallie_mae.rb b/lib/active_merchant/billing/gateways/sallie_mae.rb
index 510273a1fc4..7e15f08e232 100644
--- a/lib/active_merchant/billing/gateways/sallie_mae.rb
+++ b/lib/active_merchant/billing/gateways/sallie_mae.rb
@@ -140,4 +140,3 @@ def message_from(response)
end
end
end
-
diff --git a/lib/active_merchant/billing/gateways/secure_pay.rb b/lib/active_merchant/billing/gateways/secure_pay.rb
index 68d32c5b5c2..656e360940c 100644
--- a/lib/active_merchant/billing/gateways/secure_pay.rb
+++ b/lib/active_merchant/billing/gateways/secure_pay.rb
@@ -198,4 +198,3 @@ def split(response)
end
end
end
-
diff --git a/lib/active_merchant/billing/gateways/secure_pay_tech.rb b/lib/active_merchant/billing/gateways/secure_pay_tech.rb
index 5a6036afcd1..3cf645f8838 100644
--- a/lib/active_merchant/billing/gateways/secure_pay_tech.rb
+++ b/lib/active_merchant/billing/gateways/secure_pay_tech.rb
@@ -102,4 +102,3 @@ def post_data(action, post)
end
end
end
-
diff --git a/lib/active_merchant/billing/gateways/smart_ps.rb b/lib/active_merchant/billing/gateways/smart_ps.rb
index 0b9841189e9..b6a89f13b39 100644
--- a/lib/active_merchant/billing/gateways/smart_ps.rb
+++ b/lib/active_merchant/billing/gateways/smart_ps.rb
@@ -278,4 +278,3 @@ def determine_funding_source(source)
end
end
end
-
diff --git a/lib/active_merchant/billing/gateways/swipe_checkout.rb b/lib/active_merchant/billing/gateways/swipe_checkout.rb
index ea0bbc3b925..dcd63d1fdec 100644
--- a/lib/active_merchant/billing/gateways/swipe_checkout.rb
+++ b/lib/active_merchant/billing/gateways/swipe_checkout.rb
@@ -150,4 +150,3 @@ def build_error_response(message, params={})
end
end
end
-
diff --git a/lib/active_merchant/billing/gateways/transax.rb b/lib/active_merchant/billing/gateways/transax.rb
index c11c830bac9..7411ad573c4 100644
--- a/lib/active_merchant/billing/gateways/transax.rb
+++ b/lib/active_merchant/billing/gateways/transax.rb
@@ -20,4 +20,3 @@ class TransaxGateway < SmartPs
end
end
end
-
diff --git a/lib/active_merchant/billing/gateways/transnational.rb b/lib/active_merchant/billing/gateways/transnational.rb
index bce37f5eede..350a2e91857 100644
--- a/lib/active_merchant/billing/gateways/transnational.rb
+++ b/lib/active_merchant/billing/gateways/transnational.rb
@@ -7,4 +7,3 @@ class TransnationalGateway < NetworkMerchantsGateway
end
end
end
-
diff --git a/lib/activemerchant.rb b/lib/activemerchant.rb
index 0a3f08fee3f..118568f06b3 100644
--- a/lib/activemerchant.rb
+++ b/lib/activemerchant.rb
@@ -1 +1 @@
-require 'active_merchant'
\ No newline at end of file
+require 'active_merchant'
diff --git a/lib/support/gateway_support.rb b/lib/support/gateway_support.rb
index 1ae661a6375..84cf58df2fc 100644
--- a/lib/support/gateway_support.rb
+++ b/lib/support/gateway_support.rb
@@ -67,4 +67,3 @@ def to_s
end
end
end
-
diff --git a/test/remote/gateways/remote_inspire_test.rb b/test/remote/gateways/remote_inspire_test.rb
index d9594ceda57..221ea62b17a 100644
--- a/test/remote/gateways/remote_inspire_test.rb
+++ b/test/remote/gateways/remote_inspire_test.rb
@@ -159,5 +159,3 @@ def test_invalid_login
assert_failure response
end
end
-
-
diff --git a/test/remote/gateways/remote_so_easy_pay_test.rb b/test/remote/gateways/remote_so_easy_pay_test.rb
index 791a5343505..e24d837703b 100644
--- a/test/remote/gateways/remote_so_easy_pay_test.rb
+++ b/test/remote/gateways/remote_so_easy_pay_test.rb
@@ -62,4 +62,3 @@ def test_invalid_login
assert_equal 'Website verification failed, wrong websiteID or password', response.message
end
end
-
diff --git a/test/remote/gateways/remote_stripe_android_pay_test.rb b/test/remote/gateways/remote_stripe_android_pay_test.rb
index 10631d08d2c..5abf0974a17 100644
--- a/test/remote/gateways/remote_stripe_android_pay_test.rb
+++ b/test/remote/gateways/remote_stripe_android_pay_test.rb
@@ -45,4 +45,4 @@ def test_successful_auth_with_android_pay_raw_cryptogram
assert_equal 'wow@example.com', response.params['metadata']['email']
assert_match CHARGE_ID_REGEX, response.authorization
end
-end
\ No newline at end of file
+end
diff --git a/test/remote/gateways/remote_stripe_apple_pay_test.rb b/test/remote/gateways/remote_stripe_apple_pay_test.rb
index d7d966ddb45..c5231114490 100644
--- a/test/remote/gateways/remote_stripe_apple_pay_test.rb
+++ b/test/remote/gateways/remote_stripe_apple_pay_test.rb
@@ -163,4 +163,3 @@ def test_successful_auth_with_apple_pay_raw_cryptogram_without_eci
end
end
-
diff --git a/test/remote/gateways/remote_viaklix_test.rb b/test/remote/gateways/remote_viaklix_test.rb
index 02b2bf06df8..952d3a62a43 100644
--- a/test/remote/gateways/remote_viaklix_test.rb
+++ b/test/remote/gateways/remote_viaklix_test.rb
@@ -40,4 +40,4 @@ def test_credit
assert credit = @gateway.credit(@amount, @credit_card)
assert_success credit
end
-end
\ No newline at end of file
+end
diff --git a/test/unit/cvv_result_test.rb b/test/unit/cvv_result_test.rb
index 12ed48d1e35..ac44bdf24b1 100644
--- a/test/unit/cvv_result_test.rb
+++ b/test/unit/cvv_result_test.rb
@@ -30,4 +30,4 @@ def test_to_hash
assert_equal 'M', result['code']
assert_equal CVVResult.messages['M'], result['message']
end
-end
\ No newline at end of file
+end
diff --git a/test/unit/expiry_date_test.rb b/test/unit/expiry_date_test.rb
index 0306b339447..25e2e22bc0b 100644
--- a/test/unit/expiry_date_test.rb
+++ b/test/unit/expiry_date_test.rb
@@ -29,4 +29,4 @@ def test_month_and_year_coerced_to_integer
assert_equal 13, expiry.month
assert_equal 2009, expiry.year
end
-end
\ No newline at end of file
+end
diff --git a/test/unit/gateways/in_context_paypal_express_test.rb b/test/unit/gateways/in_context_paypal_express_test.rb
index 4760bf50e5b..4e92dc3032a 100644
--- a/test/unit/gateways/in_context_paypal_express_test.rb
+++ b/test/unit/gateways/in_context_paypal_express_test.rb
@@ -40,4 +40,3 @@ def test_test_redirect_url_without_review
assert_equal TEST_REDIRECT_URL_WITHOUT_REVIEW, @gateway.redirect_url_for('1234567890', review: false)
end
end
-
diff --git a/test/unit/gateways/inspire_test.rb b/test/unit/gateways/inspire_test.rb
index 1bb0ea565e8..6aac648f1da 100644
--- a/test/unit/gateways/inspire_test.rb
+++ b/test/unit/gateways/inspire_test.rb
@@ -140,4 +140,3 @@ def failed_refund_response
'response=3&responsetext=Invalid Transaction ID specified REFID:3150951931&authcode=&transactionid=&avsresponse=&cvvresponse=&orderid=&type=refund&response_code=300'
end
end
-
diff --git a/test/unit/gateways/instapay_test.rb b/test/unit/gateways/instapay_test.rb
index acd35d3027b..16880aab17f 100644
--- a/test/unit/gateways/instapay_test.rb
+++ b/test/unit/gateways/instapay_test.rb
@@ -99,4 +99,3 @@ def failed_capture_response
"\r\nDeclined=DECLINED:1101450002:Post amount exceeds Auth amount:\r\nhistoryid=\r\norderid=\r\nDeclined=DECLINED:1101450002:Post amount exceeds Auth amount:\r\nrcode=1101450002\r\nReason=DECLINED:1101450002:Post amount exceeds Auth amount:\r\nresult=0\r\nStatus=Declined\r\ntransid=0\r\n"
end
end
-
diff --git a/test/unit/gateways/opp_test.rb b/test/unit/gateways/opp_test.rb
index 93d33190471..3c7ccf84ae3 100644
--- a/test/unit/gateways/opp_test.rb
+++ b/test/unit/gateways/opp_test.rb
@@ -213,4 +213,3 @@ def initialize(code, body)
end
end
-
diff --git a/test/unit/gateways/paypal_digital_goods_test.rb b/test/unit/gateways/paypal_digital_goods_test.rb
index cef8d773b49..9e46f0036d6 100644
--- a/test/unit/gateways/paypal_digital_goods_test.rb
+++ b/test/unit/gateways/paypal_digital_goods_test.rb
@@ -120,4 +120,3 @@ def successful_setup_response
end
end
-
diff --git a/test/unit/gateways/psl_card_test.rb b/test/unit/gateways/psl_card_test.rb
index 8e31f389338..9ef1a651b84 100644
--- a/test/unit/gateways/psl_card_test.rb
+++ b/test/unit/gateways/psl_card_test.rb
@@ -62,4 +62,4 @@ def successful_purchase_response
def unsuccessful_purchase_response
'ResponseCode=05&Message=CARD DECLINED&QAAddress=The Parkway Larches Approach Hull North Humberside&QAPostcode=HU7 9OP&MerchantName=Merchant Name&QAName='
end
-end
\ No newline at end of file
+end
diff --git a/test/unit/gateways/quickpay_test.rb b/test/unit/gateways/quickpay_test.rb
index 3ce28fd9070..98bb37cb941 100644
--- a/test/unit/gateways/quickpay_test.rb
+++ b/test/unit/gateways/quickpay_test.rb
@@ -19,4 +19,3 @@ def test_v10
end
end
-
diff --git a/test/unit/gateways/skip_jack_test.rb b/test/unit/gateways/skip_jack_test.rb
index d1faca21da2..45f70914506 100644
--- a/test/unit/gateways/skip_jack_test.rb
+++ b/test/unit/gateways/skip_jack_test.rb
@@ -276,4 +276,3 @@ def successful_paymentech_authorization_response
CSV
end
end
-
diff --git a/test/unit/gateways/so_easy_pay_test.rb b/test/unit/gateways/so_easy_pay_test.rb
index 1dead1bd716..94a7f913a80 100644
--- a/test/unit/gateways/so_easy_pay_test.rb
+++ b/test/unit/gateways/so_easy_pay_test.rb
@@ -222,4 +222,3 @@ def failed_credit_response
end
end
-
diff --git a/test/unit/gateways/viaklix_test.rb b/test/unit/gateways/viaklix_test.rb
index ea24cf3f3e2..6b624676452 100644
--- a/test/unit/gateways/viaklix_test.rb
+++ b/test/unit/gateways/viaklix_test.rb
@@ -75,4 +75,4 @@ def invalid_login_response
ssl_result_message=The viaKLIX ID and/or User ID supplied in the authorization request is invalid.\r
RESPONSE
end
-end
\ No newline at end of file
+end
From edcc2fe4daf33b571b960408fe6a99b44487201a Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Mon, 22 Oct 2018 16:44:30 -0400
Subject: [PATCH 0123/2234] RuboCop: fix Layout/Tab
---
.rubocop_todo.yml | 11 -----------
.../billing/gateways/braintree_blue.rb | 4 ++--
.../billing/gateways/efsnet.rb | 18 +++++++++---------
.../billing/gateways/pagarme.rb | 2 +-
.../billing/gateways/trust_commerce.rb | 10 +++++-----
test/remote/gateways/remote_orbital_test.rb | 19 ++++++++++---------
6 files changed, 27 insertions(+), 37 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index ba51669d47e..a3681855ba4 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -241,17 +241,6 @@ Layout/SpaceInsideStringInterpolation:
- 'lib/active_merchant/billing/gateways/trust_commerce.rb'
- 'test/unit/gateways/worldpay_test.rb'
-# Offense count: 27
-# Cop supports --auto-correct.
-# Configuration parameters: IndentationWidth.
-Layout/Tab:
- Exclude:
- - 'lib/active_merchant/billing/gateways/braintree_blue.rb'
- - 'lib/active_merchant/billing/gateways/efsnet.rb'
- - 'lib/active_merchant/billing/gateways/pagarme.rb'
- - 'lib/active_merchant/billing/gateways/trust_commerce.rb'
- - 'test/remote/gateways/remote_orbital_test.rb'
-
# Offense count: 357
# Cop supports --auto-correct.
# Configuration parameters: AllowInHeredoc.
diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb
index 6295c80164c..1c35f5d0534 100644
--- a/lib/active_merchant/billing/gateways/braintree_blue.rb
+++ b/lib/active_merchant/billing/gateways/braintree_blue.rb
@@ -231,7 +231,7 @@ def add_customer_with_credit_card(creditcard, options)
:last_name => creditcard.last_name,
:email => scrub_email(options[:email]),
:phone => options[:phone] || (options[:billing_address][:phone] if options[:billing_address] &&
- options[:billing_address][:phone]),
+ options[:billing_address][:phone]),
:id => options[:customer],
:device_data => options[:device_data],
}.merge credit_card_params
@@ -558,7 +558,7 @@ def create_transaction_parameters(money, credit_card_or_vault_id, options)
:id => options[:store] == true ? '' : options[:store],
:email => scrub_email(options[:email]),
:phone => options[:phone] || (options[:billing_address][:phone] if options[:billing_address] &&
- options[:billing_address][:phone])
+ options[:billing_address][:phone])
},
:options => {
:store_in_vault => options[:store] ? true : false,
diff --git a/lib/active_merchant/billing/gateways/efsnet.rb b/lib/active_merchant/billing/gateways/efsnet.rb
index a7e428b1eff..91e689d3fa7 100644
--- a/lib/active_merchant/billing/gateways/efsnet.rb
+++ b/lib/active_merchant/billing/gateways/efsnet.rb
@@ -200,15 +200,15 @@ def actions
CREDIT_CARD_FIELDS = %w(AuthorizationNumber ClientIpAddress BillingAddress BillingCity BillingState BillingPostalCode BillingCountry BillingName CardVerificationValue ExpirationMonth ExpirationYear ReferenceNumber TransactionAmount AccountNumber )
ACTIONS = {
- :credit_card_authorize => CREDIT_CARD_FIELDS,
- :credit_card_charge => CREDIT_CARD_FIELDS,
- :credit_card_voice_authorize => CREDIT_CARD_FIELDS,
- :credit_card_capture => CREDIT_CARD_FIELDS,
- :credit_card_credit => CREDIT_CARD_FIELDS + ['OriginalTransactionAmount'],
- :credit_card_refund => %w(ReferenceNumber TransactionAmount OriginalTransactionAmount OriginalTransactionID ClientIpAddress),
- :void_transaction => %w(ReferenceNumber TransactionID),
- :credit_card_settle => %w(ReferenceNumber TransactionAmount OriginalTransactionAmount OriginalTransactionID ClientIpAddress),
- :system_check => %w(SystemCheck),
+ :credit_card_authorize => CREDIT_CARD_FIELDS,
+ :credit_card_charge => CREDIT_CARD_FIELDS,
+ :credit_card_voice_authorize => CREDIT_CARD_FIELDS,
+ :credit_card_capture => CREDIT_CARD_FIELDS,
+ :credit_card_credit => CREDIT_CARD_FIELDS + ['OriginalTransactionAmount'],
+ :credit_card_refund => %w(ReferenceNumber TransactionAmount OriginalTransactionAmount OriginalTransactionID ClientIpAddress),
+ :void_transaction => %w(ReferenceNumber TransactionID),
+ :credit_card_settle => %w(ReferenceNumber TransactionAmount OriginalTransactionAmount OriginalTransactionID ClientIpAddress),
+ :system_check => %w(SystemCheck),
}
end
end
diff --git a/lib/active_merchant/billing/gateways/pagarme.rb b/lib/active_merchant/billing/gateways/pagarme.rb
index 7dfabd6f56d..63d29f4f2c3 100644
--- a/lib/active_merchant/billing/gateways/pagarme.rb
+++ b/lib/active_merchant/billing/gateways/pagarme.rb
@@ -181,7 +181,7 @@ def response_error(raw_response)
end
def json_error(raw_response)
- msg = 'Resposta inválida retornada pela API do Pagar.me. Por favor entre em contato com suporte@pagar.me se você continuar recebendo essa mensagem.'
+ msg = 'Resposta inválida retornada pela API do Pagar.me. Por favor entre em contato com suporte@pagar.me se você continuar recebendo essa mensagem.'
msg += " (A resposta retornada pela API foi #{raw_response.inspect})"
{
'errors' => [{
diff --git a/lib/active_merchant/billing/gateways/trust_commerce.rb b/lib/active_merchant/billing/gateways/trust_commerce.rb
index 4908df12cde..2b3dae1ec69 100644
--- a/lib/active_merchant/billing/gateways/trust_commerce.rb
+++ b/lib/active_merchant/billing/gateways/trust_commerce.rb
@@ -19,10 +19,10 @@ module Billing #:nodoc:
# Next, create a credit card object using a TC approved test card.
#
# creditcard = ActiveMerchant::Billing::CreditCard.new(
- # :number => '4111111111111111',
- # :month => 8,
- # :year => 2006,
- # :first_name => 'Longbob',
+ # :number => '4111111111111111',
+ # :month => 8,
+ # :year => 2006,
+ # :first_name => 'Longbob',
# :last_name => 'Longsen'
# )
#
@@ -353,7 +353,7 @@ def add_addresses(params, options)
params[:shipto_address2] = shipping_address[:address2] unless shipping_address[:address2].blank?
params[:shipto_city] = shipping_address[:city] unless shipping_address[:city].blank?
params[:shipto_state] = shipping_address[:state] unless shipping_address[:state].blank?
- params[:shipto_zip] = shipping_address[:zip] unless shipping_address[:zip].blank?
+ params[:shipto_zip] = shipping_address[:zip] unless shipping_address[:zip].blank?
params[:shipto_country] = shipping_address[:country] unless shipping_address[:country].blank?
end
end
diff --git a/test/remote/gateways/remote_orbital_test.rb b/test/remote/gateways/remote_orbital_test.rb
index 20b1b018431..55cdcce9bd0 100644
--- a/test/remote/gateways/remote_orbital_test.rb
+++ b/test/remote/gateways/remote_orbital_test.rb
@@ -40,15 +40,16 @@ def setup
}
@test_suite = [
- {:card => :visa, :AVSzip => 11111, :CVD => 111, :amount => 3000},
- {:card => :visa, :AVSzip => 33333, :CVD => nil, :amount => 3801},
- {:card => :mc, :AVSzip => 44444, :CVD => nil, :amount => 4100},
- {:card => :mc, :AVSzip => 88888, :CVD => 666, :amount => 1102},
- {:card => :amex, :AVSzip => 55555, :CVD => nil, :amount => 105500},
- {:card => :amex, :AVSzip => 66666, :CVD => 2222, :amount => 7500},
- {:card => :ds, :AVSzip => 77777, :CVD => nil, :amount => 1000},
- {:card => :ds, :AVSzip => 88888, :CVD => 444, :amount => 6303},
- {:card => :jcb, :AVSzip => 33333, :CVD => nil, :amount => 2900}]
+ {:card => :visa, :AVSzip => 11111, :CVD => 111, :amount => 3000},
+ {:card => :visa, :AVSzip => 33333, :CVD => nil, :amount => 3801},
+ {:card => :mc, :AVSzip => 44444, :CVD => nil, :amount => 4100},
+ {:card => :mc, :AVSzip => 88888, :CVD => 666, :amount => 1102},
+ {:card => :amex, :AVSzip => 55555, :CVD => nil, :amount => 105500},
+ {:card => :amex, :AVSzip => 66666, :CVD => 2222, :amount => 7500},
+ {:card => :ds, :AVSzip => 77777, :CVD => nil, :amount => 1000},
+ {:card => :ds, :AVSzip => 88888, :CVD => 444, :amount => 6303},
+ {:card => :jcb, :AVSzip => 33333, :CVD => nil, :amount => 2900}
+ ]
end
def test_successful_purchase
From 4bfe35c27cb6e0e5333eeff3331f929fe292e149 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Mon, 22 Oct 2018 17:00:43 -0400
Subject: [PATCH 0124/2234] RuboCop: fix Layout/TrailingWhitespace
---
.rubocop_todo.yml | 6 ---
lib/active_merchant/billing/avs_result.rb | 24 ++++-----
.../billing/gateways/card_save.rb | 8 +--
.../billing/gateways/creditcall.rb | 6 +--
.../billing/gateways/credorax.rb | 2 +-
.../gateways/payflow/payflow_response.rb | 2 +-
.../billing/gateways/quickbooks.rb | 2 +-
.../gateways/quickpay/quickpay_common.rb | 14 +++---
.../gateways/quickpay/quickpay_v4to7.rb | 2 +-
.../billing/gateways/transax.rb | 8 +--
.../billing/gateways/trexle.rb | 12 ++---
.../billing/gateways/usa_epay.rb | 2 +-
.../remote_beanstream_interac_test.rb | 14 +++---
test/remote/gateways/remote_card_save_test.rb | 10 ++--
test/remote/gateways/remote_efsnet_test.rb | 14 +++---
test/remote/gateways/remote_instapay_test.rb | 10 ++--
test/remote/gateways/remote_itransact_test.rb | 9 ++--
.../gateways/remote_metrics_global_test.rb | 36 ++++++-------
.../remote_modern_payments_cim_test.rb | 23 ++++-----
.../remote/gateways/remote_pay_secure_test.rb | 8 +--
.../gateways/remote_paybox_direct_test.rb | 16 +++---
.../gateways/remote_payflow_express_test.rb | 6 +--
.../remote/gateways/remote_payflow_uk_test.rb | 34 ++++++-------
test/remote/gateways/remote_psl_card_test.rb | 50 +++++++++----------
test/remote/gateways/remote_quantum_test.rb | 7 ++-
.../remote/gateways/remote_sallie_mae_test.rb | 6 +--
.../gateways/remote_secure_pay_tech_test.rb | 6 +--
.../remote/gateways/remote_secure_pay_test.rb | 10 ++--
.../remote/gateways/remote_stripe_emv_test.rb | 2 +-
.../gateways/remote_trans_first_test.rb | 2 +-
...te_trans_first_transaction_express_test.rb | 2 +-
test/remote/gateways/remote_trexle_test.rb | 2 +-
.../gateways/remote_trust_commerce_test.rb | 2 +-
test/remote/gateways/remote_viaklix_test.rb | 20 ++++----
test/unit/cvv_result_test.rb | 8 +--
test/unit/expiry_date_test.rb | 8 +--
test/unit/gateways/beanstream_interac_test.rb | 14 +++---
test/unit/gateways/cecabank_test.rb | 2 +-
test/unit/gateways/federated_canada_test.rb | 34 ++++++-------
test/unit/gateways/global_collect_test.rb | 30 +++++------
test/unit/gateways/instapay_test.rb | 22 ++++----
test/unit/gateways/itransact_test.rb | 16 +++---
test/unit/gateways/mundipagg_test.rb | 2 +-
test/unit/gateways/pay_secure_test.rb | 22 ++++----
test/unit/gateways/payflow_uk_test.rb | 8 +--
test/unit/gateways/psl_card_test.rb | 14 +++---
test/unit/gateways/quantum_test.rb | 18 +++----
test/unit/gateways/quickpay_test.rb | 12 ++---
test/unit/gateways/quickpay_v4to7_test.rb | 6 +--
test/unit/gateways/secure_pay_tech_test.rb | 12 ++---
test/unit/gateways/trexle_test.rb | 34 ++++++-------
test/unit/gateways/viaklix_test.rb | 34 ++++++-------
52 files changed, 332 insertions(+), 341 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index a3681855ba4..1841c4a0842 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -241,12 +241,6 @@ Layout/SpaceInsideStringInterpolation:
- 'lib/active_merchant/billing/gateways/trust_commerce.rb'
- 'test/unit/gateways/worldpay_test.rb'
-# Offense count: 357
-# Cop supports --auto-correct.
-# Configuration parameters: AllowInHeredoc.
-Layout/TrailingWhitespace:
- Enabled: false
-
# Offense count: 4
Lint/AmbiguousBlockAssociation:
Exclude:
diff --git a/lib/active_merchant/billing/avs_result.rb b/lib/active_merchant/billing/avs_result.rb
index 527c3efa119..7324daef438 100644
--- a/lib/active_merchant/billing/avs_result.rb
+++ b/lib/active_merchant/billing/avs_result.rb
@@ -2,7 +2,7 @@
# encoding: utf-8
module ActiveMerchant
- module Billing
+ module Billing
# Implements the Address Verification System
# https://www.wellsfargo.com/downloads/pdf/biz/merchant/visa_avs.pdf
# http://en.wikipedia.org/wiki/Address_Verification_System
@@ -38,7 +38,7 @@ class AVSResult
'Y' => 'Street address and 5-digit postal code match.',
'Z' => 'Street address does not match, but 5-digit postal code matches.'
}
-
+
# Map vendor's AVS result code to a postal match code
POSTAL_MATCH_CODE = {
'Y' => %w( D H F H J L M P Q V W X Y Z ),
@@ -49,7 +49,7 @@ class AVSResult
codes.each { |code| map[code] = type }
map
end
-
+
# Map vendor's AVS result code to a street match code
STREET_MATCH_CODE = {
'Y' => %w( A B D H J M O Q T V X Y ),
@@ -60,32 +60,32 @@ class AVSResult
codes.each { |code| map[code] = type }
map
end
-
+
attr_reader :code, :message, :street_match, :postal_match
-
+
def self.messages
MESSAGES
end
-
+
def initialize(attrs)
attrs ||= {}
-
+
@code = attrs[:code].upcase unless attrs[:code].blank?
@message = self.class.messages[code]
-
+
if attrs[:street_match].blank?
@street_match = STREET_MATCH_CODE[code]
- else
+ else
@street_match = attrs[:street_match].upcase
end
-
+
if attrs[:postal_match].blank?
@postal_match = POSTAL_MATCH_CODE[code]
- else
+ else
@postal_match = attrs[:postal_match].upcase
end
end
-
+
def to_hash
{ 'code' => code,
'message' => message,
diff --git a/lib/active_merchant/billing/gateways/card_save.rb b/lib/active_merchant/billing/gateways/card_save.rb
index 821ba3c3b6a..7d5920be05b 100644
--- a/lib/active_merchant/billing/gateways/card_save.rb
+++ b/lib/active_merchant/billing/gateways/card_save.rb
@@ -2,21 +2,21 @@ module ActiveMerchant #:nodoc:
module Billing #:nodoc:
class CardSaveGateway < IridiumGateway
# CardSave lets you handle failovers on payments by providing 3 gateways in case one happens to be down
- # URLS = ['https://gw1.cardsaveonlinepayments.com:4430/','https://gw2.cardsaveonlinepayments.com:4430/','https://gw3.cardsaveonlinepayments.com:4430/']
-
+ # URLS = ['https://gw1.cardsaveonlinepayments.com:4430/','https://gw2.cardsaveonlinepayments.com:4430/','https://gw3.cardsaveonlinepayments.com:4430/']
+
self.money_format = :cents
self.default_currency = 'GBP'
self.supported_cardtypes = [ :visa, :maestro, :master, :american_express, :jcb ]
self.supported_countries = [ 'GB' ]
self.homepage_url = 'http://www.cardsave.net/'
self.display_name = 'CardSave'
-
+
def initialize(options={})
super
@test_url = 'https://gw1.cardsaveonlinepayments.com:4430/'
@live_url = 'https://gw1.cardsaveonlinepayments.com:4430/'
end
-
+
end
end
end
diff --git a/lib/active_merchant/billing/gateways/creditcall.rb b/lib/active_merchant/billing/gateways/creditcall.rb
index 4ce8a1f916d..554a12ac6be 100644
--- a/lib/active_merchant/billing/gateways/creditcall.rb
+++ b/lib/active_merchant/billing/gateways/creditcall.rb
@@ -14,14 +14,14 @@ class CreditcallGateway < Gateway
self.homepage_url = 'https://www.creditcall.com'
self.display_name = 'Creditcall'
-
+
CVV_CODE = {
'matched' => 'M',
'notmatched' => 'N',
'notchecked' => 'P',
'partialmatch' => 'N'
}
-
+
AVS_CODE = {
'matched;matched' => 'D',
'matched;notchecked' =>'B',
@@ -53,7 +53,7 @@ def purchase(money, payment_method, options={})
end
merged_params = multi_response.responses.map(&:params).reduce({}, :merge)
-
+
Response.new(
multi_response.primary_response.success?,
multi_response.primary_response.message,
diff --git a/lib/active_merchant/billing/gateways/credorax.rb b/lib/active_merchant/billing/gateways/credorax.rb
index 96f45bc5c81..9a60d276fbe 100644
--- a/lib/active_merchant/billing/gateways/credorax.rb
+++ b/lib/active_merchant/billing/gateways/credorax.rb
@@ -185,7 +185,7 @@ def credit(amount, payment_method, options={})
add_email(post, options)
add_echo(post, options)
add_transaction_type(post, options)
-
+
commit(:credit, post)
end
diff --git a/lib/active_merchant/billing/gateways/payflow/payflow_response.rb b/lib/active_merchant/billing/gateways/payflow/payflow_response.rb
index e888ea2fec1..83caaff5800 100644
--- a/lib/active_merchant/billing/gateways/payflow/payflow_response.rb
+++ b/lib/active_merchant/billing/gateways/payflow/payflow_response.rb
@@ -4,7 +4,7 @@ class PayflowResponse < Response
def profile_id
@params['profile_id']
end
-
+
def payment_history
@payment_history ||= @params['rp_payment_result'].collect(&:stringify_keys) rescue []
end
diff --git a/lib/active_merchant/billing/gateways/quickbooks.rb b/lib/active_merchant/billing/gateways/quickbooks.rb
index c81ab1deeda..f346cefc34b 100644
--- a/lib/active_merchant/billing/gateways/quickbooks.rb
+++ b/lib/active_merchant/billing/gateways/quickbooks.rb
@@ -253,7 +253,7 @@ def cvv_code_from(response)
def success?(response)
return FRAUD_WARNING_CODES.concat(['0']).include?(response['errors'].first['code']) if response['errors']
-
+
!['DECLINED', 'CANCELLED'].include?(response['status'])
end
diff --git a/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb b/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb
index 904c03d8c26..930958e0cbb 100644
--- a/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb
+++ b/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb
@@ -136,9 +136,9 @@ module QuickpayCommon
:chstatus => %w(protocol msgtype merchant apikey)
},
-
+
10 => {
- :authorize => %w(mobile_number acquirer autofee customer_id extras
+ :authorize => %w(mobile_number acquirer autofee customer_id extras
zero_auth customer_ip),
:capture => %w( extras ),
:cancel => %w( extras ),
@@ -148,7 +148,7 @@ module QuickpayCommon
:recurring => %w(auto_capture autofee zero_auth)
}
}
-
+
RESPONSE_CODES = {
200 => 'OK',
201 => 'Created',
@@ -163,18 +163,18 @@ module QuickpayCommon
409 => 'Conflict',
500 => 'Internal Server Error'
}
-
+
def self.included(base)
base.default_currency = 'DKK'
base.money_format = :cents
-
- base.supported_cardtypes = [:dankort, :forbrugsforeningen, :visa, :master,
+
+ base.supported_cardtypes = [:dankort, :forbrugsforeningen, :visa, :master,
:american_express, :diners_club, :jcb, :maestro]
base.supported_countries = ['DE', 'DK', 'ES', 'FI', 'FR', 'FO', 'GB', 'IS', 'NO', 'SE']
base.homepage_url = 'http://quickpay.net/'
base.display_name = 'QuickPay'
end
-
+
def expdate(credit_card)
year = format(credit_card.year, :two_digits)
month = format(credit_card.month, :two_digits)
diff --git a/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb b/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb
index a43fb085838..810d5cdefaa 100644
--- a/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb
+++ b/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb
@@ -6,7 +6,7 @@ module ActiveMerchant #:nodoc:
module Billing #:nodoc:
class QuickpayV4to7Gateway < Gateway
include QuickpayCommon
- self.live_url = self.test_url = 'https://secure.quickpay.dk/api'
+ self.live_url = self.test_url = 'https://secure.quickpay.dk/api'
APPROVED = '000'
# The login is the QuickpayId
diff --git a/lib/active_merchant/billing/gateways/transax.rb b/lib/active_merchant/billing/gateways/transax.rb
index 7411ad573c4..ac462b23763 100644
--- a/lib/active_merchant/billing/gateways/transax.rb
+++ b/lib/active_merchant/billing/gateways/transax.rb
@@ -4,16 +4,16 @@ module ActiveMerchant #:nodoc:
module Billing #:nodoc:
class TransaxGateway < SmartPs
self.live_url = self.test_url = 'https://secure.nelixtransax.net/api/transact.php'
-
+
# The countries the gateway supports merchants from as 2 digit ISO country codes
self.supported_countries = ['US']
-
+
# The card types supported by the payment gateway
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
-
+
# The homepage URL of the gateway
self.homepage_url = 'https://www.nelixtransax.com/'
-
+
# The name of the gateway
self.display_name = 'NELiX TransaX'
diff --git a/lib/active_merchant/billing/gateways/trexle.rb b/lib/active_merchant/billing/gateways/trexle.rb
index f7f98e21766..42451539b2c 100644
--- a/lib/active_merchant/billing/gateways/trexle.rb
+++ b/lib/active_merchant/billing/gateways/trexle.rb
@@ -154,21 +154,21 @@ def headers(params = {})
result['X-Safe-Card'] = params[:safe_card] if params[:safe_card]
result
end
-
+
def commit(method, action, params, options)
url = "#{test? ? test_url : live_url}/#{action}"
raw_response = ssl_request(method, url, post_data(params), headers(options))
parsed_response = parse(raw_response)
- success_response(parsed_response)
+ success_response(parsed_response)
rescue ResponseError => e
error_response(parse(e.response.body))
rescue JSON::ParserError
unparsable_response(raw_response)
end
-
+
def success_response(body)
return invalid_response unless body['response']
-
+
response = body['response']
Response.new(
true,
@@ -195,7 +195,7 @@ def unparsable_response(raw_response)
message += " (The raw response returned by the API was #{raw_response.inspect})"
return Response.new(false, message)
end
-
+
def invalid_response
message = 'Invalid response.'
return Response.new(false, message)
@@ -207,7 +207,7 @@ def token(response)
def parse(body)
return {} if body.blank?
- JSON.parse(body)
+ JSON.parse(body)
end
def post_data(parameters = {})
diff --git a/lib/active_merchant/billing/gateways/usa_epay.rb b/lib/active_merchant/billing/gateways/usa_epay.rb
index b43e355f61c..0558311bc11 100644
--- a/lib/active_merchant/billing/gateways/usa_epay.rb
+++ b/lib/active_merchant/billing/gateways/usa_epay.rb
@@ -9,7 +9,7 @@ class UsaEpayGateway < Gateway
self.abstract_class = true
##
- # Creates an instance of UsaEpayTransactionGateway by default, but if
+ # Creates an instance of UsaEpayTransactionGateway by default, but if
# :software id or :live_url are passed in the options hash it will
# create an instance of UsaEpayAdvancedGateway.
#
diff --git a/test/remote/gateways/remote_beanstream_interac_test.rb b/test/remote/gateways/remote_beanstream_interac_test.rb
index 497b0bb744f..4f4d1b9b79e 100644
--- a/test/remote/gateways/remote_beanstream_interac_test.rb
+++ b/test/remote/gateways/remote_beanstream_interac_test.rb
@@ -1,13 +1,13 @@
require 'test_helper'
class RemoteBeanstreamInteracTest < Test::Unit::TestCase
-
+
def setup
@gateway = BeanstreamInteracGateway.new(fixtures(:beanstream_interac))
-
+
@amount = 100
-
- @options = {
+
+ @options = {
:order_id => generate_unique_id,
:billing_address => {
:name => 'xiaobo zzz',
@@ -27,19 +27,19 @@ def setup
:custom => 'reference one'
}
end
-
+
def test_successful_purchase
assert response = @gateway.purchase(@amount, @options)
assert_success response
assert_equal 'R', response.params['responseType']
assert_false response.redirect.blank?
end
-
+
def test_failed_confirmation
assert response = @gateway.confirm('')
assert_failure response
end
-
+
def test_invalid_login
gateway = BeanstreamInteracGateway.new(
:merchant_id => '',
diff --git a/test/remote/gateways/remote_card_save_test.rb b/test/remote/gateways/remote_card_save_test.rb
index 23af62ab582..9fe97a8d251 100644
--- a/test/remote/gateways/remote_card_save_test.rb
+++ b/test/remote/gateways/remote_card_save_test.rb
@@ -1,23 +1,23 @@
require 'test_helper'
-class RemoteCardSaveTest < Test::Unit::TestCase
+class RemoteCardSaveTest < Test::Unit::TestCase
def setup
@gateway = CardSaveGateway.new(fixtures(:card_save))
-
+
@amount = 100
@credit_card = credit_card('4976000000003436', :verification_value => '452')
@declined_card = credit_card('4221690000004963', :verification_value => '125')
@addresses = {'4976000000003436' => { :name => 'John Watson', :address1 => '32 Edward Street', :city => 'Camborne,', :state => 'Cornwall', :country => 'GB', :zip => 'TR14 8PA' },
'4221690000004963' => { :name => 'Ian Lee', :address1 => '274 Lymington Avenue', :city => 'London', :state => 'London', :country => 'GB', :zip => 'N22 6JN' }}
-
- @options = {
+
+ @options = {
:order_id => '1',
:billing_address => @addresses[@credit_card.number],
:description => 'Store Purchase'
}
end
-
+
def test_successful_purchase
assert response = @gateway.purchase(@amount, @credit_card, @options)
assert_success response
diff --git a/test/remote/gateways/remote_efsnet_test.rb b/test/remote/gateways/remote_efsnet_test.rb
index 052ab40a589..4e6f22499b7 100644
--- a/test/remote/gateways/remote_efsnet_test.rb
+++ b/test/remote/gateways/remote_efsnet_test.rb
@@ -1,22 +1,22 @@
require 'test_helper'
class RemoteEfsnetTest < Test::Unit::TestCase
-
+
def setup
Base.mode = :test
@gateway = EfsnetGateway.new(fixtures(:efsnet))
-
+
@credit_card = credit_card('4000100011112224')
-
+
@amount = 100
@declined_amount = 156
- @options = { :order_id => generate_unique_id,
+ @options = { :order_id => generate_unique_id,
:billing_address => address
}
end
-
+
def test_successful_purchase
assert response = @gateway.purchase(@amount, @credit_card, @options)
assert_success response
@@ -45,10 +45,10 @@ def test_unsuccessful_purchase
def test_authorize_and_capture
amount = @amount
assert auth = @gateway.authorize(amount, @credit_card, @options)
- assert_success auth
+ assert_success auth
assert_equal 'Approved', auth.message
assert auth.authorization
-
+
assert capture = @gateway.capture(amount, auth.authorization, @options)
assert_success capture
end
diff --git a/test/remote/gateways/remote_instapay_test.rb b/test/remote/gateways/remote_instapay_test.rb
index 2919d97b98d..5a8286cf234 100644
--- a/test/remote/gateways/remote_instapay_test.rb
+++ b/test/remote/gateways/remote_instapay_test.rb
@@ -1,7 +1,7 @@
require 'test_helper'
class RemoteInstapayTest < Test::Unit::TestCase
-
+
def setup
@gateway = InstapayGateway.new(fixtures(:instapay))
@@ -38,22 +38,22 @@ def test_failed_authorization
assert response = @gateway.authorize(@amount, @declined_card, @options)
assert_failure response
end
-
+
def test_authorization_and_capture
assert authorization = @gateway.authorize(@amount, @credit_card, @options)
assert_success authorization
-
+
assert capture = @gateway.capture(@amount, authorization.authorization)
assert_success capture
assert_equal InstapayGateway::SUCCESS_MESSAGE, capture.message
end
-
+
def test_invalid_login
gateway = InstapayGateway.new(
:login => 'X',
:password => 'Y'
)
-
+
assert response = gateway.purchase(@amount, @credit_card)
assert_failure response
assert_equal 'Invalid merchant', response.message
diff --git a/test/remote/gateways/remote_itransact_test.rb b/test/remote/gateways/remote_itransact_test.rb
index 6456398e292..d949b17232d 100644
--- a/test/remote/gateways/remote_itransact_test.rb
+++ b/test/remote/gateways/remote_itransact_test.rb
@@ -1,22 +1,21 @@
require 'test_helper'
class RemoteItransactTest < Test::Unit::TestCase
-
def setup
@gateway = ItransactGateway.new(fixtures(:itransact))
-
+
@amount = 1065
@credit_card = credit_card('4000100011112224')
@declined_card = credit_card('4000300011112220')
-
- @options = {
+
+ @options = {
:order_id => '1',
:billing_address => address,
:description => 'Store Purchase'
}
end
-
+
def test_successful_purchase
assert response = @gateway.purchase(@amount, @credit_card, @options)
assert_success response
diff --git a/test/remote/gateways/remote_metrics_global_test.rb b/test/remote/gateways/remote_metrics_global_test.rb
index b1d19387559..3669fd41a11 100644
--- a/test/remote/gateways/remote_metrics_global_test.rb
+++ b/test/remote/gateways/remote_metrics_global_test.rb
@@ -3,7 +3,7 @@
class MetricsGlobalTest < Test::Unit::TestCase
def setup
Base.mode = :test
-
+
@gateway = MetricsGlobalGateway.new(fixtures(:metrics_global))
@amount = 100
@credit_card = credit_card('4111111111111111', :verification_value => '999')
@@ -13,7 +13,7 @@ def setup
:description => 'Store purchase'
}
end
-
+
def test_successful_purchase
assert response = @gateway.purchase(@amount, @credit_card, @options)
assert_success response
@@ -21,7 +21,7 @@ def test_successful_purchase
assert_equal 'This transaction has been approved', response.message
assert response.authorization
end
-
+
def test_declined_authorization
@amount = 10
assert response = @gateway.purchase(@amount, @credit_card, @options)
@@ -29,40 +29,40 @@ def test_declined_authorization
assert response.test?
assert_equal 'This transaction has been declined', response.message
end
-
+
def test_successful_authorization
assert response = @gateway.authorize(@amount, @credit_card, @options)
assert_success response
assert_equal 'This transaction has been approved', response.message
assert response.authorization
end
-
+
def test_authorization_and_capture
assert authorization = @gateway.authorize(@amount, @credit_card, @options)
assert_success authorization
-
+
assert capture = @gateway.capture(@amount, authorization.authorization)
assert_success capture
assert_equal 'This transaction has been approved', capture.message
end
-
+
def test_authorization_and_void
assert authorization = @gateway.authorize(@amount, @credit_card, @options)
assert_success authorization
-
+
assert void = @gateway.void(authorization.authorization)
assert_success void
assert_equal 'This transaction has been approved', void.message
end
-
+
def test_bad_login
gateway = MetricsGlobalGateway.new(
:login => 'X',
:password => 'Y'
)
-
+
assert response = gateway.purchase(@amount, @credit_card)
-
+
assert_equal Response, response.class
assert_equal ['avs_result_code',
'card_code',
@@ -72,18 +72,18 @@ def test_bad_login
'transaction_id'], response.params.keys.sort
assert_match(/Authentication Failed/, response.message)
-
+
assert_equal false, response.success?
end
-
+
def test_using_test_request
gateway = MetricsGlobalGateway.new(
:login => 'X',
:password => 'Y'
)
-
+
assert response = gateway.purchase(@amount, @credit_card)
-
+
assert_equal Response, response.class
assert_equal ['avs_result_code',
'card_code',
@@ -91,9 +91,9 @@ def test_using_test_request
'response_reason_code',
'response_reason_text',
'transaction_id'], response.params.keys.sort
-
+
assert_match(/Authentication Failed/, response.message)
-
- assert_equal false, response.success?
+
+ assert_equal false, response.success?
end
end
diff --git a/test/remote/gateways/remote_modern_payments_cim_test.rb b/test/remote/gateways/remote_modern_payments_cim_test.rb
index a6afc2b97fe..8c310d0fe17 100644
--- a/test/remote/gateways/remote_modern_payments_cim_test.rb
+++ b/test/remote/gateways/remote_modern_payments_cim_test.rb
@@ -1,47 +1,46 @@
require 'test_helper'
class RemoteModernPaymentsCimTest < Test::Unit::TestCase
-
def setup
@gateway = ModernPaymentsCimGateway.new(fixtures(:modern_payments))
-
+
@amount = 100
@credit_card = credit_card('4111111111111111')
@declined_card = credit_card('4000000000000000')
-
- @options = {
+
+ @options = {
:billing_address => address,
:customer => 'JIMSMITH2000'
}
end
-
+
def test_successful_create_customer
response = @gateway.create_customer(@options)
assert_success response
assert !response.params['create_customer_result'].blank?
end
-
+
def test_successful_modify_customer_credit_card
customer = @gateway.create_customer(@options)
assert_success customer
-
+
customer_id = customer.params['create_customer_result']
-
+
credit_card = @gateway.modify_customer_credit_card(customer_id, @credit_card)
assert_success credit_card
assert !credit_card.params['modify_customer_credit_card_result'].blank?
end
-
+
def test_succsessful_authorize_credit_card_payment
customer = @gateway.create_customer(@options)
assert_success customer
-
+
customer_id = customer.params['create_customer_result']
-
+
credit_card = @gateway.modify_customer_credit_card(customer_id, @credit_card)
assert_success credit_card
-
+
payment = @gateway.authorize_credit_card_payment(customer_id, @amount)
assert_success payment
end
diff --git a/test/remote/gateways/remote_pay_secure_test.rb b/test/remote/gateways/remote_pay_secure_test.rb
index 8dd8837adc1..ee153752bb9 100644
--- a/test/remote/gateways/remote_pay_secure_test.rb
+++ b/test/remote/gateways/remote_pay_secure_test.rb
@@ -4,15 +4,15 @@ class RemotePaySecureTest < Test::Unit::TestCase
def setup
@gateway = PaySecureGateway.new(fixtures(:pay_secure))
-
+
@credit_card = credit_card('4000100011112224')
- @options = {
+ @options = {
:billing_address => address,
:order_id => generate_unique_id
}
@amount = 100
end
-
+
def test_successful_purchase
assert response = @gateway.purchase(@amount, @credit_card, @options)
assert_success response
@@ -26,7 +26,7 @@ def test_unsuccessful_purchase
assert_equal 'Declined, card expired', response.message
assert_failure response
end
-
+
def test_invalid_login
gateway = PaySecureGateway.new(
:login => '',
diff --git a/test/remote/gateways/remote_paybox_direct_test.rb b/test/remote/gateways/remote_paybox_direct_test.rb
index 8ee4639b8fb..25c03d67804 100644
--- a/test/remote/gateways/remote_paybox_direct_test.rb
+++ b/test/remote/gateways/remote_paybox_direct_test.rb
@@ -6,18 +6,18 @@ class RemotePayboxDirectTest < Test::Unit::TestCase
def setup
@gateway = PayboxDirectGateway.new(fixtures(:paybox_direct))
-
+
@amount = 100
@credit_card = credit_card('1111222233334444')
@declined_card = credit_card('1111222233334445')
-
- @options = {
+
+ @options = {
:order_id => '1',
:billing_address => address,
:description => 'Store Purchase'
}
end
-
+
def test_successful_purchase
assert response = @gateway.purchase(@amount, @credit_card, @options)
assert_success response
@@ -39,7 +39,7 @@ def test_authorize_and_capture
assert capture = @gateway.capture(amount, auth.authorization, :order_id => '1')
assert_success capture
end
-
+
def test_purchase_and_void
assert purchase = @gateway.purchase(@amount, @credit_card, @options)
assert_success purchase
@@ -56,7 +56,7 @@ def test_failed_capture
assert_failure response
assert_equal 'Invalid data', response.message
end
-
+
def test_purchase_and_partial_credit
assert purchase = @gateway.purchase(@amount, @credit_card, @options)
assert_success purchase
@@ -66,7 +66,7 @@ def test_purchase_and_partial_credit
assert_equal 'The transaction was approved', credit.message
assert_success credit
end
-
+
def test_successful_refund
assert purchase = @gateway.purchase(@amount, @credit_card, @options)
assert_success purchase
@@ -84,7 +84,7 @@ def test_partial_refund
end
def test_failed_refund
- refund = @gateway.refund(@amount, '', order_id: '2')
+ refund = @gateway.refund(@amount, '', order_id: '2')
assert_failure refund
assert_equal 'Invalid data', refund.message
end
diff --git a/test/remote/gateways/remote_payflow_express_test.rb b/test/remote/gateways/remote_payflow_express_test.rb
index 5c8978d6802..827907d02d9 100644
--- a/test/remote/gateways/remote_payflow_express_test.rb
+++ b/test/remote/gateways/remote_payflow_express_test.rb
@@ -3,7 +3,7 @@
class RemotePayflowExpressTest < Test::Unit::TestCase
def setup
Base.mode = :test
-
+
@gateway = PayflowExpressGateway.new(fixtures(:payflow))
@options = {
@@ -20,7 +20,7 @@ def setup
:email => 'cody@example.com'
}
end
-
+
# Only works with a Payflow 2.0 account or by requesting the addition
# of Express checkout to an existing Payflow Pro account. This can be done
# by contacting Payflow sales. The PayPal account used must be a business
@@ -37,7 +37,7 @@ def test_set_express_authorization
assert response.test?
assert !response.params['token'].blank?
end
-
+
def test_set_express_purchase
@options.update(
:return_url => 'http://example.com',
diff --git a/test/remote/gateways/remote_payflow_uk_test.rb b/test/remote/gateways/remote_payflow_uk_test.rb
index 5242f8f813a..c2aebf853ec 100644
--- a/test/remote/gateways/remote_payflow_uk_test.rb
+++ b/test/remote/gateways/remote_payflow_uk_test.rb
@@ -6,7 +6,7 @@ def setup
# The default partner is PayPalUk
@gateway = PayflowUkGateway.new(fixtures(:payflow_uk))
-
+
@creditcard = CreditCard.new(
:number => '5105105105105100',
:month => 11,
@@ -17,7 +17,7 @@ def setup
:brand => 'master'
)
- @options = {
+ @options = {
:billing_address => {
:name => 'Cody Fauser',
:address1 => '1234 Shady Brook Lane',
@@ -30,7 +30,7 @@ def setup
:email => 'cody@example.com'
}
end
-
+
def test_successful_purchase
assert response = @gateway.purchase(100000, @creditcard, @options)
assert_equal 'Approved', response.message
@@ -38,14 +38,14 @@ def test_successful_purchase
assert response.test?
assert_not_nil response.authorization
end
-
+
def test_declined_purchase
assert response = @gateway.purchase(210000, @creditcard, @options)
assert_equal 'Failed merchant rule check', response.message
assert_failure response
assert response.test?
end
-
+
def test_successful_purchase_solo
assert response = @gateway.purchase(100000, @solo, @options)
assert_equal 'Approved', response.message
@@ -53,16 +53,16 @@ def test_successful_purchase_solo
assert response.test?
assert_not_nil response.authorization
end
-
+
def test_no_card_issue_or_card_start_with_switch
assert response = @gateway.purchase(100000, @switch, @options)
assert_failure response
-
+
assert_equal 'Field format error: CARDSTART or CARDISSUE must be present', response.message
assert_failure response
assert response.test?
end
-
+
def test_successful_purchase_switch_with_issue_number
@switch.issue_number = '01'
assert response = @gateway.purchase(100000, @switch, @options)
@@ -71,7 +71,7 @@ def test_successful_purchase_switch_with_issue_number
assert response.test?
assert_not_nil response.authorization
end
-
+
def test_successful_purchase_switch_with_start_date
@switch.start_month = 12
@switch.start_year = 1999
@@ -81,7 +81,7 @@ def test_successful_purchase_switch_with_start_date
assert response.test?
assert_not_nil response.authorization
end
-
+
def test_successful_purchase_switch_with_start_date_and_issue_number
@switch.issue_number = '05'
@switch.start_month = 12
@@ -92,7 +92,7 @@ def test_successful_purchase_switch_with_start_date_and_issue_number
assert response.test?
assert_not_nil response.authorization
end
-
+
def test_successful_authorization
assert response = @gateway.authorize(100, @creditcard, @options)
assert_equal 'Approved', response.message
@@ -110,13 +110,13 @@ def test_authorize_and_capture
assert capture = @gateway.capture(amount, auth.authorization)
assert_success capture
end
-
+
def test_failed_capture
assert response = @gateway.capture(100, '999')
assert_failure response
assert_equal 'Invalid tender', response.message
end
-
+
def test_authorize_and_void
assert auth = @gateway.authorize(100, @creditcard, @options)
assert_success auth
@@ -125,7 +125,7 @@ def test_authorize_and_void
assert void = @gateway.void(auth.authorization)
assert_success void
end
-
+
def test_invalid_login
gateway = PayflowGateway.new(
:login => '',
@@ -135,16 +135,16 @@ def test_invalid_login
assert_equal 'Invalid vendor account', response.message
assert_failure response
end
-
+
def test_duplicate_request_id
gateway = PayflowUkGateway.new(
:login => @login,
:password => @password
)
-
+
request_id = Digest::SHA1.hexdigest(rand.to_s).slice(0,32)
gateway.expects(:generate_unique_id).times(2).returns(request_id)
-
+
response1 = gateway.purchase(100, @creditcard, @options)
assert_nil response1.params['duplicate']
response2 = gateway.purchase(100, @creditcard, @options)
diff --git a/test/remote/gateways/remote_psl_card_test.rb b/test/remote/gateways/remote_psl_card_test.rb
index a5ea5c9d6ed..6b1b9e6e215 100644
--- a/test/remote/gateways/remote_psl_card_test.rb
+++ b/test/remote/gateways/remote_psl_card_test.rb
@@ -1,29 +1,29 @@
require 'test_helper'
class RemotePslCardTest < Test::Unit::TestCase
-
+
def setup
@gateway = PslCardGateway.new(fixtures(:psl_card))
-
+
@uk_maestro = CreditCard.new(fixtures(:psl_maestro))
@uk_maestro_address = fixtures(:psl_maestro_address)
-
+
@solo = CreditCard.new(fixtures(:psl_solo))
@solo_address = fixtures(:psl_solo_address)
-
+
@visa = CreditCard.new(fixtures(:psl_visa))
@visa_address = fixtures(:psl_visa_address)
-
+
@visa_debit = CreditCard.new(fixtures(:psl_visa_debit))
@visa_address = fixtures(:psl_visa_debit_address)
-
+
# The test results are determined by the amount of the transaction
@accept_amount = 1000
@referred_amount = 6000
@declined_amount = 11000
@keep_card_amount = 15000
end
-
+
def test_successful_visa_purchase
response = @gateway.purchase(@accept_amount, @visa,
:billing_address => @visa_address
@@ -31,14 +31,14 @@ def test_successful_visa_purchase
assert_success response
assert response.test?
end
-
+
def test_successful_visa_debit_purchase
response = @gateway.purchase(@accept_amount, @visa_debit,
:billing_address => @visa_debit_address
)
assert_success response
end
-
+
# Fix regression discovered in production
def test_visa_debit_purchase_should_not_send_debit_info_if_present
@visa_debit.start_month = '07'
@@ -47,7 +47,7 @@ def test_visa_debit_purchase_should_not_send_debit_info_if_present
)
assert_success response
end
-
+
def test_successful_visa_purchase_specifying_currency
response = @gateway.purchase(@accept_amount, @visa,
:billing_address => @visa_address,
@@ -56,67 +56,67 @@ def test_successful_visa_purchase_specifying_currency
assert_success response
assert response.test?
end
-
+
def test_successful_solo_purchase
- response = @gateway.purchase(@accept_amount, @solo,
+ response = @gateway.purchase(@accept_amount, @solo,
:billing_address => @solo_address
)
assert_success response
assert response.test?
end
-
+
def test_referred_purchase
- response = @gateway.purchase(@referred_amount, @uk_maestro,
+ response = @gateway.purchase(@referred_amount, @uk_maestro,
:billing_address => @uk_maestro_address
)
assert_failure response
assert response.test?
end
-
+
def test_declined_purchase
- response = @gateway.purchase(@declined_amount, @uk_maestro,
+ response = @gateway.purchase(@declined_amount, @uk_maestro,
:billing_address => @uk_maestro_address
)
assert_failure response
assert response.test?
end
-
+
def test_declined_keep_card_purchase
- response = @gateway.purchase(@keep_card_amount, @uk_maestro,
+ response = @gateway.purchase(@keep_card_amount, @uk_maestro,
:billing_address => @uk_maestro_address
)
assert_failure response
assert response.test?
end
-
+
def test_successful_authorization
- response = @gateway.authorize(@accept_amount, @visa,
+ response = @gateway.authorize(@accept_amount, @visa,
:billing_address => @visa_address
)
assert_success response
assert response.test?
end
-
+
def test_no_login
@gateway = PslCardGateway.new(
:login => ''
)
- response = @gateway.authorize(@accept_amount, @uk_maestro,
+ response = @gateway.authorize(@accept_amount, @uk_maestro,
:billing_address => @uk_maestro_address
)
assert_failure response
assert response.test?
end
-
+
def test_successful_authorization_and_capture
authorization = @gateway.authorize(@accept_amount, @visa,
:billing_address => @visa_address
)
assert_success authorization
assert authorization.test?
-
+
capture = @gateway.capture(@accept_amount, authorization.authorization)
-
+
assert_success capture
assert capture.test?
end
diff --git a/test/remote/gateways/remote_quantum_test.rb b/test/remote/gateways/remote_quantum_test.rb
index dfa3b5682a5..370e802d66c 100644
--- a/test/remote/gateways/remote_quantum_test.rb
+++ b/test/remote/gateways/remote_quantum_test.rb
@@ -1,15 +1,14 @@
require 'test_helper'
class RemoteQuantumTest < Test::Unit::TestCase
-
def setup
@gateway = QuantumGateway.new(fixtures(:quantum))
-
+
@amount = 100
@credit_card = credit_card('4000100011112224')
end
-
+
def test_successful_purchase
assert response = @gateway.purchase(@amount, @credit_card)
assert_success response
@@ -53,7 +52,7 @@ def test_void
assert response = @gateway.void(response.authorization)
assert_success response
end
-
+
def test_passing_billing_address
options = {:billing_address => address}
assert response = @gateway.purchase(@amount, @credit_card, options)
diff --git a/test/remote/gateways/remote_sallie_mae_test.rb b/test/remote/gateways/remote_sallie_mae_test.rb
index 09f14cb2337..f2b47acef22 100644
--- a/test/remote/gateways/remote_sallie_mae_test.rb
+++ b/test/remote/gateways/remote_sallie_mae_test.rb
@@ -3,12 +3,12 @@
class RemoteSallieMaeTest < Test::Unit::TestCase
def setup
@gateway = SallieMaeGateway.new(fixtures(:sallie_mae))
-
+
@amount = 100
@credit_card = credit_card('5454545454545454')
@declined_card = credit_card('4000300011112220')
-
- @options = {
+
+ @options = {
:billing_address => address,
:description => 'Store Purchase'
}
diff --git a/test/remote/gateways/remote_secure_pay_tech_test.rb b/test/remote/gateways/remote_secure_pay_tech_test.rb
index 737d2d92280..3b76bf77eef 100644
--- a/test/remote/gateways/remote_secure_pay_tech_test.rb
+++ b/test/remote/gateways/remote_secure_pay_tech_test.rb
@@ -5,14 +5,14 @@ class RemoteSecurePayTechTest < Test::Unit::TestCase
def setup
@gateway = SecurePayTechGateway.new(fixtures(:secure_pay_tech))
-
+
@accepted_amount = 10000
@declined_amount = 10075
-
+
@credit_card = credit_card('4987654321098769', :month => '5', :year => '2013')
@options = { :billing_address => address }
end
-
+
def test_successful_purchase
assert response = @gateway.purchase(@accepted_amount, @credit_card, @options)
assert_equal 'Transaction OK', response.message
diff --git a/test/remote/gateways/remote_secure_pay_test.rb b/test/remote/gateways/remote_secure_pay_test.rb
index c739e1cc9f4..63f83f5e40b 100644
--- a/test/remote/gateways/remote_secure_pay_test.rb
+++ b/test/remote/gateways/remote_secure_pay_test.rb
@@ -1,7 +1,7 @@
require 'test_helper'
-class RemoteSecurePayTest < Test::Unit::TestCase
-
+class RemoteSecurePayTest < Test::Unit::TestCase
+
def setup
@gateway = SecurePayGateway.new(fixtures(:secure_pay))
@@ -9,16 +9,16 @@ def setup
:month => '7',
:year => '2014'
)
-
+
@options = {
:order_id => generate_unique_id,
:description => 'Store purchase',
:billing_address => address
}
-
+
@amount = 100
end
-
+
def test_successful_purchase
assert response = @gateway.purchase(@amount, @credit_card, @options)
assert response.success?
diff --git a/test/remote/gateways/remote_stripe_emv_test.rb b/test/remote/gateways/remote_stripe_emv_test.rb
index 929d05d2cc2..6d2742d7d35 100644
--- a/test/remote/gateways/remote_stripe_emv_test.rb
+++ b/test/remote/gateways/remote_stripe_emv_test.rb
@@ -22,7 +22,7 @@ def setup
# This capture hex says that the payload is a transaction cryptogram (TC) but does not
# provide the actual cryptogram. This will only work in test mode and would cause real
# cards to be declined.
- @capture_options = { icc_data: '9F270140' }
+ @capture_options = { icc_data: '9F270140' }
end
# for EMV contact transactions, it's advised to do a separate auth + capture
diff --git a/test/remote/gateways/remote_trans_first_test.rb b/test/remote/gateways/remote_trans_first_test.rb
index 3b19be25327..3423954560e 100644
--- a/test/remote/gateways/remote_trans_first_test.rb
+++ b/test/remote/gateways/remote_trans_first_test.rb
@@ -78,7 +78,7 @@ def test_successful_void
assert_success void
end
- # Refunds can only be successfully run on settled transactions which take 24 hours
+ # Refunds can only be successfully run on settled transactions which take 24 hours
# def test_successful_refund
# assert purchase = @gateway.purchase(@amount, @credit_card, @options)
# assert_success purchase
diff --git a/test/remote/gateways/remote_trans_first_transaction_express_test.rb b/test/remote/gateways/remote_trans_first_transaction_express_test.rb
index f2045dcd4e1..894b07c440e 100644
--- a/test/remote/gateways/remote_trans_first_transaction_express_test.rb
+++ b/test/remote/gateways/remote_trans_first_transaction_express_test.rb
@@ -45,7 +45,7 @@ def test_successful_purchase
assert_equal 'Street address does not match, but 5-digit postal code matches.', response.avs_result['message']
assert_equal 'CVV matches', response.cvv_result['message']
end
-
+
def test_successful_purchase_no_avs
options = @options.dup
options[:shipping_address] = nil
diff --git a/test/remote/gateways/remote_trexle_test.rb b/test/remote/gateways/remote_trexle_test.rb
index cd8f5360315..149a8530797 100644
--- a/test/remote/gateways/remote_trexle_test.rb
+++ b/test/remote/gateways/remote_trexle_test.rb
@@ -163,7 +163,7 @@ def test_transcript_scrubbing
@gateway.purchase(@amount, @credit_card, @options)
end
clean_transcript = @gateway.scrub(transcript)
-
+
assert_scrubbed(@credit_card.number, clean_transcript)
assert_scrubbed(@credit_card.verification_value.to_s, clean_transcript)
end
diff --git a/test/remote/gateways/remote_trust_commerce_test.rb b/test/remote/gateways/remote_trust_commerce_test.rb
index 8fd3215f4f1..576fde7292a 100644
--- a/test/remote/gateways/remote_trust_commerce_test.rb
+++ b/test/remote/gateways/remote_trust_commerce_test.rb
@@ -156,7 +156,7 @@ def test_transcript_scrubbing
@gateway.purchase(@amount, @credit_card, @options)
end
clean_transcript = @gateway.scrub(transcript)
-
+
assert_scrubbed(@credit_card.number, clean_transcript)
assert_scrubbed(@credit_card.verification_value.to_s, clean_transcript)
end
diff --git a/test/remote/gateways/remote_viaklix_test.rb b/test/remote/gateways/remote_viaklix_test.rb
index 952d3a62a43..c3dc47c1a43 100644
--- a/test/remote/gateways/remote_viaklix_test.rb
+++ b/test/remote/gateways/remote_viaklix_test.rb
@@ -3,40 +3,40 @@
class RemoteViaklixTest < Test::Unit::TestCase
def setup
@gateway = ViaklixGateway.new(fixtures(:viaklix))
-
- @credit_card = credit_card
+
+ @credit_card = credit_card
@bad_credit_card = credit_card('invalid')
-
+
@options = {
:order_id => '#1000.1',
- :email => 'paul@domain.com',
+ :email => 'paul@domain.com',
:description => 'Test Transaction',
:billing_address => address
}
@amount = 100
end
-
+
def test_successful_purchase
assert response = @gateway.purchase(@amount, @credit_card, @options)
-
+
assert_success response
assert response.test?
assert_equal 'APPROVED', response.message
assert response.authorization
end
-
+
def test_failed_purchase
assert response = @gateway.purchase(@amount, @bad_credit_card, @options)
-
+
assert_failure response
assert response.test?
assert_equal 'The Credit Card Number supplied in the authorization request appears invalid.', response.message
end
-
+
def test_credit
assert purchase = @gateway.purchase(@amount, @credit_card, @options)
assert_success purchase
-
+
assert credit = @gateway.credit(@amount, @credit_card)
assert_success credit
end
diff --git a/test/unit/cvv_result_test.rb b/test/unit/cvv_result_test.rb
index ac44bdf24b1..282fc97c8a6 100644
--- a/test/unit/cvv_result_test.rb
+++ b/test/unit/cvv_result_test.rb
@@ -6,25 +6,25 @@ def test_nil_data
assert_nil result.code
assert_nil result.message
end
-
+
def test_blank_data
result = CVVResult.new('')
assert_nil result.code
assert_nil result.message
end
-
+
def test_successful_match
result = CVVResult.new('M')
assert_equal 'M', result.code
assert_equal CVVResult.messages['M'], result.message
end
-
+
def test_failed_match
result = CVVResult.new('N')
assert_equal 'N', result.code
assert_equal CVVResult.messages['N'], result.message
end
-
+
def test_to_hash
result = CVVResult.new('M').to_hash
assert_equal 'M', result['code']
diff --git a/test/unit/expiry_date_test.rb b/test/unit/expiry_date_test.rb
index 25e2e22bc0b..07a44b26c15 100644
--- a/test/unit/expiry_date_test.rb
+++ b/test/unit/expiry_date_test.rb
@@ -6,24 +6,24 @@ def test_should_be_expired
date = CreditCard::ExpiryDate.new(last_month.month, last_month.year)
assert date.expired?
end
-
+
def test_today_should_not_be_expired
today = Time.now.utc
date = CreditCard::ExpiryDate.new(today.month, today.year)
assert_false date.expired?
end
-
+
def test_dates_in_the_future_should_not_be_expired
next_month = 1.month.from_now
date = CreditCard::ExpiryDate.new(next_month.month, next_month.year)
assert_false date.expired?
end
-
+
def test_invalid_date
expiry = CreditCard::ExpiryDate.new(13, 2009)
assert_equal Time.at(0).utc, expiry.expiration
end
-
+
def test_month_and_year_coerced_to_integer
expiry = CreditCard::ExpiryDate.new('13', '2009')
assert_equal 13, expiry.month
diff --git a/test/unit/gateways/beanstream_interac_test.rb b/test/unit/gateways/beanstream_interac_test.rb
index c1158396746..a0a7bac3862 100644
--- a/test/unit/gateways/beanstream_interac_test.rb
+++ b/test/unit/gateways/beanstream_interac_test.rb
@@ -8,14 +8,14 @@ def setup
)
@amount = 100
-
- @options = {
+
+ @options = {
:order_id => '1',
:billing_address => address,
:description => 'Store Purchase'
}
end
-
+
def test_successful_purchase
@gateway.expects(:ssl_post).returns(successful_purchase_response)
response = @gateway.purchase(@amount, @options)
@@ -25,7 +25,7 @@ def test_successful_purchase
assert response.params['pageContents']
assert_equal response.params['pageContents'], response.redirect
end
-
+
def test_successful_confirmation
@gateway.expects(:ssl_post).returns(successful_confirmation_response)
@@ -36,15 +36,15 @@ def test_successful_confirmation
end
private
-
+
def successful_purchase_response
'responseType=R&pageContents=%3CHTML%3E%3CHEAD%3E%3C%2FHEAD%3E%3CBODY%3E%3CFORM%20action%3D%22https%3A%2F%2Fpayments%2Ebeanstream%2Ecom%2FiOnlineEmulator%2Fgateway%2Easp%22%20method%3DPOST%20id%3DfrmIOnline%20name%3DfrmIOnline%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FMERCHNUM%22%20%20value%3D%2210010162199999%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FAMOUNT%22%20%20value%3D%221500%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FTERMID%22%20value%3D%2262199999%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FCURRENCY%22%20value%3D%22CAD%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FINVOICE%22%20value%3D%221be7db7a129b07ac5f7e%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FMERCHDATA%22%20value%3D%226CE36AF7%2D5013%2D4B94%2DB740153714A41962%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FFUNDEDURL%22%20value%3D%22https%3A%2F%2Fwww%2Ebeanstream%2Ecom%2Fscripts%2Fprocess%5Ftransaction%5Fauth%2Easp%3F%26funded%3D1%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FNOTFUNDEDURL%22%20value%3D%22https%3A%2F%2Fwww%2Ebeanstream%2Ecom%2Fscripts%2Fprocess%5Ftransaction%5Fauth%2Easp%3F%26funded%3D0%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22merchant%5Fname%22%20value%3D%22Cody%20Fauser%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22referHost%22%20value%3D%22https%3A%2F%2Fwww%2Ebeanstream%2Ecom%2Fscripts%2Fprocess%5Ftransaction%2Easp%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22referHost2%22%20value%3D%22https%3A%2F%2Fwww%2Ecatnrose%2Ecom%2Fioxml%2Easp%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22referHost3%22%20value%3D%22%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FMERCHLANG%22%20value%3D%22en%22%3E%3Cinput%20type%3D%22hidden%22%20name%3D%22IDEBIT%5FVERSION%22%20value%3D%221%22%3E%3C%2FFORM%3E%3CSCRIPT%20language%3D%22JavaScript%22%3Edocument%2EfrmIOnline%2Esubmit%28%29%3B%3C%2FSCRIPT%3E%3C%2FBODY%3E%3C%2FHTML%3E'
end
-
+
def successful_return_from_interac_online
'bank_choice=1&merchant_name=Billing+Boss+IO+SB&confirmValue=&headerText=&IDEBIT_MERCHDATA=C4B50A48-6E11-4C21-A31EF4A602BC0099&IDEBIT_INVOICE=18face21593b59c7bb7e&IDEBIT_AMOUNT=1500&IDEBIT_FUNDEDURL=http%3A%2F%2Febay.massapparel.com%3A8000%2Finterac%2Ffunded%3Ffunded%3D1&IDEBIT_NOTFUNDEDURL=http%3A%2F%2Febay.massapparel.com%3A8000%2Finterac%2Fnotfunded%3Ffunded%3D0&IDEBIT_ISSLANG=en&IDEBIT_TRACK2=3728024906540591214%3D12010123456789XYZ&IDEBIT_ISSCONF=CONF%23TEST&IDEBIT_ISSNAME=TestBank1&IDEBIT_VERSION=1&accountType=Chequing'
end
-
+
def successful_confirmation_response
'trnApproved=1&trnId=10000029&messageId=1&messageText=Approved&trnOrderNumber=f29d2406b49b239b6dfb5db1f642b2&authCode=TEST&errorType=N&errorFields=&responseType=T&trnAmount=5%2E00&trnDate=6%2F8%2F2008+3%3A17%3A12+PM&avsProcessed=0&avsId=0&avsResult=0&avsAddrMatch=0&avsPostalMatch=0&avsMessage=Address+Verification+not+performed+for+this+transaction%2E&trnType=P&paymentMethod=IO&ioConfCode=CONF%23TEST&ioInstName=TestBank1&ref1=reference+one&ref2=&ref3=&ref4=&ref5='
end
diff --git a/test/unit/gateways/cecabank_test.rb b/test/unit/gateways/cecabank_test.rb
index 3ed551400fe..f58aa10e620 100644
--- a/test/unit/gateways/cecabank_test.rb
+++ b/test/unit/gateways/cecabank_test.rb
@@ -72,7 +72,7 @@ def test_unsuccessful_refund_request
assert_failure response
assert response.test?
end
-
+
def test_transcript_scrubbing
assert_equal scrubbed_transcript, @gateway.scrub(transcript)
end
diff --git a/test/unit/gateways/federated_canada_test.rb b/test/unit/gateways/federated_canada_test.rb
index 0e9497ae03c..cad64a37f16 100644
--- a/test/unit/gateways/federated_canada_test.rb
+++ b/test/unit/gateways/federated_canada_test.rb
@@ -11,13 +11,13 @@ def setup
@credit_card.verification_value = '999'
@amount = 100
- @options = {
+ @options = {
:order_id => '1',
:billing_address => address,
:description => 'Store Purchase'
}
end
-
+
def test_successful_authorization
@gateway.expects(:ssl_post).returns(successful_authorization_response)
options = {:billing_address => {:address1 => '888', :address2 => 'apt 13', :country => 'CA', :state => 'SK', :city => 'Big Beaver', :zip => '77777'}}
@@ -26,18 +26,18 @@ def test_successful_authorization
assert_success response
assert_equal '1355694937', response.authorization
assert_equal 'auth', response.params['type']
- end
-
+ end
+
def test_successful_purchase
@gateway.expects(:ssl_post).returns(successful_purchase_response)
assert response = @gateway.purchase(@amount, @credit_card, @options)
assert_instance_of Response, response
assert_success response
assert_equal '1346648416', response.authorization
- assert_equal 'sale', response.params['type']
+ assert_equal 'sale', response.params['type']
assert response.test?
end
-
+
def test_unsuccessful_request
@gateway.expects(:ssl_post).returns(failed_purchase_response)
assert response = @gateway.purchase(@amount, @credit_card, @options)
@@ -51,7 +51,7 @@ def test_add_address
assert_equal ['address1', 'address2', 'city', 'company', 'country', 'phone', 'state', 'zip'], result.stringify_keys.keys.sort
assert_equal 'SK', result[:state]
assert_equal '123 Happy Town Road', result[:address1]
- assert_equal 'apt 13', result[:address2]
+ assert_equal 'apt 13', result[:address2]
assert_equal 'CA', result[:country]
end
@@ -61,15 +61,15 @@ def test_add_invoice
assert_equal '#1001', result[:orderid]
assert_equal 'This is a great order', result[:orderdescription]
end
-
+
def test_purchase_is_valid_csv
params = {:amount => @amount}
@gateway.send(:add_creditcard, params, @credit_card)
assert data = @gateway.send(:post_data, 'auth', params)
assert_equal post_data_fixture.size, data.size
- end
-
+ end
+
def test_purchase_meets_minimum_requirements
params = {:amount => @amount}
@gateway.send(:add_creditcard, params, @credit_card)
@@ -78,7 +78,7 @@ def test_purchase_meets_minimum_requirements
assert_not_nil(data.include?(key))
end
end
-
+
def test_expdate_formatting
assert_equal '0909', @gateway.send(:expdate, credit_card('4111111111111111', :month => '9', :year => '2009'))
assert_equal '0711', @gateway.send(:expdate, credit_card('4111111111111111', :month => '7', :year => '2011'))
@@ -103,7 +103,7 @@ def test_cvv_result
response = @gateway.purchase(@amount, @credit_card)
assert_equal 'M', response.cvv_result['code']
end
-
+
def test_amount
assert_equal '1.00', @gateway.send(:amount, 100)
assert_equal '10.00', @gateway.send(:amount, 1000)
@@ -111,17 +111,17 @@ def test_amount
@gateway.send(:amount, '10.00')
end
end
-
+
private
-
+
def post_data_fixture
'password=password&type=auth&ccnumber=4111111111111111&username=demo&ccexp=1111&amount=100&cvv=999'
end
-
+
def minimum_requirements
%w{type username password amount ccnumber ccexp}
end
-
+
# Raw successful authorization response
def successful_authorization_response
'response=1&responsetext=SUCCESS&authcode=123456&transactionid=1355694937&avsresponse=Y&cvvresponse=M&orderid=&type=auth&response_code=100'
@@ -131,7 +131,7 @@ def successful_authorization_response
def successful_purchase_response
'response=1&responsetext=SUCCESS&authcode=123456&transactionid=1346648416&avsresponse=N&cvvresponse=N&orderid=&type=sale&response_code=100'
end
-
+
# Raw failed sale response
def failed_purchase_response
'response=2&responsetext=DECLINE&authcode=&transactionid=1346648595&avsresponse=N&cvvresponse=N&orderid=&type=sale&response_code=200'
diff --git a/test/unit/gateways/global_collect_test.rb b/test/unit/gateways/global_collect_test.rb
index 8ad5d5a1c02..4424d29d787 100644
--- a/test/unit/gateways/global_collect_test.rb
+++ b/test/unit/gateways/global_collect_test.rb
@@ -216,7 +216,7 @@ def test_invalid_raw_response
response = stub_comms do
@gateway.purchase(@accepted_amount, @credit_card, @options)
end.respond_with(invalid_json_response)
-
+
assert_failure response
assert_match %r{^Invalid response received from the Ingenico ePayments}, response.message
end
@@ -230,7 +230,7 @@ def test_scrub_invalid_response
response = stub_comms do
@gateway.purchase(@accepted_amount, @credit_card, @options)
end.respond_with(invalid_json_plus_card_data).message
-
+
assert_equal @gateway.scrub(response), scrubbed_invalid_json_plus
end
@@ -393,22 +393,22 @@ def failed_verify_response
end
def invalid_json_response
- '
-
- 502 Proxy Error
-
- Proxy Error
- The proxy server received an invalid
- response from an upstream server.
- The proxy server could not handle the request POST /v1/9040/payments.
- Reason: Error reading from remote server
+ '
+
+ 502 Proxy Error
+
+ Proxy Error
+ The proxy server received an invalid
+ response from an upstream server.
+ The proxy server could not handle the request POST /v1/9040/payments.
+ Reason: Error reading from remote server
'
end
def invalid_json_plus_card_data
- %q(
-
- 502 Proxy Error
+ %q(
+
+ 502 Proxy Error
opening connection to api-sandbox.globalcollect.com:443...
opened
@@ -429,6 +429,6 @@ def invalid_json_plus_card_data
end
def scrubbed_invalid_json_plus
- "Invalid response received from the Ingenico ePayments (formerly GlobalCollect) API. Please contact Ingenico ePayments if you continue to receive this message. (The raw response returned by the API was \" \\n \\n 502 Proxy Error \\n \\n opening connection to api-sandbox.globalcollect.com:443...\\n opened\\n starting SSL for api-sandbox.globalcollect.com:443...\\n SSL established\\n <- \\\"POST //v1/1428/payments HTTP/1.1\\\\r\\\\nContent-Type: application/json\\\\r\\\\nAuthorization: [FILTERED]\\\\r\\\\nDate: Tue, 15 Mar 2016 14:32:13 GMT\\\\r\\\\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\\\\r\\\\nAccept: */*\\\\r\\\\nUser-Agent: Ruby\\\\r\\\\nConnection: close\\\\r\\\\nHost: api-sandbox.globalcollect.com\\\\r\\\\nContent-Length: 560\\\\r\\\\n\\\\r\\\\n\\\"\\n <- \\\"{\\\\\\\"order\\\\\\\":{\\\\\\\"amountOfMoney\\\\\\\":{\\\\\\\"amount\\\\\\\":\\\\\\\"100\\\\\\\",\\\\\\\"currencyCode\\\\\\\":\\\\\\\"USD\\\\\\\"},\\\\\\\"customer\\\\\\\":{\\\\\\\"merchantCustomerId\\\\\\\":null,\\\\\\\"personalInformation\\\\\\\":{\\\\\\\"name\\\\\\\":{\\\\\\\"firstName\\\\\\\":null,\\\\\\\"surname\\\\\\\":null}},\\\\\\\"billingAddress\\\\\\\":{\\\\\\\"street\\\\\\\":\\\\\\\"456 My Street\\\\\\\",\\\\\\\"additionalInfo\\\\\\\":\\\\\\\"Apt 1\\\\\\\",\\\\\\\"zip\\\\\\\":\\\\\\\"K1C2N6\\\\\\\",\\\\\\\"city\\\\\\\":\\\\\\\"Ottawa\\\\\\\",\\\\\\\"state\\\\\\\":\\\\\\\"ON\\\\\\\",\\\\\\\"countryCode\\\\\\\":\\\\\\\"CA\\\\\\\"}},\\\\\\\"contactDetails\\\\\\\":{\\\\\\\"emailAddress\\\\\\\":null}},\\\\\\\"cardPaymentMethodSpecificInput\\\\\\\":{\\\\\\\"paymentProductId\\\\\\\":\\\\\\\"1\\\\\\\",\\\\\\\"skipAuthentication\\\\\\\":\\\\\\\"true\\\\\\\",\\\\\\\"skipFraudService\\\\\\\":\\\\\\\"true\\\\\\\",\\\\\\\"card\\\\\\\":{\\\\\\\"cvv\\\\\\\":\\\\\\\"[FILTERED]\\\\\\\",\\\\\\\"cardNumber\\\\\\\":\\\\\\\"[FILTERED]\\\\\\\",\\\\\\\"expiryDate\\\\\\\":\\\\\\\"0917\\\\\\\",\\\\\\\"cardholderName\\\\\\\":\\\\\\\"Longbob Longsen\\\\\\\"}}}\\\"\\n -> \\\"HTTP/1.1 201 Created\\\\r\\\\n\\\"\\n -> \\\"Date: Tue, 15 Mar 2016 18:32:14 GMT\\\\r\\\\n\\\"\\n -> \\\"Server: Apache/2.4.16 (Unix) OpenSSL/1.0.1p\\\\r\\\\n\\\"\\n -> \\\"Location: https://api-sandbox.globalcollect.com:443/v1/1428/payments/000000142800000000300000100001\\\\r\\\\n\\\"\\n -> \\\"X-Powered-By: Servlet/3.0 JSP/2.2\\\\r\\\\n\\\"\\n -> \\\"Connection: close\\\\r\\\\n\\\"\\n -> \\\"Transfer-Encoding: chunked\\\\r\\\\n\\\"\\n -> \\\"Content-Type: application/json\\\\r\\\\n\\\"\\n -> \\\"\\\\r\\\\n\\\"\\n -> \\\"457\\\\r\\\\n\\\"\")"
+ "Invalid response received from the Ingenico ePayments (formerly GlobalCollect) API. Please contact Ingenico ePayments if you continue to receive this message. (The raw response returned by the API was \"\\n \\n 502 Proxy Error\\n \\n opening connection to api-sandbox.globalcollect.com:443...\\n opened\\n starting SSL for api-sandbox.globalcollect.com:443...\\n SSL established\\n <- \\\"POST //v1/1428/payments HTTP/1.1\\\\r\\\\nContent-Type: application/json\\\\r\\\\nAuthorization: [FILTERED]\\\\r\\\\nDate: Tue, 15 Mar 2016 14:32:13 GMT\\\\r\\\\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\\\\r\\\\nAccept: */*\\\\r\\\\nUser-Agent: Ruby\\\\r\\\\nConnection: close\\\\r\\\\nHost: api-sandbox.globalcollect.com\\\\r\\\\nContent-Length: 560\\\\r\\\\n\\\\r\\\\n\\\"\\n <- \\\"{\\\\\\\"order\\\\\\\":{\\\\\\\"amountOfMoney\\\\\\\":{\\\\\\\"amount\\\\\\\":\\\\\\\"100\\\\\\\",\\\\\\\"currencyCode\\\\\\\":\\\\\\\"USD\\\\\\\"},\\\\\\\"customer\\\\\\\":{\\\\\\\"merchantCustomerId\\\\\\\":null,\\\\\\\"personalInformation\\\\\\\":{\\\\\\\"name\\\\\\\":{\\\\\\\"firstName\\\\\\\":null,\\\\\\\"surname\\\\\\\":null}},\\\\\\\"billingAddress\\\\\\\":{\\\\\\\"street\\\\\\\":\\\\\\\"456 My Street\\\\\\\",\\\\\\\"additionalInfo\\\\\\\":\\\\\\\"Apt 1\\\\\\\",\\\\\\\"zip\\\\\\\":\\\\\\\"K1C2N6\\\\\\\",\\\\\\\"city\\\\\\\":\\\\\\\"Ottawa\\\\\\\",\\\\\\\"state\\\\\\\":\\\\\\\"ON\\\\\\\",\\\\\\\"countryCode\\\\\\\":\\\\\\\"CA\\\\\\\"}},\\\\\\\"contactDetails\\\\\\\":{\\\\\\\"emailAddress\\\\\\\":null}},\\\\\\\"cardPaymentMethodSpecificInput\\\\\\\":{\\\\\\\"paymentProductId\\\\\\\":\\\\\\\"1\\\\\\\",\\\\\\\"skipAuthentication\\\\\\\":\\\\\\\"true\\\\\\\",\\\\\\\"skipFraudService\\\\\\\":\\\\\\\"true\\\\\\\",\\\\\\\"card\\\\\\\":{\\\\\\\"cvv\\\\\\\":\\\\\\\"[FILTERED]\\\\\\\",\\\\\\\"cardNumber\\\\\\\":\\\\\\\"[FILTERED]\\\\\\\",\\\\\\\"expiryDate\\\\\\\":\\\\\\\"0917\\\\\\\",\\\\\\\"cardholderName\\\\\\\":\\\\\\\"Longbob Longsen\\\\\\\"}}}\\\"\\n -> \\\"HTTP/1.1 201 Created\\\\r\\\\n\\\"\\n -> \\\"Date: Tue, 15 Mar 2016 18:32:14 GMT\\\\r\\\\n\\\"\\n -> \\\"Server: Apache/2.4.16 (Unix) OpenSSL/1.0.1p\\\\r\\\\n\\\"\\n -> \\\"Location: https://api-sandbox.globalcollect.com:443/v1/1428/payments/000000142800000000300000100001\\\\r\\\\n\\\"\\n -> \\\"X-Powered-By: Servlet/3.0 JSP/2.2\\\\r\\\\n\\\"\\n -> \\\"Connection: close\\\\r\\\\n\\\"\\n -> \\\"Transfer-Encoding: chunked\\\\r\\\\n\\\"\\n -> \\\"Content-Type: application/json\\\\r\\\\n\\\"\\n -> \\\"\\\\r\\\\n\\\"\\n -> \\\"457\\\\r\\\\n\\\"\")"
end
end
diff --git a/test/unit/gateways/instapay_test.rb b/test/unit/gateways/instapay_test.rb
index 16880aab17f..d70c9c52f72 100644
--- a/test/unit/gateways/instapay_test.rb
+++ b/test/unit/gateways/instapay_test.rb
@@ -42,31 +42,31 @@ def test_unsuccessful_auth
assert_failure response
assert_nil response.authorization
end
-
+
def test_avs_result
@gateway.expects(:ssl_post).returns(successful_purchase_response)
-
+
response = @gateway.purchase(@amount, @credit_card)
assert_equal 'X', response.avs_result['code']
end
-
+
def test_cvv_result
@gateway.expects(:ssl_post).returns(successful_purchase_response)
-
+
response = @gateway.purchase(@amount, @credit_card)
assert_equal 'M', response.cvv_result['code']
end
-
+
def test_successful_capture
@gateway.expects(:ssl_post).returns(successful_capture_response)
-
+
response = @gateway.capture(100, '123456')
assert_equal InstapayGateway::SUCCESS_MESSAGE, response.message
end
-
+
def test_failed_capture
@gateway.expects(:ssl_post).returns(failed_capture_response)
-
+
response = @gateway.capture(100, '123456')
assert_equal 'Post amount exceeds Auth amount', response.message
end
@@ -82,7 +82,7 @@ def successful_purchase_response
def failed_purchase_response
"\r\nDeclined=DECLINED:0720930009:CVV2 MISMATCH:N7\r\nhistoryid=118583848\r\norderid=92886713\r\nACCOUNTNUMBER=************2220\r\nDeclined=DECLINED:0720930009:CVV2 MISMATCH:N7\r\nhistoryid=118583848\r\norderid=92886713\r\nrcode=0720930009\r\nReason=DECLINED:0720930009:CVV2 MISMATCH:N7\r\nrecurid=0\r\nresult=0\r\nStatus=Declined\r\ntransid=80410586\r\n"
end
-
+
def successful_auth_response
"\r\nAccepted=AUTH:TEST:::118585994:::\r\nhistoryid=118585994\r\norderid=92888143\r\nAccepted=AUTH:TEST:::118585994:::\r\nACCOUNTNUMBER=************5454\r\nauthcode=TEST\r\nAuthNo=AUTH:TEST:::118585994:::\r\nhistoryid=118585994\r\norderid=92888143\r\nrecurid=0\r\nrefcode=118585994-TEST\r\nresult=1\r\nStatus=Accepted\r\ntransid=0\r\n"
end
@@ -90,11 +90,11 @@ def successful_auth_response
def failed_auth_response
"\r\nDeclined=DECLINED:0720930009:CVV2 MISMATCH:N7\r\nhistoryid=118585991\r\norderid=92888142\r\nACCOUNTNUMBER=************2220\r\nDeclined=DECLINED:0720930009:CVV2 MISMATCH:N7\r\nhistoryid=118585991\r\norderid=92888142\r\nrcode=0720930009\r\nReason=DECLINED:0720930009:CVV2 MISMATCH:N7\r\nrecurid=0\r\nresult=0\r\nStatus=Declined\r\ntransid=80412271\r\n"
end
-
+
def successful_capture_response
"\r\nAccepted=AVSAUTH:TEST:::121609962::::DUPLICATE\r\nhistoryid=121609962\r\norderid=95009583\r\nAccepted=AVSAUTH:TEST:::121609962::::DUPLICATE\r\nACCOUNTNUMBER=************5454\r\nauthcode=TEST\r\nAuthNo=AVSAUTH:TEST:::121609962::::DUPLICATE\r\nDUPLICATE=1\r\nhistoryid=121609962\r\norderid=95009583\r\nrecurid=0\r\nrefcode=121609962-TEST\r\nresult=1\r\nStatus=Accepted\r\ntransid=0\r\n"
end
-
+
def failed_capture_response
"\r\nDeclined=DECLINED:1101450002:Post amount exceeds Auth amount:\r\nhistoryid=\r\norderid=\r\nDeclined=DECLINED:1101450002:Post amount exceeds Auth amount:\r\nrcode=1101450002\r\nReason=DECLINED:1101450002:Post amount exceeds Auth amount:\r\nresult=0\r\nStatus=Declined\r\ntransid=0\r\n"
end
diff --git a/test/unit/gateways/itransact_test.rb b/test/unit/gateways/itransact_test.rb
index e1fe37ef8e3..5f43bfc702f 100644
--- a/test/unit/gateways/itransact_test.rb
+++ b/test/unit/gateways/itransact_test.rb
@@ -11,8 +11,8 @@ def setup
@credit_card = credit_card
@check = check
@amount = 1014 # = $10.14
-
- @options = {
+
+ @options = {
:email => 'name@domain.com',
:order_id => '1',
:billing_address => address,
@@ -20,14 +20,14 @@ def setup
:email_text => ['line1', 'line2', 'line3']
}
end
-
+
def test_successful_card_purchase
@gateway.expects(:ssl_post).returns(successful_card_purchase_response)
-
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
assert_instance_of Response, response
assert_success response
-
+
assert_equal '9999999999', response.authorization
assert response.test?
end
@@ -45,19 +45,19 @@ def test_successful_check_purchase
def test_unsuccessful_card_request
@gateway.expects(:ssl_post).returns(failed_purchase_response)
-
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
assert_failure response
assert response.test?
end
private
-
+
def successful_card_purchase_response
"
ok20081216141214TRUE1.099999999991234 My StreetOttawaLongbobLongsenONK1C2N6CA(555)555-5555"
end
-
+
def failed_purchase_response
'
FAILEDREQUEST_FORMATForm does not contain xml parameter'
diff --git a/test/unit/gateways/mundipagg_test.rb b/test/unit/gateways/mundipagg_test.rb
index f8fe08779cb..7caa206f0d0 100644
--- a/test/unit/gateways/mundipagg_test.rb
+++ b/test/unit/gateways/mundipagg_test.rb
@@ -712,7 +712,7 @@ def successful_void_response
def failed_void_response
'{"message": "Charge not found."}'
end
-
+
def successful_verify_response
%(
{
diff --git a/test/unit/gateways/pay_secure_test.rb b/test/unit/gateways/pay_secure_test.rb
index 32ba6132b64..a49bf1a60f0 100644
--- a/test/unit/gateways/pay_secure_test.rb
+++ b/test/unit/gateways/pay_secure_test.rb
@@ -1,7 +1,7 @@
require 'test_helper'
class PaySecureTest < Test::Unit::TestCase
-
+
def setup
@gateway = PaySecureGateway.new(
:login => 'login',
@@ -9,14 +9,14 @@ def setup
)
@credit_card = credit_card
- @options = {
+ @options = {
:order_id => '1000',
:billing_address => address,
:description => 'Test purchase'
}
@amount = 100
end
-
+
def test_successful_purchase
@gateway.expects(:ssl_post).returns(successful_purchase_response)
assert response = @gateway.purchase(@amount, @credit_card, @options)
@@ -25,7 +25,7 @@ def test_successful_purchase
assert_equal '2778;SimProxy 54041670', response.authorization
assert response.test?
end
-
+
def test_failed_purchase
@gateway.expects(:ssl_post).returns(failure_response)
assert response = @gateway.purchase(@amount, @credit_card, @options)
@@ -33,21 +33,21 @@ def test_failed_purchase
assert_equal "Field value '8f796cb29a1be32af5ce12d4ca7425c2' does not match required format.", response.message
assert_failure response
end
-
+
def test_avs_result_not_supported
@gateway.expects(:ssl_post).returns(successful_purchase_response)
-
- response = @gateway.purchase(@amount, @credit_card, @options)
+
+ response = @gateway.purchase(@amount, @credit_card, @options)
assert_nil response.avs_result['code']
end
-
+
def test_cvv_result_not_supported
@gateway.expects(:ssl_post).returns(successful_purchase_response)
-
+
response = @gateway.purchase(@amount, @credit_card, @options)
assert_nil response.cvv_result['code']
end
-
+
private
def successful_purchase_response
@@ -61,7 +61,7 @@ def successful_purchase_response
TransID: SimProxy 54041670
RESPONSE
end
-
+
def failure_response
<<-RESPONSE
Status: Declined
diff --git a/test/unit/gateways/payflow_uk_test.rb b/test/unit/gateways/payflow_uk_test.rb
index e7adc1b7fd9..9d50c599edd 100644
--- a/test/unit/gateways/payflow_uk_test.rb
+++ b/test/unit/gateways/payflow_uk_test.rb
@@ -11,19 +11,19 @@ def setup
def test_default_currency
assert_equal 'GBP', PayflowUkGateway.default_currency
end
-
+
def test_express_instance
assert_instance_of PayflowExpressUkGateway, @gateway.express
end
-
+
def test_default_partner
assert_equal 'PayPalUk', PayflowUkGateway.partner
end
-
+
def test_supported_countries
assert_equal ['GB'], PayflowUkGateway.supported_countries
end
-
+
def test_supported_card_types
assert_equal [:visa, :master, :american_express, :discover], PayflowUkGateway.supported_cardtypes
end
diff --git a/test/unit/gateways/psl_card_test.rb b/test/unit/gateways/psl_card_test.rb
index 9ef1a651b84..6a971d1815e 100644
--- a/test/unit/gateways/psl_card_test.rb
+++ b/test/unit/gateways/psl_card_test.rb
@@ -8,14 +8,14 @@ def setup
:password => 'PASSWORD'
)
- @credit_card = credit_card
+ @credit_card = credit_card
@options = {
:billing_address => address,
:description => 'Store purchase'
}
@amount = 100
end
-
+
def test_successful_authorization
@gateway.expects(:ssl_post).returns(successful_purchase_response)
assert response = @gateway.authorize(@amount, @credit_card, @options)
@@ -34,15 +34,15 @@ def test_unsuccessful_request
def test_supported_countries
assert_equal ['GB'], PslCardGateway.supported_countries
end
-
+
def test_supported_card_types
assert_equal [ :visa, :master, :american_express, :diners_club, :jcb, :maestro ], PslCardGateway.supported_cardtypes
end
-
+
def test_avs_result
@gateway.expects(:ssl_post).returns(successful_purchase_response)
- response = @gateway.purchase(@amount, @credit_card, @options)
+ response = @gateway.purchase(@amount, @credit_card, @options)
assert_equal 'Y', response.avs_result['code']
end
@@ -52,13 +52,13 @@ def test_cvv_result
response = @gateway.purchase(@amount, @credit_card, @options)
assert_equal 'M', response.cvv_result['code']
end
-
+
private
def successful_purchase_response
'ResponseCode=00&Message=AUTHCODE:01256&CrossReference=08012522454901256086&First4=4543&Last4=9982&ExpMonth=12&ExpYear=2010&AVSCV2Check=ALL MATCH&Amount=1000&QAAddress=76 Roseby Avenue Manchester&QAPostcode=M63X 7TH&MerchantName=Merchant Name&QAName=John Smith'
end
-
+
def unsuccessful_purchase_response
'ResponseCode=05&Message=CARD DECLINED&QAAddress=The Parkway Larches Approach Hull North Humberside&QAPostcode=HU7 9OP&MerchantName=Merchant Name&QAName='
end
diff --git a/test/unit/gateways/quantum_test.rb b/test/unit/gateways/quantum_test.rb
index a1d771cd8b0..10bb11ccaf4 100644
--- a/test/unit/gateways/quantum_test.rb
+++ b/test/unit/gateways/quantum_test.rb
@@ -9,19 +9,19 @@ def setup
@credit_card = credit_card
@amount = 100
-
- @options = {
+
+ @options = {
:billing_address => address,
:description => 'Store Purchase'
}
end
-
+
def test_successful_purchase
@gateway.expects(:ssl_post).returns(successful_purchase_response)
-
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
assert_success response
-
+
# Replace with authorization number from the successful response
assert_equal '2983691;2224', response.authorization
assert response.test?
@@ -29,14 +29,14 @@ def test_successful_purchase
def test_unsuccessful_request
@gateway.expects(:ssl_post).returns(failed_purchase_response)
-
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
assert_failure response
assert response.test?
end
-
+
private
-
+
# Place raw successful response from gateway here
def successful_purchase_response
%(
@@ -74,7 +74,7 @@ def successful_purchase_response
)
end
-
+
# Place raw failed response from gateway here
def failed_purchase_response
%(
diff --git a/test/unit/gateways/quickpay_test.rb b/test/unit/gateways/quickpay_test.rb
index 98bb37cb941..f9f2e2d28cd 100644
--- a/test/unit/gateways/quickpay_test.rb
+++ b/test/unit/gateways/quickpay_test.rb
@@ -1,21 +1,21 @@
require 'test_helper'
class QuickpayTest < Test::Unit::TestCase
-
+
def test_error_without_login_option
assert_raise ArgumentError do
QuickpayGateway.new
end
end
-
+
def test_v4to7
- gateway = QuickpayGateway.new(:login => 50000000, :password => 'secret')
+ gateway = QuickpayGateway.new(:login => 50000000, :password => 'secret')
assert_instance_of QuickpayV4to7Gateway, gateway
end
-
+
def test_v10
- gateway = QuickpayGateway.new(:login => 100, :api_key => 'APIKEY')
+ gateway = QuickpayGateway.new(:login => 100, :api_key => 'APIKEY')
assert_instance_of QuickpayV10Gateway, gateway
end
-
+
end
diff --git a/test/unit/gateways/quickpay_v4to7_test.rb b/test/unit/gateways/quickpay_v4to7_test.rb
index a01c4b5315c..74e395980ca 100644
--- a/test/unit/gateways/quickpay_v4to7_test.rb
+++ b/test/unit/gateways/quickpay_v4to7_test.rb
@@ -2,11 +2,11 @@
class QuickpayV4to7Test < Test::Unit::TestCase
include CommStub
-
+
def merchant_id
- '80000000000'
+ '80000000000'
end
-
+
def setup
@gateway = QuickpayGateway.new(
:login => merchant_id,
diff --git a/test/unit/gateways/secure_pay_tech_test.rb b/test/unit/gateways/secure_pay_tech_test.rb
index 90847f8e9d6..87293a7f817 100644
--- a/test/unit/gateways/secure_pay_tech_test.rb
+++ b/test/unit/gateways/secure_pay_tech_test.rb
@@ -13,32 +13,32 @@ def setup
:billing_address => address
}
end
-
+
def test_successful_purchase
@gateway.expects(:ssl_post).returns(successful_purchase_response)
-
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
assert_instance_of Response, response
assert_success response
assert response.test?
assert_equal '4--120119220646821', response.authorization
end
-
+
def test_unsuccessful_purchase
@gateway.expects(:ssl_post).returns(unsuccessful_purchase_response)
-
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
assert_instance_of Response, response
assert_failure response
assert response.test?
end
-
+
private
def successful_purchase_response
"1,4--120119220646821,000000014511,23284,014511,20080125\r\n"
end
-
+
def unsuccessful_purchase_response
"4,4--120119180936527,000000014510,23283,014510,20080125\r\n"
end
diff --git a/test/unit/gateways/trexle_test.rb b/test/unit/gateways/trexle_test.rb
index 288ca190d21..5ce9da270f2 100644
--- a/test/unit/gateways/trexle_test.rb
+++ b/test/unit/gateways/trexle_test.rb
@@ -42,7 +42,7 @@ def test_supported_countries
GI GR HK HU ID IE IL IM IN IS IT JO KW LB LI LK LT LU LV MC
MT MU MV MX MY NL NO NZ OM PH PL PT QA RO SA SE SG SI SK SM
TR TT UM US VA VN ZA)
- assert_equal expected_supported_countries, TrexleGateway.supported_countries
+ assert_equal expected_supported_countries, TrexleGateway.supported_countries
end
def test_supported_cardtypes
@@ -302,8 +302,8 @@ def test_transcript_scrubbing
private
def successful_purchase_response
- '{
- "response":{
+ '{
+ "response":{
"token":"charge_0cfad7ee5ffe75f58222bff214bfa5cc7ad7c367",
"success":true,
"captured":true
@@ -312,17 +312,17 @@ def successful_purchase_response
end
def failed_purchase_response
- '{
+ '{
"error":"Payment failed",
"detail":"An error occurred while processing your card. Try again in a little bit."
}'
end
def successful_store_response
- '{
- "response":{
+ '{
+ "response":{
"token":"token_2cb443cf26b6ecdadd8144d1fac8240710aa41f1",
- "card":{
+ "card":{
"token":"token_f974687e4e866d6cca534e1cd42236817d315b3a",
"primary":true
}
@@ -331,17 +331,17 @@ def successful_store_response
end
def failed_store_response
- '{
+ '{
"error":"an error has occured",
"detail":"invalid token"
}'
end
def successful_customer_store_response
- '{
- "response":{
+ '{
+ "response":{
"token":"token_940ade441a23d53e04017f53af6c3a1eae9978ae",
- "card":{
+ "card":{
"token":"token_9a3f559962cbf6828e2cc38a02023565b0294548",
"scheme":"master",
"display_number":"XXXX-XXXX-XXXX-4444",
@@ -362,15 +362,15 @@ def successful_customer_store_response
end
def failed_customer_store_response
- '{
+ '{
"error":"an error has occured",
"detail":"invalid token"
}'
end
def successful_refund_response
- '{
- "response":{
+ '{
+ "response":{
"token":"refund_7f696a86f9cb136520c51ea90c17f687b8df40b0",
"success":true,
"amount":100,
@@ -381,15 +381,15 @@ def successful_refund_response
end
def failed_refund_response
- '{
+ '{
"error":"Refund failed",
"detail":"invalid token"
}'
end
def successful_capture_response
- '{
- "response":{
+ '{
+ "response":{
"token":"charge_6e47a330dca67ec7f696e8b650db22fe69bb8499",
"success":true,
"captured":true
diff --git a/test/unit/gateways/viaklix_test.rb b/test/unit/gateways/viaklix_test.rb
index 6b624676452..ef288b6b652 100644
--- a/test/unit/gateways/viaklix_test.rb
+++ b/test/unit/gateways/viaklix_test.rb
@@ -7,8 +7,8 @@ def setup
:login => 'LOGIN',
:password => 'PIN'
)
-
- @credit_card = credit_card
+
+ @credit_card = credit_card
@options = {
:order_id => '37',
:email => 'paul@domain.com',
@@ -17,10 +17,10 @@ def setup
}
@amount = 100
end
-
- def test_purchase_success
+
+ def test_purchase_success
@gateway.expects(:ssl_post).returns(successful_purchase_response)
-
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
assert_instance_of Response, response
assert_success response
@@ -29,46 +29,46 @@ def test_purchase_success
def test_purchase_error
@gateway.expects(:ssl_post).returns(unsuccessful_purchase_response)
-
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
assert_instance_of Response, response
assert_failure response
end
-
+
def test_invalid_login
@gateway.expects(:ssl_post).returns(invalid_login_response)
-
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
-
+
assert_equal '7000', response.params['result']
assert_equal 'The viaKLIX ID and/or User ID supplied in the authorization request is invalid.', response.params['result_message']
assert_failure response
end
-
+
def test_avs_result
@gateway.expects(:ssl_post).returns(successful_purchase_response)
-
+
response = @gateway.purchase(@amount, @credit_card)
assert_equal 'Y', response.avs_result['code']
end
-
+
def test_cvv_result
@gateway.expects(:ssl_post).returns(successful_purchase_response)
-
+
response = @gateway.purchase(@amount, @credit_card)
assert_equal 'M', response.cvv_result['code']
end
-
+
private
-
+
def successful_purchase_response
"ssl_result=0\r\nssl_company=;\r\nssl_city=Herndon\r\nssl_avs_zip=90201\r\nssl_address2=\r\nssl_ship_to_last_name=Jacobs\r\nssl_ship_to_city=Herndon\r\nssl_approval_code=05737D\r\nssl_avs_response=Y\r\nssl_salestax=\r\nssl_ship_to_phone=\r\ncustomer_code=jacobsr1@cox.net\r\nship_to_country=US\r\ncountry=US\r\nssl_txn_id=7E2419F7-2354-4766-BF5C-19C75A1F379A\r\nssl_transaction_type=SALE\r\nssl_invoice_number=#1158.1\r\nssl_amount=243.95\r\nssl_card_number=43*******6820\r\nssl_description=\r\nssl_phone=703-404-9270\r\nssl_ship_to_avs_address=\r\nssl_first_name=Cody\r\nssl_avs_address=12213 Jonathons Glen Way\r\nssl_result_message=APPROVED\r\nssl_exp_date=1109\r\nssl_last_name=Fauser\r\nssl_ship_to_first_name=Robert\r\nssl_ship_to_address2=\r\nssl_ship_to_state=VA\r\nssl_ship_to_avs_zip=\r\nssl_cvv2_response=M\r\nssl_state=VA\r\nssl_email=cody@example.com\r\nssl_ship_to_company=\r\n"
end
-
+
def unsuccessful_purchase_response
"ssl_result=1\r\nssl_result_message=This transaction request has not been approved. You may elect to use another form of payment to complete this transaction or contact customer service for additional options."
end
-
+
def invalid_login_response
<<-RESPONSE
ssl_result=7000\r
From 4796e86750781e7d870134a7f4292948bc115710 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Tue, 23 Oct 2018 11:31:32 -0400
Subject: [PATCH 0125/2234] Revert "Mercado Pago: do not infer card type"
This reverts commit d9c5a1a011263c5677e7d0dc084d5fc2d16193ff.
This reversion is almost certainly temporary, but we were seeing
higher-than-expected inference errors when this went to production, so
we're temporarily going to pull this until we know what's up.
---
.../billing/gateways/mercado_pago.rb | 10 ++++-
test/unit/gateways/mercado_pago_test.rb | 38 ++++++++++---------
2 files changed, 28 insertions(+), 20 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/mercado_pago.rb b/lib/active_merchant/billing/gateways/mercado_pago.rb
index 51aafc8f457..3c841fccc53 100644
--- a/lib/active_merchant/billing/gateways/mercado_pago.rb
+++ b/lib/active_merchant/billing/gateways/mercado_pago.rb
@@ -10,6 +10,11 @@ class MercadoPagoGateway < Gateway
self.display_name = 'Mercado Pago'
self.money_format = :dollars
+ CARD_BRAND = {
+ 'american_express' => 'amex',
+ 'diners_club' => 'diners'
+ }
+
def initialize(options={})
requires!(options, :access_token)
super
@@ -18,6 +23,7 @@ def initialize(options={})
def purchase(money, payment, options={})
MultiResponse.run do |r|
r.process { commit('tokenize', 'card_tokens', card_token_request(money, payment, options)) }
+ options.merge!(card_brand: (CARD_BRAND[payment.brand] || payment.brand))
options.merge!(card_token: r.authorization.split('|').first)
r.process { commit('purchase', 'payments', purchase_request(money, payment, options) ) }
end
@@ -26,6 +32,7 @@ def purchase(money, payment, options={})
def authorize(money, payment, options={})
MultiResponse.run do |r|
r.process { commit('tokenize', 'card_tokens', card_token_request(money, payment, options)) }
+ options.merge!(card_brand: (CARD_BRAND[payment.brand] || payment.brand))
options.merge!(card_token: r.authorization.split('|').first)
r.process { commit('authorize', 'payments', authorize_request(money, payment, options) ) }
end
@@ -174,8 +181,7 @@ def add_invoice(post, money, options)
def add_payment(post, options)
post[:token] = options[:card_token]
- post[:issuer_id] = options[:issuer_id] if options[:issuer_id]
- post[:payment_method_id] = options[:payment_method_id] if options[:payment_method_id]
+ post[:payment_method_id] = options[:card_brand]
end
def parse(body)
diff --git a/test/unit/gateways/mercado_pago_test.rb b/test/unit/gateways/mercado_pago_test.rb
index 1e53016dde3..7b29e5252c8 100644
--- a/test/unit/gateways/mercado_pago_test.rb
+++ b/test/unit/gateways/mercado_pago_test.rb
@@ -149,14 +149,14 @@ def test_scrub
assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed
end
- def test_does_not_send_brand
+ def test_sends_american_express_as_amex
credit_card = credit_card('378282246310005', brand: 'american_express')
response = stub_comms do
@gateway.purchase(@amount, credit_card, @options)
end.check_request do |endpoint, data, headers|
if endpoint =~ /payments/
- assert_not_match(%r("payment_method_id":"amex"), data)
+ assert_match(%r("payment_method_id":"amex"), data)
end
end.respond_with(successful_purchase_response)
@@ -164,11 +164,11 @@ def test_does_not_send_brand
assert_equal '4141491|1.0', response.authorization
end
- def test_sends_payment_method_id
- credit_card = credit_card('30569309025904')
+ def test_sends_diners_club_as_diners
+ credit_card = credit_card('30569309025904', brand: 'diners_club')
response = stub_comms do
- @gateway.purchase(@amount, credit_card, @options.merge(payment_method_id: 'diners'))
+ @gateway.purchase(@amount, credit_card, @options)
end.check_request do |endpoint, data, headers|
if endpoint =~ /payments/
assert_match(%r("payment_method_id":"diners"), data)
@@ -179,6 +179,21 @@ def test_sends_payment_method_id
assert_equal '4141491|1.0', response.authorization
end
+ def test_sends_mastercard_as_master
+ credit_card = credit_card('5555555555554444', brand: 'master')
+
+ response = stub_comms do
+ @gateway.purchase(@amount, credit_card, @options)
+ end.check_request do |endpoint, data, headers|
+ if endpoint =~ /payments/
+ assert_match(%r("payment_method_id":"master"), data)
+ end
+ end.respond_with(successful_purchase_response)
+
+ assert_success response
+ assert_equal '4141491|1.0', response.authorization
+ end
+
def test_includes_deviceid_header
@options[:device_id] = '1a2b3c'
@gateway.expects(:ssl_post).with(anything, anything, headers = {'Content-Type' => 'application/json'}).returns(successful_purchase_response)
@@ -202,19 +217,6 @@ def test_includes_additional_data
assert_success response
end
- def test_includes_issuer_id
- response = stub_comms do
- @gateway.purchase(@amount, @credit_card, @options.merge(issuer_id: '1a2b3c4d'))
- end.check_request do |endpoint, data, headers|
- if endpoint =~ /payments/
- assert_match(%r("issuer_id":"1a2b3c4d"), data)
- end
- end.respond_with(successful_purchase_response)
-
- assert_success response
- assert_equal '4141491|1.0', response.authorization
- end
-
private
def pre_scrubbed
From 8e230ded182d3ff109d7617ecf9e21efc6811ef3 Mon Sep 17 00:00:00 2001
From: David Perry
Date: Tue, 23 Oct 2018 13:35:13 -0400
Subject: [PATCH 0126/2234] Authorize.Net: Pass some level 3 fields
This enables passing of some of the Level 3/III data and lineItem fields
for transactions that support them.
Also fixes some changelog formatting.
Remote:
69 tests, 238 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
95 tests, 558 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 13 +++--
.../billing/gateways/authorize_net.rb | 12 ++++
.../gateways/remote_authorize_net_test.rb | 53 ++++++++++++++----
test/unit/gateways/authorize_net_test.rb | 55 +++++++++++++++++++
4 files changed, 117 insertions(+), 16 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index a80da434731..314de3945ad 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,19 +1,20 @@
= ActiveMerchant CHANGELOG
== HEAD
-* UsaEpayTransaction: Support UMcheckformat option for echecks [dtykocki] [#3002]
-* Global Collect: handle internal server errors [molbrown] [#3005]
+* UsaEpayTransaction: Support UMcheckformat option for echecks [dtykocki] #3002
+* Global Collect: handle internal server errors [molbrown] #3005
* Barclaycard Smartpay: allow third-party payouts for credits [bpollack] #3009
* RuboCop: AlignHash [nfarve] #3004
* Beanstream: Switch `recurringPayment` flag from boolean to integer [dtykocki] #3011
-* Payflow Express: Add phone to returned Response [filipebarcos] [#3003]
+* Payflow Express: Add phone to returned Response [filipebarcos] #3003
+* Authorize.Net: Pass some level 3 fields [curiousepic] #3022
== Version 1.85.0 (September 28, 2018)
-* Authorize.Net: Support custom delimiter for cim [curiousepic] [#3001]
+* Authorize.Net: Support custom delimiter for cim [curiousepic] #3001
== Version 1.84.0 (September 27, 2018)
* PayU Latam: support partial captures [bpollack] #2974
-* Braintree: Reflect correct test mode in Braintree responses [elfassy] [#2980]
+* Braintree: Reflect correct test mode in Braintree responses [elfassy] #2980
* FirstPay: Expose error code [curiousepic] #2979
* Barclaycard Smartpay: Pass device_fingerprint when specified [dtykocki] #2981
* Komoju: remove no-longer-relevant sandbox URL [miyazawadegica] #2987
@@ -39,7 +40,7 @@
* Gateway generator: fix a typo that would cause the script to crash [bpollack] #2962
* Clearhaus: use $0 for verify transactions [bpollack] #2964
* Global Collect: properly handle partial captures [bpollack] #2967
-* Braintree: Add support for GooglePay [dtykocki] [#2966]
+* Braintree: Add support for GooglePay [dtykocki] #2966
* Adyen: allow overriding card brands [bpollack] #2968
* Adyen: allow custom routing [bpollack] #2969
* First Pay: Adds scrubbing [deedeelavinder] #2972
diff --git a/lib/active_merchant/billing/gateways/authorize_net.rb b/lib/active_merchant/billing/gateways/authorize_net.rb
index 0c4c4c0c8a0..75fa6c6fdd1 100644
--- a/lib/active_merchant/billing/gateways/authorize_net.rb
+++ b/lib/active_merchant/billing/gateways/authorize_net.rb
@@ -257,6 +257,7 @@ def add_auth_purchase(xml, transaction_type, amount, payment, options)
add_market_type_device_type(xml, payment, options)
add_settings(xml, payment, options)
add_user_fields(xml, amount, options)
+ add_ship_from_address(xml, options)
end
end
@@ -610,6 +611,16 @@ def add_shipping_address(xml, options, root_node='shipTo')
end
end
+ def add_ship_from_address(xml, options, root_node='shipFrom')
+ address = options[:ship_from_address]
+ return unless address
+
+ xml.send(root_node) do
+ xml.zip(truncate(address[:zip], 20)) unless empty?(address[:zip])
+ xml.country(truncate(address[:country], 60)) unless empty?(address[:country])
+ end
+ end
+
def add_order_id(xml, options)
xml.refId(truncate(options[:order_id], 20))
end
@@ -619,6 +630,7 @@ def add_invoice(xml, transaction_type, options)
xml.invoiceNumber(truncate(options[:order_id], 20))
xml.description(truncate(options[:description], 255))
xml.purchaseOrderNumber(options[:po_number]) if options[:po_number] && transaction_type.start_with?('profileTrans')
+ xml.summaryCommodityCode(truncate(options[:summary_commodity_code], 4)) if options[:summary_commodity_code] && !transaction_type.start_with?('profileTrans')
end
# Authorize.net API requires lineItems to be placed directly after order tag
diff --git a/test/remote/gateways/remote_authorize_net_test.rb b/test/remote/gateways/remote_authorize_net_test.rb
index 034e0f92cc8..2b239ad18bb 100644
--- a/test/remote/gateways/remote_authorize_net_test.rb
+++ b/test/remote/gateways/remote_authorize_net_test.rb
@@ -36,6 +36,16 @@ def setup
tax_exempt: 'false',
po_number: '123'
}
+
+ @level_3_options = {
+ ship_from_address: {
+ zip: '27701',
+ country: 'US'
+ },
+ summary_commodity_code: 'CODE'
+ }
+
+ @level_2_and_3_options = @level_2_options.merge(@level_3_options)
end
def test_successful_purchase
@@ -105,8 +115,31 @@ def test_successful_purchase_with_line_items
assert response.authorization
end
- def test_successful_purchase_with_level_2_data
- response = @gateway.purchase(@amount, @credit_card, @options.merge(@level_2_options))
+ def test_successful_purchase_with_level_3_line_item_data
+ additional_options = {
+ email: 'anet@example.com',
+ line_items: [
+ {
+ item_id: '1',
+ name: 'mug',
+ description: 'coffee',
+ quantity: '100',
+ unit_price: '10',
+ unit_of_measure: 'yards',
+ total_amount: '1000',
+ product_code: 'coupon'
+ }
+ ]
+ }
+ response = @gateway.purchase(@amount, @credit_card, @options.merge(additional_options))
+ assert_success response
+ assert response.test?
+ assert_equal 'This transaction has been approved', response.message
+ assert response.authorization
+ end
+
+ def test_successful_purchase_with_level_2_and_3_data
+ response = @gateway.purchase(@amount, @credit_card, @options.merge(@level_2_and_3_options))
assert_success response
assert_equal 'This transaction has been approved', response.message
end
@@ -361,11 +394,11 @@ def test_successful_purchase_using_stored_card_new_payment_profile
assert_equal 'This transaction has been approved.', response.message
end
- def test_successful_purchase_with_stored_card_and_level_2_data
+ def test_successful_purchase_with_stored_card_and_level_2_and_3_data
store_response = @gateway.store(@credit_card, @options)
assert_success store_response
- response = @gateway.purchase(@amount, store_response.authorization, @options.merge(@level_2_options))
+ response = @gateway.purchase(@amount, store_response.authorization, @options.merge(@level_2_and_3_options))
assert_success response
assert_equal 'This transaction has been approved.', response.message
end
@@ -383,15 +416,15 @@ def test_successful_authorize_and_capture_using_stored_card
assert_equal 'This transaction has been approved.', capture.message
end
- def test_successful_authorize_and_capture_using_stored_card_with_level_2_data
+ def test_successful_authorize_and_capture_using_stored_card_with_level_2_and_3_data
store = @gateway.store(@credit_card, @options)
assert_success store
- auth = @gateway.authorize(@amount, store.authorization, @options.merge(@level_2_options))
+ auth = @gateway.authorize(@amount, store.authorization, @options.merge(@level_2_and_3_options))
assert_success auth
assert_equal 'This transaction has been approved.', auth.message
- capture = @gateway.capture(@amount, auth.authorization, @options.merge(@level_2_options))
+ capture = @gateway.capture(@amount, auth.authorization, @options.merge(@level_2_and_3_options))
assert_success capture
assert_equal 'This transaction has been approved.', capture.message
end
@@ -467,14 +500,14 @@ def test_faux_successful_refund_using_stored_card
assert_match %r{does not meet the criteria for issuing a credit}, refund.message, 'Only allowed to refund transactions that have settled. This is the best we can do for now testing wise.'
end
- def test_faux_successful_refund_using_stored_card_and_level_2_data
+ def test_faux_successful_refund_using_stored_card_and_level_2_and_3_data
store = @gateway.store(@credit_card, @options)
assert_success store
- purchase = @gateway.purchase(@amount, store.authorization, @options.merge(@level_2_options))
+ purchase = @gateway.purchase(@amount, store.authorization, @options.merge(@level_2_and_3_options))
assert_success purchase
- refund = @gateway.refund(@amount, purchase.authorization, @options.merge(@level_2_options))
+ refund = @gateway.refund(@amount, purchase.authorization, @options.merge(@level_2_and_3_options))
assert_failure refund
assert_match %r{does not meet the criteria for issuing a credit}, refund.message, 'Only allowed to refund transactions that have settled. This is the best we can do for now testing wise.'
end
diff --git a/test/unit/gateways/authorize_net_test.rb b/test/unit/gateways/authorize_net_test.rb
index 358124ae04f..813c26dfaaf 100644
--- a/test/unit/gateways/authorize_net_test.rb
+++ b/test/unit/gateways/authorize_net_test.rb
@@ -29,6 +29,14 @@ def setup
description: 'Store Purchase'
}
+ @level_3_options = {
+ ship_from_address: {
+ zip: 'origin27701',
+ country: 'originUS'
+ },
+ summary_commodity_code: 'CODE'
+ }
+
@additional_options = {
line_items: [
{
@@ -47,6 +55,21 @@ def setup
}
]
}
+
+ @level_3_line_item_options = {
+ line_items: [
+ {
+ item_id: '1',
+ name: 'mug',
+ description: 'coffee',
+ quantity: '100',
+ unit_price: '10',
+ unit_of_measure: 'yards',
+ total_amount: '1000',
+ product_code: 'coupon'
+ }
+ ]
+ }
end
def test_add_swipe_data_with_bad_data
@@ -326,6 +349,20 @@ def test_passes_header_email_receipt
end.respond_with(successful_purchase_response)
end
+ def test_passes_level_3_options
+ stub_comms do
+ @gateway.purchase(@amount, credit_card, @options.merge(@level_3_options))
+ end.check_request do |endpoint, data, headers|
+ assert_match(//, data)
+ assert_match(/#{@level_3_options[:summary_commodity_code]}<\/summaryCommodityCode>/, data)
+ assert_match(/<\/order>/, data)
+ assert_match(//, data)
+ assert_match(/#{@level_3_options[:ship_from_address][:zip]}<\/zip>/, data)
+ assert_match(/#{@level_3_options[:ship_from_address][:country]}<\/country>/, data)
+ assert_match(/<\/shipFrom>/, data)
+ end.respond_with(successful_purchase_response)
+ end
+
def test_passes_line_items
stub_comms do
@gateway.purchase(@amount, credit_card, @options.merge(@additional_options))
@@ -347,6 +384,24 @@ def test_passes_line_items
end.respond_with(successful_purchase_response)
end
+ def test_passes_level_3_line_items
+ stub_comms do
+ @gateway.purchase(@amount, credit_card, @options.merge(@level_3_line_item_options))
+ end.check_request do |endpoint, data, headers|
+ assert_match(//, data)
+ assert_match(//, data)
+ assert_match(/#{@level_3_line_item_options[:line_items][0][:item_id]}<\/itemId>/, data)
+ assert_match(/#{@level_3_line_item_options[:line_items][0][:name]}<\/name>/, data)
+ assert_match(/#{@level_3_line_item_options[:line_items][0][:description]}<\/description>/, data)
+ assert_match(/#{@level_3_line_item_options[:line_items][0][:quantity]}<\/quantity>/, data)
+ assert_match(/#{@level_3_line_item_options[:line_items][0][:unit_price]}<\/unitPrice>/, data)
+ assert_match(/#{@level_3_line_item_options[:line_items][0][:unit_of_measure]}<\/unitOfMeasure>/, data)
+ assert_match(/#{@level_3_line_item_options[:line_items][0][:total_amount]}<\/totalAmount>/, data)
+ assert_match(/#{@level_3_line_item_options[:line_items][0][:product_code]}<\/productCode>/, data)
+ assert_match(/<\/lineItems>/, data)
+ end.respond_with(successful_purchase_response)
+ end
+
def test_failed_purchase
@gateway.expects(:ssl_post).returns(failed_purchase_response)
From 8a1c77a0d7bf25ea3efadaf9a3564ec6bf18a7f5 Mon Sep 17 00:00:00 2001
From: Jonathan Girard Viau
Date: Fri, 26 Oct 2018 11:01:11 -0400
Subject: [PATCH 0127/2234] Add state to the netbanx payload (#3024)
This field is needed for certain transaction that could get declined
because of the gateway "Risk Management department"
---
lib/active_merchant/billing/gateways/netbanx.rb | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/netbanx.rb b/lib/active_merchant/billing/gateways/netbanx.rb
index 444723f66ff..8afb50bfb66 100644
--- a/lib/active_merchant/billing/gateways/netbanx.rb
+++ b/lib/active_merchant/billing/gateways/netbanx.rb
@@ -165,9 +165,10 @@ def map_address(address)
return {} if address.nil?
country = Country.find(address[:country]) if address[:country]
mapped = {
- :street => address[:address1],
- :city => address[:city],
- :zip => address[:zip],
+ :street => address[:address1],
+ :city => address[:city],
+ :zip => address[:zip],
+ :state => address[:state],
}
mapped.merge!({:country => country.code(:alpha2).value}) unless country.blank?
From 9a1e62fab0fc3c24bf68a47bd48f48cc012bb873 Mon Sep 17 00:00:00 2001
From: "Jonathan G.V"
Date: Fri, 26 Oct 2018 11:41:22 -0400
Subject: [PATCH 0128/2234] Release v1.86.0
---
CHANGELOG | 4 ++++
lib/active_merchant/version.rb | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 314de3945ad..b80a96427f4 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,13 +1,17 @@
= ActiveMerchant CHANGELOG
== HEAD
+== Version 1.86.0 (October 26, 2018)
* UsaEpayTransaction: Support UMcheckformat option for echecks [dtykocki] #3002
* Global Collect: handle internal server errors [molbrown] #3005
* Barclaycard Smartpay: allow third-party payouts for credits [bpollack] #3009
* RuboCop: AlignHash [nfarve] #3004
* Beanstream: Switch `recurringPayment` flag from boolean to integer [dtykocki] #3011
+* Update Swipe HQ endpoint [bdewater] #3013
+* Braintree: Adds device_data [deedeelavinder] #3012
* Payflow Express: Add phone to returned Response [filipebarcos] #3003
* Authorize.Net: Pass some level 3 fields [curiousepic] #3022
+* Add state to the netbanx payload [Girardvjonathan] #3024
== Version 1.85.0 (September 28, 2018)
* Authorize.Net: Support custom delimiter for cim [curiousepic] #3001
diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb
index 6f6f680ff1c..813ed5dbdd2 100644
--- a/lib/active_merchant/version.rb
+++ b/lib/active_merchant/version.rb
@@ -1,3 +1,3 @@
module ActiveMerchant
- VERSION = '1.85.0'
+ VERSION = '1.86.0'
end
From cc816a671f6433c260dc850d95f23befe15bcb80 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Tue, 23 Oct 2018 14:12:56 -0400
Subject: [PATCH 0129/2234] RuboCop: fix Lint/EmptyWhen
---
.rubocop_todo.yml | 5 -----
lib/active_merchant/billing/gateways/usa_epay_advanced.rb | 3 ++-
2 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 1841c4a0842..cd0b907b06a 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -266,11 +266,6 @@ Lint/DuplicateMethods:
- 'test/remote/gateways/remote_netaxept_test.rb'
- 'test/remote/gateways/remote_verifi_test.rb'
-# Offense count: 1
-Lint/EmptyWhen:
- Exclude:
- - 'lib/active_merchant/billing/gateways/usa_epay_advanced.rb'
-
# Offense count: 3
Lint/FormatParameterMismatch:
Exclude:
diff --git a/lib/active_merchant/billing/gateways/usa_epay_advanced.rb b/lib/active_merchant/billing/gateways/usa_epay_advanced.rb
index 2f756c0979e..bf38626368a 100644
--- a/lib/active_merchant/billing/gateways/usa_epay_advanced.rb
+++ b/lib/active_merchant/billing/gateways/usa_epay_advanced.rb
@@ -1386,7 +1386,8 @@ def build_transaction_request_object(soap, options, name='Params')
build_tag soap, v[0], v[1], options[k]
end
case
- when options[:payment_method] == nil
+ when options[:payment_method].nil?
+ nil
when options[:payment_method].kind_of?(ActiveMerchant::Billing::CreditCard)
build_credit_card_data soap, options
when options[:payment_method].kind_of?(ActiveMerchant::Billing::Check)
From 4abd2f0db48a6314ab16906525efb34f8b7e6bc5 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Tue, 23 Oct 2018 14:20:41 -0400
Subject: [PATCH 0130/2234] Remove unused variables
---
.../billing/gateways/borgun.rb | 1 -
.../billing/gateways/element.rb | 4 ++--
.../billing/gateways/realex.rb | 19 +++++++++----------
test/unit/gateways/paypal_test.rb | 6 +++---
4 files changed, 14 insertions(+), 16 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/borgun.rb b/lib/active_merchant/billing/gateways/borgun.rb
index c6bf5612262..3705be21163 100644
--- a/lib/active_merchant/billing/gateways/borgun.rb
+++ b/lib/active_merchant/billing/gateways/borgun.rb
@@ -130,7 +130,6 @@ def commit(action, post)
post[:Processor] = @options[:processor]
post[:MerchantID] = @options[:merchant_id]
- url = (test? ? test_url : live_url)
request = build_request(action, post)
raw = ssl_post(url(action), request, headers)
pairs = parse(raw)
diff --git a/lib/active_merchant/billing/gateways/element.rb b/lib/active_merchant/billing/gateways/element.rb
index 248626e5802..419fdd6e843 100644
--- a/lib/active_merchant/billing/gateways/element.rb
+++ b/lib/active_merchant/billing/gateways/element.rb
@@ -334,9 +334,9 @@ def payment_account_type(payment)
def url(action)
if action == 'PaymentAccountCreate'
- url = (test? ? SERVICE_TEST_URL : SERVICE_LIVE_URL)
+ test? ? SERVICE_TEST_URL : SERVICE_LIVE_URL
else
- url = (test? ? test_url : live_url)
+ test? ? test_url : live_url
end
end
diff --git a/lib/active_merchant/billing/gateways/realex.rb b/lib/active_merchant/billing/gateways/realex.rb
index cb97ac7bb87..c44ed00d11d 100644
--- a/lib/active_merchant/billing/gateways/realex.rb
+++ b/lib/active_merchant/billing/gateways/realex.rb
@@ -286,26 +286,25 @@ def expiry_date(credit_card)
end
def message_from(response)
- message = nil
case response[:result]
when '00'
- message = SUCCESS
+ SUCCESS
when '101'
- message = response[:message]
+ esponse[:message]
when '102', '103'
- message = DECLINED
+ DECLINED
when /^2[0-9][0-9]/
- message = BANK_ERROR
+ BANK_ERROR
when /^3[0-9][0-9]/
- message = REALEX_ERROR
+ REALEX_ERROR
when /^5[0-9][0-9]/
- message = response[:message]
+ response[:message]
when '600', '601', '603'
- message = ERROR
+ ERROR
when '666'
- message = CLIENT_DEACTIVATED
+ CLIENT_DEACTIVATED
else
- message = DECLINED
+ DECLINED
end
end
diff --git a/test/unit/gateways/paypal_test.rb b/test/unit/gateways/paypal_test.rb
index 1b129b30330..a9ae07cbfc4 100644
--- a/test/unit/gateways/paypal_test.rb
+++ b/test/unit/gateways/paypal_test.rb
@@ -474,20 +474,20 @@ def test_bill_outstanding_amoung_response
end
def test_mass_pay_transfer_recipient_types
- response = stub_comms do
+ stub_comms do
@gateway.transfer 1000, 'fred@example.com'
end.check_request do |endpoint, data, headers|
assert_no_match %r{ReceiverType}, data
end.respond_with(successful_purchase_response)
- response = stub_comms do
+ stub_comms do
@gateway.transfer 1000, 'fred@example.com', :receiver_type => 'EmailAddress'
end.check_request do |endpoint, data, headers|
assert_match %r{EmailAddress}, data
assert_match %r{fred@example\.com}, data
end.respond_with(successful_purchase_response)
- response = stub_comms do
+ stub_comms do
@gateway.transfer 1000, 'fred@example.com', :receiver_type => 'UserID'
end.check_request do |endpoint, data, headers|
assert_match %r{UserID}, data
From c4781e20c14de87dbfa6731d1314f0c1531fb7ce Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Tue, 23 Oct 2018 14:24:06 -0400
Subject: [PATCH 0131/2234] Remove script markers from files that aren't
scripts
---
.rubocop_todo.yml | 8 --------
lib/active_merchant/billing/avs_result.rb | 1 -
lib/active_merchant/billing/gateways/skip_jack.rb | 1 -
test/test_helper.rb | 1 -
4 files changed, 11 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index cd0b907b06a..88855c21a7b 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -299,14 +299,6 @@ Lint/RescueException:
Exclude:
- 'lib/active_merchant/billing/gateways/quantum.rb'
-# Offense count: 3
-# Cop supports --auto-correct.
-Lint/ScriptPermission:
- Exclude:
- - 'lib/active_merchant/billing/avs_result.rb'
- - 'lib/active_merchant/billing/gateways/skip_jack.rb'
- - 'test/test_helper.rb'
-
# Offense count: 11
# Cop supports --auto-correct.
Lint/StringConversionInInterpolation:
diff --git a/lib/active_merchant/billing/avs_result.rb b/lib/active_merchant/billing/avs_result.rb
index 7324daef438..b21017eaa2f 100644
--- a/lib/active_merchant/billing/avs_result.rb
+++ b/lib/active_merchant/billing/avs_result.rb
@@ -1,4 +1,3 @@
-#!ruby19
# encoding: utf-8
module ActiveMerchant
diff --git a/lib/active_merchant/billing/gateways/skip_jack.rb b/lib/active_merchant/billing/gateways/skip_jack.rb
index 563a169ba8d..d3da3bea486 100644
--- a/lib/active_merchant/billing/gateways/skip_jack.rb
+++ b/lib/active_merchant/billing/gateways/skip_jack.rb
@@ -1,4 +1,3 @@
-#!ruby19
# encoding: utf-8
module ActiveMerchant #:nodoc:
diff --git a/test/test_helper.rb b/test/test_helper.rb
index dbfeb798930..7400150f5cc 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -1,4 +1,3 @@
-#!/usr/bin/env ruby
$:.unshift File.expand_path('../../lib', __FILE__)
require 'bundler/setup'
From 03274b2688fc959f60eb99f02e2eb933a348af73 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Tue, 23 Oct 2018 14:30:54 -0400
Subject: [PATCH 0132/2234] Fix confusing/ineffective access modifier
---
.rubocop_todo.yml | 5 -----
lib/active_merchant/network_connection_retries.rb | 14 ++++++--------
2 files changed, 6 insertions(+), 13 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 88855c21a7b..f20729eaff9 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -277,11 +277,6 @@ Lint/HandleExceptions:
- 'lib/active_merchant/billing/gateways/mastercard.rb'
- 'lib/active_merchant/billing/gateways/trust_commerce.rb'
-# Offense count: 1
-Lint/IneffectiveAccessModifier:
- Exclude:
- - 'lib/active_merchant/network_connection_retries.rb'
-
# Offense count: 1
Lint/NestedMethodDefinition:
Exclude:
diff --git a/lib/active_merchant/network_connection_retries.rb b/lib/active_merchant/network_connection_retries.rb
index 0bce98f7619..e23d7e5adf5 100644
--- a/lib/active_merchant/network_connection_retries.rb
+++ b/lib/active_merchant/network_connection_retries.rb
@@ -36,6 +36,12 @@ def retry_exceptions(options={})
end
end
+ def self.log(logger, level, message, tag=nil)
+ tag ||= self.class.to_s
+ message = "[#{tag}] #{message}"
+ logger&.send(level, message)
+ end
+
private
def retry_network_exceptions(options = {})
@@ -62,14 +68,6 @@ def retry_network_exceptions(options = {})
end
end
- def self.log(logger, level, message, tag=nil)
- tag ||= self.class.to_s
- message = "[#{tag}] #{message}"
- logger&.send(level, message)
- end
-
- private
-
def log_with_retry_details(logger, attempts, time, message, tag)
NetworkConnectionRetries.log(logger, :info, 'connection_attempt=%d connection_request_time=%.4fs connection_msg="%s"' % [attempts, time, message], tag)
end
From 16a77e0907e27e8aa599a8cdd49bf27764e83881 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 25 Oct 2018 08:52:08 -0400
Subject: [PATCH 0133/2234] RuboCop: fix Lint/UselessAssignment
Note that this fixes some ACTUAL BUGS IN THE CODE; it's not purely a
formatting change. There were several instances of the wrong variable
getting used, a test not actually doing anything, etc.
---
.rubocop_todo.yml | 4 ----
.../billing/gateways/global_collect.rb | 1 -
lib/active_merchant/billing/gateways/qbms.rb | 2 +-
lib/active_merchant/billing/gateways/realex.rb | 2 +-
lib/active_merchant/billing/gateways/redsys.rb | 2 +-
lib/active_merchant/billing/gateways/skip_jack.rb | 2 +-
.../billing/gateways/worldpay_online_payments.rb | 2 +-
lib/active_merchant/network_connection_retries.rb | 2 +-
lib/support/gateway_support.rb | 2 +-
.../remote/gateways/remote_authorize_net_cim_test.rb | 10 +++++-----
test/remote/gateways/remote_beanstream_test.rb | 2 +-
test/remote/gateways/remote_braintree_orange_test.rb | 2 +-
test/remote/gateways/remote_cenpos_test.rb | 4 ++--
test/remote/gateways/remote_cyber_source_test.rb | 2 +-
test/remote/gateways/remote_elavon_test.rb | 2 +-
test/remote/gateways/remote_iridium_test.rb | 4 ++--
.../gateways/remote_jetpay_v2_certification_test.rb | 6 +++---
test/remote/gateways/remote_litle_test.rb | 2 +-
test/remote/gateways/remote_mundipagg_test.rb | 2 +-
test/remote/gateways/remote_nab_transact_test.rb | 2 +-
test/remote/gateways/remote_payment_express_test.rb | 1 -
test/remote/gateways/remote_realex_test.rb | 4 ++--
test/remote/gateways/remote_sage_pay_test.rb | 2 +-
test/remote/gateways/remote_sage_test.rb | 2 +-
.../remote/gateways/remote_usa_epay_advanced_test.rb | 12 ------------
test/remote/gateways/remote_visanet_peru_test.rb | 2 +-
test/remote/gateways/remote_world_net_test.rb | 3 +--
test/unit/gateways/mercado_pago_test.rb | 4 ++--
test/unit/gateways/pin_test.rb | 4 ++--
test/unit/gateways/skip_jack_test.rb | 2 +-
test/unit/gateways/stripe_test.rb | 5 ++---
test/unit/gateways/trexle_test.rb | 4 ++--
32 files changed, 41 insertions(+), 61 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index f20729eaff9..0198fc2ee40 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -328,10 +328,6 @@ Lint/UselessAccessModifier:
Exclude:
- 'lib/active_merchant/network_connection_retries.rb'
-# Offense count: 68
-Lint/UselessAssignment:
- Enabled: false
-
# Offense count: 1409
Metrics/AbcSize:
Max: 192
diff --git a/lib/active_merchant/billing/gateways/global_collect.rb b/lib/active_merchant/billing/gateways/global_collect.rb
index a6f0135921e..659804cd3fd 100644
--- a/lib/active_merchant/billing/gateways/global_collect.rb
+++ b/lib/active_merchant/billing/gateways/global_collect.rb
@@ -170,7 +170,6 @@ def add_refund_customer_data(post, options)
end
def add_address(post, creditcard, options)
- billing_address = options[:billing_address] || options[:address]
shipping_address = options[:shipping_address]
if billing_address = options[:billing_address] || options[:address]
post['order']['customer']['billingAddress'] = {
diff --git a/lib/active_merchant/billing/gateways/qbms.rb b/lib/active_merchant/billing/gateways/qbms.rb
index 85c9adf939a..5d37f900bf4 100644
--- a/lib/active_merchant/billing/gateways/qbms.rb
+++ b/lib/active_merchant/billing/gateways/qbms.rb
@@ -101,7 +101,7 @@ def void(authorization, options = {})
#
def credit(money, identification, options = {})
ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE
- refund(money, identification, options = {})
+ refund(money, identification, {})
end
def refund(money, identification, options = {})
diff --git a/lib/active_merchant/billing/gateways/realex.rb b/lib/active_merchant/billing/gateways/realex.rb
index c44ed00d11d..bfe4733cd72 100644
--- a/lib/active_merchant/billing/gateways/realex.rb
+++ b/lib/active_merchant/billing/gateways/realex.rb
@@ -290,7 +290,7 @@ def message_from(response)
when '00'
SUCCESS
when '101'
- esponse[:message]
+ response[:message]
when '102', '103'
DECLINED
when /^2[0-9][0-9]/
diff --git a/lib/active_merchant/billing/gateways/redsys.rb b/lib/active_merchant/billing/gateways/redsys.rb
index 8fbe07af636..237ce51b2ce 100644
--- a/lib/active_merchant/billing/gateways/redsys.rb
+++ b/lib/active_merchant/billing/gateways/redsys.rb
@@ -523,7 +523,7 @@ def xml_signed_fields(data)
xml_signed_fields += data[:ds_cardnumber]
end
- xml_signed_fields += data[:ds_transactiontype] + data[:ds_securepayment]
+ xml_signed_fields + data[:ds_transactiontype] + data[:ds_securepayment]
end
def get_key(order_id)
diff --git a/lib/active_merchant/billing/gateways/skip_jack.rb b/lib/active_merchant/billing/gateways/skip_jack.rb
index d3da3bea486..7dbf0372d62 100644
--- a/lib/active_merchant/billing/gateways/skip_jack.rb
+++ b/lib/active_merchant/billing/gateways/skip_jack.rb
@@ -274,7 +274,7 @@ def commit(action, money, parameters)
def url_for(action)
result = test? ? self.test_url : self.live_url
result += advanced? && action == :authorization ? ADVANCED_PATH : BASIC_PATH
- result += "?#{ACTIONS[action]}"
+ result + "?#{ACTIONS[action]}"
end
def add_credentials(params, action)
diff --git a/lib/active_merchant/billing/gateways/worldpay_online_payments.rb b/lib/active_merchant/billing/gateways/worldpay_online_payments.rb
index ede932554ba..513d2a667d5 100644
--- a/lib/active_merchant/billing/gateways/worldpay_online_payments.rb
+++ b/lib/active_merchant/billing/gateways/worldpay_online_payments.rb
@@ -163,7 +163,7 @@ def commit(method, url, parameters=nil, options = {}, type = false)
rescue ResponseError => e
raw_response = e.response.body
response = response_error(raw_response)
- rescue JSON::ParserError => e
+ rescue JSON::ParserError
response = json_error(raw_response)
end
diff --git a/lib/active_merchant/network_connection_retries.rb b/lib/active_merchant/network_connection_retries.rb
index e23d7e5adf5..09e1b146f30 100644
--- a/lib/active_merchant/network_connection_retries.rb
+++ b/lib/active_merchant/network_connection_retries.rb
@@ -28,7 +28,7 @@ def retry_exceptions(options={})
rescue OpenSSL::X509::CertificateError => e
NetworkConnectionRetries.log(options[:logger], :error, e.message, options[:tag])
raise ActiveMerchant::ClientCertificateError, 'The remote server did not accept the provided SSL certificate'
- rescue Zlib::BufError => e
+ rescue Zlib::BufError
raise ActiveMerchant::InvalidResponseError, 'The remote server replied with an invalid response'
rescue *connection_errors.keys => e
raise ActiveMerchant::ConnectionError.new(derived_error_message(connection_errors, e.class), e)
diff --git a/lib/support/gateway_support.rb b/lib/support/gateway_support.rb
index 84cf58df2fc..36b916773ec 100644
--- a/lib/support/gateway_support.rb
+++ b/lib/support/gateway_support.rb
@@ -14,7 +14,7 @@ def initialize
filename = File.basename(f, '.rb')
gateway_name = filename + '_gateway'
begin
- gateway_class = ('ActiveMerchant::Billing::' + gateway_name.camelize).constantize
+ ('ActiveMerchant::Billing::' + gateway_name.camelize).constantize
rescue NameError
puts 'Could not load gateway ' + gateway_name.camelize + ' from ' + f + '.'
end
diff --git a/test/remote/gateways/remote_authorize_net_cim_test.rb b/test/remote/gateways/remote_authorize_net_cim_test.rb
index b0c5e09f7d4..08001073228 100644
--- a/test/remote/gateways/remote_authorize_net_cim_test.rb
+++ b/test/remote/gateways/remote_authorize_net_cim_test.rb
@@ -185,7 +185,7 @@ def test_successful_create_customer_payment_profile_request
end
def test_successful_create_customer_payment_profile_request_with_bank_account
- payment_profile = @options[:profile].delete(:payment_profiles)
+ @options[:profile].delete(:payment_profiles)
assert response = @gateway.create_customer_profile(@options)
@customer_profile_id = response.authorization
@@ -254,7 +254,7 @@ def test_successful_get_customer_profile_with_multiple_payment_profiles
assert response = @gateway.create_customer_profile(@options)
@customer_profile_id = response.authorization
- assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
+ assert @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
assert response = @gateway.create_customer_payment_profile(
:customer_profile_id => @customer_profile_id,
@@ -423,7 +423,7 @@ def test_successful_update_customer_payment_profile_request
masked_credit_card = ActiveMerchant::Billing::CreditCard.new(:number => response.params['payment_profile']['payment']['credit_card']['card_number'])
# Update only the billing address with a masked card and expiration date
- assert response = @gateway.update_customer_payment_profile(
+ assert @gateway.update_customer_payment_profile(
:customer_profile_id => @customer_profile_id,
:payment_profile => {
:customer_payment_profile_id => customer_payment_profile_id,
@@ -469,7 +469,7 @@ def test_successful_update_customer_payment_profile_request_with_credit_card_las
last_four_credit_card = ActiveMerchant::Billing::CreditCard.new(:number => '4242') # Credit card with only last four digits
# Update only the billing address with a card with the last 4 digits and expiration date
- assert response = @gateway.update_customer_payment_profile(
+ assert @gateway.update_customer_payment_profile(
:customer_profile_id => @customer_profile_id,
:payment_profile => {
:customer_payment_profile_id => customer_payment_profile_id,
@@ -766,7 +766,7 @@ def test_should_create_customer_profile_transaction_auth_only_and_then_prior_aut
end
def get_and_validate_customer_payment_profile_request_with_bank_account_response
- payment_profile = @options[:profile].delete(:payment_profiles)
+ @options[:profile].delete(:payment_profiles)
assert response = @gateway.create_customer_profile(@options)
@customer_profile_id = response.authorization
diff --git a/test/remote/gateways/remote_beanstream_test.rb b/test/remote/gateways/remote_beanstream_test.rb
index 7041bd6ca9a..e4dd84e4680 100644
--- a/test/remote/gateways/remote_beanstream_test.rb
+++ b/test/remote/gateways/remote_beanstream_test.rb
@@ -267,7 +267,7 @@ def test_successful_check_purchase_and_refund
assert_success purchase
assert refund = @gateway.refund(@amount, purchase.authorization)
- assert_success credit
+ assert_success refund
end
def test_successful_recurring
diff --git a/test/remote/gateways/remote_braintree_orange_test.rb b/test/remote/gateways/remote_braintree_orange_test.rb
index 4f2b3f171f3..4b4e659e4a3 100644
--- a/test/remote/gateways/remote_braintree_orange_test.rb
+++ b/test/remote/gateways/remote_braintree_orange_test.rb
@@ -27,7 +27,7 @@ def test_successful_purchase_with_echeck
:account_holder_type => 'personal',
:account_type => 'checking'
)
- assert response = @gateway.purchase(@amount, @check, @options)
+ assert response = @gateway.purchase(@amount, check, @options)
assert_equal 'This transaction has been approved', response.message
assert_success response
end
diff --git a/test/remote/gateways/remote_cenpos_test.rb b/test/remote/gateways/remote_cenpos_test.rb
index 479545edb08..a3474658bbc 100644
--- a/test/remote/gateways/remote_cenpos_test.rb
+++ b/test/remote/gateways/remote_cenpos_test.rb
@@ -104,7 +104,7 @@ def test_failed_capture
assert_success response
assert_equal 'Succeeded', response.message
- capture = @gateway.capture(@amount, response.authorization)
+ @gateway.capture(@amount, response.authorization)
capture = @gateway.capture(@amount, response.authorization)
assert_failure capture
assert_equal 'Duplicated force transaction.', capture.message
@@ -132,7 +132,7 @@ def test_failed_void
response = @gateway.authorize(@amount, @credit_card, @options)
assert_success response
- void = @gateway.void(response.authorization)
+ @gateway.void(response.authorization)
void = @gateway.void(response.authorization)
assert_failure void
assert_equal 'Original Transaction not found', void.message
diff --git a/test/remote/gateways/remote_cyber_source_test.rb b/test/remote/gateways/remote_cyber_source_test.rb
index d3af9274365..e35e01ba8ce 100644
--- a/test/remote/gateways/remote_cyber_source_test.rb
+++ b/test/remote/gateways/remote_cyber_source_test.rb
@@ -213,7 +213,7 @@ def test_successful_authorization_and_failed_capture
end
def test_failed_capture_bad_auth_info
- assert auth = @gateway.authorize(@amount, @credit_card, @options)
+ assert @gateway.authorize(@amount, @credit_card, @options)
assert capture = @gateway.capture(@amount, 'a;b;c', @options)
assert_failure capture
end
diff --git a/test/remote/gateways/remote_elavon_test.rb b/test/remote/gateways/remote_elavon_test.rb
index 63d07da8491..9c560e7ec77 100644
--- a/test/remote/gateways/remote_elavon_test.rb
+++ b/test/remote/gateways/remote_elavon_test.rb
@@ -120,7 +120,7 @@ def test_purchase_and_unsuccessful_void
assert purchase = @gateway.purchase(@amount, @credit_card, @options)
assert_success purchase
- assert response = @gateway.void(purchase.authorization)
+ assert @gateway.void(purchase.authorization)
assert response = @gateway.void(purchase.authorization)
assert_failure response
assert_equal 'The transaction ID is invalid for this transaction type', response.message
diff --git a/test/remote/gateways/remote_iridium_test.rb b/test/remote/gateways/remote_iridium_test.rb
index 92dee585764..dc033cabe3a 100644
--- a/test/remote/gateways/remote_iridium_test.rb
+++ b/test/remote/gateways/remote_iridium_test.rb
@@ -101,7 +101,7 @@ def test_successful_authorization_and_failed_capture
end
def test_failed_capture_bad_auth_info
- assert auth = @gateway.authorize(@amount, @credit_card, @options)
+ assert @gateway.authorize(@amount, @credit_card, @options)
assert capture = @gateway.capture(@amount, 'a;b;c', @options)
assert_failure capture
end
@@ -118,7 +118,7 @@ def test_successful_purchase_by_reference
def test_failed_purchase_by_reference
assert response = @gateway.authorize(1, @credit_card, @options)
assert_success response
- assert(reference = response.authorization)
+ assert response.authorization
assert response = @gateway.purchase(@amount, 'bogusref', {:order_id => generate_unique_id})
assert_failure response
diff --git a/test/remote/gateways/remote_jetpay_v2_certification_test.rb b/test/remote/gateways/remote_jetpay_v2_certification_test.rb
index 4916dd08435..be182a8be37 100644
--- a/test/remote/gateways/remote_jetpay_v2_certification_test.rb
+++ b/test/remote/gateways/remote_jetpay_v2_certification_test.rb
@@ -238,7 +238,7 @@ def test_certification_void03_void04_purchase_void_visa
puts "\n#{@options[:order_id]}: #{@unique_id}"
@options[:order_id] = 'VOID04'
- transaction_id, approval, amount, token = response.authorization.split(';')
+ transaction_id, approval, _amount, token = response.authorization.split(';')
amount = 500
authorization = [transaction_id, approval, amount, token].join(';')
assert response = @gateway.void(authorization, @options)
@@ -302,7 +302,7 @@ def test_certification_tok16_authorize_with_token_request_visa
assert response = @gateway.authorize(amount, visa, @options)
assert_success response
assert_equal 'APPROVED', response.message
- transaction_id, approval, amount, token = response.authorization.split(';')
+ _transaction_id, _approval, _amount, token = response.authorization.split(';')
assert_equal token, response.params['token']
@unique_id = response.params['unique_id']
end
@@ -314,7 +314,7 @@ def test_certification_tok17_purchase_with_token_request_amex
assert response = @gateway.purchase(amount, amex, @options)
assert_success response
assert_equal 'APPROVED', response.message
- transaction_id, approval, amount, token = response.authorization.split(';')
+ _transaction_id, _approval, _amount, token = response.authorization.split(';')
assert_equal token, response.params['token']
@unique_id = response.params['unique_id']
end
diff --git a/test/remote/gateways/remote_litle_test.rb b/test/remote/gateways/remote_litle_test.rb
index 73d71064585..8d510dcbea4 100644
--- a/test/remote/gateways/remote_litle_test.rb
+++ b/test/remote/gateways/remote_litle_test.rb
@@ -93,7 +93,7 @@ def test_successful_authorization_with_merchant_data
campaign: 'super-awesome-campaign',
merchant_grouping_id: 'brilliant-group'
)
- assert response = @gateway.authorize(10010, @credit_card1, options)
+ assert @gateway.authorize(10010, @credit_card1, options)
end
def test_successful_authorization_with_echeck
diff --git a/test/remote/gateways/remote_mundipagg_test.rb b/test/remote/gateways/remote_mundipagg_test.rb
index 417cc547102..39846fea222 100644
--- a/test/remote/gateways/remote_mundipagg_test.rb
+++ b/test/remote/gateways/remote_mundipagg_test.rb
@@ -9,7 +9,7 @@ def setup
@declined_card = credit_card('4000300011112220')
@voucher = credit_card('60607044957644', brand: 'sodexo')
@options = {
- billing_address: address(options = { neighborhood: 'Sesame Street' }),
+ billing_address: address({neighborhood: 'Sesame Street'}),
description: 'Store Purchase'
}
end
diff --git a/test/remote/gateways/remote_nab_transact_test.rb b/test/remote/gateways/remote_nab_transact_test.rb
index ce7ce019ec5..55289ec9ff0 100644
--- a/test/remote/gateways/remote_nab_transact_test.rb
+++ b/test/remote/gateways/remote_nab_transact_test.rb
@@ -246,7 +246,7 @@ def test_failure_trigger_purchase
purchase_response = @gateway.purchase(trigger_amount, gateway_id)
- assert gateway_id = purchase_response.params['crn']
+ assert purchase_response.params['crn']
assert_failure purchase_response
assert_equal 'Invalid Amount', purchase_response.message
end
diff --git a/test/remote/gateways/remote_payment_express_test.rb b/test/remote/gateways/remote_payment_express_test.rb
index cca036a49cb..8519fc72c5e 100644
--- a/test/remote/gateways/remote_payment_express_test.rb
+++ b/test/remote/gateways/remote_payment_express_test.rb
@@ -97,7 +97,6 @@ def test_store_with_custom_token
end
def test_store_invalid_credit_card
- original_number = @credit_card.number
@credit_card.number = 2
assert response = @gateway.store(@credit_card)
diff --git a/test/remote/gateways/remote_realex_test.rb b/test/remote/gateways/remote_realex_test.rb
index 73ec653e86f..fc1800f2c63 100644
--- a/test/remote/gateways/remote_realex_test.rb
+++ b/test/remote/gateways/remote_realex_test.rb
@@ -18,14 +18,14 @@ def setup
@mastercard_referral_a = card_fixtures(:realex_mastercard_referral_a)
@mastercard_coms_error = card_fixtures(:realex_mastercard_coms_error)
- @apple_pay = credit_card = network_tokenization_credit_card('4242424242424242',
+ @apple_pay = network_tokenization_credit_card('4242424242424242',
payment_cryptogram: 'EHuWW9PiBkWvqE5juRwDzAUFBAk=',
verification_value: nil,
eci: '05',
source: :apple_pay
)
- @declined_apple_pay = credit_card = network_tokenization_credit_card('4000120000001154',
+ @declined_apple_pay = network_tokenization_credit_card('4000120000001154',
payment_cryptogram: 'EHuWW9PiBkWvqE5juRwDzAUFBAk=',
verification_value: nil,
eci: '05',
diff --git a/test/remote/gateways/remote_sage_pay_test.rb b/test/remote/gateways/remote_sage_pay_test.rb
index 3abd17c88d5..c7647d53969 100644
--- a/test/remote/gateways/remote_sage_pay_test.rb
+++ b/test/remote/gateways/remote_sage_pay_test.rb
@@ -350,7 +350,7 @@ def test_successful_store_and_repurchase_with_resupplied_verification_value
assert response = @gateway.store(@visa)
assert_success response
assert !response.authorization.blank?
- assert purchase = @gateway.purchase(@amount, response.authorization, @options.merge(customer: 1))
+ assert @gateway.purchase(@amount, response.authorization, @options.merge(customer: 1))
assert purchase = @gateway.purchase(@amount, response.authorization, @options.merge(verification_value: '123', order_id: generate_unique_id))
assert_success purchase
end
diff --git a/test/remote/gateways/remote_sage_test.rb b/test/remote/gateways/remote_sage_test.rb
index fbab6a0417a..5107a12e97d 100644
--- a/test/remote/gateways/remote_sage_test.rb
+++ b/test/remote/gateways/remote_sage_test.rb
@@ -165,7 +165,7 @@ def test_partial_refund
def test_store_visa
assert response = @gateway.store(@visa, @options)
assert_success response
- assert auth = response.authorization,
+ assert response.authorization,
'Store card authorization should not be nil'
assert_not_nil response.message
end
diff --git a/test/remote/gateways/remote_usa_epay_advanced_test.rb b/test/remote/gateways/remote_usa_epay_advanced_test.rb
index 01ec1523690..df133607dda 100644
--- a/test/remote/gateways/remote_usa_epay_advanced_test.rb
+++ b/test/remote/gateways/remote_usa_epay_advanced_test.rb
@@ -92,18 +92,6 @@ def setup
:payment_method => @check,
:amount => 2500
}
-
- payment_methods = [
- {
- :name => 'My Visa', # optional
- :sort => 2, # optional
- :method => @credit_card
- },
- {
- :name => 'My Checking',
- :method => @check
- }
- ]
end
# Standard Gateway ==================================================
diff --git a/test/remote/gateways/remote_visanet_peru_test.rb b/test/remote/gateways/remote_visanet_peru_test.rb
index ff1b0160c76..5f70eaeeb3d 100644
--- a/test/remote/gateways/remote_visanet_peru_test.rb
+++ b/test/remote/gateways/remote_visanet_peru_test.rb
@@ -107,7 +107,7 @@ def test_successful_refund_unsettled
assert_success response
new_auth = "_|#{response.authorization.split('|')[1]}"
- refund = @gateway.refund(@amount, new_auth, @options.merge(force_full_refund_if_unsettled: true, ruc: '20341198217'))
+ @gateway.refund(@amount, new_auth, @options.merge(force_full_refund_if_unsettled: true, ruc: '20341198217'))
# this test will fail currently because there is no E2E test working for visanet
# assert_success refund
# assert_equal "OK", refund.message
diff --git a/test/remote/gateways/remote_world_net_test.rb b/test/remote/gateways/remote_world_net_test.rb
index 14986a28487..67d198f1fbf 100644
--- a/test/remote/gateways/remote_world_net_test.rb
+++ b/test/remote/gateways/remote_world_net_test.rb
@@ -109,7 +109,7 @@ def test_successful_void
auth = @gateway.authorize(@amount, @credit_card, @options)
assert_success auth
- assert void = @gateway.void(auth.authorization)
+ assert @gateway.void(auth.authorization)
# UNSUPPORTED
# assert_success void
# assert_equal 'REPLACE WITH SUCCESSFUL VOID MESSAGE', response.message
@@ -156,7 +156,6 @@ def test_unsuccessful_unstore
response = @gateway.store(@credit_card, @options)
assert_success response
assert_equal nil, response.message
- card_reference = response.authorization
assert response = @gateway.unstore('123456789', @options)
assert_failure response
diff --git a/test/unit/gateways/mercado_pago_test.rb b/test/unit/gateways/mercado_pago_test.rb
index 7b29e5252c8..72ad12215f5 100644
--- a/test/unit/gateways/mercado_pago_test.rb
+++ b/test/unit/gateways/mercado_pago_test.rb
@@ -196,8 +196,8 @@ def test_sends_mastercard_as_master
def test_includes_deviceid_header
@options[:device_id] = '1a2b3c'
- @gateway.expects(:ssl_post).with(anything, anything, headers = {'Content-Type' => 'application/json'}).returns(successful_purchase_response)
- @gateway.expects(:ssl_post).with(anything, anything, headers = {'Content-Type' => 'application/json', 'X-Device-Session-ID' => '1a2b3c'}).returns(successful_purchase_response)
+ @gateway.expects(:ssl_post).with(anything, anything, {'Content-Type' => 'application/json'}).returns(successful_purchase_response)
+ @gateway.expects(:ssl_post).with(anything, anything, {'Content-Type' => 'application/json', 'X-Device-Session-ID' => '1a2b3c'}).returns(successful_purchase_response)
response = @gateway.purchase(@amount, @credit_card, @options)
assert_success response
diff --git a/test/unit/gateways/pin_test.rb b/test/unit/gateways/pin_test.rb
index fc16c0d1f68..33a27b55a56 100644
--- a/test/unit/gateways/pin_test.rb
+++ b/test/unit/gateways/pin_test.rb
@@ -304,13 +304,13 @@ def test_headers
}
@gateway.expects(:ssl_request).with(:post, anything, anything, expected_headers).returns(successful_purchase_response)
- assert response = @gateway.purchase(@amount, @credit_card, {})
+ assert @gateway.purchase(@amount, @credit_card, {})
expected_headers['X-Partner-Key'] = 'MyPartnerKey'
expected_headers['X-Safe-Card'] = '1'
@gateway.expects(:ssl_request).with(:post, anything, anything, expected_headers).returns(successful_purchase_response)
- assert response = @gateway.purchase(@amount, @credit_card, :partner_key => 'MyPartnerKey', :safe_card => '1')
+ assert @gateway.purchase(@amount, @credit_card, :partner_key => 'MyPartnerKey', :safe_card => '1')
end
def test_transcript_scrubbing
diff --git a/test/unit/gateways/skip_jack_test.rb b/test/unit/gateways/skip_jack_test.rb
index 45f70914506..6df67c6a94e 100644
--- a/test/unit/gateways/skip_jack_test.rb
+++ b/test/unit/gateways/skip_jack_test.rb
@@ -206,7 +206,7 @@ def test_serial_number_is_added_before_developer_serial_number_for_capture
response = @gateway.authorize(@amount, @credit_card, @options)
@gateway.expects(:ssl_post).with('https://developer.skipjackic.com/scripts/evolvcc.dll?SJAPI_TransactionChangeStatusRequest', "szTransactionId=#{response.authorization}&szSerialNumber=X&szForceSettlement=0&szDeveloperSerialNumber=Y&szDesiredStatus=SETTLE&szAmount=1.00").returns(successful_capture_response)
- response = @gateway.capture(@amount, response.authorization)
+ @gateway.capture(@amount, response.authorization)
end
def test_successful_partial_capture
diff --git a/test/unit/gateways/stripe_test.rb b/test/unit/gateways/stripe_test.rb
index 0dd7f51097c..edbafbd49d4 100644
--- a/test/unit/gateways/stripe_test.rb
+++ b/test/unit/gateways/stripe_test.rb
@@ -725,7 +725,7 @@ def test_unsuccessful_verify
end
def test_successful_request_always_uses_live_mode_to_determine_test_request
- @gateway.expects(:ssl_request).returns(successful_partially_refunded_response(:livemode => true))
+ @gateway.expects(:ssl_request).returns(successful_partially_refunded_response)
assert response = @gateway.refund(@refund_amount, 'ch_test_charge')
assert_success response
@@ -1989,8 +1989,7 @@ def successful_purchase_response(refunded=false)
RESPONSE
end
- def successful_partially_refunded_response(options = {})
- options = {:livemode=>false}.merge!(options)
+ def successful_partially_refunded_response
<<-RESPONSE
{
"id": "re_test_refund",
diff --git a/test/unit/gateways/trexle_test.rb b/test/unit/gateways/trexle_test.rb
index 5ce9da270f2..a1ee4295ccc 100644
--- a/test/unit/gateways/trexle_test.rb
+++ b/test/unit/gateways/trexle_test.rb
@@ -286,13 +286,13 @@ def test_headers
}
@gateway.expects(:ssl_request).with(:post, anything, anything, expected_headers).returns(successful_purchase_response)
- assert response = @gateway.purchase(@amount, @credit_card, {})
+ assert @gateway.purchase(@amount, @credit_card, {})
expected_headers['X-Partner-Key'] = 'MyPartnerKey'
expected_headers['X-Safe-Card'] = '1'
@gateway.expects(:ssl_request).with(:post, anything, anything, expected_headers).returns(successful_purchase_response)
- assert response = @gateway.purchase(@amount, @credit_card, partner_key: 'MyPartnerKey', safe_card: '1')
+ assert @gateway.purchase(@amount, @credit_card, partner_key: 'MyPartnerKey', safe_card: '1')
end
def test_transcript_scrubbing
From f9ed08a45105b6951108278ef1286b2fa1f841f6 Mon Sep 17 00:00:00 2001
From: DeeDee Lavinder
Date: Tue, 30 Oct 2018 17:05:33 -0400
Subject: [PATCH 0134/2234] Barclaycard Smartpay: Improves Error Handling
The error handling was not exposing detailed error codes and messages in
the response. This returns those codes and messages where appropriate.
This also adds and updates several tests.
Unit tests:
27 tests, 133 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
Remote tests:
33 tests, 69 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
96.9697% passed
This failure is for "Invalid credentials" for
`test_successful_third_party_payout` and is
unrelated.
Closes #3026
---
CHANGELOG | 1 +
.../billing/gateways/barclaycard_smartpay.rb | 10 +++---
.../remote_barclaycard_smartpay_test.rb | 20 +++++++++--
.../gateways/barclaycard_smartpay_test.rb | 34 ++++++++++++++++---
4 files changed, 53 insertions(+), 12 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index b80a96427f4..b6a84d107d7 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -12,6 +12,7 @@
* Payflow Express: Add phone to returned Response [filipebarcos] #3003
* Authorize.Net: Pass some level 3 fields [curiousepic] #3022
* Add state to the netbanx payload [Girardvjonathan] #3024
+* Barclaycard Smartpay: Improves Error Handling [deedeelavinder] #3026
== Version 1.85.0 (September 28, 2018)
* Authorize.Net: Support custom delimiter for cim [curiousepic] #3001
diff --git a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb
index 1ea7ee14dce..84a59f82081 100644
--- a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb
+++ b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb
@@ -168,11 +168,11 @@ def commit(action, post, account = 'ws', password = @options[:password])
return Response.new(false, 'Invalid credentials', {}, :test => test?)
when '403'
return Response.new(false, 'Not allowed', {}, :test => test?)
- when '422'
- return Response.new(false, 'Unprocessable Entity', {}, :test => test?)
- when '500'
- if e.response.body.split(' ')[0] == 'validation'
- return Response.new(false, e.response.body.split(' ', 3)[2], {}, :test => test?)
+ when '422', '500'
+ if e.response.body.split(/\W+/).any? { |word| %w(validation configuration security).include?(word) }
+ error_message = e.response.body[/#{Regexp.escape('message=')}(.*?)#{Regexp.escape('&')}/m, 1].tr('+', ' ')
+ error_code = e.response.body[/#{Regexp.escape('errorCode=')}(.*?)#{Regexp.escape('&')}/m, 1]
+ return Response.new(false, error_code + ': ' + error_message, {}, :test => test?)
end
end
raise
diff --git a/test/remote/gateways/remote_barclaycard_smartpay_test.rb b/test/remote/gateways/remote_barclaycard_smartpay_test.rb
index 105166a2250..1f0444d6a08 100644
--- a/test/remote/gateways/remote_barclaycard_smartpay_test.rb
+++ b/test/remote/gateways/remote_barclaycard_smartpay_test.rb
@@ -6,6 +6,7 @@ def setup
BarclaycardSmartpayGateway.ssl_strict = false
@amount = 100
+ @error_amount = 1_000_000_000_000_000_000_000
@credit_card = credit_card('4111111111111111', :month => 10, :year => 2020, :verification_value => 737)
@declined_card = credit_card('4000300011112220', :month => 3, :year => 2030, :verification_value => 737)
@three_ds_enrolled_card = credit_card('4212345678901237', brand: :visa)
@@ -196,9 +197,16 @@ def test_partial_capture
assert_success capture
end
- def test_failed_capture
+ def test_failed_capture_with_bad_auth
+ response = @gateway.capture(100, '0000000000000000', @options)
+ assert_failure response
+ assert_equal('167: Original pspReference required for this operation', response.message)
+ end
+
+ def test_failed_capture_with_bad_amount
response = @gateway.capture(nil, '', @options)
assert_failure response
+ assert_equal('137: Invalid amount specified', response.message)
end
def test_successful_refund
@@ -287,9 +295,9 @@ def test_successful_store
end
def test_failed_store
- response = @gateway.store(credit_card('', :month => '', :year => '', :verification_value => ''), @options)
+ response = @gateway.store(credit_card('4111111111111111', :month => '', :year => '', :verification_value => ''), @options)
assert_failure response
- assert_equal 'Unprocessable Entity', response.message
+ assert_equal '129: Expiry Date Invalid', response.message
end
# AVS must be enabled on the gateway's end for the test account used
@@ -330,4 +338,10 @@ def test_transcript_scrubbing
assert_scrubbed(@credit_card.verification_value.to_s, clean_transcript)
assert_scrubbed(@gateway.options[:password], clean_transcript)
end
+
+ def test_proper_error_response_handling
+ response = @gateway.purchase(@error_amount, @credit_card, @options)
+ assert_equal('702: Internal error', response.message)
+ assert_not_equal(response.message, 'Unable to communicate with the payment system.')
+ end
end
diff --git a/test/unit/gateways/barclaycard_smartpay_test.rb b/test/unit/gateways/barclaycard_smartpay_test.rb
index e88dd36bdea..2bb8443b85d 100644
--- a/test/unit/gateways/barclaycard_smartpay_test.rb
+++ b/test/unit/gateways/barclaycard_smartpay_test.rb
@@ -207,10 +207,11 @@ def test_successful_capture
end
def test_failed_capture
- @gateway.stubs(:ssl_post).raises(ActiveMerchant::ResponseError.new(stub(:code => '500', :body => failed_capture_response)))
+ @gateway.stubs(:ssl_post).raises(ActiveMerchant::ResponseError.new(stub(:code => '422', :body => failed_capture_response)))
response = @gateway.capture(@amount, '0000000000000000', @options)
assert_failure response
+ assert_equal('167: Original pspReference required for this operation', response.message)
assert response.test?
end
@@ -238,10 +239,11 @@ def test_successful_refund
end
def test_failed_refund
- @gateway.stubs(:ssl_post).raises(ActiveMerchant::ResponseError.new(stub(:code => '500', :body => failed_refund_response)))
+ @gateway.stubs(:ssl_post).raises(ActiveMerchant::ResponseError.new(stub(:code => '422', :body => failed_refund_response)))
response = @gateway.refund(@amount, '0000000000000000', @options)
assert_failure response
+ assert_equal('137: Invalid amount specified', response.message)
assert response.test?
end
@@ -367,6 +369,22 @@ def test_transcript_scrubbing
assert_equal scrubbed_transcript, @gateway.scrub(transcript)
end
+ def test_proper_error_response_handling
+ response = stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options)
+ end.respond_with(configuration_error_response)
+
+ message = "#{response.params['errorCode']}: #{response.params['message']}"
+ assert_equal('905: Payment details are not supported', message)
+
+ response2 = stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options)
+ end.respond_with(validation_error_response)
+
+ message2 = "#{response2.params['errorCode']}: #{response2.params['message']}"
+ assert_equal('702: Internal error', message2)
+ end
+
private
def successful_authorize_response
@@ -386,7 +404,7 @@ def successful_capture_response
end
def failed_capture_response
- 'validation 100 No amount specified'
+ 'errorType=validation&errorCode=167&message=Original+pspReference+required+for+this+operation&status=422'
end
def successful_refund_response
@@ -394,7 +412,7 @@ def successful_refund_response
end
def failed_refund_response
- 'validation 100 No amount specified'
+ 'errorType=validation&errorCode=137&message=Invalid+amount+specified&status=422'
end
def successful_credit_response
@@ -429,6 +447,14 @@ def failed_avs_response
'additionalData.liabilityShift=false&additionalData.authCode=3115&additionalData.avsResult=2+Neither+postal+code+nor+address+match&additionalData.cardHolderName=Longbob+Longsen&additionalData.threeDOffered=false&additionalData.refusalReasonRaw=AUTHORISED&additionalData.issuerCountry=US&additionalData.cvcResult=1+Matches&additionalData.avsResultRaw=2&additionalData.threeDAuthenticated=false&additionalData.cvcResultRaw=1&additionalData.acquirerCode=SmartPayTestPmmAcquirer&additionalData.acquirerReference=7F50RDN2L06&fraudResult.accountScore=170&fraudResult.results.0.accountScore=20&fraudResult.results.0.checkId=2&fraudResult.results.0.name=CardChunkUsage&fraudResult.results.1.accountScore=25&fraudResult.results.1.checkId=4&fraudResult.results.1.name=HolderNameUsage&fraudResult.results.2.accountScore=25&fraudResult.results.2.checkId=8&fraudResult.results.2.name=ShopperEmailUsage&fraudResult.results.3.accountScore=0&fraudResult.results.3.checkId=1&fraudResult.results.3.name=PaymentDetailRefCheck&fraudResult.results.4.accountScore=0&fraudResult.results.4.checkId=13&fraudResult.results.4.name=IssuerRefCheck&fraudResult.results.5.accountScore=0&fraudResult.results.5.checkId=15&fraudResult.results.5.name=IssuingCountryReferral&fraudResult.results.6.accountScore=0&fraudResult.results.6.checkId=26&fraudResult.results.6.name=ShopperEmailRefCheck&fraudResult.results.7.accountScore=0&fraudResult.results.7.checkId=27&fraudResult.results.7.name=PmOwnerRefCheck&fraudResult.results.8.accountScore=0&fraudResult.results.8.checkId=10&fraudResult.results.8.name=HolderNameContainsNumber&fraudResult.results.9.accountScore=0&fraudResult.results.9.checkId=11&fraudResult.results.9.name=HolderNameIsOneWord&fraudResult.results.10.accountScore=0&fraudResult.results.10.checkId=21&fraudResult.results.10.name=EmailDomainValidation&fraudResult.results.11.accountScore=100&fraudResult.results.11.checkId=20&fraudResult.results.11.name=AVSAuthResultCheck&fraudResult.results.12.accountScore=0&fraudResult.results.12.checkId=25&fraudResult.results.12.name=CVCAuthResultCheck&pspReference=8814591938804745&refusalReason=FRAUD-CANCELLED&resultCode=Cancelled&authCode=3115'
end
+ def validation_error_response
+ 'errorType=validation&errorCode=702&message=Internal+error&status=500'
+ end
+
+ def configuration_error_response
+ 'errorType=configuration&errorCode=905&message=Payment+details+are+not+supported&pspReference=4315391674762857&status=500'
+ end
+
def transcript
%(
opening connection to pal-test.barclaycardsmartpay.com:443...
From 21d7500581450c8c6f2774f712937695bcbd4a37 Mon Sep 17 00:00:00 2001
From: David Perry
Date: Tue, 30 Oct 2018 14:29:47 -0400
Subject: [PATCH 0135/2234] Braintree: Fix passing phone-only billing address
If a billing address option had only a phone number, the billing address
element was still included in the request with all empty fields, which
causes a failure. Now we remove the phone from the billing address hash
before it's added.
Closes #3025
Remote:
64 tests, 365 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
55 tests, 139 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/braintree_blue.rb | 5 +++--
.../gateways/remote_braintree_blue_test.rb | 14 ++++++++++++
test/unit/gateways/braintree_blue_test.rb | 22 +++++++++++++++++++
4 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index b6a84d107d7..439f91e9e81 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -13,6 +13,7 @@
* Authorize.Net: Pass some level 3 fields [curiousepic] #3022
* Add state to the netbanx payload [Girardvjonathan] #3024
* Barclaycard Smartpay: Improves Error Handling [deedeelavinder] #3026
+* Braintree: Fix passing phone-only billing address [curiousepic] #3025
== Version 1.85.0 (September 28, 2018)
* Authorize.Net: Support custom delimiter for cim [curiousepic] #3001
diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb
index 1c35f5d0534..d693e587fed 100644
--- a/lib/active_merchant/billing/gateways/braintree_blue.rb
+++ b/lib/active_merchant/billing/gateways/braintree_blue.rb
@@ -304,12 +304,13 @@ def merge_credit_card_options(parameters, options)
parameters[:credit_card] ||= {}
parameters[:credit_card].merge!(:options => valid_options)
- parameters[:credit_card][:billing_address] = map_address(options[:billing_address]) if options[:billing_address]
+ address = options[:billing_address]&.except(:phone)
+ return parameters if address.nil? || address.empty?
+ parameters[:credit_card][:billing_address] = map_address(address)
parameters
end
def map_address(address)
- return {} if address.nil?
mapped = {
:street_address => address[:address1],
:extended_address => address[:address2],
diff --git a/test/remote/gateways/remote_braintree_blue_test.rb b/test/remote/gateways/remote_braintree_blue_test.rb
index 46a6610cc6f..22885692808 100644
--- a/test/remote/gateways/remote_braintree_blue_test.rb
+++ b/test/remote/gateways/remote_braintree_blue_test.rb
@@ -168,6 +168,20 @@ def test_successful_store_with_billing_address
assert_equal purchase_response.params['braintree_transaction']['billing_details'], response_billing_details
end
+ def test_successful_store_with_phone_only_billing_address_option
+ billing_address = {
+ :phone => '123-456-7890'
+ }
+ credit_card = credit_card('5105105105105100')
+ assert response = @gateway.store(credit_card, :billing_address => billing_address)
+ assert_success response
+ assert_equal 'OK', response.message
+
+ vault_id = response.params['customer_vault_id']
+ purchase_response = @gateway.purchase(@amount, vault_id)
+ assert_success purchase_response
+ end
+
def test_successful_store_with_credit_card_token
credit_card = credit_card('5105105105105100')
credit_card_token = generate_unique_id
diff --git a/test/unit/gateways/braintree_blue_test.rb b/test/unit/gateways/braintree_blue_test.rb
index e6986cae2c5..68a6092da88 100644
--- a/test/unit/gateways/braintree_blue_test.rb
+++ b/test/unit/gateways/braintree_blue_test.rb
@@ -351,6 +351,28 @@ def test_store_with_billing_address_options
@gateway.store(credit_card('41111111111111111111'), :billing_address => billing_address)
end
+ def test_store_with_phone_only_billing_address_option
+ customer_attributes = {
+ :credit_cards => [stub_everything],
+ :email => 'email',
+ :first_name => 'John',
+ :last_name => 'Smith',
+ :phone => '123-456-7890'
+ }
+ billing_address = {
+ :phone => '123-456-7890'
+ }
+ customer = stub(customer_attributes)
+ customer.stubs(:id).returns('123')
+ result = Braintree::SuccessfulResult.new(:customer => customer)
+ Braintree::CustomerGateway.any_instance.expects(:create).with do |params|
+ assert_nil params[:credit_card][:billing_address]
+ params
+ end.returns(result)
+
+ @gateway.store(credit_card('41111111111111111111'), :billing_address => billing_address)
+ end
+
def test_store_with_credit_card_token
customer = stub(
:email => 'email',
From 2841acc17f8413a88e6985b976fc2f2561ee8aa9 Mon Sep 17 00:00:00 2001
From: David Perry
Date: Thu, 1 Nov 2018 14:43:03 -0400
Subject: [PATCH 0136/2234] Litle: Capitalize check account type
Check payment methods may have lowercase account_type properties, but
the api expects it to be capitalized.
Closes #3028
Remote (10 unrelated failures, mostly unexpected successes):
37 tests, 137 assertions, 10 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
72.973% passed
Unit:
35 tests, 151 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/litle.rb | 2 +-
test/remote/gateways/remote_litle_test.rb | 4 ++--
test/unit/gateways/litle_test.rb | 4 ++--
4 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 439f91e9e81..1f9e4bbbe9d 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -14,6 +14,7 @@
* Add state to the netbanx payload [Girardvjonathan] #3024
* Barclaycard Smartpay: Improves Error Handling [deedeelavinder] #3026
* Braintree: Fix passing phone-only billing address [curiousepic] #3025
+* Litle: Capitalize check account type [curiousepic] #3028
== Version 1.85.0 (September 28, 2018)
* Authorize.Net: Support custom delimiter for cim [curiousepic] #3001
diff --git a/lib/active_merchant/billing/gateways/litle.rb b/lib/active_merchant/billing/gateways/litle.rb
index 61be3eedaa7..324b976629a 100644
--- a/lib/active_merchant/billing/gateways/litle.rb
+++ b/lib/active_merchant/billing/gateways/litle.rb
@@ -268,7 +268,7 @@ def add_payment_method(doc, payment_method, options)
end
elsif check?(payment_method)
doc.echeck do
- doc.accType(payment_method.account_type)
+ doc.accType(payment_method.account_type.capitalize)
doc.accNum(payment_method.account_number)
doc.routingNum(payment_method.routing_number)
doc.checkNum(payment_method.number)
diff --git a/test/remote/gateways/remote_litle_test.rb b/test/remote/gateways/remote_litle_test.rb
index 8d510dcbea4..6fd3107832f 100644
--- a/test/remote/gateways/remote_litle_test.rb
+++ b/test/remote/gateways/remote_litle_test.rb
@@ -67,13 +67,13 @@ def setup
name: 'Tom Black',
routing_number: '011075150',
account_number: '4099999992',
- account_type: 'Checking'
+ account_type: 'checking'
)
@authorize_check = check(
name: 'John Smith',
routing_number: '011075150',
account_number: '1099999999',
- account_type: 'Checking'
+ account_type: 'checking'
)
@store_check = check(
routing_number: '011100012',
diff --git a/test/unit/gateways/litle_test.rb b/test/unit/gateways/litle_test.rb
index 652ea34eb84..00538933ec8 100644
--- a/test/unit/gateways/litle_test.rb
+++ b/test/unit/gateways/litle_test.rb
@@ -36,13 +36,13 @@ def setup
name: 'Tom Black',
routing_number: '011075150',
account_number: '4099999992',
- account_type: 'Checking'
+ account_type: 'checking'
)
@authorize_check = check(
name: 'John Smith',
routing_number: '011075150',
account_number: '1099999999',
- account_type: 'Checking'
+ account_type: 'checking'
)
end
From 73c951d660f38986d25ed6c16bcd1a38f4f596eb Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 1 Nov 2018 10:58:54 -0400
Subject: [PATCH 0137/2234] RuboCop: fix Lint/AmbiguousBlockAssociation
---
.rubocop_todo.yml | 7 -------
test/test_helper.rb | 2 +-
test/unit/gateways/gateway_test.rb | 4 ++--
test/unit/gateways/worldpay_test.rb | 2 +-
4 files changed, 4 insertions(+), 11 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 0198fc2ee40..a25f069387e 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -241,13 +241,6 @@ Layout/SpaceInsideStringInterpolation:
- 'lib/active_merchant/billing/gateways/trust_commerce.rb'
- 'test/unit/gateways/worldpay_test.rb'
-# Offense count: 4
-Lint/AmbiguousBlockAssociation:
- Exclude:
- - 'test/test_helper.rb'
- - 'test/unit/gateways/gateway_test.rb'
- - 'test/unit/gateways/worldpay_test.rb'
-
# Offense count: 31
Lint/AmbiguousRegexpLiteral:
Enabled: false
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 7400150f5cc..90a557c2eb9 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -131,7 +131,7 @@ def clean_backtrace(&block)
yield
rescue AssertionClass => e
path = File.expand_path(__FILE__)
- raise AssertionClass, e.message, e.backtrace.reject { |line| File.expand_path(line) =~ /#{path}/ }
+ raise AssertionClass, e.message, (e.backtrace.reject { |line| File.expand_path(line) =~ /#{path}/ })
end
end
diff --git a/test/unit/gateways/gateway_test.rb b/test/unit/gateways/gateway_test.rb
index f8f29c235be..56a957f6109 100644
--- a/test/unit/gateways/gateway_test.rb
+++ b/test/unit/gateways/gateway_test.rb
@@ -11,10 +11,10 @@ def teardown
def test_should_detect_if_a_card_is_supported
Gateway.supported_cardtypes = [:visa, :bogus]
- assert [:visa, :bogus].all? { |supported_cardtype| Gateway.supports?(supported_cardtype) }
+ assert([:visa, :bogus].all? { |supported_cardtype| Gateway.supports?(supported_cardtype) })
Gateway.supported_cardtypes = []
- assert_false [:visa, :bogus].all? { |invalid_cardtype| Gateway.supports?(invalid_cardtype) }
+ assert_false([:visa, :bogus].all? { |invalid_cardtype| Gateway.supports?(invalid_cardtype) })
end
def test_should_validate_supported_countries
diff --git a/test/unit/gateways/worldpay_test.rb b/test/unit/gateways/worldpay_test.rb
index 37fcef0e548..7fe93d7acc2 100644
--- a/test/unit/gateways/worldpay_test.rb
+++ b/test/unit/gateways/worldpay_test.rb
@@ -97,7 +97,7 @@ def test_purchase_does_not_run_inquiry
end.respond_with(successful_capture_response)
assert_success response
- assert_equal %w(authorize capture), response.responses.collect{|e| e.params['action']}
+ assert_equal(%w(authorize capture), response.responses.collect{|e| e.params['action']})
end
def test_successful_void
From 349db7e5827eccecbc64ee7e4da3691b751cbc8e Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 1 Nov 2018 11:04:08 -0400
Subject: [PATCH 0138/2234] RuboCop: fix Lint/AmbiguousRegexpLiteral
---
.rubocop_todo.yml | 4 ----
test/remote/gateways/remote_blue_snap_test.rb | 16 ++++++++--------
test/remote/gateways/remote_citrus_pay_test.rb | 4 ++--
test/remote/gateways/remote_ezic_test.rb | 6 +++---
test/remote/gateways/remote_fat_zebra_test.rb | 2 +-
test/remote/gateways/remote_first_pay_test.rb | 2 +-
.../gateways/remote_global_transport_test.rb | 4 ++--
.../remote/gateways/remote_iats_payments_test.rb | 2 +-
test/remote/gateways/remote_migs_test.rb | 2 +-
test/remote/gateways/remote_openpay_test.rb | 2 +-
test/remote/gateways/remote_payu_latam_test.rb | 10 +++++-----
test/remote/gateways/remote_quickpay_v10_test.rb | 2 +-
.../remote/gateways/remote_redsys_sha256_test.rb | 2 +-
test/remote/gateways/remote_redsys_test.rb | 2 +-
test/remote/gateways/remote_stripe_test.rb | 6 +++---
...emote_trans_first_transaction_express_test.rb | 2 +-
test/remote/gateways/remote_visanet_peru_test.rb | 6 +++---
17 files changed, 35 insertions(+), 39 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index a25f069387e..deca557091e 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -241,10 +241,6 @@ Layout/SpaceInsideStringInterpolation:
- 'lib/active_merchant/billing/gateways/trust_commerce.rb'
- 'test/unit/gateways/worldpay_test.rb'
-# Offense count: 31
-Lint/AmbiguousRegexpLiteral:
- Enabled: false
-
# Offense count: 148
# Configuration parameters: AllowSafeAssignment.
Lint/AssignmentInCondition:
diff --git a/test/remote/gateways/remote_blue_snap_test.rb b/test/remote/gateways/remote_blue_snap_test.rb
index 9934855f3de..8f3604241a5 100644
--- a/test/remote/gateways/remote_blue_snap_test.rb
+++ b/test/remote/gateways/remote_blue_snap_test.rb
@@ -47,7 +47,7 @@ def test_successful_purchase_with_currency
def test_failed_purchase
response = @gateway.purchase(@amount, @declined_card, @options)
assert_failure response
- assert_match /Authorization has failed for this transaction/, response.message
+ assert_match(/Authorization has failed for this transaction/, response.message)
assert_equal '14002', response.error_code
end
@@ -77,7 +77,7 @@ def test_successful_authorize_and_capture
def test_failed_authorize
response = @gateway.authorize(@amount, @declined_card, @options)
assert_failure response
- assert_match /Authorization has failed for this transaction/, response.message
+ assert_match(/Authorization has failed for this transaction/, response.message)
end
def test_partial_capture_succeeds_even_though_amount_is_ignored_by_gateway
@@ -91,7 +91,7 @@ def test_partial_capture_succeeds_even_though_amount_is_ignored_by_gateway
def test_failed_capture
response = @gateway.capture(@amount, '')
assert_failure response
- assert_match /due to missing transaction ID/, response.message
+ assert_match(/due to missing transaction ID/, response.message)
end
def test_successful_refund
@@ -114,7 +114,7 @@ def test_partial_refund
def test_failed_refund
response = @gateway.refund(@amount, '')
assert_failure response
- assert_match /cannot be completed due to missing transaction ID/, response.message
+ assert_match(/cannot be completed due to missing transaction ID/, response.message)
end
def test_successful_void
@@ -129,7 +129,7 @@ def test_successful_void
def test_failed_void
response = @gateway.void('')
assert_failure response
- assert_match /cannot be completed due to missing transaction ID/, response.message
+ assert_match(/cannot be completed due to missing transaction ID/, response.message)
end
def test_successful_verify
@@ -141,7 +141,7 @@ def test_successful_verify
def test_failed_verify
response = @gateway.verify(@declined_card, @options)
assert_failure response
- assert_match /Authorization has failed for this transaction/, response.message
+ assert_match(/Authorization has failed for this transaction/, response.message)
end
def test_successful_store
@@ -152,14 +152,14 @@ def test_successful_store
assert response.authorization
assert_equal 'I', response.avs_result['code']
assert_equal 'P', response.cvv_result['code']
- assert_match /services\/2\/vaulted-shoppers/, response.params['content-location-header']
+ assert_match(/services\/2\/vaulted-shoppers/, response.params['content-location-header'])
end
def test_failed_store
assert response = @gateway.store(@declined_card, @options)
assert_failure response
- assert_match /Transaction failed because of payment processing failure/, response.message
+ assert_match(/Transaction failed because of payment processing failure/, response.message)
assert_equal '14002', response.error_code
end
diff --git a/test/remote/gateways/remote_citrus_pay_test.rb b/test/remote/gateways/remote_citrus_pay_test.rb
index 1acf5ed9a4b..cf7d131b942 100644
--- a/test/remote/gateways/remote_citrus_pay_test.rb
+++ b/test/remote/gateways/remote_citrus_pay_test.rb
@@ -56,7 +56,7 @@ def test_adds_3dsecure_id_to_authorize
def test_failed_purchase
assert response = @gateway.purchase(@amount, @declined_card, @options)
assert_failure response
- assert_match /FAILURE/, response.message
+ assert_match %r{FAILURE}, response.message
end
def test_successful_authorize_and_capture
@@ -73,7 +73,7 @@ def test_successful_authorize_and_capture
def test_failed_authorize
assert response = @gateway.authorize(@amount, @declined_card, @options)
assert_failure response
- assert_match /FAILURE/, response.message
+ assert_match(/FAILURE/, response.message)
end
def test_successful_refund
diff --git a/test/remote/gateways/remote_ezic_test.rb b/test/remote/gateways/remote_ezic_test.rb
index e2051de0ad3..7aacb3f3a74 100644
--- a/test/remote/gateways/remote_ezic_test.rb
+++ b/test/remote/gateways/remote_ezic_test.rb
@@ -48,7 +48,7 @@ def test_failed_capture
assert capture = @gateway.capture(@amount+30, auth.authorization)
assert_failure capture
- assert_match /Settlement amount cannot exceed authorized amount/, capture.message
+ assert_match(/Settlement amount cannot exceed authorized amount/, capture.message)
end
def test_successful_refund
@@ -76,7 +76,7 @@ def test_failed_refund
assert refund = @gateway.refund(@amount + 49, purchase.authorization)
assert_failure refund
- assert_match /Amount of refunds exceed original sale/, refund.message
+ assert_match(/Amount of refunds exceed original sale/, refund.message)
end
def test_failed_void
@@ -114,6 +114,6 @@ def test_invalid_login
gateway = EzicGateway.new(account_id: '11231')
response = gateway.purchase(@amount, @credit_card, @options)
assert_failure response
- assert_match /Invalid account number/, response.message
+ assert_match(/Invalid account number/, response.message)
end
end
diff --git a/test/remote/gateways/remote_fat_zebra_test.rb b/test/remote/gateways/remote_fat_zebra_test.rb
index 0f75fcdac91..dd4d594751e 100644
--- a/test/remote/gateways/remote_fat_zebra_test.rb
+++ b/test/remote/gateways/remote_fat_zebra_test.rb
@@ -30,7 +30,7 @@ def test_successful_multi_currency_purchase
def test_unsuccessful_multi_currency_purchase
assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:currency => 'XYZ'))
assert_failure response
- assert_match /Currency XYZ is not valid for this merchant/, response.message
+ assert_match(/Currency XYZ is not valid for this merchant/, response.message)
end
def test_successful_purchase_sans_cvv
diff --git a/test/remote/gateways/remote_first_pay_test.rb b/test/remote/gateways/remote_first_pay_test.rb
index f30fc4223b0..6e174f76976 100644
--- a/test/remote/gateways/remote_first_pay_test.rb
+++ b/test/remote/gateways/remote_first_pay_test.rb
@@ -108,7 +108,7 @@ def test_invalid_login
)
response = gateway.purchase(@amount, @credit_card, @options)
assert_failure response
- assert_match /Merchant: 1234 has encountered error #DTO-200-TC./, response.error_code
+ assert_match(/Merchant: 1234 has encountered error #DTO-200-TC./, response.error_code)
end
def test_recurring_payment
diff --git a/test/remote/gateways/remote_global_transport_test.rb b/test/remote/gateways/remote_global_transport_test.rb
index 1f5c45b4cb4..eac5264fe9c 100644
--- a/test/remote/gateways/remote_global_transport_test.rb
+++ b/test/remote/gateways/remote_global_transport_test.rb
@@ -63,7 +63,7 @@ def test_failed_capture
assert capture = @gateway.capture(1000, auth.authorization)
assert_failure capture
- assert_match /must be less than or equal to the original amount/, capture.message
+ assert_match(/must be less than or equal to the original amount/, capture.message)
end
def test_successful_refund
@@ -90,7 +90,7 @@ def test_failed_refund
assert refund = @gateway.refund(1000, purchase.authorization)
assert_failure refund
- assert_match /Refund Exceeds Available Refund Amount/, refund.message
+ assert_match(/Refund Exceeds Available Refund Amount/, refund.message)
end
def test_successful_void
diff --git a/test/remote/gateways/remote_iats_payments_test.rb b/test/remote/gateways/remote_iats_payments_test.rb
index 4a1a256da8e..34d604b7b92 100644
--- a/test/remote/gateways/remote_iats_payments_test.rb
+++ b/test/remote/gateways/remote_iats_payments_test.rb
@@ -99,7 +99,7 @@ def test_failed_store
credit_card = credit_card('4111')
assert store = @gateway.store(credit_card, @options)
assert_failure store
- assert_match /Invalid credit card number/, store.message
+ assert_match(/Invalid credit card number/, store.message)
end
def test_invalid_login
diff --git a/test/remote/gateways/remote_migs_test.rb b/test/remote/gateways/remote_migs_test.rb
index 3e6f3ae43f6..077762dc30b 100644
--- a/test/remote/gateways/remote_migs_test.rb
+++ b/test/remote/gateways/remote_migs_test.rb
@@ -41,7 +41,7 @@ def test_server_purchase_url
choice_url = @gateway.purchase_offsite_url(@amount, options)
- assert_response_match /Pay securely .* by clicking on the card logo below/, choice_url
+ assert_response_match(/Pay securely .* by clicking on the card logo below/, choice_url)
responses = {
'visa' => /You have chosen .*VISA.*/,
diff --git a/test/remote/gateways/remote_openpay_test.rb b/test/remote/gateways/remote_openpay_test.rb
index 54db72973a2..079b4d09279 100644
--- a/test/remote/gateways/remote_openpay_test.rb
+++ b/test/remote/gateways/remote_openpay_test.rb
@@ -165,7 +165,7 @@ def test_successful_verify
def test_unsuccessful_verify
response = @gateway.verify(@declined_card, @options)
assert_failure response
- assert_match /The card was declined/, response.message
+ assert_match(/The card was declined/, response.message)
end
def test_invalid_login
diff --git a/test/remote/gateways/remote_payu_latam_test.rb b/test/remote/gateways/remote_payu_latam_test.rb
index e1fa12362d6..8f6518fc4b1 100644
--- a/test/remote/gateways/remote_payu_latam_test.rb
+++ b/test/remote/gateways/remote_payu_latam_test.rb
@@ -290,13 +290,13 @@ def test_well_formed_refund_fails_as_expected
def test_failed_refund
response = @gateway.refund(@amount, '')
assert_failure response
- assert_match /property: parentTransactionId, message: must not be null/, response.message
+ assert_match(/property: parentTransactionId, message: must not be null/, response.message)
end
def test_failed_refund_with_specified_language
response = @gateway.refund(@amount, '', language: 'es')
assert_failure response
- assert_match /property: parentTransactionId, message: No puede ser vacio/, response.message
+ assert_match(/property: parentTransactionId, message: No puede ser vacio/, response.message)
end
# If this test fails, support for void may have been added to the sandbox
@@ -312,13 +312,13 @@ def test_unsupported_test_void_fails_as_expected
def test_failed_void
response = @gateway.void('')
assert_failure response
- assert_match /property: parentTransactionId, message: must not be null/, response.message
+ assert_match(/property: parentTransactionId, message: must not be null/, response.message)
end
def test_failed_void_with_specified_language
response = @gateway.void('', language: 'es')
assert_failure response
- assert_match /property: parentTransactionId, message: No puede ser vacio/, response.message
+ assert_match(/property: parentTransactionId, message: No puede ser vacio/, response.message)
end
# If this test fails, support for captures may have been added to the sandbox
@@ -334,7 +334,7 @@ def test_unsupported_test_capture_fails_as_expected
def test_failed_capture
response = @gateway.capture(@amount, '')
assert_failure response
- assert_match /must not be null/, response.message
+ assert_match(/must not be null/, response.message)
end
def test_verify_credentials
diff --git a/test/remote/gateways/remote_quickpay_v10_test.rb b/test/remote/gateways/remote_quickpay_v10_test.rb
index d10e107fa09..4a349cecafd 100644
--- a/test/remote/gateways/remote_quickpay_v10_test.rb
+++ b/test/remote/gateways/remote_quickpay_v10_test.rb
@@ -82,7 +82,7 @@ def test_unsuccessful_purchase_with_invalid_acquirers
def test_unsuccessful_authorize_with_invalid_card
assert response = @gateway.authorize(@amount, @invalid_card, @options)
assert_failure response
- assert_match /Rejected test operation/, response.message
+ assert_match(/Rejected test operation/, response.message)
end
def test_successful_authorize_and_capture
diff --git a/test/remote/gateways/remote_redsys_sha256_test.rb b/test/remote/gateways/remote_redsys_sha256_test.rb
index 8d3a2bbf8f1..43718a5f67a 100644
--- a/test/remote/gateways/remote_redsys_sha256_test.rb
+++ b/test/remote/gateways/remote_redsys_sha256_test.rb
@@ -64,7 +64,7 @@ def test_successful_authorise_and_capture
capture = @gateway.capture(100, authorize.authorization)
assert_success capture
- assert_match /Refund.*approved/, capture.message
+ assert_match(/Refund.*approved/, capture.message)
end
def test_successful_authorise_using_vault_id
diff --git a/test/remote/gateways/remote_redsys_test.rb b/test/remote/gateways/remote_redsys_test.rb
index 0dcaf5a017e..cfaf52723b2 100644
--- a/test/remote/gateways/remote_redsys_test.rb
+++ b/test/remote/gateways/remote_redsys_test.rb
@@ -66,7 +66,7 @@ def test_successful_authorise_and_capture
capture = @gateway.capture(100, authorize.authorization)
assert_success capture
- assert_match /Refund.*approved/, capture.message
+ assert_match(/Refund.*approved/, capture.message)
end
def test_successful_authorise_using_vault_id
diff --git a/test/remote/gateways/remote_stripe_test.rb b/test/remote/gateways/remote_stripe_test.rb
index cbc94e8ab52..6be3a6dd4e6 100644
--- a/test/remote/gateways/remote_stripe_test.rb
+++ b/test/remote/gateways/remote_stripe_test.rb
@@ -127,7 +127,7 @@ def test_unsuccessful_purchase
assert_failure response
assert_match %r{Your card was declined}, response.message
assert_match Gateway::STANDARD_ERROR_CODE[:card_declined], response.error_code
- assert_match /ch_[a-zA-Z\d]+/, response.authorization
+ assert_match(/ch_[a-zA-Z\d]+/, response.authorization)
end
def test_unsuccessful_purchase_with_destination_and_amount
@@ -493,8 +493,8 @@ def test_successful_store_of_bank_account
response = @gateway.store(@check, @options)
assert_success response
customer_id, bank_account_id = response.authorization.split('|')
- assert_match /^cus_/, customer_id
- assert_match /^ba_/, bank_account_id
+ assert_match(/^cus_/, customer_id)
+ assert_match(/^ba_/, bank_account_id)
end
def test_unsuccessful_purchase_from_stored_but_unverified_bank_account
diff --git a/test/remote/gateways/remote_trans_first_transaction_express_test.rb b/test/remote/gateways/remote_trans_first_transaction_express_test.rb
index 894b07c440e..32f0f08a199 100644
--- a/test/remote/gateways/remote_trans_first_transaction_express_test.rb
+++ b/test/remote/gateways/remote_trans_first_transaction_express_test.rb
@@ -232,7 +232,7 @@ def test_failed_refund
def test_successful_refund_with_echeck
purchase = @gateway.purchase(@amount, @check, @options)
assert_success purchase
- assert_match /purchase_echeck/, purchase.authorization
+ assert_match(/purchase_echeck/, purchase.authorization)
refund = @gateway.refund(@amount, purchase.authorization)
assert_success refund
diff --git a/test/remote/gateways/remote_visanet_peru_test.rb b/test/remote/gateways/remote_visanet_peru_test.rb
index 5f70eaeeb3d..59425892e09 100644
--- a/test/remote/gateways/remote_visanet_peru_test.rb
+++ b/test/remote/gateways/remote_visanet_peru_test.rb
@@ -89,7 +89,7 @@ def test_failed_authorize
def test_failed_capture
response = @gateway.capture('900000044')
assert_failure response
- assert_match /NUMORDEN 900000044 no se encuentra registrado/, response.message
+ assert_match(/NUMORDEN 900000044 no se encuentra registrado/, response.message)
assert_equal 400, response.error_code
end
@@ -116,7 +116,7 @@ def test_successful_refund_unsettled
def test_failed_refund
response = @gateway.refund(@amount, '900000044' )
assert_failure response
- assert_match /NUMORDEN 900000044 no se encuentra registrado/, response.message
+ assert_match(/NUMORDEN 900000044 no se encuentra registrado/, response.message)
assert_equal 400, response.error_code
end
@@ -132,7 +132,7 @@ def test_successful_void
def test_failed_void
response = @gateway.void('900000044')
assert_failure response
- assert_match /NUMORDEN no se encuentra registrado/, response.message
+ assert_match(/NUMORDEN no se encuentra registrado/, response.message)
assert_equal 400, response.error_code
end
From 6534296404b069e0f000199ffba7309821bd1975 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 1 Nov 2018 11:07:12 -0400
Subject: [PATCH 0139/2234] RuboCop: fix Lint/NestedMethodDefinition
---
.rubocop_todo.yml | 5 -----
test/unit/gateways/blue_pay_test.rb | 7 ++-----
2 files changed, 2 insertions(+), 10 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index deca557091e..9e10caafdfb 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -266,11 +266,6 @@ Lint/HandleExceptions:
- 'lib/active_merchant/billing/gateways/mastercard.rb'
- 'lib/active_merchant/billing/gateways/trust_commerce.rb'
-# Offense count: 1
-Lint/NestedMethodDefinition:
- Exclude:
- - 'test/unit/gateways/blue_pay_test.rb'
-
# Offense count: 4
Lint/ParenthesesAsGroupedExpression:
Exclude:
diff --git a/test/unit/gateways/blue_pay_test.rb b/test/unit/gateways/blue_pay_test.rb
index b7947bfc02f..5ae66d0fe58 100644
--- a/test/unit/gateways/blue_pay_test.rb
+++ b/test/unit/gateways/blue_pay_test.rb
@@ -175,12 +175,9 @@ def test_cvv_result
end
def test_message_from
- def get_msg(query)
- @gateway.send(:parse, query).message
- end
- assert_equal 'CVV does not match', get_msg('STATUS=2&CVV2=N&AVS=A&MESSAGE=FAILURE')
+ assert_equal 'CVV does not match', @gateway.send(:parse, 'STATUS=2&CVV2=N&AVS=A&MESSAGE=FAILURE').message
assert_equal 'Street address matches, but 5-digit and 9-digit postal code do not match.',
- get_msg('STATUS=2&CVV2=M&AVS=A&MESSAGE=FAILURE')
+ @gateway.send(:parse, 'STATUS=2&CVV2=M&AVS=A&MESSAGE=FAILURE').message
end
# Recurring Billing Unit Tests
From f5aca23b646790cd35e503f1432e8f91587e8390 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 1 Nov 2018 11:10:10 -0400
Subject: [PATCH 0140/2234] RuboCop: fix Lint/ParenthesesAsGroupedExpression
---
.rubocop_todo.yml | 7 -------
.../billing/gateways/trans_first_transaction_express.rb | 2 +-
test/remote/gateways/remote_payment_express_test.rb | 4 ++--
test/remote/gateways/remote_worldpay_test.rb | 2 +-
4 files changed, 4 insertions(+), 11 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 9e10caafdfb..2bf8d3323a0 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -266,13 +266,6 @@ Lint/HandleExceptions:
- 'lib/active_merchant/billing/gateways/mastercard.rb'
- 'lib/active_merchant/billing/gateways/trust_commerce.rb'
-# Offense count: 4
-Lint/ParenthesesAsGroupedExpression:
- Exclude:
- - 'lib/active_merchant/billing/gateways/trans_first_transaction_express.rb'
- - 'test/remote/gateways/remote_payment_express_test.rb'
- - 'test/remote/gateways/remote_worldpay_test.rb'
-
# Offense count: 1
Lint/RescueException:
Exclude:
diff --git a/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb b/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb
index 546a3d4d0c1..544eea6379b 100644
--- a/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb
+++ b/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb
@@ -539,7 +539,7 @@ def add_contact(doc, fullname, options)
if (billing_address = options[:billing_address])
if billing_address[:phone]
doc['v1'].phone do
- doc['v1'].type (options[:phone_number_type] || '4')
+ doc['v1'].type(options[:phone_number_type] || '4')
doc['v1'].nr billing_address[:phone].gsub(/\D/, '')
end
end
diff --git a/test/remote/gateways/remote_payment_express_test.rb b/test/remote/gateways/remote_payment_express_test.rb
index 8519fc72c5e..eeb9d3b0b33 100644
--- a/test/remote/gateways/remote_payment_express_test.rb
+++ b/test/remote/gateways/remote_payment_express_test.rb
@@ -107,7 +107,7 @@ def test_store_and_charge
assert response = @gateway.store(@credit_card)
assert_success response
assert_equal 'The Transaction was approved', response.message
- assert (token = response.authorization)
+ assert(token = response.authorization)
assert purchase = @gateway.purchase( @amount, token)
assert_equal 'The Transaction was approved', purchase.message
@@ -119,7 +119,7 @@ def test_store_and_authorize_and_capture
assert response = @gateway.store(@credit_card)
assert_success response
assert_equal 'The Transaction was approved', response.message
- assert (token = response.authorization)
+ assert(token = response.authorization)
assert auth = @gateway.authorize(@amount, token, @options)
assert_success auth
diff --git a/test/remote/gateways/remote_worldpay_test.rb b/test/remote/gateways/remote_worldpay_test.rb
index f32933a1010..fd4f73be9dd 100644
--- a/test/remote/gateways/remote_worldpay_test.rb
+++ b/test/remote/gateways/remote_worldpay_test.rb
@@ -155,7 +155,7 @@ def test_ip_address
def test_void
assert_success(response = @gateway.authorize(@amount, @credit_card, @options))
sleep(40)
- assert_success (void = @gateway.void(response.authorization))
+ assert_success(void = @gateway.void(response.authorization))
assert_equal 'SUCCESS', void.message
assert void.params['cancel_received_order_code']
end
From f5913a51d23fcaead6047989620fbe10b7d9c76a Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 1 Nov 2018 11:11:23 -0400
Subject: [PATCH 0141/2234] RuboCop: fix Style/MethodDefParentheses
---
.rubocop_todo.yml | 10 ----------
lib/active_merchant/billing/gateways/cyber_source.rb | 2 +-
test/unit/gateways/quickpay_v10_test.rb | 2 +-
3 files changed, 2 insertions(+), 12 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 2bf8d3323a0..47f103efa2f 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -938,16 +938,6 @@ Style/LineEndConcatenation:
Style/MethodCallWithoutArgsParentheses:
Enabled: false
-# Offense count: 4
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle.
-# SupportedStyles: require_parentheses, require_no_parentheses, require_no_parentheses_except_multiline
-Style/MethodDefParentheses:
- Exclude:
- - 'lib/active_merchant/billing/gateways/cyber_source.rb'
- - 'test/unit/gateways/ideal_rabobank_test.rb'
- - 'test/unit/gateways/quickpay_v10_test.rb'
-
# Offense count: 626
Style/MultilineBlockChain:
Enabled: false
diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb
index 60a0fd3caef..ec831d9377f 100644
--- a/lib/active_merchant/billing/gateways/cyber_source.rb
+++ b/lib/active_merchant/billing/gateways/cyber_source.rb
@@ -410,7 +410,7 @@ def add_business_rules_data(xml, payment_method, options)
end
end
- def extract_option prioritized_options, option_name
+ def extract_option(prioritized_options, option_name)
options_matching_key = prioritized_options.detect do |options|
options.has_key? option_name
end
diff --git a/test/unit/gateways/quickpay_v10_test.rb b/test/unit/gateways/quickpay_v10_test.rb
index 8a5404a3207..61bec826b5d 100644
--- a/test/unit/gateways/quickpay_v10_test.rb
+++ b/test/unit/gateways/quickpay_v10_test.rb
@@ -10,7 +10,7 @@ def setup
@options = { :order_id => '1', :billing_address => address, :customer_ip => '1.1.1.1' }
end
- def parse body
+ def parse(body)
JSON.parse(body)
end
From 08e19cf974dbc37863b566a36ca15442af398fac Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 1 Nov 2018 11:12:49 -0400
Subject: [PATCH 0142/2234] RuboCop: fix Lint/StringConversionInInterpolation
---
.rubocop_todo.yml | 11 -----------
lib/active_merchant/billing/gateways/adyen.rb | 2 +-
lib/active_merchant/billing/gateways/dibs.rb | 2 +-
lib/active_merchant/billing/gateways/pay_junction.rb | 2 +-
lib/active_merchant/billing/gateways/skip_jack.rb | 2 +-
.../billing/gateways/usa_epay_advanced.rb | 4 ++--
test/remote/gateways/remote_authorize_net_cim_test.rb | 10 +++++-----
7 files changed, 11 insertions(+), 22 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 47f103efa2f..100ba02790f 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -271,17 +271,6 @@ Lint/RescueException:
Exclude:
- 'lib/active_merchant/billing/gateways/quantum.rb'
-# Offense count: 11
-# Cop supports --auto-correct.
-Lint/StringConversionInInterpolation:
- Exclude:
- - 'lib/active_merchant/billing/gateways/adyen.rb'
- - 'lib/active_merchant/billing/gateways/dibs.rb'
- - 'lib/active_merchant/billing/gateways/pay_junction.rb'
- - 'lib/active_merchant/billing/gateways/skip_jack.rb'
- - 'lib/active_merchant/billing/gateways/usa_epay_advanced.rb'
- - 'test/remote/gateways/remote_authorize_net_cim_test.rb'
-
# Offense count: 1
Lint/UnderscorePrefixedVariableName:
Exclude:
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index cef696b8d8f..a73e0b92860 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -233,7 +233,7 @@ def parse(body)
def commit(action, parameters)
begin
- raw_response = ssl_post("#{url}/#{action.to_s}", post_data(action, parameters), request_headers)
+ raw_response = ssl_post("#{url}/#{action}", post_data(action, parameters), request_headers)
response = parse(raw_response)
rescue ResponseError => e
raw_response = e.response.body
diff --git a/lib/active_merchant/billing/gateways/dibs.rb b/lib/active_merchant/billing/gateways/dibs.rb
index 647d749bdae..d753f9fa143 100644
--- a/lib/active_merchant/billing/gateways/dibs.rb
+++ b/lib/active_merchant/billing/gateways/dibs.rb
@@ -159,7 +159,7 @@ def build_request(post)
end
def add_hmac(post)
- data = post.sort.collect { |key, value| "#{key}=#{value.to_s}" }.join('&')
+ data = post.sort.collect { |key, value| "#{key}=#{value}" }.join('&')
digest = OpenSSL::Digest.new('sha256')
key = [@options[:secret_key]].pack('H*')
post[:MAC] = OpenSSL::HMAC.hexdigest(digest, key, data)
diff --git a/lib/active_merchant/billing/gateways/pay_junction.rb b/lib/active_merchant/billing/gateways/pay_junction.rb
index 5255ef2106d..0113c737966 100644
--- a/lib/active_merchant/billing/gateways/pay_junction.rb
+++ b/lib/active_merchant/billing/gateways/pay_junction.rb
@@ -366,7 +366,7 @@ def post_data(action, params)
params[:version] = API_VERSION
params[:transaction_type] = action
- params.reject{|k,v| v.blank?}.collect{ |k, v| "dc_#{k.to_s}=#{CGI.escape(v.to_s)}" }.join('&')
+ params.reject{|k,v| v.blank?}.collect{ |k, v| "dc_#{k}=#{CGI.escape(v.to_s)}" }.join('&')
end
def parse(body)
diff --git a/lib/active_merchant/billing/gateways/skip_jack.rb b/lib/active_merchant/billing/gateways/skip_jack.rb
index 7dbf0372d62..5e5b8a91534 100644
--- a/lib/active_merchant/billing/gateways/skip_jack.rb
+++ b/lib/active_merchant/billing/gateways/skip_jack.rb
@@ -354,7 +354,7 @@ def post_data(action, money, params = {})
add_credentials(params, action)
add_amount(params, action, money)
sorted_params = params.to_a.sort{|a,b| a.to_s <=> b.to_s}.reverse
- sorted_params.collect { |key, value| "#{key.to_s}=#{CGI.escape(value.to_s)}" }.join('&')
+ sorted_params.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
end
def add_transaction_id(post, transaction_id)
diff --git a/lib/active_merchant/billing/gateways/usa_epay_advanced.rb b/lib/active_merchant/billing/gateways/usa_epay_advanced.rb
index bf38626368a..a34d269abb6 100644
--- a/lib/active_merchant/billing/gateways/usa_epay_advanced.rb
+++ b/lib/active_merchant/billing/gateways/usa_epay_advanced.rb
@@ -272,8 +272,8 @@ def initialize(options = {})
requires!(options, :login, :password)
if options[:software_id]
- self.live_url = "#{LIVE_URL_BASE}#{options[:software_id].to_s}"
- self.test_url = "#{TEST_URL_BASE}#{options[:software_id].to_s}"
+ self.live_url = "#{LIVE_URL_BASE}#{options[:software_id]}"
+ self.test_url = "#{TEST_URL_BASE}#{options[:software_id]}"
else
self.live_url = options[:live_url].to_s
self.test_url = options[:test_url].to_s if options[:test_url]
diff --git a/test/remote/gateways/remote_authorize_net_cim_test.rb b/test/remote/gateways/remote_authorize_net_cim_test.rb
index 08001073228..124b81c7753 100644
--- a/test/remote/gateways/remote_authorize_net_cim_test.rb
+++ b/test/remote/gateways/remote_authorize_net_cim_test.rb
@@ -615,7 +615,7 @@ def test_should_create_duplicate_customer_profile_transactions_with_duplicate_wi
:type => :auth_capture,
:order => {
:invoice_number => key.to_s,
- :description => "Test Order Description #{key.to_s}",
+ :description => "Test Order Description #{key}",
:purchase_order_number => key.to_s
},
:amount => @amount
@@ -651,7 +651,7 @@ def test_should_not_create_duplicate_customer_profile_transactions_without_dupli
:type => :auth_capture,
:order => {
:invoice_number => key.to_s,
- :description => "Test Order Description #{key.to_s}",
+ :description => "Test Order Description #{key}",
:purchase_order_number => key.to_s
},
:amount => @amount
@@ -821,7 +821,7 @@ def get_and_validate_auth_capture_response
:type => :auth_capture,
:order => {
:invoice_number => key.to_s,
- :description => "Test Order Description #{key.to_s}",
+ :description => "Test Order Description #{key}",
:purchase_order_number => key.to_s
},
:amount => @amount
@@ -836,7 +836,7 @@ def get_and_validate_auth_capture_response
assert_equal 'auth_capture', response.params['direct_response']['transaction_type']
assert_equal '100.00', response.params['direct_response']['amount']
assert_equal response.params['direct_response']['invoice_number'], key.to_s
- assert_equal response.params['direct_response']['order_description'], "Test Order Description #{key.to_s}"
+ assert_equal response.params['direct_response']['order_description'], "Test Order Description #{key}"
assert_equal response.params['direct_response']['purchase_order_number'], key.to_s
return response
end
@@ -856,7 +856,7 @@ def get_and_validate_auth_only_response
:type => :auth_only,
:order => {
:invoice_number => key.to_s,
- :description => "Test Order Description #{key.to_s}",
+ :description => "Test Order Description #{key}",
:purchase_order_number => key.to_s
},
:amount => @amount
From d548ddfacf98bcd07ee4636046ad90fabb4a6b5c Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 1 Nov 2018 11:16:31 -0400
Subject: [PATCH 0143/2234] RuboCop: fix Style/Lambda
---
.rubocop_todo.yml | 8 --------
lib/active_merchant/billing/gateways/orbital.rb | 2 +-
2 files changed, 1 insertion(+), 9 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 100ba02790f..62b89cf66cf 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -903,14 +903,6 @@ Style/InverseMethods:
- 'lib/active_merchant/billing/gateways/ogone.rb'
- 'lib/active_merchant/billing/gateways/worldpay.rb'
-# Offense count: 1
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle.
-# SupportedStyles: line_count_dependent, lambda, literal
-Style/Lambda:
- Exclude:
- - 'lib/active_merchant/billing/gateways/orbital.rb'
-
# Offense count: 15
# Cop supports --auto-correct.
Style/LineEndConcatenation:
diff --git a/lib/active_merchant/billing/gateways/orbital.rb b/lib/active_merchant/billing/gateways/orbital.rb
index 53ac7b2ac25..89a5007f85b 100644
--- a/lib/active_merchant/billing/gateways/orbital.rb
+++ b/lib/active_merchant/billing/gateways/orbital.rb
@@ -531,7 +531,7 @@ def commit(order, message_type, trace_number=nil)
headers = POST_HEADERS.merge('Content-length' => order.size.to_s)
headers.merge!( 'Trace-number' => trace_number.to_s,
'Merchant-Id' => @options[:merchant_id] ) if @options[:retry_logic] && trace_number
- request = lambda{|url| parse(ssl_post(url, order, headers))}
+ request = ->(url){ parse(ssl_post(url, order, headers))}
# Failover URL will be attempted in the event of a connection error
response = begin
From a23919156f315f895341480c26512ab314cc8e71 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 1 Nov 2018 11:18:30 -0400
Subject: [PATCH 0144/2234] RuboCop: fix Style/LineEndConcatenation
---
.rubocop_todo.yml | 10 ----------
lib/active_merchant/billing/gateways/commercegate.rb | 4 ++--
lib/active_merchant/billing/gateways/pay_hub.rb | 2 +-
lib/active_merchant/billing/gateways/swipe_checkout.rb | 4 ++--
test/unit/gateways/barclays_epdq_extra_plus_test.rb | 10 +++++-----
test/unit/gateways/ogone_test.rb | 10 +++++-----
6 files changed, 15 insertions(+), 25 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 62b89cf66cf..cae28dbf98e 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -903,16 +903,6 @@ Style/InverseMethods:
- 'lib/active_merchant/billing/gateways/ogone.rb'
- 'lib/active_merchant/billing/gateways/worldpay.rb'
-# Offense count: 15
-# Cop supports --auto-correct.
-Style/LineEndConcatenation:
- Exclude:
- - 'lib/active_merchant/billing/gateways/commercegate.rb'
- - 'lib/active_merchant/billing/gateways/pay_hub.rb'
- - 'lib/active_merchant/billing/gateways/swipe_checkout.rb'
- - 'test/unit/gateways/barclays_epdq_extra_plus_test.rb'
- - 'test/unit/gateways/ogone_test.rb'
-
# Offense count: 31
# Cop supports --auto-correct.
# Configuration parameters: IgnoredMethods.
diff --git a/lib/active_merchant/billing/gateways/commercegate.rb b/lib/active_merchant/billing/gateways/commercegate.rb
index c831141b0c8..f3cd6500830 100644
--- a/lib/active_merchant/billing/gateways/commercegate.rb
+++ b/lib/active_merchant/billing/gateways/commercegate.rb
@@ -126,8 +126,8 @@ def message_from(response)
if response['returnText'].present?
response['returnText']
else
- 'Invalid response received from the CommerceGate API. ' +
- 'Please contact CommerceGate support if you continue to receive this message. ' +
+ 'Invalid response received from the CommerceGate API. ' \
+ 'Please contact CommerceGate support if you continue to receive this message. ' \
"(The raw response returned by the API was #{response.inspect})"
end
end
diff --git a/lib/active_merchant/billing/gateways/pay_hub.rb b/lib/active_merchant/billing/gateways/pay_hub.rb
index d354f5c1db9..47c6ac35cc7 100644
--- a/lib/active_merchant/billing/gateways/pay_hub.rb
+++ b/lib/active_merchant/billing/gateways/pay_hub.rb
@@ -200,7 +200,7 @@ def response_error(raw_response)
def json_error(raw_response)
{
- error_message: 'Invalid response received from the Payhub API. Please contact wecare@payhub.com if you continue to receive this message.' +
+ error_message: 'Invalid response received from the Payhub API. Please contact wecare@payhub.com if you continue to receive this message.' \
" (The raw response returned by the API was #{raw_response.inspect})"
}
end
diff --git a/lib/active_merchant/billing/gateways/swipe_checkout.rb b/lib/active_merchant/billing/gateways/swipe_checkout.rb
index dcd63d1fdec..aaf4002d355 100644
--- a/lib/active_merchant/billing/gateways/swipe_checkout.rb
+++ b/lib/active_merchant/billing/gateways/swipe_checkout.rb
@@ -117,8 +117,8 @@ def commit(action, money, parameters)
rescue ResponseError => e
build_error_response("ssl_post() with url #{url} raised ResponseError: #{e}")
rescue JSON::ParserError => e
- msg = 'Invalid response received from the Swipe Checkout API. ' +
- 'Please contact support@optimizerhq.com if you continue to receive this message.' +
+ msg = 'Invalid response received from the Swipe Checkout API. ' \
+ 'Please contact support@optimizerhq.com if you continue to receive this message.' \
" (Full error message: #{e})"
build_error_response(msg)
end
diff --git a/test/unit/gateways/barclays_epdq_extra_plus_test.rb b/test/unit/gateways/barclays_epdq_extra_plus_test.rb
index 2155d23a374..330bdf13d4d 100644
--- a/test/unit/gateways/barclays_epdq_extra_plus_test.rb
+++ b/test/unit/gateways/barclays_epdq_extra_plus_test.rb
@@ -414,15 +414,15 @@ def test_transcript_scrubbing
private
def string_to_digest
- 'ALIAS=2mynicesigAMOUNT=100mynicesigCARDNO=4111111111111111mynicesig'+
- 'CN=Client NamemynicesigCURRENCY=EURmynicesigOPERATION=RESmynicesig'+
+ 'ALIAS=2mynicesigAMOUNT=100mynicesigCARDNO=4111111111111111mynicesig'\
+ 'CN=Client NamemynicesigCURRENCY=EURmynicesigOPERATION=RESmynicesig'\
'ORDERID=1mynicesigPSPID=MrPSPIDmynicesig'
end
def d3d_string_to_digest
- 'ALIAS=2mynicesigAMOUNT=100mynicesigCARDNO=4111111111111111mynicesig'+
- 'CN=Client NamemynicesigCURRENCY=EURmynicesigFLAG3D=Ymynicesig'+
- 'HTTP_ACCEPT=*/*mynicesigOPERATION=RESmynicesigORDERID=1mynicesig'+
+ 'ALIAS=2mynicesigAMOUNT=100mynicesigCARDNO=4111111111111111mynicesig'\
+ 'CN=Client NamemynicesigCURRENCY=EURmynicesigFLAG3D=Ymynicesig'\
+ 'HTTP_ACCEPT=*/*mynicesigOPERATION=RESmynicesigORDERID=1mynicesig'\
'PSPID=MrPSPIDmynicesigWIN3DS=MAINWmynicesig'
end
diff --git a/test/unit/gateways/ogone_test.rb b/test/unit/gateways/ogone_test.rb
index 3118e4b7193..8454a030cfd 100644
--- a/test/unit/gateways/ogone_test.rb
+++ b/test/unit/gateways/ogone_test.rb
@@ -453,15 +453,15 @@ def test_transcript_scrubbing
private
def string_to_digest
- 'ALIAS=2mynicesigAMOUNT=100mynicesigCARDNO=4111111111111111mynicesig'+
- 'CN=Client NamemynicesigCURRENCY=EURmynicesigOPERATION=RESmynicesig'+
+ 'ALIAS=2mynicesigAMOUNT=100mynicesigCARDNO=4111111111111111mynicesig'\
+ 'CN=Client NamemynicesigCURRENCY=EURmynicesigOPERATION=RESmynicesig'\
'ORDERID=1mynicesigPSPID=MrPSPIDmynicesig'
end
def d3d_string_to_digest
- 'ALIAS=2mynicesigAMOUNT=100mynicesigCARDNO=4111111111111111mynicesig'+
- 'CN=Client NamemynicesigCURRENCY=EURmynicesigFLAG3D=Ymynicesig'+
- 'HTTP_ACCEPT=*/*mynicesigOPERATION=RESmynicesigORDERID=1mynicesig'+
+ 'ALIAS=2mynicesigAMOUNT=100mynicesigCARDNO=4111111111111111mynicesig'\
+ 'CN=Client NamemynicesigCURRENCY=EURmynicesigFLAG3D=Ymynicesig'\
+ 'HTTP_ACCEPT=*/*mynicesigOPERATION=RESmynicesigORDERID=1mynicesig'\
'PSPID=MrPSPIDmynicesigWIN3DS=MAINWmynicesig'
end
From 3e4930f652435904448df6f28930a36d07fa3541 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 1 Nov 2018 11:20:03 -0400
Subject: [PATCH 0145/2234] RuboCop: fix Lint/UnderscorePrefixedVariableName
---
.rubocop_todo.yml | 5 -----
lib/active_merchant/billing/gateways/ogone.rb | 4 ++--
2 files changed, 2 insertions(+), 7 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index cae28dbf98e..21f586c44be 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -271,11 +271,6 @@ Lint/RescueException:
Exclude:
- 'lib/active_merchant/billing/gateways/quantum.rb'
-# Offense count: 1
-Lint/UnderscorePrefixedVariableName:
- Exclude:
- - 'lib/active_merchant/billing/gateways/ogone.rb'
-
# Offense count: 1453
# Cop supports --auto-correct.
# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
diff --git a/lib/active_merchant/billing/gateways/ogone.rb b/lib/active_merchant/billing/gateways/ogone.rb
index 0ac3b015f75..776fa67b0a4 100644
--- a/lib/active_merchant/billing/gateways/ogone.rb
+++ b/lib/active_merchant/billing/gateways/ogone.rb
@@ -301,8 +301,8 @@ def add_eci(post, eci)
add_pair post, 'ECI', eci.to_s
end
- def add_alias(post, _alias, alias_operation = nil)
- add_pair post, 'ALIAS', _alias
+ def add_alias(post, alias_name, alias_operation = nil)
+ add_pair post, 'ALIAS', alias_name
add_pair post, 'ALIASOPERATION', alias_operation unless alias_operation.nil?
end
From 695bd9a7be3e5c8bac95feadaa43bdbb0ad2e108 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 1 Nov 2018 11:22:45 -0400
Subject: [PATCH 0146/2234] RuboCop: fix Layout/SpaceInsideStringInterpolation
---
.rubocop_todo.yml | 10 ----------
lib/active_merchant/billing/gateways/garanti.rb | 2 +-
lib/active_merchant/billing/gateways/trust_commerce.rb | 2 +-
test/unit/gateways/worldpay_test.rb | 2 +-
4 files changed, 3 insertions(+), 13 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 21f586c44be..ad95f8046e4 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -231,16 +231,6 @@ Layout/SpaceInsideReferenceBrackets:
- 'test/remote/gateways/remote_ideal_rabobank_test.rb'
- 'test/remote/gateways/remote_wirecard_test.rb'
-# Offense count: 3
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle.
-# SupportedStyles: space, no_space
-Layout/SpaceInsideStringInterpolation:
- Exclude:
- - 'lib/active_merchant/billing/gateways/garanti.rb'
- - 'lib/active_merchant/billing/gateways/trust_commerce.rb'
- - 'test/unit/gateways/worldpay_test.rb'
-
# Offense count: 148
# Configuration parameters: AllowSafeAssignment.
Lint/AssignmentInCondition:
diff --git a/lib/active_merchant/billing/gateways/garanti.rb b/lib/active_merchant/billing/gateways/garanti.rb
index 5a95e3383db..ef2dacc84c8 100644
--- a/lib/active_merchant/billing/gateways/garanti.rb
+++ b/lib/active_merchant/billing/gateways/garanti.rb
@@ -181,7 +181,7 @@ def add_addresses(xml, options)
def add_address(xml, address)
xml.tag! 'Name', normalize(address[:name])
address_text = address[:address1]
- address_text << " #{ address[:address2]}" if address[:address2]
+ address_text << " #{address[:address2]}" if address[:address2]
xml.tag! 'Text', normalize(address_text)
xml.tag! 'City', normalize(address[:city])
xml.tag! 'District', normalize(address[:state])
diff --git a/lib/active_merchant/billing/gateways/trust_commerce.rb b/lib/active_merchant/billing/gateways/trust_commerce.rb
index 2b3dae1ec69..7fab693c69e 100644
--- a/lib/active_merchant/billing/gateways/trust_commerce.rb
+++ b/lib/active_merchant/billing/gateways/trust_commerce.rb
@@ -371,7 +371,7 @@ def clean_and_stringify_params(parameters)
end
def post_data(parameters)
- parameters.collect { |key, value| "#{key}=#{ CGI.escape(value.to_s)}" }.join('&')
+ parameters.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
end
def commit(action, parameters)
diff --git a/test/unit/gateways/worldpay_test.rb b/test/unit/gateways/worldpay_test.rb
index 7fe93d7acc2..e40767eda0a 100644
--- a/test/unit/gateways/worldpay_test.rb
+++ b/test/unit/gateways/worldpay_test.rb
@@ -655,7 +655,7 @@ def successful_refund_inquiry_response(last_event='CAPTURED')
VISA-SSL
- #{ last_event }
+ #{last_event}
From 12f15a70f6c12bf3397d7be6fa66dc1c1438d1fd Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 1 Nov 2018 11:38:57 -0400
Subject: [PATCH 0147/2234] RuboCop: fix Lint/DuplicateMethods
---
.rubocop_todo.yml | 9 ---
.../remote_litle_certification_test.rb | 56 -------------------
.../remote_mercury_certification_test.rb | 24 --------
.../gateways/remote_modern_payments_test.rb | 11 ----
test/remote/gateways/remote_netaxept_test.rb | 14 -----
test/remote/gateways/remote_verifi_test.rb | 9 ---
6 files changed, 123 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index ad95f8046e4..70e66b6ae38 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -236,15 +236,6 @@ Layout/SpaceInsideReferenceBrackets:
Lint/AssignmentInCondition:
Enabled: false
-# Offense count: 8
-Lint/DuplicateMethods:
- Exclude:
- - 'test/remote/gateways/remote_litle_certification_test.rb'
- - 'test/remote/gateways/remote_mercury_certification_test.rb'
- - 'test/remote/gateways/remote_modern_payments_test.rb'
- - 'test/remote/gateways/remote_netaxept_test.rb'
- - 'test/remote/gateways/remote_verifi_test.rb'
-
# Offense count: 3
Lint/FormatParameterMismatch:
Exclude:
diff --git a/test/remote/gateways/remote_litle_certification_test.rb b/test/remote/gateways/remote_litle_certification_test.rb
index 90335ac3a7b..c36e352e476 100644
--- a/test/remote/gateways/remote_litle_certification_test.rb
+++ b/test/remote/gateways/remote_litle_certification_test.rb
@@ -1161,62 +1161,6 @@ def test_authorize_and_purchase_and_credit_with_token
private
- def auth_assertions(amount, card, options, assertions={})
- # 1: authorize
- assert response = @gateway.authorize(amount, card, options)
- assert_success response
- assert_equal 'Approved', response.message
- assert_equal assertions[:avs], response.avs_result['code'] if assertions[:avs]
- assert_equal assertions[:cvv], response.cvv_result['code'] if assertions[:cvv]
- assert_equal auth_code(options[:order_id]), response.params['authCode']
- puts "Test #{options[:order_id]} Authorize: #{txn_id(response)}"
-
- # 1A: capture
- assert response = @gateway.capture(amount, response.authorization, {:id => transaction_id})
- assert_equal 'Approved', response.message
- puts "Test #{options[:order_id]}A: #{txn_id(response)}"
-
- # 1B: credit
- assert response = @gateway.credit(amount, response.authorization, {:id => transaction_id})
- assert_equal 'Approved', response.message
- puts "Test #{options[:order_id]}B: #{txn_id(response)}"
-
- # 1C: void
- assert response = @gateway.void(response.authorization, {:id => transaction_id})
- assert_equal 'Approved', response.message
- puts "Test #{options[:order_id]}C: #{txn_id(response)}"
- end
-
- def authorize_avs_assertions(credit_card, options, assertions={})
- assert response = @gateway.authorize(000, credit_card, options)
- assert_equal assertions.key?(:success) ? assertions[:success] : true, response.success?
- assert_equal assertions[:message] || 'Approved', response.message
- assert_equal assertions[:avs], response.avs_result['code'], caller.inspect
- assert_equal assertions[:cvv], response.cvv_result['code'], caller.inspect if assertions[:cvv]
- puts "Test #{options[:order_id]} AVS Only: #{txn_id(response)}"
- end
-
- def sale_assertions(amount, card, options, assertions={})
- # 1: sale
- assert response = @gateway.purchase(amount, card, options)
- assert_success response
- assert_equal 'Approved', response.message
- assert_equal assertions[:avs], response.avs_result['code'] if assertions[:avs]
- assert_equal assertions[:cvv], response.cvv_result['code'] if assertions[:cvv]
- assert_equal auth_code(options[:order_id]), response.params['authCode']
- puts "Test #{options[:order_id]} Sale: #{txn_id(response)}"
-
- # 1B: credit
- assert response = @gateway.credit(amount, response.authorization, {:id => transaction_id})
- assert_equal 'Approved', response.message
- puts "Test #{options[:order_id]}B Sale: #{txn_id(response)}"
-
- # 1C: void
- assert response = @gateway.void(response.authorization, {:id => transaction_id})
- assert_equal 'Approved', response.message
- puts "Test #{options[:order_id]}C Sale: #{txn_id(response)}"
- end
-
def auth_assertions(amount, card, options, assertions={})
# 1: authorize
assert response = @gateway.authorize(amount, card, options)
diff --git a/test/remote/gateways/remote_mercury_certification_test.rb b/test/remote/gateways/remote_mercury_certification_test.rb
index f019b3ad045..56cb9de3234 100644
--- a/test/remote/gateways/remote_mercury_certification_test.rb
+++ b/test/remote/gateways/remote_mercury_certification_test.rb
@@ -30,30 +30,6 @@ def test_sale_and_void
assert_equal 'AP', void.params['text_response']
end
- def test_preauth_capture_and_reversal
- close_batch(tokenization_gateway)
-
- cc = credit_card(
- '4005550000000480',
- :brand => 'visa',
- :month => '12',
- :year => '15',
- :verification_value => '123'
- )
-
- preauth = tokenization_gateway.authorize(106, cc, options('1'))
- assert_success preauth
- assert_equal 'AP', preauth.params['text_response']
-
- capture = tokenization_gateway.capture(106, preauth.authorization, options)
- assert_success capture
- assert_equal 'AP', capture.params['text_response']
-
- reversal = tokenization_gateway.void(capture.authorization, options.merge(:try_reversal => true))
- assert_success reversal
- assert_equal 'REVERSED', reversal.params['text_response']
- end
-
def test_return
close_batch(tokenization_gateway)
diff --git a/test/remote/gateways/remote_modern_payments_test.rb b/test/remote/gateways/remote_modern_payments_test.rb
index cb5d594afa7..e0fff6eeb95 100644
--- a/test/remote/gateways/remote_modern_payments_test.rb
+++ b/test/remote/gateways/remote_modern_payments_test.rb
@@ -32,16 +32,6 @@ def test_unsuccessful_purchase
assert_equal ModernPaymentsCimGateway::FAILURE_MESSAGE, response.message
end
- def test_invalid_login
- gateway = ModernPaymentsGateway.new(
- :login => '5000',
- :password => 'password'
- )
- assert response = gateway.purchase(@amount, @credit_card, @options)
- assert_failure response
- assert_equal ModernPaymentsCimGateway::FAILURE_MESSAGE, response.message
- end
-
def test_invalid_login
gateway = ModernPaymentsGateway.new(
:login => '',
@@ -52,5 +42,4 @@ def test_invalid_login
gateway.purchase(@amount, @credit_card, @options)
end
end
-
end
diff --git a/test/remote/gateways/remote_netaxept_test.rb b/test/remote/gateways/remote_netaxept_test.rb
index 5219b4144bc..6112d9798c9 100644
--- a/test/remote/gateways/remote_netaxept_test.rb
+++ b/test/remote/gateways/remote_netaxept_test.rb
@@ -74,20 +74,6 @@ def test_failed_void
assert_equal 'Unable to annul, wrong state', response.message
end
- def test_successful_amex_purchase
- credit_card = credit_card('378282246310005', :brand => 'american_express')
- assert response = @gateway.purchase(@amount, credit_card, @options)
- assert_success response
- assert_equal 'OK', response.message
- end
-
- def test_successful_master_purchase
- credit_card = credit_card('5413000000000000', :brand => 'master')
- assert response = @gateway.purchase(@amount, credit_card, @options)
- assert_success response
- assert_equal 'OK', response.message
- end
-
def test_error_in_transaction_setup
assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:currency => 'BOGG'))
assert_failure response
diff --git a/test/remote/gateways/remote_verifi_test.rb b/test/remote/gateways/remote_verifi_test.rb
index d9579c15752..2514864a96f 100644
--- a/test/remote/gateways/remote_verifi_test.rb
+++ b/test/remote/gateways/remote_verifi_test.rb
@@ -58,15 +58,6 @@ def test_authorization_and_capture
assert_equal 'Transaction was Approved', capture.message
end
- def test_authorization_and_void
- assert authorization = @gateway.authorize(@amount, @credit_card, @options)
- assert_success authorization
- assert authorization
- assert void = @gateway.void(authorization.authorization, @options)
- assert_success void
- assert_equal 'Transaction was Approved', void.message
- end
-
# Credits are not enabled on test accounts, so this should always fail
def test_credit
assert response = @gateway.credit(@amount, @credit_card, @options)
From db320231388bcc434684f7aebc2d1537db476b6b Mon Sep 17 00:00:00 2001
From: David Perry
Date: Fri, 2 Nov 2018 09:59:38 -0400
Subject: [PATCH 0148/2234] Braintree: Account for nil billing address fields
The earlier fix for phone-only billing address options did not account
for other elements being present but nil. Now we compact the address.
Closes #3029
Remote:
64 tests, 365 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
56 tests, 141 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/braintree_blue.rb | 2 +-
.../gateways/remote_braintree_blue_test.rb | 3 +-
test/unit/gateways/braintree_blue_test.rb | 28 +++++++++++++++++++
4 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 1f9e4bbbe9d..d98fa432d0a 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -15,6 +15,7 @@
* Barclaycard Smartpay: Improves Error Handling [deedeelavinder] #3026
* Braintree: Fix passing phone-only billing address [curiousepic] #3025
* Litle: Capitalize check account type [curiousepic] #3028
+* Braintree: Account for nil billing address fields [curiousepic] #3029
== Version 1.85.0 (September 28, 2018)
* Authorize.Net: Support custom delimiter for cim [curiousepic] #3001
diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb
index d693e587fed..067fadc5299 100644
--- a/lib/active_merchant/billing/gateways/braintree_blue.rb
+++ b/lib/active_merchant/billing/gateways/braintree_blue.rb
@@ -305,7 +305,7 @@ def merge_credit_card_options(parameters, options)
parameters[:credit_card] ||= {}
parameters[:credit_card].merge!(:options => valid_options)
address = options[:billing_address]&.except(:phone)
- return parameters if address.nil? || address.empty?
+ return parameters if address.nil? || address.values.compact.empty?
parameters[:credit_card][:billing_address] = map_address(address)
parameters
end
diff --git a/test/remote/gateways/remote_braintree_blue_test.rb b/test/remote/gateways/remote_braintree_blue_test.rb
index 22885692808..ff816acb973 100644
--- a/test/remote/gateways/remote_braintree_blue_test.rb
+++ b/test/remote/gateways/remote_braintree_blue_test.rb
@@ -170,7 +170,8 @@ def test_successful_store_with_billing_address
def test_successful_store_with_phone_only_billing_address_option
billing_address = {
- :phone => '123-456-7890'
+ :phone => '123-456-7890',
+ :city => nil
}
credit_card = credit_card('5105105105105100')
assert response = @gateway.store(credit_card, :billing_address => billing_address)
diff --git a/test/unit/gateways/braintree_blue_test.rb b/test/unit/gateways/braintree_blue_test.rb
index 68a6092da88..0a604b717f5 100644
--- a/test/unit/gateways/braintree_blue_test.rb
+++ b/test/unit/gateways/braintree_blue_test.rb
@@ -373,6 +373,34 @@ def test_store_with_phone_only_billing_address_option
@gateway.store(credit_card('41111111111111111111'), :billing_address => billing_address)
end
+ def test_store_with_phone_only_non_nil_billing_address_option
+ customer_attributes = {
+ :credit_cards => [stub_everything],
+ :email => 'email',
+ :first_name => 'John',
+ :last_name => 'Smith',
+ :phone => '123-456-7890'
+ }
+ billing_address = {
+ :phone => '123-456-7890',
+ :address1 => nil,
+ :address2 => nil,
+ :city => nil,
+ :state => nil,
+ :zip => nil,
+ :country_name => nil
+ }
+ customer = stub(customer_attributes)
+ customer.stubs(:id).returns('123')
+ result = Braintree::SuccessfulResult.new(:customer => customer)
+ Braintree::CustomerGateway.any_instance.expects(:create).with do |params|
+ assert_nil params[:credit_card][:billing_address]
+ params
+ end.returns(result)
+
+ @gateway.store(credit_card('41111111111111111111'), :billing_address => billing_address)
+ end
+
def test_store_with_credit_card_token
customer = stub(
:email => 'email',
From 2f4b8e0e1e8e248d6e32042e90792e4cd49a2390 Mon Sep 17 00:00:00 2001
From: Kheang Lim
Date: Fri, 2 Nov 2018 11:48:10 -0400
Subject: [PATCH 0149/2234] Realex: Add verify
Add verify method by making an Open to Buy (OTB) request:
https://developer.realexpayments.com/#!/api/process-payment/otb
Closes #3030
Remote (1 unrelated failure from `test_realex_purchase_then_refund`):
23 tests, 122 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
95.6522% passed
Unit:
22 tests, 526 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/realex.rb | 21 ++++++++++++
test/remote/gateways/remote_realex_test.rb | 26 +++++++++++++++
test/unit/gateways/realex_test.rb | 32 ++++++++++++++++++-
4 files changed, 79 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index d98fa432d0a..d678c59ba95 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -16,6 +16,7 @@
* Braintree: Fix passing phone-only billing address [curiousepic] #3025
* Litle: Capitalize check account type [curiousepic] #3028
* Braintree: Account for nil billing address fields [curiousepic] #3029
+* Realex: Add verify [kheang] #3030
== Version 1.85.0 (September 28, 2018)
* Authorize.Net: Support custom delimiter for cim [curiousepic] #3001
diff --git a/lib/active_merchant/billing/gateways/realex.rb b/lib/active_merchant/billing/gateways/realex.rb
index bfe4733cd72..6d58ea3f6e9 100644
--- a/lib/active_merchant/billing/gateways/realex.rb
+++ b/lib/active_merchant/billing/gateways/realex.rb
@@ -80,6 +80,13 @@ def void(authorization, options = {})
commit(request)
end
+ def verify(credit_card, options = {})
+ requires!(options, :order_id)
+
+ request = build_verify_request(credit_card, options)
+ commit(request)
+ end
+
def supports_scrubbing
true
end
@@ -185,6 +192,20 @@ def build_void_request(authorization, options)
xml.target!
end
+ # Verify initiates an OTB (Open To Buy) request
+ def build_verify_request(credit_card, options)
+ timestamp = new_timestamp
+ xml = Builder::XmlMarkup.new :indent => 2
+ xml.tag! 'request', 'timestamp' => timestamp, 'type' => 'otb' do
+ add_merchant_details(xml, options)
+ xml.tag! 'orderid', sanitize_order_id(options[:order_id])
+ add_card(xml, credit_card)
+ add_comments(xml, options)
+ add_signed_digest(xml, timestamp, @options[:login], sanitize_order_id(options[:order_id]), credit_card.number)
+ end
+ xml.target!
+ end
+
def add_address_and_customer_info(xml, options)
billing_address = options[:billing_address] || options[:address]
shipping_address = options[:shipping_address]
diff --git a/test/remote/gateways/remote_realex_test.rb b/test/remote/gateways/remote_realex_test.rb
index fc1800f2c63..b8280a6d8bc 100644
--- a/test/remote/gateways/remote_realex_test.rb
+++ b/test/remote/gateways/remote_realex_test.rb
@@ -328,6 +328,32 @@ def test_realex_purchase_then_refund
assert_equal 'Successful', rebate_response.message
end
+ def test_realex_verify
+ response = @gateway.verify(@visa,
+ :order_id => generate_unique_id,
+ :description => 'Test Realex verify'
+ )
+
+ assert_not_nil response
+ assert_success response
+ assert response.test?
+ assert response.authorization.length > 0
+ assert_equal 'Successful', response.message
+ end
+
+ def test_realex_verify_declined
+ response = @gateway.verify(@visa_declined,
+ :order_id => generate_unique_id,
+ :description => 'Test Realex verify declined'
+ )
+
+ assert_not_nil response
+ assert_failure response
+ assert response.test?
+ assert_equal '101', response.params['result']
+ assert_match %r{DECLINED}i, response.message
+ end
+
def test_maps_avs_and_cvv_response_codes
[ @visa, @mastercard ].each do |card|
response = @gateway.purchase(@amount, card,
diff --git a/test/unit/gateways/realex_test.rb b/test/unit/gateways/realex_test.rb
index e30172fa1ed..8eb73a2ed5b 100644
--- a/test/unit/gateways/realex_test.rb
+++ b/test/unit/gateways/realex_test.rb
@@ -3,7 +3,8 @@
class RealexTest < Test::Unit::TestCase
class ActiveMerchant::Billing::RealexGateway
# For the purposes of testing, lets redefine some protected methods as public.
- public :build_purchase_or_authorization_request, :build_refund_request, :build_void_request, :build_capture_request
+ public :build_purchase_or_authorization_request, :build_refund_request, :build_void_request,
+ :build_capture_request, :build_verify_request
end
def setup
@@ -193,6 +194,35 @@ def test_void_xml
assert_xml_equal valid_void_request_xml, @gateway.build_void_request('1;4321;1234', {})
end
+ def test_verify_xml
+ options = {
+ :order_id => '1'
+ }
+ @gateway.expects(:new_timestamp).returns('20181026114304')
+
+ valid_verify_request_xml = <<-SRC
+
+ your_merchant_id
+ your_account
+ 1
+
+ 4263971921001307
+ 0808
+ Longbob Longsen
+ VISA
+
+
+
+
+
+
+ d53aebf1eaee4c3ff4c30f83f27b80ce99ba5644
+
+SRC
+
+ assert_xml_equal valid_verify_request_xml, @gateway.build_verify_request(@credit_card, options)
+ end
+
def test_auth_xml
options = {
:order_id => '1'
From d1c2025a9cfe6f6ff14093cfcb7b83adc2b257f2 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Fri, 2 Nov 2018 15:33:07 -0400
Subject: [PATCH 0150/2234] RuboCop: fix Style/RandomWithOffset
---
.rubocop_todo.yml | 13 -------------
lib/active_merchant/billing/gateways/borgun.rb | 2 +-
test/remote/gateways/remote_beanstream_test.rb | 2 +-
.../remote/gateways/remote_braintree_orange_test.rb | 6 +++---
test/remote/gateways/remote_inspire_test.rb | 6 +++---
test/remote/gateways/remote_merchant_ware_test.rb | 2 +-
.../remote_merchant_ware_version_four_test.rb | 2 +-
test/remote/gateways/remote_pay_junction_test.rb | 2 +-
test/unit/gateways/beanstream_test.rb | 2 +-
9 files changed, 12 insertions(+), 25 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 70e66b6ae38..9939f162946 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -1073,19 +1073,6 @@ Style/Proc:
Style/RaiseArgs:
Enabled: false
-# Offense count: 12
-# Cop supports --auto-correct.
-Style/RandomWithOffset:
- Exclude:
- - 'lib/active_merchant/billing/gateways/borgun.rb'
- - 'test/remote/gateways/remote_beanstream_test.rb'
- - 'test/remote/gateways/remote_braintree_orange_test.rb'
- - 'test/remote/gateways/remote_inspire_test.rb'
- - 'test/remote/gateways/remote_merchant_ware_test.rb'
- - 'test/remote/gateways/remote_merchant_ware_version_four_test.rb'
- - 'test/remote/gateways/remote_pay_junction_test.rb'
- - 'test/unit/gateways/beanstream_test.rb'
-
# Offense count: 87
# Cop supports --auto-correct.
# Configuration parameters: AllowMultipleReturnValues.
diff --git a/lib/active_merchant/billing/gateways/borgun.rb b/lib/active_merchant/billing/gateways/borgun.rb
index 3705be21163..966124156ce 100644
--- a/lib/active_merchant/billing/gateways/borgun.rb
+++ b/lib/active_merchant/billing/gateways/borgun.rb
@@ -213,7 +213,7 @@ def url(action)
end
def six_random_digits
- (0...6).map { (48 + rand(10)).chr }.join
+ (0...6).map { rand(48..57).chr }.join
end
end
end
diff --git a/test/remote/gateways/remote_beanstream_test.rb b/test/remote/gateways/remote_beanstream_test.rb
index e4dd84e4680..876a02f65f0 100644
--- a/test/remote/gateways/remote_beanstream_test.rb
+++ b/test/remote/gateways/remote_beanstream_test.rb
@@ -316,7 +316,7 @@ def test_successful_add_to_vault_with_store_method
end
def test_add_to_vault_with_custom_vault_id_with_store_method
- @options[:vault_id] = rand(100000)+10001
+ @options[:vault_id] = rand(10001..110000)
assert response = @gateway.store(@visa, @options.dup)
assert_equal 'Operation Successful', response.message
assert_success response
diff --git a/test/remote/gateways/remote_braintree_orange_test.rb b/test/remote/gateways/remote_braintree_orange_test.rb
index 4b4e659e4a3..0816eb1821b 100644
--- a/test/remote/gateways/remote_braintree_orange_test.rb
+++ b/test/remote/gateways/remote_braintree_orange_test.rb
@@ -4,7 +4,7 @@ class RemoteBraintreeOrangeTest < Test::Unit::TestCase
def setup
@gateway = BraintreeGateway.new(fixtures(:braintree_orange))
- @amount = rand(10000) + 1001
+ @amount = rand(1001..11000)
@credit_card = credit_card('4111111111111111')
@check = check()
@declined_amount = rand(99)
@@ -67,7 +67,7 @@ def test_successful_add_to_vault_and_use
end
def test_add_to_vault_with_custom_vault_id
- @options[:store] = rand(100000)+10001
+ @options[:store] = rand(10001..110000)
assert response = @gateway.purchase(@amount, @credit_card, @options)
assert_equal 'This transaction has been approved', response.message
assert_success response
@@ -75,7 +75,7 @@ def test_add_to_vault_with_custom_vault_id
end
def test_add_to_vault_with_custom_vault_id_with_store_method
- @options[:billing_id] = rand(100000)+10001
+ @options[:billing_id] = rand(10001..110000)
assert response = @gateway.store(@credit_card, @options.dup)
assert_equal 'Customer Added', response.message
assert_success response
diff --git a/test/remote/gateways/remote_inspire_test.rb b/test/remote/gateways/remote_inspire_test.rb
index 221ea62b17a..4e137b4d3ff 100644
--- a/test/remote/gateways/remote_inspire_test.rb
+++ b/test/remote/gateways/remote_inspire_test.rb
@@ -4,7 +4,7 @@ class RemoteBraintreeTest < Test::Unit::TestCase
def setup
@gateway = InspireGateway.new(fixtures(:inspire))
- @amount = rand(10000) + 1001
+ @amount = rand(1001..11000)
@credit_card = credit_card('4111111111111111', :brand => 'visa')
@declined_amount = rand(99)
@options = { :order_id => generate_unique_id,
@@ -57,7 +57,7 @@ def test_successful_add_to_vault_and_use
end
def test_add_to_vault_with_custom_vault_id
- @options[:store] = rand(100000)+10001
+ @options[:store] = rand(10001..110000)
response = @gateway.purchase(@amount, @credit_card, @options)
assert_success response
assert_equal 'This transaction has been approved', response.message
@@ -65,7 +65,7 @@ def test_add_to_vault_with_custom_vault_id
end
def test_add_to_vault_with_custom_vault_id_with_store_method
- @options[:billing_id] = rand(100000)+10001
+ @options[:billing_id] = rand(10001..110000)
response = @gateway.store(@credit_card, @options.dup)
assert_success response
assert_equal 'This transaction has been approved', response.message
diff --git a/test/remote/gateways/remote_merchant_ware_test.rb b/test/remote/gateways/remote_merchant_ware_test.rb
index 71c812e730a..b4b4dc2c899 100644
--- a/test/remote/gateways/remote_merchant_ware_test.rb
+++ b/test/remote/gateways/remote_merchant_ware_test.rb
@@ -4,7 +4,7 @@ class RemoteMerchantWareTest < Test::Unit::TestCase
def setup
@gateway = MerchantWareGateway.new(fixtures(:merchant_ware))
- @amount = rand(1000) + 200
+ @amount = rand(200..1199)
@credit_card = credit_card('5424180279791732', {:brand => 'master'})
diff --git a/test/remote/gateways/remote_merchant_ware_version_four_test.rb b/test/remote/gateways/remote_merchant_ware_version_four_test.rb
index 98bb62a166d..9d02a5514d2 100644
--- a/test/remote/gateways/remote_merchant_ware_version_four_test.rb
+++ b/test/remote/gateways/remote_merchant_ware_version_four_test.rb
@@ -3,7 +3,7 @@
class RemoteMerchantWareVersionFourTest < Test::Unit::TestCase
def setup
@gateway = MerchantWareVersionFourGateway.new(fixtures(:merchant_ware_version_four))
- @amount = rand(1000) + 200
+ @amount = rand(200..1199)
@credit_card = credit_card('5424180279791732', {:brand => 'master'})
@declined_card = credit_card('1234567890123')
diff --git a/test/remote/gateways/remote_pay_junction_test.rb b/test/remote/gateways/remote_pay_junction_test.rb
index 7514b3c8a5a..bacaae52e44 100644
--- a/test/remote/gateways/remote_pay_junction_test.rb
+++ b/test/remote/gateways/remote_pay_junction_test.rb
@@ -138,6 +138,6 @@ def test_should_send_invoice
private
def success_price
- 200 + rand(200)
+ rand(200..399)
end
end
diff --git a/test/unit/gateways/beanstream_test.rb b/test/unit/gateways/beanstream_test.rb
index 985748dfd03..c07adf22c0e 100644
--- a/test/unit/gateways/beanstream_test.rb
+++ b/test/unit/gateways/beanstream_test.rb
@@ -139,7 +139,7 @@ def test_successful_purchase_with_check
def test_successful_purchase_with_vault
@gateway.expects(:ssl_post).returns(successful_purchase_response)
- vault = rand(100000)+10001
+ vault = rand(10001..110000)
assert response = @gateway.purchase(@amount, vault, @options)
assert_success response
From e789801bcf3dbc9ca69dd4887f69459ff7f76131 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Fri, 2 Nov 2018 15:35:01 -0400
Subject: [PATCH 0151/2234] RuboCop: fix Style/TernaryParentheses
---
.rubocop_todo.yml | 18 ------------------
.../gateways/beanstream/beanstream_core.rb | 6 +++---
.../billing/gateways/blue_snap.rb | 6 +++---
lib/active_merchant/billing/gateways/borgun.rb | 2 +-
.../billing/gateways/card_stream.rb | 2 +-
lib/active_merchant/billing/gateways/litle.rb | 2 +-
lib/active_merchant/billing/gateways/ogone.rb | 2 +-
.../billing/gateways/payeezy.rb | 2 +-
.../billing/gateways/visanet_peru.rb | 2 +-
9 files changed, 12 insertions(+), 30 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 9939f162946..00f7496edca 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -1165,24 +1165,6 @@ Style/StringLiterals:
Style/SymbolArray:
Enabled: false
-# Offense count: 15
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle, AllowSafeAssignment.
-# SupportedStyles: require_parentheses, require_no_parentheses, require_parentheses_when_complex
-Style/TernaryParentheses:
- Exclude:
- - 'lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb'
- - 'lib/active_merchant/billing/gateways/blue_snap.rb'
- - 'lib/active_merchant/billing/gateways/borgun.rb'
- - 'lib/active_merchant/billing/gateways/braintree_blue.rb'
- - 'lib/active_merchant/billing/gateways/card_stream.rb'
- - 'lib/active_merchant/billing/gateways/litle.rb'
- - 'lib/active_merchant/billing/gateways/moneris_us.rb'
- - 'lib/active_merchant/billing/gateways/ogone.rb'
- - 'lib/active_merchant/billing/gateways/orbital.rb'
- - 'lib/active_merchant/billing/gateways/payeezy.rb'
- - 'lib/active_merchant/billing/gateways/visanet_peru.rb'
-
# Offense count: 7
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleForMultiline.
diff --git a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb
index d1d7b2b75c4..0c309da8c52 100644
--- a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb
+++ b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb
@@ -193,11 +193,11 @@ def add_customer_ip(post, options)
end
def void_action(original_transaction_type)
- (original_transaction_type == TRANSACTIONS[:refund]) ? :void_refund : :void_purchase
+ original_transaction_type == TRANSACTIONS[:refund] ? :void_refund : :void_purchase
end
def refund_action(type)
- (type == TRANSACTIONS[:check_purchase]) ? :check_refund : :refund
+ type == TRANSACTIONS[:check_purchase] ? :check_refund : :refund
end
def secure_profile_action(type)
@@ -412,7 +412,7 @@ def post(data, use_profile_api=nil)
:test => test? || response[:authCode] == 'TEST',
:authorization => authorization_from(response),
:cvv_result => CVD_CODES[response[:cvdId]],
- :avs_result => { :code => (AVS_CODES.include? response[:avsId]) ? AVS_CODES[response[:avsId]] : response[:avsId] }
+ :avs_result => { :code => AVS_CODES.include? response[:avsId] ? AVS_CODES[response[:avsId]] : response[:avsId] }
)
end
diff --git a/lib/active_merchant/billing/gateways/blue_snap.rb b/lib/active_merchant/billing/gateways/blue_snap.rb
index 441d0e4b763..240a90c5a49 100644
--- a/lib/active_merchant/billing/gateways/blue_snap.rb
+++ b/lib/active_merchant/billing/gateways/blue_snap.rb
@@ -262,7 +262,7 @@ def commit(action, verb = :post)
def url(action = nil)
base = test? ? test_url : live_url
- resource = (action == :store) ? 'vaulted-shoppers' : 'transactions'
+ resource = action == :store ? 'vaulted-shoppers' : 'transactions'
"#{base}/#{resource}"
end
@@ -288,7 +288,7 @@ def message_from(succeeded, parsed_response)
end
def authorization_from(action, parsed_response)
- (action == :store) ? vaulted_shopper_id(parsed_response) : parsed_response['transaction-id']
+ action == :store ? vaulted_shopper_id(parsed_response) : parsed_response['transaction-id']
end
def vaulted_shopper_id(parsed_response)
@@ -307,7 +307,7 @@ def root_attributes
end
def root_element(action)
- (action == :store) ? 'vaulted-shopper' : 'card-transaction'
+ action == :store ? 'vaulted-shopper' : 'card-transaction'
end
def headers
diff --git a/lib/active_merchant/billing/gateways/borgun.rb b/lib/active_merchant/billing/gateways/borgun.rb
index 966124156ce..ae144a95c59 100644
--- a/lib/active_merchant/billing/gateways/borgun.rb
+++ b/lib/active_merchant/billing/gateways/borgun.rb
@@ -181,7 +181,7 @@ def headers
end
def build_request(action, post)
- mode = (action == 'void') ? 'cancel' : 'get'
+ mode = action == 'void' ? 'cancel' : 'get'
xml = Builder::XmlMarkup.new :indent => 18
xml.instruct!(:xml, :version => '1.0', :encoding => 'utf-8')
xml.tag!("#{mode}Authorization") do
diff --git a/lib/active_merchant/billing/gateways/card_stream.rb b/lib/active_merchant/billing/gateways/card_stream.rb
index c049b2dff57..8fa7085e67c 100644
--- a/lib/active_merchant/billing/gateways/card_stream.rb
+++ b/lib/active_merchant/billing/gateways/card_stream.rb
@@ -278,7 +278,7 @@ def add_credit_card(post, credit_card)
end
def add_threeds_required(post, options)
- add_pair(post, :threeDSRequired, (options[:threeds_required] || @threeds_required) ? 'Y' : 'N')
+ add_pair(post, :threeDSRequired, options[:threeds_required] || @threeds_required ? 'Y' : 'N')
end
def add_remote_address(post, options={})
diff --git a/lib/active_merchant/billing/gateways/litle.rb b/lib/active_merchant/billing/gateways/litle.rb
index 324b976629a..2adaf564609 100644
--- a/lib/active_merchant/billing/gateways/litle.rb
+++ b/lib/active_merchant/billing/gateways/litle.rb
@@ -402,7 +402,7 @@ def success_from(kind, parsed)
end
def authorization_from(kind, parsed, money)
- (kind == :registerToken) ? parsed[:litleToken] : "#{parsed[:litleTxnId]};#{kind};#{money}"
+ kind == :registerToken ? parsed[:litleToken] : "#{parsed[:litleTxnId]};#{kind};#{money}"
end
def split_authorization(authorization)
diff --git a/lib/active_merchant/billing/gateways/ogone.rb b/lib/active_merchant/billing/gateways/ogone.rb
index 776fa67b0a4..3805eaf7df9 100644
--- a/lib/active_merchant/billing/gateways/ogone.rb
+++ b/lib/active_merchant/billing/gateways/ogone.rb
@@ -149,7 +149,7 @@ def initialize(options = {})
# Verify and reserve the specified amount on the account, without actually doing the transaction.
def authorize(money, payment_source, options = {})
post = {}
- action = (payment_source.brand == 'mastercard') ? 'PAU' : 'RES'
+ action = payment_source.brand == 'mastercard' ? 'PAU' : 'RES'
add_invoice(post, options)
add_payment_source(post, payment_source, options)
add_address(post, payment_source, options)
diff --git a/lib/active_merchant/billing/gateways/payeezy.rb b/lib/active_merchant/billing/gateways/payeezy.rb
index fc14df47d07..6342bce30d8 100644
--- a/lib/active_merchant/billing/gateways/payeezy.rb
+++ b/lib/active_merchant/billing/gateways/payeezy.rb
@@ -135,7 +135,7 @@ def amount_from_authorization(authorization)
def add_authorization_info(params, authorization, options = {})
transaction_id, transaction_tag, method, _ = authorization.split('|')
- params[:method] = (method == 'token') ? 'credit_card' : method
+ params[:method] = method == 'token' ? 'credit_card' : method
if options[:reversal_id]
params[:reversal_id] = options[:reversal_id]
diff --git a/lib/active_merchant/billing/gateways/visanet_peru.rb b/lib/active_merchant/billing/gateways/visanet_peru.rb
index c8ba88f8b16..47f0b5d99de 100644
--- a/lib/active_merchant/billing/gateways/visanet_peru.rb
+++ b/lib/active_merchant/billing/gateways/visanet_peru.rb
@@ -176,7 +176,7 @@ def url(action, params, options={})
end
def method(action)
- (%w(authorize refund).include? action) ? :post : :put
+ %w(authorize refund).include? action ? :post : :put
end
def authorization_from(params, response, options)
From 13a07dc44c5a4086d759c49fd1a1108c6223b05b Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Fri, 2 Nov 2018 15:36:57 -0400
Subject: [PATCH 0152/2234] RuboCop: fix Style/StringLiterals
This had actually already been fixed, then got re-introduced a month
ago.
---
.rubocop_todo.yml | 4 ----
test/unit/gateways/global_collect_test.rb | 2 +-
2 files changed, 1 insertion(+), 5 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 00f7496edca..179c4eeef19 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -1154,10 +1154,6 @@ Style/SpecialGlobalVars:
Style/StringLiteralsInInterpolation:
Enabled: false
-Style/StringLiterals:
- Exclude:
- - 'test/unit/gateways/global_collect_test.rb'
-
# Offense count: 307
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, MinSize.
diff --git a/test/unit/gateways/global_collect_test.rb b/test/unit/gateways/global_collect_test.rb
index 4424d29d787..318f4ea8e38 100644
--- a/test/unit/gateways/global_collect_test.rb
+++ b/test/unit/gateways/global_collect_test.rb
@@ -429,6 +429,6 @@ def invalid_json_plus_card_data
end
def scrubbed_invalid_json_plus
- "Invalid response received from the Ingenico ePayments (formerly GlobalCollect) API. Please contact Ingenico ePayments if you continue to receive this message. (The raw response returned by the API was \"\\n \\n 502 Proxy Error\\n \\n opening connection to api-sandbox.globalcollect.com:443...\\n opened\\n starting SSL for api-sandbox.globalcollect.com:443...\\n SSL established\\n <- \\\"POST //v1/1428/payments HTTP/1.1\\\\r\\\\nContent-Type: application/json\\\\r\\\\nAuthorization: [FILTERED]\\\\r\\\\nDate: Tue, 15 Mar 2016 14:32:13 GMT\\\\r\\\\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\\\\r\\\\nAccept: */*\\\\r\\\\nUser-Agent: Ruby\\\\r\\\\nConnection: close\\\\r\\\\nHost: api-sandbox.globalcollect.com\\\\r\\\\nContent-Length: 560\\\\r\\\\n\\\\r\\\\n\\\"\\n <- \\\"{\\\\\\\"order\\\\\\\":{\\\\\\\"amountOfMoney\\\\\\\":{\\\\\\\"amount\\\\\\\":\\\\\\\"100\\\\\\\",\\\\\\\"currencyCode\\\\\\\":\\\\\\\"USD\\\\\\\"},\\\\\\\"customer\\\\\\\":{\\\\\\\"merchantCustomerId\\\\\\\":null,\\\\\\\"personalInformation\\\\\\\":{\\\\\\\"name\\\\\\\":{\\\\\\\"firstName\\\\\\\":null,\\\\\\\"surname\\\\\\\":null}},\\\\\\\"billingAddress\\\\\\\":{\\\\\\\"street\\\\\\\":\\\\\\\"456 My Street\\\\\\\",\\\\\\\"additionalInfo\\\\\\\":\\\\\\\"Apt 1\\\\\\\",\\\\\\\"zip\\\\\\\":\\\\\\\"K1C2N6\\\\\\\",\\\\\\\"city\\\\\\\":\\\\\\\"Ottawa\\\\\\\",\\\\\\\"state\\\\\\\":\\\\\\\"ON\\\\\\\",\\\\\\\"countryCode\\\\\\\":\\\\\\\"CA\\\\\\\"}},\\\\\\\"contactDetails\\\\\\\":{\\\\\\\"emailAddress\\\\\\\":null}},\\\\\\\"cardPaymentMethodSpecificInput\\\\\\\":{\\\\\\\"paymentProductId\\\\\\\":\\\\\\\"1\\\\\\\",\\\\\\\"skipAuthentication\\\\\\\":\\\\\\\"true\\\\\\\",\\\\\\\"skipFraudService\\\\\\\":\\\\\\\"true\\\\\\\",\\\\\\\"card\\\\\\\":{\\\\\\\"cvv\\\\\\\":\\\\\\\"[FILTERED]\\\\\\\",\\\\\\\"cardNumber\\\\\\\":\\\\\\\"[FILTERED]\\\\\\\",\\\\\\\"expiryDate\\\\\\\":\\\\\\\"0917\\\\\\\",\\\\\\\"cardholderName\\\\\\\":\\\\\\\"Longbob Longsen\\\\\\\"}}}\\\"\\n -> \\\"HTTP/1.1 201 Created\\\\r\\\\n\\\"\\n -> \\\"Date: Tue, 15 Mar 2016 18:32:14 GMT\\\\r\\\\n\\\"\\n -> \\\"Server: Apache/2.4.16 (Unix) OpenSSL/1.0.1p\\\\r\\\\n\\\"\\n -> \\\"Location: https://api-sandbox.globalcollect.com:443/v1/1428/payments/000000142800000000300000100001\\\\r\\\\n\\\"\\n -> \\\"X-Powered-By: Servlet/3.0 JSP/2.2\\\\r\\\\n\\\"\\n -> \\\"Connection: close\\\\r\\\\n\\\"\\n -> \\\"Transfer-Encoding: chunked\\\\r\\\\n\\\"\\n -> \\\"Content-Type: application/json\\\\r\\\\n\\\"\\n -> \\\"\\\\r\\\\n\\\"\\n -> \\\"457\\\\r\\\\n\\\"\")"
+ 'Invalid response received from the Ingenico ePayments (formerly GlobalCollect) API. Please contact Ingenico ePayments if you continue to receive this message. (The raw response returned by the API was "\\n \\n 502 Proxy Error\\n \\n opening connection to api-sandbox.globalcollect.com:443...\\n opened\\n starting SSL for api-sandbox.globalcollect.com:443...\\n SSL established\\n <- \\"POST //v1/1428/payments HTTP/1.1\\\\r\\\\nContent-Type: application/json\\\\r\\\\nAuthorization: [FILTERED]\\\\r\\\\nDate: Tue, 15 Mar 2016 14:32:13 GMT\\\\r\\\\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\\\\r\\\\nAccept: */*\\\\r\\\\nUser-Agent: Ruby\\\\r\\\\nConnection: close\\\\r\\\\nHost: api-sandbox.globalcollect.com\\\\r\\\\nContent-Length: 560\\\\r\\\\n\\\\r\\\\n\\"\\n <- \\"{\\\\\\"order\\\\\\":{\\\\\\"amountOfMoney\\\\\\":{\\\\\\"amount\\\\\\":\\\\\\"100\\\\\\",\\\\\\"currencyCode\\\\\\":\\\\\\"USD\\\\\\"},\\\\\\"customer\\\\\\":{\\\\\\"merchantCustomerId\\\\\\":null,\\\\\\"personalInformation\\\\\\":{\\\\\\"name\\\\\\":{\\\\\\"firstName\\\\\\":null,\\\\\\"surname\\\\\\":null}},\\\\\\"billingAddress\\\\\\":{\\\\\\"street\\\\\\":\\\\\\"456 My Street\\\\\\",\\\\\\"additionalInfo\\\\\\":\\\\\\"Apt 1\\\\\\",\\\\\\"zip\\\\\\":\\\\\\"K1C2N6\\\\\\",\\\\\\"city\\\\\\":\\\\\\"Ottawa\\\\\\",\\\\\\"state\\\\\\":\\\\\\"ON\\\\\\",\\\\\\"countryCode\\\\\\":\\\\\\"CA\\\\\\"}},\\\\\\"contactDetails\\\\\\":{\\\\\\"emailAddress\\\\\\":null}},\\\\\\"cardPaymentMethodSpecificInput\\\\\\":{\\\\\\"paymentProductId\\\\\\":\\\\\\"1\\\\\\",\\\\\\"skipAuthentication\\\\\\":\\\\\\"true\\\\\\",\\\\\\"skipFraudService\\\\\\":\\\\\\"true\\\\\\",\\\\\\"card\\\\\\":{\\\\\\"cvv\\\\\\":\\\\\\"[FILTERED]\\\\\\",\\\\\\"cardNumber\\\\\\":\\\\\\"[FILTERED]\\\\\\",\\\\\\"expiryDate\\\\\\":\\\\\\"0917\\\\\\",\\\\\\"cardholderName\\\\\\":\\\\\\"Longbob Longsen\\\\\\"}}}\\"\\n -> \\"HTTP/1.1 201 Created\\\\r\\\\n\\"\\n -> \\"Date: Tue, 15 Mar 2016 18:32:14 GMT\\\\r\\\\n\\"\\n -> \\"Server: Apache/2.4.16 (Unix) OpenSSL/1.0.1p\\\\r\\\\n\\"\\n -> \\"Location: https://api-sandbox.globalcollect.com:443/v1/1428/payments/000000142800000000300000100001\\\\r\\\\n\\"\\n -> \\"X-Powered-By: Servlet/3.0 JSP/2.2\\\\r\\\\n\\"\\n -> \\"Connection: close\\\\r\\\\n\\"\\n -> \\"Transfer-Encoding: chunked\\\\r\\\\n\\"\\n -> \\"Content-Type: application/json\\\\r\\\\n\\"\\n -> \\"\\\\r\\\\n\\"\\n -> \\"457\\\\r\\\\n\\"")'
end
end
From e382e5738972b8cb6d771f8b6879d44987b7b02b Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Fri, 2 Nov 2018 15:41:01 -0400
Subject: [PATCH 0153/2234] RuboCop: fix Layout/SpaceInsideReferenceBrackets
---
.rubocop_todo.yml | 17 ----------------
.../gateways/beanstream/beanstream_core.rb | 2 +-
.../billing/gateways/blue_pay.rb | 2 +-
.../billing/gateways/braintree_blue.rb | 2 +-
lib/active_merchant/billing/gateways/cams.rb | 20 +++++++++----------
.../billing/gateways/metrics_global.rb | 4 ++--
.../billing/gateways/sage_pay.rb | 6 +++---
.../billing/gateways/secure_pay.rb | 4 ++--
.../billing/gateways/transact_pro.rb | 2 +-
test/remote/gateways/remote_wirecard_test.rb | 4 ++--
10 files changed, 23 insertions(+), 40 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 179c4eeef19..b13c458f006 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -214,23 +214,6 @@ Layout/SpaceInsideParens:
Layout/SpaceInsidePercentLiteralDelimiters:
Enabled: false
-# Offense count: 35
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets.
-# SupportedStyles: space, no_space
-# SupportedStylesForEmptyBrackets: space, no_space
-Layout/SpaceInsideReferenceBrackets:
- Exclude:
- - 'lib/active_merchant/billing/gateways/blue_pay.rb'
- - 'lib/active_merchant/billing/gateways/cams.rb'
- - 'lib/active_merchant/billing/gateways/ideal/ideal_base.rb'
- - 'lib/active_merchant/billing/gateways/metrics_global.rb'
- - 'lib/active_merchant/billing/gateways/sage_pay.rb'
- - 'lib/active_merchant/billing/gateways/secure_pay.rb'
- - 'lib/active_merchant/billing/gateways/transact_pro.rb'
- - 'test/remote/gateways/remote_ideal_rabobank_test.rb'
- - 'test/remote/gateways/remote_wirecard_test.rb'
-
# Offense count: 148
# Configuration parameters: AllowSafeAssignment.
Lint/AssignmentInCondition:
diff --git a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb
index 0c309da8c52..3b6c9d2cfc4 100644
--- a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb
+++ b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb
@@ -412,7 +412,7 @@ def post(data, use_profile_api=nil)
:test => test? || response[:authCode] == 'TEST',
:authorization => authorization_from(response),
:cvv_result => CVD_CODES[response[:cvdId]],
- :avs_result => { :code => AVS_CODES.include? response[:avsId] ? AVS_CODES[response[:avsId]] : response[:avsId] }
+ :avs_result => { :code => AVS_CODES.include?(response[:avsId]) ? AVS_CODES[response[:avsId]] : response[:avsId] }
)
end
diff --git a/lib/active_merchant/billing/gateways/blue_pay.rb b/lib/active_merchant/billing/gateways/blue_pay.rb
index 063434a150f..c9cf54e23ff 100644
--- a/lib/active_merchant/billing/gateways/blue_pay.rb
+++ b/lib/active_merchant/billing/gateways/blue_pay.rb
@@ -374,7 +374,7 @@ def message_from(parsed)
if CARD_CODE_ERRORS.include?(parsed[:card_code])
message = CVVResult.messages[parsed[:card_code]]
elsif AVS_ERRORS.include?(parsed[:avs_result_code])
- message = AVSResult.messages[ parsed[:avs_result_code] ]
+ message = AVSResult.messages[parsed[:avs_result_code]]
else
message = message.chomp('.')
end
diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb
index 067fadc5299..5f0c0f30542 100644
--- a/lib/active_merchant/billing/gateways/braintree_blue.rb
+++ b/lib/active_merchant/billing/gateways/braintree_blue.rb
@@ -53,7 +53,7 @@ def initialize(options = {})
super
if wiredump_device.present?
- logger = ((Logger === wiredump_device) ? wiredump_device : Logger.new(wiredump_device))
+ logger = (Logger === wiredump_device ? wiredump_device : Logger.new(wiredump_device))
logger.level = Logger::DEBUG
else
logger = Braintree::Configuration.logger.clone
diff --git a/lib/active_merchant/billing/gateways/cams.rb b/lib/active_merchant/billing/gateways/cams.rb
index c053f77ecbc..fdb310358c6 100644
--- a/lib/active_merchant/billing/gateways/cams.rb
+++ b/lib/active_merchant/billing/gateways/cams.rb
@@ -140,18 +140,18 @@ def scrub(transcript)
def add_address(post, creditcard, options={})
post[:firstname] = creditcard.first_name
- post[:lastname ] = creditcard.last_name
+ post[:lastname] = creditcard.last_name
return unless options[:billing_address]
address = options[:billing_address]
- post[:address1 ] = address[:address1]
- post[:address2 ] = address[:address2]
- post[:city ] = address[:city]
- post[:state ] = address[:state]
- post[:zip ] = address[:zip]
- post[:country ] = address[:country]
- post[:phone ] = address[:phone]
+ post[:address1] = address[:address1]
+ post[:address2] = address[:address2]
+ post[:city] = address[:city]
+ post[:state] = address[:state]
+ post[:zip] = address[:zip]
+ post[:country] = address[:country]
+ post[:phone] = address[:phone]
end
def add_reference(post, authorization)
@@ -167,8 +167,8 @@ def add_invoice(post, money, options)
def add_payment(post, payment)
post[:ccnumber] = payment.number
- post[:ccexp ] = "#{payment.month.to_s.rjust(2,"0")}#{payment.year.to_s[-2..-1]}"
- post[:cvv ] = payment.verification_value
+ post[:ccexp] = "#{payment.month.to_s.rjust(2,"0")}#{payment.year.to_s[-2..-1]}"
+ post[:cvv] = payment.verification_value
end
def parse(body)
diff --git a/lib/active_merchant/billing/gateways/metrics_global.rb b/lib/active_merchant/billing/gateways/metrics_global.rb
index de046d9932b..314f403c83c 100644
--- a/lib/active_merchant/billing/gateways/metrics_global.rb
+++ b/lib/active_merchant/billing/gateways/metrics_global.rb
@@ -286,9 +286,9 @@ def add_address(post, options)
def message_from(results)
if results[:response_code] == DECLINED
- return CVVResult.messages[ results[:card_code] ] if CARD_CODE_ERRORS.include?(results[:card_code])
+ return CVVResult.messages[results[:card_code]] if CARD_CODE_ERRORS.include?(results[:card_code])
if AVS_REASON_CODES.include?(results[:response_reason_code]) && AVS_ERRORS.include?(results[:avs_result_code])
- return AVSResult.messages[ results[:avs_result_code] ]
+ return AVSResult.messages[results[:avs_result_code]]
end
end
diff --git a/lib/active_merchant/billing/gateways/sage_pay.rb b/lib/active_merchant/billing/gateways/sage_pay.rb
index 81506b77007..591b3c6a43d 100644
--- a/lib/active_merchant/billing/gateways/sage_pay.rb
+++ b/lib/active_merchant/billing/gateways/sage_pay.rb
@@ -349,10 +349,10 @@ def commit(action, parameters)
:test => test?,
:authorization => authorization_from(response, parameters, action),
:avs_result => {
- :street_match => AVS_CODE[ response['AddressResult'] ],
- :postal_match => AVS_CODE[ response['PostCodeResult'] ],
+ :street_match => AVS_CODE[response['AddressResult']],
+ :postal_match => AVS_CODE[response['PostCodeResult']],
},
- :cvv_result => CVV_CODE[ response['CV2Result'] ]
+ :cvv_result => CVV_CODE[response['CV2Result']]
)
end
diff --git a/lib/active_merchant/billing/gateways/secure_pay.rb b/lib/active_merchant/billing/gateways/secure_pay.rb
index 656e360940c..4cd0c8a63d3 100644
--- a/lib/active_merchant/billing/gateways/secure_pay.rb
+++ b/lib/active_merchant/billing/gateways/secure_pay.rb
@@ -183,9 +183,9 @@ def add_address(post, options)
def message_from(results)
if results[:response_code] == DECLINED
- return CVVResult.messages[ results[:card_code] ] if CARD_CODE_ERRORS.include?(results[:card_code])
+ return CVVResult.messages[results[:card_code]] if CARD_CODE_ERRORS.include?(results[:card_code])
if AVS_REASON_CODES.include?(results[:response_reason_code]) && AVS_ERRORS.include?(results[:avs_result_code])
- return AVSResult.messages[ results[:avs_result_code] ]
+ return AVSResult.messages[results[:avs_result_code]]
end
end
diff --git a/lib/active_merchant/billing/gateways/transact_pro.rb b/lib/active_merchant/billing/gateways/transact_pro.rb
index 5855527bfc0..6029f837afb 100644
--- a/lib/active_merchant/billing/gateways/transact_pro.rb
+++ b/lib/active_merchant/billing/gateways/transact_pro.rb
@@ -174,7 +174,7 @@ def parse(body)
{ status: 'success', id: m[2] } :
{ status: 'failure', message: m[2] }
else
- Hash[ status: body ]
+ Hash[status: body]
end
end
diff --git a/test/remote/gateways/remote_wirecard_test.rb b/test/remote/gateways/remote_wirecard_test.rb
index b58b05ee05b..586e1567351 100644
--- a/test/remote/gateways/remote_wirecard_test.rb
+++ b/test/remote/gateways/remote_wirecard_test.rb
@@ -214,7 +214,7 @@ def test_wrong_creditcard_purchase
assert response = @gateway.purchase(@amount, @declined_card, @options)
assert response.test?
assert_failure response
- assert response.message[ /Credit card number not allowed in demo mode/ ], 'Got wrong response message'
+ assert response.message[/Credit card number not allowed in demo mode/], 'Got wrong response message'
assert_equal '24997', response.params['ErrorCode']
end
@@ -222,7 +222,7 @@ def test_wrong_creditcard_store
assert response = @gateway.store(@declined_card, @options)
assert response.test?
assert_failure response
- assert response.message[ /Credit card number not allowed in demo mode/ ], 'Got wrong response message'
+ assert response.message[/Credit card number not allowed in demo mode/], 'Got wrong response message'
end
def test_unauthorized_capture
From 4a7f7ddaa0751e1dfec8822c2bbbcad990630fb7 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Fri, 2 Nov 2018 15:45:00 -0400
Subject: [PATCH 0154/2234] RuboCop: fix Performance/InefficientHashSearch
---
.rubocop_todo.yml | 10 ----------
.../billing/gateways/usa_epay_advanced.rb | 2 +-
test/unit/gateways/payscout_test.rb | 18 +++++++++---------
3 files changed, 10 insertions(+), 20 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index b13c458f006..5d019a72cf0 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -414,16 +414,6 @@ Performance/CompareWithBlock:
Exclude:
- 'lib/active_merchant/billing/gateways/skip_jack.rb'
-# Offense count: 13
-# Cop supports --auto-correct.
-Performance/InefficientHashSearch:
- Exclude:
- - 'lib/active_merchant/billing/credit_card.rb'
- - 'lib/active_merchant/billing/gateways/inspire.rb'
- - 'lib/active_merchant/billing/gateways/smart_ps.rb'
- - 'lib/active_merchant/billing/gateways/usa_epay_advanced.rb'
- - 'test/unit/gateways/payscout_test.rb'
-
# Offense count: 8
# Cop supports --auto-correct.
Performance/RangeInclude:
diff --git a/lib/active_merchant/billing/gateways/usa_epay_advanced.rb b/lib/active_merchant/billing/gateways/usa_epay_advanced.rb
index a34d269abb6..803fce7532e 100644
--- a/lib/active_merchant/billing/gateways/usa_epay_advanced.rb
+++ b/lib/active_merchant/billing/gateways/usa_epay_advanced.rb
@@ -1503,7 +1503,7 @@ def build_shipping_address(soap, options)
def build_field_value_array(soap, tag_name, type, custom_data, fields)
soap.tag! tag_name, 'SOAP-ENC:arryType' => "xsd:#{type}[#{options.length}]", 'xsi:type' => "ns1:#{type}Array" do
custom_data.each do |k, v|
- build_field_value soap, fields[k][1], v, fields[k][0] if fields.keys.include? k
+ build_field_value soap, fields[k][1], v, fields[k][0] if fields.key?(k)
end
end
end
diff --git a/test/unit/gateways/payscout_test.rb b/test/unit/gateways/payscout_test.rb
index fcf69767329..f5cb64b3a3f 100644
--- a/test/unit/gateways/payscout_test.rb
+++ b/test/unit/gateways/payscout_test.rb
@@ -259,15 +259,15 @@ def test_add_creditcard
def test_parse
data = @gateway.send(:parse, approved_authorization_response)
- assert data.keys.include?('response')
- assert data.keys.include?('responsetext')
- assert data.keys.include?('authcode')
- assert data.keys.include?('transactionid')
- assert data.keys.include?('avsresponse')
- assert data.keys.include?('cvvresponse')
- assert data.keys.include?('orderid')
- assert data.keys.include?('type')
- assert data.keys.include?('response_code')
+ assert data.key?('response')
+ assert data.key?('responsetext')
+ assert data.key?('authcode')
+ assert data.key?('transactionid')
+ assert data.key?('avsresponse')
+ assert data.key?('cvvresponse')
+ assert data.key?('orderid')
+ assert data.key?('type')
+ assert data.key?('response_code')
assert_equal '1', data['response']
assert_equal 'SUCCESS', data['responsetext']
From affa88530639dfe3d2e81bdfa1f2084671d6c679 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Fri, 2 Nov 2018 15:46:54 -0400
Subject: [PATCH 0155/2234] RuboCop: fix Performance/ReverseEach
---
.rubocop_todo.yml | 6 ------
lib/active_merchant/billing/gateways/trust_commerce.rb | 2 +-
2 files changed, 1 insertion(+), 7 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 5d019a72cf0..436868e009a 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -445,12 +445,6 @@ Performance/RedundantMatch:
Performance/RedundantMerge:
Enabled: false
-# Offense count: 1
-# Cop supports --auto-correct.
-Performance/ReverseEach:
- Exclude:
- - 'lib/active_merchant/billing/gateways/trust_commerce.rb'
-
# Offense count: 12
# Cop supports --auto-correct.
Performance/StringReplacement:
diff --git a/lib/active_merchant/billing/gateways/trust_commerce.rb b/lib/active_merchant/billing/gateways/trust_commerce.rb
index 7fab693c69e..19bf5d122ad 100644
--- a/lib/active_merchant/billing/gateways/trust_commerce.rb
+++ b/lib/active_merchant/billing/gateways/trust_commerce.rb
@@ -362,7 +362,7 @@ def clean_and_stringify_params(parameters)
# TCLink wants us to send a hash with string keys, and activemerchant pushes everything around with
# symbol keys. Before sending our input to TCLink, we convert all our keys to strings and dump the symbol keys.
# We also remove any pairs with nil values, as these confuse TCLink.
- parameters.keys.reverse.each do |key|
+ parameters.keys.reverse_each do |key|
if parameters[key]
parameters[key.to_s] = parameters[key]
end
From 2960fcf47668012af8c200f7b3b09dd57b4bab13 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Fri, 2 Nov 2018 15:48:05 -0400
Subject: [PATCH 0156/2234] RuboCop: fix Performance/CompareWithBlock
---
.rubocop_todo.yml | 6 ------
lib/active_merchant/billing/gateways/skip_jack.rb | 2 +-
2 files changed, 1 insertion(+), 7 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 436868e009a..0fd6882efd2 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -408,12 +408,6 @@ Performance/Casecmp:
- 'lib/active_merchant/billing/gateways/redsys.rb'
- 'lib/active_merchant/country.rb'
-# Offense count: 1
-# Cop supports --auto-correct.
-Performance/CompareWithBlock:
- Exclude:
- - 'lib/active_merchant/billing/gateways/skip_jack.rb'
-
# Offense count: 8
# Cop supports --auto-correct.
Performance/RangeInclude:
diff --git a/lib/active_merchant/billing/gateways/skip_jack.rb b/lib/active_merchant/billing/gateways/skip_jack.rb
index 5e5b8a91534..adbbd32f0dc 100644
--- a/lib/active_merchant/billing/gateways/skip_jack.rb
+++ b/lib/active_merchant/billing/gateways/skip_jack.rb
@@ -353,7 +353,7 @@ def parse_status_response(body, response_keys)
def post_data(action, money, params = {})
add_credentials(params, action)
add_amount(params, action, money)
- sorted_params = params.to_a.sort{|a,b| a.to_s <=> b.to_s}.reverse
+ sorted_params = params.to_a.sort_by(&:to_s).reverse
sorted_params.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
end
From e58d67036447ca5dc8ae5f2e3767fd929e06580a Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Fri, 2 Nov 2018 15:50:37 -0400
Subject: [PATCH 0157/2234] RuboCop: fix Performance/RedundantBlockCall
---
.rubocop_todo.yml | 6 ------
test/unit/gateways/nab_transact_test.rb | 2 +-
2 files changed, 1 insertion(+), 7 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 0fd6882efd2..07c068687e3 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -420,12 +420,6 @@ Performance/RangeInclude:
- 'lib/active_merchant/billing/gateways/moneris.rb'
- 'lib/active_merchant/billing/gateways/moneris_us.rb'
-# Offense count: 1
-# Cop supports --auto-correct.
-Performance/RedundantBlockCall:
- Exclude:
- - 'test/unit/gateways/nab_transact_test.rb'
-
# Offense count: 4
# Cop supports --auto-correct.
Performance/RedundantMatch:
diff --git a/test/unit/gateways/nab_transact_test.rb b/test/unit/gateways/nab_transact_test.rb
index 3e7dca2eedb..d6a0af00347 100644
--- a/test/unit/gateways/nab_transact_test.rb
+++ b/test/unit/gateways/nab_transact_test.rb
@@ -229,7 +229,7 @@ def valid_metadata(name, location)
def assert_metadata(name, location, &block)
stub_comms(@gateway, :ssl_request) do
- block.call
+ yield
end.check_request do |method, endpoint, data, headers|
metadata_matcher = Regexp.escape(valid_metadata(name, location))
assert_match %r{#{metadata_matcher}}, data
From 7cf9934d925eaa23dafbbcd3cd6fbaff012f578e Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Fri, 2 Nov 2018 15:52:27 -0400
Subject: [PATCH 0158/2234] RuboCop: fix Performance/RangeInclude
---
.rubocop_todo.yml | 12 ------------
lib/active_merchant/billing/check.rb | 2 +-
lib/active_merchant/billing/credit_card_methods.rb | 4 ++--
lib/active_merchant/billing/gateways/blue_pay.rb | 2 +-
lib/active_merchant/billing/gateways/blue_snap.rb | 2 +-
lib/active_merchant/billing/gateways/cashnet.rb | 2 +-
lib/active_merchant/billing/gateways/moneris.rb | 2 +-
lib/active_merchant/billing/gateways/moneris_us.rb | 2 +-
8 files changed, 8 insertions(+), 20 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 07c068687e3..f6413bda303 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -408,18 +408,6 @@ Performance/Casecmp:
- 'lib/active_merchant/billing/gateways/redsys.rb'
- 'lib/active_merchant/country.rb'
-# Offense count: 8
-# Cop supports --auto-correct.
-Performance/RangeInclude:
- Exclude:
- - 'lib/active_merchant/billing/check.rb'
- - 'lib/active_merchant/billing/credit_card_methods.rb'
- - 'lib/active_merchant/billing/gateways/blue_pay.rb'
- - 'lib/active_merchant/billing/gateways/blue_snap.rb'
- - 'lib/active_merchant/billing/gateways/cashnet.rb'
- - 'lib/active_merchant/billing/gateways/moneris.rb'
- - 'lib/active_merchant/billing/gateways/moneris_us.rb'
-
# Offense count: 4
# Cop supports --auto-correct.
Performance/RedundantMatch:
diff --git a/lib/active_merchant/billing/check.rb b/lib/active_merchant/billing/check.rb
index 9d73819560a..0653848f3f5 100644
--- a/lib/active_merchant/billing/check.rb
+++ b/lib/active_merchant/billing/check.rb
@@ -59,7 +59,7 @@ def credit_card?
# (3(d1 + d4 + d7) + 7(d2 + d5 + d8) + 1(d3 + d6 + d9))mod 10 = 0
# See http://en.wikipedia.org/wiki/Routing_transit_number#Internal_checksums
def valid_routing_number?
- digits = routing_number.to_s.split('').map(&:to_i).select{|d| (0..9).include?(d)}
+ digits = routing_number.to_s.split('').map(&:to_i).select{|d| (0..9).cover?(d)}
case digits.size
when 9
checksum = ((3 * (digits[0] + digits[3] + digits[6])) +
diff --git a/lib/active_merchant/billing/credit_card_methods.rb b/lib/active_merchant/billing/credit_card_methods.rb
index 1d79d9a2e1c..67c80f5e5b1 100644
--- a/lib/active_merchant/billing/credit_card_methods.rb
+++ b/lib/active_merchant/billing/credit_card_methods.rb
@@ -10,7 +10,7 @@ module CreditCardMethods
'diners_club' => ->(num) { num =~ /^3(0[0-5]|[68]\d)\d{11}$/ },
'jcb' => ->(num) { num =~ /^35(28|29|[3-8]\d)\d{12}$/ },
'dankort' => ->(num) { num =~ /^5019\d{12}$/ },
- 'maestro' => ->(num) { (12..19).include?(num&.size) && in_bin_range?(num.slice(0, 6), MAESTRO_RANGES) },
+ 'maestro' => ->(num) { (12..19).cover?(num&.size) && in_bin_range?(num.slice(0, 6), MAESTRO_RANGES) },
'forbrugsforeningen' => ->(num) { num =~ /^600722\d{10}$/ },
'sodexo' => ->(num) { num =~ /^(606071|603389|606070|606069|606068|600818)\d{8}$/ },
'vr' => ->(num) { num =~ /^(627416|637036)\d{8}$/ },
@@ -86,7 +86,7 @@ def credit_card?
end
def valid_expiry_year?(year)
- (Time.now.year..Time.now.year + 20).include?(year.to_i)
+ (Time.now.year..Time.now.year + 20).cover?(year.to_i)
end
def valid_start_year?(year)
diff --git a/lib/active_merchant/billing/gateways/blue_pay.rb b/lib/active_merchant/billing/gateways/blue_pay.rb
index c9cf54e23ff..988c2f1e946 100644
--- a/lib/active_merchant/billing/gateways/blue_pay.rb
+++ b/lib/active_merchant/billing/gateways/blue_pay.rb
@@ -510,7 +510,7 @@ def calc_rebill_tps(post)
end
def handle_response(response)
- if ignore_http_status || (200...300).include?(response.code.to_i)
+ if ignore_http_status || (200...300).cover?(response.code.to_i)
return response.body
end
raise ResponseError.new(response)
diff --git a/lib/active_merchant/billing/gateways/blue_snap.rb b/lib/active_merchant/billing/gateways/blue_snap.rb
index 240a90c5a49..aaeaee85478 100644
--- a/lib/active_merchant/billing/gateways/blue_snap.rb
+++ b/lib/active_merchant/billing/gateways/blue_snap.rb
@@ -279,7 +279,7 @@ def avs_lookup_key(p)
end
def success_from(action, response)
- (200...300).include?(response.code.to_i)
+ (200...300).cover?(response.code.to_i)
end
def message_from(succeeded, parsed_response)
diff --git a/lib/active_merchant/billing/gateways/cashnet.rb b/lib/active_merchant/billing/gateways/cashnet.rb
index 9632d273383..db28d9de497 100644
--- a/lib/active_merchant/billing/gateways/cashnet.rb
+++ b/lib/active_merchant/billing/gateways/cashnet.rb
@@ -140,7 +140,7 @@ def parse(body)
end
def handle_response(response)
- if (200...300).include?(response.code.to_i)
+ if (200...300).cover?(response.code.to_i)
return response.body
elsif response.code.to_i == 302
return ssl_get(URI.parse(response['location']))
diff --git a/lib/active_merchant/billing/gateways/moneris.rb b/lib/active_merchant/billing/gateways/moneris.rb
index 2a632811ed5..bf8533c78fc 100644
--- a/lib/active_merchant/billing/gateways/moneris.rb
+++ b/lib/active_merchant/billing/gateways/moneris.rb
@@ -244,7 +244,7 @@ def authorization_from(response = {})
def successful?(response)
response[:response_code] &&
response[:complete] &&
- (0..49).include?(response[:response_code].to_i)
+ (0..49).cover?(response[:response_code].to_i)
end
def parse(xml)
diff --git a/lib/active_merchant/billing/gateways/moneris_us.rb b/lib/active_merchant/billing/gateways/moneris_us.rb
index dd625fe0a96..9fc3f5b55c4 100644
--- a/lib/active_merchant/billing/gateways/moneris_us.rb
+++ b/lib/active_merchant/billing/gateways/moneris_us.rb
@@ -239,7 +239,7 @@ def authorization_from(response = {})
def successful?(response)
response[:response_code] &&
response[:complete] &&
- (0..49).include?(response[:response_code].to_i)
+ (0..49).cover?(response[:response_code].to_i)
end
def parse(xml)
From 969a232142cdee58554db7805bd3b7f4a20cab88 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Fri, 2 Nov 2018 15:54:42 -0400
Subject: [PATCH 0159/2234] RuboCop: fix Performance/Casecmp
---
.rubocop_todo.yml | 11 -----------
lib/active_merchant/billing/gateways/ebanx.rb | 2 +-
lib/active_merchant/billing/gateways/eway_managed.rb | 2 +-
lib/active_merchant/billing/gateways/itransact.rb | 2 +-
lib/active_merchant/billing/gateways/paystation.rb | 2 +-
lib/active_merchant/billing/gateways/redsys.rb | 2 +-
lib/active_merchant/country.rb | 2 +-
7 files changed, 6 insertions(+), 17 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index f6413bda303..94529205619 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -397,17 +397,6 @@ Naming/VariableNumber:
- 'test/unit/gateways/orbital_test.rb'
- 'test/unit/gateways/paypal/paypal_common_api_test.rb'
-# Offense count: 6
-# Cop supports --auto-correct.
-Performance/Casecmp:
- Exclude:
- - 'lib/active_merchant/billing/gateways/ebanx.rb'
- - 'lib/active_merchant/billing/gateways/eway_managed.rb'
- - 'lib/active_merchant/billing/gateways/itransact.rb'
- - 'lib/active_merchant/billing/gateways/paystation.rb'
- - 'lib/active_merchant/billing/gateways/redsys.rb'
- - 'lib/active_merchant/country.rb'
-
# Offense count: 4
# Cop supports --auto-correct.
Performance/RedundantMatch:
diff --git a/lib/active_merchant/billing/gateways/ebanx.rb b/lib/active_merchant/billing/gateways/ebanx.rb
index d22affa971f..b7d1dc15171 100644
--- a/lib/active_merchant/billing/gateways/ebanx.rb
+++ b/lib/active_merchant/billing/gateways/ebanx.rb
@@ -147,7 +147,7 @@ def add_customer_data(post, payment, options)
def add_customer_responsible_person(post, payment, options)
post[:payment][:person_type] = options[:person_type] if options[:person_type]
- if options[:person_type] && options[:person_type].downcase == 'business'
+ if options[:person_type]&.casecmp('business')&.zero?
post[:payment][:responsible] = {}
post[:payment][:responsible][:name] = options[:responsible_name] if options[:responsible_name]
post[:payment][:responsible][:document] = options[:responsible_document] if options[:responsible_document]
diff --git a/lib/active_merchant/billing/gateways/eway_managed.rb b/lib/active_merchant/billing/gateways/eway_managed.rb
index 85616ed0b74..780f5c55481 100644
--- a/lib/active_merchant/billing/gateways/eway_managed.rb
+++ b/lib/active_merchant/billing/gateways/eway_managed.rb
@@ -165,7 +165,7 @@ def parse(body)
reply[:success]=true
else
if root = REXML::XPath.first(xml, '//UpdateCustomerResult') then
- if root.text.downcase == 'true' then
+ if root.text.casecmp('true').zero? then
reply[:message]='OK'
reply[:success]=true
else
diff --git a/lib/active_merchant/billing/gateways/itransact.rb b/lib/active_merchant/billing/gateways/itransact.rb
index b0329417f44..e76919e4b8f 100644
--- a/lib/active_merchant/billing/gateways/itransact.rb
+++ b/lib/active_merchant/billing/gateways/itransact.rb
@@ -424,7 +424,7 @@ def parse(raw_xml)
def successful?(response)
# Turns out the PaymentClearing gateway is not consistent...
- response[:status].downcase =='ok'
+ response[:status].casecmp('ok').zero?
end
def test_mode?(response)
diff --git a/lib/active_merchant/billing/gateways/paystation.rb b/lib/active_merchant/billing/gateways/paystation.rb
index 44d64dce8ae..69a6f8c8b95 100644
--- a/lib/active_merchant/billing/gateways/paystation.rb
+++ b/lib/active_merchant/billing/gateways/paystation.rb
@@ -179,7 +179,7 @@ def commit(post)
message = message_from(response)
PaystationResponse.new(success?(response), message, response,
- :test => (response[:tm] && response[:tm].downcase == 't'),
+ :test => (response[:tm]&.casecmp('t')&.zero?),
:authorization => response[:paystation_transaction_id]
)
end
diff --git a/lib/active_merchant/billing/gateways/redsys.rb b/lib/active_merchant/billing/gateways/redsys.rb
index 237ce51b2ce..792b935d557 100644
--- a/lib/active_merchant/billing/gateways/redsys.rb
+++ b/lib/active_merchant/billing/gateways/redsys.rb
@@ -432,7 +432,7 @@ def parse(data)
def validate_signature(data)
if sha256_authentication?
sig = Base64.strict_encode64(mac256(get_key(data[:ds_order].to_s), xml_signed_fields(data)))
- sig.upcase == data[:ds_signature].to_s.upcase
+ sig.casecmp(data[:ds_signature].to_s).zero?
else
str = data[:ds_amount] +
data[:ds_order].to_s +
diff --git a/lib/active_merchant/country.rb b/lib/active_merchant/country.rb
index 82c333fef74..996647a975a 100644
--- a/lib/active_merchant/country.rb
+++ b/lib/active_merchant/country.rb
@@ -326,7 +326,7 @@ def self.find(name)
country_code = CountryCode.new(name)
country = COUNTRIES.detect{|c| c[country_code.format] == upcase_name }
else
- country = COUNTRIES.detect{|c| c[:name].upcase == name.upcase }
+ country = COUNTRIES.detect{|c| c[:name].casecmp(name).zero? }
end
raise InvalidCountryCodeError, "No country could be found for the country #{name}" if country.nil?
Country.new(country.dup)
From 20ddb42be9c0cfc79cc6e08abd5f2084184390ca Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Fri, 2 Nov 2018 15:57:09 -0400
Subject: [PATCH 0160/2234] RuboCop: fix Performance/Casecmp
---
.rubocop_todo.yml | 6 ------
.../billing/gateways/authorize_net_cim.rb | 2 +-
lib/active_merchant/billing/gateways/beanstream.rb | 3 ++-
.../billing/gateways/braintree_blue.rb | 6 +++---
lib/active_merchant/billing/gateways/digitzs.rb | 6 +++---
lib/active_merchant/billing/gateways/element.rb | 4 ++--
.../billing/gateways/global_collect.rb | 2 +-
lib/active_merchant/billing/gateways/iridium.rb | 4 ++--
.../billing/gateways/mercado_pago.rb | 10 +++++-----
.../billing/gateways/merchant_one.rb | 4 ++--
.../billing/gateways/merchant_warrior.rb | 2 +-
lib/active_merchant/billing/gateways/migs.rb | 6 ++----
lib/active_merchant/billing/gateways/netbanx.rb | 2 +-
lib/active_merchant/billing/gateways/ogone.rb | 2 +-
lib/active_merchant/billing/gateways/orbital.rb | 10 ++++++----
.../billing/gateways/pay_gate_xml.rb | 9 ++++++---
.../billing/gateways/payflow/payflow_common_api.rb | 2 +-
lib/active_merchant/billing/gateways/payway.rb | 2 +-
lib/active_merchant/billing/gateways/stripe.rb | 8 ++++----
.../billing/gateways/usa_epay_advanced.rb | 4 ++--
lib/active_merchant/billing/gateways/worldpay.rb | 4 ++--
test/remote/gateways/remote_card_save_test.rb | 2 +-
test/remote/gateways/remote_eway_rapid_test.rb | 2 +-
test/remote/gateways/remote_linkpoint_test.rb | 11 +++++------
.../remote/gateways/remote_optimal_payment_test.rb | 2 +-
test/remote/gateways/remote_orbital_test.rb | 4 ++--
test/remote/gateways/remote_pro_pay_test.rb | 2 +-
.../gateways/remote_usa_epay_advanced_test.rb | 2 +-
test/remote/gateways/remote_worldpay_test.rb | 4 ++--
test/unit/gateways/credorax_test.rb | 2 +-
test/unit/gateways/mundipagg_test.rb | 2 +-
test/unit/gateways/stripe_test.rb | 14 +++++++-------
test/unit/gateways/usa_epay_advanced_test.rb | 2 +-
33 files changed, 72 insertions(+), 75 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 94529205619..689e4e01296 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -404,12 +404,6 @@ Performance/RedundantMatch:
- 'lib/active_merchant/billing/gateways/opp.rb'
- 'test/unit/gateways/payu_latam_test.rb'
-# Offense count: 59
-# Cop supports --auto-correct.
-# Configuration parameters: MaxKeyValuePairs.
-Performance/RedundantMerge:
- Enabled: false
-
# Offense count: 12
# Cop supports --auto-correct.
Performance/StringReplacement:
diff --git a/lib/active_merchant/billing/gateways/authorize_net_cim.rb b/lib/active_merchant/billing/gateways/authorize_net_cim.rb
index af7c4a769b1..f57e1397af3 100644
--- a/lib/active_merchant/billing/gateways/authorize_net_cim.rb
+++ b/lib/active_merchant/billing/gateways/authorize_net_cim.rb
@@ -614,7 +614,7 @@ def build_update_customer_shipping_address_request(xml, options)
def build_create_customer_profile_transaction_request(xml, options)
options[:extra_options] ||= {}
- options[:extra_options].merge!('x_delim_char' => @options[:delimiter]) if @options[:delimiter]
+ options[:extra_options]['x_delim_char'] = @options[:delimiter] if @options[:delimiter]
add_transaction(xml, options[:transaction])
xml.tag!('extraOptions') do
diff --git a/lib/active_merchant/billing/gateways/beanstream.rb b/lib/active_merchant/billing/gateways/beanstream.rb
index 0c1b42ed7b4..6947992934d 100644
--- a/lib/active_merchant/billing/gateways/beanstream.rb
+++ b/lib/active_merchant/billing/gateways/beanstream.rb
@@ -186,7 +186,8 @@ def update(vault_id, payment_method, options = {})
else
post[:singleUseToken] = payment_method
end
- options.merge!({:vault_id => vault_id, :operation => secure_profile_action(:modify)})
+ options[:vault_id] = vault_id
+ options[:operation] = secure_profile_action(:modify)
add_secure_profile_variables(post,options)
commit(post, true)
end
diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb
index 5f0c0f30542..fdd5111fa8a 100644
--- a/lib/active_merchant/billing/gateways/braintree_blue.rb
+++ b/lib/active_merchant/billing/gateways/braintree_blue.rb
@@ -143,7 +143,7 @@ def update(vault_id, creditcard, options = {})
braintree_credit_card = @braintree_gateway.customer.find(vault_id).credit_cards.detect(&:default?)
return Response.new(false, 'Braintree::NotFoundError') if braintree_credit_card.nil?
- options.merge!(:update_existing_token => braintree_credit_card.token)
+ options[:update_existing_token] = braintree_credit_card.token
credit_card_params = merge_credit_card_options({
:credit_card => {
:cardholder_name => creditcard.name,
@@ -303,7 +303,7 @@ def merge_credit_card_options(parameters, options)
end
parameters[:credit_card] ||= {}
- parameters[:credit_card].merge!(:options => valid_options)
+ parameters[:credit_card][:options] = valid_options
address = options[:billing_address]&.except(:phone)
return parameters if address.nil? || address.values.compact.empty?
parameters[:credit_card][:billing_address] = map_address(address)
@@ -569,7 +569,7 @@ def create_transaction_parameters(money, credit_card_or_vault_id, options)
}
if options[:skip_advanced_fraud_checking]
- parameters[:options].merge!({ :skip_advanced_fraud_checking => options[:skip_advanced_fraud_checking] })
+ parameters[:options][:skip_advanced_fraud_checking] = options[:skip_advanced_fraud_checking]
end
parameters[:custom_fields] = options[:custom_fields]
diff --git a/lib/active_merchant/billing/gateways/digitzs.rb b/lib/active_merchant/billing/gateways/digitzs.rb
index b8b7d96fcb5..1dff6179965 100644
--- a/lib/active_merchant/billing/gateways/digitzs.rb
+++ b/lib/active_merchant/billing/gateways/digitzs.rb
@@ -36,7 +36,7 @@ def refund(money, authorization, options={})
def store(payment, options = {})
MultiResponse.run do |r|
r.process { commit('auth/token', app_token_request(options)) }
- options.merge!({ app_token: app_token_from(r) })
+ options[:app_token] = app_token_from(r)
if options[:customer_id].present?
customer_id = check_customer_exists(options)
@@ -197,7 +197,7 @@ def add_credit_card_to_customer(payment, options = {})
def add_customer_with_credit_card(payment, options = {})
customer_response = commit('customers', create_customer_request(payment, options), options)
- options.merge!({customer_id: customer_response.authorization})
+ options[:customer_id] = customer_response.authorization
commit('tokens', create_token_request(payment, options), options)
end
@@ -257,7 +257,7 @@ def headers(options)
'x-api-key' => @options[:api_key]
}
- headers.merge!({'Authorization' => "Bearer #{options[:app_token]}"}) if options[:app_token]
+ headers['Authorization'] = "Bearer #{options[:app_token]}" if options[:app_token]
headers
end
diff --git a/lib/active_merchant/billing/gateways/element.rb b/lib/active_merchant/billing/gateways/element.rb
index 419fdd6e843..a82803884ba 100644
--- a/lib/active_merchant/billing/gateways/element.rb
+++ b/lib/active_merchant/billing/gateways/element.rb
@@ -54,7 +54,7 @@ def authorize(money, payment, options={})
def capture(money, authorization, options={})
trans_id, _ = split_authorization(authorization)
- options.merge!({trans_id: trans_id})
+ options[:trans_id] = trans_id
request = build_soap_request do |xml|
xml.CreditCardAuthorizationCompletion(xmlns: 'https://transaction.elementexpress.com') do
@@ -69,7 +69,7 @@ def capture(money, authorization, options={})
def refund(money, authorization, options={})
trans_id, _ = split_authorization(authorization)
- options.merge!({trans_id: trans_id})
+ options[:trans_id] = trans_id
request = build_soap_request do |xml|
xml.CreditCardReturn(xmlns: 'https://transaction.elementexpress.com') do
diff --git a/lib/active_merchant/billing/gateways/global_collect.rb b/lib/active_merchant/billing/gateways/global_collect.rb
index 659804cd3fd..a96cbb12d42 100644
--- a/lib/active_merchant/billing/gateways/global_collect.rb
+++ b/lib/active_merchant/billing/gateways/global_collect.rb
@@ -200,7 +200,7 @@ def add_address(post, creditcard, options)
def add_fraud_fields(post, options)
fraud_fields = {}
fraud_fields.merge!(options[:fraud_fields]) if options[:fraud_fields]
- fraud_fields.merge!({customerIpAddress: options[:ip]}) if options[:ip]
+ fraud_fields[:customerIpAddress] = options[:ip] if options[:ip]
post['fraudFields'] = fraud_fields unless fraud_fields.empty?
end
diff --git a/lib/active_merchant/billing/gateways/iridium.rb b/lib/active_merchant/billing/gateways/iridium.rb
index 3723f287e43..65024f293aa 100644
--- a/lib/active_merchant/billing/gateways/iridium.rb
+++ b/lib/active_merchant/billing/gateways/iridium.rb
@@ -278,7 +278,7 @@ def scrub(transcript)
private
def build_purchase_request(type, money, creditcard, options)
- options.merge!(:action => 'CardDetailsTransaction')
+ options[:action] = 'CardDetailsTransaction'
build_request(options) do |xml|
add_purchase_data(xml, type, money, options)
add_creditcard(xml, creditcard)
@@ -287,7 +287,7 @@ def build_purchase_request(type, money, creditcard, options)
end
def build_reference_request(type, money, authorization, options)
- options.merge!(:action => 'CrossReferenceTransaction')
+ options[:action] = 'CrossReferenceTransaction'
order_id, cross_reference, _ = authorization.split(';')
build_request(options) do |xml|
if money
diff --git a/lib/active_merchant/billing/gateways/mercado_pago.rb b/lib/active_merchant/billing/gateways/mercado_pago.rb
index 3c841fccc53..900f2ceb361 100644
--- a/lib/active_merchant/billing/gateways/mercado_pago.rb
+++ b/lib/active_merchant/billing/gateways/mercado_pago.rb
@@ -23,8 +23,8 @@ def initialize(options={})
def purchase(money, payment, options={})
MultiResponse.run do |r|
r.process { commit('tokenize', 'card_tokens', card_token_request(money, payment, options)) }
- options.merge!(card_brand: (CARD_BRAND[payment.brand] || payment.brand))
- options.merge!(card_token: r.authorization.split('|').first)
+ options[:card_brand] = (CARD_BRAND[payment.brand] || payment.brand)
+ options[:card_token] = r.authorization.split('|').first
r.process { commit('purchase', 'payments', purchase_request(money, payment, options) ) }
end
end
@@ -32,8 +32,8 @@ def purchase(money, payment, options={})
def authorize(money, payment, options={})
MultiResponse.run do |r|
r.process { commit('tokenize', 'card_tokens', card_token_request(money, payment, options)) }
- options.merge!(card_brand: (CARD_BRAND[payment.brand] || payment.brand))
- options.merge!(card_token: r.authorization.split('|').first)
+ options[:card_brand] = (CARD_BRAND[payment.brand] || payment.brand)
+ options[:card_token] = r.authorization.split('|').first
r.process { commit('authorize', 'payments', authorize_request(money, payment, options) ) }
end
end
@@ -108,7 +108,7 @@ def purchase_request(money, payment, options = {})
def authorize_request(money, payment, options = {})
post = purchase_request(money, payment, options)
- post.merge!(capture: false)
+ post[:capture] = false
post
end
diff --git a/lib/active_merchant/billing/gateways/merchant_one.rb b/lib/active_merchant/billing/gateways/merchant_one.rb
index a514a9e6107..2352178da07 100644
--- a/lib/active_merchant/billing/gateways/merchant_one.rb
+++ b/lib/active_merchant/billing/gateways/merchant_one.rb
@@ -46,7 +46,7 @@ def purchase(money, creditcard, options = {})
def capture(money, authorization, options = {})
post = {}
- post.merge!(:transactionid => authorization)
+ post[:transactionid] = authorization
add_amount(post, money, options)
commit('capture', money, post)
end
@@ -87,7 +87,7 @@ def commit(action, money, parameters={})
end
def post_data(action, parameters = {})
- parameters.merge!({:type => action})
+ parameters[:type] = action
ret = ''
for key in parameters.keys
ret += "#{key}=#{CGI.escape(parameters[key].to_s)}"
diff --git a/lib/active_merchant/billing/gateways/merchant_warrior.rb b/lib/active_merchant/billing/gateways/merchant_warrior.rb
index 701b44ab049..66da5f62317 100644
--- a/lib/active_merchant/billing/gateways/merchant_warrior.rb
+++ b/lib/active_merchant/billing/gateways/merchant_warrior.rb
@@ -46,7 +46,7 @@ def capture(money, identification, options = {})
post = {}
add_amount(post, money, options)
add_transaction(post, identification)
- post.merge!('captureAmount' => amount(money))
+ post['captureAmount'] = amount(money)
commit('processCapture', post)
end
diff --git a/lib/active_merchant/billing/gateways/migs.rb b/lib/active_merchant/billing/gateways/migs.rb
index 27c13eee3b6..a7bc303d06c 100644
--- a/lib/active_merchant/billing/gateways/migs.rb
+++ b/lib/active_merchant/billing/gateways/migs.rb
@@ -169,10 +169,8 @@ def purchase_offsite_url(money, options = {})
add_invoice(post, options)
add_creditcard_type(post, options[:card_type]) if options[:card_type]
- post.merge!(
- :Locale => options[:locale] || 'en',
- :ReturnURL => options[:return_url]
- )
+ post[:Locale] = options[:locale] || 'en'
+ post[:ReturnURL] = options[:return_url]
add_standard_parameters('pay', post, options[:unique_id])
diff --git a/lib/active_merchant/billing/gateways/netbanx.rb b/lib/active_merchant/billing/gateways/netbanx.rb
index 8afb50bfb66..78f80153ec4 100644
--- a/lib/active_merchant/billing/gateways/netbanx.rb
+++ b/lib/active_merchant/billing/gateways/netbanx.rb
@@ -170,7 +170,7 @@ def map_address(address)
:zip => address[:zip],
:state => address[:state],
}
- mapped.merge!({:country => country.code(:alpha2).value}) unless country.blank?
+ mapped[:country] = country.code(:alpha2).value unless country.blank?
mapped
end
diff --git a/lib/active_merchant/billing/gateways/ogone.rb b/lib/active_merchant/billing/gateways/ogone.rb
index 3805eaf7df9..b0a8be19343 100644
--- a/lib/active_merchant/billing/gateways/ogone.rb
+++ b/lib/active_merchant/billing/gateways/ogone.rb
@@ -213,7 +213,7 @@ def verify(credit_card, options={})
# Store a credit card by creating an Ogone Alias
def store(payment_source, options = {})
- options.merge!(:alias_operation => 'BYPSP') unless(options.has_key?(:billing_id) || options.has_key?(:store))
+ options[:alias_operation] = 'BYPSP' unless(options.has_key?(:billing_id) || options.has_key?(:store))
response = authorize(@options[:store_amount] || 1, payment_source, options)
void(response.authorization) if response.success?
response
diff --git a/lib/active_merchant/billing/gateways/orbital.rb b/lib/active_merchant/billing/gateways/orbital.rb
index 89a5007f85b..c5f9000e4e3 100644
--- a/lib/active_merchant/billing/gateways/orbital.rb
+++ b/lib/active_merchant/billing/gateways/orbital.rb
@@ -273,13 +273,13 @@ def void(authorization, options = {}, deprecated = {})
# 'MS' - Manual Suspend
def add_customer_profile(creditcard, options = {})
- options.merge!(:customer_profile_action => CREATE)
+ options[:customer_profile_action] = CREATE
order = build_customer_request_xml(creditcard, options)
commit(order, :add_customer_profile)
end
def update_customer_profile(creditcard, options = {})
- options.merge!(:customer_profile_action => UPDATE)
+ options[:customer_profile_action] = UPDATE
order = build_customer_request_xml(creditcard, options)
commit(order, :update_customer_profile)
end
@@ -529,8 +529,10 @@ def recurring_parse_element(response, node)
def commit(order, message_type, trace_number=nil)
headers = POST_HEADERS.merge('Content-length' => order.size.to_s)
- headers.merge!( 'Trace-number' => trace_number.to_s,
- 'Merchant-Id' => @options[:merchant_id] ) if @options[:retry_logic] && trace_number
+ if @options[:retry_logic] && trace_number
+ headers['Trace-number'] = trace_number.to_s
+ headers['Merchant-Id'] = @options[:merchant_id]
+ end
request = ->(url){ parse(ssl_post(url, order, headers))}
# Failover URL will be attempted in the event of a connection error
diff --git a/lib/active_merchant/billing/gateways/pay_gate_xml.rb b/lib/active_merchant/billing/gateways/pay_gate_xml.rb
index 572ae9d7066..7c17b1dfa3f 100644
--- a/lib/active_merchant/billing/gateways/pay_gate_xml.rb
+++ b/lib/active_merchant/billing/gateways/pay_gate_xml.rb
@@ -170,21 +170,24 @@ def purchase(money, creditcard, options = {})
def authorize(money, creditcard, options = {})
action = 'authtx'
- options.merge!(:money => money, :creditcard => creditcard)
+ options[:money] = money
+ options[:creditcard] = creditcard
commit(action, build_request(action, options))
end
def capture(money, authorization, options = {})
action = 'settletx'
- options.merge!(:money => money, :authorization => authorization)
+ options[:money] = money
+ options[:authorization] = authorization
commit(action, build_request(action, options), authorization)
end
def refund(money, authorization, options={})
action = 'refundtx'
- options.merge!(:money => money, :authorization => authorization)
+ options[:money] = money
+ options[:authorization] = authorization
commit(action, build_request(action, options))
end
diff --git a/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb b/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb
index 319c56bb64b..b524126ef1e 100644
--- a/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb
+++ b/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb
@@ -202,7 +202,7 @@ def build_headers(content_length)
'X-VPS-Request-ID' => SecureRandom.hex(16)
}
- headers.merge!('PAYPAL-NVP' => 'Y') if self.use_paypal_nvp
+ headers['PAYPAL-NVP'] = 'Y' if self.use_paypal_nvp
headers
end
diff --git a/lib/active_merchant/billing/gateways/payway.rb b/lib/active_merchant/billing/gateways/payway.rb
index b7b40b6c8b0..e8f9d8c163a 100644
--- a/lib/active_merchant/billing/gateways/payway.rb
+++ b/lib/active_merchant/billing/gateways/payway.rb
@@ -177,7 +177,7 @@ def add_auth(post)
# Creates the request and returns the summarized result
def commit(action, post)
add_auth(post)
- post.merge!('order.type' => TRANSACTIONS[action])
+ post['order.type'] = TRANSACTIONS[action]
request = post.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
response = ssl_post(self.live_url, request)
diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb
index 81c2fd982cc..905a370e3c9 100644
--- a/lib/active_merchant/billing/gateways/stripe.rb
+++ b/lib/active_merchant/billing/gateways/stripe.rb
@@ -177,7 +177,7 @@ def refund_application_fee(money, identification, options = {})
post = {}
add_amount(post, money, options)
- options.merge!(:key => @fee_refund_api_key) if @fee_refund_api_key
+ options[:key] = @fee_refund_api_key if @fee_refund_api_key
options.delete(:stripe_account)
refund_fee = commit(:post, "application_fees/#{CGI.escape(identification)}/refunds", post, options)
@@ -491,7 +491,7 @@ def add_emv_metadata(post, creditcard)
end
def fetch_application_fee(identification, options = {})
- options.merge!(:key => @fee_refund_api_key)
+ options[:key] = @fee_refund_api_key
fetch_charge = commit(:get, "charges/#{CGI.escape(identification)}", nil, options)
application_fee_response!(fetch_charge, "Application fee id could not be retrieved: #{fetch_charge.message}")
@@ -549,8 +549,8 @@ def headers(options = {})
'X-Stripe-Client-User-Agent' => stripe_client_user_agent(options),
'X-Stripe-Client-User-Metadata' => {:ip => options[:ip]}.to_json
}
- headers.merge!('Idempotency-Key' => idempotency_key) if idempotency_key
- headers.merge!('Stripe-Account' => options[:stripe_account]) if options[:stripe_account]
+ headers['Idempotency-Key'] = idempotency_key if idempotency_key
+ headers['Stripe-Account'] = options[:stripe_account] if options[:stripe_account]
headers
end
diff --git a/lib/active_merchant/billing/gateways/usa_epay_advanced.rb b/lib/active_merchant/billing/gateways/usa_epay_advanced.rb
index 803fce7532e..90a0adb9f64 100644
--- a/lib/active_merchant/billing/gateways/usa_epay_advanced.rb
+++ b/lib/active_merchant/billing/gateways/usa_epay_advanced.rb
@@ -1538,7 +1538,7 @@ def commit(action, request)
def build_response(action, soap)
response_params, success, message, authorization, avs, cvv = parse(action, soap)
- response_params.merge!('soap_response' => soap) if @options[:soap_response]
+ response_params['soap_response'] = soap if @options[:soap_response]
Response.new(
success,
@@ -1553,7 +1553,7 @@ def build_response(action, soap)
def avs_from(avs)
avs_params = { :code => avs }
- avs_params.merge!(:message => AVS_CUSTOM_MESSAGES[avs]) if AVS_CUSTOM_MESSAGES.key?(avs)
+ avs_params[:message] = AVS_CUSTOM_MESSAGES[avs] if AVS_CUSTOM_MESSAGES.key?(avs)
avs_params
end
diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb
index 7d817e61a9b..bb06b90c88f 100644
--- a/lib/active_merchant/billing/gateways/worldpay.rb
+++ b/lib/active_merchant/billing/gateways/worldpay.rb
@@ -212,7 +212,7 @@ def add_amount(xml, money, options)
}
if options[:debit_credit_indicator]
- amount_hash.merge!('debitCreditIndicator' => options[:debit_credit_indicator])
+ amount_hash['debitCreditIndicator'] = options[:debit_credit_indicator]
end
xml.tag! 'amount', amount_hash
@@ -339,7 +339,7 @@ def headers(options)
'Authorization' => encoded_credentials
}
if options[:cookie]
- headers.merge!('Set-Cookie' => options[:cookie]) if options[:cookie]
+ headers['Set-Cookie'] = options[:cookie] if options[:cookie]
end
headers
end
diff --git a/test/remote/gateways/remote_card_save_test.rb b/test/remote/gateways/remote_card_save_test.rb
index 9fe97a8d251..06ee56d1053 100644
--- a/test/remote/gateways/remote_card_save_test.rb
+++ b/test/remote/gateways/remote_card_save_test.rb
@@ -25,7 +25,7 @@ def test_successful_purchase
end
def test_unsuccessful_purchase
- @options.merge!(:billing_address => @addresses[@declined_card.number])
+ @options[:billing_address] = @addresses[@declined_card.number]
assert response = @gateway.purchase(@amount, @declined_card, @options)
assert_failure response
assert_equal 'Card declined', response.message
diff --git a/test/remote/gateways/remote_eway_rapid_test.rb b/test/remote/gateways/remote_eway_rapid_test.rb
index edf59a27625..f0c33ba61e8 100644
--- a/test/remote/gateways/remote_eway_rapid_test.rb
+++ b/test/remote/gateways/remote_eway_rapid_test.rb
@@ -153,7 +153,7 @@ def test_successful_store
end
def test_failed_store
- @options[:billing_address].merge!(country: nil)
+ @options[:billing_address][:country] = nil
response = @gateway.store(@credit_card, @options)
assert_failure response
assert_equal 'V6044', response.params['Errors']
diff --git a/test/remote/gateways/remote_linkpoint_test.rb b/test/remote/gateways/remote_linkpoint_test.rb
index 722b17d6ef7..1a51911712d 100644
--- a/test/remote/gateways/remote_linkpoint_test.rb
+++ b/test/remote/gateways/remote_linkpoint_test.rb
@@ -90,12 +90,11 @@ def test_successfull_purchase_and_credit
end
def test_successfull_purchase_with_item_entity
- @options.merge!({:line_items =>
- [
- {:id => '123456', :description => 'Logo T-Shirt', :price => '12.00', :quantity => '1',
- :options => [{:name => 'Color', :value => 'Red'}, {:name => 'Size', :value => 'XL'}]},
- {:id => '111', :description => 'keychain', :price => '3.00', :quantity => '1'}
- ]})
+ @options[:line_items] = [
+ {:id => '123456', :description => 'Logo T-Shirt', :price => '12.00', :quantity => '1',
+ :options => [{:name => 'Color', :value => 'Red'}, {:name => 'Size', :value => 'XL'}]},
+ {:id => '111', :description => 'keychain', :price => '3.00', :quantity => '1'}
+ ]
assert purchase = @gateway.purchase(1500, @credit_card, @options)
assert_success purchase
end
diff --git a/test/remote/gateways/remote_optimal_payment_test.rb b/test/remote/gateways/remote_optimal_payment_test.rb
index f42849579d9..58a93dcce78 100644
--- a/test/remote/gateways/remote_optimal_payment_test.rb
+++ b/test/remote/gateways/remote_optimal_payment_test.rb
@@ -24,7 +24,7 @@ def test_successful_purchase
end
def test_unsuccessful_purchase_with_shipping_address
- @options.merge!(:shipping_address => address)
+ @options[:shipping_address] = address
assert response = @gateway.purchase(@amount, @credit_card, @options)
assert_success response
assert_equal 'no_error', response.message
diff --git a/test/remote/gateways/remote_orbital_test.rb b/test/remote/gateways/remote_orbital_test.rb
index 55cdcce9bd0..ccceb0fc5ed 100644
--- a/test/remote/gateways/remote_orbital_test.rb
+++ b/test/remote/gateways/remote_orbital_test.rb
@@ -198,7 +198,7 @@ def test_auth_only_transactions
for suite in @test_suite do
amount = suite[:amount]
card = credit_card(@cards[suite[:card]], :verification_value => suite[:CVD])
- @options[:address].merge!(:zip => suite[:AVSzip])
+ @options[:address][:zip] = suite[:AVSzip]
assert response = @gateway.authorize(amount, card, @options)
assert_kind_of Response, response
@@ -216,7 +216,7 @@ def test_auth_capture_transactions
for suite in @test_suite do
amount = suite[:amount]
card = credit_card(@cards[suite[:card]], :verification_value => suite[:CVD])
- options = @options; options[:address].merge!(:zip => suite[:AVSzip])
+ options = @options; options[:address][:zip] = suite[:AVSzip]
assert response = @gateway.purchase(amount, card, options)
assert_kind_of Response, response
diff --git a/test/remote/gateways/remote_pro_pay_test.rb b/test/remote/gateways/remote_pro_pay_test.rb
index 5a99435ed6b..c447f996862 100644
--- a/test/remote/gateways/remote_pro_pay_test.rb
+++ b/test/remote/gateways/remote_pro_pay_test.rb
@@ -34,7 +34,7 @@ def test_successful_purchase_with_more_options
end
def test_successful_recurring_purchase_without_cvv
- @options.merge!({recurring_payment: 'Y'})
+ @options[:recurring_payment] = 'Y'
response = @gateway.purchase(@amount, @credit_card_without_cvv, @options)
assert_success response
assert_equal 'Success', response.message
diff --git a/test/remote/gateways/remote_usa_epay_advanced_test.rb b/test/remote/gateways/remote_usa_epay_advanced_test.rb
index df133607dda..021f73d910a 100644
--- a/test/remote/gateways/remote_usa_epay_advanced_test.rb
+++ b/test/remote/gateways/remote_usa_epay_advanced_test.rb
@@ -312,7 +312,7 @@ def test_run_check_credit
# TODO get offline auth_code?
def test_post_auth
- @options.merge!(:authorization_code => 123456)
+ @options[:authorization_code] = 123456
response = @gateway.post_auth(@options)
assert response.params['post_auth_return']
end
diff --git a/test/remote/gateways/remote_worldpay_test.rb b/test/remote/gateways/remote_worldpay_test.rb
index fd4f73be9dd..c6f116a15c4 100644
--- a/test/remote/gateways/remote_worldpay_test.rb
+++ b/test/remote/gateways/remote_worldpay_test.rb
@@ -21,11 +21,11 @@ def test_successful_purchase
end
def test_successful_purchase_with_hcg_additional_data
- @options.merge!(hcg_additional_data: {
+ @options[:hcg_additional_data] = {
key1: 'value1',
key2: 'value2',
key3: 'value3'
- })
+ }
assert response = @gateway.purchase(@amount, @credit_card, @options)
assert_success response
diff --git a/test/unit/gateways/credorax_test.rb b/test/unit/gateways/credorax_test.rb
index 8c588c3f108..18eb1d1381d 100644
--- a/test/unit/gateways/credorax_test.rb
+++ b/test/unit/gateways/credorax_test.rb
@@ -215,7 +215,7 @@ def test_adds_a9_field
end
def test_supports_billing_descriptor
- @options.merge!({ billing_descriptor: 'abcdefghijkl'})
+ @options[:billing_descriptor] = 'abcdefghijkl'
stub_comms do
@gateway.purchase(@amount, @credit_card, @options)
end.check_request do |endpoint, data, headers|
diff --git a/test/unit/gateways/mundipagg_test.rb b/test/unit/gateways/mundipagg_test.rb
index 7caa206f0d0..208ddba3a5d 100644
--- a/test/unit/gateways/mundipagg_test.rb
+++ b/test/unit/gateways/mundipagg_test.rb
@@ -25,7 +25,7 @@ def test_successful_purchase
end
def test_successful_purchase_with_holder_document
- @options.merge!(holder_document: 'a1b2c3d4')
+ @options[:holder_document] = 'a1b2c3d4'
response = stub_comms do
@gateway.purchase(@amount, @credit_card, @options)
end.check_request do |endpoint, data, headers|
diff --git a/test/unit/gateways/stripe_test.rb b/test/unit/gateways/stripe_test.rb
index edbafbd49d4..0f66d7985ad 100644
--- a/test/unit/gateways/stripe_test.rb
+++ b/test/unit/gateways/stripe_test.rb
@@ -1197,7 +1197,7 @@ def test_passing_expand_parameters
post.include?('expand[0]=balance_transaction')
end.returns(successful_authorization_response)
- @options.merge!(:expand => :balance_transaction)
+ @options[:expand] = :balance_transaction
@gateway.authorize(@amount, @credit_card, @options)
end
@@ -1207,7 +1207,7 @@ def test_passing_expand_parameters_as_array
post.include?('expand[0]=balance_transaction&expand[1]=customer')
end.returns(successful_authorization_response)
- @options.merge!(:expand => [:balance_transaction, :customer])
+ @options[:expand] = [:balance_transaction, :customer]
@gateway.authorize(@amount, @credit_card, @options)
end
@@ -1225,7 +1225,7 @@ def test_passing_recurring_eci_sets_recurring_flag
post.include?('recurring=true')
end.returns(successful_authorization_response)
- @options.merge!(eci: 'recurring')
+ @options[:eci] = 'recurring'
@gateway.authorize(@amount, @credit_card, @options)
end
@@ -1235,7 +1235,7 @@ def test_passing_unknown_eci_does_not_set_recurring_flag
!post.include?('recurring')
end.returns(successful_authorization_response)
- @options.merge!(eci: 'installment')
+ @options[:eci] = 'installment'
@gateway.authorize(@amount, @credit_card, @options)
end
@@ -1245,7 +1245,7 @@ def test_passing_recurring_true_option_sets_recurring_flag
post.include?('recurring=true')
end.returns(successful_authorization_response)
- @options.merge!(recurring: true)
+ @options[:recurring] = true
@gateway.authorize(@amount, @credit_card, @options)
end
@@ -1255,7 +1255,7 @@ def test_passing_recurring_false_option_does_not_set_recurring_flag
!post.include?('recurring')
end.returns(successful_authorization_response)
- @options.merge!(recurring: false)
+ @options[:recurring] = false
@gateway.authorize(@amount, @credit_card, @options)
end
@@ -1400,7 +1400,7 @@ def test_passing_stripe_account_header
headers.include?('Stripe-Account')
end.returns(successful_authorization_response)
- @options.merge!(stripe_account: fixtures(:stripe_destination)[:stripe_user_id])
+ @options[:stripe_account] = fixtures(:stripe_destination)[:stripe_user_id]
@gateway.purchase(@amount, @credit_card, @options)
end
diff --git a/test/unit/gateways/usa_epay_advanced_test.rb b/test/unit/gateways/usa_epay_advanced_test.rb
index 5f37ec88899..7c22b87d841 100644
--- a/test/unit/gateways/usa_epay_advanced_test.rb
+++ b/test/unit/gateways/usa_epay_advanced_test.rb
@@ -290,7 +290,7 @@ def test_successful_get_customer_payment_methods
end
def test_successful_update_customer_payment_method
- @options.merge!(@payment_options).merge!(:method_id => 1)
+ @options.merge!(@payment_options)[:method_id] = 1
@gateway.expects(:ssl_post).returns(successful_update_customer_payment_method_response)
assert response = @gateway.update_customer_payment_method(@options)
From b7c2aca7ba599bf406797cf403bad8bbdbffe9b0 Mon Sep 17 00:00:00 2001
From: David Perry
Date: Mon, 5 Nov 2018 09:31:06 -0500
Subject: [PATCH 0161/2234] Braintree: Actually account for nil address fields
Phone is not the only field a billing address option may contain that
the gateway doesn't want in the element, so we now instead map fields
first, and then don't add the hash if there are no non-nil fields.
Closes #3032
Remote:
64 tests, 365 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
56 tests, 141 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/braintree_blue.rb | 9 +++++----
test/remote/gateways/remote_braintree_blue_test.rb | 11 +++++++++--
test/unit/gateways/braintree_blue_test.rb | 4 +++-
4 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index d678c59ba95..d225259b878 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -17,6 +17,7 @@
* Litle: Capitalize check account type [curiousepic] #3028
* Braintree: Account for nil billing address fields [curiousepic] #3029
* Realex: Add verify [kheang] #3030
+* Braintree: Actually account for nil address fields [curiousepic] #3032
== Version 1.85.0 (September 28, 2018)
* Authorize.Net: Support custom delimiter for cim [curiousepic] #3001
diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb
index fdd5111fa8a..715f57e0f9b 100644
--- a/lib/active_merchant/billing/gateways/braintree_blue.rb
+++ b/lib/active_merchant/billing/gateways/braintree_blue.rb
@@ -303,10 +303,11 @@ def merge_credit_card_options(parameters, options)
end
parameters[:credit_card] ||= {}
- parameters[:credit_card][:options] = valid_options
- address = options[:billing_address]&.except(:phone)
- return parameters if address.nil? || address.values.compact.empty?
- parameters[:credit_card][:billing_address] = map_address(address)
+ parameters[:credit_card].merge!(:options => valid_options)
+ if options[:billing_address]
+ address = map_address(options[:billing_address])
+ parameters[:credit_card][:billing_address] = address unless address.all? { |_k, v| v.nil? }
+ end
parameters
end
diff --git a/test/remote/gateways/remote_braintree_blue_test.rb b/test/remote/gateways/remote_braintree_blue_test.rb
index ff816acb973..7ae338e81ca 100644
--- a/test/remote/gateways/remote_braintree_blue_test.rb
+++ b/test/remote/gateways/remote_braintree_blue_test.rb
@@ -168,10 +168,17 @@ def test_successful_store_with_billing_address
assert_equal purchase_response.params['braintree_transaction']['billing_details'], response_billing_details
end
- def test_successful_store_with_phone_only_billing_address_option
+ def test_successful_store_with_nil_billing_address_options
billing_address = {
+ :name => 'John Smith',
:phone => '123-456-7890',
- :city => nil
+ :company => nil,
+ :address1 => nil,
+ :address2 => nil,
+ :city => nil,
+ :state => nil,
+ :zip => nil,
+ :country_name => nil
}
credit_card = credit_card('5105105105105100')
assert response = @gateway.store(credit_card, :billing_address => billing_address)
diff --git a/test/unit/gateways/braintree_blue_test.rb b/test/unit/gateways/braintree_blue_test.rb
index 0a604b717f5..21f7e152be5 100644
--- a/test/unit/gateways/braintree_blue_test.rb
+++ b/test/unit/gateways/braintree_blue_test.rb
@@ -373,7 +373,7 @@ def test_store_with_phone_only_billing_address_option
@gateway.store(credit_card('41111111111111111111'), :billing_address => billing_address)
end
- def test_store_with_phone_only_non_nil_billing_address_option
+ def test_store_with_nil_billing_address_options
customer_attributes = {
:credit_cards => [stub_everything],
:email => 'email',
@@ -382,7 +382,9 @@ def test_store_with_phone_only_non_nil_billing_address_option
:phone => '123-456-7890'
}
billing_address = {
+ :name => 'John Smith',
:phone => '123-456-7890',
+ :company => nil,
:address1 => nil,
:address2 => nil,
:city => nil,
From 6ea353a450fd48c1df7c539e698327bd5ac40e0d Mon Sep 17 00:00:00 2001
From: Niaja
Date: Mon, 22 Oct 2018 11:10:06 -0400
Subject: [PATCH 0162/2234] Rubocop: Layout/CaseIndention and
Layout/ElseAlignment
Fixes some issues with indention and alignment with cases and elses.
---
.rubocop.yml | 3 +
.rubocop_todo.yml | 25 -------
.../billing/credit_card_formatting.rb | 6 +-
lib/active_merchant/billing/gateway.rb | 18 ++---
.../billing/gateways/authorize_net.rb | 12 ++--
.../billing/gateways/authorize_net_cim.rb | 16 ++---
.../billing/gateways/balanced.rb | 16 ++---
.../billing/gateways/braintree_blue.rb | 2 +-
.../billing/gateways/card_stream.rb | 14 ++--
.../billing/gateways/clearhaus.rb | 12 ++--
.../billing/gateways/eway_managed.rb | 8 +--
.../billing/gateways/firstdata_e4.rb | 12 ++--
.../billing/gateways/moneris.rb | 20 +++---
.../billing/gateways/moneris_us.rb | 10 +--
.../billing/gateways/netbanx.rb | 70 +++++++++----------
lib/active_merchant/billing/gateways/omise.rb | 10 +--
.../billing/gateways/pac_net_raven.rb | 10 +--
.../billing/gateways/payflow.rb | 18 ++---
.../billing/gateways/payment_express.rb | 14 ++--
.../billing/gateways/paymill.rb | 4 +-
.../billing/gateways/sage_pay.rb | 6 +-
.../billing/gateways/trust_commerce.rb | 6 +-
lib/active_merchant/billing/response.rb | 12 ++--
23 files changed, 151 insertions(+), 173 deletions(-)
diff --git a/.rubocop.yml b/.rubocop.yml
index d101dfec1a3..f1deca38196 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -29,3 +29,6 @@ Layout/AlignParameters:
Layout/DotPosition:
EnforcedStyle: trailing
+
+Layout/CaseIndentation:
+ EnforcedStyle: end
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 689e4e01296..3c88f5cb74d 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -14,36 +14,11 @@ Gemspec/OrderedDependencies:
Exclude:
- 'activemerchant.gemspec'
-# Offense count: 113
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle, IndentOneStep, IndentationWidth.
-# SupportedStyles: case, end
-Layout/CaseIndentation:
- Enabled: false
-
# Offense count: 426
# Cop supports --auto-correct.
Layout/ClosingHeredocIndentation:
Enabled: false
-# Offense count: 24
-# Cop supports --auto-correct.
-Layout/ElseAlignment:
- Exclude:
- - 'lib/active_merchant/billing/gateway.rb'
- - 'lib/active_merchant/billing/gateways/authorize_net.rb'
- - 'lib/active_merchant/billing/gateways/balanced.rb'
- - 'lib/active_merchant/billing/gateways/braintree_blue.rb'
- - 'lib/active_merchant/billing/gateways/card_stream.rb'
- - 'lib/active_merchant/billing/gateways/clearhaus.rb'
- - 'lib/active_merchant/billing/gateways/firstdata_e4.rb'
- - 'lib/active_merchant/billing/gateways/moneris.rb'
- - 'lib/active_merchant/billing/gateways/moneris_us.rb'
- - 'lib/active_merchant/billing/gateways/pac_net_raven.rb'
- - 'lib/active_merchant/billing/gateways/payflow.rb'
- - 'lib/active_merchant/billing/gateways/trust_commerce.rb'
- - 'lib/active_merchant/billing/response.rb'
-
# Offense count: 165
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
diff --git a/lib/active_merchant/billing/credit_card_formatting.rb b/lib/active_merchant/billing/credit_card_formatting.rb
index 74837bebac0..2a55bae60ad 100644
--- a/lib/active_merchant/billing/credit_card_formatting.rb
+++ b/lib/active_merchant/billing/credit_card_formatting.rb
@@ -13,9 +13,9 @@ def format(number, option)
return '' if number.blank?
case option
- when :two_digits then sprintf('%.2i', number.to_i)[-2..-1]
- when :four_digits then sprintf('%.4i', number.to_i)[-4..-1]
- else number
+ when :two_digits then sprintf('%.2i', number.to_i)[-2..-1]
+ when :four_digits then sprintf('%.4i', number.to_i)[-4..-1]
+ else number
end
end
end
diff --git a/lib/active_merchant/billing/gateway.rb b/lib/active_merchant/billing/gateway.rb
index 9db7133d6b2..29fcc6bbaf8 100644
--- a/lib/active_merchant/billing/gateway.rb
+++ b/lib/active_merchant/billing/gateway.rb
@@ -204,11 +204,11 @@ def supports_network_tokenization?
def normalize(field)
case field
- when 'true' then true
- when 'false' then false
- when '' then nil
- when 'null' then nil
- else field
+ when 'true' then true
+ when 'false' then false
+ when '' then nil
+ when 'null' then nil
+ else field
end
end
@@ -241,10 +241,10 @@ def name
def amount(money)
return nil if money.nil?
cents = if money.respond_to?(:cents)
- ActiveMerchant.deprecated 'Support for Money objects is deprecated and will be removed from a future release of ActiveMerchant. Please use an Integer value in cents'
- money.cents
- else
- money
+ ActiveMerchant.deprecated 'Support for Money objects is deprecated and will be removed from a future release of ActiveMerchant. Please use an Integer value in cents'
+ money.cents
+ else
+ money
end
if money.is_a?(String)
diff --git a/lib/active_merchant/billing/gateways/authorize_net.rb b/lib/active_merchant/billing/gateways/authorize_net.rb
index 75fa6c6fdd1..31640f0ca11 100644
--- a/lib/active_merchant/billing/gateways/authorize_net.rb
+++ b/lib/active_merchant/billing/gateways/authorize_net.rb
@@ -133,9 +133,9 @@ def capture(amount, authorization, options={})
def refund(amount, authorization, options={})
response = if auth_was_for_cim?(authorization)
- cim_refund(amount, authorization, options)
- else
- normal_refund(amount, authorization, options)
+ cim_refund(amount, authorization, options)
+ else
+ normal_refund(amount, authorization, options)
end
return response if response.success?
@@ -594,9 +594,9 @@ def add_shipping_address(xml, options, root_node='shipTo')
xml.send(root_node) do
first_name, last_name = if address[:name]
- split_names(address[:name])
- else
- [address[:first_name], address[:last_name]]
+ split_names(address[:name])
+ else
+ [address[:first_name], address[:last_name]]
end
full_address = "#{address[:address1]} #{address[:address2]}".strip
diff --git a/lib/active_merchant/billing/gateways/authorize_net_cim.rb b/lib/active_merchant/billing/gateways/authorize_net_cim.rb
index f57e1397af3..5f9d67c1a01 100644
--- a/lib/active_merchant/billing/gateways/authorize_net_cim.rb
+++ b/lib/active_merchant/billing/gateways/authorize_net_cim.rb
@@ -379,18 +379,18 @@ def create_customer_profile_transaction(options)
requires!(options, :transaction)
requires!(options[:transaction], :type)
case options[:transaction][:type]
- when :void
+ when :void
requires!(options[:transaction], :trans_id)
- when :refund
+ when :refund
requires!(options[:transaction], :trans_id) &&
(
(options[:transaction][:customer_profile_id] && options[:transaction][:customer_payment_profile_id]) ||
options[:transaction][:credit_card_number_masked] ||
(options[:transaction][:bank_routing_number_masked] && options[:transaction][:bank_account_number_masked])
)
- when :prior_auth_capture
+ when :prior_auth_capture
requires!(options[:transaction], :amount, :trans_id)
- else
+ else
requires!(options[:transaction], :amount, :customer_profile_id, :customer_payment_profile_id)
end
request = build_request(:create_customer_profile_transaction, options)
@@ -665,12 +665,12 @@ def add_transaction(xml, transaction)
xml.tag!(CIM_TRANSACTION_TYPES[transaction[:type]]) do
# The amount to be billed to the customer
case transaction[:type]
- when :void
+ when :void
tag_unless_blank(xml,'customerProfileId', transaction[:customer_profile_id])
tag_unless_blank(xml,'customerPaymentProfileId', transaction[:customer_payment_profile_id])
tag_unless_blank(xml,'customerShippingAddressId', transaction[:customer_shipping_address_id])
xml.tag!('transId', transaction[:trans_id])
- when :refund
+ when :refund
xml.tag!('amount', transaction[:amount])
tag_unless_blank(xml, 'customerProfileId', transaction[:customer_profile_id])
tag_unless_blank(xml, 'customerPaymentProfileId', transaction[:customer_payment_profile_id])
@@ -683,11 +683,11 @@ def add_transaction(xml, transaction)
add_tax(xml, transaction[:tax]) if transaction[:tax]
add_duty(xml, transaction[:duty]) if transaction[:duty]
add_shipping(xml, transaction[:shipping]) if transaction[:shipping]
- when :prior_auth_capture
+ when :prior_auth_capture
xml.tag!('amount', transaction[:amount])
add_order(xml, transaction[:order]) if transaction[:order].present?
xml.tag!('transId', transaction[:trans_id])
- else
+ else
xml.tag!('amount', transaction[:amount])
xml.tag!('customerProfileId', transaction[:customer_profile_id])
xml.tag!('customerPaymentProfileId', transaction[:customer_payment_profile_id])
diff --git a/lib/active_merchant/billing/gateways/balanced.rb b/lib/active_merchant/billing/gateways/balanced.rb
index dcc931d7e45..671cc596bf3 100644
--- a/lib/active_merchant/billing/gateways/balanced.rb
+++ b/lib/active_merchant/billing/gateways/balanced.rb
@@ -45,10 +45,10 @@ def purchase(money, payment_method, options = {})
MultiResponse.run do |r|
identifier = if(payment_method.respond_to?(:number))
- r.process{store(payment_method, options)}
- r.authorization
- else
- payment_method
+ r.process{store(payment_method, options)}
+ r.authorization
+ else
+ payment_method
end
r.process{commit('debits', "cards/#{card_identifier_from(identifier)}/debits", post)}
end
@@ -62,10 +62,10 @@ def authorize(money, payment_method, options = {})
MultiResponse.run do |r|
identifier = if(payment_method.respond_to?(:number))
- r.process{store(payment_method, options)}
- r.authorization
- else
- payment_method
+ r.process{store(payment_method, options)}
+ r.authorization
+ else
+ payment_method
end
r.process{commit('card_holds', "cards/#{card_identifier_from(identifier)}/card_holds", post)}
end
diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb
index 715f57e0f9b..0669b444b8b 100644
--- a/lib/active_merchant/billing/gateways/braintree_blue.rb
+++ b/lib/active_merchant/billing/gateways/braintree_blue.rb
@@ -303,7 +303,7 @@ def merge_credit_card_options(parameters, options)
end
parameters[:credit_card] ||= {}
- parameters[:credit_card].merge!(:options => valid_options)
+ parameters[:credit_card][:options] = valid_options
if options[:billing_address]
address = map_address(options[:billing_address])
parameters[:credit_card][:billing_address] = address unless address.all? { |_k, v| v.nil? }
diff --git a/lib/active_merchant/billing/gateways/card_stream.rb b/lib/active_merchant/billing/gateways/card_stream.rb
index 8fa7085e67c..190f2fe797b 100644
--- a/lib/active_merchant/billing/gateways/card_stream.rb
+++ b/lib/active_merchant/billing/gateways/card_stream.rb
@@ -334,13 +334,13 @@ def avs_from(response)
street_match = AVS_STREET_MATCH[response[:avscv2ResponseCode].to_s[2, 1]]
code = if postal_match == 'Y' && street_match == 'Y'
- 'M'
- elsif postal_match == 'Y'
- 'P'
- elsif street_match == 'Y'
- 'A'
- else
- 'I'
+ 'M'
+ elsif postal_match == 'Y'
+ 'P'
+ elsif street_match == 'Y'
+ 'A'
+ else
+ 'I'
end
AVSResult.new({
diff --git a/lib/active_merchant/billing/gateways/clearhaus.rb b/lib/active_merchant/billing/gateways/clearhaus.rb
index 4fd7745f395..2d2d73aa4f2 100644
--- a/lib/active_merchant/billing/gateways/clearhaus.rb
+++ b/lib/active_merchant/billing/gateways/clearhaus.rb
@@ -54,12 +54,12 @@ def authorize(amount, payment, options={})
add_invoice(post, amount, options)
action = if payment.respond_to?(:number)
- add_payment(post, payment)
- '/authorizations'
- elsif payment.kind_of?(String)
- "/cards/#{payment}/authorizations"
- else
- raise ArgumentError.new("Unknown payment type #{payment.inspect}")
+ add_payment(post, payment)
+ '/authorizations'
+ elsif payment.kind_of?(String)
+ "/cards/#{payment}/authorizations"
+ else
+ raise ArgumentError.new("Unknown payment type #{payment.inspect}")
end
post[:recurring] = options[:recurring] if options[:recurring]
diff --git a/lib/active_merchant/billing/gateways/eway_managed.rb b/lib/active_merchant/billing/gateways/eway_managed.rb
index 780f5c55481..2182bfac70b 100644
--- a/lib/active_merchant/billing/gateways/eway_managed.rb
+++ b/lib/active_merchant/billing/gateways/eway_managed.rb
@@ -231,13 +231,13 @@ def commit(action, post)
def soap_request(arguments, action)
# eWay demands all fields be sent, but contain an empty string if blank
post = case action
- when 'QueryCustomer'
+ when 'QueryCustomer'
arguments
- when 'ProcessPayment'
+ when 'ProcessPayment'
default_payment_fields.merge(arguments)
- when 'CreateCustomer'
+ when 'CreateCustomer'
default_customer_fields.merge(arguments)
- when 'UpdateCustomer'
+ when 'UpdateCustomer'
default_customer_fields.merge(arguments)
end
diff --git a/lib/active_merchant/billing/gateways/firstdata_e4.rb b/lib/active_merchant/billing/gateways/firstdata_e4.rb
index fa5781da07c..da6b77b306e 100755
--- a/lib/active_merchant/billing/gateways/firstdata_e4.rb
+++ b/lib/active_merchant/billing/gateways/firstdata_e4.rb
@@ -246,12 +246,12 @@ def add_credit_card(xml, credit_card, options)
def add_credit_card_eci(xml, credit_card, options)
eci = if credit_card.is_a?(NetworkTokenizationCreditCard) && credit_card.source == :apple_pay && card_brand(credit_card) == 'discover'
- # Discover requires any Apple Pay transaction, regardless of in-app
- # or web, and regardless of the ECI contained in the PKPaymentToken,
- # to have an ECI value explicitly of 04.
- '04'
- else
- (credit_card.respond_to?(:eci) ? credit_card.eci : nil) || options[:eci] || DEFAULT_ECI
+ # Discover requires any Apple Pay transaction, regardless of in-app
+ # or web, and regardless of the ECI contained in the PKPaymentToken,
+ # to have an ECI value explicitly of 04.
+ '04'
+ else
+ (credit_card.respond_to?(:eci) ? credit_card.eci : nil) || options[:eci] || DEFAULT_ECI
end
xml.tag! 'Ecommerce_Flag', eci.to_s =~ /^[0-9]+$/ ? eci.to_s.rjust(2, '0') : eci
diff --git a/lib/active_merchant/billing/gateways/moneris.rb b/lib/active_merchant/billing/gateways/moneris.rb
index bf8533c78fc..97c3d6cbc63 100644
--- a/lib/active_merchant/billing/gateways/moneris.rb
+++ b/lib/active_merchant/billing/gateways/moneris.rb
@@ -51,11 +51,11 @@ def authorize(money, creditcard_or_datakey, options = {})
post[:address] = options[:billing_address] || options[:address]
post[:crypt_type] = options[:crypt_type] || @options[:crypt_type]
action = if post[:cavv]
- 'cavv_preauth'
- elsif post[:data_key].blank?
- 'preauth'
- else
- 'res_preauth_cc'
+ 'cavv_preauth'
+ elsif post[:data_key].blank?
+ 'preauth'
+ else
+ 'res_preauth_cc'
end
commit(action, post)
end
@@ -73,11 +73,11 @@ def purchase(money, creditcard_or_datakey, options = {})
post[:address] = options[:billing_address] || options[:address]
post[:crypt_type] = options[:crypt_type] || @options[:crypt_type]
action = if post[:cavv]
- 'cavv_purchase'
- elsif post[:data_key].blank?
- 'purchase'
- else
- 'res_purchase_cc'
+ 'cavv_purchase'
+ elsif post[:data_key].blank?
+ 'purchase'
+ else
+ 'res_purchase_cc'
end
commit(action, post)
end
diff --git a/lib/active_merchant/billing/gateways/moneris_us.rb b/lib/active_merchant/billing/gateways/moneris_us.rb
index 9fc3f5b55c4..5cb3c515183 100644
--- a/lib/active_merchant/billing/gateways/moneris_us.rb
+++ b/lib/active_merchant/billing/gateways/moneris_us.rb
@@ -74,11 +74,11 @@ def purchase(money, creditcard_or_datakey, options = {})
add_address(post, creditcard_or_datakey, options)
post[:crypt_type] = options[:crypt_type] || @options[:crypt_type]
action = if creditcard_or_datakey.is_a?(String)
- 'us_res_purchase_cc'
- elsif card_brand(creditcard_or_datakey) == 'check'
- 'us_ach_debit'
- elsif post[:data_key].blank?
- 'us_purchase'
+ 'us_res_purchase_cc'
+ elsif card_brand(creditcard_or_datakey) == 'check'
+ 'us_ach_debit'
+ elsif post[:data_key].blank?
+ 'us_purchase'
end
commit(action, post)
end
diff --git a/lib/active_merchant/billing/gateways/netbanx.rb b/lib/active_merchant/billing/gateways/netbanx.rb
index 78f80153ec4..901efd4ddfb 100644
--- a/lib/active_merchant/billing/gateways/netbanx.rb
+++ b/lib/active_merchant/billing/gateways/netbanx.rb
@@ -247,41 +247,41 @@ def headers
def error_code_from(response)
unless success_from(response)
case response['errorCode']
- when '3002' then STANDARD_ERROR_CODE[:invalid_number] # You submitted an invalid card number or brand or combination of card number and brand with your request.
- when '3004' then STANDARD_ERROR_CODE[:incorrect_zip] # The zip/postal code must be provided for an AVS check request.
- when '3005' then STANDARD_ERROR_CODE[:incorrect_cvc] # You submitted an incorrect CVC value with your request.
- when '3006' then STANDARD_ERROR_CODE[:expired_card] # You submitted an expired credit card number with your request.
- when '3009' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank.
- when '3011' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank because the card used is a restricted card. Contact the cardholder's credit card company for further investigation.
- when '3012' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank because the credit card expiry date submitted is invalid.
- when '3013' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank due to problems with the credit card account.
- when '3014' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined - the issuing bank has returned an unknown response. Contact the card holder's credit card company for further investigation.
- when '3015' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you process the transaction manually by calling the cardholder's credit card company.
- when '3016' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – it may be a lost or stolen card.
- when '3017' then STANDARD_ERROR_CODE[:invalid_number] # You submitted an invalid credit card number with your request.
- when '3022' then STANDARD_ERROR_CODE[:card_declined] # The card has been declined due to insufficient funds.
- when '3023' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank due to its proprietary card activity regulations.
- when '3024' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined because the issuing bank does not permit the transaction for this card.
- when '3032' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank or external gateway because the card is probably in one of their negative databases.
- when '3035' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to exceeded PIN attempts.
- when '3036' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to an invalid issuer.
- when '3037' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined because it is invalid.
- when '3038' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to customer cancellation.
- when '3039' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to an invalid authentication value.
- when '3040' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined because the request type is not permitted on the card.
- when '3041' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to a timeout.
- when '3042' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to a cryptographic error.
- when '3045' then STANDARD_ERROR_CODE[:invalid_expiry_date] # You submitted an invalid date format for this request.
- when '3046' then STANDARD_ERROR_CODE[:card_declined] # The transaction was declined because the amount was set to zero.
- when '3047' then STANDARD_ERROR_CODE[:card_declined] # The transaction was declined because the amount exceeds the floor limit.
- when '3048' then STANDARD_ERROR_CODE[:card_declined] # The transaction was declined because the amount is less than the floor limit.
- when '3049' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – the credit card has expired.
- when '3050' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – fraudulent activity is suspected.
- when '3051' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – contact the acquirer for more information.
- when '3052' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – the credit card is restricted.
- when '3053' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – please call the acquirer.
- when '3054' then STANDARD_ERROR_CODE[:card_declined] # The transaction was declined due to suspected fraud.
- else STANDARD_ERROR_CODE[:processing_error]
+ when '3002' then STANDARD_ERROR_CODE[:invalid_number] # You submitted an invalid card number or brand or combination of card number and brand with your request.
+ when '3004' then STANDARD_ERROR_CODE[:incorrect_zip] # The zip/postal code must be provided for an AVS check request.
+ when '3005' then STANDARD_ERROR_CODE[:incorrect_cvc] # You submitted an incorrect CVC value with your request.
+ when '3006' then STANDARD_ERROR_CODE[:expired_card] # You submitted an expired credit card number with your request.
+ when '3009' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank.
+ when '3011' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank because the card used is a restricted card. Contact the cardholder's credit card company for further investigation.
+ when '3012' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank because the credit card expiry date submitted is invalid.
+ when '3013' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank due to problems with the credit card account.
+ when '3014' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined - the issuing bank has returned an unknown response. Contact the card holder's credit card company for further investigation.
+ when '3015' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you process the transaction manually by calling the cardholder's credit card company.
+ when '3016' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – it may be a lost or stolen card.
+ when '3017' then STANDARD_ERROR_CODE[:invalid_number] # You submitted an invalid credit card number with your request.
+ when '3022' then STANDARD_ERROR_CODE[:card_declined] # The card has been declined due to insufficient funds.
+ when '3023' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank due to its proprietary card activity regulations.
+ when '3024' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined because the issuing bank does not permit the transaction for this card.
+ when '3032' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank or external gateway because the card is probably in one of their negative databases.
+ when '3035' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to exceeded PIN attempts.
+ when '3036' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to an invalid issuer.
+ when '3037' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined because it is invalid.
+ when '3038' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to customer cancellation.
+ when '3039' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to an invalid authentication value.
+ when '3040' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined because the request type is not permitted on the card.
+ when '3041' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to a timeout.
+ when '3042' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to a cryptographic error.
+ when '3045' then STANDARD_ERROR_CODE[:invalid_expiry_date] # You submitted an invalid date format for this request.
+ when '3046' then STANDARD_ERROR_CODE[:card_declined] # The transaction was declined because the amount was set to zero.
+ when '3047' then STANDARD_ERROR_CODE[:card_declined] # The transaction was declined because the amount exceeds the floor limit.
+ when '3048' then STANDARD_ERROR_CODE[:card_declined] # The transaction was declined because the amount is less than the floor limit.
+ when '3049' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – the credit card has expired.
+ when '3050' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – fraudulent activity is suspected.
+ when '3051' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – contact the acquirer for more information.
+ when '3052' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – the credit card is restricted.
+ when '3053' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – please call the acquirer.
+ when '3054' then STANDARD_ERROR_CODE[:card_declined] # The transaction was declined due to suspected fraud.
+ else STANDARD_ERROR_CODE[:processing_error]
end
end
end
diff --git a/lib/active_merchant/billing/gateways/omise.rb b/lib/active_merchant/billing/gateways/omise.rb
index 30ff0845778..3dbb8e30c37 100644
--- a/lib/active_merchant/billing/gateways/omise.rb
+++ b/lib/active_merchant/billing/gateways/omise.rb
@@ -246,15 +246,15 @@ def error_code_from(response)
def message_to_standard_error_code_from(response)
message = response['message'] if response['code'] == 'invalid_card'
case message
- when /brand not supported/
+ when /brand not supported/
STANDARD_ERROR_CODE[:invalid_number]
- when /number is invalid/
+ when /number is invalid/
STANDARD_ERROR_CODE[:incorrect_number]
- when /expiration date cannot be in the past/
+ when /expiration date cannot be in the past/
STANDARD_ERROR_CODE[:expired_card]
- when /expiration \w+ is invalid/
+ when /expiration \w+ is invalid/
STANDARD_ERROR_CODE[:invalid_expiry_date]
- else
+ else
STANDARD_ERROR_CODE[:processing_error]
end
end
diff --git a/lib/active_merchant/billing/gateways/pac_net_raven.rb b/lib/active_merchant/billing/gateways/pac_net_raven.rb
index 631e1441175..fbc5557fd07 100644
--- a/lib/active_merchant/billing/gateways/pac_net_raven.rb
+++ b/lib/active_merchant/billing/gateways/pac_net_raven.rb
@@ -193,11 +193,11 @@ def request_id
def signature(action, post, parameters = {})
string = if %w(cc_settle cc_debit cc_preauth cc_refund).include?(action)
- post['UserName'] + post['Timestamp'] + post['RequestID'] + post['PymtType'] + parameters['Amount'].to_s + parameters['Currency']
- elsif action == 'void'
- post['UserName'] + post['Timestamp'] + post['RequestID'] + parameters['TrackingNumber']
- else
- post['UserName']
+ post['UserName'] + post['Timestamp'] + post['RequestID'] + post['PymtType'] + parameters['Amount'].to_s + parameters['Currency']
+ elsif action == 'void'
+ post['UserName'] + post['Timestamp'] + post['RequestID'] + parameters['TrackingNumber']
+ else
+ post['UserName']
end
OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA1.new(@options[:secret]), @options[:secret], string)
end
diff --git a/lib/active_merchant/billing/gateways/payflow.rb b/lib/active_merchant/billing/gateways/payflow.rb
index db7ac1cbe11..418e2e05b68 100644
--- a/lib/active_merchant/billing/gateways/payflow.rb
+++ b/lib/active_merchant/billing/gateways/payflow.rb
@@ -318,20 +318,20 @@ def build_recurring_request(action, money, options)
def get_pay_period(options)
requires!(options, [:periodicity, :bimonthly, :monthly, :biweekly, :weekly, :yearly, :daily, :semimonthly, :quadweekly, :quarterly, :semiyearly])
case options[:periodicity]
- when :weekly then 'Weekly'
- when :biweekly then 'Bi-weekly'
- when :semimonthly then 'Semi-monthly'
- when :quadweekly then 'Every four weeks'
- when :monthly then 'Monthly'
- when :quarterly then 'Quarterly'
- when :semiyearly then 'Semi-yearly'
- when :yearly then 'Yearly'
+ when :weekly then 'Weekly'
+ when :biweekly then 'Bi-weekly'
+ when :semimonthly then 'Semi-monthly'
+ when :quadweekly then 'Every four weeks'
+ when :monthly then 'Monthly'
+ when :quarterly then 'Quarterly'
+ when :semiyearly then 'Semi-yearly'
+ when :yearly then 'Yearly'
end
end
def format_rp_date(time)
case time
- when Time, Date then time.strftime('%m%d%Y')
+ when Time, Date then time.strftime('%m%d%Y')
else
time.to_s
end
diff --git a/lib/active_merchant/billing/gateways/payment_express.rb b/lib/active_merchant/billing/gateways/payment_express.rb
index 347f423fac7..b668aa14109 100644
--- a/lib/active_merchant/billing/gateways/payment_express.rb
+++ b/lib/active_merchant/billing/gateways/payment_express.rb
@@ -340,13 +340,13 @@ def format_date(month, year)
def normalized_client_type(client_type_from_options)
case client_type_from_options.to_s.downcase
- when 'web' then 'Web'
- when 'ivr' then 'IVR'
- when 'moto' then 'MOTO'
- when 'unattended' then 'Unattended'
- when 'internet' then 'Internet'
- when 'recurring' then 'Recurring'
- else nil
+ when 'web' then 'Web'
+ when 'ivr' then 'IVR'
+ when 'moto' then 'MOTO'
+ when 'unattended' then 'Unattended'
+ when 'internet' then 'Internet'
+ when 'recurring' then 'Recurring'
+ else nil
end
end
end
diff --git a/lib/active_merchant/billing/gateways/paymill.rb b/lib/active_merchant/billing/gateways/paymill.rb
index ff2f8268484..858cc4bd5d9 100644
--- a/lib/active_merchant/billing/gateways/paymill.rb
+++ b/lib/active_merchant/billing/gateways/paymill.rb
@@ -128,9 +128,9 @@ def authorization_from(parsed_response)
def action_with_token(action, money, payment_method, options)
options[:money] = money
case payment_method
- when String
+ when String
self.send("#{action}_with_token", money, payment_method, options)
- else
+ else
MultiResponse.run do |r|
r.process { save_card(payment_method, options) }
r.process { self.send("#{action}_with_token", money, r.authorization, options) }
diff --git a/lib/active_merchant/billing/gateways/sage_pay.rb b/lib/active_merchant/billing/gateways/sage_pay.rb
index 591b3c6a43d..ae3f747d018 100644
--- a/lib/active_merchant/billing/gateways/sage_pay.rb
+++ b/lib/active_merchant/billing/gateways/sage_pay.rb
@@ -380,9 +380,9 @@ def url_for(action)
def build_url(action)
endpoint = case action
- when :purchase, :authorization then 'vspdirect-register'
- when :store then 'directtoken'
- else TRANSACTIONS[action].downcase
+ when :purchase, :authorization then 'vspdirect-register'
+ when :store then 'directtoken'
+ else TRANSACTIONS[action].downcase
end
"#{test? ? self.test_url : self.live_url}/#{endpoint}.vsp"
end
diff --git a/lib/active_merchant/billing/gateways/trust_commerce.rb b/lib/active_merchant/billing/gateways/trust_commerce.rb
index 19bf5d122ad..eaf6cf4900b 100644
--- a/lib/active_merchant/billing/gateways/trust_commerce.rb
+++ b/lib/active_merchant/billing/gateways/trust_commerce.rb
@@ -383,9 +383,9 @@ def commit(action, parameters)
clean_and_stringify_params(parameters)
data = if tclink?
- TCLink.send(parameters)
- else
- parse( ssl_post(self.live_url, post_data(parameters)) )
+ TCLink.send(parameters)
+ else
+ parse( ssl_post(self.live_url, post_data(parameters)) )
end
# to be considered successful, transaction status must be either "approved" or "accepted"
diff --git a/lib/active_merchant/billing/response.rb b/lib/active_merchant/billing/response.rb
index a59174ceb7c..8470e8385e1 100644
--- a/lib/active_merchant/billing/response.rb
+++ b/lib/active_merchant/billing/response.rb
@@ -27,15 +27,15 @@ def initialize(success, message, params = {}, options = {})
@emv_authorization = options[:emv_authorization]
@avs_result = if options[:avs_result].kind_of?(AVSResult)
- options[:avs_result].to_hash
- else
- AVSResult.new(options[:avs_result]).to_hash
+ options[:avs_result].to_hash
+ else
+ AVSResult.new(options[:avs_result]).to_hash
end
@cvv_result = if options[:cvv_result].kind_of?(CVVResult)
- options[:cvv_result].to_hash
- else
- CVVResult.new(options[:cvv_result]).to_hash
+ options[:cvv_result].to_hash
+ else
+ CVVResult.new(options[:cvv_result]).to_hash
end
end
end
From e6cc43a3fb6145bf4c5d6d46a4eefd1282015ba6 Mon Sep 17 00:00:00 2001
From: DeeDee Lavinder
Date: Mon, 5 Nov 2018 20:38:36 -0500
Subject: [PATCH 0163/2234] Corrects Method method
---
lib/active_merchant/billing/gateways/visanet_peru.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/active_merchant/billing/gateways/visanet_peru.rb b/lib/active_merchant/billing/gateways/visanet_peru.rb
index 47f0b5d99de..c8ba88f8b16 100644
--- a/lib/active_merchant/billing/gateways/visanet_peru.rb
+++ b/lib/active_merchant/billing/gateways/visanet_peru.rb
@@ -176,7 +176,7 @@ def url(action, params, options={})
end
def method(action)
- %w(authorize refund).include? action ? :post : :put
+ (%w(authorize refund).include? action) ? :post : :put
end
def authorization_from(params, response, options)
From c1c78afe84f800b124c7011942aac2e6fba51dfc Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Tue, 6 Nov 2018 09:34:00 -0500
Subject: [PATCH 0164/2234] Visanet Peru: fix RuboCop error
Additionally, the unit tests previously didn't actually test the right
thing (the requests were returned in the wrong order)--but, due to how
they were written, they could still pass. Problematic ones have been
fixed, and would now fail with the patch that #3034 had to paritally
revert.
Unit: 13 tests, 67 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
.../billing/gateways/visanet_peru.rb | 2 +-
test/unit/gateways/visanet_peru_test.rb | 18 +++++++++---------
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/visanet_peru.rb b/lib/active_merchant/billing/gateways/visanet_peru.rb
index c8ba88f8b16..c15d4fdde1c 100644
--- a/lib/active_merchant/billing/gateways/visanet_peru.rb
+++ b/lib/active_merchant/billing/gateways/visanet_peru.rb
@@ -176,7 +176,7 @@ def url(action, params, options={})
end
def method(action)
- (%w(authorize refund).include? action) ? :post : :put
+ %w(authorize refund).include?(action) ? :post : :put
end
def authorization_from(params, response, options)
diff --git a/test/unit/gateways/visanet_peru_test.rb b/test/unit/gateways/visanet_peru_test.rb
index 55d77cb4427..bbf3af32b47 100644
--- a/test/unit/gateways/visanet_peru_test.rb
+++ b/test/unit/gateways/visanet_peru_test.rb
@@ -16,20 +16,20 @@ def setup
end
def test_successful_purchase
- @gateway.expects(:ssl_request).returns(successful_authorize_response)
- @gateway.expects(:ssl_request).returns(successful_capture_response)
+ @gateway.expects(:ssl_request).with(:post, any_parameters).returns(successful_authorize_response)
+ @gateway.expects(:ssl_request).with(:put, any_parameters).returns(successful_capture_response)
response = @gateway.purchase(@amount, @credit_card, @options)
assert_success response
assert_equal 'OK', response.message
assert_match %r([0-9]{9}|$), response.authorization
- assert_equal @options[:order_id], response.params['externalTransactionId']
+ assert_equal 'de9dc65c094fb4f1defddc562731af81', response.params['externalTransactionId']
assert response.test?
end
def test_failed_purchase
- @gateway.expects(:ssl_request).returns(failed_authorize_response_bad_card)
+ @gateway.expects(:ssl_request).with(:post, any_parameters).returns(failed_authorize_response_bad_card)
response = @gateway.purchase(@amount, @declined_card, @options)
assert_failure response
@@ -64,14 +64,14 @@ def test_failed_authorize
end
def test_successful_capture
- @gateway.expects(:ssl_request).returns(successful_authorize_response)
- @gateway.expects(:ssl_request).returns(successful_capture_response)
+ @gateway.expects(:ssl_request).with(:post, any_parameters).returns(successful_authorize_response)
+ @gateway.expects(:ssl_request).with(:put, any_parameters).returns(successful_capture_response)
response = @gateway.authorize(@amount, @credit_card, @options)
capture = @gateway.capture(response.authorization, @options)
assert_success capture
assert_equal 'OK', capture.message
assert_match %r(^[0-9]{9}|$), capture.authorization
- assert_equal @options[:order_id], capture.params['externalTransactionId']
+ assert_equal 'de9dc65c094fb4f1defddc562731af81', capture.params['externalTransactionId']
assert capture.test?
end
@@ -90,14 +90,14 @@ def test_successful_refund
response = @gateway.purchase(@amount, @credit_card, @options)
assert_success response
- @gateway.expects(:ssl_request).returns(successful_refund_response)
+ @gateway.expects(:ssl_request).with(:put, any_parameters).returns(successful_refund_response)
refund = @gateway.refund(@amount, response.authorization)
assert_success refund
assert_equal 'OK', refund.message
end
def test_failed_refund
- @gateway.expects(:ssl_request).returns(failed_refund_response)
+ @gateway.expects(:ssl_request).with(:put, any_parameters).returns(failed_refund_response)
response = @gateway.refund(@amount, '122333444')
assert_failure response
assert_match(/No se realizo la anulacion del deposito/, response.message)
From 57eb7ddb92091cd75290328700e15566d0e53c87 Mon Sep 17 00:00:00 2001
From: molbrown
Date: Fri, 2 Nov 2018 14:29:42 -0400
Subject: [PATCH 0165/2234] Paymentez: Adds support for user.phone field
Adds user.phone field for Paymentez and updates remote test.
Unit tests:
19 tests, 77 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote tests:
17 tests, 33 assertions, 6 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
64.7059% passed
These failures due to `The method authorize is not supported by carrier`.
Country credentials used for testing do not support `authorize`. Unrelated.
Closes #3033
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/paymentez.rb | 1 +
test/remote/gateways/remote_paymentez_test.rb | 3 ++-
3 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index d225259b878..67b40fb097b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -18,6 +18,7 @@
* Braintree: Account for nil billing address fields [curiousepic] #3029
* Realex: Add verify [kheang] #3030
* Braintree: Actually account for nil address fields [curiousepic] #3032
+* Paymentez: Adds support for user.phone field [molbrown] #3033
== Version 1.85.0 (September 28, 2018)
* Authorize.Net: Support custom delimiter for cim [curiousepic] #3001
diff --git a/lib/active_merchant/billing/gateways/paymentez.rb b/lib/active_merchant/billing/gateways/paymentez.rb
index af73e15b31c..55a7a786c0c 100644
--- a/lib/active_merchant/billing/gateways/paymentez.rb
+++ b/lib/active_merchant/billing/gateways/paymentez.rb
@@ -134,6 +134,7 @@ def add_customer_data(post, options)
post[:user][:email] = options[:email]
post[:user][:ip_address] = options[:ip] if options[:ip]
post[:user][:fiscal_number] = options[:fiscal_number] if options[:fiscal_number]
+ post[:user][:phone] = options[:phone] || (options[:billing_address][:phone] if options[:billing_address])
end
def add_invoice(post, money, options)
diff --git a/test/remote/gateways/remote_paymentez_test.rb b/test/remote/gateways/remote_paymentez_test.rb
index b6c2fca7173..5a43ce26613 100644
--- a/test/remote/gateways/remote_paymentez_test.rb
+++ b/test/remote/gateways/remote_paymentez_test.rb
@@ -26,7 +26,8 @@ def test_successful_purchase_with_more_options
options = {
order_id: '1',
ip: '127.0.0.1',
- tax_percentage: 0.07
+ tax_percentage: 0.07,
+ phone: '333 333 3333'
}
response = @gateway.purchase(@amount, @credit_card, @options.merge(options))
From 3d94477b8c7e2d6d192b3cc442526574fed81216 Mon Sep 17 00:00:00 2001
From: molbrown
Date: Wed, 7 Nov 2018 14:15:12 -0500
Subject: [PATCH 0166/2234] Paymentez: Does not send nil for empty parameter
phone
Unit tests:
19 tests, 77 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote tests:
18 tests, 34 assertions, 7 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
61.1111% passed
These failures due to The method authorize is not supported by carrier.
Country credentials used for testing do not support authorize. Unrelated.
Closes #3036
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/paymentez.rb | 3 ++-
test/remote/gateways/remote_paymentez_test.rb | 12 ++++++++++++
3 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 67b40fb097b..c175a8f17a9 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -19,6 +19,7 @@
* Realex: Add verify [kheang] #3030
* Braintree: Actually account for nil address fields [curiousepic] #3032
* Paymentez: Adds support for user.phone field [molbrown] #3033
+* Paymentez: Does not send nil for empty parameter phone [molbrown] #3036
== Version 1.85.0 (September 28, 2018)
* Authorize.Net: Support custom delimiter for cim [curiousepic] #3001
diff --git a/lib/active_merchant/billing/gateways/paymentez.rb b/lib/active_merchant/billing/gateways/paymentez.rb
index 55a7a786c0c..603fca01baa 100644
--- a/lib/active_merchant/billing/gateways/paymentez.rb
+++ b/lib/active_merchant/billing/gateways/paymentez.rb
@@ -134,7 +134,8 @@ def add_customer_data(post, options)
post[:user][:email] = options[:email]
post[:user][:ip_address] = options[:ip] if options[:ip]
post[:user][:fiscal_number] = options[:fiscal_number] if options[:fiscal_number]
- post[:user][:phone] = options[:phone] || (options[:billing_address][:phone] if options[:billing_address])
+ post[:user][:phone] = options[:phone] || (options[:billing_address][:phone] if options[:billing_address] &&
+ options[:billing_address][:phone])
end
def add_invoice(post, money, options)
diff --git a/test/remote/gateways/remote_paymentez_test.rb b/test/remote/gateways/remote_paymentez_test.rb
index 5a43ce26613..6cb11be8a46 100644
--- a/test/remote/gateways/remote_paymentez_test.rb
+++ b/test/remote/gateways/remote_paymentez_test.rb
@@ -34,6 +34,18 @@ def test_successful_purchase_with_more_options
assert_success response
end
+ def test_successful_purchase_without_phone_option
+ options = {
+ order_id: '1',
+ ip: '127.0.0.1',
+ tax_percentage: 0.07
+ }
+
+ response = @gateway.purchase(@amount, @credit_card, @options.merge(options))
+ assert_success response
+ refute_includes(response.params, 'phone')
+ end
+
def test_successful_purchase_with_token
store_response = @gateway.store(@credit_card, @options)
assert_success store_response
From d70550265c31af11d6a35cff7a5a072f43e74f5d Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Wed, 7 Nov 2018 16:50:31 -0500
Subject: [PATCH 0167/2234] Revert "Paymentez: Does not send nil for empty
parameter phone"
This reverts commit 3d94477b8c7e2d6d192b3cc442526574fed81216.
---
CHANGELOG | 1 -
lib/active_merchant/billing/gateways/paymentez.rb | 3 +--
test/remote/gateways/remote_paymentez_test.rb | 12 ------------
3 files changed, 1 insertion(+), 15 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index c175a8f17a9..67b40fb097b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -19,7 +19,6 @@
* Realex: Add verify [kheang] #3030
* Braintree: Actually account for nil address fields [curiousepic] #3032
* Paymentez: Adds support for user.phone field [molbrown] #3033
-* Paymentez: Does not send nil for empty parameter phone [molbrown] #3036
== Version 1.85.0 (September 28, 2018)
* Authorize.Net: Support custom delimiter for cim [curiousepic] #3001
diff --git a/lib/active_merchant/billing/gateways/paymentez.rb b/lib/active_merchant/billing/gateways/paymentez.rb
index 603fca01baa..55a7a786c0c 100644
--- a/lib/active_merchant/billing/gateways/paymentez.rb
+++ b/lib/active_merchant/billing/gateways/paymentez.rb
@@ -134,8 +134,7 @@ def add_customer_data(post, options)
post[:user][:email] = options[:email]
post[:user][:ip_address] = options[:ip] if options[:ip]
post[:user][:fiscal_number] = options[:fiscal_number] if options[:fiscal_number]
- post[:user][:phone] = options[:phone] || (options[:billing_address][:phone] if options[:billing_address] &&
- options[:billing_address][:phone])
+ post[:user][:phone] = options[:phone] || (options[:billing_address][:phone] if options[:billing_address])
end
def add_invoice(post, money, options)
diff --git a/test/remote/gateways/remote_paymentez_test.rb b/test/remote/gateways/remote_paymentez_test.rb
index 6cb11be8a46..5a43ce26613 100644
--- a/test/remote/gateways/remote_paymentez_test.rb
+++ b/test/remote/gateways/remote_paymentez_test.rb
@@ -34,18 +34,6 @@ def test_successful_purchase_with_more_options
assert_success response
end
- def test_successful_purchase_without_phone_option
- options = {
- order_id: '1',
- ip: '127.0.0.1',
- tax_percentage: 0.07
- }
-
- response = @gateway.purchase(@amount, @credit_card, @options.merge(options))
- assert_success response
- refute_includes(response.params, 'phone')
- end
-
def test_successful_purchase_with_token
store_response = @gateway.store(@credit_card, @options)
assert_success store_response
From a2941fb36c49defdd35c08411384646ba2239f41 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Wed, 7 Nov 2018 16:50:47 -0500
Subject: [PATCH 0168/2234] Revert "Paymentez: Adds support for user.phone
field"
This reverts commit 57eb7ddb92091cd75290328700e15566d0e53c87.
---
CHANGELOG | 1 -
lib/active_merchant/billing/gateways/paymentez.rb | 1 -
test/remote/gateways/remote_paymentez_test.rb | 3 +--
3 files changed, 1 insertion(+), 4 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 67b40fb097b..d225259b878 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -18,7 +18,6 @@
* Braintree: Account for nil billing address fields [curiousepic] #3029
* Realex: Add verify [kheang] #3030
* Braintree: Actually account for nil address fields [curiousepic] #3032
-* Paymentez: Adds support for user.phone field [molbrown] #3033
== Version 1.85.0 (September 28, 2018)
* Authorize.Net: Support custom delimiter for cim [curiousepic] #3001
diff --git a/lib/active_merchant/billing/gateways/paymentez.rb b/lib/active_merchant/billing/gateways/paymentez.rb
index 55a7a786c0c..af73e15b31c 100644
--- a/lib/active_merchant/billing/gateways/paymentez.rb
+++ b/lib/active_merchant/billing/gateways/paymentez.rb
@@ -134,7 +134,6 @@ def add_customer_data(post, options)
post[:user][:email] = options[:email]
post[:user][:ip_address] = options[:ip] if options[:ip]
post[:user][:fiscal_number] = options[:fiscal_number] if options[:fiscal_number]
- post[:user][:phone] = options[:phone] || (options[:billing_address][:phone] if options[:billing_address])
end
def add_invoice(post, money, options)
diff --git a/test/remote/gateways/remote_paymentez_test.rb b/test/remote/gateways/remote_paymentez_test.rb
index 5a43ce26613..b6c2fca7173 100644
--- a/test/remote/gateways/remote_paymentez_test.rb
+++ b/test/remote/gateways/remote_paymentez_test.rb
@@ -26,8 +26,7 @@ def test_successful_purchase_with_more_options
options = {
order_id: '1',
ip: '127.0.0.1',
- tax_percentage: 0.07,
- phone: '333 333 3333'
+ tax_percentage: 0.07
}
response = @gateway.purchase(@amount, @credit_card, @options.merge(options))
From 89eb45ad69509c125f4d51b443382195dd6ef6e9 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 1 Nov 2018 11:57:50 -0400
Subject: [PATCH 0169/2234] Mercado Pago: do not infer card type
This is a re-application of d9c5a1a0.
Allow the card type to be passed in explicitly instead via the
:payment_method_id option. Additionally, allow sending the :issuer_id.
Unit: 19 tests, 93 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote: 17 tests, 46 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
.../billing/gateways/mercado_pago.rb | 10 +----
test/unit/gateways/mercado_pago_test.rb | 38 +++++++++----------
2 files changed, 20 insertions(+), 28 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/mercado_pago.rb b/lib/active_merchant/billing/gateways/mercado_pago.rb
index 900f2ceb361..ef76ab493ad 100644
--- a/lib/active_merchant/billing/gateways/mercado_pago.rb
+++ b/lib/active_merchant/billing/gateways/mercado_pago.rb
@@ -10,11 +10,6 @@ class MercadoPagoGateway < Gateway
self.display_name = 'Mercado Pago'
self.money_format = :dollars
- CARD_BRAND = {
- 'american_express' => 'amex',
- 'diners_club' => 'diners'
- }
-
def initialize(options={})
requires!(options, :access_token)
super
@@ -23,7 +18,6 @@ def initialize(options={})
def purchase(money, payment, options={})
MultiResponse.run do |r|
r.process { commit('tokenize', 'card_tokens', card_token_request(money, payment, options)) }
- options[:card_brand] = (CARD_BRAND[payment.brand] || payment.brand)
options[:card_token] = r.authorization.split('|').first
r.process { commit('purchase', 'payments', purchase_request(money, payment, options) ) }
end
@@ -32,7 +26,6 @@ def purchase(money, payment, options={})
def authorize(money, payment, options={})
MultiResponse.run do |r|
r.process { commit('tokenize', 'card_tokens', card_token_request(money, payment, options)) }
- options[:card_brand] = (CARD_BRAND[payment.brand] || payment.brand)
options[:card_token] = r.authorization.split('|').first
r.process { commit('authorize', 'payments', authorize_request(money, payment, options) ) }
end
@@ -181,7 +174,8 @@ def add_invoice(post, money, options)
def add_payment(post, options)
post[:token] = options[:card_token]
- post[:payment_method_id] = options[:card_brand]
+ post[:issuer_id] = options[:issuer_id] if options[:issuer_id]
+ post[:payment_method_id] = options[:payment_method_id] if options[:payment_method_id]
end
def parse(body)
diff --git a/test/unit/gateways/mercado_pago_test.rb b/test/unit/gateways/mercado_pago_test.rb
index 72ad12215f5..9139432254c 100644
--- a/test/unit/gateways/mercado_pago_test.rb
+++ b/test/unit/gateways/mercado_pago_test.rb
@@ -149,14 +149,14 @@ def test_scrub
assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed
end
- def test_sends_american_express_as_amex
+ def test_does_not_send_brand
credit_card = credit_card('378282246310005', brand: 'american_express')
response = stub_comms do
@gateway.purchase(@amount, credit_card, @options)
end.check_request do |endpoint, data, headers|
if endpoint =~ /payments/
- assert_match(%r("payment_method_id":"amex"), data)
+ assert_not_match(%r("payment_method_id":"amex"), data)
end
end.respond_with(successful_purchase_response)
@@ -164,11 +164,11 @@ def test_sends_american_express_as_amex
assert_equal '4141491|1.0', response.authorization
end
- def test_sends_diners_club_as_diners
- credit_card = credit_card('30569309025904', brand: 'diners_club')
+ def test_sends_payment_method_id
+ credit_card = credit_card('30569309025904')
response = stub_comms do
- @gateway.purchase(@amount, credit_card, @options)
+ @gateway.purchase(@amount, credit_card, @options.merge(payment_method_id: 'diners'))
end.check_request do |endpoint, data, headers|
if endpoint =~ /payments/
assert_match(%r("payment_method_id":"diners"), data)
@@ -179,21 +179,6 @@ def test_sends_diners_club_as_diners
assert_equal '4141491|1.0', response.authorization
end
- def test_sends_mastercard_as_master
- credit_card = credit_card('5555555555554444', brand: 'master')
-
- response = stub_comms do
- @gateway.purchase(@amount, credit_card, @options)
- end.check_request do |endpoint, data, headers|
- if endpoint =~ /payments/
- assert_match(%r("payment_method_id":"master"), data)
- end
- end.respond_with(successful_purchase_response)
-
- assert_success response
- assert_equal '4141491|1.0', response.authorization
- end
-
def test_includes_deviceid_header
@options[:device_id] = '1a2b3c'
@gateway.expects(:ssl_post).with(anything, anything, {'Content-Type' => 'application/json'}).returns(successful_purchase_response)
@@ -217,6 +202,19 @@ def test_includes_additional_data
assert_success response
end
+ def test_includes_issuer_id
+ response = stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options.merge(issuer_id: '1a2b3c4d'))
+ end.check_request do |endpoint, data, headers|
+ if endpoint =~ /payments/
+ assert_match(%r("issuer_id":"1a2b3c4d"), data)
+ end
+ end.respond_with(successful_purchase_response)
+
+ assert_success response
+ assert_equal '4141491|1.0', response.authorization
+ end
+
private
def pre_scrubbed
From 9ca795fbfbc1afd08aad71b8baaa192f6141e80f Mon Sep 17 00:00:00 2001
From: molbrown
Date: Wed, 7 Nov 2018 16:05:10 -0500
Subject: [PATCH 0170/2234] Paymentez: Does not send phone parameter unless it
is defined
Unit tests:
19 tests, 77 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote tests:
18 tests, 34 assertions, 6 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
66.6667% passed
These failures due to `The method authorize is not supported by carrier`.
Country credentials used for testing do not support authorize. Unrelated.
Closes Paymentez: #3037
---
CHANGELOG | 1 +
.../billing/gateways/paymentez.rb | 3 +++
test/remote/gateways/remote_paymentez_test.rb | 21 ++++++++++++++++---
3 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index d225259b878..5597fcaa206 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -18,6 +18,7 @@
* Braintree: Account for nil billing address fields [curiousepic] #3029
* Realex: Add verify [kheang] #3030
* Braintree: Actually account for nil address fields [curiousepic] #3032
+* Paymentez: Does not send phone parameter unless it is defined [molbrown] #3037
== Version 1.85.0 (September 28, 2018)
* Authorize.Net: Support custom delimiter for cim [curiousepic] #3001
diff --git a/lib/active_merchant/billing/gateways/paymentez.rb b/lib/active_merchant/billing/gateways/paymentez.rb
index af73e15b31c..de8aef722bf 100644
--- a/lib/active_merchant/billing/gateways/paymentez.rb
+++ b/lib/active_merchant/billing/gateways/paymentez.rb
@@ -134,6 +134,9 @@ def add_customer_data(post, options)
post[:user][:email] = options[:email]
post[:user][:ip_address] = options[:ip] if options[:ip]
post[:user][:fiscal_number] = options[:fiscal_number] if options[:fiscal_number]
+ if phone = options[:phone] || options[:billing_address][:phone]
+ post[:user][:phone] = phone
+ end
end
def add_invoice(post, money, options)
diff --git a/test/remote/gateways/remote_paymentez_test.rb b/test/remote/gateways/remote_paymentez_test.rb
index b6c2fca7173..2498722a50c 100644
--- a/test/remote/gateways/remote_paymentez_test.rb
+++ b/test/remote/gateways/remote_paymentez_test.rb
@@ -5,8 +5,8 @@ def setup
@gateway = PaymentezGateway.new(fixtures(:paymentez))
@amount = 100
- @credit_card = credit_card('4111111111111111', verification_value: '555')
- @declined_card = credit_card('4242424242424242', verification_value: '555')
+ @credit_card = credit_card('4111111111111111', verification_value: '666')
+ @declined_card = credit_card('4242424242424242', verification_value: '666')
@options = {
billing_address: address,
description: 'Store Purchase',
@@ -26,7 +26,22 @@ def test_successful_purchase_with_more_options
options = {
order_id: '1',
ip: '127.0.0.1',
- tax_percentage: 0.07
+ tax_percentage: 0.07,
+ phone: '333 333 3333'
+ }
+
+ response = @gateway.purchase(@amount, @credit_card, @options.merge(options))
+ assert_success response
+ end
+
+ def test_successful_purchase_without_phone_option
+ options = {
+ order_id: '1',
+ ip: '127.0.0.1',
+ tax_percentage: 0.07,
+ billing_address: {
+ phone: nil
+ }
}
response = @gateway.purchase(@amount, @credit_card, @options.merge(options))
From 1cab3d01310d91d9e4fd8309b877218b9912cc22 Mon Sep 17 00:00:00 2001
From: molbrown
Date: Thu, 8 Nov 2018 15:30:11 -0500
Subject: [PATCH 0171/2234] Revert "Paymentez: Does not send phone parameter
unless it is defined"
This reverts commit 9ca795fbfbc1afd08aad71b8baaa192f6141e80f.
---
CHANGELOG | 1 -
.../billing/gateways/paymentez.rb | 3 ---
test/remote/gateways/remote_paymentez_test.rb | 21 +++----------------
3 files changed, 3 insertions(+), 22 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 5597fcaa206..d225259b878 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -18,7 +18,6 @@
* Braintree: Account for nil billing address fields [curiousepic] #3029
* Realex: Add verify [kheang] #3030
* Braintree: Actually account for nil address fields [curiousepic] #3032
-* Paymentez: Does not send phone parameter unless it is defined [molbrown] #3037
== Version 1.85.0 (September 28, 2018)
* Authorize.Net: Support custom delimiter for cim [curiousepic] #3001
diff --git a/lib/active_merchant/billing/gateways/paymentez.rb b/lib/active_merchant/billing/gateways/paymentez.rb
index de8aef722bf..af73e15b31c 100644
--- a/lib/active_merchant/billing/gateways/paymentez.rb
+++ b/lib/active_merchant/billing/gateways/paymentez.rb
@@ -134,9 +134,6 @@ def add_customer_data(post, options)
post[:user][:email] = options[:email]
post[:user][:ip_address] = options[:ip] if options[:ip]
post[:user][:fiscal_number] = options[:fiscal_number] if options[:fiscal_number]
- if phone = options[:phone] || options[:billing_address][:phone]
- post[:user][:phone] = phone
- end
end
def add_invoice(post, money, options)
diff --git a/test/remote/gateways/remote_paymentez_test.rb b/test/remote/gateways/remote_paymentez_test.rb
index 2498722a50c..b6c2fca7173 100644
--- a/test/remote/gateways/remote_paymentez_test.rb
+++ b/test/remote/gateways/remote_paymentez_test.rb
@@ -5,8 +5,8 @@ def setup
@gateway = PaymentezGateway.new(fixtures(:paymentez))
@amount = 100
- @credit_card = credit_card('4111111111111111', verification_value: '666')
- @declined_card = credit_card('4242424242424242', verification_value: '666')
+ @credit_card = credit_card('4111111111111111', verification_value: '555')
+ @declined_card = credit_card('4242424242424242', verification_value: '555')
@options = {
billing_address: address,
description: 'Store Purchase',
@@ -26,22 +26,7 @@ def test_successful_purchase_with_more_options
options = {
order_id: '1',
ip: '127.0.0.1',
- tax_percentage: 0.07,
- phone: '333 333 3333'
- }
-
- response = @gateway.purchase(@amount, @credit_card, @options.merge(options))
- assert_success response
- end
-
- def test_successful_purchase_without_phone_option
- options = {
- order_id: '1',
- ip: '127.0.0.1',
- tax_percentage: 0.07,
- billing_address: {
- phone: nil
- }
+ tax_percentage: 0.07
}
response = @gateway.purchase(@amount, @credit_card, @options.merge(options))
From df4be76590d81efefaf1da994ce92b20ec731d37 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 8 Nov 2018 15:33:28 -0500
Subject: [PATCH 0172/2234] Credorax: add submerchant_id support
Unit: 20 tests, 92 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/credorax.rb | 10 ++++++++++
test/unit/gateways/credorax_test.rb | 9 +++++++++
3 files changed, 20 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index d225259b878..0f3b7d98826 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -18,6 +18,7 @@
* Braintree: Account for nil billing address fields [curiousepic] #3029
* Realex: Add verify [kheang] #3030
* Braintree: Actually account for nil address fields [curiousepic] #3032
+* Credorax: allow sending submerchant ID (h3 parameter) [bpollack] #3040
== Version 1.85.0 (September 28, 2018)
* Authorize.Net: Support custom delimiter for cim [curiousepic] #3001
diff --git a/lib/active_merchant/billing/gateways/credorax.rb b/lib/active_merchant/billing/gateways/credorax.rb
index 9a60d276fbe..4689e66d7fe 100644
--- a/lib/active_merchant/billing/gateways/credorax.rb
+++ b/lib/active_merchant/billing/gateways/credorax.rb
@@ -129,6 +129,7 @@ def purchase(amount, payment_method, options={})
add_email(post, options)
add_3d_secure(post, options)
add_echo(post, options)
+ add_submerchant_id(post, options)
add_transaction_type(post, options)
commit(:purchase, post)
@@ -142,6 +143,7 @@ def authorize(amount, payment_method, options={})
add_email(post, options)
add_3d_secure(post, options)
add_echo(post, options)
+ add_submerchant_id(post, options)
add_transaction_type(post, options)
commit(:authorize, post)
@@ -153,6 +155,7 @@ def capture(amount, authorization, options={})
add_reference(post, authorization)
add_customer_data(post, options)
add_echo(post, options)
+ add_submerchant_id(post, options)
commit(:capture, post)
end
@@ -162,6 +165,7 @@ def void(authorization, options={})
add_customer_data(post, options)
reference_action = add_reference(post, authorization)
add_echo(post, options)
+ add_submerchant_id(post, options)
post[:a1] = generate_unique_id
commit(:void, post, reference_action)
@@ -173,6 +177,7 @@ def refund(amount, authorization, options={})
add_reference(post, authorization)
add_customer_data(post, options)
add_echo(post, options)
+ add_submerchant_id(post, options)
commit(:refund, post)
end
@@ -184,6 +189,7 @@ def credit(amount, payment_method, options={})
add_customer_data(post, options)
add_email(post, options)
add_echo(post, options)
+ add_submerchant_id(post, options)
add_transaction_type(post, options)
commit(:credit, post)
@@ -268,6 +274,10 @@ def add_echo(post, options)
post[:d2] = options[:echo] unless options[:echo].blank?
end
+ def add_submerchant_id(post, options)
+ post[:h3] = options[:submerchant_id] if options[:submerchant_id]
+ end
+
def add_transaction_type(post, options)
post[:a9] = options[:transaction_type] if options[:transaction_type]
end
diff --git a/test/unit/gateways/credorax_test.rb b/test/unit/gateways/credorax_test.rb
index 18eb1d1381d..c93b3987470 100644
--- a/test/unit/gateways/credorax_test.rb
+++ b/test/unit/gateways/credorax_test.rb
@@ -214,6 +214,15 @@ def test_adds_a9_field
end.respond_with(successful_purchase_response)
end
+ def test_adds_submerchant_id
+ @options[:submerchant_id] = '12345'
+ stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options)
+ end.check_request do |endpoint, data, headers|
+ assert_match(/h3=12345/, data)
+ end.respond_with(successful_purchase_response)
+ end
+
def test_supports_billing_descriptor
@options[:billing_descriptor] = 'abcdefghijkl'
stub_comms do
From 3989f79ea94b0d5d3cc2a75a717756aee1945977 Mon Sep 17 00:00:00 2001
From: dtykocki
Date: Mon, 8 Oct 2018 12:46:59 -0400
Subject: [PATCH 0173/2234] Worldpay: Pass stored credential option fields
In preparation for Visa card-on-file requirements.
WorldPay's documentation on this subject can be found at:
http://support.worldpay.com/support/kb/gg/corporate-gateway-guide/content/industryschemeextras/storedcredentials.htm
Closes #3041
Remote:
27 tests, 109 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
39 tests, 222 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/worldpay.rb | 11 ++
test/remote/gateways/remote_worldpay_test.rb | 105 +++++++++++++-----
test/unit/gateways/worldpay_test.rb | 15 +++
4 files changed, 103 insertions(+), 29 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 0f3b7d98826..8a56e45b2ae 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -19,6 +19,7 @@
* Realex: Add verify [kheang] #3030
* Braintree: Actually account for nil address fields [curiousepic] #3032
* Credorax: allow sending submerchant ID (h3 parameter) [bpollack] #3040
+* Worldpay: Pass stored credential option fields [curiousepic] #3041
== Version 1.85.0 (September 28, 2018)
* Authorize.Net: Support custom delimiter for cim [curiousepic] #3001
diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb
index bb06b90c88f..b758032d61f 100644
--- a/lib/active_merchant/billing/gateways/worldpay.rb
+++ b/lib/active_merchant/billing/gateways/worldpay.rb
@@ -248,10 +248,21 @@ def add_payment_method(xml, amount, payment_method, options)
xml.tag! 'session', 'shopperIPAddress' => options[:ip] if options[:ip]
xml.tag! 'session', 'id' => options[:session_id] if options[:session_id]
end
+ add_stored_credential_options(xml, options) if options[:stored_credential_usage]
end
end
end
+ def add_stored_credential_options(xml, options={})
+ if options[:stored_credential_initiated_reason]
+ xml.tag! 'storedCredentials', 'usage' => options[:stored_credential_usage], 'merchantInitiatedReason' => options[:stored_credential_initiated_reason] do
+ xml.tag! 'schemeTransactionIdentifier', options[:stored_credential_transaction_id] if options[:stored_credential_transaction_id]
+ end
+ else
+ xml.tag! 'storedCredentials', 'usage' => options[:stored_credential_usage]
+ end
+ end
+
def add_email(xml, options)
return unless options[:execute_threed] || options[:email]
xml.tag! 'shopper' do
diff --git a/test/remote/gateways/remote_worldpay_test.rb b/test/remote/gateways/remote_worldpay_test.rb
index c6f116a15c4..ff3c3b19ab9 100644
--- a/test/remote/gateways/remote_worldpay_test.rb
+++ b/test/remote/gateways/remote_worldpay_test.rb
@@ -11,7 +11,10 @@ def setup
@declined_card = credit_card('4111111111111111', :first_name => nil, :last_name => 'REFUSED')
@threeDS_card = credit_card('4111111111111111', :first_name => nil, :last_name => '3D')
- @options = {order_id: generate_unique_id, email: 'wow@example.com'}
+ @options = {
+ order_id: generate_unique_id,
+ email: 'wow@example.com'
+ }
end
def test_successful_purchase
@@ -44,8 +47,8 @@ def test_authorize_and_capture
assert_success auth
assert_equal 'SUCCESS', auth.message
assert auth.authorization
- sleep(40)
- assert capture = @gateway.capture(@amount, auth.authorization)
+
+ assert capture = @gateway.capture(@amount, auth.authorization, authorization_validated: true)
assert_success capture
end
@@ -53,15 +56,14 @@ def test_authorize_and_capture_by_reference
assert auth = @gateway.authorize(@amount, @credit_card, @options)
assert_success auth
assert_equal 'SUCCESS', auth.message
- sleep(40)
- assert capture = @gateway.capture(@amount, auth.authorization)
- assert_success capture
+ assert capture = @gateway.capture(@amount, auth.authorization, authorization_validated: true)
+ assert_success capture
assert reference = auth.authorization
@options[:order_id] = generate_unique_id
+
assert auth = @gateway.authorize(@amount, reference, @options)
- sleep(40)
- assert capture = @gateway.capture(@amount, auth.authorization)
+ assert capture = @gateway.capture(@amount, auth.authorization, authorization_validated: true)
assert_success capture
end
@@ -69,15 +71,15 @@ def test_authorize_and_purchase_by_reference
assert auth = @gateway.authorize(@amount, @credit_card, @options)
assert_success auth
assert_equal 'SUCCESS', auth.message
- sleep(40)
- assert capture = @gateway.capture(@amount, auth.authorization)
- assert_success capture
+ assert capture = @gateway.capture(@amount, auth.authorization, authorization_validated: true)
+ assert_success capture
assert reference = auth.authorization
+
@options[:order_id] = generate_unique_id
assert auth = @gateway.authorize(@amount, reference, @options)
+
@options[:order_id] = generate_unique_id
- sleep(40)
assert capture = @gateway.purchase(@amount, auth.authorization, @options)
assert_success capture
end
@@ -87,8 +89,8 @@ def test_authorize_and_purchase_with_instalments
assert_success auth
assert_equal 'SUCCESS', auth.message
assert auth.authorization
- sleep(40)
- assert capture = @gateway.capture(@amount, auth.authorization)
+
+ assert capture = @gateway.capture(@amount, auth.authorization, authorization_validated: true)
assert_success capture
end
@@ -113,6 +115,52 @@ def test_successful_authorize_with_3ds
refute first_message.params['session_id'].blank?
end
+ def test_successful_auth_and_capture_with_stored_cred_options
+ assert auth = @gateway.authorize(@amount, @credit_card, @options.merge(stored_credential_usage: 'FIRST'))
+ assert_success auth
+ assert auth.authorization
+ assert auth.params['scheme_response']
+ assert auth.params['transaction_identifier']
+
+ assert capture = @gateway.capture(@amount, auth.authorization, authorization_validated: true)
+ assert_success capture
+
+ options = @options.merge(
+ order_id: generate_unique_id,
+ stored_credential_usage: 'USED',
+ stored_credential_initiated_reason: 'UNSCHEDULED',
+ stored_credential_transaction_id: auth.params['transaction_identifier']
+ )
+ assert next_auth = @gateway.authorize(@amount, @credit_card, options)
+ assert next_auth.authorization
+ assert next_auth.params['scheme_response']
+ assert next_auth.params['transaction_identifier']
+
+ assert capture = @gateway.capture(@amount, next_auth.authorization, authorization_validated: true)
+ assert_success capture
+ end
+
+ # Fails currently because the sandbox doesn't actually validate the stored_credential options
+ # def test_failed_authorize_with_bad_stored_cred_options
+ # assert auth = @gateway.authorize(@amount, @credit_card, @options.merge(stored_credential_usage: 'FIRST'))
+ # assert_success auth
+ # assert auth.authorization
+ # assert auth.params['scheme_response']
+ # assert auth.params['transaction_identifier']
+ #
+ # assert capture = @gateway.capture(@amount, auth.authorization, authorization_validated: true)
+ # assert_success capture
+ #
+ # options = @options.merge(
+ # order_id: generate_unique_id,
+ # stored_credential_usage: 'MEH',
+ # stored_credential_initiated_reason: 'BLAH',
+ # stored_credential_transaction_id: 'nah'
+ # )
+ # assert next_auth = @gateway.authorize(@amount, @credit_card, options)
+ # assert_failure next_auth
+ # end
+
def test_failed_authorize_with_3ds
session_id = generate_unique_id
options = @options.merge(
@@ -153,9 +201,8 @@ def test_ip_address
end
def test_void
- assert_success(response = @gateway.authorize(@amount, @credit_card, @options))
- sleep(40)
- assert_success(void = @gateway.void(response.authorization))
+ assert_success response = @gateway.authorize(@amount, @credit_card, @options)
+ assert_success void = @gateway.void(response.authorization, authorization_validated: true)
assert_equal 'SUCCESS', void.message
assert void.params['cancel_received_order_code']
end
@@ -243,22 +290,22 @@ def test_transcript_scrubbing
# Worldpay has a delay between asking for a transaction to be captured and actually marking it as captured
# These 2 tests work if you get authorizations from a purchase, wait some time and then perform the refund/void operation.
- # def get_authorization
- # assert_success(response = @gateway.purchase(@amount, @credit_card, @options))
- # assert response.authorization
- # puts "auth: " + response.authorization
- # end
-
- # def test_refund
- # refund = @gateway.refund(@amount, 'replace_with_authorization')
- # assert_success refund
- # assert_equal "SUCCESS", refund.message
- # end
+ def test_get_authorization
+ response = @gateway.purchase(@amount, @credit_card, @options)
+ assert response.authorization
+ puts 'auth: ' + response.authorization
+ end
+ def test_refund
+ refund = @gateway.refund(@amount, '39270fd70be13aab55f84e28be45cad3')
+ assert_success refund
+ assert_equal 'SUCCESS', refund.message
+ end
+ #
# def test_void_fails_unless_status_is_authorised
# response = @gateway.void('replace_with_authorization') # existing transaction in CAPTURED state
# assert_failure response
- # assert_equal "A transaction status of 'AUTHORISED' is required.", response.message
+ # assert_equal 'A transaction status of 'AUTHORISED' is required.', response.message
# end
end
diff --git a/test/unit/gateways/worldpay_test.rb b/test/unit/gateways/worldpay_test.rb
index e40767eda0a..a5e6cb611d2 100644
--- a/test/unit/gateways/worldpay_test.rb
+++ b/test/unit/gateways/worldpay_test.rb
@@ -53,6 +53,21 @@ def test_authorize_passes_ip_and_session_id
assert_success response
end
+ def test_authorize_passes_stored_credential_options
+ options = @options.merge(
+ stored_credential_usage: 'USED',
+ stored_credential_initiated_reason: 'UNSCHEDULED',
+ stored_credential_transaction_id: '000000000000020005060720116005060'
+ )
+ response = stub_comms do
+ @gateway.authorize(@amount, @credit_card, options)
+ end.check_request do |endpoint, data, headers|
+ assert_match(//, data)
+ assert_match(/000000000000020005060720116005060\<\/schemeTransactionIdentifier\>/, data)
+ end.respond_with(successful_authorize_response)
+ assert_success response
+ end
+
def test_failed_authorize
response = stub_comms do
@gateway.authorize(@amount, @credit_card, @options)
From f87ecc4b61eea6021dbc3b9751c2bbedb25afa17 Mon Sep 17 00:00:00 2001
From: David Perry
Date: Fri, 9 Nov 2018 16:40:29 -0500
Subject: [PATCH 0174/2234] Worldpay: Re-comment remote test
---
test/remote/gateways/remote_worldpay_test.rb | 24 ++++++++++----------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/test/remote/gateways/remote_worldpay_test.rb b/test/remote/gateways/remote_worldpay_test.rb
index ff3c3b19ab9..64f7db2583b 100644
--- a/test/remote/gateways/remote_worldpay_test.rb
+++ b/test/remote/gateways/remote_worldpay_test.rb
@@ -289,18 +289,18 @@ def test_transcript_scrubbing
# Worldpay has a delay between asking for a transaction to be captured and actually marking it as captured
# These 2 tests work if you get authorizations from a purchase, wait some time and then perform the refund/void operation.
-
- def test_get_authorization
- response = @gateway.purchase(@amount, @credit_card, @options)
- assert response.authorization
- puts 'auth: ' + response.authorization
- end
-
- def test_refund
- refund = @gateway.refund(@amount, '39270fd70be13aab55f84e28be45cad3')
- assert_success refund
- assert_equal 'SUCCESS', refund.message
- end
+ #
+ # def test_get_authorization
+ # response = @gateway.purchase(@amount, @credit_card, @options)
+ # assert response.authorization
+ # puts 'auth: ' + response.authorization
+ # end
+ #
+ # def test_refund
+ # refund = @gateway.refund(@amount, '39270fd70be13aab55f84e28be45cad3')
+ # assert_success refund
+ # assert_equal 'SUCCESS', refund.message
+ # end
#
# def test_void_fails_unless_status_is_authorised
# response = @gateway.void('replace_with_authorization') # existing transaction in CAPTURED state
From 96b499e14c8fa2f31f9d1db65d019b3d01d887f5 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Mon, 12 Nov 2018 08:25:02 -0500
Subject: [PATCH 0175/2234] RuboCop: fix regression introduced in f87ecc4b61ee
---
test/remote/gateways/remote_worldpay_test.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/remote/gateways/remote_worldpay_test.rb b/test/remote/gateways/remote_worldpay_test.rb
index 64f7db2583b..f21d674f2a6 100644
--- a/test/remote/gateways/remote_worldpay_test.rb
+++ b/test/remote/gateways/remote_worldpay_test.rb
@@ -289,7 +289,7 @@ def test_transcript_scrubbing
# Worldpay has a delay between asking for a transaction to be captured and actually marking it as captured
# These 2 tests work if you get authorizations from a purchase, wait some time and then perform the refund/void operation.
- #
+ #
# def test_get_authorization
# response = @gateway.purchase(@amount, @credit_card, @options)
# assert response.authorization
From 7f16b1b3cb675ef8face489bd686c2e6de5a083b Mon Sep 17 00:00:00 2001
From: Lawrence Matacena
Date: Thu, 11 Oct 2018 04:55:58 -0400
Subject: [PATCH 0176/2234] Allow for CC number to be nil
These are some slight tweaks to 2bc749340f89, largely about restoring
the old, consistent behavior for CreditCardMethods#first_digits and
CreditCardMethods#last_digits.
Closes #3010
---
CHANGELOG | 2 ++
lib/active_merchant/billing/credit_card_methods.rb | 6 ++++--
test/unit/credit_card_methods_test.rb | 4 ++++
test/unit/credit_card_test.rb | 10 ++++++++++
4 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 8a56e45b2ae..8faf2ed2db4 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,8 @@
= ActiveMerchant CHANGELOG
== HEAD
+* Make behavior of nil CC numbers more consistent [guaguasi] #3010
+
== Version 1.86.0 (October 26, 2018)
* UsaEpayTransaction: Support UMcheckformat option for echecks [dtykocki] #3002
* Global Collect: handle internal server errors [molbrown] #3005
diff --git a/lib/active_merchant/billing/credit_card_methods.rb b/lib/active_merchant/billing/credit_card_methods.rb
index 67c80f5e5b1..05f07e46667 100644
--- a/lib/active_merchant/billing/credit_card_methods.rb
+++ b/lib/active_merchant/billing/credit_card_methods.rb
@@ -160,7 +160,7 @@ def brand?(number)
end
def electron?(number)
- return false unless [16, 19].include?(number.length)
+ return false unless [16, 19].include?(number&.length)
# don't recalculate for each range
bank_identification_number = first_digits(number).to_i
@@ -176,7 +176,7 @@ def type?(number)
end
def first_digits(number)
- number.slice(0,6)
+ number&.slice(0, 6) || ''
end
def last_digits(number)
@@ -201,10 +201,12 @@ def matching_type?(number, brand)
private
def valid_card_number_length?(number) #:nodoc:
+ return false if number.nil?
number.length >= 12
end
def valid_card_number_characters?(number) #:nodoc:
+ return false if number.nil?
!number.match(/\D/)
end
diff --git a/test/unit/credit_card_methods_test.rb b/test/unit/credit_card_methods_test.rb
index 831359b9636..da6211e1a7f 100644
--- a/test/unit/credit_card_methods_test.rb
+++ b/test/unit/credit_card_methods_test.rb
@@ -167,6 +167,7 @@ def test_matching_discover_card
def test_matching_invalid_card
assert_nil CreditCard.brand?('XXXXXXXXXXXX0000')
assert_false CreditCard.valid_number?('XXXXXXXXXXXX0000')
+ assert_false CreditCard.valid_number?(nil)
end
def test_16_digit_maestro_uk
@@ -213,6 +214,9 @@ def test_electron_cards
end
end
+ # nil check
+ assert_false electron_test.call(nil)
+
# Visa range
assert_false electron_test.call('4245180000000000')
assert_false electron_test.call('4918810000000000')
diff --git a/test/unit/credit_card_test.rb b/test/unit/credit_card_test.rb
index 5c2f1eb6b50..40702473604 100644
--- a/test/unit/credit_card_test.rb
+++ b/test/unit/credit_card_test.rb
@@ -246,6 +246,16 @@ def test_bogus_last_digits
assert_equal '1', ccn.last_digits
end
+ def test_should_return_empty_string_for_first_digits_of_nil_card_number
+ ccn = CreditCard.new
+ assert_equal '', ccn.first_digits
+ end
+
+ def test_should_return_empty_string_for_last_digits_of_nil_card_number
+ ccn = CreditCard.new
+ assert_equal '', ccn.last_digits
+ end
+
def test_should_return_first_four_digits_of_card_number
ccn = CreditCard.new(:number => '4779139500118580')
assert_equal '477913', ccn.first_digits
From 83f89368f1f7c80dbf2e87b4d4a6aecfe307dbf3 Mon Sep 17 00:00:00 2001
From: DeeDee Lavinder
Date: Sat, 10 Nov 2018 23:24:24 -0500
Subject: [PATCH 0177/2234] Moneris: Adds Credential On File Logic
This allows Credential On File information to be passed in the options
hash. `cof_enabled` must be set to `true`. Values for the three
CoF fields: `issuer_id`, `payment_indicator`, and `payment_information`
must also be included.
Unit Tests:
37 tests, 188 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
Remote Tests:
29 tests, 114 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/moneris.rb | 115 ++++++++------
test/remote/gateways/remote_moneris_test.rb | 80 +++++++---
test/unit/gateways/moneris_test.rb | 149 +++++++++++++++++-
4 files changed, 279 insertions(+), 66 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 8faf2ed2db4..04d7ba4ca8f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,7 @@
== HEAD
* Make behavior of nil CC numbers more consistent [guaguasi] #3010
+* Moneris: Adds Credential on File logic [deedeelavinder] #3042
== Version 1.86.0 (October 26, 2018)
* UsaEpayTransaction: Support UMcheckformat option for echecks [dtykocki] #3002
diff --git a/lib/active_merchant/billing/gateways/moneris.rb b/lib/active_merchant/billing/gateways/moneris.rb
index 97c3d6cbc63..a92f567ec7a 100644
--- a/lib/active_merchant/billing/gateways/moneris.rb
+++ b/lib/active_merchant/billing/gateways/moneris.rb
@@ -33,7 +33,8 @@ def initialize(options = {})
requires!(options, :login, :password)
@cvv_enabled = options[:cvv_enabled]
@avs_enabled = options[:avs_enabled]
- options = { :crypt_type => 7 }.merge(options)
+ @cof_enabled = options[:cof_enabled]
+ options[:crypt_type] = 7 unless options.has_key?(:crypt_type)
super
end
@@ -46,17 +47,18 @@ def authorize(money, creditcard_or_datakey, options = {})
requires!(options, :order_id)
post = {}
add_payment_source(post, creditcard_or_datakey, options)
- post[:amount] = amount(money)
- post[:order_id] = options[:order_id]
- post[:address] = options[:billing_address] || options[:address]
+ post[:amount] = amount(money)
+ post[:order_id] = options[:order_id]
+ post[:address] = options[:billing_address] || options[:address]
post[:crypt_type] = options[:crypt_type] || @options[:crypt_type]
+ add_cof(post, options) if @cof_enabled
action = if post[:cavv]
'cavv_preauth'
elsif post[:data_key].blank?
'preauth'
else
'res_preauth_cc'
- end
+ end
commit(action, post)
end
@@ -68,17 +70,18 @@ def purchase(money, creditcard_or_datakey, options = {})
requires!(options, :order_id)
post = {}
add_payment_source(post, creditcard_or_datakey, options)
- post[:amount] = amount(money)
- post[:order_id] = options[:order_id]
- post[:address] = options[:billing_address] || options[:address]
+ post[:amount] = amount(money)
+ post[:order_id] = options[:order_id]
+ post[:address] = options[:billing_address] || options[:address]
post[:crypt_type] = options[:crypt_type] || @options[:crypt_type]
+ add_cof(post, options) if @cof_enabled
action = if post[:cavv]
'cavv_purchase'
elsif post[:data_key].blank?
'purchase'
else
'res_purchase_cc'
- end
+ end
commit(action, post)
end
@@ -182,16 +185,16 @@ def expdate(creditcard)
def add_payment_source(post, payment_method, options)
if payment_method.is_a?(String)
- post[:data_key] = payment_method
- post[:cust_id] = options[:customer]
+ post[:data_key] = payment_method
+ post[:cust_id] = options[:customer]
else
if payment_method.respond_to?(:track_data) && payment_method.track_data.present?
- post[:pos_code] = '00'
- post[:track2] = payment_method.track_data
+ post[:pos_code] = '00'
+ post[:track2] = payment_method.track_data
else
- post[:pan] = payment_method.number
- post[:expdate] = expdate(payment_method)
- post[:cvd_value] = payment_method.verification_value if payment_method.verification_value?
+ post[:pan] = payment_method.number
+ post[:expdate] = expdate(payment_method)
+ post[:cvd_value] = payment_method.verification_value if payment_method.verification_value?
post[:cavv] = payment_method.payment_cryptogram if payment_method.is_a?(NetworkTokenizationCreditCard)
post[:wallet_indicator] = wallet_indicator(payment_method.source.to_s) if payment_method.is_a?(NetworkTokenizationCreditCard)
post[:crypt_type] = (payment_method.eci || 7) if payment_method.is_a?(NetworkTokenizationCreditCard)
@@ -200,6 +203,12 @@ def add_payment_source(post, payment_method, options)
end
end
+ def add_cof(post, options)
+ post[:issuer_id] = options[:issuer_id] if options[:issuer_id]
+ post[:payment_indicator] = options[:payment_indicator] if options[:payment_indicator]
+ post[:payment_information] = options[:payment_information] if options[:payment_information]
+ end
+
# Common params used amongst the +credit+, +void+ and +capture+ methods
def crediting_params(authorization, options = {})
{
@@ -225,12 +234,14 @@ def commit(action, parameters = {})
raw = ssl_post(url, data)
response = parse(raw)
- Response.new(successful?(response), message_from(response[:message]), response,
- :test => test?,
- :avs_result => { :code => response[:avs_result_code] },
- :cvv_result => response[:cvd_result_code] && response[:cvd_result_code][-1,1],
- :authorization => authorization_from(response)
- )
+ Response.new(
+ successful?(response),
+ message_from(response[:message]),
+ response,
+ :test => test?,
+ :avs_result => {:code => response[:avs_result_code]},
+ :cvv_result => response[:cvd_result_code] && response[:cvd_result_code][-1, 1],
+ :authorization => authorization_from(response))
end
# Generates a Moneris authorization string of the form 'trans_id;receipt_id'.
@@ -262,9 +273,9 @@ def hashify_xml!(xml, response)
end
def post_data(action, parameters = {})
- xml = REXML::Document.new
- root = xml.add_element('request')
- root.add_element('store_id').text = options[:login]
+ xml = REXML::Document.new
+ root = xml.add_element('request')
+ root.add_element('store_id').text = options[:login]
root.add_element('api_token').text = options[:password]
root.add_element(transaction_element(action, parameters))
@@ -281,6 +292,8 @@ def transaction_element(action, parameters)
transaction.add_element(avs_element(parameters[:address])) if @avs_enabled && parameters[:address]
when :cvd_info
transaction.add_element(cvd_element(parameters[:cvd_value])) if @cvv_enabled
+ when :cof_info
+ transaction.add_element(credential_on_file(parameters)) if @cof_enabled
else
transaction.add_element(key.to_s).text = parameters[key] unless parameters[key].blank?
end
@@ -294,8 +307,8 @@ def avs_element(address)
tokens = full_address.split(/\s+/)
element = REXML::Element.new('avs_info')
- element.add_element('avs_street_number').text = tokens.select{|x| x =~ /\d/}.join(' ')
- element.add_element('avs_street_name').text = tokens.reject{|x| x =~ /\d/}.join(' ')
+ element.add_element('avs_street_number').text = tokens.select {|x| x =~ /\d/}.join(' ')
+ element.add_element('avs_street_name').text = tokens.reject {|x| x =~ /\d/}.join(' ')
element.add_element('avs_zipcode').text = address[:zip]
element
end
@@ -311,6 +324,18 @@ def cvd_element(cvd_value)
element
end
+ def credential_on_file(parameters)
+ issuer_id = parameters[:issuer_id] || ''
+ payment_indicator = parameters[:payment_indicator] if parameters[:payment_indicator]
+ payment_information = parameters[:payment_information] if parameters[:payment_information]
+
+ cof_info = REXML::Element.new('cof_info')
+ cof_info.add_element('issuer_id').text = issuer_id
+ cof_info.add_element('payment_indicator').text = payment_indicator
+ cof_info.add_element('payment_information').text = payment_information
+ cof_info
+ end
+
def wallet_indicator(token_source)
return 'APP' if token_source == 'apple_pay'
return 'ANP' if token_source == 'android_pay'
@@ -324,24 +349,24 @@ def message_from(message)
def actions
{
- 'purchase' => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type, :avs_info, :cvd_info, :track2, :pos_code],
- 'preauth' => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type, :avs_info, :cvd_info, :track2, :pos_code],
- 'command' => [:order_id],
- 'refund' => [:order_id, :amount, :txn_number, :crypt_type],
- 'indrefund' => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type],
- 'completion' => [:order_id, :comp_amount, :txn_number, :crypt_type],
- 'purchasecorrection' => [:order_id, :txn_number, :crypt_type],
- 'cavv_preauth' => [:order_id, :cust_id, :amount, :pan, :expdate, :cavv, :crypt_type, :wallet_indicator],
- 'cavv_purchase' => [:order_id, :cust_id, :amount, :pan, :expdate, :cavv, :crypt_type, :wallet_indicator],
- 'transact' => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type],
- 'Batchcloseall' => [],
- 'opentotals' => [:ecr_number],
- 'batchclose' => [:ecr_number],
- 'res_add_cc' => [:pan, :expdate, :crypt_type],
- 'res_delete' => [:data_key],
- 'res_update_cc' => [:data_key, :pan, :expdate, :crypt_type],
- 'res_purchase_cc' => [:data_key, :order_id, :cust_id, :amount, :crypt_type],
- 'res_preauth_cc' => [:data_key, :order_id, :cust_id, :amount, :crypt_type]
+ 'purchase' => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type, :avs_info, :cvd_info, :track2, :pos_code, :cof_info],
+ 'preauth' => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type, :avs_info, :cvd_info, :track2, :pos_code, :cof_info],
+ 'command' => [:order_id],
+ 'refund' => [:order_id, :amount, :txn_number, :crypt_type],
+ 'indrefund' => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type],
+ 'completion' => [:order_id, :comp_amount, :txn_number, :crypt_type],
+ 'purchasecorrection' => [:order_id, :txn_number, :crypt_type],
+ 'cavv_preauth' => [:order_id, :cust_id, :amount, :pan, :expdate, :cavv, :crypt_type, :wallet_indicator],
+ 'cavv_purchase' => [:order_id, :cust_id, :amount, :pan, :expdate, :cavv, :crypt_type, :wallet_indicator],
+ 'transact' => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type],
+ 'Batchcloseall' => [],
+ 'opentotals' => [:ecr_number],
+ 'batchclose' => [:ecr_number],
+ 'res_add_cc' => [:pan, :expdate, :crypt_type, :cof_info],
+ 'res_delete' => [:data_key],
+ 'res_update_cc' => [:data_key, :pan, :expdate, :crypt_type],
+ 'res_purchase_cc' => [:data_key, :order_id, :cust_id, :amount, :crypt_type, :cof_info],
+ 'res_preauth_cc' => [:data_key, :order_id, :cust_id, :amount, :crypt_type, :cof_info]
}
end
end
diff --git a/test/remote/gateways/remote_moneris_test.rb b/test/remote/gateways/remote_moneris_test.rb
index 060ad177255..27da8f7271c 100644
--- a/test/remote/gateways/remote_moneris_test.rb
+++ b/test/remote/gateways/remote_moneris_test.rb
@@ -8,9 +8,9 @@ def setup
@amount = 100
@credit_card = credit_card('4242424242424242')
@options = {
- :order_id => generate_unique_id,
- :customer => generate_unique_id,
- :billing_address => address
+ :order_id => generate_unique_id,
+ :customer => generate_unique_id,
+ :billing_address => address
}
end
@@ -21,8 +21,48 @@ def test_successful_purchase
assert_false response.authorization.blank?
end
+ def test_successful_first_purchase_with_credential_on_file
+ gateway = MonerisGateway.new(fixtures(:moneris).merge(cof_enabled: true))
+ assert response = gateway.purchase(@amount, @credit_card, @options.merge(issuer_id: '', payment_indicator: 'C', payment_information: '0'))
+ assert_success response
+ assert_equal 'Approved', response.message
+ assert_false response.authorization.blank?
+ assert_not_empty response.params['issuer_id']
+ end
+
+ def test_successful_subsequent_purchase_with_credential_on_file
+ gateway = MonerisGateway.new(fixtures(:moneris).merge(cof_enabled: true))
+ assert response = gateway.authorize(
+ @amount,
+ @credit_card,
+ @options.merge(
+ issuer_id: '',
+ payment_indicator: 'C',
+ payment_information: '0'
+ )
+ )
+ assert_success response
+ assert_equal 'Approved', response.message
+ assert_false response.authorization.blank?
+
+ assert response2 = gateway.purchase(
+ @amount,
+ @credit_card,
+ @options.merge(
+ order_id: response.authorization,
+ issuer_id: response.params['issuer_id'],
+ payment_indicator: 'U',
+ payment_information: '2'
+ )
+ )
+ assert_success response2
+ assert_equal 'Approved', response2.message
+ assert_false response2.authorization.blank?
+ end
+
def test_successful_purchase_with_network_tokenization
- @credit_card = network_tokenization_credit_card('4242424242424242',
+ @credit_card = network_tokenization_credit_card(
+ '4242424242424242',
payment_cryptogram: 'BwABB4JRdgAAAAAAiFF2AAAAAAA=',
verification_value: nil
)
@@ -33,7 +73,8 @@ def test_successful_purchase_with_network_tokenization
end
def test_successful_purchase_with_network_tokenization_apple_pay_source
- @credit_card = network_tokenization_credit_card('4242424242424242',
+ @credit_card = network_tokenization_credit_card(
+ '4242424242424242',
payment_cryptogram: 'BwABB4JRdgAAAAAAiFF2AAAAAAA=',
verification_value: nil,
source: :apple_pay
@@ -86,7 +127,8 @@ def test_successful_authorization_and_void
end
def test_successful_authorization_with_network_tokenization
- @credit_card = network_tokenization_credit_card('4242424242424242',
+ @credit_card = network_tokenization_credit_card(
+ '4242424242424242',
payment_cryptogram: 'BwABB4JRdgAAAAAAiFF2AAAAAAA=',
verification_value: nil
)
@@ -202,23 +244,23 @@ def test_avs_result_valid_when_enabled
assert response = gateway.purchase(1010, @credit_card, @options)
assert_success response
assert_equal(response.avs_result, {
- 'code' => 'A',
- 'message' => 'Street address matches, but 5-digit and 9-digit postal code do not match.',
- 'street_match' => 'Y',
- 'postal_match' => 'N'
+ 'code' => 'A',
+ 'message' => 'Street address matches, but 5-digit and 9-digit postal code do not match.',
+ 'street_match' => 'Y',
+ 'postal_match' => 'N'
})
end
def test_avs_result_nil_when_address_absent
gateway = MonerisGateway.new(fixtures(:moneris).merge(avs_enabled: true))
- assert response = gateway.purchase(1010, @credit_card, @options.tap { |x| x.delete(:billing_address) })
+ assert response = gateway.purchase(1010, @credit_card, @options.tap {|x| x.delete(:billing_address)})
assert_success response
assert_equal(response.avs_result, {
- 'code' => nil,
- 'message' => nil,
- 'street_match' => nil,
- 'postal_match' => nil
+ 'code' => nil,
+ 'message' => nil,
+ 'street_match' => nil,
+ 'postal_match' => nil
})
end
@@ -226,10 +268,10 @@ def test_avs_result_nil_when_efraud_disabled
assert response = @gateway.purchase(@amount, @credit_card, @options)
assert_success response
assert_equal(response.avs_result, {
- 'code' => nil,
- 'message' => nil,
- 'street_match' => nil,
- 'postal_match' => nil
+ 'code' => nil,
+ 'message' => nil,
+ 'street_match' => nil,
+ 'postal_match' => nil
})
end
diff --git a/test/unit/gateways/moneris_test.rb b/test/unit/gateways/moneris_test.rb
index 084bc5c84ca..a4144b398d5 100644
--- a/test/unit/gateways/moneris_test.rb
+++ b/test/unit/gateways/moneris_test.rb
@@ -7,7 +7,7 @@ def setup
Base.mode = :test
@gateway = MonerisGateway.new(
- :login => 'store1',
+ :login => 'store3',
:password => 'yesguy'
)
@@ -18,7 +18,7 @@ def setup
def test_default_options
assert_equal 7, @gateway.options[:crypt_type]
- assert_equal 'store1', @gateway.options[:login]
+ assert_equal 'store3', @gateway.options[:login]
assert_equal 'yesguy', @gateway.options[:password]
end
@@ -30,6 +30,65 @@ def test_successful_purchase
assert_equal '58-0_3;1026.1', response.authorization
end
+ def test_successful_first_purchase_with_credential_on_file
+ gateway = MonerisGateway.new(
+ :login => 'store3',
+ :password => 'yesguy',
+ :cof_enabled => true
+ )
+ gateway.expects(:ssl_post).returns(successful_first_cof_purchase_response)
+ assert response = gateway.purchase(
+ @amount,
+ @credit_card,
+ @options.merge(
+ issuer_id: '',
+ payment_indicator: 'C',
+ payment_information: '0'
+ )
+ )
+ assert_success response
+ assert_equal 'Approved', response.message
+ assert_false response.authorization.blank?
+ assert_not_empty response.params['issuer_id']
+ end
+
+ def test_successful_subsequent_purchase_with_credential_on_file
+ gateway = MonerisGateway.new(
+ :login => 'store3',
+ :password => 'yesguy',
+ :cof_enabled => true
+ )
+ gateway.expects(:ssl_post).returns(successful_first_cof_authorize_response)
+ assert response = gateway.authorize(
+ @amount,
+ @credit_card,
+ @options.merge(
+ issuer_id: '',
+ payment_indicator: 'C',
+ payment_information: '0'
+ )
+ )
+ assert_success response
+ assert_equal 'Approved', response.message
+ assert_false response.authorization.blank?
+
+ gateway.expects(:ssl_post).returns(successful_subsequent_cof_purchase_response)
+
+ assert response2 = gateway.purchase(
+ @amount,
+ @credit_card,
+ @options.merge(
+ order_id: response.authorization,
+ issuer_id: response.params['issuer_id'],
+ payment_indicator: 'U',
+ payment_information: '2'
+ )
+ )
+ assert_success response2
+ assert_equal 'Approved', response2.message
+ assert_false response2.authorization.blank?
+ end
+
def test_successful_purchase_with_network_tokenization
@gateway.expects(:ssl_post).returns(successful_purchase_network_tokenization)
@credit_card = network_tokenization_credit_card('4242424242424242',
@@ -360,6 +419,92 @@ def successful_purchase_response
RESPONSE
end
+ def successful_first_cof_purchase_response
+ <<-RESPONSE
+
+
+
+
+ a33ba7edd448b91ef8d2f85fea614b8d
+ 660114080015099160
+ 027
+ 01
+ 822665
+ 07:43:28
+ 2018-11-11
+ 00
+ true
+ APPROVED * =
+ 1.00
+ V
+ 799655-0_11
+ false
+ null
+ null
+ 355689484440192
+ false
+
+
+ RESPONSE
+ end
+
+ def successful_first_cof_authorize_response
+ <<-RESPONSE
+
+
+
+ 8dbc28468af2007779bbede7ec1bab6c
+ 660109300018229130
+ 027
+ 01
+ 718280
+ 07:50:53
+ 2018-11-11
+ 01
+ true
+ APPROVED * =
+ 1.00
+ V
+ 830724-0_11
+ false
+ null
+ null
+ 1A8315282537312
+ 550923784451193
+ false
+
+
+ RESPONSE
+ end
+
+ def successful_subsequent_cof_purchase_response
+ <<-RESPONSE
+
+
+
+ 830724-0_11;8dbc28468af2007779bbede7ec1bab6c
+ 660109490014038930
+ 027
+ 01
+ 111234
+ 07:50:54
+ 2018-11-11
+ 00
+ true
+ APPROVED * =
+ 1.00
+ V
+ 455422-0_11
+ false
+ null
+ null
+ 762097792112819
+ false
+
+
+ RESPONSE
+ end
+
def successful_purchase_network_tokenization
<<-RESPONSE
From 2059d31765d9f237b05d21b51a45d41e00696eeb Mon Sep 17 00:00:00 2001
From: Niaja
Date: Mon, 12 Nov 2018 14:06:16 -0500
Subject: [PATCH 0178/2234] Adyen: Return AVS and CVC Result
Returns the result of avs and cvc in the response if it is provided.
Loaded suite test/unit/gateways/adyen_test
........................
24 tests, 115 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
----------------------------------------------------------------------------------------
Loaded suite test/remote/gateways/remote_adyen_test
....................................
36 tests, 90 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/adyen.rb | 45 ++++++++++++++++++-
test/remote/gateways/remote_adyen_test.rb | 12 ++---
test/unit/gateways/adyen_test.rb | 7 +++
4 files changed, 57 insertions(+), 8 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 04d7ba4ca8f..10dd14af650 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -3,6 +3,7 @@
== HEAD
* Make behavior of nil CC numbers more consistent [guaguasi] #3010
* Moneris: Adds Credential on File logic [deedeelavinder] #3042
+* Adyen: Return AVS and CVC Result [nfarve] #3044
== Version 1.86.0 (October 26, 2018)
* UsaEpayTransaction: Support UMcheckformat option for echecks [dtykocki] #3002
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index a73e0b92860..7aef6d0fbc1 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -103,6 +103,38 @@ def scrub(transcript)
private
+ AVS_MAPPING = {
+ '0' => 'R', # Unknown
+ '1' => 'A', # Address matches, postal code doesn't
+ '2' => 'N', # Neither postal code nor address match
+ '3' => 'R', # AVS unavailable
+ '4' => 'E', # AVS not supported for this card type
+ '5' => 'U', # No AVS data provided
+ '6' => 'Z', # Postal code matches, address doesn't match
+ '7' => 'D', # Both postal code and address match
+ '8' => 'U', # Address not checked, postal code unknown
+ '9' => 'B', # Address matches, postal code unknown
+ '10' => 'N', # Address doesn't match, postal code unknown
+ '11' => 'U', # Postal code not checked, address unknown
+ '12' => 'B', # Address matches, postal code not checked
+ '13' => 'U', # Address doesn't match, postal code not checked
+ '14' => 'P', # Postal code matches, address unknown
+ '15' => 'P', # Postal code matches, address not checked
+ '16' => 'N', # Postal code doesn't match, address unknown
+ '17' => 'U', # Postal code doesn't match, address not checked
+ '18' => 'I' # Neither postal code nor address were checked
+ }
+
+ CVC_MAPPING = {
+ '0' => 'P', # Unknown
+ '1' => 'M', # Matches
+ '2' => 'N', # Does not match
+ '3' => 'P', # Not checked
+ '4' => 'S', # No CVC/CVV provided, but was required
+ '5' => 'U', # Issuer not certifed by CVC/CVV
+ '6' => 'P' # No CVC/CVV provided
+ }
+
NETWORK_TOKENIZATION_CARD_SOURCE = {
'apple_pay' => 'applepay',
'android_pay' => 'androidpay',
@@ -239,7 +271,6 @@ def commit(action, parameters)
raw_response = e.response.body
response = parse(raw_response)
end
-
success = success_from(action, response)
Response.new(
success,
@@ -247,10 +278,20 @@ def commit(action, parameters)
response,
authorization: authorization_from(action, parameters, response),
test: test?,
- error_code: success ? nil : error_code_from(response)
+ error_code: success ? nil : error_code_from(response),
+ avs_result: AVSResult.new(:code => avs_code_from(response)),
+ cvv_result: CVVResult.new(cvv_result_from(response))
)
end
+ def avs_code_from(response)
+ AVS_MAPPING[response['additionalData']['avsResult'][0..1].strip] if response.dig('additionalData', 'avsResult')
+ end
+
+ def cvv_result_from(response)
+ CVC_MAPPING[response['additionalData']['cvcResult'][0]] if response.dig('additionalData', 'cvcResult')
+ end
+
def url
if test?
test_url
diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb
index 0ba48c81be2..d9f2bfead67 100644
--- a/test/remote/gateways/remote_adyen_test.rb
+++ b/test/remote/gateways/remote_adyen_test.rb
@@ -7,8 +7,8 @@ def setup
@amount = 100
@credit_card = credit_card('4111111111111111',
- :month => 8,
- :year => 2018,
+ :month => 10,
+ :year => 2020,
:first_name => 'John',
:last_name => 'Smith',
:verification_value => '737',
@@ -63,7 +63,7 @@ def test_successful_authorize
def test_failed_authorize
response = @gateway.authorize(@amount, @declined_card, @options)
assert_failure response
- assert_equal 'CVC Declined', response.message
+ assert_equal 'Refused', response.message
end
def test_successful_purchase
@@ -108,7 +108,7 @@ def test_successful_purchase_with_google_pay
def test_failed_purchase
response = @gateway.purchase(@amount, @declined_card, @options)
assert_failure response
- assert_equal 'CVC Declined', response.message
+ assert_equal 'Refused', response.message
end
def test_successful_authorize_and_capture
@@ -184,7 +184,7 @@ def test_failed_store
assert response = @gateway.store(@declined_card, @options)
assert_failure response
- assert_equal 'CVC Declined', response.message
+ assert_equal 'Refused', response.message
end
def test_successful_purchase_using_stored_card
@@ -214,7 +214,7 @@ def test_successful_verify
def test_failed_verify
response = @gateway.verify(@declined_card, @options)
assert_failure response
- assert_match 'CVC Declined', response.message
+ assert_match 'Refused', response.message
end
def test_invalid_login
diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb
index 053b160516a..abfdee32e92 100644
--- a/test/unit/gateways/adyen_test.rb
+++ b/test/unit/gateways/adyen_test.rb
@@ -64,6 +64,8 @@ def test_successful_authorize
assert_success response
assert_equal '#7914775043909934#', response.authorization
+ assert_equal 'R', response.avs_result['code']
+ assert_equal 'M', response.cvv_result['code']
assert response.test?
end
@@ -418,6 +420,11 @@ def failed_purchase_response
def successful_authorize_response
<<-RESPONSE
{
+ "additionalData": {
+ "cvcResult": "1 Matches",
+ "avsResult": "0 Unknown",
+ "cvcResultRaw": "M"
+ },
"pspReference":"7914775043909934",
"resultCode":"Authorised",
"authCode":"50055"
From f2e0acff44609b60f0cda49537aa583410bcc561 Mon Sep 17 00:00:00 2001
From: DeeDee Lavinder
Date: Tue, 13 Nov 2018 11:14:43 -0500
Subject: [PATCH 0179/2234] Moneris: fix remote test creds
Remote: 29 tests, 114 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
test/fixtures.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/fixtures.yml b/test/fixtures.yml
index d5dc2626ca6..f1de6db6807 100644
--- a/test/fixtures.yml
+++ b/test/fixtures.yml
@@ -520,7 +520,7 @@ monei:
# Working credentials, no need to replace
moneris:
- login: store1
+ login: store3
password: yesguy
moneris_us:
From 03055385c5875334dce29a43969ec60b09ae1a5a Mon Sep 17 00:00:00 2001
From: molbrown
Date: Mon, 12 Nov 2018 10:36:05 -0500
Subject: [PATCH 0180/2234] Paymentez: Supports phone field, does not send if
empty
Unit:
19 tests, 77 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
19 tests, 35 assertions, 6 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
68.4211% passed
These failures due to `The method authorize is not supported by carrier`.
Country credentials used for testing do not support authorize. Unrelated.
Closes #3043
---
CHANGELOG | 1 +
.../billing/gateways/paymentez.rb | 3 ++
test/remote/gateways/remote_paymentez_test.rb | 30 +++++++++++++++++--
3 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 10dd14af650..80d1de5d7db 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -24,6 +24,7 @@
* Braintree: Actually account for nil address fields [curiousepic] #3032
* Credorax: allow sending submerchant ID (h3 parameter) [bpollack] #3040
* Worldpay: Pass stored credential option fields [curiousepic] #3041
+* Paymentez: Supports phone field, does not send if empty [molbrown] #3043
== Version 1.85.0 (September 28, 2018)
* Authorize.Net: Support custom delimiter for cim [curiousepic] #3001
diff --git a/lib/active_merchant/billing/gateways/paymentez.rb b/lib/active_merchant/billing/gateways/paymentez.rb
index af73e15b31c..cbdaa48d867 100644
--- a/lib/active_merchant/billing/gateways/paymentez.rb
+++ b/lib/active_merchant/billing/gateways/paymentez.rb
@@ -134,6 +134,9 @@ def add_customer_data(post, options)
post[:user][:email] = options[:email]
post[:user][:ip_address] = options[:ip] if options[:ip]
post[:user][:fiscal_number] = options[:fiscal_number] if options[:fiscal_number]
+ if phone = options[:phone] || options.dig(:billing_address, :phone)
+ post[:user][:phone] = phone
+ end
end
def add_invoice(post, money, options)
diff --git a/test/remote/gateways/remote_paymentez_test.rb b/test/remote/gateways/remote_paymentez_test.rb
index b6c2fca7173..a09a19f1581 100644
--- a/test/remote/gateways/remote_paymentez_test.rb
+++ b/test/remote/gateways/remote_paymentez_test.rb
@@ -5,8 +5,8 @@ def setup
@gateway = PaymentezGateway.new(fixtures(:paymentez))
@amount = 100
- @credit_card = credit_card('4111111111111111', verification_value: '555')
- @declined_card = credit_card('4242424242424242', verification_value: '555')
+ @credit_card = credit_card('4111111111111111', verification_value: '666')
+ @declined_card = credit_card('4242424242424242', verification_value: '666')
@options = {
billing_address: address,
description: 'Store Purchase',
@@ -23,6 +23,32 @@ def test_successful_purchase
end
def test_successful_purchase_with_more_options
+ options = {
+ order_id: '1',
+ ip: '127.0.0.1',
+ tax_percentage: 0.07,
+ phone: '333 333 3333'
+ }
+
+ response = @gateway.purchase(@amount, @credit_card, @options.merge(options))
+ assert_success response
+ end
+
+ def test_successful_purchase_without_phone_billing_address_option
+ options = {
+ order_id: '1',
+ ip: '127.0.0.1',
+ tax_percentage: 0.07,
+ billing_address: {
+ phone: nil
+ }
+ }
+
+ response = @gateway.purchase(@amount, @credit_card, @options.merge(options))
+ assert_success response
+ end
+
+ def test_successful_purchase_without_phone_option
options = {
order_id: '1',
ip: '127.0.0.1',
From 5dad76ca2fd20d1498b8e7c1c2ccd74380dac391 Mon Sep 17 00:00:00 2001
From: David Perry
Date: Tue, 13 Nov 2018 16:16:16 -0500
Subject: [PATCH 0181/2234] Braintree: Account for nil address with existing
customer
The prior fix only worked for naive first-time stores. Now it's also
used when adding a card to an existing customer profile.
Closes #3407
Remote:
66 tests, 378 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
57 tests, 150 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/braintree_blue.rb | 5 +-
.../gateways/remote_braintree_blue_test.rb | 50 +++++++++++++++++++
test/unit/gateways/braintree_blue_test.rb | 36 +++++++++++++
4 files changed, 91 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 80d1de5d7db..c1a9e5d5161 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -4,6 +4,7 @@
* Make behavior of nil CC numbers more consistent [guaguasi] #3010
* Moneris: Adds Credential on File logic [deedeelavinder] #3042
* Adyen: Return AVS and CVC Result [nfarve] #3044
+* Braintree: Account for nil address with existing customer [curiousepic] #3047
== Version 1.86.0 (October 26, 2018)
* UsaEpayTransaction: Support UMcheckformat option for echecks [dtykocki] #3002
diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb
index 0669b444b8b..f660e41f64a 100644
--- a/lib/active_merchant/billing/gateways/braintree_blue.rb
+++ b/lib/active_merchant/billing/gateways/braintree_blue.rb
@@ -259,7 +259,10 @@ def add_credit_card_to_customer(credit_card, options)
expiration_year: credit_card.year.to_s,
device_data: options[:device_data],
}
- parameters[:billing_address] = map_address(options[:billing_address]) if options[:billing_address]
+ if options[:billing_address]
+ address = map_address(options[:billing_address])
+ parameters[:credit_card][:billing_address] = address unless address.all? { |_k, v| v.nil? }
+ end
result = @braintree_gateway.credit_card.create(parameters)
ActiveMerchant::Billing::Response.new(
diff --git a/test/remote/gateways/remote_braintree_blue_test.rb b/test/remote/gateways/remote_braintree_blue_test.rb
index 7ae338e81ca..db3c1fbd6db 100644
--- a/test/remote/gateways/remote_braintree_blue_test.rb
+++ b/test/remote/gateways/remote_braintree_blue_test.rb
@@ -38,6 +38,27 @@ def test_successful_authorize
assert_equal 'authorized', response.params['braintree_transaction']['status']
end
+ def test_successful_authorize_with_nil_billing_address_options
+ credit_card = credit_card('5105105105105100')
+ options = {
+ :billing_address => {
+ :name => 'John Smith',
+ :phone => '123-456-7890',
+ :company => nil,
+ :address1 => nil,
+ :address2 => nil,
+ :city => nil,
+ :state => nil,
+ :zip => nil,
+ :country_name => nil
+ }
+ }
+ assert response = @gateway.authorize(@amount, credit_card, options)
+ assert_success response
+ assert_equal '1000 Approved', response.message
+ assert_equal 'authorized', response.params['braintree_transaction']['status']
+ end
+
def test_masked_card_number
assert response = @gateway.authorize(@amount, @credit_card, @options)
assert_equal('510510******5100', response.params['braintree_transaction']['credit_card_details']['masked_number'])
@@ -224,6 +245,35 @@ def test_successful_store_with_existing_customer_id
assert_not_nil response.params['credit_card_token']
end
+ def test_successful_store_with_existing_customer_id_and_nil_billing_address_options
+ credit_card = credit_card('5105105105105100')
+ customer_id = generate_unique_id
+ options = {
+ :customer => customer_id,
+ :billing_address => {
+ :name => 'John Smith',
+ :phone => '123-456-7890',
+ :company => nil,
+ :address1 => nil,
+ :address2 => nil,
+ :city => nil,
+ :state => nil,
+ :zip => nil,
+ :country_name => nil
+ }
+ }
+ assert response = @gateway.store(credit_card, options)
+ assert_success response
+ assert_equal 1, @braintree_backend.customer.find(customer_id).credit_cards.size
+
+ assert response = @gateway.store(credit_card, options)
+ assert_success response
+ assert_equal 2, @braintree_backend.customer.find(customer_id).credit_cards.size
+ assert_equal customer_id, response.params['customer_vault_id']
+ assert_equal customer_id, response.authorization
+ assert_not_nil response.params['credit_card_token']
+ end
+
def test_successful_purchase
assert response = @gateway.purchase(@amount, @credit_card, @options)
assert_success response
diff --git a/test/unit/gateways/braintree_blue_test.rb b/test/unit/gateways/braintree_blue_test.rb
index 21f7e152be5..b13264ae47f 100644
--- a/test/unit/gateways/braintree_blue_test.rb
+++ b/test/unit/gateways/braintree_blue_test.rb
@@ -473,6 +473,42 @@ def test_store_with_existing_customer_id
assert_equal 'cctoken', response.params['credit_card_token']
end
+ def test_store_with_existing_customer_id_and_nil_billing_address_options
+ credit_card = stub(
+ customer_id: 'customerid',
+ token: 'cctoken'
+ )
+ options = {
+ :customer => 'customerid',
+ :billing_address => {
+ :name => 'John Smith',
+ :phone => '123-456-7890',
+ :company => nil,
+ :address1 => nil,
+ :address2 => nil,
+ :city => nil,
+ :state => nil,
+ :zip => nil,
+ :country_name => nil
+ }
+ }
+
+ result = Braintree::SuccessfulResult.new(credit_card: credit_card)
+ Braintree::CustomerGateway.any_instance.expects(:find).with('customerid')
+ Braintree::CreditCardGateway.any_instance.expects(:create).with do |params|
+ assert_equal 'customerid', params[:customer_id]
+ assert_equal '41111111111111111111', params[:number]
+ assert_equal 'Longbob Longsen', params[:cardholder_name]
+ params
+ end.returns(result)
+
+ response = @gateway.store(credit_card('41111111111111111111'), options)
+ assert_success response
+ assert_nil response.params['braintree_customer']
+ assert_equal 'customerid', response.params['customer_vault_id']
+ assert_equal 'cctoken', response.params['credit_card_token']
+ end
+
def test_update_with_cvv
stored_credit_card = mock(:token => 'token', :default? => true)
customer = mock(:credit_cards => [stored_credit_card], :id => '123')
From a75538dc1dd5986481a73e34efcd3a8e73c37961 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 8 Nov 2018 14:55:25 -0500
Subject: [PATCH 0182/2234] RuboCop: fix Layout/SpaceAfterComma
---
.rubocop_todo.yml | 5 -----
lib/active_merchant/billing/credit_card.rb | 2 +-
lib/active_merchant/billing/gateways/adyen.rb | 4 ++--
.../billing/gateways/authorize_net.rb | 2 +-
.../billing/gateways/authorize_net_cim.rb | 8 ++++----
.../billing/gateways/bank_frick.rb | 2 +-
.../billing/gateways/beanstream.rb | 2 +-
.../gateways/beanstream/beanstream_core.rb | 2 +-
.../billing/gateways/blue_pay.rb | 6 +++---
lib/active_merchant/billing/gateways/bogus.rb | 2 +-
.../billing/gateways/borgun.rb | 4 ++--
.../billing/gateways/bridge_pay.rb | 2 +-
lib/active_merchant/billing/gateways/cams.rb | 6 +++---
.../billing/gateways/cardknox.rb | 2 +-
.../billing/gateways/cashnet.rb | 2 +-
lib/active_merchant/billing/gateways/cc5.rb | 2 +-
.../billing/gateways/commercegate.rb | 2 +-
.../billing/gateways/credorax.rb | 2 +-
.../billing/gateways/ct_payment.rb | 8 ++++----
.../billing/gateways/cyber_source.rb | 6 +++---
.../billing/gateways/data_cash.rb | 2 +-
lib/active_merchant/billing/gateways/dibs.rb | 2 +-
.../billing/gateways/efsnet.rb | 8 ++++----
.../billing/gateways/elavon.rb | 2 +-
lib/active_merchant/billing/gateways/epay.rb | 2 +-
lib/active_merchant/billing/gateways/eway.rb | 2 +-
lib/active_merchant/billing/gateways/exact.rb | 2 +-
.../billing/gateways/first_giving.rb | 2 +-
.../billing/gateways/firstdata_e4.rb | 2 +-
.../billing/gateways/flo2cash.rb | 2 +-
.../billing/gateways/garanti.rb | 6 +++---
.../billing/gateways/global_collect.rb | 2 +-
lib/active_merchant/billing/gateways/hdfc.rb | 2 +-
lib/active_merchant/billing/gateways/hps.rb | 4 ++--
.../billing/gateways/inspire.rb | 14 ++++++-------
.../billing/gateways/iridium.rb | 12 +++++------
.../billing/gateways/itransact.rb | 4 ++--
lib/active_merchant/billing/gateways/iveri.rb | 4 ++--
.../billing/gateways/jetpay.rb | 2 +-
.../billing/gateways/jetpay_v2.rb | 2 +-
.../billing/gateways/linkpoint.rb | 4 ++--
.../billing/gateways/merchant_e_solutions.rb | 6 +++---
.../billing/gateways/merchant_one.rb | 4 ++--
.../billing/gateways/merchant_warrior.rb | 2 +-
.../billing/gateways/mercury.rb | 4 ++--
.../billing/gateways/moneris_us.rb | 2 +-
.../billing/gateways/mundipagg.rb | 2 +-
.../billing/gateways/net_registry.rb | 2 +-
.../billing/gateways/netaxept.rb | 2 +-
.../billing/gateways/netbilling.rb | 4 ++--
lib/active_merchant/billing/gateways/nmi.rb | 2 +-
lib/active_merchant/billing/gateways/ogone.rb | 4 ++--
lib/active_merchant/billing/gateways/omise.rb | 2 +-
.../billing/gateways/orbital.rb | 2 +-
.../billing/gateways/pay_junction.rb | 2 +-
.../billing/gateways/pay_junction_v2.rb | 2 +-
.../billing/gateways/pay_secure.rb | 4 ++--
.../billing/gateways/paybox_direct.rb | 16 +++++++--------
.../billing/gateways/payflow.rb | 2 +-
.../billing/gateways/payflow_express.rb | 2 +-
.../billing/gateways/payment_express.rb | 6 +++---
.../billing/gateways/payway.rb | 2 +-
.../billing/gateways/plugnpay.rb | 2 +-
.../billing/gateways/pro_pay.rb | 4 ++--
.../billing/gateways/psigate.rb | 2 +-
.../billing/gateways/quantum.rb | 8 ++++----
.../billing/gateways/quickbooks.rb | 2 +-
.../billing/gateways/qvalent.rb | 2 +-
.../billing/gateways/realex.rb | 2 +-
.../billing/gateways/safe_charge.rb | 4 ++--
lib/active_merchant/billing/gateways/sage.rb | 12 +++++------
.../billing/gateways/skip_jack.rb | 2 +-
.../billing/gateways/smart_ps.rb | 14 ++++++-------
.../billing/gateways/so_easy_pay.rb | 2 +-
.../trans_first_transaction_express.rb | 2 +-
.../billing/gateways/transact_pro.rb | 4 ++--
.../billing/gateways/transax.rb | 2 +-
.../billing/gateways/trust_commerce.rb | 2 +-
.../billing/gateways/usa_epay_advanced.rb | 20 +++++++++----------
.../billing/gateways/viaklix.rb | 4 ++--
.../billing/gateways/visanet_peru.rb | 2 +-
.../billing/gateways/wirecard.rb | 2 +-
.../billing/gateways/worldpay.rb | 4 ++--
lib/active_merchant/country.rb | 2 +-
lib/support/ssl_verify.rb | 2 +-
.../remote/gateways/remote_beanstream_test.rb | 2 +-
.../remote_ct_payment_certification_test.rb | 8 ++++----
.../remote/gateways/remote_ct_payment_test.rb | 12 +++++------
.../remote_litle_certification_test.rb | 8 ++++----
.../remote_merchant_ware_version_four_test.rb | 4 ++--
test/remote/gateways/remote_orbital_test.rb | 4 ++--
.../remote/gateways/remote_payflow_uk_test.rb | 2 +-
.../remote_usa_epay_transaction_test.rb | 2 +-
test/test_helper.rb | 2 +-
test/unit/gateways/braintree_blue_test.rb | 6 +++---
test/unit/gateways/braintree_orange_test.rb | 2 +-
test/unit/gateways/card_connect_test.rb | 2 +-
test/unit/gateways/epay_test.rb | 2 +-
test/unit/gateways/eway_rapid_test.rb | 2 +-
test/unit/gateways/hps_test.rb | 12 +++++------
test/unit/gateways/nab_transact_test.rb | 12 +++++------
test/unit/gateways/opp_test.rb | 14 ++++++-------
test/unit/gateways/optimal_payment_test.rb | 4 ++--
.../gateways/paypal/paypal_common_api_test.rb | 4 ++--
test/unit/gateways/qvalent_test.rb | 2 +-
test/unit/gateways/redsys_test.rb | 2 +-
test/unit/gateways/secure_pay_au_test.rb | 12 +++++------
test/unit/gateways/securion_pay_test.rb | 4 ++--
test/unit/gateways/stripe_test.rb | 10 +++++-----
109 files changed, 229 insertions(+), 234 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 3c88f5cb74d..ade1c7ede93 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -116,11 +116,6 @@ Layout/MultilineOperationIndentation:
- 'test/unit/gateways/ogone_test.rb'
- 'test/unit/gateways/skip_jack_test.rb'
-# Offense count: 315
-# Cop supports --auto-correct.
-Layout/SpaceAfterComma:
- Enabled: false
-
# Offense count: 638
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
diff --git a/lib/active_merchant/billing/credit_card.rb b/lib/active_merchant/billing/credit_card.rb
index 19dcbec394a..d48f1d2b769 100644
--- a/lib/active_merchant/billing/credit_card.rb
+++ b/lib/active_merchant/billing/credit_card.rb
@@ -388,7 +388,7 @@ def expiration #:nodoc:
private
def month_days
- mdays = [nil,31,28,31,30,31,30,31,31,30,31,30,31]
+ mdays = [nil, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
mdays[2] = 29 if Date.leap?(year)
mdays[month]
end
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index 7aef6d0fbc1..de0f15f32ee 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -7,7 +7,7 @@ class AdyenGateway < Gateway
self.test_url = 'https://pal-test.adyen.com/pal/servlet/Payment/v18'
self.live_url = 'https://pal-live.adyen.com/pal/servlet/Payment/v18'
- self.supported_countries = ['AT','AU','BE','BG','BR','CH','CY','CZ','DE','DK','EE','ES','FI','FR','GB','GI','GR','HK','HU','IE','IS','IT','LI','LT','LU','LV','MC','MT','MX','NL','NO','PL','PT','RO','SE','SG','SK','SI','US']
+ self.supported_countries = ['AT', 'AU', 'BE', 'BG', 'BR', 'CH', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GB', 'GI', 'GR', 'HK', 'HU', 'IE', 'IS', 'IT', 'LI', 'LT', 'LU', 'LV', 'MC', 'MT', 'MX', 'NL', 'NO', 'PL', 'PT', 'RO', 'SE', 'SG', 'SK', 'SI', 'US']
self.default_currency = 'USD'
self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :jcb, :dankort, :maestro, :discover]
@@ -216,7 +216,7 @@ def add_card(post, credit_card)
cvc: credit_card.verification_value
}
- card.delete_if{|k,v| v.blank? }
+ card.delete_if{|k, v| v.blank? }
card[:holderName] ||= 'Not Provided' if credit_card.is_a?(NetworkTokenizationCreditCard)
requires!(card, :expiryMonth, :expiryYear, :holderName, :number)
post[:card] = card
diff --git a/lib/active_merchant/billing/gateways/authorize_net.rb b/lib/active_merchant/billing/gateways/authorize_net.rb
index 31640f0ca11..db5d98b69aa 100644
--- a/lib/active_merchant/billing/gateways/authorize_net.rb
+++ b/lib/active_merchant/billing/gateways/authorize_net.rb
@@ -394,7 +394,7 @@ def add_payment_source(xml, source, options, action = nil)
end
def camel_case_lower(key)
- String(key).split('_').inject([]){ |buffer,e| buffer.push(buffer.empty? ? e : e.capitalize) }.join
+ String(key).split('_').inject([]){ |buffer, e| buffer.push(buffer.empty? ? e : e.capitalize) }.join
end
def add_settings(xml, source, options)
diff --git a/lib/active_merchant/billing/gateways/authorize_net_cim.rb b/lib/active_merchant/billing/gateways/authorize_net_cim.rb
index 5f9d67c1a01..3a5cce3d5e5 100644
--- a/lib/active_merchant/billing/gateways/authorize_net_cim.rb
+++ b/lib/active_merchant/billing/gateways/authorize_net_cim.rb
@@ -666,9 +666,9 @@ def add_transaction(xml, transaction)
# The amount to be billed to the customer
case transaction[:type]
when :void
- tag_unless_blank(xml,'customerProfileId', transaction[:customer_profile_id])
- tag_unless_blank(xml,'customerPaymentProfileId', transaction[:customer_payment_profile_id])
- tag_unless_blank(xml,'customerShippingAddressId', transaction[:customer_shipping_address_id])
+ tag_unless_blank(xml, 'customerProfileId', transaction[:customer_profile_id])
+ tag_unless_blank(xml, 'customerPaymentProfileId', transaction[:customer_payment_profile_id])
+ tag_unless_blank(xml, 'customerShippingAddressId', transaction[:customer_shipping_address_id])
xml.tag!('transId', transaction[:trans_id])
when :refund
xml.tag!('amount', transaction[:amount])
@@ -698,7 +698,7 @@ def add_transaction(xml, transaction)
if [:auth_capture, :auth_only, :capture_only].include?(transaction[:type])
xml.tag!('recurringBilling', transaction[:recurring_billing]) if transaction.has_key?(:recurring_billing)
end
- unless [:void,:refund,:prior_auth_capture].include?(transaction[:type])
+ unless [:void, :refund, :prior_auth_capture].include?(transaction[:type])
tag_unless_blank(xml, 'cardCode', transaction[:card_code])
end
end
diff --git a/lib/active_merchant/billing/gateways/bank_frick.rb b/lib/active_merchant/billing/gateways/bank_frick.rb
index fdfdfcff642..8a35089978c 100644
--- a/lib/active_merchant/billing/gateways/bank_frick.rb
+++ b/lib/active_merchant/billing/gateways/bank_frick.rb
@@ -9,7 +9,7 @@ class BankFrickGateway < Gateway
self.test_url = 'https://test.ctpe.io/payment/ctpe'
self.live_url = 'https://ctpe.io/payment/ctpe'
- self.supported_countries = ['LI','US']
+ self.supported_countries = ['LI', 'US']
self.default_currency = 'EUR'
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
diff --git a/lib/active_merchant/billing/gateways/beanstream.rb b/lib/active_merchant/billing/gateways/beanstream.rb
index 6947992934d..aedcac80462 100644
--- a/lib/active_merchant/billing/gateways/beanstream.rb
+++ b/lib/active_merchant/billing/gateways/beanstream.rb
@@ -188,7 +188,7 @@ def update(vault_id, payment_method, options = {})
end
options[:vault_id] = vault_id
options[:operation] = secure_profile_action(:modify)
- add_secure_profile_variables(post,options)
+ add_secure_profile_variables(post, options)
commit(post, true)
end
diff --git a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb
index 3b6c9d2cfc4..e3ff636c26f 100644
--- a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb
+++ b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb
@@ -398,7 +398,7 @@ def recurring_parse(data)
end
def commit(params, use_profile_api = false)
- post(post_data(params,use_profile_api),use_profile_api)
+ post(post_data(params, use_profile_api), use_profile_api)
end
def recurring_commit(params)
diff --git a/lib/active_merchant/billing/gateways/blue_pay.rb b/lib/active_merchant/billing/gateways/blue_pay.rb
index 988c2f1e946..b3f789b7de3 100644
--- a/lib/active_merchant/billing/gateways/blue_pay.rb
+++ b/lib/active_merchant/billing/gateways/blue_pay.rb
@@ -330,7 +330,7 @@ def commit(action, money, fields)
def parse_recurring(response_fields, opts={}) # expected status?
parsed = {}
- response_fields.each do |k,v|
+ response_fields.each do |k, v|
mapped_key = REBILL_FIELD_MAP.include?(k) ? REBILL_FIELD_MAP[k] : k
parsed[mapped_key] = v
end
@@ -345,14 +345,14 @@ def parse_recurring(response_fields, opts={}) # expected status?
def parse(body)
# The bp20api has max one value per form field.
- response_fields = Hash[CGI::parse(body).map{|k,v| [k.upcase,v.first]}]
+ response_fields = Hash[CGI::parse(body).map{|k, v| [k.upcase, v.first]}]
if response_fields.include? 'REBILL_ID'
return parse_recurring(response_fields)
end
parsed = {}
- response_fields.each do |k,v|
+ response_fields.each do |k, v|
mapped_key = FIELD_MAP.include?(k) ? FIELD_MAP[k] : k
parsed[mapped_key] = v
end
diff --git a/lib/active_merchant/billing/gateways/bogus.rb b/lib/active_merchant/billing/gateways/bogus.rb
index b5d51182368..e72bae4760c 100644
--- a/lib/active_merchant/billing/gateways/bogus.rb
+++ b/lib/active_merchant/billing/gateways/bogus.rb
@@ -106,7 +106,7 @@ def unstore(reference, options = {})
when /1$/
Response.new(true, SUCCESS_MESSAGE, {}, :test => true)
when /2$/
- Response.new(false, FAILURE_MESSAGE, {:error => FAILURE_MESSAGE },:test => true, :error_code => STANDARD_ERROR_CODE[:processing_error])
+ Response.new(false, FAILURE_MESSAGE, {:error => FAILURE_MESSAGE }, :test => true, :error_code => STANDARD_ERROR_CODE[:processing_error])
else
raise Error, UNSTORE_ERROR_MESSAGE
end
diff --git a/lib/active_merchant/billing/gateways/borgun.rb b/lib/active_merchant/billing/gateways/borgun.rb
index ae144a95c59..26b7fff9ef5 100644
--- a/lib/active_merchant/billing/gateways/borgun.rb
+++ b/lib/active_merchant/billing/gateways/borgun.rb
@@ -76,7 +76,7 @@ def scrub(transcript)
private
- CURRENCY_CODES = Hash.new{|h,k| raise ArgumentError.new("Unsupported currency for HDFC: #{k}")}
+ CURRENCY_CODES = Hash.new{|h, k| raise ArgumentError.new("Unsupported currency for HDFC: #{k}")}
CURRENCY_CODES['ISK'] = '352'
CURRENCY_CODES['EUR'] = '978'
CURRENCY_CODES['USD'] = '840'
@@ -190,7 +190,7 @@ def build_request(action, post)
end
end
inner = CGI.escapeHTML(xml.target!)
- envelope(mode).sub(/{{ :body }}/,inner)
+ envelope(mode).sub(/{{ :body }}/, inner)
end
def envelope(mode)
diff --git a/lib/active_merchant/billing/gateways/bridge_pay.rb b/lib/active_merchant/billing/gateways/bridge_pay.rb
index 3e12f5b11d6..51d6cf3bc4d 100644
--- a/lib/active_merchant/billing/gateways/bridge_pay.rb
+++ b/lib/active_merchant/billing/gateways/bridge_pay.rb
@@ -237,7 +237,7 @@ def post_data(post)
{
:UserName => @options[:user_name],
:Password => @options[:password]
- }.merge(post).collect{|k,v| "#{k}=#{CGI.escape(v.to_s)}"}.join('&')
+ }.merge(post).collect{|k, v| "#{k}=#{CGI.escape(v.to_s)}"}.join('&')
end
end
end
diff --git a/lib/active_merchant/billing/gateways/cams.rb b/lib/active_merchant/billing/gateways/cams.rb
index fdb310358c6..872c7818b2b 100644
--- a/lib/active_merchant/billing/gateways/cams.rb
+++ b/lib/active_merchant/billing/gateways/cams.rb
@@ -167,7 +167,7 @@ def add_invoice(post, money, options)
def add_payment(post, payment)
post[:ccnumber] = payment.number
- post[:ccexp] = "#{payment.month.to_s.rjust(2,"0")}#{payment.year.to_s[-2..-1]}"
+ post[:ccexp] = "#{payment.month.to_s.rjust(2, "0")}#{payment.year.to_s[-2..-1]}"
post[:cvv] = payment.verification_value
end
@@ -175,7 +175,7 @@ def parse(body)
kvs = body.split('&')
kvs.inject({}) { |h, kv|
- k,v = kv.split('=')
+ k, v = kv.split('=')
h[k] = v
h
}
@@ -219,7 +219,7 @@ def post_data(parameters = {})
parameters[:password] = @options[:password]
parameters[:username] = @options[:username]
- parameters.collect{|k,v| "#{k}=#{v}" }.join('&')
+ parameters.collect{|k, v| "#{k}=#{v}" }.join('&')
end
def error_code_from(response)
diff --git a/lib/active_merchant/billing/gateways/cardknox.rb b/lib/active_merchant/billing/gateways/cardknox.rb
index aa61d77dc77..a611004f75b 100644
--- a/lib/active_merchant/billing/gateways/cardknox.rb
+++ b/lib/active_merchant/billing/gateways/cardknox.rb
@@ -3,7 +3,7 @@ module Billing #:nodoc:
class CardknoxGateway < Gateway
self.live_url = 'https://x1.cardknox.com/gateway'
- self.supported_countries = ['US','CA','GB']
+ self.supported_countries = ['US', 'CA', 'GB']
self.default_currency = 'USD'
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb]
diff --git a/lib/active_merchant/billing/gateways/cashnet.rb b/lib/active_merchant/billing/gateways/cashnet.rb
index db28d9de497..880ffb4986c 100644
--- a/lib/active_merchant/billing/gateways/cashnet.rb
+++ b/lib/active_merchant/billing/gateways/cashnet.rb
@@ -136,7 +136,7 @@ def parse(body)
match = body.match(/(.*)<\/cngateway>/)
return nil unless match
- Hash[CGI::parse(match[1]).map{|k,v| [k.to_sym,v.first]}]
+ Hash[CGI::parse(match[1]).map{|k, v| [k.to_sym, v.first]}]
end
def handle_response(response)
diff --git a/lib/active_merchant/billing/gateways/cc5.rb b/lib/active_merchant/billing/gateways/cc5.rb
index e9c5dac6e00..695eb7a8703 100644
--- a/lib/active_merchant/billing/gateways/cc5.rb
+++ b/lib/active_merchant/billing/gateways/cc5.rb
@@ -188,7 +188,7 @@ def normalize(text)
return unless text
if ActiveSupport::Inflector.method(:transliterate).arity == -2
- ActiveSupport::Inflector.transliterate(text,'')
+ ActiveSupport::Inflector.transliterate(text, '')
else
text.gsub(/[^\x00-\x7F]+/, '')
end
diff --git a/lib/active_merchant/billing/gateways/commercegate.rb b/lib/active_merchant/billing/gateways/commercegate.rb
index f3cd6500830..c1d6d5bc1f4 100644
--- a/lib/active_merchant/billing/gateways/commercegate.rb
+++ b/lib/active_merchant/billing/gateways/commercegate.rb
@@ -111,7 +111,7 @@ def parse(body)
results = {}
body.split(/\&/).each do |pair|
- key,val = pair.split(%r{=})
+ key, val = pair.split(%r{=})
results[key] = CGI.unescape(val)
end
diff --git a/lib/active_merchant/billing/gateways/credorax.rb b/lib/active_merchant/billing/gateways/credorax.rb
index 4689e66d7fe..4c2f173fb0f 100644
--- a/lib/active_merchant/billing/gateways/credorax.rb
+++ b/lib/active_merchant/billing/gateways/credorax.rb
@@ -337,7 +337,7 @@ def url
end
def parse(body)
- Hash[CGI::parse(body).map{|k,v| [k.upcase,v.first]}]
+ Hash[CGI::parse(body).map{|k, v| [k.upcase, v.first]}]
end
def success_from(response)
diff --git a/lib/active_merchant/billing/gateways/ct_payment.rb b/lib/active_merchant/billing/gateways/ct_payment.rb
index dd0c1ae2599..2e3d444cc1b 100644
--- a/lib/active_merchant/billing/gateways/ct_payment.rb
+++ b/lib/active_merchant/billing/gateways/ct_payment.rb
@@ -118,7 +118,7 @@ def verify(credit_card, options={})
post = {}
add_terminal_number(post, options)
add_operator_id(post, options)
- add_invoice(post,0, options)
+ add_invoice(post, 0, options)
add_payment(post, credit_card)
add_address(post, credit_card, options)
add_customer_data(post, options)
@@ -159,7 +159,7 @@ def add_terminal_number(post, options)
end
def add_money(post, money)
- post[:Amount] = money.to_s.rjust(11,'0')
+ post[:Amount] = money.to_s.rjust(11, '0')
end
def add_operator_id(post, options)
@@ -179,7 +179,7 @@ def add_address(post, creditcard, options)
def add_invoice(post, money, options)
post[:CurrencyCode] = options[:currency] || (currency(money) if money)
- post[:InvoiceNumber] = options[:order_id].rjust(12,'0')
+ post[:InvoiceNumber] = options[:order_id].rjust(12, '0')
post[:InputType] = 'I'
post[:LanguageCode] = 'E'
end
@@ -189,7 +189,7 @@ def add_payment(post, payment)
post[:Token] = split_authorization(payment)[3].strip
else
post[:CardType] = CARD_BRAND[payment.brand] || ' '
- post[:CardNumber] = payment.number.rjust(40,' ')
+ post[:CardNumber] = payment.number.rjust(40, ' ')
post[:ExpirationDate] = expdate(payment)
post[:Cvv2Cvc2Number] = payment.verification_value
end
diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb
index ec831d9377f..d31c5e46de1 100644
--- a/lib/active_merchant/billing/gateways/cyber_source.rb
+++ b/lib/active_merchant/billing/gateways/cyber_source.rb
@@ -209,7 +209,7 @@ def calculate_tax(creditcard, options)
# Determines if a card can be used for Pinless Debit Card transactions
def validate_pinless_debit_card(creditcard, options = {})
requires!(options, :order_id)
- commit(build_validate_pinless_debit_request(creditcard,options), :validate_pinless_debit_card, nil, options)
+ commit(build_validate_pinless_debit_request(creditcard, options), :validate_pinless_debit_card, nil, options)
end
def supports_scrubbing?
@@ -392,7 +392,7 @@ def build_retrieve_subscription_request(reference, options)
xml.target!
end
- def build_validate_pinless_debit_request(creditcard,options)
+ def build_validate_pinless_debit_request(creditcard, options)
xml = Builder::XmlMarkup.new :indent => 2
add_creditcard(xml, creditcard)
add_validate_pinless_debit_service(xml)
@@ -432,7 +432,7 @@ def add_line_item_data(xml, options)
def add_merchant_data(xml, options)
xml.tag! 'merchantID', @options[:login]
xml.tag! 'merchantReferenceCode', options[:order_id] || generate_unique_id
- xml.tag! 'clientLibrary','Ruby Active Merchant'
+ xml.tag! 'clientLibrary', 'Ruby Active Merchant'
xml.tag! 'clientLibraryVersion', VERSION
xml.tag! 'clientEnvironment', RUBY_PLATFORM
end
diff --git a/lib/active_merchant/billing/gateways/data_cash.rb b/lib/active_merchant/billing/gateways/data_cash.rb
index f943a330d01..7a24dd3e5f3 100644
--- a/lib/active_merchant/billing/gateways/data_cash.rb
+++ b/lib/active_merchant/billing/gateways/data_cash.rb
@@ -269,7 +269,7 @@ def commit(request)
end
def format_date(month, year)
- "#{format(month,:two_digits)}/#{format(year, :two_digits)}"
+ "#{format(month, :two_digits)}/#{format(year, :two_digits)}"
end
def parse(body)
diff --git a/lib/active_merchant/billing/gateways/dibs.rb b/lib/active_merchant/billing/gateways/dibs.rb
index d753f9fa143..7e4d7ae7cec 100644
--- a/lib/active_merchant/billing/gateways/dibs.rb
+++ b/lib/active_merchant/billing/gateways/dibs.rb
@@ -87,7 +87,7 @@ def scrub(transcript)
private
- CURRENCY_CODES = Hash.new{|h,k| raise ArgumentError.new("Unsupported currency: #{k}")}
+ CURRENCY_CODES = Hash.new{|h, k| raise ArgumentError.new("Unsupported currency: #{k}")}
CURRENCY_CODES['USD'] = '840'
CURRENCY_CODES['DKK'] = '208'
CURRENCY_CODES['NOK'] = '578'
diff --git a/lib/active_merchant/billing/gateways/efsnet.rb b/lib/active_merchant/billing/gateways/efsnet.rb
index 91e689d3fa7..ad16cfbf349 100644
--- a/lib/active_merchant/billing/gateways/efsnet.rb
+++ b/lib/active_merchant/billing/gateways/efsnet.rb
@@ -99,16 +99,16 @@ def build_credit_card_request(money, creditcard, options = {})
:client_ip_address => options[:ip]
}
- add_creditcard(post,creditcard)
- add_address(post,options)
+ add_creditcard(post, creditcard)
+ add_address(post, options)
post
end
def format_reference_number(number)
- number.to_s.slice(0,12)
+ number.to_s.slice(0, 12)
end
- def add_address(post,options)
+ def add_address(post, options)
if address = options[:billing_address] || options[:address]
if address[:address2]
post[:billing_address] = address[:address1].to_s << ' ' << address[:address2].to_s
diff --git a/lib/active_merchant/billing/gateways/elavon.rb b/lib/active_merchant/billing/gateways/elavon.rb
index 1800d17b373..34bb44f5bc0 100644
--- a/lib/active_merchant/billing/gateways/elavon.rb
+++ b/lib/active_merchant/billing/gateways/elavon.rb
@@ -149,7 +149,7 @@ def scrub(transcript)
private
- def add_invoice(form,options)
+ def add_invoice(form, options)
form[:invoice_number] = truncate((options[:order_id] || options[:invoice]), 10)
form[:description] = truncate(options[:description], 255)
end
diff --git a/lib/active_merchant/billing/gateways/epay.rb b/lib/active_merchant/billing/gateways/epay.rb
index 7f351623253..f26a9112a5d 100644
--- a/lib/active_merchant/billing/gateways/epay.rb
+++ b/lib/active_merchant/billing/gateways/epay.rb
@@ -208,7 +208,7 @@ def do_authorize(params)
end
result = {}
- query.each_pair do |k,v|
+ query.each_pair do |k, v|
result[k] = v.is_a?(Array) && v.size == 1 ? v[0] : v # make values like ['v'] into 'v'
end
result
diff --git a/lib/active_merchant/billing/gateways/eway.rb b/lib/active_merchant/billing/gateways/eway.rb
index a45db4bf881..5625420870e 100644
--- a/lib/active_merchant/billing/gateways/eway.rb
+++ b/lib/active_merchant/billing/gateways/eway.rb
@@ -145,7 +145,7 @@ def post_data(parameters = {})
def message_from(message)
return '' if message.blank?
- MESSAGES[message[0,2]] || message
+ MESSAGES[message[0, 2]] || message
end
def purchase_url(cvn)
diff --git a/lib/active_merchant/billing/gateways/exact.rb b/lib/active_merchant/billing/gateways/exact.rb
index 6858ef98aa6..a388bcc341f 100644
--- a/lib/active_merchant/billing/gateways/exact.rb
+++ b/lib/active_merchant/billing/gateways/exact.rb
@@ -211,7 +211,7 @@ def parse(xml)
parse_elements(response, root)
end
- response.delete_if{ |k,v| SENSITIVE_FIELDS.include?(k) }
+ response.delete_if{ |k, v| SENSITIVE_FIELDS.include?(k) }
end
def parse_elements(response, root)
diff --git a/lib/active_merchant/billing/gateways/first_giving.rb b/lib/active_merchant/billing/gateways/first_giving.rb
index 975409638d7..3af7a394116 100644
--- a/lib/active_merchant/billing/gateways/first_giving.rb
+++ b/lib/active_merchant/billing/gateways/first_giving.rb
@@ -116,7 +116,7 @@ def post_data(post)
end
def encode(hash)
- hash.collect{|(k,v)| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}"}.join('&')
+ hash.collect{|(k, v)| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}"}.join('&')
end
def creditcard_brand(brand)
diff --git a/lib/active_merchant/billing/gateways/firstdata_e4.rb b/lib/active_merchant/billing/gateways/firstdata_e4.rb
index da6b77b306e..655703826f4 100755
--- a/lib/active_merchant/billing/gateways/firstdata_e4.rb
+++ b/lib/active_merchant/billing/gateways/firstdata_e4.rb
@@ -438,7 +438,7 @@ def parse(xml)
parse_elements(response, root)
end
- response.delete_if{ |k,v| SENSITIVE_FIELDS.include?(k) }
+ response.delete_if{ |k, v| SENSITIVE_FIELDS.include?(k) }
end
def parse_elements(response, root)
diff --git a/lib/active_merchant/billing/gateways/flo2cash.rb b/lib/active_merchant/billing/gateways/flo2cash.rb
index 83bdb83f50f..e3ced39eae0 100644
--- a/lib/active_merchant/billing/gateways/flo2cash.rb
+++ b/lib/active_merchant/billing/gateways/flo2cash.rb
@@ -71,7 +71,7 @@ def scrub(transcript)
private
- CURRENCY_CODES = Hash.new{|h,k| raise ArgumentError.new("Unsupported currency: #{k}")}
+ CURRENCY_CODES = Hash.new{|h, k| raise ArgumentError.new("Unsupported currency: #{k}")}
CURRENCY_CODES['NZD'] = '554'
def add_invoice(post, money, options)
diff --git a/lib/active_merchant/billing/gateways/garanti.rb b/lib/active_merchant/billing/gateways/garanti.rb
index ef2dacc84c8..64cf7224a95 100644
--- a/lib/active_merchant/billing/gateways/garanti.rb
+++ b/lib/active_merchant/billing/gateways/garanti.rb
@@ -5,7 +5,7 @@ class GarantiGateway < Gateway
self.test_url = 'https://sanalposprovtest.garanti.com.tr/VPServlet'
# The countries the gateway supports merchants from as 2 digit ISO country codes
- self.supported_countries = ['US','TR']
+ self.supported_countries = ['US', 'TR']
# The card types supported by the payment gateway
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
@@ -195,7 +195,7 @@ def normalize(text)
return unless text
if ActiveSupport::Inflector.method(:transliterate).arity == -2
- ActiveSupport::Inflector.transliterate(text,'')
+ ActiveSupport::Inflector.transliterate(text, '')
else
text.gsub(/[^\x00-\x7F]+/, '')
end
@@ -214,7 +214,7 @@ def currency_code(currency)
CURRENCY_CODES[currency] || CURRENCY_CODES[default_currency]
end
- def commit(money,request)
+ def commit(money, request)
url = test? ? self.test_url : self.live_url
raw_response = ssl_post(url, 'data=' + request)
response = parse(raw_response)
diff --git a/lib/active_merchant/billing/gateways/global_collect.rb b/lib/active_merchant/billing/gateways/global_collect.rb
index a96cbb12d42..d0f3702191c 100644
--- a/lib/active_merchant/billing/gateways/global_collect.rb
+++ b/lib/active_merchant/billing/gateways/global_collect.rb
@@ -329,7 +329,7 @@ def error_code_from(succeeded, response)
end
def nestable_hash
- Hash.new {|h,k| h[k] = Hash.new(&h.default_proc) }
+ Hash.new {|h, k| h[k] = Hash.new(&h.default_proc) }
end
def capture_requested?(response)
diff --git a/lib/active_merchant/billing/gateways/hdfc.rb b/lib/active_merchant/billing/gateways/hdfc.rb
index f10438b0b47..a6e228d5721 100644
--- a/lib/active_merchant/billing/gateways/hdfc.rb
+++ b/lib/active_merchant/billing/gateways/hdfc.rb
@@ -57,7 +57,7 @@ def refund(amount, authorization, options={})
private
- CURRENCY_CODES = Hash.new{|h,k| raise ArgumentError.new("Unsupported currency for HDFC: #{k}")}
+ CURRENCY_CODES = Hash.new{|h, k| raise ArgumentError.new("Unsupported currency for HDFC: #{k}")}
CURRENCY_CODES['AED'] = '784'
CURRENCY_CODES['AUD'] = '036'
CURRENCY_CODES['CAD'] = '124'
diff --git a/lib/active_merchant/billing/gateways/hps.rb b/lib/active_merchant/billing/gateways/hps.rb
index 5572924d1c7..22677874ff1 100644
--- a/lib/active_merchant/billing/gateways/hps.rb
+++ b/lib/active_merchant/billing/gateways/hps.rb
@@ -42,7 +42,7 @@ def purchase(money, card_or_token, options={})
commit('CreditSale') do |xml|
add_amount(xml, money)
add_allow_dup(xml)
- add_customer_data(xml, card_or_token,options)
+ add_customer_data(xml, card_or_token, options)
add_details(xml, options)
add_descriptor_name(xml, options)
add_payment(xml, card_or_token, options)
@@ -54,7 +54,7 @@ def refund(money, transaction_id, options={})
add_amount(xml, money)
add_allow_dup(xml)
add_reference(xml, transaction_id)
- add_customer_data(xml, transaction_id,options)
+ add_customer_data(xml, transaction_id, options)
add_details(xml, options)
end
end
diff --git a/lib/active_merchant/billing/gateways/inspire.rb b/lib/active_merchant/billing/gateways/inspire.rb
index f7ee068cdf0..78a193fc5ce 100644
--- a/lib/active_merchant/billing/gateways/inspire.rb
+++ b/lib/active_merchant/billing/gateways/inspire.rb
@@ -33,7 +33,7 @@ def initialize(options = {})
def authorize(money, creditcard, options = {})
post = {}
add_invoice(post, options)
- add_payment_source(post, creditcard,options)
+ add_payment_source(post, creditcard, options)
add_address(post, creditcard, options)
add_customer_data(post, options)
@@ -136,11 +136,11 @@ def add_payment_source(params, source, options={})
end
end
- def add_customer_vault_id(params,vault_id)
+ def add_customer_vault_id(params, vault_id)
params[:customer_vault_id] = vault_id
end
- def add_creditcard(post, creditcard,options)
+ def add_creditcard(post, creditcard, options)
if options[:store]
post[:customer_vault] = 'add_customer'
post[:customer_vault_id] = options[:store] unless options[:store] == true
@@ -164,7 +164,7 @@ def add_check(post, check)
def parse(body)
results = {}
body.split(/&/).each do |pair|
- key,val = pair.split(%r{=})
+ key, val = pair.split(%r{=})
results[key] = val
end
@@ -174,7 +174,7 @@ def parse(body)
def commit(action, money, parameters)
parameters[:amount] = amount(money) if money
- response = parse( ssl_post(self.live_url, post_data(action,parameters)) )
+ response = parse( ssl_post(self.live_url, post_data(action, parameters)) )
Response.new(response['response'] == '1', message_from(response), response,
:authorization => response['transactionid'],
@@ -186,7 +186,7 @@ def commit(action, money, parameters)
def message_from(response)
case response['responsetext']
- when 'SUCCESS','Approved'
+ when 'SUCCESS', 'Approved'
'This transaction has been approved'
when 'DECLINE'
'This transaction has been declined'
@@ -201,7 +201,7 @@ def post_data(action, parameters = {})
post[:password] = @options[:password]
post[:type] = action if action
- request = post.merge(parameters).map {|key,value| "#{key}=#{CGI.escape(value.to_s)}"}.join('&')
+ request = post.merge(parameters).map {|key, value| "#{key}=#{CGI.escape(value.to_s)}"}.join('&')
request
end
diff --git a/lib/active_merchant/billing/gateways/iridium.rb b/lib/active_merchant/billing/gateways/iridium.rb
index 65024f293aa..6b0ca00b4b7 100644
--- a/lib/active_merchant/billing/gateways/iridium.rb
+++ b/lib/active_merchant/billing/gateways/iridium.rb
@@ -419,29 +419,29 @@ def parse_element(reply, node)
case node.name
when 'CrossReferenceTransactionResult'
reply[:transaction_result] = {}
- node.attributes.each do |a,b|
+ node.attributes.each do |a, b|
reply[:transaction_result][a.underscore.to_sym] = b
end
node.elements.each{|e| parse_element(reply[:transaction_result], e) } if node.has_elements?
when 'CardDetailsTransactionResult'
reply[:transaction_result] = {}
- node.attributes.each do |a,b|
+ node.attributes.each do |a, b|
reply[:transaction_result][a.underscore.to_sym] = b
end
node.elements.each{|e| parse_element(reply[:transaction_result], e) } if node.has_elements?
when 'TransactionOutputData'
reply[:transaction_output_data] = {}
- node.attributes.each{|a,b| reply[:transaction_output_data][a.underscore.to_sym] = b }
+ node.attributes.each{|a, b| reply[:transaction_output_data][a.underscore.to_sym] = b }
node.elements.each{|e| parse_element(reply[:transaction_output_data], e) } if node.has_elements?
when 'CustomVariables'
reply[:custom_variables] = {}
- node.attributes.each{|a,b| reply[:custom_variables][a.underscore.to_sym] = b }
+ node.attributes.each{|a, b| reply[:custom_variables][a.underscore.to_sym] = b }
node.elements.each{|e| parse_element(reply[:custom_variables], e) } if node.has_elements?
when 'GatewayEntryPoints'
reply[:gateway_entry_points] = {}
- node.attributes.each{|a,b| reply[:gateway_entry_points][a.underscore.to_sym] = b }
+ node.attributes.each{|a, b| reply[:gateway_entry_points][a.underscore.to_sym] = b }
node.elements.each{|e| parse_element(reply[:gateway_entry_points], e) } if node.has_elements?
else
k = node.name.underscore.to_sym
@@ -451,7 +451,7 @@ def parse_element(reply, node)
else
if node.has_attributes?
reply[k] = {}
- node.attributes.each{|a,b| reply[k][a.underscore.to_sym] = b }
+ node.attributes.each{|a, b| reply[k][a.underscore.to_sym] = b }
else
reply[k] = node.text
end
diff --git a/lib/active_merchant/billing/gateways/itransact.rb b/lib/active_merchant/billing/gateways/itransact.rb
index e76919e4b8f..e7861de3d95 100644
--- a/lib/active_merchant/billing/gateways/itransact.rb
+++ b/lib/active_merchant/billing/gateways/itransact.rb
@@ -336,7 +336,7 @@ def add_creditcard(xml, creditcard)
xml.AccountInfo {
xml.CardAccount {
xml.AccountNumber(creditcard.number.to_s)
- xml.ExpirationMonth(creditcard.month.to_s.rjust(2,'0'))
+ xml.ExpirationMonth(creditcard.month.to_s.rjust(2, '0'))
xml.ExpirationYear(creditcard.year.to_s)
xml.CVVNumber(creditcard.verification_value.to_s) unless creditcard.verification_value.blank?
}
@@ -372,7 +372,7 @@ def add_transaction_control(xml, options)
def add_vendor_data(xml, options)
return if options[:vendor_data].blank?
xml.VendorData {
- options[:vendor_data].each do |k,v|
+ options[:vendor_data].each do |k, v|
xml.Element {
xml.Name(k)
xml.Key(v)
diff --git a/lib/active_merchant/billing/gateways/iveri.rb b/lib/active_merchant/billing/gateways/iveri.rb
index 808966879c2..6d0f1f092df 100644
--- a/lib/active_merchant/billing/gateways/iveri.rb
+++ b/lib/active_merchant/billing/gateways/iveri.rb
@@ -241,8 +241,8 @@ def error_code_from(response, succeeded)
def underscore(camel_cased_word)
camel_cased_word.to_s.gsub(/::/, '/').
- gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
- gsub(/([a-z\d])([A-Z])/,'\1_\2').
+ gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
+ gsub(/([a-z\d])([A-Z])/, '\1_\2').
tr('-', '_').
downcase
end
diff --git a/lib/active_merchant/billing/gateways/jetpay.rb b/lib/active_merchant/billing/gateways/jetpay.rb
index f6c631c4421..cbe81b5368f 100644
--- a/lib/active_merchant/billing/gateways/jetpay.rb
+++ b/lib/active_merchant/billing/gateways/jetpay.rb
@@ -344,7 +344,7 @@ def add_credit_card(xml, credit_card)
xml.tag! 'CardExpYear', format_exp(credit_card.year)
if credit_card.first_name || credit_card.last_name
- xml.tag! 'CardName', [credit_card.first_name,credit_card.last_name].compact.join(' ')
+ xml.tag! 'CardName', [credit_card.first_name, credit_card.last_name].compact.join(' ')
end
unless credit_card.verification_value.nil? || (credit_card.verification_value.length == 0)
diff --git a/lib/active_merchant/billing/gateways/jetpay_v2.rb b/lib/active_merchant/billing/gateways/jetpay_v2.rb
index ff136384912..ae99f7f75e3 100644
--- a/lib/active_merchant/billing/gateways/jetpay_v2.rb
+++ b/lib/active_merchant/billing/gateways/jetpay_v2.rb
@@ -369,7 +369,7 @@ def add_credit_card(xml, credit_card)
xml.tag! 'CardExpYear', format_exp(credit_card.year)
if credit_card.first_name || credit_card.last_name
- xml.tag! 'CardName', [credit_card.first_name,credit_card.last_name].compact.join(' ')
+ xml.tag! 'CardName', [credit_card.first_name, credit_card.last_name].compact.join(' ')
end
unless credit_card.verification_value.nil? || (credit_card.verification_value.length == 0)
diff --git a/lib/active_merchant/billing/gateways/linkpoint.rb b/lib/active_merchant/billing/gateways/linkpoint.rb
index 37f0b3ab0b5..61e5fe0e430 100644
--- a/lib/active_merchant/billing/gateways/linkpoint.rb
+++ b/lib/active_merchant/billing/gateways/linkpoint.rb
@@ -266,8 +266,8 @@ def commit(money, creditcard, options = {})
Response.new(successful?(response), response[:message], response,
:test => test?,
:authorization => response[:ordernum],
- :avs_result => { :code => response[:avs].to_s[2,1] },
- :cvv_result => response[:avs].to_s[3,1]
+ :avs_result => { :code => response[:avs].to_s[2, 1] },
+ :cvv_result => response[:avs].to_s[3, 1]
)
end
diff --git a/lib/active_merchant/billing/gateways/merchant_e_solutions.rb b/lib/active_merchant/billing/gateways/merchant_e_solutions.rb
index f1306ce3db9..1f465a07ca4 100644
--- a/lib/active_merchant/billing/gateways/merchant_e_solutions.rb
+++ b/lib/active_merchant/billing/gateways/merchant_e_solutions.rb
@@ -148,7 +148,7 @@ def add_3dsecure_params(post, options)
def parse(body)
results = {}
body.split(/&/).each do |pair|
- key,val = pair.split(/=/)
+ key, val = pair.split(/=/)
results[key] = val
end
results
@@ -159,7 +159,7 @@ def commit(action, money, parameters)
parameters[:transaction_amount] = amount(money) if money unless action == 'V'
response = begin
- parse( ssl_post(url, post_data(action,parameters)) )
+ parse( ssl_post(url, post_data(action, parameters)) )
rescue ActiveMerchant::ResponseError => e
{ 'error_code' => '404', 'auth_response_text' => e.to_s }
end
@@ -186,7 +186,7 @@ def post_data(action, parameters = {})
post[:profile_key] = @options[:password]
post[:transaction_type] = action if action
- request = post.merge(parameters).map {|key,value| "#{key}=#{CGI.escape(value.to_s)}"}.join('&')
+ request = post.merge(parameters).map {|key, value| "#{key}=#{CGI.escape(value.to_s)}"}.join('&')
request
end
end
diff --git a/lib/active_merchant/billing/gateways/merchant_one.rb b/lib/active_merchant/billing/gateways/merchant_one.rb
index 2352178da07..e20dfe354bf 100644
--- a/lib/active_merchant/billing/gateways/merchant_one.rb
+++ b/lib/active_merchant/billing/gateways/merchant_one.rb
@@ -83,7 +83,7 @@ def add_creditcard(post, creditcard)
def commit(action, money, parameters={})
parameters['username'] = @options[:username]
parameters['password'] = @options[:password]
- parse(ssl_post(BASE_URL,post_data(action, parameters)))
+ parse(ssl_post(BASE_URL, post_data(action, parameters)))
end
def post_data(action, parameters = {})
@@ -99,7 +99,7 @@ def post_data(action, parameters = {})
end
def parse(data)
- responses = CGI.parse(data).inject({}){|h,(k, v)| h[k] = v.first; h}
+ responses = CGI.parse(data).inject({}){|h, (k, v)| h[k] = v.first; h}
Response.new(
(responses['response'].to_i == 1),
responses['responsetext'],
diff --git a/lib/active_merchant/billing/gateways/merchant_warrior.rb b/lib/active_merchant/billing/gateways/merchant_warrior.rb
index 66da5f62317..6a8e5538bb5 100644
--- a/lib/active_merchant/billing/gateways/merchant_warrior.rb
+++ b/lib/active_merchant/billing/gateways/merchant_warrior.rb
@@ -203,7 +203,7 @@ def success?(response)
end
def post_data(post)
- post.collect{|k,v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
+ post.collect{|k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
end
end
end
diff --git a/lib/active_merchant/billing/gateways/mercury.rb b/lib/active_merchant/billing/gateways/mercury.rb
index 9580630d773..6fea6dd9197 100644
--- a/lib/active_merchant/billing/gateways/mercury.rb
+++ b/lib/active_merchant/billing/gateways/mercury.rb
@@ -18,7 +18,7 @@ class MercuryGateway < Gateway
self.homepage_url = 'http://www.mercurypay.com'
self.display_name = 'Mercury'
- self.supported_countries = ['US','CA']
+ self.supported_countries = ['US', 'CA']
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb]
self.default_currency = 'USD'
@@ -349,7 +349,7 @@ def escape_xml(xml)
end
def unescape_xml(escaped_xml)
- escaped_xml.gsub(/\>/,'>').gsub(/\</,'<')
+ escaped_xml.gsub(/\>/, '>').gsub(/\</, '<')
end
end
end
diff --git a/lib/active_merchant/billing/gateways/moneris_us.rb b/lib/active_merchant/billing/gateways/moneris_us.rb
index 5cb3c515183..9355406aed3 100644
--- a/lib/active_merchant/billing/gateways/moneris_us.rb
+++ b/lib/active_merchant/billing/gateways/moneris_us.rb
@@ -223,7 +223,7 @@ def commit(action, parameters = {})
Response.new(successful?(response), message_from(response[:message]), response,
:test => test?,
:avs_result => { :code => response[:avs_result_code] },
- :cvv_result => response[:cvd_result_code] && response[:cvd_result_code][-1,1],
+ :cvv_result => response[:cvd_result_code] && response[:cvd_result_code][-1, 1],
:authorization => authorization_from(response)
)
end
diff --git a/lib/active_merchant/billing/gateways/mundipagg.rb b/lib/active_merchant/billing/gateways/mundipagg.rb
index fa9c882c6d2..cb23e8e6235 100644
--- a/lib/active_merchant/billing/gateways/mundipagg.rb
+++ b/lib/active_merchant/billing/gateways/mundipagg.rb
@@ -177,7 +177,7 @@ def add_credit_card(post, payment, options)
post[:payment][:credit_card][:card][:exp_year] = payment.year
post[:payment][:credit_card][:card][:cvv] = payment.verification_value
post[:payment][:credit_card][:card][:holder_document] = options[:holder_document] if options[:holder_document]
- add_billing_address(post,'credit_card', options)
+ add_billing_address(post, 'credit_card', options)
end
end
diff --git a/lib/active_merchant/billing/gateways/net_registry.rb b/lib/active_merchant/billing/gateways/net_registry.rb
index 62a2e8c9ba9..88cec2f11cf 100644
--- a/lib/active_merchant/billing/gateways/net_registry.rb
+++ b/lib/active_merchant/billing/gateways/net_registry.rb
@@ -152,7 +152,7 @@ def commit(action, params)
def post_data(action, params)
params['COMMAND'] = TRANSACTIONS[action]
params['LOGIN'] = "#{@options[:login]}/#{@options[:password]}"
- escape_uri(params.map{|k,v| "#{k}=#{v}"}.join('&'))
+ escape_uri(params.map{|k, v| "#{k}=#{v}"}.join('&'))
end
# The upstream is picky and so we can't use CGI.escape like we want to
diff --git a/lib/active_merchant/billing/gateways/netaxept.rb b/lib/active_merchant/billing/gateways/netaxept.rb
index f142ce5a968..18eb61964ca 100644
--- a/lib/active_merchant/billing/gateways/netaxept.rb
+++ b/lib/active_merchant/billing/gateways/netaxept.rb
@@ -173,7 +173,7 @@ def build_url(base, parameters=nil)
end
def encode(hash)
- hash.collect{|(k,v)| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}"}.join('&')
+ hash.collect{|(k, v)| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}"}.join('&')
end
end
end
diff --git a/lib/active_merchant/billing/gateways/netbilling.rb b/lib/active_merchant/billing/gateways/netbilling.rb
index 32635e806dd..7b13aaf27cf 100644
--- a/lib/active_merchant/billing/gateways/netbilling.rb
+++ b/lib/active_merchant/billing/gateways/netbilling.rb
@@ -186,7 +186,7 @@ def add_credit_card(post, credit_card)
def parse(body)
results = {}
body.split(/&/).each do |pair|
- key,val = pair.split(/\=/)
+ key, val = pair.split(/\=/)
results[key.to_sym] = CGI.unescape(val)
end
results
@@ -224,7 +224,7 @@ def post_data(action, parameters = {})
parameters[:pay_type] = 'C'
parameters[:tran_type] = TRANSACTIONS[action]
- parameters.reject{|k,v| v.blank?}.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
+ parameters.reject{|k, v| v.blank?}.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
end
end
diff --git a/lib/active_merchant/billing/gateways/nmi.rb b/lib/active_merchant/billing/gateways/nmi.rb
index 0b6910ba82a..aa6e956f6c1 100644
--- a/lib/active_merchant/billing/gateways/nmi.rb
+++ b/lib/active_merchant/billing/gateways/nmi.rb
@@ -254,7 +254,7 @@ def url
end
def parse(body)
- Hash[CGI::parse(body).map { |k,v| [k.intern, v.first] }]
+ Hash[CGI::parse(body).map { |k, v| [k.intern, v.first] }]
end
def success_from(response)
diff --git a/lib/active_merchant/billing/gateways/ogone.rb b/lib/active_merchant/billing/gateways/ogone.rb
index b0a8be19343..99f998e895f 100644
--- a/lib/active_merchant/billing/gateways/ogone.rb
+++ b/lib/active_merchant/billing/gateways/ogone.rb
@@ -429,9 +429,9 @@ def calculate_signature(signed_parameters, algorithm, secret)
raise "Unknown signature algorithm #{algorithm}"
end
- filtered_params = signed_parameters.select{|k,v| !v.blank?}
+ filtered_params = signed_parameters.select{|k, v| !v.blank?}
sha_encryptor.hexdigest(
- filtered_params.sort_by{|k,v| k.upcase}.map{|k, v| "#{k.upcase}=#{v}#{secret}"}.join('')
+ filtered_params.sort_by{|k, v| k.upcase}.map{|k, v| "#{k.upcase}=#{v}#{secret}"}.join('')
).upcase
end
diff --git a/lib/active_merchant/billing/gateways/omise.rb b/lib/active_merchant/billing/gateways/omise.rb
index 3dbb8e30c37..fbb1af839ab 100644
--- a/lib/active_merchant/billing/gateways/omise.rb
+++ b/lib/active_merchant/billing/gateways/omise.rb
@@ -164,7 +164,7 @@ def scrub(transcript)
transcript.
gsub(/(Authorization: Basic )\w+/i, '\1[FILTERED]').
gsub(/(\\"number\\":)\\"\d+\\"/, '\1[FILTERED]').
- gsub(/(\\"security_code\\":)\\"\d+\\"/,'\1[FILTERED]')
+ gsub(/(\\"security_code\\":)\\"\d+\\"/, '\1[FILTERED]')
end
private
diff --git a/lib/active_merchant/billing/gateways/orbital.rb b/lib/active_merchant/billing/gateways/orbital.rb
index c5f9000e4e3..fe3f1a3b1d8 100644
--- a/lib/active_merchant/billing/gateways/orbital.rb
+++ b/lib/active_merchant/billing/gateways/orbital.rb
@@ -516,7 +516,7 @@ def parse(body)
end
end
- response.delete_if { |k,_| SENSITIVE_FIELDS.include?(k) }
+ response.delete_if { |k, _| SENSITIVE_FIELDS.include?(k) }
end
def recurring_parse_element(response, node)
diff --git a/lib/active_merchant/billing/gateways/pay_junction.rb b/lib/active_merchant/billing/gateways/pay_junction.rb
index 0113c737966..84ccb33b34b 100644
--- a/lib/active_merchant/billing/gateways/pay_junction.rb
+++ b/lib/active_merchant/billing/gateways/pay_junction.rb
@@ -366,7 +366,7 @@ def post_data(action, params)
params[:version] = API_VERSION
params[:transaction_type] = action
- params.reject{|k,v| v.blank?}.collect{ |k, v| "dc_#{k}=#{CGI.escape(v.to_s)}" }.join('&')
+ params.reject{|k, v| v.blank?}.collect{ |k, v| "dc_#{k}=#{CGI.escape(v.to_s)}" }.join('&')
end
def parse(body)
diff --git a/lib/active_merchant/billing/gateways/pay_junction_v2.rb b/lib/active_merchant/billing/gateways/pay_junction_v2.rb
index 669188c9d48..2f9a5148dc7 100644
--- a/lib/active_merchant/billing/gateways/pay_junction_v2.rb
+++ b/lib/active_merchant/billing/gateways/pay_junction_v2.rb
@@ -173,7 +173,7 @@ def success_from(response)
def message_from(response)
return response['response']['message'] if response['response']
- response['errors']&.inject(''){ |message,error| error['message'] + '|' + message }
+ response['errors']&.inject(''){ |message, error| error['message'] + '|' + message }
end
def authorization_from(response)
diff --git a/lib/active_merchant/billing/gateways/pay_secure.rb b/lib/active_merchant/billing/gateways/pay_secure.rb
index bbdfc2bacf9..f5f539a3185 100644
--- a/lib/active_merchant/billing/gateways/pay_secure.rb
+++ b/lib/active_merchant/billing/gateways/pay_secure.rb
@@ -52,7 +52,7 @@ def add_amount(post, money)
end
def add_invoice(post, options)
- post[:merchant_transid] = options[:order_id].to_s.slice(0,21)
+ post[:merchant_transid] = options[:order_id].to_s.slice(0, 21)
post[:memnum] = options[:invoice]
post[:custnum] = options[:customer]
post[:clientdata] = options[:description]
@@ -104,7 +104,7 @@ def post_data(action, parameters = {})
parameters[:merchant_id] = @options[:login]
parameters[:password] = @options[:password]
- parameters.reject{|k,v| v.blank?}.collect { |key, value| "#{key.to_s.upcase}=#{CGI.escape(value.to_s)}" }.join('&')
+ parameters.reject{|k, v| v.blank?}.collect { |key, value| "#{key.to_s.upcase}=#{CGI.escape(value.to_s)}" }.join('&')
end
end
end
diff --git a/lib/active_merchant/billing/gateways/paybox_direct.rb b/lib/active_merchant/billing/gateways/paybox_direct.rb
index c66933c5baa..ecb3d938a9f 100644
--- a/lib/active_merchant/billing/gateways/paybox_direct.rb
+++ b/lib/active_merchant/billing/gateways/paybox_direct.rb
@@ -86,8 +86,8 @@ def capture(money, authorization, options = {})
post = {}
add_invoice(post, options)
add_amount(post, money, options)
- post[:numappel] = authorization[0,10]
- post[:numtrans] = authorization[10,10]
+ post[:numappel] = authorization[0, 10]
+ post[:numtrans] = authorization[10, 10]
commit('capture', money, post)
end
@@ -130,8 +130,8 @@ def add_creditcard(post, creditcard)
end
def add_reference(post, identification)
- post[:numappel] = identification[0,10]
- post[:numtrans] = identification[10,10]
+ post[:numappel] = identification[0, 10]
+ post[:numtrans] = identification[10, 10]
end
def add_amount(post, money, options)
@@ -142,14 +142,14 @@ def add_amount(post, money, options)
def parse(body)
results = {}
body.split(/&/).each do |pair|
- key,val = pair.split(/\=/)
+ key, val = pair.split(/\=/)
results[key.downcase.to_sym] = CGI.unescape(val) if val
end
results
end
def commit(action, money = nil, parameters = nil)
- request_data = post_data(action,parameters)
+ request_data = post_data(action, parameters)
response = parse(ssl_post(test? ? self.test_url : self.live_url, request_data))
response = parse(ssl_post(self.live_url_backup, request_data)) if service_unavailable?(response) && !test?
Response.new(success?(response), message_from(response), response.merge(
@@ -157,7 +157,7 @@ def commit(action, money = nil, parameters = nil)
:test => test?,
:authorization => response[:numappel].to_s + response[:numtrans].to_s,
:fraud_review => false,
- :sent_params => parameters.delete_if{|key,value| ['porteur','dateval','cvv'].include?(key.to_s)}
+ :sent_params => parameters.delete_if{|key, value| ['porteur', 'dateval', 'cvv'].include?(key.to_s)}
)
end
@@ -179,7 +179,7 @@ def post_data(action, parameters = {})
:type => TRANSACTIONS[action.to_sym],
:dateq => Time.now.strftime('%d%m%Y%H%M%S'),
:numquestion => unique_id(parameters[:order_id]),
- :site => @options[:login].to_s[0,7],
+ :site => @options[:login].to_s[0, 7],
:rang => @options[:rang] || @options[:login].to_s[7..-1],
:cle => @options[:password],
:pays => '',
diff --git a/lib/active_merchant/billing/gateways/payflow.rb b/lib/active_merchant/billing/gateways/payflow.rb
index 418e2e05b68..e8f08d29834 100644
--- a/lib/active_merchant/billing/gateways/payflow.rb
+++ b/lib/active_merchant/billing/gateways/payflow.rb
@@ -143,7 +143,7 @@ def build_reference_sale_or_authorization_request(action, money, reference, opti
billing_address = options[:billing_address] || options[:address]
add_address(xml, 'BillTo', billing_address, options) if billing_address
- add_address(xml, 'ShipTo', options[:shipping_address],options) if options[:shipping_address]
+ add_address(xml, 'ShipTo', options[:shipping_address], options) if options[:shipping_address]
xml.tag! 'TotalAmt', amount(money), 'Currency' => options[:currency] || currency(money)
end
diff --git a/lib/active_merchant/billing/gateways/payflow_express.rb b/lib/active_merchant/billing/gateways/payflow_express.rb
index c2970b6e052..9676d2b1cf2 100644
--- a/lib/active_merchant/billing/gateways/payflow_express.rb
+++ b/lib/active_merchant/billing/gateways/payflow_express.rb
@@ -198,7 +198,7 @@ def add_paypal_details(xml, options)
xml.tag! 'Token', options[:token] unless options[:token].blank?
xml.tag! 'NoShipping', options[:no_shipping] ? '1' : '0'
xml.tag! 'AddressOverride', options[:address_override] ? '1' : '0'
- xml.tag! 'ButtonSource', application_id.to_s.slice(0,32) unless application_id.blank?
+ xml.tag! 'ButtonSource', application_id.to_s.slice(0, 32) unless application_id.blank?
# Customization of the payment page
xml.tag! 'PageStyle', options[:page_style] unless options[:page_style].blank?
diff --git a/lib/active_merchant/billing/gateways/payment_express.rb b/lib/active_merchant/billing/gateways/payment_express.rb
index b668aa14109..d3e28786d8e 100644
--- a/lib/active_merchant/billing/gateways/payment_express.rb
+++ b/lib/active_merchant/billing/gateways/payment_express.rb
@@ -274,9 +274,9 @@ def add_optional_elements(xml, options)
xml.add_element('ClientType').text = client_type
end
- xml.add_element('TxnData1').text = options[:txn_data1].to_s.slice(0,255) unless options[:txn_data1].blank?
- xml.add_element('TxnData2').text = options[:txn_data2].to_s.slice(0,255) unless options[:txn_data2].blank?
- xml.add_element('TxnData3').text = options[:txn_data3].to_s.slice(0,255) unless options[:txn_data3].blank?
+ xml.add_element('TxnData1').text = options[:txn_data1].to_s.slice(0, 255) unless options[:txn_data1].blank?
+ xml.add_element('TxnData2').text = options[:txn_data2].to_s.slice(0, 255) unless options[:txn_data2].blank?
+ xml.add_element('TxnData3').text = options[:txn_data3].to_s.slice(0, 255) unless options[:txn_data3].blank?
end
def new_transaction
diff --git a/lib/active_merchant/billing/gateways/payway.rb b/lib/active_merchant/billing/gateways/payway.rb
index e8f9d8c163a..b80e5f937a1 100644
--- a/lib/active_merchant/billing/gateways/payway.rb
+++ b/lib/active_merchant/billing/gateways/payway.rb
@@ -150,7 +150,7 @@ def add_payment_method(post, payment_method)
post['card.cardHolderName'] = "#{payment_method.first_name} #{payment_method.last_name}"
post['card.PAN'] = payment_method.number
post['card.CVN'] = payment_method.verification_value
- post['card.expiryYear'] = payment_method.year.to_s[-2,2]
+ post['card.expiryYear'] = payment_method.year.to_s[-2, 2]
post['card.expiryMonth'] = sprintf('%02d', payment_method.month)
else
post['customer.customerReferenceNumber'] = payment_method
diff --git a/lib/active_merchant/billing/gateways/plugnpay.rb b/lib/active_merchant/billing/gateways/plugnpay.rb
index 634c1294189..750f133a35b 100644
--- a/lib/active_merchant/billing/gateways/plugnpay.rb
+++ b/lib/active_merchant/billing/gateways/plugnpay.rb
@@ -189,7 +189,7 @@ def commit(action, post)
def parse(body)
body = CGI.unescape(body)
results = {}
- body.split('&').collect { |e| e.split('=') }.each do |key,value|
+ body.split('&').collect { |e| e.split('=') }.each do |key, value|
results[key.downcase.to_sym] = normalize(value.to_s.strip)
end
diff --git a/lib/active_merchant/billing/gateways/pro_pay.rb b/lib/active_merchant/billing/gateways/pro_pay.rb
index ef3eb1050a9..d70b1539bb0 100644
--- a/lib/active_merchant/billing/gateways/pro_pay.rb
+++ b/lib/active_merchant/billing/gateways/pro_pay.rb
@@ -317,8 +317,8 @@ def build_xml_request
def underscore(camel_cased_word)
camel_cased_word.to_s.gsub(/::/, '/').
- gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
- gsub(/([a-z\d])([A-Z])/,'\1_\2').
+ gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
+ gsub(/([a-z\d])([A-Z])/, '\1_\2').
tr('-', '_').
downcase
end
diff --git a/lib/active_merchant/billing/gateways/psigate.rb b/lib/active_merchant/billing/gateways/psigate.rb
index f8dfbc67a5c..b987dd1e74b 100644
--- a/lib/active_merchant/billing/gateways/psigate.rb
+++ b/lib/active_merchant/billing/gateways/psigate.rb
@@ -168,7 +168,7 @@ def parameters(money, creditcard, options = {})
if creditcard
exp_month = sprintf('%.2i', creditcard.month) unless creditcard.month.blank?
- exp_year = creditcard.year.to_s[2,2] unless creditcard.year.blank?
+ exp_year = creditcard.year.to_s[2, 2] unless creditcard.year.blank?
card_id_code = (creditcard.verification_value.blank? ? nil : '1')
params.update(
diff --git a/lib/active_merchant/billing/gateways/quantum.rb b/lib/active_merchant/billing/gateways/quantum.rb
index 280bdcd87c8..e3b1d12decd 100644
--- a/lib/active_merchant/billing/gateways/quantum.rb
+++ b/lib/active_merchant/billing/gateways/quantum.rb
@@ -81,7 +81,7 @@ def setup_address_hash(options)
def build_auth_request(money, creditcard, options)
xml = Builder::XmlMarkup.new
- add_common_credit_card_info(xml,'AUTH_ONLY')
+ add_common_credit_card_info(xml, 'AUTH_ONLY')
add_purchase_data(xml, money)
add_creditcard(xml, creditcard)
add_address(xml, creditcard, options[:billing_address], options)
@@ -94,7 +94,7 @@ def build_auth_request(money, creditcard, options)
def build_capture_request(money, authorization, options)
xml = Builder::XmlMarkup.new
- add_common_credit_card_info(xml,'PREVIOUS_SALE')
+ add_common_credit_card_info(xml, 'PREVIOUS_SALE')
transaction_id, _ = authorization_parts_from(authorization)
add_transaction_id(xml, transaction_id)
xml.target!
@@ -115,7 +115,7 @@ def build_purchase_request(money, creditcard, options)
def build_void_request(authorization, options)
xml = Builder::XmlMarkup.new
- add_common_credit_card_info(xml,'VOID')
+ add_common_credit_card_info(xml, 'VOID')
transaction_id, _ = authorization_parts_from(authorization)
add_transaction_id(xml, transaction_id)
xml.target!
@@ -123,7 +123,7 @@ def build_void_request(authorization, options)
def build_credit_request(money, authorization, options)
xml = Builder::XmlMarkup.new
- add_common_credit_card_info(xml,'RETURN')
+ add_common_credit_card_info(xml, 'RETURN')
add_purchase_data(xml, money)
transaction_id, cc = authorization_parts_from(authorization)
add_transaction_id(xml, transaction_id)
diff --git a/lib/active_merchant/billing/gateways/quickbooks.rb b/lib/active_merchant/billing/gateways/quickbooks.rb
index f346cefc34b..48442334eb2 100644
--- a/lib/active_merchant/billing/gateways/quickbooks.rb
+++ b/lib/active_merchant/billing/gateways/quickbooks.rb
@@ -48,7 +48,7 @@ class QuickbooksGateway < Gateway
'PMT-6000' => STANDARD_ERROR_CODE[:processing_error], # A temporary Issue prevented this request from being processed.
}
- FRAUD_WARNING_CODES = ['PMT-1000','PMT-1001','PMT-1002','PMT-1003']
+ FRAUD_WARNING_CODES = ['PMT-1000', 'PMT-1001', 'PMT-1002', 'PMT-1003']
def initialize(options = {})
requires!(options, :consumer_key, :consumer_secret, :access_token, :token_secret, :realm)
diff --git a/lib/active_merchant/billing/gateways/qvalent.rb b/lib/active_merchant/billing/gateways/qvalent.rb
index 6d59464a09c..0dd7c279255 100644
--- a/lib/active_merchant/billing/gateways/qvalent.rb
+++ b/lib/active_merchant/billing/gateways/qvalent.rb
@@ -103,7 +103,7 @@ def scrub(transcript)
private
- CURRENCY_CODES = Hash.new{|h,k| raise ArgumentError.new("Unsupported currency: #{k}")}
+ CURRENCY_CODES = Hash.new{|h, k| raise ArgumentError.new("Unsupported currency: #{k}")}
CURRENCY_CODES['AUD'] = 'AUD'
CURRENCY_CODES['INR'] = 'INR'
diff --git a/lib/active_merchant/billing/gateways/realex.rb b/lib/active_merchant/billing/gateways/realex.rb
index 6d58ea3f6e9..1892e652378 100644
--- a/lib/active_merchant/billing/gateways/realex.rb
+++ b/lib/active_merchant/billing/gateways/realex.rb
@@ -279,7 +279,7 @@ def add_network_tokenization_card(xml, payment)
end
xml.tag! 'supplementarydata' do
xml.tag! 'item', 'type' => 'mobile' do
- xml.tag! 'field01', payment.source.to_s.gsub('_','-')
+ xml.tag! 'field01', payment.source.to_s.gsub('_', '-')
end
end
end
diff --git a/lib/active_merchant/billing/gateways/safe_charge.rb b/lib/active_merchant/billing/gateways/safe_charge.rb
index 7a3c64f7a27..8d3cccd3cc6 100644
--- a/lib/active_merchant/billing/gateways/safe_charge.rb
+++ b/lib/active_merchant/billing/gateways/safe_charge.rb
@@ -252,8 +252,8 @@ def error_code_from(response)
def underscore(camel_cased_word)
camel_cased_word.to_s.gsub(/::/, '/').
- gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
- gsub(/([a-z\d])([A-Z])/,'\1_\2').
+ gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
+ gsub(/([a-z\d])([A-Z])/, '\1_\2').
tr('-', '_').
downcase
end
diff --git a/lib/active_merchant/billing/gateways/sage.rb b/lib/active_merchant/billing/gateways/sage.rb
index 2c44e92eeed..52bb573c93e 100644
--- a/lib/active_merchant/billing/gateways/sage.rb
+++ b/lib/active_merchant/billing/gateways/sage.rb
@@ -179,9 +179,9 @@ def parse(data, source)
def parse_check(data)
response = {}
- response[:success] = data[1,1]
- response[:code] = data[2,6].strip
- response[:message] = data[8,32].strip
+ response[:success] = data[1, 1]
+ response[:code] = data[2, 6].strip
+ response[:message] = data[8, 32].strip
response[:risk] = data[40, 2]
response[:reference] = data[42, 10]
@@ -194,9 +194,9 @@ def parse_check(data)
def parse_credit_card(data)
response = {}
- response[:success] = data[1,1]
- response[:code] = data[2,6]
- response[:message] = data[8,32].strip
+ response[:success] = data[1, 1]
+ response[:code] = data[2, 6]
+ response[:message] = data[8, 32].strip
response[:front_end] = data[40, 2]
response[:cvv_result] = data[42, 1]
response[:avs_result] = data[43, 1].strip
diff --git a/lib/active_merchant/billing/gateways/skip_jack.rb b/lib/active_merchant/billing/gateways/skip_jack.rb
index adbbd32f0dc..56dd6a2309e 100644
--- a/lib/active_merchant/billing/gateways/skip_jack.rb
+++ b/lib/active_merchant/billing/gateways/skip_jack.rb
@@ -368,7 +368,7 @@ def add_invoice(post, options)
post[:OrderDescription] = options[:description]
if order_items = options[:items]
- post[:OrderString] = order_items.collect { |item| "#{item[:sku]}~#{item[:description].tr('~','-')}~#{item[:declared_value]}~#{item[:quantity]}~#{item[:taxable]}~~~~~~~~#{item[:tax_rate]}~||"}.join
+ post[:OrderString] = order_items.collect { |item| "#{item[:sku]}~#{item[:description].tr('~', '-')}~#{item[:declared_value]}~#{item[:quantity]}~#{item[:taxable]}~~~~~~~~#{item[:tax_rate]}~||"}.join
else
post[:OrderString] = '1~None~0.00~0~N~||'
end
diff --git a/lib/active_merchant/billing/gateways/smart_ps.rb b/lib/active_merchant/billing/gateways/smart_ps.rb
index b6a89f13b39..8f84413abdc 100644
--- a/lib/active_merchant/billing/gateways/smart_ps.rb
+++ b/lib/active_merchant/billing/gateways/smart_ps.rb
@@ -23,7 +23,7 @@ def initialize(options = {})
def authorize(money, creditcard, options = {})
post = {}
add_invoice(post, options)
- add_payment_source(post, creditcard,options)
+ add_payment_source(post, creditcard, options)
add_address(post, options[:billing_address] || options[:address])
add_address(post, options[:shipping_address], 'shipping')
add_customer_data(post, options)
@@ -65,7 +65,7 @@ def credit(money, payment_source, options = {})
add_payment_source(post, payment_source, options)
add_address(post, options[:billing_address] || options[:address])
add_customer_data(post, options)
- add_sku(post,options)
+ add_sku(post, options)
add_currency(post, money, options)
add_processor(post, options)
commit('credit', money, post)
@@ -138,7 +138,7 @@ def add_customer_data(post, options)
end
end
- def add_address(post, address,prefix='')
+ def add_address(post, address, prefix='')
prefix +='_' unless prefix.blank?
unless address.blank? or address.values.blank?
post[prefix+'address1'] = address[:address1].to_s
@@ -206,7 +206,7 @@ def add_check(post, check, options)
post[:account_type] = check.account_type # The customer's type of ACH account
end
- def add_sku(post,options)
+ def add_sku(post, options)
post['product_sku_#'] = options[:sku] || options['product_sku_#']
end
@@ -221,7 +221,7 @@ def add_eci(post, options)
def parse(body)
results = {}
body.split(/&/).each do |pair|
- key,val = pair.split(/=/)
+ key, val = pair.split(/=/)
results[key] = val
end
@@ -230,7 +230,7 @@ def parse(body)
def commit(action, money, parameters)
parameters[:amount] = localized_amount(money, parameters[:currency] || default_currency) if money
- response = parse( ssl_post(self.live_url, post_data(action,parameters)) )
+ response = parse( ssl_post(self.live_url, post_data(action, parameters)) )
Response.new(response['response'] == '1', message_from(response), response,
:authorization => (response['transactionid'] || response['customer_vault_id']),
:test => test?,
@@ -263,7 +263,7 @@ def post_data(action, parameters = {})
post[:password] = @options[:password]
post[:type] = action if action
- request = post.merge(parameters).map {|key,value| "#{key}=#{CGI.escape(value.to_s)}"}.join('&')
+ request = post.merge(parameters).map {|key, value| "#{key}=#{CGI.escape(value.to_s)}"}.join('&')
request
end
diff --git a/lib/active_merchant/billing/gateways/so_easy_pay.rb b/lib/active_merchant/billing/gateways/so_easy_pay.rb
index 7b5198b7be7..f0fa4523322 100644
--- a/lib/active_merchant/billing/gateways/so_easy_pay.rb
+++ b/lib/active_merchant/billing/gateways/so_easy_pay.rb
@@ -114,7 +114,7 @@ def fill_credentials(soap, options)
def fill_cardholder(soap, card, options)
ch_info = options[:billing_address] || options[:address]
- soap.tag!('customerIP',options[:ip].to_s)
+ soap.tag!('customerIP', options[:ip].to_s)
name = card.name || ch_info[:name]
soap.tag!('cardHolderName', name.to_s)
address = ch_info[:address1] || ''
diff --git a/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb b/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb
index 544eea6379b..c58ffb0d041 100644
--- a/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb
+++ b/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb
@@ -321,7 +321,7 @@ def scrub(transcript)
private
- CURRENCY_CODES = Hash.new{|h,k| raise ArgumentError.new("Unsupported currency: #{k}")}
+ CURRENCY_CODES = Hash.new{|h, k| raise ArgumentError.new("Unsupported currency: #{k}")}
CURRENCY_CODES['USD'] = '840'
def headers
diff --git a/lib/active_merchant/billing/gateways/transact_pro.rb b/lib/active_merchant/billing/gateways/transact_pro.rb
index 6029f837afb..783e5e18b29 100644
--- a/lib/active_merchant/billing/gateways/transact_pro.rb
+++ b/lib/active_merchant/billing/gateways/transact_pro.rb
@@ -165,7 +165,7 @@ def add_credentials(post, key=:guid)
def parse(body)
if body =~ /^ID:/
- body.split('~').reduce(Hash.new) { |h,v|
+ body.split('~').reduce(Hash.new) { |h, v|
m = v.match('(.*?):(.*)')
h.merge!(m[1].underscore.to_sym => m[2])
}
@@ -180,7 +180,7 @@ def parse(body)
def commit(action, parameters, amount=nil)
url = (test? ? test_url : live_url)
- response = parse(ssl_post(url, post_data(action,parameters)))
+ response = parse(ssl_post(url, post_data(action, parameters)))
Response.new(
success_from(response),
diff --git a/lib/active_merchant/billing/gateways/transax.rb b/lib/active_merchant/billing/gateways/transax.rb
index ac462b23763..336a7fb31c3 100644
--- a/lib/active_merchant/billing/gateways/transax.rb
+++ b/lib/active_merchant/billing/gateways/transax.rb
@@ -1,4 +1,4 @@
-require File.join(File.dirname(__FILE__),'smart_ps.rb')
+require File.join(File.dirname(__FILE__), 'smart_ps.rb')
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
diff --git a/lib/active_merchant/billing/gateways/trust_commerce.rb b/lib/active_merchant/billing/gateways/trust_commerce.rb
index eaf6cf4900b..416824a5d38 100644
--- a/lib/active_merchant/billing/gateways/trust_commerce.rb
+++ b/lib/active_merchant/billing/gateways/trust_commerce.rb
@@ -403,7 +403,7 @@ def parse(body)
results = {}
body.split(/\n/).each do |pair|
- key,val = pair.split(/=/)
+ key, val = pair.split(/=/)
results[key] = val
end
diff --git a/lib/active_merchant/billing/gateways/usa_epay_advanced.rb b/lib/active_merchant/billing/gateways/usa_epay_advanced.rb
index 90a0adb9f64..23077a0fd87 100644
--- a/lib/active_merchant/billing/gateways/usa_epay_advanced.rb
+++ b/lib/active_merchant/billing/gateways/usa_epay_advanced.rb
@@ -1297,7 +1297,7 @@ def build_get_account_details(soap, options)
def build_customer_data(soap, options)
soap.CustomerData 'xsi:type' => 'ns1:CustomerObject' do
- CUSTOMER_OPTIONS.each do |k,v|
+ CUSTOMER_OPTIONS.each do |k, v|
build_tag soap, v[0], v[1], options[k]
end
build_billing_address soap, options
@@ -1370,7 +1370,7 @@ def build_customer_payment_methods(soap, options)
def build_customer_transaction(soap, options)
soap.Parameters 'xsi:type' => 'ns1:CustomerTransactionRequest' do
build_transaction_detail soap, options
- CUSTOMER_TRANSACTION_REQUEST_OPTIONS.each do |k,v|
+ CUSTOMER_TRANSACTION_REQUEST_OPTIONS.each do |k, v|
build_tag soap, v[0], v[1], options[k]
end
build_custom_fields soap, options
@@ -1382,7 +1382,7 @@ def build_customer_transaction(soap, options)
def build_transaction_request_object(soap, options, name='Params')
soap.tag! name, 'xsi:type' => 'ns1:TransactionRequestObject' do
- TRANSACTION_REQUEST_OBJECT_OPTIONS.each do |k,v|
+ TRANSACTION_REQUEST_OBJECT_OPTIONS.each do |k, v|
build_tag soap, v[0], v[1], options[k]
end
case
@@ -1406,10 +1406,10 @@ def build_transaction_request_object(soap, options, name='Params')
def build_transaction_detail(soap, options)
soap.Details 'xsi:type' => 'ns1:TransactionDetail' do
- TRANSACTION_DETAIL_OPTIONS.each do |k,v|
+ TRANSACTION_DETAIL_OPTIONS.each do |k, v|
build_tag soap, v[0], v[1], options[k]
end
- TRANSACTION_DETAIL_MONEY_OPTIONS.each do |k,v|
+ TRANSACTION_DETAIL_MONEY_OPTIONS.each do |k, v|
build_tag soap, v[0], v[1], amount(options[k])
end
end
@@ -1425,7 +1425,7 @@ def build_credit_card_data(soap, options)
end
build_tag soap, :string, 'CardCode', options[:payment_method].verification_value
build_tag soap, :boolean, 'CardPresent', options[:card_present] || false
- CREDIT_CARD_DATA_OPTIONS.each do |k,v|
+ CREDIT_CARD_DATA_OPTIONS.each do |k, v|
build_tag soap, v[0], v[1], options[k]
end
end
@@ -1445,7 +1445,7 @@ def build_check_data(soap, options)
build_tag soap, :string, 'Account', options[:payment_method].account_number
build_tag soap, :string, 'Routing', options[:payment_method].routing_number
build_tag soap, :string, 'AccountType', options[:payment_method].account_type.capitalize
- CHECK_DATA_OPTIONS.each do |k,v|
+ CHECK_DATA_OPTIONS.each do |k, v|
build_tag soap, v[0], v[1], options[k]
end
end
@@ -1457,7 +1457,7 @@ def build_recurring_billing(soap, options)
build_tag soap, :double, 'Amount', amount(options[:recurring][:amount])
build_tag soap, :string, 'Next', options[:recurring][:next].strftime('%Y-%m-%d') if options[:recurring][:next]
build_tag soap, :string, 'Expire', options[:recurring][:expire].strftime('%Y-%m-%d') if options[:recurring][:expire]
- RECURRING_BILLING_OPTIONS.each do |k,v|
+ RECURRING_BILLING_OPTIONS.each do |k, v|
build_tag soap, v[0], v[1], options[:recurring][k]
end
end
@@ -1480,7 +1480,7 @@ def build_billing_address(soap, options)
options[:billing_address][:first_name], options[:billing_address][:last_name] = split_names(options[:billing_address][:name])
end
soap.BillingAddress 'xsi:type' => 'ns1:Address' do
- ADDRESS_OPTIONS.each do |k,v|
+ ADDRESS_OPTIONS.each do |k, v|
build_tag soap, v[0], v[1], options[:billing_address][k]
end
end
@@ -1493,7 +1493,7 @@ def build_shipping_address(soap, options)
options[:shipping_address][:first_name], options[:shipping_address][:last_name] = split_names(options[:shipping_address][:name])
end
soap.ShippingAddress 'xsi:type' => 'ns1:Address' do
- ADDRESS_OPTIONS.each do |k,v|
+ ADDRESS_OPTIONS.each do |k, v|
build_tag soap, v[0], v[1], options[:shipping_address][k]
end
end
diff --git a/lib/active_merchant/billing/gateways/viaklix.rb b/lib/active_merchant/billing/gateways/viaklix.rb
index 4e82980e7f1..af2b009d410 100644
--- a/lib/active_merchant/billing/gateways/viaklix.rb
+++ b/lib/active_merchant/billing/gateways/viaklix.rb
@@ -73,12 +73,12 @@ def add_customer_data(form, options)
form[:customer_code] = options[:customer].to_s.slice(0, 10) unless options[:customer].blank?
end
- def add_invoice(form,options)
+ def add_invoice(form, options)
form[:invoice_number] = (options[:order_id] || options[:invoice]).to_s.slice(0, 10)
form[:description] = options[:description].to_s.slice(0, 255)
end
- def add_address(form,options)
+ def add_address(form, options)
billing_address = options[:billing_address] || options[:address]
if billing_address
diff --git a/lib/active_merchant/billing/gateways/visanet_peru.rb b/lib/active_merchant/billing/gateways/visanet_peru.rb
index c15d4fdde1c..96eecc7d3a8 100644
--- a/lib/active_merchant/billing/gateways/visanet_peru.rb
+++ b/lib/active_merchant/billing/gateways/visanet_peru.rb
@@ -82,7 +82,7 @@ def scrub(transcript)
private
- CURRENCY_CODES = Hash.new{|h,k| raise ArgumentError.new("Unsupported currency: #{k}")}
+ CURRENCY_CODES = Hash.new{|h, k| raise ArgumentError.new("Unsupported currency: #{k}")}
CURRENCY_CODES['USD'] = 840
CURRENCY_CODES['PEN'] = 604
diff --git a/lib/active_merchant/billing/gateways/wirecard.rb b/lib/active_merchant/billing/gateways/wirecard.rb
index d04ddc569e5..9f412cf48ae 100644
--- a/lib/active_merchant/billing/gateways/wirecard.rb
+++ b/lib/active_merchant/billing/gateways/wirecard.rb
@@ -140,7 +140,7 @@ def scrub(transcript)
private
def clean_description(description)
- description.to_s.slice(0,32).encode('US-ASCII', invalid: :replace, undef: :replace, replace: '?')
+ description.to_s.slice(0, 32).encode('US-ASCII', invalid: :replace, undef: :replace, replace: '?')
end
def prepare_options_hash(options)
diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb
index b758032d61f..57cf72a9100 100644
--- a/lib/active_merchant/billing/gateways/worldpay.rb
+++ b/lib/active_merchant/billing/gateways/worldpay.rb
@@ -175,7 +175,7 @@ def build_authorization_request(money, payment_method, options)
end
def order_tag_attributes(options)
- { 'orderCode' => options[:order_id], 'installationId' => options[:inst_id] || @options[:inst_id] }.reject{|_,v| !v}
+ { 'orderCode' => options[:order_id], 'installationId' => options[:inst_id] || @options[:inst_id] }.reject{|_, v| !v}
end
def build_capture_request(money, authorization, options)
@@ -423,7 +423,7 @@ def required_status_message(raw, success_criteria)
end
def authorization_from(raw)
- pair = raw.detect{|k,v| k.to_s =~ /_order_code$/}
+ pair = raw.detect{|k, v| k.to_s =~ /_order_code$/}
(pair ? pair.last : nil)
end
diff --git a/lib/active_merchant/country.rb b/lib/active_merchant/country.rb
index 996647a975a..34710a2572e 100644
--- a/lib/active_merchant/country.rb
+++ b/lib/active_merchant/country.rb
@@ -39,7 +39,7 @@ class Country
def initialize(options = {})
@name = options.delete(:name)
- @codes = options.collect{|k,v| CountryCode.new(v)}
+ @codes = options.collect{|k, v| CountryCode.new(v)}
end
def code(format)
diff --git a/lib/support/ssl_verify.rb b/lib/support/ssl_verify.rb
index 28189db7837..5570e7fde47 100644
--- a/lib/support/ssl_verify.rb
+++ b/lib/support/ssl_verify.rb
@@ -23,7 +23,7 @@ def test_gateways
end
uri = URI.parse(g.live_url)
- result,message = ssl_verify_peer?(uri)
+ result, message = ssl_verify_peer?(uri)
case result
when :success
print '.'
diff --git a/test/remote/gateways/remote_beanstream_test.rb b/test/remote/gateways/remote_beanstream_test.rb
index 876a02f65f0..eed3b72531f 100644
--- a/test/remote/gateways/remote_beanstream_test.rb
+++ b/test/remote/gateways/remote_beanstream_test.rb
@@ -309,7 +309,7 @@ def test_invalid_login
end
def test_successful_add_to_vault_with_store_method
- assert response = @gateway.store(@visa,@options)
+ assert response = @gateway.store(@visa, @options)
assert_equal 'Operation Successful', response.message
assert_success response
assert_not_nil response.params['customer_vault_id']
diff --git a/test/remote/gateways/remote_ct_payment_certification_test.rb b/test/remote/gateways/remote_ct_payment_certification_test.rb
index b2a9784e416..7a4ef3988f4 100644
--- a/test/remote/gateways/remote_ct_payment_certification_test.rb
+++ b/test/remote/gateways/remote_ct_payment_certification_test.rb
@@ -10,7 +10,7 @@ def setup
billing_address: address,
description: 'Store Purchase',
merchant_terminal_number: ' ',
- order_id: generate_unique_id[0,11]
+ order_id: generate_unique_id[0, 11]
}
end
@@ -59,7 +59,7 @@ def test7
response = @gateway.authorize(@amount, @credit_card, @options)
print_result(7, response)
- capture_response = @gateway.capture(@amount, response.authorization, @options.merge(order_id: generate_unique_id[0,11]))
+ capture_response = @gateway.capture(@amount, response.authorization, @options.merge(order_id: generate_unique_id[0, 11]))
print_result(10, capture_response)
end
@@ -69,14 +69,14 @@ def test8
response = @gateway.authorize(@amount, @credit_card, @options)
print_result(8, response)
- capture_response = @gateway.capture(@amount, response.authorization, @options.merge(order_id: generate_unique_id[0,11]))
+ capture_response = @gateway.capture(@amount, response.authorization, @options.merge(order_id: generate_unique_id[0, 11]))
print_result(11, capture_response)
end
def test9
@credit_card = credit_card('341400000000000', month: '07', year: 2025, verification_value: '1234')
@credit_card.brand = 'american_express'
- response = @gateway.authorize(@amount, @credit_card, @options.merge(order_id: generate_unique_id[0,11]))
+ response = @gateway.authorize(@amount, @credit_card, @options.merge(order_id: generate_unique_id[0, 11]))
print_result(9, response)
capture_response = @gateway.capture(@amount, response.authorization, @options)
diff --git a/test/remote/gateways/remote_ct_payment_test.rb b/test/remote/gateways/remote_ct_payment_test.rb
index 43a198bd09a..4fd0ba8738a 100644
--- a/test/remote/gateways/remote_ct_payment_test.rb
+++ b/test/remote/gateways/remote_ct_payment_test.rb
@@ -10,7 +10,7 @@ def setup
@options = {
billing_address: address,
description: 'Store Purchase',
- order_id: generate_unique_id[0,11],
+ order_id: generate_unique_id[0, 11],
email: 'bigbird@sesamestreet.com'
}
@@ -32,7 +32,7 @@ def test_successful_authorize_and_capture
auth = @gateway.authorize(@amount, @credit_card, @options)
assert_success auth
- assert capture = @gateway.capture(@amount, auth.authorization, @options.merge(order_id: generate_unique_id[0,11]))
+ assert capture = @gateway.capture(@amount, auth.authorization, @options.merge(order_id: generate_unique_id[0, 11]))
assert_success capture
assert_equal 'APPROVED', capture.message
end
@@ -47,7 +47,7 @@ def test_partial_capture
auth = @gateway.authorize(@amount, @credit_card, @options)
assert_success auth
- assert capture = @gateway.capture(@amount-1, auth.authorization, @options.merge(order_id: generate_unique_id[0,11]))
+ assert capture = @gateway.capture(@amount-1, auth.authorization, @options.merge(order_id: generate_unique_id[0, 11]))
assert_success capture
end
@@ -61,7 +61,7 @@ def test_successful_refund
purchase = @gateway.purchase(@amount, @credit_card, @options)
assert_success purchase
- assert refund = @gateway.refund(@amount, purchase.authorization, @options.merge(order_id: generate_unique_id[0,11]))
+ assert refund = @gateway.refund(@amount, purchase.authorization, @options.merge(order_id: generate_unique_id[0, 11]))
assert_success refund
assert_equal 'APPROVED', refund.message
end
@@ -70,12 +70,12 @@ def test_partial_refund
purchase = @gateway.purchase(@amount, @credit_card, @options)
assert_success purchase
- assert refund = @gateway.refund(@amount-1, purchase.authorization, @options.merge(order_id: generate_unique_id[0,11]))
+ assert refund = @gateway.refund(@amount-1, purchase.authorization, @options.merge(order_id: generate_unique_id[0, 11]))
assert_success refund
end
def test_failed_refund
- response = @gateway.refund(@amount, '0123456789asd;0123456789asdf;12345678', @options.merge(order_id: generate_unique_id[0,11]))
+ response = @gateway.refund(@amount, '0123456789asd;0123456789asdf;12345678', @options.merge(order_id: generate_unique_id[0, 11]))
assert_failure response
assert_equal 'The original transaction number does not match any actual transaction', response.message
end
diff --git a/test/remote/gateways/remote_litle_certification_test.rb b/test/remote/gateways/remote_litle_certification_test.rb
index c36e352e476..3a9558c701f 100644
--- a/test/remote/gateways/remote_litle_certification_test.rb
+++ b/test/remote/gateways/remote_litle_certification_test.rb
@@ -854,7 +854,7 @@ def test50
assert_success store_response
assert_equal '445711', store_response.params['bin']
assert_equal 'VI', store_response.params['type']
- assert_equal '0123', store_response.params['litleToken'][-4,4]
+ assert_equal '0123', store_response.params['litleToken'][-4, 4]
assert_equal '801', store_response.params['response']
assert_equal 'Account number was successfully registered', store_response.message
puts "Test #{options[:order_id]}: #{txn_id(response)}"
@@ -889,7 +889,7 @@ def test52
assert_equal '445711', store_response.params['bin']
assert_equal 'VI', store_response.params['type']
assert_equal '802', store_response.params['response']
- assert_equal '0123', store_response.params['litleToken'][-4,4]
+ assert_equal '0123', store_response.params['litleToken'][-4, 4]
puts "Test #{options[:order_id]}: #{txn_id(store_response)}"
end
@@ -944,7 +944,7 @@ def test55
assert response = @gateway.authorize(15000, credit_card, options)
assert_success response
assert_equal 'Approved', response.message
- assert_equal '0196', response.params['tokenResponse_litleToken'][-4,4]
+ assert_equal '0196', response.params['tokenResponse_litleToken'][-4, 4]
assert %w(801 802).include? response.params['tokenResponse_tokenResponseCode']
assert_equal 'MC', response.params['tokenResponse_type']
assert_equal '543510', response.params['tokenResponse_bin']
@@ -984,7 +984,7 @@ def test57_58
assert_success response
assert_equal 'Approved', response.message
- assert_equal '0196', response.params['tokenResponse_litleToken'][-4,4]
+ assert_equal '0196', response.params['tokenResponse_litleToken'][-4, 4]
assert %w(801 802).include? response.params['tokenResponse_tokenResponseCode']
assert_equal 'MC', response.params['tokenResponse_type']
assert_equal '543510', response.params['tokenResponse_bin']
diff --git a/test/remote/gateways/remote_merchant_ware_version_four_test.rb b/test/remote/gateways/remote_merchant_ware_version_four_test.rb
index 9d02a5514d2..155bdc2e460 100644
--- a/test/remote/gateways/remote_merchant_ware_version_four_test.rb
+++ b/test/remote/gateways/remote_merchant_ware_version_four_test.rb
@@ -8,12 +8,12 @@ def setup
@declined_card = credit_card('1234567890123')
@options = {
- :order_id => generate_unique_id[0,8],
+ :order_id => generate_unique_id[0, 8],
:billing_address => address
}
@reference_purchase_options = {
- :order_id => generate_unique_id[0,8]
+ :order_id => generate_unique_id[0, 8]
}
end
diff --git a/test/remote/gateways/remote_orbital_test.rb b/test/remote/gateways/remote_orbital_test.rb
index ccceb0fc5ed..62fe766500c 100644
--- a/test/remote/gateways/remote_orbital_test.rb
+++ b/test/remote/gateways/remote_orbital_test.rb
@@ -231,7 +231,7 @@ def test_auth_capture_transactions
# ==== Section C
def test_mark_for_capture_transactions
- [[:visa, 3000],[:mc, 4100],[:amex, 105500],[:ds, 1000],[:jcb, 2900]].each do |suite|
+ [[:visa, 3000], [:mc, 4100], [:amex, 105500], [:ds, 1000], [:jcb, 2900]].each do |suite|
amount = suite[1]
card = credit_card(@cards[suite[0]])
assert auth_response = @gateway.authorize(amount, card, @options)
@@ -247,7 +247,7 @@ def test_mark_for_capture_transactions
# ==== Section D
def test_refund_transactions
- [[:visa, 1200],[:mc, 1100],[:amex, 105500],[:ds, 1000],[:jcb, 2900]].each do |suite|
+ [[:visa, 1200], [:mc, 1100], [:amex, 105500], [:ds, 1000], [:jcb, 2900]].each do |suite|
amount = suite[1]
card = credit_card(@cards[suite[0]])
assert purchase_response = @gateway.purchase(amount, card, @options)
diff --git a/test/remote/gateways/remote_payflow_uk_test.rb b/test/remote/gateways/remote_payflow_uk_test.rb
index c2aebf853ec..5a5df22e94a 100644
--- a/test/remote/gateways/remote_payflow_uk_test.rb
+++ b/test/remote/gateways/remote_payflow_uk_test.rb
@@ -142,7 +142,7 @@ def test_duplicate_request_id
:password => @password
)
- request_id = Digest::SHA1.hexdigest(rand.to_s).slice(0,32)
+ request_id = Digest::SHA1.hexdigest(rand.to_s).slice(0, 32)
gateway.expects(:generate_unique_id).times(2).returns(request_id)
response1 = gateway.purchase(100, @creditcard, @options)
diff --git a/test/remote/gateways/remote_usa_epay_transaction_test.rb b/test/remote/gateways/remote_usa_epay_transaction_test.rb
index b4760f3f387..e3afb520134 100644
--- a/test/remote/gateways/remote_usa_epay_transaction_test.rb
+++ b/test/remote/gateways/remote_usa_epay_transaction_test.rb
@@ -63,7 +63,7 @@ def test_successful_purchase_with_extra_test_mode
end
def test_successful_purchase_with_email_receipt
- assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:email => 'hank@hill.com',:cust_receipt => 'Yes'))
+ assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:email => 'hank@hill.com', :cust_receipt => 'Yes'))
assert_equal 'Success', response.message
assert_success response
end
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 90a557c2eb9..99f482ce780 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -273,7 +273,7 @@ def symbolize_keys(hash)
return unless hash.is_a?(Hash)
hash.symbolize_keys!
- hash.each{|k,v| symbolize_keys(v)}
+ hash.each{|k, v| symbolize_keys(v)}
end
end
end
diff --git a/test/unit/gateways/braintree_blue_test.rb b/test/unit/gateways/braintree_blue_test.rb
index b13264ae47f..7c89a988d05 100644
--- a/test/unit/gateways/braintree_blue_test.rb
+++ b/test/unit/gateways/braintree_blue_test.rb
@@ -726,12 +726,12 @@ def test_that_setting_a_wiredump_device_on_the_gateway_sets_the_braintree_logger
end
def test_solution_id_is_added_to_create_transaction_parameters
- assert_nil @gateway.send(:create_transaction_parameters, 100, credit_card('41111111111111111111'),{})[:channel]
+ assert_nil @gateway.send(:create_transaction_parameters, 100, credit_card('41111111111111111111'), {})[:channel]
ActiveMerchant::Billing::BraintreeBlueGateway.application_id = 'ABC123'
- assert_equal @gateway.send(:create_transaction_parameters, 100, credit_card('41111111111111111111'),{})[:channel], 'ABC123'
+ assert_equal @gateway.send(:create_transaction_parameters, 100, credit_card('41111111111111111111'), {})[:channel], 'ABC123'
gateway = BraintreeBlueGateway.new(:merchant_id => 'test', :public_key => 'test', :private_key => 'test', channel: 'overidden-channel')
- assert_equal gateway.send(:create_transaction_parameters, 100, credit_card('41111111111111111111'),{})[:channel], 'overidden-channel'
+ assert_equal gateway.send(:create_transaction_parameters, 100, credit_card('41111111111111111111'), {})[:channel], 'overidden-channel'
ensure
ActiveMerchant::Billing::BraintreeBlueGateway.application_id = nil
end
diff --git a/test/unit/gateways/braintree_orange_test.rb b/test/unit/gateways/braintree_orange_test.rb
index 80eebb19dfc..399580184fb 100644
--- a/test/unit/gateways/braintree_orange_test.rb
+++ b/test/unit/gateways/braintree_orange_test.rb
@@ -96,7 +96,7 @@ def test_add_address
def test_add_shipping_address
result = {}
- @gateway.send(:add_address, result, {:address1 => '164 Waverley Street', :country => 'US', :state => 'CO'},'shipping' )
+ @gateway.send(:add_address, result, {:address1 => '164 Waverley Street', :country => 'US', :state => 'CO'}, 'shipping' )
assert_equal ['shipping_address1', 'shipping_city', 'shipping_company', 'shipping_country', 'shipping_phone', 'shipping_state', 'shipping_zip'], result.stringify_keys.keys.sort
assert_equal 'CO', result['shipping_state']
assert_equal '164 Waverley Street', result['shipping_address1']
diff --git a/test/unit/gateways/card_connect_test.rb b/test/unit/gateways/card_connect_test.rb
index d0e424e7be2..e4a49a1541b 100644
--- a/test/unit/gateways/card_connect_test.rb
+++ b/test/unit/gateways/card_connect_test.rb
@@ -79,7 +79,7 @@ def test_failed_authorize
def test_successful_capture
@gateway.expects(:ssl_request).returns(successful_capture_response)
- response = @gateway.capture(@amount,'363168161558', @options)
+ response = @gateway.capture(@amount, '363168161558', @options)
assert_success response
assert_equal '363168161558', response.authorization
diff --git a/test/unit/gateways/epay_test.rb b/test/unit/gateways/epay_test.rb
index 6c4554f5969..59becd05499 100644
--- a/test/unit/gateways/epay_test.rb
+++ b/test/unit/gateways/epay_test.rb
@@ -39,7 +39,7 @@ def test_invalid_characters_in_response
end
def test_failed_response_on_purchase
- @gateway.expects(:raw_ssl_request).returns(Net::HTTPBadRequest.new(1.0, 400,'Bad Request'))
+ @gateway.expects(:raw_ssl_request).returns(Net::HTTPBadRequest.new(1.0, 400, 'Bad Request'))
assert response = @gateway.authorize(100, @credit_card)
assert_equal 400, response.params['response_code']
diff --git a/test/unit/gateways/eway_rapid_test.rb b/test/unit/gateways/eway_rapid_test.rb
index 41aed4196d0..15788011e99 100644
--- a/test/unit/gateways/eway_rapid_test.rb
+++ b/test/unit/gateways/eway_rapid_test.rb
@@ -189,7 +189,7 @@ def test_partner_id_truncates_to_50_characters
stub_comms do
@gateway.purchase(200, @credit_card, partner_id: partner_string)
end.check_request do |endpoint, data, headers|
- assert_match(%r{"PartnerID":"#{partner_string.slice(0,50)}"}, data)
+ assert_match(%r{"PartnerID":"#{partner_string.slice(0, 50)}"}, data)
end.respond_with(successful_purchase_response)
end
diff --git a/test/unit/gateways/hps_test.rb b/test/unit/gateways/hps_test.rb
index f6371b26394..107ec989b05 100644
--- a/test/unit/gateways/hps_test.rb
+++ b/test/unit/gateways/hps_test.rb
@@ -90,7 +90,7 @@ def test_failed_capture
def test_successful_refund
@gateway.expects(:ssl_post).returns(successful_refund_response)
- refund = @gateway.refund(@amount,'transaction_id')
+ refund = @gateway.refund(@amount, 'transaction_id')
assert_instance_of Response, refund
assert_success refund
assert_equal '0', refund.params['GatewayRspCode']
@@ -99,7 +99,7 @@ def test_successful_refund
def test_failed_refund
@gateway.expects(:ssl_post).returns(failed_refund_response)
- refund = @gateway.refund(@amount,'169054')
+ refund = @gateway.refund(@amount, '169054')
assert_instance_of Response, refund
assert_failure refund
end
@@ -124,7 +124,7 @@ def test_successful_purchase_with_swipe_no_encryption
@gateway.expects(:ssl_post).returns(successful_swipe_purchase_response)
@credit_card.track_data = '%B547888879888877776?;5473500000000014=25121019999888877776?'
- response = @gateway.purchase(@amount,@credit_card,@options)
+ response = @gateway.purchase(@amount, @credit_card, @options)
assert_success response
assert_equal 'Success', response.message
end
@@ -133,7 +133,7 @@ def test_failed_purchase_with_swipe_bad_track_data
@gateway.expects(:ssl_post).returns(failed_swipe_purchase_response)
@credit_card.track_data = '%B547888879888877776?;?'
- response = @gateway.purchase(@amount,@credit_card,@options)
+ response = @gateway.purchase(@amount, @credit_card, @options)
assert_failure response
assert_equal 'Transaction was rejected because the track data could not be read.', response.message
@@ -144,7 +144,7 @@ def test_successful_purchase_with_swipe_encryption_type_01
@options[:encryption_type] = '01'
@credit_card.track_data = '<E1052711%B5473501000000014^MC TEST CARD^251200000000000000000000000000000000?|GVEY/MKaKXuqqjKRRueIdCHPPoj1gMccgNOtHC41ymz7bIvyJJVdD3LW8BbwvwoenI+|+++++++C4cI2zjMp|11;5473501000000014=25120000000000000000?|8XqYkQGMdGeiIsgM0pzdCbEGUDP|+++++++C4cI2zjMp|00|||/wECAQECAoFGAgEH2wYcShV78RZwb3NAc2VjdXJlZXhjaGFuZ2UubmV0PX50qfj4dt0lu9oFBESQQNkpoxEVpCW3ZKmoIV3T93zphPS3XKP4+DiVlM8VIOOmAuRrpzxNi0TN/DWXWSjUC8m/PI2dACGdl/hVJ/imfqIs68wYDnp8j0ZfgvM26MlnDbTVRrSx68Nzj2QAgpBCHcaBb/FZm9T7pfMr2Mlh2YcAt6gGG1i2bJgiEJn8IiSDX5M2ybzqRT86PCbKle/XCTwFFe1X|>'
- response = @gateway.purchase(@amount,@credit_card,@options)
+ response = @gateway.purchase(@amount, @credit_card, @options)
assert_success response
assert_equal 'Success', response.message
@@ -157,7 +157,7 @@ def test_successful_purchase_with_swipe_encryption_type_02
@options[:encrypted_track_number] = 2
@options[:ktb] = '/wECAQECAoFGAgEH3QgVTDT6jRZwb3NAc2VjdXJlZXhjaGFuZ2UubmV0Nkt08KRSPigRYcr1HVgjRFEvtUBy+VcCKlOGA3871r3SOkqDvH2+30insdLHmhTLCc4sC2IhlobvWnutAfylKk2GLspH/pfEnVKPvBv0hBnF4413+QIRlAuGX6+qZjna2aMl0kIsjEY4N6qoVq2j5/e5I+41+a2pbm61blv2PEMAmyuCcAbN3/At/1kRZNwN6LSUg9VmJO83kOglWBe1CbdFtncq'
@credit_card.track_data = '7SV2BK6ESQPrq01iig27E74SxMg'
- response = @gateway.purchase(@amount,@credit_card,@options)
+ response = @gateway.purchase(@amount, @credit_card, @options)
assert_success response
assert_equal 'Success', response.message
diff --git a/test/unit/gateways/nab_transact_test.rb b/test/unit/gateways/nab_transact_test.rb
index d6a0af00347..d02ebadce3a 100644
--- a/test/unit/gateways/nab_transact_test.rb
+++ b/test/unit/gateways/nab_transact_test.rb
@@ -222,7 +222,7 @@ def check_transaction_type(type)
end
def valid_metadata(name, location)
- return <<-XML.gsub(/^\s{4}/,'').gsub(/\n/, '')
+ return <<-XML.gsub(/^\s{4}/, '').gsub(/\n/, '')
XML
end
@@ -241,7 +241,7 @@ def failed_login_response
end
def successful_purchase_response
- <<-XML.gsub(/^\s{4}/,'')
+ <<-XML.gsub(/^\s{4}/, '')
@@ -284,7 +284,7 @@ def successful_purchase_response
end
def failed_purchase_response
- <<-XML.gsub(/^\s{4}/,'')
+ <<-XML.gsub(/^\s{4}/, '')
@@ -327,7 +327,7 @@ def failed_purchase_response
end
def successful_authorize_response
- <<-XML.gsub(/^\s{4}/,'')
+ <<-XML.gsub(/^\s{4}/, '')
@@ -372,7 +372,7 @@ def successful_authorize_response
end
def successful_refund_response
- <<-XML.gsub(/^\s{4}/,'')
+ <<-XML.gsub(/^\s{4}/, '')
@@ -415,7 +415,7 @@ def successful_refund_response
end
def failed_refund_response
- <<-XML.gsub(/^\s{4}/,'')
+ <<-XML.gsub(/^\s{4}/, '')
diff --git a/test/unit/gateways/opp_test.rb b/test/unit/gateways/opp_test.rb
index 3c7ccf84ae3..7302649b7da 100644
--- a/test/unit/gateways/opp_test.rb
+++ b/test/unit/gateways/opp_test.rb
@@ -188,18 +188,18 @@ def post_scrubbed
def successful_response(type, id)
OppMockResponse.new(200,
- JSON.generate({'id' => id,'paymentType' => type,'paymentBrand' => 'VISA','amount' => '1.00','currency' => 'EUR',"des
- criptor" => '5410.9959.0306 OPP_Channel ','result' => {'code' => '000.100.110','description' => "Request successfully processed in 'Merchant in Integrator Test Mode'"},'card' => {"bin
- " => '420000','last4Digits' => '0000','holder' => 'Longbob Longsen','expiryMonth' => '05','expiryYear' => '2018'},'buildNumber' => '20150618-111601.r185004.opp-tags-20150618_stage',"time
- stamp" => '2015-06-20 19:31:01+0000','ndc' => '8a8294174b7ecb28014b9699220015ca_4453edbc001f405da557c05cb3c3add9'})
+ JSON.generate({'id' => id, 'paymentType' => type, 'paymentBrand' => 'VISA', 'amount' => '1.00', 'currency' => 'EUR', "des
+ criptor" => '5410.9959.0306 OPP_Channel ', 'result' => {'code' => '000.100.110', 'description' => "Request successfully processed in 'Merchant in Integrator Test Mode'"}, 'card' => {"bin
+ " => '420000', 'last4Digits' => '0000', 'holder' => 'Longbob Longsen', 'expiryMonth' => '05', 'expiryYear' => '2018'}, 'buildNumber' => '20150618-111601.r185004.opp-tags-20150618_stage', "time
+ stamp" => '2015-06-20 19:31:01+0000', 'ndc' => '8a8294174b7ecb28014b9699220015ca_4453edbc001f405da557c05cb3c3add9'})
)
end
def failed_response(type, id, code='100.100.101')
OppMockResponse.new(400,
- JSON.generate({'id' => id,'paymentType' => type,'paymentBrand' => 'VISA','result' => {'code' => code,"des
- cription" => 'invalid creditcard, bank account number or bank name'},'card' => {'bin' => '444444','last4Digits' => '4444','holder' => 'Longbob Longsen','expiryMonth' => '05','expiryYear' => '2018'},
- 'buildNumber' => '20150618-111601.r185004.opp-tags-20150618_stage','timestamp' => '2015-06-20 20:40:26+0000','ndc' => '8a8294174b7ecb28014b9699220015ca_5200332e7d664412a84ed5f4777b3c7d'})
+ JSON.generate({'id' => id, 'paymentType' => type, 'paymentBrand' => 'VISA', 'result' => {'code' => code, "des
+ cription" => 'invalid creditcard, bank account number or bank name'}, 'card' => {'bin' => '444444', 'last4Digits' => '4444', 'holder' => 'Longbob Longsen', 'expiryMonth' => '05', 'expiryYear' => '2018'},
+ 'buildNumber' => '20150618-111601.r185004.opp-tags-20150618_stage', 'timestamp' => '2015-06-20 20:40:26+0000', 'ndc' => '8a8294174b7ecb28014b9699220015ca_5200332e7d664412a84ed5f4777b3c7d'})
)
end
diff --git a/test/unit/gateways/optimal_payment_test.rb b/test/unit/gateways/optimal_payment_test.rb
index b88d15665f7..45d34d08ab2 100644
--- a/test/unit/gateways/optimal_payment_test.rb
+++ b/test/unit/gateways/optimal_payment_test.rb
@@ -101,7 +101,7 @@ def test_purchase_from_any_other_country_includes_region_field
def test_purchase_with_shipping_address
@options[:shipping_address] = {:country => 'CA'}
@gateway.expects(:ssl_post).with do |url, data|
- xml = data.split('&').detect{|string| string =~ /txnRequest=/}.gsub('txnRequest=','')
+ xml = data.split('&').detect{|string| string =~ /txnRequest=/}.gsub('txnRequest=', '')
doc = Nokogiri::XML.parse(CGI.unescape(xml))
doc.xpath('//xmlns:shippingDetails/xmlns:country').first.text == 'CA' && doc.to_s.include?('')
end.returns(successful_purchase_response)
@@ -112,7 +112,7 @@ def test_purchase_with_shipping_address
def test_purchase_without_shipping_address
@options[:shipping_address] = nil
@gateway.expects(:ssl_post).with do |url, data|
- xml = data.split('&').detect{|string| string =~ /txnRequest=/}.gsub('txnRequest=','')
+ xml = data.split('&').detect{|string| string =~ /txnRequest=/}.gsub('txnRequest=', '')
doc = Nokogiri::XML.parse(CGI.unescape(xml))
doc.to_s.include?('') == false
end.returns(successful_purchase_response)
diff --git a/test/unit/gateways/paypal/paypal_common_api_test.rb b/test/unit/gateways/paypal/paypal_common_api_test.rb
index 5193e20846b..588406406e0 100644
--- a/test/unit/gateways/paypal/paypal_common_api_test.rb
+++ b/test/unit/gateways/paypal/paypal_common_api_test.rb
@@ -118,13 +118,13 @@ def test_balance_cleans_up_currencies_values_like_0
end
def test_build_do_authorize_request
- request = REXML::Document.new(@gateway.send(:build_do_authorize,123, 100, :currency => 'USD'))
+ request = REXML::Document.new(@gateway.send(:build_do_authorize, 123, 100, :currency => 'USD'))
assert_equal '123', REXML::XPath.first(request, '//DoAuthorizationReq/DoAuthorizationRequest/TransactionID').text
assert_equal '1.00', REXML::XPath.first(request, '//DoAuthorizationReq/DoAuthorizationRequest/Amount').text
end
def test_build_manage_pending_transaction_status_request
- request = REXML::Document.new(@gateway.send(:build_manage_pending_transaction_status,123, 'Accept'))
+ request = REXML::Document.new(@gateway.send(:build_manage_pending_transaction_status, 123, 'Accept'))
assert_equal '123', REXML::XPath.first(request, '//ManagePendingTransactionStatusReq/ManagePendingTransactionStatusRequest/TransactionID').text
assert_equal 'Accept', REXML::XPath.first(request, '//ManagePendingTransactionStatusReq/ManagePendingTransactionStatusRequest/Action').text
end
diff --git a/test/unit/gateways/qvalent_test.rb b/test/unit/gateways/qvalent_test.rb
index 12a53e48d1d..f7fa337755a 100644
--- a/test/unit/gateways/qvalent_test.rb
+++ b/test/unit/gateways/qvalent_test.rb
@@ -55,7 +55,7 @@ def test_failed_authorize
end.respond_with(failed_authorize_response)
assert_failure response
- assert_equal 'Expired card',response.message
+ assert_equal 'Expired card', response.message
assert response.test?
end
diff --git a/test/unit/gateways/redsys_test.rb b/test/unit/gateways/redsys_test.rb
index 4a5e9ce3816..741b5ae9eed 100644
--- a/test/unit/gateways/redsys_test.rb
+++ b/test/unit/gateways/redsys_test.rb
@@ -256,7 +256,7 @@ def test_whitespace_string_cvv_transcript_scrubbing
# one with card and another without.
def purchase_request
- "entrada=%3CDATOSENTRADA%3E%0A++%3CDS_Version%3E0.1%3C%2FDS_Version%3E%0A++%3CDS_MERCHANT_CURRENCY%3E978%3C%2FDS_MERCHANT_CURRENCY%3E%0A++%3CDS_MERCHANT_AMOUNT%3E123%3C%2FDS_MERCHANT_AMOUNT%3E%0A++%3CDS_MERCHANT_ORDER%3E1001%3C%2FDS_MERCHANT_ORDER%3E%0A++%3CDS_MERCHANT_TRANSACTIONTYPE%3EA%3C%2FDS_MERCHANT_TRANSACTIONTYPE%3E%0A++%3CDS_MERCHANT_PRODUCTDESCRIPTION%2F%3E%0A++%3CDS_MERCHANT_TERMINAL%3E1%3C%2FDS_MERCHANT_TERMINAL%3E%0A++%3CDS_MERCHANT_MERCHANTCODE%3E091952713%3C%2FDS_MERCHANT_MERCHANTCODE%3E%0A++%3CDS_MERCHANT_MERCHANTSIGNATURE%3Eb98b606a6a588d8c45c239f244160efbbe30b4a8%3C%2FDS_MERCHANT_MERCHANTSIGNATURE%3E%0A++%3CDS_MERCHANT_TITULAR%3ELongbob+Longsen%3C%2FDS_MERCHANT_TITULAR%3E%0A++%3CDS_MERCHANT_PAN%3E4242424242424242%3C%2FDS_MERCHANT_PAN%3E%0A++%3CDS_MERCHANT_EXPIRYDATE%3E#{(Time.now.year + 1).to_s.slice(2,2)}09%3C%2FDS_MERCHANT_EXPIRYDATE%3E%0A++%3CDS_MERCHANT_CVV2%3E123%3C%2FDS_MERCHANT_CVV2%3E%0A%3C%2FDATOSENTRADA%3E%0A"
+ "entrada=%3CDATOSENTRADA%3E%0A++%3CDS_Version%3E0.1%3C%2FDS_Version%3E%0A++%3CDS_MERCHANT_CURRENCY%3E978%3C%2FDS_MERCHANT_CURRENCY%3E%0A++%3CDS_MERCHANT_AMOUNT%3E123%3C%2FDS_MERCHANT_AMOUNT%3E%0A++%3CDS_MERCHANT_ORDER%3E1001%3C%2FDS_MERCHANT_ORDER%3E%0A++%3CDS_MERCHANT_TRANSACTIONTYPE%3EA%3C%2FDS_MERCHANT_TRANSACTIONTYPE%3E%0A++%3CDS_MERCHANT_PRODUCTDESCRIPTION%2F%3E%0A++%3CDS_MERCHANT_TERMINAL%3E1%3C%2FDS_MERCHANT_TERMINAL%3E%0A++%3CDS_MERCHANT_MERCHANTCODE%3E091952713%3C%2FDS_MERCHANT_MERCHANTCODE%3E%0A++%3CDS_MERCHANT_MERCHANTSIGNATURE%3Eb98b606a6a588d8c45c239f244160efbbe30b4a8%3C%2FDS_MERCHANT_MERCHANTSIGNATURE%3E%0A++%3CDS_MERCHANT_TITULAR%3ELongbob+Longsen%3C%2FDS_MERCHANT_TITULAR%3E%0A++%3CDS_MERCHANT_PAN%3E4242424242424242%3C%2FDS_MERCHANT_PAN%3E%0A++%3CDS_MERCHANT_EXPIRYDATE%3E#{(Time.now.year + 1).to_s.slice(2, 2)}09%3C%2FDS_MERCHANT_EXPIRYDATE%3E%0A++%3CDS_MERCHANT_CVV2%3E123%3C%2FDS_MERCHANT_CVV2%3E%0A%3C%2FDATOSENTRADA%3E%0A"
end
def purchase_request_with_credit_card_token
diff --git a/test/unit/gateways/secure_pay_au_test.rb b/test/unit/gateways/secure_pay_au_test.rb
index e99997f6d4e..5d995aab6f8 100644
--- a/test/unit/gateways/secure_pay_au_test.rb
+++ b/test/unit/gateways/secure_pay_au_test.rb
@@ -201,7 +201,7 @@ def test_supports_scrubbing?
private
def successful_store_response
- <<-XML.gsub(/^\s{4}/,'')
+ <<-XML.gsub(/^\s{4}/, '')
@@ -240,7 +240,7 @@ def successful_store_response
end
def successful_unstore_response
- <<-XML.gsub(/^\s{4}/,'')
+ <<-XML.gsub(/^\s{4}/, '')
@@ -272,7 +272,7 @@ def successful_unstore_response
end
def successful_triggered_payment_response
- <<-XML.gsub(/^\s{4}/,'')
+ <<-XML.gsub(/^\s{4}/, '')
@@ -318,7 +318,7 @@ def failed_login_response
end
def successful_purchase_response
- <<-XML.gsub(/^\s{4}/,'')
+ <<-XML.gsub(/^\s{4}/, '')
@@ -365,7 +365,7 @@ def successful_purchase_response
end
def failed_purchase_response
- <<-XML.gsub(/^\s{4}/,'')
+ <<-XML.gsub(/^\s{4}/, '')
@@ -412,7 +412,7 @@ def failed_purchase_response
end
def successful_live_purchase_response
- <<-XML.gsub(/^\s{4}/,'')
+ <<-XML.gsub(/^\s{4}/, '')
diff --git a/test/unit/gateways/securion_pay_test.rb b/test/unit/gateways/securion_pay_test.rb
index 2880ca98a15..198c2c920f8 100644
--- a/test/unit/gateways/securion_pay_test.rb
+++ b/test/unit/gateways/securion_pay_test.rb
@@ -87,7 +87,7 @@ def test_invalid_raw_response
def test_client_data_submitted_with_purchase
stub_comms(@gateway, :ssl_request) do
updated_options = @options.merge({ description: 'test charge', ip: '127.127.127.127', user_agent: 'browser XXX', referrer: 'http://www.foobar.com', email: 'foo@bar.com' })
- @gateway.purchase(@amount,@credit_card,updated_options)
+ @gateway.purchase(@amount, @credit_card, updated_options)
end.check_request do |method, endpoint, data, headers|
assert_match(/description=test\+charge/, data)
assert_match(/ip=127\.127\.127\.127/, data)
@@ -100,7 +100,7 @@ def test_client_data_submitted_with_purchase
def test_client_data_submitted_with_purchase_without_email_or_order
stub_comms(@gateway, :ssl_request) do
updated_options = @options.merge({ description: 'test charge', ip: '127.127.127.127', user_agent: 'browser XXX', referrer: 'http://www.foobar.com' })
- @gateway.purchase(@amount,@credit_card,updated_options)
+ @gateway.purchase(@amount, @credit_card, updated_options)
end.check_request do |method, endpoint, data, headers|
assert_match(/description=test\+charge/, data)
assert_match(/ip=127\.127\.127\.127/, data)
diff --git a/test/unit/gateways/stripe_test.rb b/test/unit/gateways/stripe_test.rb
index 0f66d7985ad..b19b6e1fc74 100644
--- a/test/unit/gateways/stripe_test.rb
+++ b/test/unit/gateways/stripe_test.rb
@@ -938,8 +938,8 @@ def test_destination_amount_is_submitted_for_purchase
def test_client_data_submitted_with_purchase
stub_comms(@gateway, :ssl_request) do
- updated_options = @options.merge({:description => 'a test customer',:ip => '127.127.127.127', :user_agent => 'some browser', :order_id => '42', :email => 'foo@wonderfullyfakedomain.com', :receipt_email => 'receipt-receiver@wonderfullyfakedomain.com', :referrer =>'http://www.shopify.com'})
- @gateway.purchase(@amount,@credit_card,updated_options)
+ updated_options = @options.merge({:description => 'a test customer', :ip => '127.127.127.127', :user_agent => 'some browser', :order_id => '42', :email => 'foo@wonderfullyfakedomain.com', :receipt_email => 'receipt-receiver@wonderfullyfakedomain.com', :referrer =>'http://www.shopify.com'})
+ @gateway.purchase(@amount, @credit_card, updated_options)
end.check_request do |method, endpoint, data, headers|
assert_match(/description=a\+test\+customer/, data)
assert_match(/ip=127\.127\.127\.127/, data)
@@ -955,8 +955,8 @@ def test_client_data_submitted_with_purchase
def test_client_data_submitted_with_purchase_without_email_or_order
stub_comms(@gateway, :ssl_request) do
- updated_options = @options.merge({:description => 'a test customer',:ip => '127.127.127.127', :user_agent => 'some browser', :referrer =>'http://www.shopify.com'})
- @gateway.purchase(@amount,@credit_card,updated_options)
+ updated_options = @options.merge({:description => 'a test customer', :ip => '127.127.127.127', :user_agent => 'some browser', :referrer =>'http://www.shopify.com'})
+ @gateway.purchase(@amount, @credit_card, updated_options)
end.check_request do |method, endpoint, data, headers|
assert_match(/description=a\+test\+customer/, data)
assert_match(/ip=127\.127\.127\.127/, data)
@@ -970,7 +970,7 @@ def test_client_data_submitted_with_purchase_without_email_or_order
def test_client_data_submitted_with_metadata_in_options
stub_comms(@gateway, :ssl_request) do
updated_options = @options.merge({:metadata => {:this_is_a_random_key_name => 'with a random value', :i_made_up_this_key_too => 'canyoutell'}, :order_id => '42', :email => 'foo@wonderfullyfakedomain.com'})
- @gateway.purchase(@amount,@credit_card,updated_options)
+ @gateway.purchase(@amount, @credit_card, updated_options)
end.check_request do |method, endpoint, data, headers|
assert_match(/metadata\[this_is_a_random_key_name\]=with\+a\+random\+value/, data)
assert_match(/metadata\[i_made_up_this_key_too\]=canyoutell/, data)
From 8fdbbf6840cbf19bf360fc4fe552debc2182451c Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 8 Nov 2018 15:00:31 -0500
Subject: [PATCH 0183/2234] RuboCop: fix Style/ParenthesesAroundCondition
---
.rubocop_todo.yml | 6 ------
lib/active_merchant/billing/gateways/borgun.rb | 2 +-
lib/active_merchant/billing/gateways/braintree_blue.rb | 6 +++---
lib/active_merchant/billing/gateways/card_stream.rb | 2 +-
lib/active_merchant/billing/gateways/cenpos.rb | 2 +-
lib/active_merchant/billing/gateways/checkout.rb | 2 +-
lib/active_merchant/billing/gateways/ct_payment.rb | 2 +-
lib/active_merchant/billing/gateways/cyber_source.rb | 2 +-
lib/active_merchant/billing/gateways/eway.rb | 2 +-
lib/active_merchant/billing/gateways/hdfc.rb | 2 +-
lib/active_merchant/billing/gateways/hps.rb | 2 +-
lib/active_merchant/billing/gateways/payex.rb | 2 +-
lib/active_merchant/billing/gateways/paymill.rb | 2 +-
lib/active_merchant/billing/gateways/payu_latam.rb | 2 +-
lib/active_merchant/billing/gateways/quantum.rb | 2 +-
lib/active_merchant/billing/gateways/realex.rb | 2 +-
lib/active_merchant/billing/gateways/stripe.rb | 2 +-
lib/active_merchant/billing/gateways/telr.rb | 2 +-
lib/active_merchant/billing/gateways/visanet_peru.rb | 4 ++--
lib/active_merchant/billing/gateways/wirecard.rb | 2 +-
.../billing/gateways/worldpay_online_payments.rb | 2 +-
21 files changed, 23 insertions(+), 29 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index ade1c7ede93..cedf33c61f6 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -927,12 +927,6 @@ Style/OrAssignment:
Style/ParallelAssignment:
Enabled: false
-# Offense count: 29
-# Cop supports --auto-correct.
-# Configuration parameters: AllowSafeAssignment, AllowInMultilineConditions.
-Style/ParenthesesAroundCondition:
- Enabled: false
-
# Offense count: 877
# Cop supports --auto-correct.
# Configuration parameters: PreferredDelimiters.
diff --git a/lib/active_merchant/billing/gateways/borgun.rb b/lib/active_merchant/billing/gateways/borgun.rb
index 26b7fff9ef5..df56f97646d 100644
--- a/lib/active_merchant/billing/gateways/borgun.rb
+++ b/lib/active_merchant/billing/gateways/borgun.rb
@@ -112,7 +112,7 @@ def parse(xml)
body.children.each do |node|
if node.text?
next
- elsif (node.elements.size == 0)
+ elsif node.elements.size == 0
response[node.name.downcase.to_sym] = node.text
else
node.elements.each do |childnode|
diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb
index f660e41f64a..8e8f9f6830a 100644
--- a/lib/active_merchant/billing/gateways/braintree_blue.rb
+++ b/lib/active_merchant/billing/gateways/braintree_blue.rb
@@ -279,10 +279,10 @@ def add_credit_card_to_customer(credit_card, options)
def scrub_email(email)
return nil unless email.present?
- return nil if (
+ return nil if
email !~ /^.+@[^\.]+(\.[^\.]+)+[a-z]$/i ||
email =~ /\.(con|met)$/i
- )
+
email
end
@@ -323,7 +323,7 @@ def map_address(address)
:region => address[:state],
:postal_code => scrub_zip(address[:zip]),
}
- if (address[:country] || address[:country_code_alpha2])
+ if address[:country] || address[:country_code_alpha2]
mapped[:country_code_alpha2] = (address[:country] || address[:country_code_alpha2])
elsif address[:country_name]
mapped[:country_name] = address[:country_name]
diff --git a/lib/active_merchant/billing/gateways/card_stream.rb b/lib/active_merchant/billing/gateways/card_stream.rb
index 190f2fe797b..f5ac54fdb83 100644
--- a/lib/active_merchant/billing/gateways/card_stream.rb
+++ b/lib/active_merchant/billing/gateways/card_stream.rb
@@ -141,7 +141,7 @@ class CardStreamGateway < Gateway
def initialize(options = {})
requires!(options, :login, :shared_secret)
@threeds_required = false
- if (options[:threeDSRequired])
+ if options[:threeDSRequired]
ActiveMerchant.deprecated(THREEDSECURE_REQUIRED_DEPRECATION_MESSAGE)
@threeds_required = options[:threeDSRequired]
end
diff --git a/lib/active_merchant/billing/gateways/cenpos.rb b/lib/active_merchant/billing/gateways/cenpos.rb
index 2a36063982f..5412821c21e 100644
--- a/lib/active_merchant/billing/gateways/cenpos.rb
+++ b/lib/active_merchant/billing/gateways/cenpos.rb
@@ -219,7 +219,7 @@ def parse(xml)
doc.remove_namespaces!
body = doc.xpath('//ProcessCreditCardResult')
body.children.each do |node|
- if (node.elements.size == 0)
+ if node.elements.size == 0
response[node.name.underscore.to_sym] = node.text
else
node.elements.each do |childnode|
diff --git a/lib/active_merchant/billing/gateways/checkout.rb b/lib/active_merchant/billing/gateways/checkout.rb
index cd6692a37d8..bd6149b246d 100644
--- a/lib/active_merchant/billing/gateways/checkout.rb
+++ b/lib/active_merchant/billing/gateways/checkout.rb
@@ -187,7 +187,7 @@ def parse_xml(xml)
Nokogiri::XML(CGI.unescapeHTML(xml)).xpath('//response').children.each do |node|
if node.text?
next
- elsif (node.elements.size == 0)
+ elsif node.elements.size == 0
response[node.name.downcase.to_sym] = node.text
else
node.elements.each do |childnode|
diff --git a/lib/active_merchant/billing/gateways/ct_payment.rb b/lib/active_merchant/billing/gateways/ct_payment.rb
index 2e3d444cc1b..2fde2028088 100644
--- a/lib/active_merchant/billing/gateways/ct_payment.rb
+++ b/lib/active_merchant/billing/gateways/ct_payment.rb
@@ -254,7 +254,7 @@ def post_data(action, parameters = {})
parameters[:CompanyNumber] = @options[:company_number]
parameters[:MerchantNumber] = @options[:merchant_number]
parameters = parameters.collect do |key, value|
- "#{key}=#{value}" unless (value.nil? || value.empty?)
+ "#{key}=#{value}" unless value.nil? || value.empty?
end.join('&')
payload = Base64.strict_encode64(parameters)
"auth-api-key=#{@options[:api_key]}&payload=#{payload}".strip
diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb
index d31c5e46de1..9cb8d2f1a2b 100644
--- a/lib/active_merchant/billing/gateways/cyber_source.rb
+++ b/lib/active_merchant/billing/gateways/cyber_source.rb
@@ -469,7 +469,7 @@ def add_creditcard(xml, creditcard)
xml.tag! 'accountNumber', creditcard.number
xml.tag! 'expirationMonth', format(creditcard.month, :two_digits)
xml.tag! 'expirationYear', format(creditcard.year, :four_digits)
- xml.tag!('cvNumber', creditcard.verification_value) unless (@options[:ignore_cvv] || creditcard.verification_value.blank? )
+ xml.tag!('cvNumber', creditcard.verification_value) unless @options[:ignore_cvv] || creditcard.verification_value.blank?
xml.tag! 'cardType', @@credit_card_codes[card_brand(creditcard).to_sym]
end
end
diff --git a/lib/active_merchant/billing/gateways/eway.rb b/lib/active_merchant/billing/gateways/eway.rb
index 5625420870e..04874aac7ba 100644
--- a/lib/active_merchant/billing/gateways/eway.rb
+++ b/lib/active_merchant/billing/gateways/eway.rb
@@ -66,7 +66,7 @@ def scrub(transcript)
private
def requires_address!(options)
- raise ArgumentError.new('Missing eWay required parameters: address or billing_address') unless (options.has_key?(:address) or options.has_key?(:billing_address))
+ raise ArgumentError.new('Missing eWay required parameters: address or billing_address') unless options.has_key?(:address) or options.has_key?(:billing_address)
end
def add_creditcard(post, creditcard)
diff --git a/lib/active_merchant/billing/gateways/hdfc.rb b/lib/active_merchant/billing/gateways/hdfc.rb
index a6e228d5721..3037ccac471 100644
--- a/lib/active_merchant/billing/gateways/hdfc.rb
+++ b/lib/active_merchant/billing/gateways/hdfc.rb
@@ -113,7 +113,7 @@ def parse(xml)
doc.children.each do |node|
if node.text?
next
- elsif (node.elements.size == 0)
+ elsif node.elements.size == 0
response[node.name.downcase.to_sym] = node.text
else
node.elements.each do |childnode|
diff --git a/lib/active_merchant/billing/gateways/hps.rb b/lib/active_merchant/billing/gateways/hps.rb
index 22677874ff1..dbc7997370b 100644
--- a/lib/active_merchant/billing/gateways/hps.rb
+++ b/lib/active_merchant/billing/gateways/hps.rb
@@ -204,7 +204,7 @@ def parse(raw)
doc.remove_namespaces!
if(header = doc.xpath('//Header').first)
header.elements.each do |node|
- if (node.elements.size == 0)
+ if node.elements.size == 0
response[node.name] = node.text
else
node.elements.each do |childnode|
diff --git a/lib/active_merchant/billing/gateways/payex.rb b/lib/active_merchant/billing/gateways/payex.rb
index 03aa3f24a9b..b82b8c4d21b 100644
--- a/lib/active_merchant/billing/gateways/payex.rb
+++ b/lib/active_merchant/billing/gateways/payex.rb
@@ -364,7 +364,7 @@ def parse(xml)
doc = Nokogiri::XML(body)
doc.root&.xpath('*')&.each do |node|
- if (node.elements.size == 0)
+ if node.elements.size == 0
response[node.name.downcase.to_sym] = node.text
else
node.elements.each do |childnode|
diff --git a/lib/active_merchant/billing/gateways/paymill.rb b/lib/active_merchant/billing/gateways/paymill.rb
index 858cc4bd5d9..46179c8ecf5 100644
--- a/lib/active_merchant/billing/gateways/paymill.rb
+++ b/lib/active_merchant/billing/gateways/paymill.rb
@@ -314,7 +314,7 @@ def transaction_id(authorization)
def response_message(parsed_response)
return parsed_response['error'] if parsed_response['error']
- return 'Transaction approved.' if (parsed_response['data'] == [])
+ return 'Transaction approved.' if parsed_response['data'] == []
code = parsed_response['data']['response_code'].to_i
RESPONSE_CODES[code] || code.to_s
diff --git a/lib/active_merchant/billing/gateways/payu_latam.rb b/lib/active_merchant/billing/gateways/payu_latam.rb
index bb5d16e085b..9c73136aca2 100644
--- a/lib/active_merchant/billing/gateways/payu_latam.rb
+++ b/lib/active_merchant/billing/gateways/payu_latam.rb
@@ -167,7 +167,7 @@ def add_payer(post, payment_method, options)
address = options[:billing_address]
payer = {}
payer[:fullName] = payment_method.name.strip
- payer[:contactPhone] = address[:phone] if (address && address[:phone])
+ payer[:contactPhone] = address[:phone] if address && address[:phone]
payer[:dniNumber] = options[:dni_number] if options[:dni_number]
payer[:dniType] = options[:dni_type] if options[:dni_type]
payer[:emailAddress] = options[:email] if options[:email]
diff --git a/lib/active_merchant/billing/gateways/quantum.rb b/lib/active_merchant/billing/gateways/quantum.rb
index e3b1d12decd..d15ec35c939 100644
--- a/lib/active_merchant/billing/gateways/quantum.rb
+++ b/lib/active_merchant/billing/gateways/quantum.rb
@@ -182,7 +182,7 @@ def add_creditcard(xml, creditcard)
xml.tag! 'CreditCardNumber', creditcard.number
xml.tag! 'ExpireMonth', format(creditcard.month, :two_digits)
xml.tag! 'ExpireYear', format(creditcard.year, :four_digits)
- xml.tag!('CVV2', creditcard.verification_value) unless (@options[:ignore_cvv] || creditcard.verification_value.blank? )
+ xml.tag!('CVV2', creditcard.verification_value) unless @options[:ignore_cvv] || creditcard.verification_value.blank?
end
# Where we actually build the full SOAP request using builder
diff --git a/lib/active_merchant/billing/gateways/realex.rb b/lib/active_merchant/billing/gateways/realex.rb
index 1892e652378..3e0e1a21276 100644
--- a/lib/active_merchant/billing/gateways/realex.rb
+++ b/lib/active_merchant/billing/gateways/realex.rb
@@ -118,7 +118,7 @@ def parse(xml)
doc = Nokogiri::XML(xml)
doc.xpath('//response/*').each do |node|
- if (node.elements.size == 0)
+ if node.elements.size == 0
response[node.name.downcase.to_sym] = normalize(node.text)
else
node.elements.each do |childnode|
diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb
index 905a370e3c9..1650c1baf43 100644
--- a/lib/active_merchant/billing/gateways/stripe.rb
+++ b/lib/active_merchant/billing/gateways/stripe.rb
@@ -474,7 +474,7 @@ def add_customer(post, payment, options)
def add_flags(post, options)
post[:uncaptured] = true if options[:uncaptured]
- post[:recurring] = true if (options[:eci] == 'recurring' || options[:recurring])
+ post[:recurring] = true if options[:eci] == 'recurring' || options[:recurring]
end
def add_metadata(post, options = {})
diff --git a/lib/active_merchant/billing/gateways/telr.rb b/lib/active_merchant/billing/gateways/telr.rb
index f3938d89c9a..c39b0a17e34 100644
--- a/lib/active_merchant/billing/gateways/telr.rb
+++ b/lib/active_merchant/billing/gateways/telr.rb
@@ -215,7 +215,7 @@ def parse(xml)
doc = Nokogiri::XML(xml)
doc.root&.xpath('*')&.each do |node|
- if (node.elements.size == 0)
+ if node.elements.size == 0
response[node.name.downcase.to_sym] = node.text
else
node.elements.each do |childnode|
diff --git a/lib/active_merchant/billing/gateways/visanet_peru.rb b/lib/active_merchant/billing/gateways/visanet_peru.rb
index 96eecc7d3a8..6e5818bee63 100644
--- a/lib/active_merchant/billing/gateways/visanet_peru.rb
+++ b/lib/active_merchant/billing/gateways/visanet_peru.rb
@@ -166,9 +166,9 @@ def headers
end
def url(action, params, options={})
- if (action == 'authorize')
+ if action == 'authorize'
"#{base_url}/#{@options[:merchant_id]}"
- elsif (action == 'refund')
+ elsif action == 'refund'
"#{base_url}/#{@options[:merchant_id]}/#{action}/#{options[:transaction_id]}"
else
"#{base_url}/#{@options[:merchant_id]}/#{action}/#{params[:purchaseNumber]}"
diff --git a/lib/active_merchant/billing/gateways/wirecard.rb b/lib/active_merchant/billing/gateways/wirecard.rb
index 9f412cf48ae..71134e66e2a 100644
--- a/lib/active_merchant/billing/gateways/wirecard.rb
+++ b/lib/active_merchant/billing/gateways/wirecard.rb
@@ -343,7 +343,7 @@ def parse_response(response, root)
end
status.elements.to_a.each do |node|
- if (node.elements.size == 0)
+ if node.elements.size == 0
response[node.name.to_sym] = (node.text || '').strip
else
node.elements.each do |childnode|
diff --git a/lib/active_merchant/billing/gateways/worldpay_online_payments.rb b/lib/active_merchant/billing/gateways/worldpay_online_payments.rb
index 513d2a667d5..d3a03ffbeec 100644
--- a/lib/active_merchant/billing/gateways/worldpay_online_payments.rb
+++ b/lib/active_merchant/billing/gateways/worldpay_online_payments.rb
@@ -139,7 +139,7 @@ def commit(method, url, parameters=nil, options = {}, type = false)
raw_response = ssl_request(method, self.live_url + url, json, headers(options))
- if (raw_response != '')
+ if raw_response != ''
response = parse(raw_response)
if type == 'token'
success = response.key?('token')
From e2fb86b1091bcee917a8597808c8305e52aa21e3 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 8 Nov 2018 15:04:17 -0500
Subject: [PATCH 0184/2234] RuboCop: fix Style/DefWithParentheses
---
.rubocop_todo.yml | 7 -------
lib/active_merchant/billing/gateways/latitude19.rb | 2 +-
lib/active_merchant/billing/gateways/pagarme.rb | 2 +-
3 files changed, 2 insertions(+), 9 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index cedf33c61f6..399f452aaeb 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -569,13 +569,6 @@ Style/DateTime:
- 'test/unit/gateways/orbital_test.rb'
- 'test/unit/gateways/paypal/paypal_common_api_test.rb'
-# Offense count: 2
-# Cop supports --auto-correct.
-Style/DefWithParentheses:
- Exclude:
- - 'lib/active_merchant/billing/gateways/latitude19.rb'
- - 'lib/active_merchant/billing/gateways/pagarme.rb'
-
# Offense count: 210
Style/Documentation:
Enabled: false
diff --git a/lib/active_merchant/billing/gateways/latitude19.rb b/lib/active_merchant/billing/gateways/latitude19.rb
index 89d3d8f50df..d30b5e14a22 100644
--- a/lib/active_merchant/billing/gateways/latitude19.rb
+++ b/lib/active_merchant/billing/gateways/latitude19.rb
@@ -153,7 +153,7 @@ def add_request_id(post)
post[:id] = SecureRandom.hex(16)
end
- def add_timestamp()
+ def add_timestamp
Time.now.getutc.strftime('%Y%m%d%H%M%S')
end
diff --git a/lib/active_merchant/billing/gateways/pagarme.rb b/lib/active_merchant/billing/gateways/pagarme.rb
index 63d29f4f2c3..26545c7c2d3 100644
--- a/lib/active_merchant/billing/gateways/pagarme.rb
+++ b/lib/active_merchant/billing/gateways/pagarme.rb
@@ -230,7 +230,7 @@ def authorization_from(response)
end
end
- def test?()
+ def test?
@api_key.start_with?('ak_test')
end
From 01a6f98fe3319a00e8c2c962b8580b9f8adc8e02 Mon Sep 17 00:00:00 2001
From: Niaja
Date: Fri, 16 Nov 2018 10:25:10 -0500
Subject: [PATCH 0185/2234] Optimal Payment: Add verify capabilities
Adds verify to optimal payment.
Loaded suite test/remote/gateways/remote_optimal_payment_test
Started
................
16 tests, 73 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Loaded suite test/unit/gateways/optimal_payment_test
...................
19 tests, 75 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/optimal_payment.rb | 5 +++++
test/remote/gateways/remote_optimal_payment_test.rb | 6 ++++++
3 files changed, 12 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index c1a9e5d5161..8837cadee46 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -5,6 +5,7 @@
* Moneris: Adds Credential on File logic [deedeelavinder] #3042
* Adyen: Return AVS and CVC Result [nfarve] #3044
* Braintree: Account for nil address with existing customer [curiousepic] #3047
+* Optimal Payment: Add verify capabilities #3052
== Version 1.86.0 (October 26, 2018)
* UsaEpayTransaction: Support UMcheckformat option for echecks [dtykocki] #3002
diff --git a/lib/active_merchant/billing/gateways/optimal_payment.rb b/lib/active_merchant/billing/gateways/optimal_payment.rb
index 7dd2427ac33..30f7bf57e02 100644
--- a/lib/active_merchant/billing/gateways/optimal_payment.rb
+++ b/lib/active_merchant/billing/gateways/optimal_payment.rb
@@ -60,6 +60,11 @@ def capture(money, authorization, options = {})
commit('ccSettlement', money, options)
end
+ def verify(credit_card, options = {})
+ parse_card_or_auth(credit_card, options)
+ commit('ccVerification', 0, options)
+ end
+
def supports_scrubbing?
true
end
diff --git a/test/remote/gateways/remote_optimal_payment_test.rb b/test/remote/gateways/remote_optimal_payment_test.rb
index 58a93dcce78..6061a306300 100644
--- a/test/remote/gateways/remote_optimal_payment_test.rb
+++ b/test/remote/gateways/remote_optimal_payment_test.rb
@@ -51,6 +51,12 @@ def test_purchase_with_no_cvv
assert_equal 'no_error', response.message
end
+ def test_successful_verify
+ response = @gateway.verify(@credit_card, @options)
+ assert_success response
+ assert_equal 'no_error', response.message
+ end
+
def test_authorize_and_capture
assert auth = @gateway.authorize(@amount, @credit_card, @options)
assert_success auth
From acf1b4c2be042fd2fc8657028c6ecf5e8c401ba6 Mon Sep 17 00:00:00 2001
From: DeeDee Lavinder
Date: Thu, 15 Nov 2018 12:48:44 -0500
Subject: [PATCH 0186/2234] Moneris: Allows cof_enabled gateway to process
non-cof transactions
Adds a bypass for transactions without credential-on-file details when
@cof_enabled is true.
Unit Tests:
37 tests, 188 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
Remote Tests:
31 tests, 119 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
93.5484% passed
(The two failing tests are not related and appear to be timing-based.)
---
lib/active_merchant/billing/gateways/moneris.rb | 12 ++++++++----
test/remote/gateways/remote_moneris_test.rb | 17 +++++++++++++++++
2 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/moneris.rb b/lib/active_merchant/billing/gateways/moneris.rb
index a92f567ec7a..839bac02869 100644
--- a/lib/active_merchant/billing/gateways/moneris.rb
+++ b/lib/active_merchant/billing/gateways/moneris.rb
@@ -293,7 +293,7 @@ def transaction_element(action, parameters)
when :cvd_info
transaction.add_element(cvd_element(parameters[:cvd_value])) if @cvv_enabled
when :cof_info
- transaction.add_element(credential_on_file(parameters)) if @cof_enabled
+ transaction.add_element(credential_on_file(parameters)) if @cof_enabled && cof_details_present?(parameters)
else
transaction.add_element(key.to_s).text = parameters[key] unless parameters[key].blank?
end
@@ -324,10 +324,14 @@ def cvd_element(cvd_value)
element
end
+ def cof_details_present?(parameters)
+ parameters[:issuer_id] && parameters[:payment_indicator] && parameters[:payment_information]
+ end
+
def credential_on_file(parameters)
- issuer_id = parameters[:issuer_id] || ''
- payment_indicator = parameters[:payment_indicator] if parameters[:payment_indicator]
- payment_information = parameters[:payment_information] if parameters[:payment_information]
+ issuer_id = parameters[:issuer_id]
+ payment_indicator = parameters[:payment_indicator]
+ payment_information = parameters[:payment_information]
cof_info = REXML::Element.new('cof_info')
cof_info.add_element('issuer_id').text = issuer_id
diff --git a/test/remote/gateways/remote_moneris_test.rb b/test/remote/gateways/remote_moneris_test.rb
index 27da8f7271c..f096b7a9d51 100644
--- a/test/remote/gateways/remote_moneris_test.rb
+++ b/test/remote/gateways/remote_moneris_test.rb
@@ -30,6 +30,23 @@ def test_successful_first_purchase_with_credential_on_file
assert_not_empty response.params['issuer_id']
end
+ def test_successful_purchase_with_cof_enabled_and_no_cof_options
+ gateway = MonerisGateway.new(fixtures(:moneris).merge(cof_enabled: true))
+ assert response = gateway.purchase(@amount, @credit_card, @options)
+ assert_success response
+ assert_equal 'Approved', response.message
+ assert_false response.authorization.blank?
+ end
+
+ def test_successful_non_cof_purchase_with_cof_enabled_and_only_issuer_id_sent
+ gateway = MonerisGateway.new(fixtures(:moneris).merge(cof_enabled: true))
+ assert response = gateway.purchase(@amount, @credit_card, @options.merge(issuer_id: ''))
+ assert_success response
+ assert_equal 'Approved', response.message
+ assert_false response.authorization.blank?
+ assert_nil response.params['issuer_id']
+ end
+
def test_successful_subsequent_purchase_with_credential_on_file
gateway = MonerisGateway.new(fixtures(:moneris).merge(cof_enabled: true))
assert response = gateway.authorize(
From ec8288dffd2c431c768541b601df9874e7065d22 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Tue, 20 Nov 2018 13:53:54 -0500
Subject: [PATCH 0187/2234] Update India support for various gateways
---
CHANGELOG | 3 +++
lib/active_merchant/billing/gateways/cenpos.rb | 2 +-
lib/active_merchant/billing/gateways/cyber_source.rb | 2 +-
lib/active_merchant/billing/gateways/migs.rb | 2 +-
4 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 8837cadee46..667d5008138 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -6,6 +6,9 @@
* Adyen: Return AVS and CVC Result [nfarve] #3044
* Braintree: Account for nil address with existing customer [curiousepic] #3047
* Optimal Payment: Add verify capabilities #3052
+* Cenpos: update supported countries [bpollack] #3055
+* CyberSource: update supported countries [bpollack] #3055
+* MiGS: update supported countries [bpollack] #3055
== Version 1.86.0 (October 26, 2018)
* UsaEpayTransaction: Support UMcheckformat option for echecks [dtykocki] #3002
diff --git a/lib/active_merchant/billing/gateways/cenpos.rb b/lib/active_merchant/billing/gateways/cenpos.rb
index 5412821c21e..9ba37a7c00b 100644
--- a/lib/active_merchant/billing/gateways/cenpos.rb
+++ b/lib/active_merchant/billing/gateways/cenpos.rb
@@ -8,7 +8,7 @@ class CenposGateway < Gateway
self.live_url = 'https://ww3.cenpos.net/6/transact.asmx'
- self.supported_countries = %w(AD AI AG AR AU AT BS BB BE BZ BM BR BN BG CA HR CY CZ DK DM EE FI FR DE GR GD GY HK HU IS IN IL IT JP LV LI LT LU MY MT MX MC MS NL PA PL PT KN LC MF VC SM SG SK SI ZA ES SR SE CH TR GB US UY)
+ self.supported_countries = %w(AD AI AG AR AU AT BS BB BE BZ BM BR BN BG CA HR CY CZ DK DM EE FI FR DE GR GD GY HK HU IS IL IT JP LV LI LT LU MY MT MX MC MS NL PA PL PT KN LC MF VC SM SG SK SI ZA ES SR SE CH TR GB US UY)
self.default_currency = 'USD'
self.money_format = :dollars
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb
index 9cb8d2f1a2b..daafe4ad92d 100644
--- a/lib/active_merchant/billing/gateways/cyber_source.rb
+++ b/lib/active_merchant/billing/gateways/cyber_source.rb
@@ -27,7 +27,7 @@ class CyberSourceGateway < Gateway
XSD_VERSION = '1.121'
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb, :dankort, :maestro]
- self.supported_countries = %w(US BR CA CN DK FI FR DE JP MX NO SE GB SG LB)
+ self.supported_countries = %w(US BR CA CN DK FI FR DE IN JP MX NO SE GB SG LB)
self.default_currency = 'USD'
self.currencies_without_fractions = %w(JPY)
diff --git a/lib/active_merchant/billing/gateways/migs.rb b/lib/active_merchant/billing/gateways/migs.rb
index a7bc303d06c..bb0c3ef7ae1 100644
--- a/lib/active_merchant/billing/gateways/migs.rb
+++ b/lib/active_merchant/billing/gateways/migs.rb
@@ -17,7 +17,7 @@ class MigsGateway < Gateway
# MiGS is supported throughout Asia Pacific, Middle East and Africa
# MiGS is used in Australia (AU) by ANZ (eGate), CBA (CommWeb) and more
# Source of Country List: http://www.scribd.com/doc/17811923
- self.supported_countries = %w(AU AE BD BN EG HK ID IN JO KW LB LK MU MV MY NZ OM PH QA SA SG TT VN)
+ self.supported_countries = %w(AU AE BD BN EG HK ID JO KW LB LK MU MV MY NZ OM PH QA SA SG TT VN)
# The card types supported by the payment gateway
self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :jcb]
From 8af148a9db3802a0c7832b46030543e3658a7bd2 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 8 Nov 2018 15:06:12 -0500
Subject: [PATCH 0188/2234] RuboCop: fix Layout/SpaceInsideParens
---
.rubocop_todo.yml | 7 -------
lib/active_merchant/billing/gateways/bogus.rb | 4 ++--
lib/active_merchant/billing/gateways/braintree_blue.rb | 2 +-
lib/active_merchant/billing/gateways/cardknox.rb | 2 +-
lib/active_merchant/billing/gateways/cyber_source.rb | 2 +-
lib/active_merchant/billing/gateways/elavon.rb | 2 +-
lib/active_merchant/billing/gateways/inspire.rb | 2 +-
lib/active_merchant/billing/gateways/itransact.rb | 2 +-
lib/active_merchant/billing/gateways/linkpoint.rb | 2 +-
lib/active_merchant/billing/gateways/mercado_pago.rb | 4 ++--
.../billing/gateways/merchant_e_solutions.rb | 2 +-
lib/active_merchant/billing/gateways/net_registry.rb | 2 +-
lib/active_merchant/billing/gateways/pay_hub.rb | 2 +-
lib/active_merchant/billing/gateways/pay_junction.rb | 2 +-
lib/active_merchant/billing/gateways/pay_secure.rb | 2 +-
lib/active_merchant/billing/gateways/payflow.rb | 6 +++---
.../billing/gateways/payflow/payflow_common_api.rb | 2 +-
lib/active_merchant/billing/gateways/paymill.rb | 2 +-
lib/active_merchant/billing/gateways/plugnpay.rb | 2 +-
lib/active_merchant/billing/gateways/psl_card.rb | 4 ++--
lib/active_merchant/billing/gateways/quantum.rb | 2 +-
lib/active_merchant/billing/gateways/sage_pay.rb | 2 +-
.../billing/gateways/secure_pay_tech.rb | 2 +-
lib/active_merchant/billing/gateways/skip_jack.rb | 2 +-
lib/active_merchant/billing/gateways/smart_ps.rb | 2 +-
lib/active_merchant/billing/gateways/trust_commerce.rb | 4 ++--
.../billing/gateways/usa_epay_transaction.rb | 2 +-
lib/active_merchant/billing/gateways/verifi.rb | 2 +-
lib/active_merchant/billing/gateways/viaklix.rb | 2 +-
lib/active_merchant/billing/gateways/worldpay.rb | 2 +-
test/remote/gateways/remote_card_stream_test.rb | 4 ++--
test/remote/gateways/remote_cyber_source_test.rb | 2 +-
test/remote/gateways/remote_exact_test.rb | 6 +++---
test/remote/gateways/remote_firstdata_e4_test.rb | 6 +++---
test/remote/gateways/remote_firstdata_e4_v27_test.rb | 6 +++---
test/remote/gateways/remote_flo2cash_simple_test.rb | 2 +-
test/remote/gateways/remote_pay_junction_test.rb | 4 ++--
test/remote/gateways/remote_payeezy_test.rb | 4 ++--
test/remote/gateways/remote_payment_express_test.rb | 2 +-
test/remote/gateways/remote_stripe_connect_test.rb | 2 +-
test/remote/gateways/remote_visanet_peru_test.rb | 2 +-
test/unit/gateways/blue_pay_test.rb | 6 +++---
test/unit/gateways/braintree_blue_test.rb | 2 +-
test/unit/gateways/braintree_orange_test.rb | 8 ++++----
test/unit/gateways/cashnet_test.rb | 2 +-
test/unit/gateways/clearhaus_test.rb | 2 +-
test/unit/gateways/evo_ca_test.rb | 4 ++--
test/unit/gateways/exact_test.rb | 10 +++++-----
test/unit/gateways/federated_canada_test.rb | 2 +-
test/unit/gateways/inspire_test.rb | 4 ++--
test/unit/gateways/metrics_global_test.rb | 4 ++--
test/unit/gateways/money_movers_test.rb | 2 +-
test/unit/gateways/pac_net_raven_test.rb | 2 +-
test/unit/gateways/payflow_test.rb | 4 ++--
test/unit/gateways/paypal_digital_goods_test.rb | 6 +++---
test/unit/gateways/plugnpay_test.rb | 4 ++--
56 files changed, 86 insertions(+), 93 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 399f452aaeb..a93108be0b4 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -172,13 +172,6 @@ Layout/SpaceInsideBlockBraces:
Layout/SpaceInsideHashLiteralBraces:
Enabled: false
-# Offense count: 116
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle.
-# SupportedStyles: space, no_space
-Layout/SpaceInsideParens:
- Enabled: false
-
# Offense count: 115
# Cop supports --auto-correct.
Layout/SpaceInsidePercentLiteralDelimiters:
diff --git a/lib/active_merchant/billing/gateways/bogus.rb b/lib/active_merchant/billing/gateways/bogus.rb
index e72bae4760c..8cafd0eeba5 100644
--- a/lib/active_merchant/billing/gateways/bogus.rb
+++ b/lib/active_merchant/billing/gateways/bogus.rb
@@ -47,7 +47,7 @@ def credit(money, paysource, options = {})
money = amount(money)
case normalize(paysource)
when /1$/
- Response.new(true, SUCCESS_MESSAGE, {:paid_amount => money}, :test => true )
+ Response.new(true, SUCCESS_MESSAGE, {:paid_amount => money}, :test => true)
when /2$/
Response.new(false, FAILURE_MESSAGE, {:paid_amount => money, :error => FAILURE_MESSAGE }, :test => true, :error_code => STANDARD_ERROR_CODE[:processing_error])
else
@@ -130,7 +130,7 @@ def authorize_swipe(money, paysource, options = {})
money = amount(money)
case normalize(paysource)
when /1$/, AUTHORIZATION
- Response.new(true, SUCCESS_MESSAGE, {:authorized_amount => money}, :test => true, :authorization => AUTHORIZATION )
+ Response.new(true, SUCCESS_MESSAGE, {:authorized_amount => money}, :test => true, :authorization => AUTHORIZATION)
when /2$/
Response.new(false, FAILURE_MESSAGE, {:authorized_amount => money, :error => FAILURE_MESSAGE }, :test => true, :error_code => STANDARD_ERROR_CODE[:processing_error])
else
diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb
index 8e8f9f6830a..d39a4b72b56 100644
--- a/lib/active_merchant/billing/gateways/braintree_blue.rb
+++ b/lib/active_merchant/billing/gateways/braintree_blue.rb
@@ -69,7 +69,7 @@ def initialize(options = {})
:logger => options[:logger] || logger
)
- @braintree_gateway = Braintree::Gateway.new( @configuration )
+ @braintree_gateway = Braintree::Gateway.new(@configuration)
end
def authorize(money, credit_card_or_vault_id, options = {})
diff --git a/lib/active_merchant/billing/gateways/cardknox.rb b/lib/active_merchant/billing/gateways/cardknox.rb
index a611004f75b..634eb8a72ac 100644
--- a/lib/active_merchant/billing/gateways/cardknox.rb
+++ b/lib/active_merchant/billing/gateways/cardknox.rb
@@ -255,7 +255,7 @@ def add_cardknox_token(post, authorization)
def parse(body)
fields = {}
for line in body.split('&')
- key, value = *line.scan( %r{^(\w+)\=(.*)$} ).flatten
+ key, value = *line.scan(%r{^(\w+)\=(.*)$}).flatten
fields[key] = CGI.unescape(value.to_s)
end
diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb
index daafe4ad92d..2d3e2ceff0f 100644
--- a/lib/active_merchant/billing/gateways/cyber_source.rb
+++ b/lib/active_merchant/billing/gateways/cyber_source.rb
@@ -113,7 +113,7 @@ def initialize(options = {})
def authorize(money, creditcard_or_reference, options = {})
setup_address_hash(options)
- commit(build_auth_request(money, creditcard_or_reference, options), :authorize, money, options )
+ commit(build_auth_request(money, creditcard_or_reference, options), :authorize, money, options)
end
def capture(money, authorization, options = {})
diff --git a/lib/active_merchant/billing/gateways/elavon.rb b/lib/active_merchant/billing/gateways/elavon.rb
index 34bb44f5bc0..bdcf11490e4 100644
--- a/lib/active_merchant/billing/gateways/elavon.rb
+++ b/lib/active_merchant/billing/gateways/elavon.rb
@@ -256,7 +256,7 @@ def commit(action, money, parameters, options)
parameters[:amount] = amount(money)
parameters[:transaction_type] = self.actions[action]
- response = parse( ssl_post(test? ? self.test_url : self.live_url, post_data(parameters, options)) )
+ response = parse(ssl_post(test? ? self.test_url : self.live_url, post_data(parameters, options)))
Response.new(response['result'] == '0', message_from(response), response,
:test => @options[:test] || test?,
diff --git a/lib/active_merchant/billing/gateways/inspire.rb b/lib/active_merchant/billing/gateways/inspire.rb
index 78a193fc5ce..0e57ffe09f2 100644
--- a/lib/active_merchant/billing/gateways/inspire.rb
+++ b/lib/active_merchant/billing/gateways/inspire.rb
@@ -174,7 +174,7 @@ def parse(body)
def commit(action, money, parameters)
parameters[:amount] = amount(money) if money
- response = parse( ssl_post(self.live_url, post_data(action, parameters)) )
+ response = parse(ssl_post(self.live_url, post_data(action, parameters)))
Response.new(response['response'] == '1', message_from(response), response,
:authorization => response['transactionid'],
diff --git a/lib/active_merchant/billing/gateways/itransact.rb b/lib/active_merchant/billing/gateways/itransact.rb
index e7861de3d95..8bac0734e0a 100644
--- a/lib/active_merchant/billing/gateways/itransact.rb
+++ b/lib/active_merchant/billing/gateways/itransact.rb
@@ -302,7 +302,7 @@ def add_invoice(xml, money, options)
xml.AuthCode options[:force] if options[:force]
if options[:order_items].blank?
xml.Total(amount(money)) unless(money.nil? || money < 0.01)
- xml.Description(options[:description]) unless( options[:description].blank?)
+ xml.Description(options[:description]) unless(options[:description].blank?)
else
xml.OrderItems {
options[:order_items].each do |item|
diff --git a/lib/active_merchant/billing/gateways/linkpoint.rb b/lib/active_merchant/billing/gateways/linkpoint.rb
index 61e5fe0e430..4dd09c89800 100644
--- a/lib/active_merchant/billing/gateways/linkpoint.rb
+++ b/lib/active_merchant/billing/gateways/linkpoint.rb
@@ -169,7 +169,7 @@ def initialize(options = {})
def recurring(money, creditcard, options={})
ActiveMerchant.deprecated RECURRING_DEPRECATION_MESSAGE
- requires!(options, [:periodicity, :bimonthly, :monthly, :biweekly, :weekly, :yearly, :daily], :installments, :order_id )
+ requires!(options, [:periodicity, :bimonthly, :monthly, :biweekly, :weekly, :yearly, :daily], :installments, :order_id)
options.update(
:ordertype => 'SALE',
diff --git a/lib/active_merchant/billing/gateways/mercado_pago.rb b/lib/active_merchant/billing/gateways/mercado_pago.rb
index ef76ab493ad..95a9f372930 100644
--- a/lib/active_merchant/billing/gateways/mercado_pago.rb
+++ b/lib/active_merchant/billing/gateways/mercado_pago.rb
@@ -19,7 +19,7 @@ def purchase(money, payment, options={})
MultiResponse.run do |r|
r.process { commit('tokenize', 'card_tokens', card_token_request(money, payment, options)) }
options[:card_token] = r.authorization.split('|').first
- r.process { commit('purchase', 'payments', purchase_request(money, payment, options) ) }
+ r.process { commit('purchase', 'payments', purchase_request(money, payment, options)) }
end
end
@@ -27,7 +27,7 @@ def authorize(money, payment, options={})
MultiResponse.run do |r|
r.process { commit('tokenize', 'card_tokens', card_token_request(money, payment, options)) }
options[:card_token] = r.authorization.split('|').first
- r.process { commit('authorize', 'payments', authorize_request(money, payment, options) ) }
+ r.process { commit('authorize', 'payments', authorize_request(money, payment, options)) }
end
end
diff --git a/lib/active_merchant/billing/gateways/merchant_e_solutions.rb b/lib/active_merchant/billing/gateways/merchant_e_solutions.rb
index 1f465a07ca4..fd7368d68db 100644
--- a/lib/active_merchant/billing/gateways/merchant_e_solutions.rb
+++ b/lib/active_merchant/billing/gateways/merchant_e_solutions.rb
@@ -159,7 +159,7 @@ def commit(action, money, parameters)
parameters[:transaction_amount] = amount(money) if money unless action == 'V'
response = begin
- parse( ssl_post(url, post_data(action, parameters)) )
+ parse(ssl_post(url, post_data(action, parameters)))
rescue ActiveMerchant::ResponseError => e
{ 'error_code' => '404', 'auth_response_text' => e.to_s }
end
diff --git a/lib/active_merchant/billing/gateways/net_registry.rb b/lib/active_merchant/billing/gateways/net_registry.rb
index 88cec2f11cf..0440ee8be2f 100644
--- a/lib/active_merchant/billing/gateways/net_registry.rb
+++ b/lib/active_merchant/billing/gateways/net_registry.rb
@@ -142,7 +142,7 @@ def expiry(credit_card)
# omitted if nil.
def commit(action, params)
# get gateway response
- response = parse( ssl_post(self.live_url, post_data(action, params)) )
+ response = parse(ssl_post(self.live_url, post_data(action, params)))
Response.new(response['status'] == 'approved', message_from(response), response,
:authorization => authorization_from(response, action)
diff --git a/lib/active_merchant/billing/gateways/pay_hub.rb b/lib/active_merchant/billing/gateways/pay_hub.rb
index 47c6ac35cc7..fdcc6c5d600 100644
--- a/lib/active_merchant/billing/gateways/pay_hub.rb
+++ b/lib/active_merchant/billing/gateways/pay_hub.rb
@@ -171,7 +171,7 @@ def commit(post)
success = false
begin
- raw_response = ssl_post(live_url, post.to_json, {'Content-Type' => 'application/json'} )
+ raw_response = ssl_post(live_url, post.to_json, {'Content-Type' => 'application/json'})
response = parse(raw_response)
success = (response['RESPONSE_CODE'] == '00')
rescue ResponseError => e
diff --git a/lib/active_merchant/billing/gateways/pay_junction.rb b/lib/active_merchant/billing/gateways/pay_junction.rb
index 84ccb33b34b..19dd8317037 100644
--- a/lib/active_merchant/billing/gateways/pay_junction.rb
+++ b/lib/active_merchant/billing/gateways/pay_junction.rb
@@ -334,7 +334,7 @@ def add_optional_fields(params, options)
def commit(action, parameters)
url = test? ? self.test_url : self.live_url
- response = parse( ssl_post(url, post_data(action, parameters)) )
+ response = parse(ssl_post(url, post_data(action, parameters)))
Response.new(successful?(response), message_from(response), response,
:test => test?,
diff --git a/lib/active_merchant/billing/gateways/pay_secure.rb b/lib/active_merchant/billing/gateways/pay_secure.rb
index f5f539a3185..117b33939d9 100644
--- a/lib/active_merchant/billing/gateways/pay_secure.rb
+++ b/lib/active_merchant/billing/gateways/pay_secure.rb
@@ -66,7 +66,7 @@ def add_credit_card(post, credit_card)
end
def commit(action, money, parameters)
- response = parse( ssl_post(self.live_url, post_data(action, parameters)) )
+ response = parse(ssl_post(self.live_url, post_data(action, parameters)))
Response.new(successful?(response), message_from(response), response,
:test => test_response?(response),
diff --git a/lib/active_merchant/billing/gateways/payflow.rb b/lib/active_merchant/billing/gateways/payflow.rb
index e8f08d29834..3123693a84d 100644
--- a/lib/active_merchant/billing/gateways/payflow.rb
+++ b/lib/active_merchant/billing/gateways/payflow.rb
@@ -92,7 +92,7 @@ def cancel_recurring(profile_id)
def recurring_inquiry(profile_id, options = {})
ActiveMerchant.deprecated RECURRING_DEPRECATION_MESSAGE
- request = build_recurring_request(:inquiry, nil, options.update( :profile_id => profile_id ))
+ request = build_recurring_request(:inquiry, nil, options.update(:profile_id => profile_id))
commit(request, options.merge(:request_type => :recurring))
end
@@ -289,7 +289,7 @@ def build_recurring_request(action, money, options)
end
if action == :add
- xml.tag! 'Start', format_rp_date(options[:starting_at] || Date.today + 1 )
+ xml.tag! 'Start', format_rp_date(options[:starting_at] || Date.today + 1)
else
xml.tag! 'Start', format_rp_date(options[:starting_at]) unless options[:starting_at].nil?
end
@@ -308,7 +308,7 @@ def build_recurring_request(action, money, options)
xml.tag! 'ProfileID', options[:profile_id]
end
if action == :inquiry
- xml.tag! 'PaymentHistory', ( options[:history] ? 'Y' : 'N' )
+ xml.tag! 'PaymentHistory', (options[:history] ? 'Y' : 'N')
end
end
end
diff --git a/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb b/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb
index b524126ef1e..32213491eb5 100644
--- a/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb
+++ b/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb
@@ -178,7 +178,7 @@ def parse_element(response, node)
# down as we do everywhere else. RPPaymentResult elements are not contained
# in an RPPaymentResults element so we'll come here multiple times
response[node_name] ||= []
- response[node_name] << ( payment_result_response = {} )
+ response[node_name] << (payment_result_response = {})
node.xpath('.//*').each{ |e| parse_element(payment_result_response, e) }
when node.xpath('.//*').to_a.any?
node.xpath('.//*').each{|e| parse_element(response, e) }
diff --git a/lib/active_merchant/billing/gateways/paymill.rb b/lib/active_merchant/billing/gateways/paymill.rb
index 46179c8ecf5..01b4cd9ebfb 100644
--- a/lib/active_merchant/billing/gateways/paymill.rb
+++ b/lib/active_merchant/billing/gateways/paymill.rb
@@ -82,7 +82,7 @@ def add_credit_card(post, credit_card, options)
post['account.verification'] = credit_card.verification_value
post['account.email'] = (options[:email] || nil)
post['presentation.amount3D'] = (options[:money] || nil)
- post['presentation.currency3D'] = (options[:currency] || currency( options[:money]))
+ post['presentation.currency3D'] = (options[:currency] || currency(options[:money]))
end
def headers
diff --git a/lib/active_merchant/billing/gateways/plugnpay.rb b/lib/active_merchant/billing/gateways/plugnpay.rb
index 750f133a35b..36becf69ff8 100644
--- a/lib/active_merchant/billing/gateways/plugnpay.rb
+++ b/lib/active_merchant/billing/gateways/plugnpay.rb
@@ -174,7 +174,7 @@ def refund(money, reference, options = {})
private
def commit(action, post)
- response = parse( ssl_post(self.live_url, post_data(action, post)) )
+ response = parse(ssl_post(self.live_url, post_data(action, post)))
success = SUCCESS_CODES.include?(response[:finalstatus])
message = success ? 'Success' : message_from(response)
diff --git a/lib/active_merchant/billing/gateways/psl_card.rb b/lib/active_merchant/billing/gateways/psl_card.rb
index 827a5cc11a4..d0495a42037 100644
--- a/lib/active_merchant/billing/gateways/psl_card.rb
+++ b/lib/active_merchant/billing/gateways/psl_card.rb
@@ -242,7 +242,7 @@ def currency_code(currency)
def parse(body)
fields = {}
for line in body.split('&')
- key, value = *line.scan( %r{^(\w+)\=(.*)$} ).flatten
+ key, value = *line.scan(%r{^(\w+)\=(.*)$}).flatten
fields[key] = CGI.unescape(value)
end
fields.symbolize_keys
@@ -257,7 +257,7 @@ def parse(body)
# - ActiveMerchant::Billing::Response object
#
def commit(request)
- response = parse( ssl_post(self.live_url, post_data(request)) )
+ response = parse(ssl_post(self.live_url, post_data(request)))
Response.new(response[:ResponseCode] == APPROVED, response[:Message], response,
:test => test?,
diff --git a/lib/active_merchant/billing/gateways/quantum.rb b/lib/active_merchant/billing/gateways/quantum.rb
index d15ec35c939..38a53eeb08c 100644
--- a/lib/active_merchant/billing/gateways/quantum.rb
+++ b/lib/active_merchant/billing/gateways/quantum.rb
@@ -44,7 +44,7 @@ def initialize(options = {})
#
def authorize(money, creditcard, options = {})
setup_address_hash(options)
- commit(build_auth_request(money, creditcard, options), options )
+ commit(build_auth_request(money, creditcard, options), options)
end
# Capture an authorization that has previously been requested
diff --git a/lib/active_merchant/billing/gateways/sage_pay.rb b/lib/active_merchant/billing/gateways/sage_pay.rb
index ae3f747d018..449d7306580 100644
--- a/lib/active_merchant/billing/gateways/sage_pay.rb
+++ b/lib/active_merchant/billing/gateways/sage_pay.rb
@@ -343,7 +343,7 @@ def format_date(month, year)
end
def commit(action, parameters)
- response = parse( ssl_post(url_for(action), post_data(action, parameters)) )
+ response = parse(ssl_post(url_for(action), post_data(action, parameters)))
Response.new(response['Status'] == APPROVED, message_from(response), response,
:test => test?,
diff --git a/lib/active_merchant/billing/gateways/secure_pay_tech.rb b/lib/active_merchant/billing/gateways/secure_pay_tech.rb
index 3cf645f8838..b6980d4cf99 100644
--- a/lib/active_merchant/billing/gateways/secure_pay_tech.rb
+++ b/lib/active_merchant/billing/gateways/secure_pay_tech.rb
@@ -82,7 +82,7 @@ def parse(body)
end
def commit(action, post)
- response = parse( ssl_post(self.live_url, post_data(action, post) ) )
+ response = parse(ssl_post(self.live_url, post_data(action, post)))
Response.new(response[:result_code] == 1, message_from(response), response,
:test => test?,
diff --git a/lib/active_merchant/billing/gateways/skip_jack.rb b/lib/active_merchant/billing/gateways/skip_jack.rb
index 56dd6a2309e..3528b04f22c 100644
--- a/lib/active_merchant/billing/gateways/skip_jack.rb
+++ b/lib/active_merchant/billing/gateways/skip_jack.rb
@@ -260,7 +260,7 @@ def add_status_action(post, action)
end
def commit(action, money, parameters)
- response = parse( ssl_post( url_for(action), post_data(action, money, parameters) ), action )
+ response = parse(ssl_post(url_for(action), post_data(action, money, parameters)), action)
# Pass along the original transaction id in the case an update transaction
Response.new(response[:success], message_from(response, action), response,
diff --git a/lib/active_merchant/billing/gateways/smart_ps.rb b/lib/active_merchant/billing/gateways/smart_ps.rb
index 8f84413abdc..fe196f6dc0b 100644
--- a/lib/active_merchant/billing/gateways/smart_ps.rb
+++ b/lib/active_merchant/billing/gateways/smart_ps.rb
@@ -230,7 +230,7 @@ def parse(body)
def commit(action, money, parameters)
parameters[:amount] = localized_amount(money, parameters[:currency] || default_currency) if money
- response = parse( ssl_post(self.live_url, post_data(action, parameters)) )
+ response = parse(ssl_post(self.live_url, post_data(action, parameters)))
Response.new(response['response'] == '1', message_from(response), response,
:authorization => (response['transactionid'] || response['customer_vault_id']),
:test => test?,
diff --git a/lib/active_merchant/billing/gateways/trust_commerce.rb b/lib/active_merchant/billing/gateways/trust_commerce.rb
index 416824a5d38..c10819e6eed 100644
--- a/lib/active_merchant/billing/gateways/trust_commerce.rb
+++ b/lib/active_merchant/billing/gateways/trust_commerce.rb
@@ -237,7 +237,7 @@ def void(authorization, options = {})
def recurring(money, creditcard, options = {})
ActiveMerchant.deprecated RECURRING_DEPRECATION_MESSAGE
- requires!(options, [:periodicity, :bimonthly, :monthly, :biweekly, :weekly, :yearly, :daily] )
+ requires!(options, [:periodicity, :bimonthly, :monthly, :biweekly, :weekly, :yearly, :daily])
cycle = case options[:periodicity]
when :monthly
@@ -385,7 +385,7 @@ def commit(action, parameters)
data = if tclink?
TCLink.send(parameters)
else
- parse( ssl_post(self.live_url, post_data(parameters)) )
+ parse(ssl_post(self.live_url, post_data(parameters)))
end
# to be considered successful, transaction status must be either "approved" or "accepted"
diff --git a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb
index bb9b41d7fcb..4eb7827b27c 100644
--- a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb
+++ b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb
@@ -234,7 +234,7 @@ def add_split_payments(post, options)
def parse(body)
fields = {}
for line in body.split('&')
- key, value = *line.scan( %r{^(\w+)\=(.*)$} ).flatten
+ key, value = *line.scan(%r{^(\w+)\=(.*)$}).flatten
fields[key] = CGI.unescape(value.to_s)
end
diff --git a/lib/active_merchant/billing/gateways/verifi.rb b/lib/active_merchant/billing/gateways/verifi.rb
index b8c2142e621..e435505d8be 100644
--- a/lib/active_merchant/billing/gateways/verifi.rb
+++ b/lib/active_merchant/billing/gateways/verifi.rb
@@ -192,7 +192,7 @@ def add_security_key_data(post, options, money)
def commit(trx_type, money, post)
post[:amount] = amount(money)
- response = parse( ssl_post(self.live_url, post_data(trx_type, post)) )
+ response = parse(ssl_post(self.live_url, post_data(trx_type, post)))
Response.new(response[:response].to_i == SUCCESS, message_from(response), response,
:test => test?,
diff --git a/lib/active_merchant/billing/gateways/viaklix.rb b/lib/active_merchant/billing/gateways/viaklix.rb
index af2b009d410..269c5b3a8be 100644
--- a/lib/active_merchant/billing/gateways/viaklix.rb
+++ b/lib/active_merchant/billing/gateways/viaklix.rb
@@ -138,7 +138,7 @@ def commit(action, money, parameters)
parameters[:amount] = amount(money)
parameters[:transaction_type] = self.actions[action]
- response = parse( ssl_post(test? ? self.test_url : self.live_url, post_data(parameters)) )
+ response = parse(ssl_post(test? ? self.test_url : self.live_url, post_data(parameters)))
Response.new(response['result'] == APPROVED, message_from(response), response,
:test => @options[:test] || test?,
diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb
index 57cf72a9100..30b795da727 100644
--- a/lib/active_merchant/billing/gateways/worldpay.rb
+++ b/lib/active_merchant/billing/gateways/worldpay.rb
@@ -67,7 +67,7 @@ def refund(money, authorization, options = {})
return response if response.success?
return response unless options[:force_full_refund_if_unsettled]
- void(authorization, options ) if response.params['last_event'] == 'AUTHORISED'
+ void(authorization, options) if response.params['last_event'] == 'AUTHORISED'
end
# Credits only function on a Merchant ID/login/profile flagged for Payouts
diff --git a/test/remote/gateways/remote_card_stream_test.rb b/test/remote/gateways/remote_card_stream_test.rb
index c35543a9b9b..fd6d3e8e3ef 100644
--- a/test/remote/gateways/remote_card_stream_test.rb
+++ b/test/remote/gateways/remote_card_stream_test.rb
@@ -424,8 +424,8 @@ def test_transcript_scrubbing
end
clean_transcript = @gateway.scrub(transcript)
- assert_scrubbed( @visacreditcard.number, clean_transcript)
- assert_scrubbed( @visacreditcard.verification_value.to_s, clean_transcript)
+ assert_scrubbed(@visacreditcard.number, clean_transcript)
+ assert_scrubbed(@visacreditcard.verification_value.to_s, clean_transcript)
assert_scrubbed(@gateway.options[:shared_secret], clean_transcript)
end
end
diff --git a/test/remote/gateways/remote_cyber_source_test.rb b/test/remote/gateways/remote_cyber_source_test.rb
index e35e01ba8ce..eca6db9a23e 100644
--- a/test/remote/gateways/remote_cyber_source_test.rb
+++ b/test/remote/gateways/remote_cyber_source_test.rb
@@ -219,7 +219,7 @@ def test_failed_capture_bad_auth_info
end
def test_invalid_login
- gateway = CyberSourceGateway.new( :login => 'asdf', :password => 'qwer' )
+ gateway = CyberSourceGateway.new(:login => 'asdf', :password => 'qwer')
assert response = gateway.purchase(@amount, @credit_card, @options)
assert_failure response
assert_equal "wsse:FailedCheck: \nSecurity Data : UsernameToken authentication failed.\n", response.message
diff --git a/test/remote/gateways/remote_exact_test.rb b/test/remote/gateways/remote_exact_test.rb
index 879c7b3aa42..8843e170d74 100644
--- a/test/remote/gateways/remote_exact_test.rb
+++ b/test/remote/gateways/remote_exact_test.rb
@@ -21,7 +21,7 @@ def test_successful_purchase
def test_unsuccessful_purchase
# ask for error 13 response (Amount Error) via dollar amount 5,000 + error
@amount = 501300
- assert response = @gateway.purchase(@amount, @credit_card, @options )
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
assert_match %r{Transaction Normal}, response.message
assert_failure response
end
@@ -49,8 +49,8 @@ def test_failed_capture
end
def test_invalid_login
- gateway = ExactGateway.new( :login => 'NotARealUser',
- :password => 'NotARealPassword' )
+ gateway = ExactGateway.new(:login => 'NotARealUser',
+ :password => 'NotARealPassword')
assert response = gateway.purchase(@amount, @credit_card, @options)
assert_match %r{^Invalid Login}, response.message
assert_failure response
diff --git a/test/remote/gateways/remote_firstdata_e4_test.rb b/test/remote/gateways/remote_firstdata_e4_test.rb
index 3a541b57290..f7d88e60197 100755
--- a/test/remote/gateways/remote_firstdata_e4_test.rb
+++ b/test/remote/gateways/remote_firstdata_e4_test.rb
@@ -89,7 +89,7 @@ def test_successful_purchase_with_card_authentication
def test_unsuccessful_purchase
# ask for error 13 response (Amount Error) via dollar amount 5,000 + error
@amount = 501300
- assert response = @gateway.purchase(@amount, @credit_card, @options )
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
assert_match(/Transaction Normal/, response.message)
assert_failure response
end
@@ -104,7 +104,7 @@ def test_bad_creditcard_number
def test_trans_error
# ask for error 42 (unable to send trans) as the cents bit...
@amount = 500042
- assert response = @gateway.purchase(@amount, @credit_card, @options )
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
assert_match(/Unable to Send Transaction/, response.message) # 42 is 'unable to send trans'
assert_failure response
assert_equal response.error_code, 'processing_error'
@@ -179,7 +179,7 @@ def test_failed_verify
def test_invalid_login
gateway = FirstdataE4Gateway.new(:login => 'NotARealUser',
- :password => 'NotARealPassword' )
+ :password => 'NotARealPassword')
assert response = gateway.purchase(@amount, @credit_card, @options)
assert_match %r{Unauthorized Request}, response.message
assert_failure response
diff --git a/test/remote/gateways/remote_firstdata_e4_v27_test.rb b/test/remote/gateways/remote_firstdata_e4_v27_test.rb
index 0832c159edc..4233159fc39 100644
--- a/test/remote/gateways/remote_firstdata_e4_v27_test.rb
+++ b/test/remote/gateways/remote_firstdata_e4_v27_test.rb
@@ -81,7 +81,7 @@ def test_successful_purchase_with_card_authentication
def test_unsuccessful_purchase
# ask for error 13 response (Amount Error) via dollar amount 5,000 + error
@amount = 501300
- assert response = @gateway.purchase(@amount, @credit_card, @options )
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
assert_match(/Transaction Normal/, response.message)
assert_failure response
end
@@ -96,7 +96,7 @@ def test_bad_creditcard_number
def test_trans_error
# ask for error 42 (unable to send trans) as the cents bit...
@amount = 500042
- assert response = @gateway.purchase(@amount, @credit_card, @options )
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
assert_match(/Unable to Send Transaction/, response.message) # 42 is 'unable to send trans'
assert_failure response
assert_equal response.error_code, 'processing_error'
@@ -162,7 +162,7 @@ def test_invalid_login
gateway = FirstdataE4V27Gateway.new(:login => 'NotARealUser',
:password => 'NotARealPassword',
:key_id => 'NotARealKey',
- :hmac_key => 'NotARealHMAC' )
+ :hmac_key => 'NotARealHMAC')
assert response = gateway.purchase(@amount, @credit_card, @options)
assert_match %r{Unauthorized Request}, response.message
assert_failure response
diff --git a/test/remote/gateways/remote_flo2cash_simple_test.rb b/test/remote/gateways/remote_flo2cash_simple_test.rb
index 15aafebb4bb..f952d7c0be1 100644
--- a/test/remote/gateways/remote_flo2cash_simple_test.rb
+++ b/test/remote/gateways/remote_flo2cash_simple_test.rb
@@ -7,7 +7,7 @@ def setup
@gateway = Flo2cashSimpleGateway.new(fixtures(:flo2cash_simple))
@amount = 100
- @credit_card = credit_card('5123456789012346', brand: :master, month: 5, year: 2017, verification_value: 111 )
+ @credit_card = credit_card('5123456789012346', brand: :master, month: 5, year: 2017, verification_value: 111)
@declined_card = credit_card('4000300011112220')
@options = {
diff --git a/test/remote/gateways/remote_pay_junction_test.rb b/test/remote/gateways/remote_pay_junction_test.rb
index bacaae52e44..1db822d8bb1 100644
--- a/test/remote/gateways/remote_pay_junction_test.rb
+++ b/test/remote/gateways/remote_pay_junction_test.rb
@@ -55,7 +55,7 @@ def test_successful_purchase_with_cvv
end
def test_successful_authorize
- assert response = @gateway.authorize( AMOUNT, @credit_card, @options)
+ assert response = @gateway.authorize(AMOUNT, @credit_card, @options)
assert_equal PayJunctionGateway::SUCCESS_MESSAGE, response.message
assert_equal 'hold', response.params['posture'], 'Should be a held charge'
@@ -102,7 +102,7 @@ def test_successful_instant_purchase
# transaction can be executed if you have the transaction ID of a
# previous successful transaction.
- purchase = @gateway.purchase( AMOUNT, @credit_card, @options)
+ purchase = @gateway.purchase(AMOUNT, @credit_card, @options)
assert_success purchase
assert response = @gateway.purchase(AMOUNT, purchase.authorization, :order_id => generate_unique_id)
diff --git a/test/remote/gateways/remote_payeezy_test.rb b/test/remote/gateways/remote_payeezy_test.rb
index 2580c070dbe..24871731678 100644
--- a/test/remote/gateways/remote_payeezy_test.rb
+++ b/test/remote/gateways/remote_payeezy_test.rb
@@ -70,7 +70,7 @@ def test_successful_purchase_with_soft_descriptors
def test_failed_purchase
@amount = 501300
- assert response = @gateway.purchase(@amount, @credit_card, @options )
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
assert_match(/Transaction not approved/, response.message)
assert_failure response
end
@@ -262,7 +262,7 @@ def test_response_contains_cvv_and_avs_results
def test_trans_error
# ask for error 42 (unable to send trans) as the cents bit...
@amount = 500042
- assert response = @gateway.purchase(@amount, @credit_card, @options )
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
assert_match(/Server Error/, response.message) # 42 is 'unable to send trans'
assert_failure response
assert_equal '500', response.error_code
diff --git a/test/remote/gateways/remote_payment_express_test.rb b/test/remote/gateways/remote_payment_express_test.rb
index eeb9d3b0b33..355f1830817 100644
--- a/test/remote/gateways/remote_payment_express_test.rb
+++ b/test/remote/gateways/remote_payment_express_test.rb
@@ -109,7 +109,7 @@ def test_store_and_charge
assert_equal 'The Transaction was approved', response.message
assert(token = response.authorization)
- assert purchase = @gateway.purchase( @amount, token)
+ assert purchase = @gateway.purchase(@amount, token)
assert_equal 'The Transaction was approved', purchase.message
assert_success purchase
assert_not_nil purchase.authorization
diff --git a/test/remote/gateways/remote_stripe_connect_test.rb b/test/remote/gateways/remote_stripe_connect_test.rb
index a8cd4664f36..8309d62f98d 100644
--- a/test/remote/gateways/remote_stripe_connect_test.rb
+++ b/test/remote/gateways/remote_stripe_connect_test.rb
@@ -18,7 +18,7 @@ def setup
end
def test_application_fee_for_stripe_connect
- assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:application_fee => 12 ))
+ assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:application_fee => 12))
assert_success response
end
diff --git a/test/remote/gateways/remote_visanet_peru_test.rb b/test/remote/gateways/remote_visanet_peru_test.rb
index 59425892e09..d596f4b451e 100644
--- a/test/remote/gateways/remote_visanet_peru_test.rb
+++ b/test/remote/gateways/remote_visanet_peru_test.rb
@@ -114,7 +114,7 @@ def test_successful_refund_unsettled
end
def test_failed_refund
- response = @gateway.refund(@amount, '900000044' )
+ response = @gateway.refund(@amount, '900000044')
assert_failure response
assert_match(/NUMORDEN 900000044 no se encuentra registrado/, response.message)
assert_equal 400, response.error_code
diff --git a/test/unit/gateways/blue_pay_test.rb b/test/unit/gateways/blue_pay_test.rb
index 5ae66d0fe58..b4b040f5c43 100644
--- a/test/unit/gateways/blue_pay_test.rb
+++ b/test/unit/gateways/blue_pay_test.rb
@@ -51,7 +51,7 @@ def test_failed_authorization
def test_add_address_outsite_north_america
result = {}
- @gateway.send(:add_address, result, :billing_address => {:address1 => '123 Test St.', :address2 => '5F', :city => 'Testville', :company => 'Test Company', :country => 'DE', :state => ''} )
+ @gateway.send(:add_address, result, :billing_address => {:address1 => '123 Test St.', :address2 => '5F', :city => 'Testville', :company => 'Test Company', :country => 'DE', :state => ''})
assert_equal ['ADDR1', 'ADDR2', 'CITY', 'COMPANY_NAME', 'COUNTRY', 'PHONE', 'STATE', 'ZIP'], result.stringify_keys.keys.sort
assert_equal 'n/a', result[:STATE]
assert_equal '123 Test St.', result[:ADDR1]
@@ -61,7 +61,7 @@ def test_add_address_outsite_north_america
def test_add_address
result = {}
- @gateway.send(:add_address, result, :billing_address => {:address1 => '123 Test St.', :address2 => '5F', :city => 'Testville', :company => 'Test Company', :country => 'US', :state => 'AK'} )
+ @gateway.send(:add_address, result, :billing_address => {:address1 => '123 Test St.', :address2 => '5F', :city => 'Testville', :company => 'Test Company', :country => 'US', :state => 'AK'})
assert_equal ['ADDR1', 'ADDR2', 'CITY', 'COMPANY_NAME', 'COUNTRY', 'PHONE', 'STATE', 'ZIP'], result.stringify_keys.keys.sort
assert_equal 'AK', result[:STATE]
@@ -73,7 +73,7 @@ def test_name_comes_from_payment_method
result = {}
@gateway.send(:add_creditcard, result, @credit_card)
- @gateway.send(:add_address, result, :billing_address => {:address1 => '123 Test St.', :address2 => '5F', :city => 'Testville', :company => 'Test Company', :country => 'US', :state => 'AK'} )
+ @gateway.send(:add_address, result, :billing_address => {:address1 => '123 Test St.', :address2 => '5F', :city => 'Testville', :company => 'Test Company', :country => 'US', :state => 'AK'})
assert_equal @credit_card.first_name, result[:NAME1]
assert_equal @credit_card.last_name, result[:NAME2]
diff --git a/test/unit/gateways/braintree_blue_test.rb b/test/unit/gateways/braintree_blue_test.rb
index 7c89a988d05..1a0b83e24cc 100644
--- a/test/unit/gateways/braintree_blue_test.rb
+++ b/test/unit/gateways/braintree_blue_test.rb
@@ -11,7 +11,7 @@ def setup
:test => true
)
- @internal_gateway = @gateway.instance_variable_get( :@braintree_gateway )
+ @internal_gateway = @gateway.instance_variable_get(:@braintree_gateway)
end
def teardown
diff --git a/test/unit/gateways/braintree_orange_test.rb b/test/unit/gateways/braintree_orange_test.rb
index 399580184fb..ee4149137bb 100644
--- a/test/unit/gateways/braintree_orange_test.rb
+++ b/test/unit/gateways/braintree_orange_test.rb
@@ -47,7 +47,7 @@ def test_successful_store
def test_add_processor
result = {}
- @gateway.send(:add_processor, result, {:processor => 'ccprocessorb'} )
+ @gateway.send(:add_processor, result, {:processor => 'ccprocessorb'})
assert_equal ['processor_id'], result.stringify_keys.keys.sort
assert_equal 'ccprocessorb', result[:processor_id]
end
@@ -86,7 +86,7 @@ def test_unsuccessful_verify
def test_add_address
result = {}
- @gateway.send(:add_address, result, {:address1 => '164 Waverley Street', :country => 'US', :state => 'CO'} )
+ @gateway.send(:add_address, result, {:address1 => '164 Waverley Street', :country => 'US', :state => 'CO'})
assert_equal ['address1', 'city', 'company', 'country', 'phone', 'state', 'zip'], result.stringify_keys.keys.sort
assert_equal 'CO', result['state']
assert_equal '164 Waverley Street', result['address1']
@@ -96,7 +96,7 @@ def test_add_address
def test_add_shipping_address
result = {}
- @gateway.send(:add_address, result, {:address1 => '164 Waverley Street', :country => 'US', :state => 'CO'}, 'shipping' )
+ @gateway.send(:add_address, result, {:address1 => '164 Waverley Street', :country => 'US', :state => 'CO'}, 'shipping')
assert_equal ['shipping_address1', 'shipping_city', 'shipping_company', 'shipping_country', 'shipping_phone', 'shipping_state', 'shipping_zip'], result.stringify_keys.keys.sort
assert_equal 'CO', result['shipping_state']
assert_equal '164 Waverley Street', result['shipping_address1']
@@ -114,7 +114,7 @@ def test_adding_store_adds_vault_id_flag
def test_blank_store_doesnt_add_vault_flag
result = {}
- @gateway.send(:add_creditcard, result, @credit_card, {} )
+ @gateway.send(:add_creditcard, result, @credit_card, {})
assert_equal ['ccexp', 'ccnumber', 'cvv', 'firstname', 'lastname'], result.stringify_keys.keys.sort
assert_nil result[:customer_vault]
end
diff --git a/test/unit/gateways/cashnet_test.rb b/test/unit/gateways/cashnet_test.rb
index af7ab9fa0bd..844702eac9a 100644
--- a/test/unit/gateways/cashnet_test.rb
+++ b/test/unit/gateways/cashnet_test.rb
@@ -76,7 +76,7 @@ def test_add_creditcard
def test_add_address
result = {}
- @gateway.send(:add_address, result, billing_address: {address1: '123 Test St.', address2: '5F', city: 'Testville', zip: '12345', state: 'AK'} )
+ @gateway.send(:add_address, result, billing_address: {address1: '123 Test St.', address2: '5F', city: 'Testville', zip: '12345', state: 'AK'})
assert_equal ['addr_g', 'city_g', 'state_g', 'zip_g'], result.stringify_keys.keys.sort
assert_equal '123 Test St.,5F', result[:addr_g]
diff --git a/test/unit/gateways/clearhaus_test.rb b/test/unit/gateways/clearhaus_test.rb
index 0794d356bdc..d0b383e962f 100644
--- a/test/unit/gateways/clearhaus_test.rb
+++ b/test/unit/gateways/clearhaus_test.rb
@@ -153,7 +153,7 @@ def test_successful_void
def test_failed_void
@gateway.expects(:ssl_post).returns(failed_void_response)
- response = @gateway.void( @credit_card, @options)
+ response = @gateway.void(@credit_card, @options)
assert_failure response
assert_equal 40000, response.error_code
diff --git a/test/unit/gateways/evo_ca_test.rb b/test/unit/gateways/evo_ca_test.rb
index e699e1462a1..f2fe062e658 100644
--- a/test/unit/gateways/evo_ca_test.rb
+++ b/test/unit/gateways/evo_ca_test.rb
@@ -99,7 +99,7 @@ def test_successful_refund
def test_add_address
result = {}
- @gateway.send(:add_address, result, :address => {:address1 => '123 Main Street', :country => 'CA', :state => 'BC'} )
+ @gateway.send(:add_address, result, :address => {:address1 => '123 Main Street', :country => 'CA', :state => 'BC'})
assert_equal %w{address1 address2 city company country firstname lastname phone state zip}, result.stringify_keys.keys.sort
assert_equal 'BC', result[:state]
assert_equal '123 Main Street', result[:address1]
@@ -109,7 +109,7 @@ def test_add_address
def test_add_shipping_address
result = {}
- @gateway.send(:add_address, result, :shipping_address => {:address1 => '123 Main Street', :country => 'CA', :state => 'BC'} )
+ @gateway.send(:add_address, result, :shipping_address => {:address1 => '123 Main Street', :country => 'CA', :state => 'BC'})
assert_equal %w{shipping_address1 shipping_address2 shipping_city shipping_company shipping_country shipping_firstname shipping_lastname shipping_state shipping_zip}, result.stringify_keys.keys.sort
assert_equal 'BC', result[:shipping_state]
assert_equal '123 Main Street', result[:shipping_address1]
diff --git a/test/unit/gateways/exact_test.rb b/test/unit/gateways/exact_test.rb
index b48a4170d74..33345b22541 100644
--- a/test/unit/gateways/exact_test.rb
+++ b/test/unit/gateways/exact_test.rb
@@ -2,8 +2,8 @@
class ExactTest < Test::Unit::TestCase
def setup
- @gateway = ExactGateway.new( :login => 'A00427-01',
- :password => 'testus' )
+ @gateway = ExactGateway.new(:login => 'A00427-01',
+ :password => 'testus')
@credit_card = credit_card
@amount = 100
@@ -49,9 +49,9 @@ def test_failed_purchase
end
def test_expdate
- assert_equal( '%02d%s' % [ @credit_card.month,
- @credit_card.year.to_s[-2..-1] ],
- @gateway.send(:expdate, @credit_card) )
+ assert_equal('%02d%s' % [ @credit_card.month,
+ @credit_card.year.to_s[-2..-1] ],
+ @gateway.send(:expdate, @credit_card))
end
def test_soap_fault
diff --git a/test/unit/gateways/federated_canada_test.rb b/test/unit/gateways/federated_canada_test.rb
index cad64a37f16..d3ca5956ae8 100644
--- a/test/unit/gateways/federated_canada_test.rb
+++ b/test/unit/gateways/federated_canada_test.rb
@@ -47,7 +47,7 @@ def test_unsuccessful_request
def test_add_address
result = {}
- @gateway.send(:add_address, result, :billing_address => {:address1 => '123 Happy Town Road', :address2 => 'apt 13', :country => 'CA', :state => 'SK', :phone => '1234567890'} )
+ @gateway.send(:add_address, result, :billing_address => {:address1 => '123 Happy Town Road', :address2 => 'apt 13', :country => 'CA', :state => 'SK', :phone => '1234567890'})
assert_equal ['address1', 'address2', 'city', 'company', 'country', 'phone', 'state', 'zip'], result.stringify_keys.keys.sort
assert_equal 'SK', result[:state]
assert_equal '123 Happy Town Road', result[:address1]
diff --git a/test/unit/gateways/inspire_test.rb b/test/unit/gateways/inspire_test.rb
index 6aac648f1da..b92b13ef34c 100644
--- a/test/unit/gateways/inspire_test.rb
+++ b/test/unit/gateways/inspire_test.rb
@@ -60,7 +60,7 @@ def test_failed_refund
def test_add_address
result = {}
- @gateway.send(:add_address, result, nil, :billing_address => {:address1 => '164 Waverley Street', :country => 'US', :state => 'CO'} )
+ @gateway.send(:add_address, result, nil, :billing_address => {:address1 => '164 Waverley Street', :country => 'US', :state => 'CO'})
assert_equal ['address1', 'city', 'company', 'country', 'phone', 'state', 'zip'], result.stringify_keys.keys.sort
assert_equal 'CO', result[:state]
assert_equal '164 Waverley Street', result[:address1]
@@ -86,7 +86,7 @@ def test_adding_store_adds_vault_id_flag
def test_blank_store_doesnt_add_vault_flag
result = {}
- @gateway.send(:add_creditcard, result, @credit_card, {} )
+ @gateway.send(:add_creditcard, result, @credit_card, {})
assert_equal ['ccexp', 'ccnumber', 'cvv', 'firstname', 'lastname'], result.stringify_keys.keys.sort
assert_nil result[:customer_vault]
end
diff --git a/test/unit/gateways/metrics_global_test.rb b/test/unit/gateways/metrics_global_test.rb
index 5082a40facc..5cf3c841bff 100644
--- a/test/unit/gateways/metrics_global_test.rb
+++ b/test/unit/gateways/metrics_global_test.rb
@@ -44,7 +44,7 @@ def test_failed_authorization
def test_add_address_outsite_north_america
result = {}
- @gateway.send(:add_address, result, :billing_address => {:address1 => '164 Waverley Street', :country => 'DE', :state => ''} )
+ @gateway.send(:add_address, result, :billing_address => {:address1 => '164 Waverley Street', :country => 'DE', :state => ''})
assert_equal ['address', 'city', 'company', 'country', 'phone', 'state', 'zip'], result.stringify_keys.keys.sort
assert_equal 'n/a', result[:state]
@@ -55,7 +55,7 @@ def test_add_address_outsite_north_america
def test_add_address
result = {}
- @gateway.send(:add_address, result, :billing_address => {:address1 => '164 Waverley Street', :country => 'US', :state => 'CO'} )
+ @gateway.send(:add_address, result, :billing_address => {:address1 => '164 Waverley Street', :country => 'US', :state => 'CO'})
assert_equal ['address', 'city', 'company', 'country', 'phone', 'state', 'zip'], result.stringify_keys.keys.sort
assert_equal 'CO', result[:state]
diff --git a/test/unit/gateways/money_movers_test.rb b/test/unit/gateways/money_movers_test.rb
index de2c1820701..c5c3b275baf 100644
--- a/test/unit/gateways/money_movers_test.rb
+++ b/test/unit/gateways/money_movers_test.rb
@@ -44,7 +44,7 @@ def test_unsuccessful_request
def test_add_address
result = {}
- @gateway.send(:add_address, result, :billing_address => {:address1 => '1 Main St.', :address2 => 'apt 13', :country => 'US', :state => 'MI', :phone => '1234567890'} )
+ @gateway.send(:add_address, result, :billing_address => {:address1 => '1 Main St.', :address2 => 'apt 13', :country => 'US', :state => 'MI', :phone => '1234567890'})
assert_equal ['address1', 'address2', 'city', 'company', 'country', 'phone', 'state', 'zip'], result.stringify_keys.keys.sort
assert_equal 'MI', result[:state]
assert_equal '1 Main St.', result[:address1]
diff --git a/test/unit/gateways/pac_net_raven_test.rb b/test/unit/gateways/pac_net_raven_test.rb
index 29d99cb9e84..f2e66cce048 100644
--- a/test/unit/gateways/pac_net_raven_test.rb
+++ b/test/unit/gateways/pac_net_raven_test.rb
@@ -179,7 +179,7 @@ def test_argument_error_secret
def test_add_address
result = {}
- @gateway.send(:add_address, result, :billing_address => {:address1 => 'Address 1', :address2 => 'Address 2', :zip => 'ZIP'} )
+ @gateway.send(:add_address, result, :billing_address => {:address1 => 'Address 1', :address2 => 'Address 2', :zip => 'ZIP'})
assert_equal ['BillingPostalCode', 'BillingStreetAddressLineFour', 'BillingStreetAddressLineOne'], result.stringify_keys.keys.sort
assert_equal 'ZIP', result['BillingPostalCode']
assert_equal 'Address 2', result['BillingStreetAddressLineFour']
diff --git a/test/unit/gateways/payflow_test.rb b/test/unit/gateways/payflow_test.rb
index ef6e449fbce..2ddee59bb92 100644
--- a/test/unit/gateways/payflow_test.rb
+++ b/test/unit/gateways/payflow_test.rb
@@ -14,7 +14,7 @@ def setup
@amount = 100
@credit_card = credit_card('4242424242424242')
@options = { :billing_address => address.merge(:first_name => 'Longbob', :last_name => 'Longsen') }
- @check = check( :name => 'Jim Smith' )
+ @check = check(:name => 'Jim Smith')
end
def test_successful_authorization
@@ -360,7 +360,7 @@ def test_recurring_profile_payment_history_inquiry
end
def test_recurring_profile_payment_history_inquiry_contains_the_proper_xml
- request = @gateway.send( :build_recurring_request, :inquiry, nil, :profile_id => 'RT0000000009', :history => true)
+ request = @gateway.send(:build_recurring_request, :inquiry, nil, :profile_id => 'RT0000000009', :history => true)
assert_match %r(Y 'Test Title',
:return_url => 'http://return.url',
:cancel_return_url => 'http://cancel.url',
- :items => [ Hash.new ] )
+ :items => [ Hash.new ])
end
assert_raise ArgumentError do
@@ -70,7 +70,7 @@ def test_setup_request_invalid_requests
:quantity => '1',
:amount => 100,
:description => 'Description',
- :category => 'Physical' } ] )
+ :category => 'Physical' } ])
end
end
@@ -87,7 +87,7 @@ def test_build_setup_request_valid
:quantity => '1',
:amount => 100,
:description => 'Description',
- :category => 'Digital' } ] )
+ :category => 'Digital' } ])
end
private
diff --git a/test/unit/gateways/plugnpay_test.rb b/test/unit/gateways/plugnpay_test.rb
index c815b9fe251..4760eada3f6 100644
--- a/test/unit/gateways/plugnpay_test.rb
+++ b/test/unit/gateways/plugnpay_test.rb
@@ -70,7 +70,7 @@ def test_refund
def test_add_address_outsite_north_america
result = PlugnpayGateway::PlugnpayPostData.new
- @gateway.send(:add_addresses, result, :billing_address => {:address1 => '164 Waverley Street', :country => 'DE', :state => 'Dortmund'} )
+ @gateway.send(:add_addresses, result, :billing_address => {:address1 => '164 Waverley Street', :country => 'DE', :state => 'Dortmund'})
assert_equal result[:state], 'ZZ'
assert_equal result[:province], 'Dortmund'
@@ -85,7 +85,7 @@ def test_add_address_outsite_north_america
def test_add_address
result = PlugnpayGateway::PlugnpayPostData.new
- @gateway.send(:add_addresses, result, :billing_address => {:address1 => '164 Waverley Street', :country => 'US', :state => 'CO'} )
+ @gateway.send(:add_addresses, result, :billing_address => {:address1 => '164 Waverley Street', :country => 'US', :state => 'CO'})
assert_equal result[:card_state], 'CO'
assert_equal result[:card_address1], '164 Waverley Street'
From cbbd15e7a990002629acde0ba30ef9cdcb14c279 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Tue, 20 Nov 2018 08:41:09 -0500
Subject: [PATCH 0189/2234] Clearhaus: update submission data format
Unit: 22 tests, 110 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote: 23 tests, 70 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/clearhaus.rb | 12 ++++++------
test/unit/gateways/clearhaus_test.rb | 10 +++++-----
3 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 667d5008138..6888977fb1e 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
= ActiveMerchant CHANGELOG
== HEAD
+* Clearhaus: update submission data format [bpollack] #3053
* Make behavior of nil CC numbers more consistent [guaguasi] #3010
* Moneris: Adds Credential on File logic [deedeelavinder] #3042
* Adyen: Return AVS and CVC Result [nfarve] #3044
diff --git a/lib/active_merchant/billing/gateways/clearhaus.rb b/lib/active_merchant/billing/gateways/clearhaus.rb
index 2d2d73aa4f2..b53d792a4f4 100644
--- a/lib/active_merchant/billing/gateways/clearhaus.rb
+++ b/lib/active_merchant/billing/gateways/clearhaus.rb
@@ -63,7 +63,7 @@ def authorize(amount, payment, options={})
end
post[:recurring] = options[:recurring] if options[:recurring]
- post[:threed_secure] = {pares: options[:pares]} if options[:pares]
+ post[:card][:pares] = options[:pares] if options[:pares]
commit(action, post)
end
@@ -108,7 +108,7 @@ def scrub(transcript)
transcript.
gsub(%r((Authorization: Basic )[\w=]+), '\1[FILTERED]').
gsub(%r((&?card(?:\[|%5B)csc(?:\]|%5D)=)[^&]*)i, '\1[FILTERED]').
- gsub(%r((&?card(?:\[|%5B)number(?:\]|%5D)=)[^&]*)i, '\1[FILTERED]')
+ gsub(%r((&?card(?:\[|%5B)pan(?:\]|%5D)=)[^&]*)i, '\1[FILTERED]')
end
private
@@ -126,12 +126,12 @@ def add_amount(post, amount, options)
def add_payment(post, payment)
card = {}
- card[:number] = payment.number
+ card[:pan] = payment.number
card[:expire_month] = '%02d'% payment.month
card[:expire_year] = payment.year
if payment.verification_value?
- card[:csc] = payment.verification_value
+ card[:csc] = payment.verification_value
end
post[:card] = card if card.any?
@@ -139,8 +139,8 @@ def add_payment(post, payment)
def headers(api_key)
{
- 'Authorization' => 'Basic ' + Base64.strict_encode64("#{api_key}:"),
- 'User-Agent' => "Clearhaus ActiveMerchantBindings/#{ActiveMerchant::VERSION}"
+ 'Authorization' => 'Basic ' + Base64.strict_encode64("#{api_key}:"),
+ 'User-Agent' => "Clearhaus ActiveMerchantBindings/#{ActiveMerchant::VERSION}"
}
end
diff --git a/test/unit/gateways/clearhaus_test.rb b/test/unit/gateways/clearhaus_test.rb
index d0b383e962f..b877de05e4f 100644
--- a/test/unit/gateways/clearhaus_test.rb
+++ b/test/unit/gateways/clearhaus_test.rb
@@ -56,7 +56,7 @@ def test_successful_authorize_with_threed
assert_success response
assert response.test?
end.check_request do |endpoint, data, headers|
- expr = { threed_secure: { pares: '123' } }.to_query
+ expr = { card: { pares: '123' } }.to_query
assert_match expr, data
end.respond_with(successful_authorize_response)
end
@@ -225,7 +225,7 @@ def test_signing_request
end.check_request do |method, endpoint, data, headers|
assert headers['Signature']
assert_match %r{7e51b92e-ca7e-48e3-8a96-7d66cf1f2da2 RS256-hex}, headers['Signature']
- assert_match %r{02f56ed1f6c60cdefd$}, headers['Signature']
+ assert_match %r{25f8283c3cc43911d7$}, headers['Signature']
end.respond_with(successful_authorize_response)
end
@@ -244,7 +244,7 @@ def test_cleans_whitespace_from_private_key
end.check_request do |method, endpoint, data, headers|
assert headers['Signature']
assert_match %r{7e51b92e-ca7e-48e3-8a96-7d66cf1f2da2 RS256-hex}, headers['Signature']
- assert_match %r{02f56ed1f6c60cdefd$}, headers['Signature']
+ assert_match %r{25f8283c3cc43911d7$}, headers['Signature']
end.respond_with(successful_authorize_response)
end
@@ -275,7 +275,7 @@ def pre_scrubbed
starting SSL for gateway.test.clearhaus.com:443...
SSL established
<- "POST /authorizations HTTP/1.1\r\nContent-Type: application/x-www-form-urlencoded\r\nAuthorization: Basic NTI2Y2Y1NjQtMTE5Yy00YmI2LTljZjgtMDAxNWVhYzdlNGY2Og==\r\nUser-Agent: Clearhaus ActiveMerchantBindings/1.54.0\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nConnection: close\r\nHost: gateway.test.clearhaus.com\r\nContent-Length: 128\r\n\r\n"
-<- "amount=100&card%5Bcsc%5D=123&card%5Bexpire_month%5D=09&card%5Bexpire_year%5D=2016&card%5Bnumber%5D=4111111111111111¤cy=EUR"
+<- "amount=100&card%5Bcsc%5D=123&card%5Bexpire_month%5D=09&card%5Bexpire_year%5D=2016&card%5Bpan%5D=4111111111111111¤cy=EUR"
-> "HTTP/1.1 201 Created\r\n"
-> "Content-Type: application/vnd.clearhaus-gateway.hal+json; version=0.9.0; charset=utf-8\r\n"
-> "Date: Wed, 28 Oct 2015 18:56:11 GMT\r\n"
@@ -318,7 +318,7 @@ def post_scrubbed
starting SSL for gateway.test.clearhaus.com:443...
SSL established
<- "POST /authorizations HTTP/1.1\r\nContent-Type: application/x-www-form-urlencoded\r\nAuthorization: Basic [FILTERED]\r\nUser-Agent: Clearhaus ActiveMerchantBindings/1.54.0\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nConnection: close\r\nHost: gateway.test.clearhaus.com\r\nContent-Length: 128\r\n\r\n"
-<- "amount=100&card%5Bcsc%5D=[FILTERED]&card%5Bexpire_month%5D=09&card%5Bexpire_year%5D=2016&card%5Bnumber%5D=[FILTERED]¤cy=EUR"
+<- "amount=100&card%5Bcsc%5D=[FILTERED]&card%5Bexpire_month%5D=09&card%5Bexpire_year%5D=2016&card%5Bpan%5D=[FILTERED]¤cy=EUR"
-> "HTTP/1.1 201 Created\r\n"
-> "Content-Type: application/vnd.clearhaus-gateway.hal+json; version=0.9.0; charset=utf-8\r\n"
-> "Date: Wed, 28 Oct 2015 18:56:11 GMT\r\n"
From 60efe5c5bd27cafa22edb6cdef2273ca7a8da72f Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 8 Nov 2018 15:08:40 -0500
Subject: [PATCH 0190/2234] RuboCop: fix block spacing
This is actually two fixes, Layout/SpaceInsideBlockBraces and
Layout/SpaceBeforeBlockBraces, because the diff actually looks worse
if you do either of them alone (and the same lines largely get touched
on the follow-up diff anyway).
---
.rubocop_todo.yml | 16 --------
lib/active_merchant/billing/check.rb | 2 +-
lib/active_merchant/billing/compatibility.rb | 6 +--
lib/active_merchant/billing/gateways/adyen.rb | 6 +--
.../billing/gateways/allied_wallet.rb | 2 +-
.../billing/gateways/authorize_net.rb | 4 +-
.../billing/gateways/authorize_net_arb.rb | 2 +-
.../billing/gateways/authorize_net_cim.rb | 4 +-
.../billing/gateways/axcessms.rb | 4 +-
.../billing/gateways/balanced.rb | 10 ++---
.../gateways/beanstream/beanstream_core.rb | 2 +-
.../billing/gateways/blue_pay.rb | 2 +-
.../billing/gateways/blue_snap.rb | 2 +-
.../billing/gateways/borgun.rb | 2 +-
.../billing/gateways/braintree_blue.rb | 2 +-
.../billing/gateways/bridge_pay.rb | 2 +-
lib/active_merchant/billing/gateways/cams.rb | 2 +-
.../billing/gateways/cardknox.rb | 4 +-
.../billing/gateways/cardprocess.rb | 2 +-
.../billing/gateways/cashnet.rb | 2 +-
lib/active_merchant/billing/gateways/cc5.rb | 2 +-
.../billing/gateways/creditcall.rb | 4 +-
.../billing/gateways/credorax.rb | 6 +--
.../billing/gateways/ct_payment.rb | 2 +-
lib/active_merchant/billing/gateways/culqi.rb | 2 +-
.../billing/gateways/cyber_source.rb | 2 +-
.../billing/gateways/data_cash.rb | 2 +-
lib/active_merchant/billing/gateways/dibs.rb | 2 +-
.../billing/gateways/digitzs.rb | 4 +-
.../billing/gateways/elavon.rb | 2 +-
.../billing/gateways/eway_rapid.rb | 2 +-
lib/active_merchant/billing/gateways/exact.rb | 2 +-
.../billing/gateways/federated_canada.rb | 2 +-
.../billing/gateways/first_giving.rb | 2 +-
.../billing/gateways/firstdata_e4.rb | 2 +-
.../billing/gateways/flo2cash.rb | 4 +-
.../billing/gateways/garanti.rb | 2 +-
.../billing/gateways/global_collect.rb | 2 +-
lib/active_merchant/billing/gateways/hdfc.rb | 2 +-
.../billing/gateways/inspire.rb | 2 +-
.../billing/gateways/iridium.rb | 20 +++++-----
lib/active_merchant/billing/gateways/iveri.rb | 2 +-
.../billing/gateways/jetpay.rb | 2 +-
.../billing/gateways/jetpay_v2.rb | 2 +-
.../billing/gateways/maxipago.rb | 2 +-
.../billing/gateways/merchant_e_solutions.rb | 2 +-
.../billing/gateways/merchant_one.rb | 2 +-
.../billing/gateways/merchant_partners.rb | 2 +-
.../billing/gateways/merchant_warrior.rb | 4 +-
.../billing/gateways/micropayment.rb | 2 +-
lib/active_merchant/billing/gateways/migs.rb | 2 +-
.../billing/gateways/modern_payments_cim.rb | 4 +-
.../billing/gateways/moneris.rb | 4 +-
.../billing/gateways/moneris_us.rb | 4 +-
.../billing/gateways/money_movers.rb | 2 +-
.../billing/gateways/nab_transact.rb | 2 +-
.../billing/gateways/net_registry.rb | 2 +-
.../billing/gateways/netaxept.rb | 12 +++---
.../billing/gateways/netbilling.rb | 2 +-
.../billing/gateways/netpay.rb | 2 +-
lib/active_merchant/billing/gateways/nmi.rb | 2 +-
lib/active_merchant/billing/gateways/ogone.rb | 6 +--
lib/active_merchant/billing/gateways/opp.rb | 2 +-
.../billing/gateways/orbital.rb | 4 +-
.../billing/gateways/pac_net_raven.rb | 2 +-
.../billing/gateways/pay_conex.rb | 2 +-
.../billing/gateways/pay_gate_xml.rb | 4 +-
.../billing/gateways/pay_junction.rb | 2 +-
.../billing/gateways/pay_junction_v2.rb | 4 +-
.../billing/gateways/pay_secure.rb | 2 +-
.../billing/gateways/paybox_direct.rb | 2 +-
lib/active_merchant/billing/gateways/payex.rb | 14 +++----
.../gateways/payflow/payflow_common_api.rb | 4 +-
.../billing/gateways/payscout.rb | 2 +-
.../billing/gateways/payu_in.rb | 6 +--
.../billing/gateways/psl_card.rb | 2 +-
.../billing/gateways/quantum.rb | 2 +-
.../billing/gateways/quickbooks.rb | 10 ++---
.../billing/gateways/quickpay/quickpay_v10.rb | 2 +-
.../billing/gateways/qvalent.rb | 4 +-
.../billing/gateways/realex.rb | 2 +-
.../billing/gateways/secure_net.rb | 2 +-
.../billing/gateways/secure_pay_au.rb | 2 +-
.../billing/gateways/skip_jack.rb | 2 +-
.../billing/gateways/smart_ps.rb | 2 +-
.../trans_first_transaction_express.rb | 2 +-
.../billing/gateways/transact_pro.rb | 4 +-
.../billing/gateways/usa_epay_transaction.rb | 2 +-
lib/active_merchant/billing/gateways/vanco.rb | 4 +-
.../billing/gateways/viaklix.rb | 2 +-
.../billing/gateways/visanet_peru.rb | 2 +-
.../billing/gateways/worldpay.rb | 20 +++++-----
lib/active_merchant/billing/response.rb | 2 +-
lib/active_merchant/country.rb | 8 ++--
lib/support/gateway_support.rb | 4 +-
.../gateways/remote_braintree_blue_test.rb | 2 +-
test/remote/gateways/remote_moneris_test.rb | 2 +-
test/remote/gateways/remote_paypal_test.rb | 2 +-
.../gateways/remote_securion_pay_test.rb | 6 +--
test/test_helper.rb | 2 +-
test/unit/country_code_test.rb | 2 +-
test/unit/credit_card_test.rb | 2 +-
test/unit/gateways/balanced_test.rb | 2 +-
test/unit/gateways/cyber_source_test.rb | 2 +-
test/unit/gateways/data_cash_test.rb | 4 +-
test/unit/gateways/exact_test.rb | 2 +-
test/unit/gateways/firstdata_e4_test.rb | 4 +-
test/unit/gateways/firstdata_e4_v27_test.rb | 2 +-
test/unit/gateways/migs_test.rb | 6 +--
test/unit/gateways/optimal_payment_test.rb | 4 +-
test/unit/gateways/pac_net_raven_test.rb | 6 +--
test/unit/gateways/realex_test.rb | 2 +-
test/unit/gateways/securion_pay_test.rb | 4 +-
test/unit/gateways/stripe_test.rb | 10 ++---
test/unit/gateways/webpay_test.rb | 2 +-
test/unit/gateways/worldpay_test.rb | 2 +-
test/unit/multi_response_test.rb | 38 +++++++++----------
117 files changed, 217 insertions(+), 233 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index a93108be0b4..10ed49082bc 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -134,14 +134,6 @@ Layout/SpaceAroundKeyword:
Layout/SpaceAroundOperators:
Enabled: false
-# Offense count: 182
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
-# SupportedStyles: space, no_space
-# SupportedStylesForEmptyBraces: space, no_space
-Layout/SpaceBeforeBlockBraces:
- Enabled: false
-
# Offense count: 118
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets.
@@ -156,14 +148,6 @@ Layout/SpaceInsideArrayPercentLiteral:
Exclude:
- 'lib/active_merchant/billing/gateways/migs/migs_codes.rb'
-# Offense count: 345
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
-# SupportedStyles: space, no_space
-# SupportedStylesForEmptyBraces: space, no_space
-Layout/SpaceInsideBlockBraces:
- Enabled: false
-
# Offense count: 1186
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
diff --git a/lib/active_merchant/billing/check.rb b/lib/active_merchant/billing/check.rb
index 0653848f3f5..6dcba4b0267 100644
--- a/lib/active_merchant/billing/check.rb
+++ b/lib/active_merchant/billing/check.rb
@@ -59,7 +59,7 @@ def credit_card?
# (3(d1 + d4 + d7) + 7(d2 + d5 + d8) + 1(d3 + d6 + d9))mod 10 = 0
# See http://en.wikipedia.org/wiki/Routing_transit_number#Internal_checksums
def valid_routing_number?
- digits = routing_number.to_s.split('').map(&:to_i).select{|d| (0..9).cover?(d)}
+ digits = routing_number.to_s.split('').map(&:to_i).select { |d| (0..9).cover?(d) }
case digits.size
when 9
checksum = ((3 * (digits[0] + digits[3] + digits[6])) +
diff --git a/lib/active_merchant/billing/compatibility.rb b/lib/active_merchant/billing/compatibility.rb
index df999f60ed3..11103dcee68 100644
--- a/lib/active_merchant/billing/compatibility.rb
+++ b/lib/active_merchant/billing/compatibility.rb
@@ -61,7 +61,7 @@ def internal_errors
class Errors < Hash
def initialize
- super(){|h, k| h[k] = []}
+ super() { |h, k| h[k] = [] }
end
alias count size
@@ -75,7 +75,7 @@ def []=(key, value)
end
def empty?
- all?{|k, v| v&.empty?}
+ all? { |k, v| v&.empty? }
end
def on(field)
@@ -91,7 +91,7 @@ def add_to_base(error)
end
def each_full
- full_messages.each{|msg| yield msg}
+ full_messages.each { |msg| yield msg }
end
def full_messages
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index de0f15f32ee..2e7b5ba1eb9 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -34,8 +34,8 @@ def initialize(options={})
def purchase(money, payment, options={})
MultiResponse.run do |r|
- r.process{authorize(money, payment, options)}
- r.process{capture(money, r.authorization, options)}
+ r.process { authorize(money, payment, options) }
+ r.process { capture(money, r.authorization, options) }
end
end
@@ -216,7 +216,7 @@ def add_card(post, credit_card)
cvc: credit_card.verification_value
}
- card.delete_if{|k, v| v.blank? }
+ card.delete_if { |k, v| v.blank? }
card[:holderName] ||= 'Not Provided' if credit_card.is_a?(NetworkTokenizationCreditCard)
requires!(card, :expiryMonth, :expiryYear, :holderName, :number)
post[:card] = card
diff --git a/lib/active_merchant/billing/gateways/allied_wallet.rb b/lib/active_merchant/billing/gateways/allied_wallet.rb
index 55181e90d30..8cdbd6f4eaa 100644
--- a/lib/active_merchant/billing/gateways/allied_wallet.rb
+++ b/lib/active_merchant/billing/gateways/allied_wallet.rb
@@ -182,7 +182,7 @@ def parse(body)
def parse_element(response, node)
if node.has_elements?
- node.elements.each{|element| parse_element(response, element) }
+ node.elements.each { |element| parse_element(response, element) }
else
response[node.name.underscore.to_sym] = node.text
end
diff --git a/lib/active_merchant/billing/gateways/authorize_net.rb b/lib/active_merchant/billing/gateways/authorize_net.rb
index db5d98b69aa..738bc90a586 100644
--- a/lib/active_merchant/billing/gateways/authorize_net.rb
+++ b/lib/active_merchant/billing/gateways/authorize_net.rb
@@ -199,7 +199,7 @@ def unstore(authorization)
end
def verify_credentials
- response = commit(:verify_credentials) { }
+ response = commit(:verify_credentials) {}
response.success?
end
@@ -394,7 +394,7 @@ def add_payment_source(xml, source, options, action = nil)
end
def camel_case_lower(key)
- String(key).split('_').inject([]){ |buffer, e| buffer.push(buffer.empty? ? e : e.capitalize) }.join
+ String(key).split('_').inject([]) { |buffer, e| buffer.push(buffer.empty? ? e : e.capitalize) }.join
end
def add_settings(xml, source, options)
diff --git a/lib/active_merchant/billing/gateways/authorize_net_arb.rb b/lib/active_merchant/billing/gateways/authorize_net_arb.rb
index 8781f60ea66..406cc55e50e 100644
--- a/lib/active_merchant/billing/gateways/authorize_net_arb.rb
+++ b/lib/active_merchant/billing/gateways/authorize_net_arb.rb
@@ -407,7 +407,7 @@ def recurring_parse(action, xml)
def recurring_parse_element(response, node)
if node.has_elements?
- node.elements.each{|e| recurring_parse_element(response, e) }
+ node.elements.each { |e| recurring_parse_element(response, e) }
else
response[node.name.underscore.to_sym] = node.text
end
diff --git a/lib/active_merchant/billing/gateways/authorize_net_cim.rb b/lib/active_merchant/billing/gateways/authorize_net_cim.rb
index 3a5cce3d5e5..0ca1ec4d7a0 100644
--- a/lib/active_merchant/billing/gateways/authorize_net_cim.rb
+++ b/lib/active_merchant/billing/gateways/authorize_net_cim.rb
@@ -878,7 +878,7 @@ def tag_unless_blank(xml, tag_name, data)
end
def format_extra_options(options)
- options&.map{ |k, v| "#{k}=#{v}" }&.join('&')
+ options&.map { |k, v| "#{k}=#{v}" }&.join('&')
end
def parse_direct_response(params)
@@ -952,7 +952,7 @@ def parse(action, xml)
def parse_element(node)
if node.has_elements?
response = {}
- node.elements.each{ |e|
+ node.elements.each { |e|
key = e.name.underscore
value = parse_element(e)
if response.has_key?(key)
diff --git a/lib/active_merchant/billing/gateways/axcessms.rb b/lib/active_merchant/billing/gateways/axcessms.rb
index 59c8edaa4ea..7f9207ff6a2 100644
--- a/lib/active_merchant/billing/gateways/axcessms.rb
+++ b/lib/active_merchant/billing/gateways/axcessms.rb
@@ -94,11 +94,11 @@ def parse(body)
def parse_element(response, node)
if node.has_attributes?
- node.attributes.each{|name, value| response["#{node.name}_#{name}".underscore.to_sym] = value }
+ node.attributes.each { |name, value| response["#{node.name}_#{name}".underscore.to_sym] = value }
end
if node.has_elements?
- node.elements.each{|element| parse_element(response, element) }
+ node.elements.each { |element| parse_element(response, element) }
else
response[node.name.underscore.to_sym] = node.text
end
diff --git a/lib/active_merchant/billing/gateways/balanced.rb b/lib/active_merchant/billing/gateways/balanced.rb
index 671cc596bf3..f9b7accff02 100644
--- a/lib/active_merchant/billing/gateways/balanced.rb
+++ b/lib/active_merchant/billing/gateways/balanced.rb
@@ -45,12 +45,12 @@ def purchase(money, payment_method, options = {})
MultiResponse.run do |r|
identifier = if(payment_method.respond_to?(:number))
- r.process{store(payment_method, options)}
+ r.process { store(payment_method, options) }
r.authorization
else
payment_method
end
- r.process{commit('debits', "cards/#{card_identifier_from(identifier)}/debits", post)}
+ r.process { commit('debits', "cards/#{card_identifier_from(identifier)}/debits", post) }
end
end
@@ -62,12 +62,12 @@ def authorize(money, payment_method, options = {})
MultiResponse.run do |r|
identifier = if(payment_method.respond_to?(:number))
- r.process{store(payment_method, options)}
+ r.process { store(payment_method, options) }
r.authorization
else
payment_method
end
- r.process{commit('card_holds', "cards/#{card_identifier_from(identifier)}/card_holds", post)}
+ r.process { commit('card_holds', "cards/#{card_identifier_from(identifier)}/card_holds", post) }
end
end
@@ -118,7 +118,7 @@ def reference_identifier_from(identifier)
when %r{\|}
uri = identifier.
split('|').
- detect{|part| part.size > 0}
+ detect { |part| part.size > 0 }
uri.split('/')[2]
when %r{\/}
identifier.split('/')[5]
diff --git a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb
index e3ff636c26f..5d0640262fe 100644
--- a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb
+++ b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb
@@ -463,7 +463,7 @@ def post_data(params, use_profile_api)
params[:vbvEnabled] = '0'
params[:scEnabled] = '0'
- params.reject{|k, v| v.blank?}.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
+ params.reject { |k, v| v.blank? }.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
end
end
end
diff --git a/lib/active_merchant/billing/gateways/blue_pay.rb b/lib/active_merchant/billing/gateways/blue_pay.rb
index b3f789b7de3..b80ffcc2575 100644
--- a/lib/active_merchant/billing/gateways/blue_pay.rb
+++ b/lib/active_merchant/billing/gateways/blue_pay.rb
@@ -345,7 +345,7 @@ def parse_recurring(response_fields, opts={}) # expected status?
def parse(body)
# The bp20api has max one value per form field.
- response_fields = Hash[CGI::parse(body).map{|k, v| [k.upcase, v.first]}]
+ response_fields = Hash[CGI::parse(body).map { |k, v| [k.upcase, v.first] }]
if response_fields.include? 'REBILL_ID'
return parse_recurring(response_fields)
diff --git a/lib/active_merchant/billing/gateways/blue_snap.rb b/lib/active_merchant/billing/gateways/blue_snap.rb
index aaeaee85478..8c55f6910b7 100644
--- a/lib/active_merchant/billing/gateways/blue_snap.rb
+++ b/lib/active_merchant/billing/gateways/blue_snap.rb
@@ -230,7 +230,7 @@ def parse(response)
def parse_element(parsed, node)
if !node.elements.empty?
- node.elements.each {|e| parse_element(parsed, e) }
+ node.elements.each { |e| parse_element(parsed, e) }
else
parsed[node.name.downcase] = node.text
end
diff --git a/lib/active_merchant/billing/gateways/borgun.rb b/lib/active_merchant/billing/gateways/borgun.rb
index df56f97646d..b949144fcfb 100644
--- a/lib/active_merchant/billing/gateways/borgun.rb
+++ b/lib/active_merchant/billing/gateways/borgun.rb
@@ -76,7 +76,7 @@ def scrub(transcript)
private
- CURRENCY_CODES = Hash.new{|h, k| raise ArgumentError.new("Unsupported currency for HDFC: #{k}")}
+ CURRENCY_CODES = Hash.new { |h, k| raise ArgumentError.new("Unsupported currency for HDFC: #{k}") }
CURRENCY_CODES['ISK'] = '352'
CURRENCY_CODES['EUR'] = '978'
CURRENCY_CODES['USD'] = '840'
diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb
index d39a4b72b56..6a263624017 100644
--- a/lib/active_merchant/billing/gateways/braintree_blue.rb
+++ b/lib/active_merchant/billing/gateways/braintree_blue.rb
@@ -123,7 +123,7 @@ def store(creditcard, options = {})
if options[:customer].present?
MultiResponse.new.tap do |r|
customer_exists_response = nil
- r.process{customer_exists_response = check_customer_exists(options[:customer])}
+ r.process { customer_exists_response = check_customer_exists(options[:customer]) }
r.process do
if customer_exists_response.params['exists']
add_credit_card_to_customer(creditcard, options)
diff --git a/lib/active_merchant/billing/gateways/bridge_pay.rb b/lib/active_merchant/billing/gateways/bridge_pay.rb
index 51d6cf3bc4d..d8cf6218265 100644
--- a/lib/active_merchant/billing/gateways/bridge_pay.rb
+++ b/lib/active_merchant/billing/gateways/bridge_pay.rb
@@ -237,7 +237,7 @@ def post_data(post)
{
:UserName => @options[:user_name],
:Password => @options[:password]
- }.merge(post).collect{|k, v| "#{k}=#{CGI.escape(v.to_s)}"}.join('&')
+ }.merge(post).collect { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
end
end
end
diff --git a/lib/active_merchant/billing/gateways/cams.rb b/lib/active_merchant/billing/gateways/cams.rb
index 872c7818b2b..4fd30dd0489 100644
--- a/lib/active_merchant/billing/gateways/cams.rb
+++ b/lib/active_merchant/billing/gateways/cams.rb
@@ -219,7 +219,7 @@ def post_data(parameters = {})
parameters[:password] = @options[:password]
parameters[:username] = @options[:username]
- parameters.collect{|k, v| "#{k}=#{v}" }.join('&')
+ parameters.collect { |k, v| "#{k}=#{v}" }.join('&')
end
def error_code_from(response)
diff --git a/lib/active_merchant/billing/gateways/cardknox.rb b/lib/active_merchant/billing/gateways/cardknox.rb
index 634eb8a72ac..10b3976dc7d 100644
--- a/lib/active_merchant/billing/gateways/cardknox.rb
+++ b/lib/active_merchant/billing/gateways/cardknox.rb
@@ -276,7 +276,7 @@ def parse(body)
amount: fields['xAuthAmount'],
masked_card_num: fields['xMaskedCardNumber'],
masked_account_number: fields['MaskedAccountNumber']
- }.delete_if{|k, v| v.nil?}
+ }.delete_if { |k, v| v.nil? }
end
def commit(action, source_type, parameters)
@@ -320,7 +320,7 @@ def post_data(command, parameters = {})
initial_parameters[:Hash] = "s/#{seed}/#{hash}/n" unless @options[:pin].blank?
parameters = initial_parameters.merge(parameters)
- parameters.reject{|k, v| v.blank?}.collect{ |key, value| "x#{key}=#{CGI.escape(value.to_s)}" }.join('&')
+ parameters.reject { |k, v| v.blank? }.collect { |key, value| "x#{key}=#{CGI.escape(value.to_s)}" }.join('&')
end
end
end
diff --git a/lib/active_merchant/billing/gateways/cardprocess.rb b/lib/active_merchant/billing/gateways/cardprocess.rb
index 42824ccf952..c91121c0641 100644
--- a/lib/active_merchant/billing/gateways/cardprocess.rb
+++ b/lib/active_merchant/billing/gateways/cardprocess.rb
@@ -189,7 +189,7 @@ def post_data(action, parameters = {})
post[:authentication][:password] = @options[:password]
post[:authentication][:entityId] = @options[:entity_id]
post[:paymentType] = action
- dot_flatten_hash(post).map {|key, value| "#{key}=#{CGI.escape(value.to_s)}"}.join('&')
+ dot_flatten_hash(post).map { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
end
def error_code_from(response)
diff --git a/lib/active_merchant/billing/gateways/cashnet.rb b/lib/active_merchant/billing/gateways/cashnet.rb
index 880ffb4986c..48a7d1308c5 100644
--- a/lib/active_merchant/billing/gateways/cashnet.rb
+++ b/lib/active_merchant/billing/gateways/cashnet.rb
@@ -136,7 +136,7 @@ def parse(body)
match = body.match(/(.*)<\/cngateway>/)
return nil unless match
- Hash[CGI::parse(match[1]).map{|k, v| [k.to_sym, v.first]}]
+ Hash[CGI::parse(match[1]).map { |k, v| [k.to_sym, v.first] }]
end
def handle_response(response)
diff --git a/lib/active_merchant/billing/gateways/cc5.rb b/lib/active_merchant/billing/gateways/cc5.rb
index 695eb7a8703..3d25ec7d3f1 100644
--- a/lib/active_merchant/billing/gateways/cc5.rb
+++ b/lib/active_merchant/billing/gateways/cc5.rb
@@ -174,7 +174,7 @@ def parse(body)
def parse_element(response, node)
if node.has_elements?
- node.elements.each{|element| parse_element(response, element) }
+ node.elements.each { |element| parse_element(response, element) }
else
response[node.name.underscore.to_sym] = node.text
end
diff --git a/lib/active_merchant/billing/gateways/creditcall.rb b/lib/active_merchant/billing/gateways/creditcall.rb
index 554a12ac6be..45f84569f5d 100644
--- a/lib/active_merchant/billing/gateways/creditcall.rb
+++ b/lib/active_merchant/billing/gateways/creditcall.rb
@@ -147,7 +147,7 @@ def build_xml_request
def add_transaction_details(xml, amount, authorization, type, options={})
xml.TransactionDetails do
xml.MessageType type
- xml.Amount(unit: 'Minor'){ xml.text(amount) } if amount
+ xml.Amount(unit: 'Minor') { xml.text(amount) } if amount
xml.CardEaseReference authorization if authorization
xml.VoidReason '01' if type == 'Void'
end
@@ -157,7 +157,7 @@ def add_terminal_details(xml, options={})
xml.TerminalDetails do
xml.TerminalID @options[:terminal_id]
xml.TransactionKey @options[:transaction_key]
- xml.Software(version: 'SoftwareVersion'){ xml.text('SoftwareName') }
+ xml.Software(version: 'SoftwareVersion') { xml.text('SoftwareName') }
end
end
diff --git a/lib/active_merchant/billing/gateways/credorax.rb b/lib/active_merchant/billing/gateways/credorax.rb
index 4c2f173fb0f..ccc42a508ed 100644
--- a/lib/active_merchant/billing/gateways/credorax.rb
+++ b/lib/active_merchant/billing/gateways/credorax.rb
@@ -317,11 +317,11 @@ def sign_request(params)
end
def post_data(action, params, reference_action)
- params.keys.each { |key| params[key] = params[key].to_s}
+ params.keys.each { |key| params[key] = params[key].to_s }
params[:M] = @options[:merchant_id]
params[:O] = request_action(action, reference_action)
params[:K] = sign_request(params)
- params.map {|k, v| "#{k}=#{CGI.escape(v.to_s)}"}.join('&')
+ params.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
end
def request_action(action, reference_action)
@@ -337,7 +337,7 @@ def url
end
def parse(body)
- Hash[CGI::parse(body).map{|k, v| [k.upcase, v.first]}]
+ Hash[CGI::parse(body).map { |k, v| [k.upcase, v.first] }]
end
def success_from(response)
diff --git a/lib/active_merchant/billing/gateways/ct_payment.rb b/lib/active_merchant/billing/gateways/ct_payment.rb
index 2fde2028088..315f16375d8 100644
--- a/lib/active_merchant/billing/gateways/ct_payment.rb
+++ b/lib/active_merchant/billing/gateways/ct_payment.rb
@@ -224,7 +224,7 @@ def commit(action, parameters)
commit_raw(action, parameters)
else
MultiResponse.run(true) do |r|
- r.process { commit_raw(action, parameters)}
+ r.process { commit_raw(action, parameters) }
r.process {
split_auth = split_authorization(r.authorization)
auth = (action.include?('recur')? split_auth[4] : split_auth[0])
diff --git a/lib/active_merchant/billing/gateways/culqi.rb b/lib/active_merchant/billing/gateways/culqi.rb
index 7b0e078207a..80b4d030198 100644
--- a/lib/active_merchant/billing/gateways/culqi.rb
+++ b/lib/active_merchant/billing/gateways/culqi.rb
@@ -235,7 +235,7 @@ def headers
end
def post_data(action, params)
- params.map {|k, v| "#{k}=#{CGI.escape(v.to_s)}"}.join('&')
+ params.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
end
def url
diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb
index 2d3e2ceff0f..83f4734a5f0 100644
--- a/lib/active_merchant/billing/gateways/cyber_source.rb
+++ b/lib/active_merchant/billing/gateways/cyber_source.rb
@@ -755,7 +755,7 @@ def parse(xml)
def parse_element(reply, node)
if node.has_elements?
- node.elements.each{|e| parse_element(reply, e) }
+ node.elements.each { |e| parse_element(reply, e) }
else
if node.parent.name =~ /item/
parent = node.parent.name
diff --git a/lib/active_merchant/billing/gateways/data_cash.rb b/lib/active_merchant/billing/gateways/data_cash.rb
index 7a24dd3e5f3..def3288babf 100644
--- a/lib/active_merchant/billing/gateways/data_cash.rb
+++ b/lib/active_merchant/billing/gateways/data_cash.rb
@@ -286,7 +286,7 @@ def parse(body)
def parse_element(response, node)
if node.has_elements?
- node.elements.each{|e| parse_element(response, e) }
+ node.elements.each { |e| parse_element(response, e) }
else
response[node.name.underscore.to_sym] = node.text
end
diff --git a/lib/active_merchant/billing/gateways/dibs.rb b/lib/active_merchant/billing/gateways/dibs.rb
index 7e4d7ae7cec..e3936bc383f 100644
--- a/lib/active_merchant/billing/gateways/dibs.rb
+++ b/lib/active_merchant/billing/gateways/dibs.rb
@@ -87,7 +87,7 @@ def scrub(transcript)
private
- CURRENCY_CODES = Hash.new{|h, k| raise ArgumentError.new("Unsupported currency: #{k}")}
+ CURRENCY_CODES = Hash.new { |h, k| raise ArgumentError.new("Unsupported currency: #{k}") }
CURRENCY_CODES['USD'] = '840'
CURRENCY_CODES['DKK'] = '208'
CURRENCY_CODES['NOK'] = '578'
diff --git a/lib/active_merchant/billing/gateways/digitzs.rb b/lib/active_merchant/billing/gateways/digitzs.rb
index 1dff6179965..bbc82d4a2b8 100644
--- a/lib/active_merchant/billing/gateways/digitzs.rb
+++ b/lib/active_merchant/billing/gateways/digitzs.rb
@@ -228,7 +228,7 @@ def success_from(response)
def message_from(response)
return response['message'] if response['message']
return 'Success' if success_from(response)
- response['errors'].map {|error_hash| error_hash['detail'] }.join(', ')
+ response['errors'].map { |error_hash| error_hash['detail'] }.join(', ')
end
def authorization_from(response)
@@ -263,7 +263,7 @@ def headers(options)
def error_code_from(response)
unless success_from(response)
- response['errors'].nil? ? response['message'] : response['errors'].map {|error_hash| error_hash['code'] }.join(', ')
+ response['errors'].nil? ? response['message'] : response['errors'].map { |error_hash| error_hash['code'] }.join(', ')
end
end
diff --git a/lib/active_merchant/billing/gateways/elavon.rb b/lib/active_merchant/billing/gateways/elavon.rb
index bdcf11490e4..ab234228e87 100644
--- a/lib/active_merchant/billing/gateways/elavon.rb
+++ b/lib/active_merchant/billing/gateways/elavon.rb
@@ -299,7 +299,7 @@ def preamble
def parse(msg)
resp = {}
- msg.split(self.delimiter).collect{|li|
+ msg.split(self.delimiter).collect { |li|
key, value = li.split('=')
resp[key.to_s.strip.gsub(/^ssl_/, '')] = value.to_s.strip
}
diff --git a/lib/active_merchant/billing/gateways/eway_rapid.rb b/lib/active_merchant/billing/gateways/eway_rapid.rb
index c8fb53e0aa0..29d06a837b4 100644
--- a/lib/active_merchant/billing/gateways/eway_rapid.rb
+++ b/lib/active_merchant/billing/gateways/eway_rapid.rb
@@ -299,7 +299,7 @@ def success?(response)
end
def parse_errors(message)
- errors = message.split(',').collect{|code| MESSAGES[code.strip]}.flatten.join(',')
+ errors = message.split(',').collect { |code| MESSAGES[code.strip] }.flatten.join(',')
errors.presence || message
end
diff --git a/lib/active_merchant/billing/gateways/exact.rb b/lib/active_merchant/billing/gateways/exact.rb
index a388bcc341f..06f31316e66 100644
--- a/lib/active_merchant/billing/gateways/exact.rb
+++ b/lib/active_merchant/billing/gateways/exact.rb
@@ -211,7 +211,7 @@ def parse(xml)
parse_elements(response, root)
end
- response.delete_if{ |k, v| SENSITIVE_FIELDS.include?(k) }
+ response.delete_if { |k, v| SENSITIVE_FIELDS.include?(k) }
end
def parse_elements(response, root)
diff --git a/lib/active_merchant/billing/gateways/federated_canada.rb b/lib/active_merchant/billing/gateways/federated_canada.rb
index 639fd3a3aff..b6666a9fa44 100644
--- a/lib/active_merchant/billing/gateways/federated_canada.rb
+++ b/lib/active_merchant/billing/gateways/federated_canada.rb
@@ -152,7 +152,7 @@ def post_data(action, parameters = {})
parameters[:type] = action
parameters[:username] = @options[:login]
parameters[:password] = @options[:password]
- parameters.map{|k, v| "#{k}=#{CGI.escape(v.to_s)}"}.join('&')
+ parameters.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
end
end
end
diff --git a/lib/active_merchant/billing/gateways/first_giving.rb b/lib/active_merchant/billing/gateways/first_giving.rb
index 3af7a394116..09dea7f8e5a 100644
--- a/lib/active_merchant/billing/gateways/first_giving.rb
+++ b/lib/active_merchant/billing/gateways/first_giving.rb
@@ -116,7 +116,7 @@ def post_data(post)
end
def encode(hash)
- hash.collect{|(k, v)| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}"}.join('&')
+ hash.collect { |(k, v)| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}" }.join('&')
end
def creditcard_brand(brand)
diff --git a/lib/active_merchant/billing/gateways/firstdata_e4.rb b/lib/active_merchant/billing/gateways/firstdata_e4.rb
index 655703826f4..12290ad51c6 100755
--- a/lib/active_merchant/billing/gateways/firstdata_e4.rb
+++ b/lib/active_merchant/billing/gateways/firstdata_e4.rb
@@ -438,7 +438,7 @@ def parse(xml)
parse_elements(response, root)
end
- response.delete_if{ |k, v| SENSITIVE_FIELDS.include?(k) }
+ response.delete_if { |k, v| SENSITIVE_FIELDS.include?(k) }
end
def parse_elements(response, root)
diff --git a/lib/active_merchant/billing/gateways/flo2cash.rb b/lib/active_merchant/billing/gateways/flo2cash.rb
index e3ced39eae0..1f5c9d8076b 100644
--- a/lib/active_merchant/billing/gateways/flo2cash.rb
+++ b/lib/active_merchant/billing/gateways/flo2cash.rb
@@ -71,7 +71,7 @@ def scrub(transcript)
private
- CURRENCY_CODES = Hash.new{|h, k| raise ArgumentError.new("Unsupported currency: #{k}")}
+ CURRENCY_CODES = Hash.new { |h, k| raise ArgumentError.new("Unsupported currency: #{k}") }
CURRENCY_CODES['NZD'] = '554'
def add_invoice(post, money, options)
@@ -172,7 +172,7 @@ def parse(body, action)
def parse_element(response, node)
if node.has_elements?
- node.elements.each{|element| parse_element(response, element) }
+ node.elements.each { |element| parse_element(response, element) }
else
response[node.name.underscore.to_sym] = node.text
end
diff --git a/lib/active_merchant/billing/gateways/garanti.rb b/lib/active_merchant/billing/gateways/garanti.rb
index 64cf7224a95..3c7f19efc5d 100644
--- a/lib/active_merchant/billing/gateways/garanti.rb
+++ b/lib/active_merchant/billing/gateways/garanti.rb
@@ -240,7 +240,7 @@ def parse(body)
def parse_element(response, node)
if node.has_elements?
- node.elements.each{|element| parse_element(response, element) }
+ node.elements.each { |element| parse_element(response, element) }
else
response[node.name.underscore.to_sym] = node.text
end
diff --git a/lib/active_merchant/billing/gateways/global_collect.rb b/lib/active_merchant/billing/gateways/global_collect.rb
index d0f3702191c..370780d14f1 100644
--- a/lib/active_merchant/billing/gateways/global_collect.rb
+++ b/lib/active_merchant/billing/gateways/global_collect.rb
@@ -329,7 +329,7 @@ def error_code_from(succeeded, response)
end
def nestable_hash
- Hash.new {|h, k| h[k] = Hash.new(&h.default_proc) }
+ Hash.new { |h, k| h[k] = Hash.new(&h.default_proc) }
end
def capture_requested?(response)
diff --git a/lib/active_merchant/billing/gateways/hdfc.rb b/lib/active_merchant/billing/gateways/hdfc.rb
index 3037ccac471..142d7c83b82 100644
--- a/lib/active_merchant/billing/gateways/hdfc.rb
+++ b/lib/active_merchant/billing/gateways/hdfc.rb
@@ -57,7 +57,7 @@ def refund(amount, authorization, options={})
private
- CURRENCY_CODES = Hash.new{|h, k| raise ArgumentError.new("Unsupported currency for HDFC: #{k}")}
+ CURRENCY_CODES = Hash.new { |h, k| raise ArgumentError.new("Unsupported currency for HDFC: #{k}") }
CURRENCY_CODES['AED'] = '784'
CURRENCY_CODES['AUD'] = '036'
CURRENCY_CODES['CAD'] = '124'
diff --git a/lib/active_merchant/billing/gateways/inspire.rb b/lib/active_merchant/billing/gateways/inspire.rb
index 0e57ffe09f2..e7771e9ec81 100644
--- a/lib/active_merchant/billing/gateways/inspire.rb
+++ b/lib/active_merchant/billing/gateways/inspire.rb
@@ -201,7 +201,7 @@ def post_data(action, parameters = {})
post[:password] = @options[:password]
post[:type] = action if action
- request = post.merge(parameters).map {|key, value| "#{key}=#{CGI.escape(value.to_s)}"}.join('&')
+ request = post.merge(parameters).map { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
request
end
diff --git a/lib/active_merchant/billing/gateways/iridium.rb b/lib/active_merchant/billing/gateways/iridium.rb
index 6b0ca00b4b7..6b6eda3805b 100644
--- a/lib/active_merchant/billing/gateways/iridium.rb
+++ b/lib/active_merchant/billing/gateways/iridium.rb
@@ -422,36 +422,36 @@ def parse_element(reply, node)
node.attributes.each do |a, b|
reply[:transaction_result][a.underscore.to_sym] = b
end
- node.elements.each{|e| parse_element(reply[:transaction_result], e) } if node.has_elements?
+ node.elements.each { |e| parse_element(reply[:transaction_result], e) } if node.has_elements?
when 'CardDetailsTransactionResult'
reply[:transaction_result] = {}
node.attributes.each do |a, b|
reply[:transaction_result][a.underscore.to_sym] = b
end
- node.elements.each{|e| parse_element(reply[:transaction_result], e) } if node.has_elements?
+ node.elements.each { |e| parse_element(reply[:transaction_result], e) } if node.has_elements?
when 'TransactionOutputData'
reply[:transaction_output_data] = {}
- node.attributes.each{|a, b| reply[:transaction_output_data][a.underscore.to_sym] = b }
- node.elements.each{|e| parse_element(reply[:transaction_output_data], e) } if node.has_elements?
+ node.attributes.each { |a, b| reply[:transaction_output_data][a.underscore.to_sym] = b }
+ node.elements.each { |e| parse_element(reply[:transaction_output_data], e) } if node.has_elements?
when 'CustomVariables'
reply[:custom_variables] = {}
- node.attributes.each{|a, b| reply[:custom_variables][a.underscore.to_sym] = b }
- node.elements.each{|e| parse_element(reply[:custom_variables], e) } if node.has_elements?
+ node.attributes.each { |a, b| reply[:custom_variables][a.underscore.to_sym] = b }
+ node.elements.each { |e| parse_element(reply[:custom_variables], e) } if node.has_elements?
when 'GatewayEntryPoints'
reply[:gateway_entry_points] = {}
- node.attributes.each{|a, b| reply[:gateway_entry_points][a.underscore.to_sym] = b }
- node.elements.each{|e| parse_element(reply[:gateway_entry_points], e) } if node.has_elements?
+ node.attributes.each { |a, b| reply[:gateway_entry_points][a.underscore.to_sym] = b }
+ node.elements.each { |e| parse_element(reply[:gateway_entry_points], e) } if node.has_elements?
else
k = node.name.underscore.to_sym
if node.has_elements?
reply[k] = {}
- node.elements.each{|e| parse_element(reply[k], e) }
+ node.elements.each { |e| parse_element(reply[k], e) }
else
if node.has_attributes?
reply[k] = {}
- node.attributes.each{|a, b| reply[k][a.underscore.to_sym] = b }
+ node.attributes.each { |a, b| reply[k][a.underscore.to_sym] = b }
else
reply[k] = node.text
end
diff --git a/lib/active_merchant/billing/gateways/iveri.rb b/lib/active_merchant/billing/gateways/iveri.rb
index 6d0f1f092df..4a8d96e4752 100644
--- a/lib/active_merchant/billing/gateways/iveri.rb
+++ b/lib/active_merchant/billing/gateways/iveri.rb
@@ -206,7 +206,7 @@ def parse_element(parsed, node)
end
if !node.elements.empty?
- node.elements.each {|e| parse_element(parsed, e) }
+ node.elements.each { |e| parse_element(parsed, e) }
else
parsed[underscore(node.name)] = node.text
end
diff --git a/lib/active_merchant/billing/gateways/jetpay.rb b/lib/active_merchant/billing/gateways/jetpay.rb
index cbe81b5368f..aaa955dd24a 100644
--- a/lib/active_merchant/billing/gateways/jetpay.rb
+++ b/lib/active_merchant/billing/gateways/jetpay.rb
@@ -315,7 +315,7 @@ def parse(body)
def parse_element(response, node)
if node.has_elements?
- node.elements.each{|element| parse_element(response, element) }
+ node.elements.each { |element| parse_element(response, element) }
else
response[node.name.underscore.to_sym] = node.text
end
diff --git a/lib/active_merchant/billing/gateways/jetpay_v2.rb b/lib/active_merchant/billing/gateways/jetpay_v2.rb
index ae99f7f75e3..515bba8fc84 100644
--- a/lib/active_merchant/billing/gateways/jetpay_v2.rb
+++ b/lib/active_merchant/billing/gateways/jetpay_v2.rb
@@ -324,7 +324,7 @@ def parse(body)
def parse_element(response, node)
if node.has_elements?
- node.elements.each{|element| parse_element(response, element) }
+ node.elements.each { |element| parse_element(response, element) }
else
response[node.name.underscore.to_sym] = node.text
end
diff --git a/lib/active_merchant/billing/gateways/maxipago.rb b/lib/active_merchant/billing/gateways/maxipago.rb
index d029d261b93..b4ca346327b 100644
--- a/lib/active_merchant/billing/gateways/maxipago.rb
+++ b/lib/active_merchant/billing/gateways/maxipago.rb
@@ -142,7 +142,7 @@ def parse(body)
def parse_element(response, node)
if node.has_elements?
- node.elements.each{|element| parse_element(response, element) }
+ node.elements.each { |element| parse_element(response, element) }
else
response[node.name.underscore.to_sym] = node.text
end
diff --git a/lib/active_merchant/billing/gateways/merchant_e_solutions.rb b/lib/active_merchant/billing/gateways/merchant_e_solutions.rb
index fd7368d68db..bad8070e2d1 100644
--- a/lib/active_merchant/billing/gateways/merchant_e_solutions.rb
+++ b/lib/active_merchant/billing/gateways/merchant_e_solutions.rb
@@ -186,7 +186,7 @@ def post_data(action, parameters = {})
post[:profile_key] = @options[:password]
post[:transaction_type] = action if action
- request = post.merge(parameters).map {|key, value| "#{key}=#{CGI.escape(value.to_s)}"}.join('&')
+ request = post.merge(parameters).map { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
request
end
end
diff --git a/lib/active_merchant/billing/gateways/merchant_one.rb b/lib/active_merchant/billing/gateways/merchant_one.rb
index e20dfe354bf..f2b081c2074 100644
--- a/lib/active_merchant/billing/gateways/merchant_one.rb
+++ b/lib/active_merchant/billing/gateways/merchant_one.rb
@@ -99,7 +99,7 @@ def post_data(action, parameters = {})
end
def parse(data)
- responses = CGI.parse(data).inject({}){|h, (k, v)| h[k] = v.first; h}
+ responses = CGI.parse(data).inject({}) { |h, (k, v)| h[k] = v.first; h }
Response.new(
(responses['response'].to_i == 1),
responses['responsetext'],
diff --git a/lib/active_merchant/billing/gateways/merchant_partners.rb b/lib/active_merchant/billing/gateways/merchant_partners.rb
index 3af4a301cdf..e4630211a5d 100644
--- a/lib/active_merchant/billing/gateways/merchant_partners.rb
+++ b/lib/active_merchant/billing/gateways/merchant_partners.rb
@@ -212,7 +212,7 @@ def parse_element(response, node)
if node.elements.size == 0
response[node.name.downcase.underscore.to_sym] = node.text
else
- node.elements.each{|element| parse_element(response, element) }
+ node.elements.each { |element| parse_element(response, element) }
end
end
diff --git a/lib/active_merchant/billing/gateways/merchant_warrior.rb b/lib/active_merchant/billing/gateways/merchant_warrior.rb
index 6a8e5538bb5..8e92e21811e 100644
--- a/lib/active_merchant/billing/gateways/merchant_warrior.rb
+++ b/lib/active_merchant/billing/gateways/merchant_warrior.rb
@@ -158,7 +158,7 @@ def parse(body)
def parse_element(response, node)
if node.has_elements?
- node.elements.each{|element| parse_element(response, element)}
+ node.elements.each { |element| parse_element(response, element) }
else
response[node.name.underscore.to_sym] = node.text
end
@@ -203,7 +203,7 @@ def success?(response)
end
def post_data(post)
- post.collect{|k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
+ post.collect { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
end
end
end
diff --git a/lib/active_merchant/billing/gateways/micropayment.rb b/lib/active_merchant/billing/gateways/micropayment.rb
index 17a3750fb95..fc416311865 100644
--- a/lib/active_merchant/billing/gateways/micropayment.rb
+++ b/lib/active_merchant/billing/gateways/micropayment.rb
@@ -140,7 +140,7 @@ def headers
end
def post_data(action, params)
- params.map {|k, v| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}"}.join('&')
+ params.map { |k, v| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}" }.join('&')
end
def url(action)
diff --git a/lib/active_merchant/billing/gateways/migs.rb b/lib/active_merchant/billing/gateways/migs.rb
index bb0c3ef7ae1..f689a41fc4f 100644
--- a/lib/active_merchant/billing/gateways/migs.rb
+++ b/lib/active_merchant/billing/gateways/migs.rb
@@ -249,7 +249,7 @@ def add_creditcard(post, creditcard)
def add_creditcard_type(post, card_type)
post[:Gateway] = 'ssl'
- post[:card] = CARD_TYPES.detect{|ct| ct.am_code == card_type}.migs_long_code
+ post[:card] = CARD_TYPES.detect { |ct| ct.am_code == card_type }.migs_long_code
end
def parse(body)
diff --git a/lib/active_merchant/billing/gateways/modern_payments_cim.rb b/lib/active_merchant/billing/gateways/modern_payments_cim.rb
index 0d9ef36fc3e..b1626434d38 100644
--- a/lib/active_merchant/billing/gateways/modern_payments_cim.rb
+++ b/lib/active_merchant/billing/gateways/modern_payments_cim.rb
@@ -122,7 +122,7 @@ def build_request(action, params)
xml.tag! action, { 'xmlns' => xmlns(action) } do
xml.tag! 'clientId', @options[:login]
xml.tag! 'clientCode', @options[:password]
- params.each {|key, value| xml.tag! key, value }
+ params.each { |key, value| xml.tag! key, value }
end
end
end
@@ -207,7 +207,7 @@ def parse(action, xml)
def parse_element(response, node)
if node.has_elements?
- node.elements.each{|e| parse_element(response, e) }
+ node.elements.each { |e| parse_element(response, e) }
else
response[node.name.underscore.to_sym] = node.text.to_s.strip
end
diff --git a/lib/active_merchant/billing/gateways/moneris.rb b/lib/active_merchant/billing/gateways/moneris.rb
index 839bac02869..9410a306b0a 100644
--- a/lib/active_merchant/billing/gateways/moneris.rb
+++ b/lib/active_merchant/billing/gateways/moneris.rb
@@ -307,8 +307,8 @@ def avs_element(address)
tokens = full_address.split(/\s+/)
element = REXML::Element.new('avs_info')
- element.add_element('avs_street_number').text = tokens.select {|x| x =~ /\d/}.join(' ')
- element.add_element('avs_street_name').text = tokens.reject {|x| x =~ /\d/}.join(' ')
+ element.add_element('avs_street_number').text = tokens.select { |x| x =~ /\d/ }.join(' ')
+ element.add_element('avs_street_name').text = tokens.reject { |x| x =~ /\d/ }.join(' ')
element.add_element('avs_zipcode').text = address[:zip]
element
end
diff --git a/lib/active_merchant/billing/gateways/moneris_us.rb b/lib/active_merchant/billing/gateways/moneris_us.rb
index 9355406aed3..28c06ea91d0 100644
--- a/lib/active_merchant/billing/gateways/moneris_us.rb
+++ b/lib/active_merchant/billing/gateways/moneris_us.rb
@@ -291,8 +291,8 @@ def avs_element(address)
tokens = full_address.split(/\s+/)
element = REXML::Element.new('avs_info')
- element.add_element('avs_street_number').text = tokens.select{|x| x =~ /\d/}.join(' ')
- element.add_element('avs_street_name').text = tokens.reject{|x| x =~ /\d/}.join(' ')
+ element.add_element('avs_street_number').text = tokens.select { |x| x =~ /\d/ }.join(' ')
+ element.add_element('avs_street_name').text = tokens.reject { |x| x =~ /\d/ }.join(' ')
element.add_element('avs_zipcode').text = address[:zip]
element
end
diff --git a/lib/active_merchant/billing/gateways/money_movers.rb b/lib/active_merchant/billing/gateways/money_movers.rb
index 870b47d2ac4..8a7a1e9e9a4 100644
--- a/lib/active_merchant/billing/gateways/money_movers.rb
+++ b/lib/active_merchant/billing/gateways/money_movers.rb
@@ -144,7 +144,7 @@ def post_data(action, parameters = {})
parameters[:type] = action
parameters[:username] = @options[:login]
parameters[:password] = @options[:password]
- parameters.map{|k, v| "#{k}=#{CGI.escape(v.to_s)}"}.join('&')
+ parameters.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
end
end
end
diff --git a/lib/active_merchant/billing/gateways/nab_transact.rb b/lib/active_merchant/billing/gateways/nab_transact.rb
index d09cf7ffc9d..f7df53da09b 100644
--- a/lib/active_merchant/billing/gateways/nab_transact.rb
+++ b/lib/active_merchant/billing/gateways/nab_transact.rb
@@ -280,7 +280,7 @@ def parse(body)
def parse_element(response, node)
if node.has_elements?
- node.elements.each{|element| parse_element(response, element) }
+ node.elements.each { |element| parse_element(response, element) }
else
response[node.name.underscore.to_sym] = node.text
end
diff --git a/lib/active_merchant/billing/gateways/net_registry.rb b/lib/active_merchant/billing/gateways/net_registry.rb
index 0440ee8be2f..8f199a88ca8 100644
--- a/lib/active_merchant/billing/gateways/net_registry.rb
+++ b/lib/active_merchant/billing/gateways/net_registry.rb
@@ -152,7 +152,7 @@ def commit(action, params)
def post_data(action, params)
params['COMMAND'] = TRANSACTIONS[action]
params['LOGIN'] = "#{@options[:login]}/#{@options[:password]}"
- escape_uri(params.map{|k, v| "#{k}=#{v}"}.join('&'))
+ escape_uri(params.map { |k, v| "#{k}=#{v}" }.join('&'))
end
# The upstream is picky and so we can't use CGI.escape like we want to
diff --git a/lib/active_merchant/billing/gateways/netaxept.rb b/lib/active_merchant/billing/gateways/netaxept.rb
index 18eb61964ca..6681259e657 100644
--- a/lib/active_merchant/billing/gateways/netaxept.rb
+++ b/lib/active_merchant/billing/gateways/netaxept.rb
@@ -31,8 +31,8 @@ def purchase(money, creditcard, options = {})
requires!(options, :order_id)
MultiResponse.run do |r|
- r.process{authorize(money, creditcard, options)}
- r.process{capture(money, r.authorization, options)}
+ r.process { authorize(money, creditcard, options) }
+ r.process { capture(money, r.authorization, options) }
end
end
@@ -40,9 +40,9 @@ def authorize(money, creditcard, options = {})
requires!(options, :order_id)
MultiResponse.run do |r|
- r.process{setup_transaction(money, options)}
- r.process{add_and_auth_credit_card(r.authorization, creditcard, options)}
- r.process{query_transaction(r.authorization, options)}
+ r.process { setup_transaction(money, options) }
+ r.process { add_and_auth_credit_card(r.authorization, creditcard, options) }
+ r.process { query_transaction(r.authorization, options) }
end
end
@@ -173,7 +173,7 @@ def build_url(base, parameters=nil)
end
def encode(hash)
- hash.collect{|(k, v)| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}"}.join('&')
+ hash.collect { |(k, v)| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}" }.join('&')
end
end
end
diff --git a/lib/active_merchant/billing/gateways/netbilling.rb b/lib/active_merchant/billing/gateways/netbilling.rb
index 7b13aaf27cf..1cc79fe11fb 100644
--- a/lib/active_merchant/billing/gateways/netbilling.rb
+++ b/lib/active_merchant/billing/gateways/netbilling.rb
@@ -224,7 +224,7 @@ def post_data(action, parameters = {})
parameters[:pay_type] = 'C'
parameters[:tran_type] = TRANSACTIONS[action]
- parameters.reject{|k, v| v.blank?}.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
+ parameters.reject { |k, v| v.blank? }.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
end
end
diff --git a/lib/active_merchant/billing/gateways/netpay.rb b/lib/active_merchant/billing/gateways/netpay.rb
index 7b660cefe98..48e2a0a14d5 100644
--- a/lib/active_merchant/billing/gateways/netpay.rb
+++ b/lib/active_merchant/billing/gateways/netpay.rb
@@ -190,7 +190,7 @@ def commit(action, parameters, options)
add_login_data(parameters)
add_action(parameters, action, options)
- post = parameters.collect{|key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
+ post = parameters.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
parse(ssl_post(url, post), parameters)
end
diff --git a/lib/active_merchant/billing/gateways/nmi.rb b/lib/active_merchant/billing/gateways/nmi.rb
index aa6e956f6c1..8591a802945 100644
--- a/lib/active_merchant/billing/gateways/nmi.rb
+++ b/lib/active_merchant/billing/gateways/nmi.rb
@@ -246,7 +246,7 @@ def headers
end
def post_data(action, params)
- params.map {|k, v| "#{k}=#{CGI.escape(v.to_s)}"}.join('&')
+ params.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
end
def url
diff --git a/lib/active_merchant/billing/gateways/ogone.rb b/lib/active_merchant/billing/gateways/ogone.rb
index 99f998e895f..5d6041c887f 100644
--- a/lib/active_merchant/billing/gateways/ogone.rb
+++ b/lib/active_merchant/billing/gateways/ogone.rb
@@ -429,9 +429,9 @@ def calculate_signature(signed_parameters, algorithm, secret)
raise "Unknown signature algorithm #{algorithm}"
end
- filtered_params = signed_parameters.select{|k, v| !v.blank?}
+ filtered_params = signed_parameters.select { |k, v| !v.blank? }
sha_encryptor.hexdigest(
- filtered_params.sort_by{|k, v| k.upcase}.map{|k, v| "#{k.upcase}=#{v}#{secret}"}.join('')
+ filtered_params.sort_by { |k, v| k.upcase }.map { |k, v| "#{k.upcase}=#{v}#{secret}" }.join('')
).upcase
end
@@ -446,7 +446,7 @@ def legacy_calculate_signature(parameters, secret)
PSPID
Operation
ALIAS
- ).map{|key| parameters[key]} +
+ ).map { |key| parameters[key] } +
[secret]
).join('')
).upcase
diff --git a/lib/active_merchant/billing/gateways/opp.rb b/lib/active_merchant/billing/gateways/opp.rb
index 19d3a11477f..03f6e92286e 100644
--- a/lib/active_merchant/billing/gateways/opp.rb
+++ b/lib/active_merchant/billing/gateways/opp.rb
@@ -272,7 +272,7 @@ def add_3d_secure(post, options)
def add_options(post, options)
post[:createRegistration] = options[:create_registration] if options[:create_registration] && !options[:registrationId]
post[:testMode] = options[:test_mode] if test? && options[:test_mode]
- options.each {|key, value| post[key] = value if key.to_s.match('customParameters\[[a-zA-Z0-9\._]{3,64}\]') }
+ options.each { |key, value| post[key] = value if key.to_s.match('customParameters\[[a-zA-Z0-9\._]{3,64}\]') }
post['customParameters[SHOPPER_pluginId]'] = 'activemerchant'
post['customParameters[custom_disable3DSecure]'] = options[:disable_3d_secure] if options[:disable_3d_secure]
end
diff --git a/lib/active_merchant/billing/gateways/orbital.rb b/lib/active_merchant/billing/gateways/orbital.rb
index fe3f1a3b1d8..f85b73cd35a 100644
--- a/lib/active_merchant/billing/gateways/orbital.rb
+++ b/lib/active_merchant/billing/gateways/orbital.rb
@@ -521,7 +521,7 @@ def parse(body)
def recurring_parse_element(response, node)
if node.has_elements?
- node.elements.each{|e| recurring_parse_element(response, e) }
+ node.elements.each { |e| recurring_parse_element(response, e) }
else
response[node.name.underscore.to_sym] = node.text
end
@@ -533,7 +533,7 @@ def commit(order, message_type, trace_number=nil)
headers['Trace-number'] = trace_number.to_s
headers['Merchant-Id'] = @options[:merchant_id]
end
- request = ->(url){ parse(ssl_post(url, order, headers))}
+ request = ->(url) { parse(ssl_post(url, order, headers)) }
# Failover URL will be attempted in the event of a connection error
response = begin
diff --git a/lib/active_merchant/billing/gateways/pac_net_raven.rb b/lib/active_merchant/billing/gateways/pac_net_raven.rb
index fbc5557fd07..952684b1943 100644
--- a/lib/active_merchant/billing/gateways/pac_net_raven.rb
+++ b/lib/active_merchant/billing/gateways/pac_net_raven.rb
@@ -107,7 +107,7 @@ def add_address(post, options)
end
def parse(body)
- Hash[body.split('&').map{|x| x.split('=').map{|y| CGI.unescape(y)}}]
+ Hash[body.split('&').map { |x| x.split('=').map { |y| CGI.unescape(y) } }]
end
def commit(action, money, parameters)
diff --git a/lib/active_merchant/billing/gateways/pay_conex.rb b/lib/active_merchant/billing/gateways/pay_conex.rb
index 0095bcfc29b..d0ae08146e8 100644
--- a/lib/active_merchant/billing/gateways/pay_conex.rb
+++ b/lib/active_merchant/billing/gateways/pay_conex.rb
@@ -231,7 +231,7 @@ def message_from(response)
def post_data(action, params)
params[:transaction_type] = action
- params.map {|k, v| "#{k}=#{CGI.escape(v.to_s)}"}.join('&')
+ params.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
end
def unparsable_response(raw_response)
diff --git a/lib/active_merchant/billing/gateways/pay_gate_xml.rb b/lib/active_merchant/billing/gateways/pay_gate_xml.rb
index 7c17b1dfa3f..35261aaf564 100644
--- a/lib/active_merchant/billing/gateways/pay_gate_xml.rb
+++ b/lib/active_merchant/billing/gateways/pay_gate_xml.rb
@@ -162,8 +162,8 @@ def initialize(options = {})
def purchase(money, creditcard, options = {})
MultiResponse.run do |r|
- r.process{authorize(money, creditcard, options)}
- r.process{capture(money, r.authorization, options)}
+ r.process { authorize(money, creditcard, options) }
+ r.process { capture(money, r.authorization, options) }
end
end
diff --git a/lib/active_merchant/billing/gateways/pay_junction.rb b/lib/active_merchant/billing/gateways/pay_junction.rb
index 19dd8317037..68a24d6f8fc 100644
--- a/lib/active_merchant/billing/gateways/pay_junction.rb
+++ b/lib/active_merchant/billing/gateways/pay_junction.rb
@@ -366,7 +366,7 @@ def post_data(action, params)
params[:version] = API_VERSION
params[:transaction_type] = action
- params.reject{|k, v| v.blank?}.collect{ |k, v| "dc_#{k}=#{CGI.escape(v.to_s)}" }.join('&')
+ params.reject { |k, v| v.blank? }.collect { |k, v| "dc_#{k}=#{CGI.escape(v.to_s)}" }.join('&')
end
def parse(body)
diff --git a/lib/active_merchant/billing/gateways/pay_junction_v2.rb b/lib/active_merchant/billing/gateways/pay_junction_v2.rb
index 2f9a5148dc7..aed266facd6 100644
--- a/lib/active_merchant/billing/gateways/pay_junction_v2.rb
+++ b/lib/active_merchant/billing/gateways/pay_junction_v2.rb
@@ -146,7 +146,7 @@ def headers
end
def post_data(params)
- params.map {|k, v| "#{k}=#{CGI.escape(v.to_s)}"}.join('&')
+ params.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
end
def url(params={})
@@ -173,7 +173,7 @@ def success_from(response)
def message_from(response)
return response['response']['message'] if response['response']
- response['errors']&.inject(''){ |message, error| error['message'] + '|' + message }
+ response['errors']&.inject('') { |message, error| error['message'] + '|' + message }
end
def authorization_from(response)
diff --git a/lib/active_merchant/billing/gateways/pay_secure.rb b/lib/active_merchant/billing/gateways/pay_secure.rb
index 117b33939d9..76c13578379 100644
--- a/lib/active_merchant/billing/gateways/pay_secure.rb
+++ b/lib/active_merchant/billing/gateways/pay_secure.rb
@@ -104,7 +104,7 @@ def post_data(action, parameters = {})
parameters[:merchant_id] = @options[:login]
parameters[:password] = @options[:password]
- parameters.reject{|k, v| v.blank?}.collect { |key, value| "#{key.to_s.upcase}=#{CGI.escape(value.to_s)}" }.join('&')
+ parameters.reject { |k, v| v.blank? }.collect { |key, value| "#{key.to_s.upcase}=#{CGI.escape(value.to_s)}" }.join('&')
end
end
end
diff --git a/lib/active_merchant/billing/gateways/paybox_direct.rb b/lib/active_merchant/billing/gateways/paybox_direct.rb
index ecb3d938a9f..e99d787f210 100644
--- a/lib/active_merchant/billing/gateways/paybox_direct.rb
+++ b/lib/active_merchant/billing/gateways/paybox_direct.rb
@@ -157,7 +157,7 @@ def commit(action, money = nil, parameters = nil)
:test => test?,
:authorization => response[:numappel].to_s + response[:numtrans].to_s,
:fraud_review => false,
- :sent_params => parameters.delete_if{|key, value| ['porteur', 'dateval', 'cvv'].include?(key.to_s)}
+ :sent_params => parameters.delete_if { |key, value| ['porteur', 'dateval', 'cvv'].include?(key.to_s) }
)
end
diff --git a/lib/active_merchant/billing/gateways/payex.rb b/lib/active_merchant/billing/gateways/payex.rb
index b82b8c4d21b..c43e36bb13f 100644
--- a/lib/active_merchant/billing/gateways/payex.rb
+++ b/lib/active_merchant/billing/gateways/payex.rb
@@ -63,8 +63,8 @@ def authorize(amount, payment_method, options = {})
if payment_method.respond_to?(:number)
# credit card authorization
MultiResponse.new.tap do |r|
- r.process {send_initialize(amount, true, options)}
- r.process {send_purchasecc(payment_method, r.params['orderref'])}
+ r.process { send_initialize(amount, true, options) }
+ r.process { send_purchasecc(payment_method, r.params['orderref']) }
end
else
# stored authorization
@@ -91,8 +91,8 @@ def purchase(amount, payment_method, options = {})
if payment_method.respond_to?(:number)
# credit card purchase
MultiResponse.new.tap do |r|
- r.process {send_initialize(amount, false, options)}
- r.process {send_purchasecc(payment_method, r.params['orderref'])}
+ r.process { send_initialize(amount, false, options) }
+ r.process { send_purchasecc(payment_method, r.params['orderref']) }
end
else
# stored purchase
@@ -154,10 +154,10 @@ def store(creditcard, options = {})
requires!(options, :order_id)
amount = amount(1) # 1 cent for authorization
MultiResponse.run(:first) do |r|
- r.process {send_create_agreement(options)}
- r.process {send_initialize(amount, true, options.merge({agreement_ref: r.authorization}))}
+ r.process { send_create_agreement(options) }
+ r.process { send_initialize(amount, true, options.merge({agreement_ref: r.authorization})) }
order_ref = r.params['orderref']
- r.process {send_purchasecc(creditcard, order_ref)}
+ r.process { send_purchasecc(creditcard, order_ref) }
end
end
diff --git a/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb b/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb
index 32213491eb5..4ad1bd00739 100644
--- a/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb
+++ b/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb
@@ -179,9 +179,9 @@ def parse_element(response, node)
# in an RPPaymentResults element so we'll come here multiple times
response[node_name] ||= []
response[node_name] << (payment_result_response = {})
- node.xpath('.//*').each{ |e| parse_element(payment_result_response, e) }
+ node.xpath('.//*').each { |e| parse_element(payment_result_response, e) }
when node.xpath('.//*').to_a.any?
- node.xpath('.//*').each{|e| parse_element(response, e) }
+ node.xpath('.//*').each { |e| parse_element(response, e) }
when node_name.to_s =~ /amt$/
# *Amt elements don't put the value in the #text - instead they use a Currency attribute
response[node_name] = node.attributes['Currency'].to_s
diff --git a/lib/active_merchant/billing/gateways/payscout.rb b/lib/active_merchant/billing/gateways/payscout.rb
index 88fb8624655..d2ad18b5a16 100644
--- a/lib/active_merchant/billing/gateways/payscout.rb
+++ b/lib/active_merchant/billing/gateways/payscout.rb
@@ -102,7 +102,7 @@ def add_creditcard(post, creditcard)
end
def parse(body)
- Hash[body.split('&').map{|x| x.split('=')}]
+ Hash[body.split('&').map { |x| x.split('=') }]
end
def commit(action, money, parameters)
diff --git a/lib/active_merchant/billing/gateways/payu_in.rb b/lib/active_merchant/billing/gateways/payu_in.rb
index f75cbbd7df7..eabc32c1cd6 100644
--- a/lib/active_merchant/billing/gateways/payu_in.rb
+++ b/lib/active_merchant/billing/gateways/payu_in.rb
@@ -32,11 +32,11 @@ def purchase(money, payment, options={})
add_auth(post)
MultiResponse.run do |r|
- r.process{commit(url('purchase'), post)}
+ r.process { commit(url('purchase'), post) }
if(r.params['enrolled'].to_s == '0')
- r.process{commit(r.params['post_uri'], r.params['form_post_vars'])}
+ r.process { commit(r.params['post_uri'], r.params['form_post_vars']) }
else
- r.process{handle_3dsecure(r)}
+ r.process { handle_3dsecure(r) }
end
end
end
diff --git a/lib/active_merchant/billing/gateways/psl_card.rb b/lib/active_merchant/billing/gateways/psl_card.rb
index d0495a42037..77da4a123db 100644
--- a/lib/active_merchant/billing/gateways/psl_card.rb
+++ b/lib/active_merchant/billing/gateways/psl_card.rb
@@ -183,7 +183,7 @@ def add_address(post, options)
address = options[:billing_address] || options[:address]
return if address.nil?
- post[:QAAddress] = [:address1, :address2, :city, :state].collect{|a| address[a]}.reject(&:blank?).join(' ')
+ post[:QAAddress] = [:address1, :address2, :city, :state].collect { |a| address[a] }.reject(&:blank?).join(' ')
post[:QAPostcode] = address[:zip]
end
diff --git a/lib/active_merchant/billing/gateways/quantum.rb b/lib/active_merchant/billing/gateways/quantum.rb
index 38a53eeb08c..4fd43ad07ca 100644
--- a/lib/active_merchant/billing/gateways/quantum.rb
+++ b/lib/active_merchant/billing/gateways/quantum.rb
@@ -251,7 +251,7 @@ def parse(xml)
def parse_element(reply, node)
if node.has_elements?
- node.elements.each{|e| parse_element(reply, e) }
+ node.elements.each { |e| parse_element(reply, e) }
else
if node.parent.name =~ /item/
parent = node.parent.name + (node.parent.attributes['id'] ? '_' + node.parent.attributes['id'] : '')
diff --git a/lib/active_merchant/billing/gateways/quickbooks.rb b/lib/active_merchant/billing/gateways/quickbooks.rb
index 48442334eb2..1f73575bdab 100644
--- a/lib/active_merchant/billing/gateways/quickbooks.rb
+++ b/lib/active_merchant/billing/gateways/quickbooks.rb
@@ -224,17 +224,17 @@ def headers(method, uri)
}
# prepare components for signature
- oauth_signature_base_string = [method.to_s.upcase, request_uri.to_s, oauth_parameters.to_param].map{|v| CGI.escape(v) }.join('&')
- oauth_signing_key = [@options[:consumer_secret], @options[:token_secret]].map{|v| CGI.escape(v)}.join('&')
+ oauth_signature_base_string = [method.to_s.upcase, request_uri.to_s, oauth_parameters.to_param].map { |v| CGI.escape(v) }.join('&')
+ oauth_signing_key = [@options[:consumer_secret], @options[:token_secret]].map { |v| CGI.escape(v) }.join('&')
hmac_signature = OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha1'), oauth_signing_key, oauth_signature_base_string)
# append signature to required OAuth parameters
oauth_parameters[:oauth_signature] = CGI.escape(Base64.encode64(hmac_signature).chomp.gsub(/\n/, ''))
# prepare Authorization header string
- oauth_parameters = Hash[oauth_parameters.sort_by {|k, _| k}]
+ oauth_parameters = Hash[oauth_parameters.sort_by { |k, _| k }]
oauth_headers = ["OAuth realm=\"#{@options[:realm]}\""]
- oauth_headers += oauth_parameters.map {|k, v| "#{k}=\"#{v}\""}
+ oauth_headers += oauth_parameters.map { |k, v| "#{k}=\"#{v}\"" }
{
'Content-type' => 'application/json',
@@ -258,7 +258,7 @@ def success?(response)
end
def message_from(response)
- response['errors'].present? ? response['errors'].map {|error_hash| error_hash['message'] }.join(' ') : response['status']
+ response['errors'].present? ? response['errors'].map { |error_hash| error_hash['message'] }.join(' ') : response['status']
end
def errors_from(response)
diff --git a/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb b/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb
index f26ed7eda57..10ad00b3ae3 100644
--- a/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb
+++ b/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb
@@ -78,7 +78,7 @@ def verify(credit_card, options={})
def store(credit_card, options = {})
MultiResponse.run do |r|
r.process { create_store(options) }
- r.process { authorize_store(r.authorization, credit_card, options)}
+ r.process { authorize_store(r.authorization, credit_card, options) }
end
end
diff --git a/lib/active_merchant/billing/gateways/qvalent.rb b/lib/active_merchant/billing/gateways/qvalent.rb
index 0dd7c279255..46c43aae0cd 100644
--- a/lib/active_merchant/billing/gateways/qvalent.rb
+++ b/lib/active_merchant/billing/gateways/qvalent.rb
@@ -103,7 +103,7 @@ def scrub(transcript)
private
- CURRENCY_CODES = Hash.new{|h, k| raise ArgumentError.new("Unsupported currency: #{k}")}
+ CURRENCY_CODES = Hash.new { |h, k| raise ArgumentError.new("Unsupported currency: #{k}") }
CURRENCY_CODES['AUD'] = 'AUD'
CURRENCY_CODES['INR'] = 'INR'
@@ -197,7 +197,7 @@ def parse(body)
def parse_element(response, node)
if node.has_elements?
- node.elements.each{|element| parse_element(response, element) }
+ node.elements.each { |element| parse_element(response, element) }
else
response[node.name.underscore.to_sym] = node.text
end
diff --git a/lib/active_merchant/billing/gateways/realex.rb b/lib/active_merchant/billing/gateways/realex.rb
index 3e0e1a21276..ca0b91517b3 100644
--- a/lib/active_merchant/billing/gateways/realex.rb
+++ b/lib/active_merchant/billing/gateways/realex.rb
@@ -286,7 +286,7 @@ def add_network_tokenization_card(xml, payment)
def format_address_code(address)
code = [address[:zip].to_s, address[:address1].to_s + address[:address2].to_s]
- code.collect{|e| e.gsub(/\D/, '')}.reject(&:empty?).join('|')
+ code.collect { |e| e.gsub(/\D/, '') }.reject(&:empty?).join('|')
end
def new_timestamp
diff --git a/lib/active_merchant/billing/gateways/secure_net.rb b/lib/active_merchant/billing/gateways/secure_net.rb
index 66ccc07dc00..f3abdf29935 100644
--- a/lib/active_merchant/billing/gateways/secure_net.rb
+++ b/lib/active_merchant/billing/gateways/secure_net.rb
@@ -247,7 +247,7 @@ def parse(xml)
def recurring_parse_element(response, node)
if node.has_elements?
- node.elements.each{|e| recurring_parse_element(response, e) }
+ node.elements.each { |e| recurring_parse_element(response, e) }
else
response[node.name.underscore.to_sym] = node.text
end
diff --git a/lib/active_merchant/billing/gateways/secure_pay_au.rb b/lib/active_merchant/billing/gateways/secure_pay_au.rb
index 3a6aa76775f..37a2845bbd5 100644
--- a/lib/active_merchant/billing/gateways/secure_pay_au.rb
+++ b/lib/active_merchant/billing/gateways/secure_pay_au.rb
@@ -276,7 +276,7 @@ def parse(body)
def parse_element(response, node)
if node.has_elements?
- node.elements.each{|element| parse_element(response, element) }
+ node.elements.each { |element| parse_element(response, element) }
else
response[node.name.underscore.to_sym] = node.text
end
diff --git a/lib/active_merchant/billing/gateways/skip_jack.rb b/lib/active_merchant/billing/gateways/skip_jack.rb
index 3528b04f22c..158742d58f7 100644
--- a/lib/active_merchant/billing/gateways/skip_jack.rb
+++ b/lib/active_merchant/billing/gateways/skip_jack.rb
@@ -368,7 +368,7 @@ def add_invoice(post, options)
post[:OrderDescription] = options[:description]
if order_items = options[:items]
- post[:OrderString] = order_items.collect { |item| "#{item[:sku]}~#{item[:description].tr('~', '-')}~#{item[:declared_value]}~#{item[:quantity]}~#{item[:taxable]}~~~~~~~~#{item[:tax_rate]}~||"}.join
+ post[:OrderString] = order_items.collect { |item| "#{item[:sku]}~#{item[:description].tr('~', '-')}~#{item[:declared_value]}~#{item[:quantity]}~#{item[:taxable]}~~~~~~~~#{item[:tax_rate]}~||" }.join
else
post[:OrderString] = '1~None~0.00~0~N~||'
end
diff --git a/lib/active_merchant/billing/gateways/smart_ps.rb b/lib/active_merchant/billing/gateways/smart_ps.rb
index fe196f6dc0b..0e1b7c0a699 100644
--- a/lib/active_merchant/billing/gateways/smart_ps.rb
+++ b/lib/active_merchant/billing/gateways/smart_ps.rb
@@ -263,7 +263,7 @@ def post_data(action, parameters = {})
post[:password] = @options[:password]
post[:type] = action if action
- request = post.merge(parameters).map {|key, value| "#{key}=#{CGI.escape(value.to_s)}"}.join('&')
+ request = post.merge(parameters).map { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
request
end
diff --git a/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb b/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb
index c58ffb0d041..e9ac1ac2a9f 100644
--- a/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb
+++ b/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb
@@ -321,7 +321,7 @@ def scrub(transcript)
private
- CURRENCY_CODES = Hash.new{|h, k| raise ArgumentError.new("Unsupported currency: #{k}")}
+ CURRENCY_CODES = Hash.new { |h, k| raise ArgumentError.new("Unsupported currency: #{k}") }
CURRENCY_CODES['USD'] = '840'
def headers
diff --git a/lib/active_merchant/billing/gateways/transact_pro.rb b/lib/active_merchant/billing/gateways/transact_pro.rb
index 783e5e18b29..5aaa36d756d 100644
--- a/lib/active_merchant/billing/gateways/transact_pro.rb
+++ b/lib/active_merchant/billing/gateways/transact_pro.rb
@@ -32,7 +32,7 @@ def purchase(amount, payment, options={})
post[:rs] = @options[:terminal]
MultiResponse.run do |r|
- r.process{commit('init', post)}
+ r.process { commit('init', post) }
r.process do
post = PostData.new
post[:init_transaction_id] = r.authorization
@@ -54,7 +54,7 @@ def authorize(amount, payment, options={})
post[:rs] = @options[:terminal]
MultiResponse.run do |r|
- r.process{commit('init_dms', post)}
+ r.process { commit('init_dms', post) }
r.process do
post = PostData.new
post[:init_transaction_id] = r.authorization
diff --git a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb
index 4eb7827b27c..55d6b439956 100644
--- a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb
+++ b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb
@@ -253,7 +253,7 @@ def parse(body)
:error_code => fields['UMerrorcode'],
:acs_url => fields['UMacsurl'],
:payload => fields['UMpayload']
- }.delete_if{|k, v| v.nil?}
+ }.delete_if { |k, v| v.nil? }
end
def commit(action, parameters)
diff --git a/lib/active_merchant/billing/gateways/vanco.rb b/lib/active_merchant/billing/gateways/vanco.rb
index 38e2f2aef87..546eedbca4e 100644
--- a/lib/active_merchant/billing/gateways/vanco.rb
+++ b/lib/active_merchant/billing/gateways/vanco.rb
@@ -82,8 +82,8 @@ def add_errors_to_response(response, errors_xml)
response[:error_message] = error['ErrorDescription']
response[:error_codes] = error['ErrorCode']
elsif error.kind_of?(Array)
- error_str = error.map { |e| e['ErrorDescription']}.join('. ')
- error_codes = error.map { |e| e['ErrorCode']}.join(', ')
+ error_str = error.map { |e| e['ErrorDescription'] }.join('. ')
+ error_codes = error.map { |e| e['ErrorCode'] }.join(', ')
response[:error_message] = "#{error_str}."
response[:error_codes] = error_codes
end
diff --git a/lib/active_merchant/billing/gateways/viaklix.rb b/lib/active_merchant/billing/gateways/viaklix.rb
index 269c5b3a8be..b68a8ec3ac9 100644
--- a/lib/active_merchant/billing/gateways/viaklix.rb
+++ b/lib/active_merchant/billing/gateways/viaklix.rb
@@ -165,7 +165,7 @@ def post_data(parameters)
# Parse the response message
def parse(msg)
resp = {}
- msg.split(self.delimiter).collect{|li|
+ msg.split(self.delimiter).collect { |li|
key, value = li.split('=')
resp[key.strip.gsub(/^ssl_/, '')] = value.to_s.strip
}
diff --git a/lib/active_merchant/billing/gateways/visanet_peru.rb b/lib/active_merchant/billing/gateways/visanet_peru.rb
index 6e5818bee63..70999dc58ee 100644
--- a/lib/active_merchant/billing/gateways/visanet_peru.rb
+++ b/lib/active_merchant/billing/gateways/visanet_peru.rb
@@ -82,7 +82,7 @@ def scrub(transcript)
private
- CURRENCY_CODES = Hash.new{|h, k| raise ArgumentError.new("Unsupported currency: #{k}")}
+ CURRENCY_CODES = Hash.new { |h, k| raise ArgumentError.new("Unsupported currency: #{k}") }
CURRENCY_CODES['USD'] = 840
CURRENCY_CODES['PEN'] = 604
diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb
index 30b795da727..e5b30d2d6f8 100644
--- a/lib/active_merchant/billing/gateways/worldpay.rb
+++ b/lib/active_merchant/billing/gateways/worldpay.rb
@@ -30,8 +30,8 @@ def initialize(options = {})
def purchase(money, payment_method, options = {})
MultiResponse.run do |r|
- r.process{authorize(money, payment_method, options)}
- r.process{capture(money, r.authorization, options.merge(:authorization_validated => true))}
+ r.process { authorize(money, payment_method, options) }
+ r.process { capture(money, r.authorization, options.merge(:authorization_validated => true)) }
end
end
@@ -42,19 +42,19 @@ def authorize(money, payment_method, options = {})
def capture(money, authorization, options = {})
MultiResponse.run do |r|
- r.process{inquire_request(authorization, options, 'AUTHORISED')} unless options[:authorization_validated]
+ r.process { inquire_request(authorization, options, 'AUTHORISED') } unless options[:authorization_validated]
if r.params
authorization_currency = r.params['amount_currency_code']
options = options.merge(:currency => authorization_currency) if authorization_currency.present?
end
- r.process{capture_request(money, authorization, options)}
+ r.process { capture_request(money, authorization, options) }
end
end
def void(authorization, options = {})
MultiResponse.run do |r|
- r.process{inquire_request(authorization, options, 'AUTHORISED')} unless options[:authorization_validated]
- r.process{cancel_request(authorization, options)}
+ r.process { inquire_request(authorization, options, 'AUTHORISED') } unless options[:authorization_validated]
+ r.process { cancel_request(authorization, options) }
end
end
@@ -175,7 +175,7 @@ def build_authorization_request(money, payment_method, options)
end
def order_tag_attributes(options)
- { 'orderCode' => options[:order_id], 'installationId' => options[:inst_id] || @options[:inst_id] }.reject{|_, v| !v}
+ { 'orderCode' => options[:order_id], 'installationId' => options[:inst_id] || @options[:inst_id] }.reject { |_, v| !v }
end
def build_capture_request(money, authorization, options)
@@ -337,7 +337,7 @@ def parse_element(raw, node)
end
if node.has_elements?
raw[node.name.underscore.to_sym] = true unless node.name.blank?
- node.elements.each{|e| parse_element(raw, e) }
+ node.elements.each { |e| parse_element(raw, e) }
else
raw[node.name.underscore.to_sym] = node.text unless node.text.nil?
end
@@ -418,12 +418,12 @@ def error_code_from(success, raw)
def required_status_message(raw, success_criteria)
if(!success_criteria.include?(raw[:last_event]))
- "A transaction status of #{success_criteria.collect{|c| "'#{c}'"}.join(" or ")} is required."
+ "A transaction status of #{success_criteria.collect { |c| "'#{c}'" }.join(" or ")} is required."
end
end
def authorization_from(raw)
- pair = raw.detect{|k, v| k.to_s =~ /_order_code$/}
+ pair = raw.detect { |k, v| k.to_s =~ /_order_code$/ }
(pair ? pair.last : nil)
end
diff --git a/lib/active_merchant/billing/response.rb b/lib/active_merchant/billing/response.rb
index 8470e8385e1..491bb0cab5b 100644
--- a/lib/active_merchant/billing/response.rb
+++ b/lib/active_merchant/billing/response.rb
@@ -70,7 +70,7 @@ def process(ignore_result=false)
def <<(response)
if response.is_a?(MultiResponse)
- response.responses.each{|r| @responses << r}
+ response.responses.each { |r| @responses << r }
else
@responses << response
end
diff --git a/lib/active_merchant/country.rb b/lib/active_merchant/country.rb
index 34710a2572e..bdc25799900 100644
--- a/lib/active_merchant/country.rb
+++ b/lib/active_merchant/country.rb
@@ -39,11 +39,11 @@ class Country
def initialize(options = {})
@name = options.delete(:name)
- @codes = options.collect{|k, v| CountryCode.new(v)}
+ @codes = options.collect { |k, v| CountryCode.new(v) }
end
def code(format)
- @codes.detect{|c| c.format == format}
+ @codes.detect { |c| c.format == format }
end
def ==(other)
@@ -324,9 +324,9 @@ def self.find(name)
when 2, 3
upcase_name = name.upcase
country_code = CountryCode.new(name)
- country = COUNTRIES.detect{|c| c[country_code.format] == upcase_name }
+ country = COUNTRIES.detect { |c| c[country_code.format] == upcase_name }
else
- country = COUNTRIES.detect{|c| c[:name].casecmp(name).zero? }
+ country = COUNTRIES.detect { |c| c[:name].casecmp(name).zero? }
end
raise InvalidCountryCodeError, "No country could be found for the country #{name}" if country.nil?
Country.new(country.dup)
diff --git a/lib/support/gateway_support.rb b/lib/support/gateway_support.rb
index 36b916773ec..b3bb28e54cf 100644
--- a/lib/support/gateway_support.rb
+++ b/lib/support/gateway_support.rb
@@ -24,14 +24,14 @@ def initialize
end
def each_gateway
- @gateways.each{|g| yield g }
+ @gateways.each { |g| yield g }
end
def features
width = 15
print 'Name'.center(width + 20)
- ACTIONS.each{|f| print f.to_s.capitalize.center(width) }
+ ACTIONS.each { |f| print f.to_s.capitalize.center(width) }
puts
each_gateway do |g|
diff --git a/test/remote/gateways/remote_braintree_blue_test.rb b/test/remote/gateways/remote_braintree_blue_test.rb
index db3c1fbd6db..b756c862f63 100644
--- a/test/remote/gateways/remote_braintree_blue_test.rb
+++ b/test/remote/gateways/remote_braintree_blue_test.rb
@@ -3,7 +3,7 @@
class RemoteBraintreeBlueTest < Test::Unit::TestCase
def setup
@gateway = BraintreeGateway.new(fixtures(:braintree_blue))
- @braintree_backend = @gateway.instance_eval{@braintree_gateway}
+ @braintree_backend = @gateway.instance_eval { @braintree_gateway }
@amount = 100
@declined_amount = 2000_00
diff --git a/test/remote/gateways/remote_moneris_test.rb b/test/remote/gateways/remote_moneris_test.rb
index f096b7a9d51..1e4308bc62d 100644
--- a/test/remote/gateways/remote_moneris_test.rb
+++ b/test/remote/gateways/remote_moneris_test.rb
@@ -271,7 +271,7 @@ def test_avs_result_valid_when_enabled
def test_avs_result_nil_when_address_absent
gateway = MonerisGateway.new(fixtures(:moneris).merge(avs_enabled: true))
- assert response = gateway.purchase(1010, @credit_card, @options.tap {|x| x.delete(:billing_address)})
+ assert response = gateway.purchase(1010, @credit_card, @options.tap { |x| x.delete(:billing_address) })
assert_success response
assert_equal(response.avs_result, {
'code' => nil,
diff --git a/test/remote/gateways/remote_paypal_test.rb b/test/remote/gateways/remote_paypal_test.rb
index 3cb88a8ed96..7465a369da7 100644
--- a/test/remote/gateways/remote_paypal_test.rb
+++ b/test/remote/gateways/remote_paypal_test.rb
@@ -216,7 +216,7 @@ def test_failed_multiple_transfer
assert_success response
# You can only include up to 250 recipients
- recipients = (1..251).collect {|i| [100, "person#{i}@example.com"]}
+ recipients = (1..251).collect { |i| [100, "person#{i}@example.com"] }
response = @gateway.transfer(*recipients)
assert_failure response
end
diff --git a/test/remote/gateways/remote_securion_pay_test.rb b/test/remote/gateways/remote_securion_pay_test.rb
index d6b66c7ad0b..59b600899f1 100644
--- a/test/remote/gateways/remote_securion_pay_test.rb
+++ b/test/remote/gateways/remote_securion_pay_test.rb
@@ -106,7 +106,7 @@ def test_successful_full_refund
assert refund.params['refunded']
assert_equal 0, refund.params['amount']
assert_equal 1, refund.params['refunds'].size
- assert_equal @amount, refund.params['refunds'].map{|r| r['amount']}.sum
+ assert_equal @amount, refund.params['refunds'].map { |r| r['amount'] }.sum
assert refund.authorization
end
@@ -124,7 +124,7 @@ def test_successful_partially_refund
assert second_refund.params['refunded']
assert_equal @amount - 2 * @refund_amount, second_refund.params['amount']
assert_equal 2, second_refund.params['refunds'].size
- assert_equal 2 * @refund_amount, second_refund.params['refunds'].map{|r| r['amount']}.sum
+ assert_equal 2 * @refund_amount, second_refund.params['refunds'].map { |r| r['amount'] }.sum
assert second_refund.authorization
end
@@ -154,7 +154,7 @@ def test_successful_void
assert void.params['refunded']
assert_equal 0, void.params['amount']
assert_equal 1, void.params['refunds'].size
- assert_equal @amount, void.params['refunds'].map{|r| r['amount']}.sum
+ assert_equal @amount, void.params['refunds'].map { |r| r['amount'] }.sum
assert void.authorization
end
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 99f482ce780..9666234fea9 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -273,7 +273,7 @@ def symbolize_keys(hash)
return unless hash.is_a?(Hash)
hash.symbolize_keys!
- hash.each{|k, v| symbolize_keys(v)}
+ hash.each { |k, v| symbolize_keys(v) }
end
end
end
diff --git a/test/unit/country_code_test.rb b/test/unit/country_code_test.rb
index b455d05f3d7..12ee3ae4ab4 100644
--- a/test/unit/country_code_test.rb
+++ b/test/unit/country_code_test.rb
@@ -26,6 +26,6 @@ def test_numeric_code
end
def test_invalid_code_format
- assert_raises(ActiveMerchant::CountryCodeFormatError){ ActiveMerchant::CountryCode.new('Canada') }
+ assert_raises(ActiveMerchant::CountryCodeFormatError) { ActiveMerchant::CountryCode.new('Canada') }
end
end
diff --git a/test/unit/credit_card_test.rb b/test/unit/credit_card_test.rb
index 40702473604..fed8dea282f 100644
--- a/test/unit/credit_card_test.rb
+++ b/test/unit/credit_card_test.rb
@@ -188,7 +188,7 @@ def test_should_correctly_identify_card_brand
assert_equal 'visa', CreditCard.brand?('4242424242424242')
assert_equal 'american_express', CreditCard.brand?('341111111111111')
assert_equal 'master', CreditCard.brand?('5105105105105100')
- (222100..272099).each {|bin| assert_equal 'master', CreditCard.brand?(bin.to_s + '1111111111'), "Failed with BIN #{bin}"}
+ (222100..272099).each { |bin| assert_equal 'master', CreditCard.brand?(bin.to_s + '1111111111'), "Failed with BIN #{bin}" }
assert_nil CreditCard.brand?('')
end
diff --git a/test/unit/gateways/balanced_test.rb b/test/unit/gateways/balanced_test.rb
index f405a513edf..68e98b4f0d4 100644
--- a/test/unit/gateways/balanced_test.rb
+++ b/test/unit/gateways/balanced_test.rb
@@ -277,7 +277,7 @@ def test_passing_address
@gateway.purchase(@amount, @credit_card, address: a)
end.check_request do |method, endpoint, data, headers|
next if endpoint =~ /debits/
- clean = proc{|s| Regexp.escape(CGI.escape(s))}
+ clean = proc { |s| Regexp.escape(CGI.escape(s)) }
assert_match(%r{address\[line1\]=#{clean[a[:address1]]}}, data)
assert_match(%r{address\[line2\]=#{clean[a[:address2]]}}, data)
assert_match(%r{address\[city\]=#{clean[a[:city]]}}, data)
diff --git a/test/unit/gateways/cyber_source_test.rb b/test/unit/gateways/cyber_source_test.rb
index 82dbff6dd06..77602767222 100644
--- a/test/unit/gateways/cyber_source_test.rb
+++ b/test/unit/gateways/cyber_source_test.rb
@@ -231,7 +231,7 @@ def test_successful_check_purchase_request
end
def test_requires_error_on_tax_calculation_without_line_items
- assert_raise(ArgumentError){ @gateway.calculate_tax(@credit_card, @options.delete_if{|key, val| key == :line_items})}
+ assert_raise(ArgumentError) { @gateway.calculate_tax(@credit_card, @options.delete_if { |key, val| key == :line_items }) }
end
def test_default_currency
diff --git a/test/unit/gateways/data_cash_test.rb b/test/unit/gateways/data_cash_test.rb
index a4f24b4a457..2fb5ac40d10 100644
--- a/test/unit/gateways/data_cash_test.rb
+++ b/test/unit/gateways/data_cash_test.rb
@@ -87,11 +87,11 @@ def test_supported_card_types
end
def test_purchase_with_missing_order_id_option
- assert_raise(ArgumentError){ @gateway.purchase(100, @credit_card, {}) }
+ assert_raise(ArgumentError) { @gateway.purchase(100, @credit_card, {}) }
end
def test_authorize_with_missing_order_id_option
- assert_raise(ArgumentError){ @gateway.authorize(100, @credit_card, {}) }
+ assert_raise(ArgumentError) { @gateway.authorize(100, @credit_card, {}) }
end
def test_purchase_does_not_raise_exception_with_missing_billing_address
diff --git a/test/unit/gateways/exact_test.rb b/test/unit/gateways/exact_test.rb
index 33345b22541..664f3d27ebf 100644
--- a/test/unit/gateways/exact_test.rb
+++ b/test/unit/gateways/exact_test.rb
@@ -22,7 +22,7 @@ def test_successful_purchase
assert response.test?
assert_equal 'Transaction Normal - VER UNAVAILABLE', response.message
- ExactGateway::SENSITIVE_FIELDS.each{ |f| assert !response.params.has_key?(f.to_s) }
+ ExactGateway::SENSITIVE_FIELDS.each { |f| assert !response.params.has_key?(f.to_s) }
end
def test_successful_refund
diff --git a/test/unit/gateways/firstdata_e4_test.rb b/test/unit/gateways/firstdata_e4_test.rb
index 7758d68a0e1..e4aa2511096 100755
--- a/test/unit/gateways/firstdata_e4_test.rb
+++ b/test/unit/gateways/firstdata_e4_test.rb
@@ -38,7 +38,7 @@ def test_successful_purchase
assert response.test?
assert_equal 'Transaction Normal - Approved', response.message
- FirstdataE4Gateway::SENSITIVE_FIELDS.each{|f| assert !response.params.has_key?(f.to_s)}
+ FirstdataE4Gateway::SENSITIVE_FIELDS.each { |f| assert !response.params.has_key?(f.to_s) }
end
def test_successful_purchase_with_specified_currency
@@ -51,7 +51,7 @@ def test_successful_purchase_with_specified_currency
assert_equal 'Transaction Normal - Approved', response.message
assert_equal 'GBP', response.params['currency']
- FirstdataE4Gateway::SENSITIVE_FIELDS.each{|f| assert !response.params.has_key?(f.to_s)}
+ FirstdataE4Gateway::SENSITIVE_FIELDS.each { |f| assert !response.params.has_key?(f.to_s) }
end
def test_successful_purchase_with_token
diff --git a/test/unit/gateways/firstdata_e4_v27_test.rb b/test/unit/gateways/firstdata_e4_v27_test.rb
index fbee6ed84cf..77c51017ffe 100644
--- a/test/unit/gateways/firstdata_e4_v27_test.rb
+++ b/test/unit/gateways/firstdata_e4_v27_test.rb
@@ -40,7 +40,7 @@ def test_successful_purchase
assert response.test?
assert_equal 'Transaction Normal - Approved', response.message
- FirstdataE4V27Gateway::SENSITIVE_FIELDS.each{|f| assert !response.params.has_key?(f.to_s)}
+ FirstdataE4V27Gateway::SENSITIVE_FIELDS.each { |f| assert !response.params.has_key?(f.to_s) }
end
def test_successful_purchase_with_token
diff --git a/test/unit/gateways/migs_test.rb b/test/unit/gateways/migs_test.rb
index 807a7def5b0..f6ba3282202 100644
--- a/test/unit/gateways/migs_test.rb
+++ b/test/unit/gateways/migs_test.rb
@@ -63,10 +63,10 @@ def test_purchase_offsite_response
assert_success response
tampered_response1 = response_params.gsub('20DE', '20DF')
- assert_raise(SecurityError){@gateway.purchase_offsite_response(tampered_response1)}
+ assert_raise(SecurityError) { @gateway.purchase_offsite_response(tampered_response1) }
tampered_response2 = response_params.gsub('Locale=en', 'Locale=es')
- assert_raise(SecurityError){@gateway.purchase_offsite_response(tampered_response2)}
+ assert_raise(SecurityError) { @gateway.purchase_offsite_response(tampered_response2) }
end
def test_scrub
@@ -93,7 +93,7 @@ def failed_purchase_response
end
def build_response(options)
- options.collect { |key, value| "vpc_#{key}=#{CGI.escape(value.to_s)}"}.join('&')
+ options.collect { |key, value| "vpc_#{key}=#{CGI.escape(value.to_s)}" }.join('&')
end
def pre_scrubbed
diff --git a/test/unit/gateways/optimal_payment_test.rb b/test/unit/gateways/optimal_payment_test.rb
index 45d34d08ab2..f8d194e94ad 100644
--- a/test/unit/gateways/optimal_payment_test.rb
+++ b/test/unit/gateways/optimal_payment_test.rb
@@ -101,7 +101,7 @@ def test_purchase_from_any_other_country_includes_region_field
def test_purchase_with_shipping_address
@options[:shipping_address] = {:country => 'CA'}
@gateway.expects(:ssl_post).with do |url, data|
- xml = data.split('&').detect{|string| string =~ /txnRequest=/}.gsub('txnRequest=', '')
+ xml = data.split('&').detect { |string| string =~ /txnRequest=/ }.gsub('txnRequest=', '')
doc = Nokogiri::XML.parse(CGI.unescape(xml))
doc.xpath('//xmlns:shippingDetails/xmlns:country').first.text == 'CA' && doc.to_s.include?('')
end.returns(successful_purchase_response)
@@ -112,7 +112,7 @@ def test_purchase_with_shipping_address
def test_purchase_without_shipping_address
@options[:shipping_address] = nil
@gateway.expects(:ssl_post).with do |url, data|
- xml = data.split('&').detect{|string| string =~ /txnRequest=/}.gsub('txnRequest=', '')
+ xml = data.split('&').detect { |string| string =~ /txnRequest=/ }.gsub('txnRequest=', '')
doc = Nokogiri::XML.parse(CGI.unescape(xml))
doc.to_s.include?('') == false
end.returns(successful_purchase_response)
diff --git a/test/unit/gateways/pac_net_raven_test.rb b/test/unit/gateways/pac_net_raven_test.rb
index f2e66cce048..79530834e28 100644
--- a/test/unit/gateways/pac_net_raven_test.rb
+++ b/test/unit/gateways/pac_net_raven_test.rb
@@ -157,21 +157,21 @@ def test_failed_void
end
def test_argument_error_prn
- exception = assert_raises(ArgumentError){
+ exception = assert_raises(ArgumentError) {
PacNetRavenGateway.new(:user => 'user', :secret => 'secret')
}
assert_equal 'Missing required parameter: prn', exception.message
end
def test_argument_error_user
- exception = assert_raises(ArgumentError){
+ exception = assert_raises(ArgumentError) {
PacNetRavenGateway.new(:secret => 'secret', :prn => 123456)
}
assert_equal 'Missing required parameter: user', exception.message
end
def test_argument_error_secret
- exception = assert_raises(ArgumentError){
+ exception = assert_raises(ArgumentError) {
PacNetRavenGateway.new(:user => 'user', :prn => 123456)
}
assert_equal 'Missing required parameter: secret', exception.message
diff --git a/test/unit/gateways/realex_test.rb b/test/unit/gateways/realex_test.rb
index 8eb73a2ed5b..b0b5e92859b 100644
--- a/test/unit/gateways/realex_test.rb
+++ b/test/unit/gateways/realex_test.rb
@@ -540,6 +540,6 @@ def assert_xml_equal_recursive(a, b)
assert_equal a1.name, b1.name
assert_equal a1.value, b1.value
end
- a.children.zip(b.children).all?{|a1, b1| assert_xml_equal_recursive(a1, b1)}
+ a.children.zip(b.children).all? { |a1, b1| assert_xml_equal_recursive(a1, b1) }
end
end
diff --git a/test/unit/gateways/securion_pay_test.rb b/test/unit/gateways/securion_pay_test.rb
index 198c2c920f8..06fbe0ff622 100644
--- a/test/unit/gateways/securion_pay_test.rb
+++ b/test/unit/gateways/securion_pay_test.rb
@@ -202,7 +202,7 @@ def test_successful_full_refund
assert response.params['refunded']
assert_equal 0, response.params['amount']
assert_equal 1, response.params['refunds'].size
- assert_equal @amount, response.params['refunds'].map{|r| r['amount']}.sum
+ assert_equal @amount, response.params['refunds'].map { |r| r['amount'] }.sum
assert_equal 'char_DQca5ZjbewP2Oe0lIsNe4EXP', response.authorization
assert response.test?
end
@@ -215,7 +215,7 @@ def test_successful_partially_refund
assert_success response
assert response.params['refunded']
assert_equal @amount - @refund_amount, response.params['amount']
- assert_equal @refund_amount, response.params['refunds'].map{|r| r['amount']}.sum
+ assert_equal @refund_amount, response.params['refunds'].map { |r| r['amount'] }.sum
assert_equal 'char_oVnJ1j6fZqOvnopBBvlnpEuX', response.authorization
assert response.test?
end
diff --git a/test/unit/gateways/stripe_test.rb b/test/unit/gateways/stripe_test.rb
index b19b6e1fc74..34b53e17927 100644
--- a/test/unit/gateways/stripe_test.rb
+++ b/test/unit/gateways/stripe_test.rb
@@ -1071,7 +1071,7 @@ def test_gateway_without_credentials
end
def test_metadata_header
- @gateway.expects(:ssl_request).once.with {|method, url, post, headers|
+ @gateway.expects(:ssl_request).once.with { |method, url, post, headers|
headers && headers['X-Stripe-Client-User-Metadata'] == {:ip => '1.1.1.1'}.to_json
}.returns(successful_purchase_response)
@@ -1079,7 +1079,7 @@ def test_metadata_header
end
def test_optional_version_header
- @gateway.expects(:ssl_request).once.with {|method, url, post, headers|
+ @gateway.expects(:ssl_request).once.with { |method, url, post, headers|
headers && headers['Stripe-Version'] == '2013-10-29'
}.returns(successful_purchase_response)
@@ -1087,7 +1087,7 @@ def test_optional_version_header
end
def test_optional_idempotency_key_header
- @gateway.expects(:ssl_request).once.with {|method, url, post, headers|
+ @gateway.expects(:ssl_request).once.with { |method, url, post, headers|
headers && headers['Idempotency-Key'] == 'test123'
}.returns(successful_purchase_response)
@@ -1096,7 +1096,7 @@ def test_optional_idempotency_key_header
end
def test_optional_idempotency_on_void
- @gateway.expects(:ssl_request).once.with {|method, url, post, headers|
+ @gateway.expects(:ssl_request).once.with { |method, url, post, headers|
headers && headers['Idempotency-Key'] == 'test123'
}.returns(successful_purchase_response(true))
@@ -1119,7 +1119,7 @@ def test_optional_idempotency_on_verify
def test_initialize_gateway_with_version
@gateway = StripeGateway.new(:login => 'login', :version => '2013-12-03')
- @gateway.expects(:ssl_request).once.with {|method, url, post, headers|
+ @gateway.expects(:ssl_request).once.with { |method, url, post, headers|
headers && headers['Stripe-Version'] == '2013-12-03'
}.returns(successful_purchase_response)
diff --git a/test/unit/gateways/webpay_test.rb b/test/unit/gateways/webpay_test.rb
index d0163560e37..25123a5623b 100644
--- a/test/unit/gateways/webpay_test.rb
+++ b/test/unit/gateways/webpay_test.rb
@@ -158,7 +158,7 @@ def test_gateway_without_credentials
end
def test_metadata_header
- @gateway.expects(:ssl_request).once.with {|method, url, post, headers|
+ @gateway.expects(:ssl_request).once.with { |method, url, post, headers|
headers && headers['X-Webpay-Client-User-Metadata'] == {:ip => '1.1.1.1'}.to_json
}.returns(successful_purchase_response)
diff --git a/test/unit/gateways/worldpay_test.rb b/test/unit/gateways/worldpay_test.rb
index a5e6cb611d2..cc4eee1f918 100644
--- a/test/unit/gateways/worldpay_test.rb
+++ b/test/unit/gateways/worldpay_test.rb
@@ -112,7 +112,7 @@ def test_purchase_does_not_run_inquiry
end.respond_with(successful_capture_response)
assert_success response
- assert_equal(%w(authorize capture), response.responses.collect{|e| e.params['action']})
+ assert_equal(%w(authorize capture), response.responses.collect { |e| e.params['action'] })
end
def test_successful_void
diff --git a/test/unit/multi_response_test.rb b/test/unit/multi_response_test.rb
index 82e8735e962..a60062d0003 100644
--- a/test/unit/multi_response_test.rb
+++ b/test/unit/multi_response_test.rb
@@ -12,8 +12,8 @@ def test_processes_sub_requests
r1 = Response.new(true, '1', {})
r2 = Response.new(true, '2', {})
m = MultiResponse.run do |r|
- r.process{r1}
- r.process{r2}
+ r.process { r1 }
+ r.process { r2 }
end
assert_equal [r1, r2], m.responses
end
@@ -22,8 +22,8 @@ def test_run_convenience_method
r1 = Response.new(true, '1', {})
r2 = Response.new(true, '2', {})
m = MultiResponse.run do |r|
- r.process{r1}
- r.process{r2}
+ r.process { r1 }
+ r.process { r2 }
end
assert_equal [r1, r2], m.responses
end
@@ -42,7 +42,7 @@ def test_proxies_last_request
:error_code => :card_declined,
:fraud_review => true
)
- m.process{r1}
+ m.process { r1 }
assert_equal({'one' => 1}, m.params)
assert_equal '1', m.message
assert m.test
@@ -63,7 +63,7 @@ def test_proxies_last_request
:cvv_result => 'CVV2',
:fraud_review => false
)
- m.process{r2}
+ m.process { r2 }
assert_equal({'two' => 2}, m.params)
assert_equal '2', m.message
assert !m.test
@@ -87,7 +87,7 @@ def test_proxies_first_request_if_marked
:cvv_result => 'CVV1',
:fraud_review => true
)
- m.process{r1}
+ m.process { r1 }
assert_equal({'one' => 1}, m.params)
assert_equal '1', m.message
assert m.test
@@ -107,7 +107,7 @@ def test_proxies_first_request_if_marked
:cvv_result => 'CVV2',
:fraud_review => false
)
- m.process{r2}
+ m.process { r2 }
assert_equal({'one' => 1}, m.params)
assert_equal '1', m.message
assert m.test
@@ -124,9 +124,9 @@ def test_primary_response_always_returns_the_last_response_on_failure
r1 = Response.new(true, '1', {}, {})
r2 = Response.new(false, '2', {}, {})
r3 = Response.new(false, '3', {}, {})
- m.process{r1}
- m.process{r2}
- m.process{r3}
+ m.process { r1 }
+ m.process { r2 }
+ m.process { r3 }
assert_equal r2, m.primary_response
assert_equal '2', m.message
end
@@ -135,8 +135,8 @@ def test_stops_processing_upon_failure
r1 = Response.new(false, '1', {})
r2 = Response.new(true, '2', {})
m = MultiResponse.run do |r|
- r.process{r1}
- r.process{r2}
+ r.process { r1 }
+ r.process { r2 }
end
assert !m.success?
assert_equal [r1], m.responses
@@ -147,12 +147,12 @@ def test_merges_sub_multi_responses
r2 = Response.new(true, '2', {})
r3 = Response.new(true, '3', {})
m1 = MultiResponse.run do |r|
- r.process{r1}
- r.process{r2}
+ r.process { r1 }
+ r.process { r2 }
end
m = MultiResponse.run do |r|
- r.process{m1}
- r.process{r3}
+ r.process { m1 }
+ r.process { r3 }
end
assert_equal [r1, r2, r3], m.responses
end
@@ -161,12 +161,12 @@ def test_handles_ignores_optional_request_result
m = MultiResponse.new
r1 = Response.new(true, '1')
- m.process{r1}
+ m.process { r1 }
assert_equal '1', m.message
assert_equal [r1], m.responses
r2 = Response.new(false, '2')
- m.process(:ignore_result){r2}
+ m.process(:ignore_result) { r2 }
assert_equal '1', m.message
assert_equal [r1, r2], m.responses
From 34f48ad6d1db4d655259e185c1d2363958ba00ff Mon Sep 17 00:00:00 2001
From: Niaja
Date: Wed, 21 Nov 2018 10:51:22 -0500
Subject: [PATCH 0191/2234] Forte: Allow void on capture
Forte uses different transaction id's for captures. When trying to void
a capture this results in a error. This saves the original auth
transaction id and authorization id in the capture authorization so the original auth will be voided
or refunded.
Loaded suite test/unit/gateways/forte_test
20 tests, 67 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Loaded suite test/remote/gateways/remote_forte_test
21 tests, 59 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/forte.rb | 18 +++++++++++-------
test/remote/gateways/remote_forte_test.rb | 16 ++++++++++++++++
3 files changed, 28 insertions(+), 7 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 6888977fb1e..deb927532a8 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -10,6 +10,7 @@
* Cenpos: update supported countries [bpollack] #3055
* CyberSource: update supported countries [bpollack] #3055
* MiGS: update supported countries [bpollack] #3055
+* Forte: Allow void on capture #3059
== Version 1.86.0 (October 26, 2018)
* UsaEpayTransaction: Support UMcheckformat option for echecks [dtykocki] #3002
diff --git a/lib/active_merchant/billing/gateways/forte.rb b/lib/active_merchant/billing/gateways/forte.rb
index 12b2e6e3308..bdc06c7a3f5 100644
--- a/lib/active_merchant/billing/gateways/forte.rb
+++ b/lib/active_merchant/billing/gateways/forte.rb
@@ -191,7 +191,7 @@ def commit(type, parameters)
success_from(response),
message_from(response),
response,
- authorization: authorization_from(response),
+ authorization: authorization_from(response, parameters),
avs_result: AVSResult.new(code: response['response']['avs_result']),
cvv_result: CVVResult.new(response['response']['cvv_code']),
test: test?
@@ -219,8 +219,12 @@ def message_from(response)
response['response']['response_desc']
end
- def authorization_from(response)
- [response.try(:[], 'transaction_id'), response.try(:[], 'response').try(:[], 'authorization_code')].join('#')
+ def authorization_from(response, parameters)
+ if parameters[:action] == 'capture'
+ [response['transaction_id'], response.dig('response', 'authorization_code'), parameters[:transaction_id], parameters[:authorization_code]].join('#')
+ else
+ [response['transaction_id'], response.dig('response', 'authorization_code')].join('#')
+ end
end
def endpoint
@@ -253,13 +257,13 @@ def split_authorization(authorization)
end
def authorization_code_from(authorization)
- _, authorization_code = split_authorization(authorization)
- authorization_code
+ _, authorization_code, _, original_auth_authorization_code = split_authorization(authorization)
+ original_auth_authorization_code.present? ? original_auth_authorization_code : authorization_code
end
def transaction_id_from(authorization)
- transaction_id, _ = split_authorization(authorization)
- transaction_id
+ transaction_id, _, original_auth_transaction_id, _= split_authorization(authorization)
+ original_auth_transaction_id.present? ? original_auth_transaction_id : transaction_id
end
end
end
diff --git a/test/remote/gateways/remote_forte_test.rb b/test/remote/gateways/remote_forte_test.rb
index 4be212bd5c7..8a2df5bccc8 100644
--- a/test/remote/gateways/remote_forte_test.rb
+++ b/test/remote/gateways/remote_forte_test.rb
@@ -82,6 +82,22 @@ def test_successful_authorize_and_capture
assert_equal 'APPROVED', capture.message
end
+ def test_successful_authorize_capture_void
+ auth = @gateway.authorize(@amount, @credit_card, @options)
+ assert_success auth
+
+ wait_for_authorization_to_clear
+
+ assert capture = @gateway.capture(@amount, auth.authorization, @options)
+ assert_success capture
+ assert_match auth.authorization.split('#')[0], capture.authorization
+ assert_match auth.authorization.split('#')[1], capture.authorization
+ assert_equal 'APPROVED', capture.message
+
+ void = @gateway.void(capture.authorization)
+ assert_success void
+ end
+
def test_failed_authorize
@amount = 1985
response = @gateway.authorize(@amount, @declined_card, @options)
From ad6ffd468cb0e80405c668c430aeb2a647da73d2 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 22 Nov 2018 09:30:44 -0500
Subject: [PATCH 0192/2234] Upgrade RuboCop
---
.rubocop_todo.yml | 238 +++++++++++++++++++++++++++-------------------
Gemfile | 2 +-
2 files changed, 141 insertions(+), 99 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 10ed49082bc..25af39afb54 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
-# on 2018-06-26 11:27:33 -0400 using RuboCop version 0.57.2.
+# on 2018-11-20 16:45:49 -0500 using RuboCop version 0.60.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
@@ -14,121 +14,149 @@ Gemspec/OrderedDependencies:
Exclude:
- 'activemerchant.gemspec'
-# Offense count: 426
+# Offense count: 1828
+# Cop supports --auto-correct.
+# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
+# SupportedHashRocketStyles: key, separator, table
+# SupportedColonStyles: key, separator, table
+# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
+Layout/AlignHash:
+ Enabled: false
+
+# Offense count: 57
# Cop supports --auto-correct.
Layout/ClosingHeredocIndentation:
Enabled: false
-# Offense count: 165
+# Offense count: 167
+# Cop supports --auto-correct.
+Layout/EmptyLineAfterGuardClause:
+ Enabled: false
+
+# Offense count: 173
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only
Layout/EmptyLinesAroundClassBody:
Enabled: false
-# Offense count: 40
+# Offense count: 39
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleAlignWith, AutoCorrect, Severity.
# SupportedStylesAlignWith: keyword, variable, start_of_line
Layout/EndAlignment:
Enabled: false
-# Offense count: 191
+# Offense count: 174
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment.
Layout/ExtraSpacing:
Enabled: false
-# Offense count: 122
+# Offense count: 105
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses
Layout/FirstParameterIndentation:
Enabled: false
-# Offense count: 253
+# Offense count: 255
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: special_inside_parentheses, consistent, align_braces
Layout/IndentHash:
Enabled: false
-# Offense count: 387
+# Offense count: 392
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent
Layout/IndentHeredoc:
Enabled: false
-# Offense count: 97
+# Offense count: 92
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: normal, rails
Layout/IndentationConsistency:
Enabled: false
-# Offense count: 197
+# Offense count: 193
# Cop supports --auto-correct.
# Configuration parameters: Width, IgnoredPatterns.
Layout/IndentationWidth:
Enabled: false
-# Offense count: 6
+# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: symmetrical, new_line, same_line
Layout/MultilineArrayBraceLayout:
Exclude:
- 'lib/active_merchant/billing/gateways/optimal_payment.rb'
- - 'test/remote/gateways/remote_linkpoint_test.rb'
- - 'test/remote/gateways/remote_orbital_test.rb'
- - 'test/remote/gateways/remote_payflow_express_test.rb'
-# Offense count: 42
+# Offense count: 36
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: symmetrical, new_line, same_line
Layout/MultilineHashBraceLayout:
Enabled: false
-# Offense count: 234
+# Offense count: 232
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: symmetrical, new_line, same_line
Layout/MultilineMethodCallBraceLayout:
Enabled: false
-# Offense count: 35
+# Offense count: 24
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: aligned, indented
Layout/MultilineOperationIndentation:
Exclude:
- 'lib/active_merchant/billing/credit_card_methods.rb'
- - 'lib/active_merchant/billing/gateways/commercegate.rb'
- 'lib/active_merchant/billing/gateways/iridium.rb'
- 'lib/active_merchant/billing/gateways/moneris.rb'
- 'lib/active_merchant/billing/gateways/moneris_us.rb'
- 'lib/active_merchant/billing/gateways/orbital.rb'
- 'lib/active_merchant/billing/gateways/redsys.rb'
- - 'test/unit/gateways/barclays_epdq_extra_plus_test.rb'
- 'test/unit/gateways/braintree_blue_test.rb'
- - 'test/unit/gateways/ogone_test.rb'
- 'test/unit/gateways/skip_jack_test.rb'
-# Offense count: 638
+# Offense count: 15
+# Cop supports --auto-correct.
+Layout/RescueEnsureAlignment:
+ Exclude:
+ - 'lib/active_merchant/billing/gateways/balanced.rb'
+ - 'lib/active_merchant/billing/gateways/clearhaus.rb'
+ - 'lib/active_merchant/billing/gateways/culqi.rb'
+ - 'lib/active_merchant/billing/gateways/eway_managed.rb'
+ - 'lib/active_merchant/billing/gateways/fat_zebra.rb'
+ - 'lib/active_merchant/billing/gateways/hps.rb'
+ - 'lib/active_merchant/billing/gateways/iveri.rb'
+ - 'lib/active_merchant/billing/gateways/kushki.rb'
+ - 'lib/active_merchant/billing/gateways/merchant_e_solutions.rb'
+ - 'lib/active_merchant/billing/gateways/netbanx.rb'
+ - 'lib/active_merchant/billing/gateways/opp.rb'
+ - 'lib/active_merchant/billing/gateways/orbital.rb'
+ - 'lib/active_merchant/billing/gateways/pay_junction_v2.rb'
+ - 'lib/active_merchant/billing/gateways/quickbooks.rb'
+ - 'lib/active_merchant/billing/gateways/trans_first_transaction_express.rb'
+
+# Offense count: 649
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: space, no_space
Layout/SpaceAroundEqualsInParameterDefault:
Enabled: false
-# Offense count: 105
+# Offense count: 104
# Cop supports --auto-correct.
Layout/SpaceAroundKeyword:
Enabled: false
-# Offense count: 802
+# Offense count: 782
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment.
Layout/SpaceAroundOperators:
@@ -161,7 +189,7 @@ Layout/SpaceInsideHashLiteralBraces:
Layout/SpaceInsidePercentLiteralDelimiters:
Enabled: false
-# Offense count: 148
+# Offense count: 150
# Configuration parameters: AllowSafeAssignment.
Lint/AssignmentInCondition:
Enabled: false
@@ -182,34 +210,29 @@ Lint/RescueException:
Exclude:
- 'lib/active_merchant/billing/gateways/quantum.rb'
-# Offense count: 1453
+# Offense count: 1502
# Cop supports --auto-correct.
# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
Lint/UnusedBlockArgument:
Enabled: false
-# Offense count: 283
+# Offense count: 284
# Cop supports --auto-correct.
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods.
Lint/UnusedMethodArgument:
Enabled: false
-# Offense count: 1
-# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods.
-Lint/UselessAccessModifier:
- Exclude:
- - 'lib/active_merchant/network_connection_retries.rb'
-
-# Offense count: 1409
+# Offense count: 1418
Metrics/AbcSize:
Max: 192
# Offense count: 26
# Configuration parameters: CountComments, ExcludedMethods.
+# ExcludedMethods: refine
Metrics/BlockLength:
Max: 54
-# Offense count: 12
+# Offense count: 9
# Configuration parameters: CountBlocks.
Metrics/BlockNesting:
Max: 6
@@ -218,8 +241,8 @@ Metrics/BlockNesting:
Metrics/CyclomaticComplexity:
Max: 36
-# Offense count: 1741
-# Configuration parameters: CountComments.
+# Offense count: 1793
+# Configuration parameters: CountComments, ExcludedMethods.
Metrics/MethodLength:
Max: 163
@@ -228,11 +251,9 @@ Metrics/MethodLength:
Metrics/ParameterLists:
Max: 6
-# Offense count: 126
+# Offense count: 129
Metrics/PerceivedComplexity:
- Max: 32
- Exclude:
- - 'lib/active_merchant/billing/gateways/braintree_blue.rb'
+ Max: 33
# Offense count: 6
Naming/AccessorMethodName:
@@ -246,7 +267,7 @@ Naming/ConstantName:
Exclude:
- 'test/test_helper.rb'
-# Offense count: 45
+# Offense count: 46
# Configuration parameters: EnforcedStyle.
# SupportedStyles: lowercase, uppercase
Naming/HeredocDelimiterCase:
@@ -264,6 +285,8 @@ Naming/HeredocDelimiterNaming:
Enabled: false
# Offense count: 1
+# Configuration parameters: EnforcedStyleForLeadingUnderscores.
+# SupportedStylesForLeadingUnderscores: disallowed, required, optional
Naming/MemoizedInstanceVariableName:
Exclude:
- 'lib/active_merchant/billing/compatibility.rb'
@@ -299,7 +322,7 @@ Naming/PredicateName:
# Offense count: 14
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
-# AllowedNames: io, id, to, by, on, in, at
+# AllowedNames: io, id, to, by, on, in, at, ip, db
Naming/UncommunicativeMethodParamName:
Exclude:
- 'lib/active_merchant/billing/gateways/blue_snap.rb'
@@ -312,13 +335,12 @@ Naming/UncommunicativeMethodParamName:
- 'test/unit/gateways/paypal/paypal_common_api_test.rb'
- 'test/unit/gateways/realex_test.rb'
-# Offense count: 51
+# Offense count: 49
# Configuration parameters: EnforcedStyle.
# SupportedStyles: snake_case, camelCase
Naming/VariableName:
Exclude:
- 'lib/active_merchant/billing/gateways/cyber_source.rb'
- - 'lib/active_merchant/billing/gateways/ideal/ideal_base.rb'
- 'lib/active_merchant/billing/gateways/iridium.rb'
- 'lib/active_merchant/billing/gateways/latitude19.rb'
- 'lib/active_merchant/billing/gateways/optimal_payment.rb'
@@ -351,14 +373,13 @@ Performance/RedundantMatch:
- 'lib/active_merchant/billing/gateways/opp.rb'
- 'test/unit/gateways/payu_latam_test.rb'
-# Offense count: 12
+# Offense count: 11
# Cop supports --auto-correct.
Performance/StringReplacement:
Exclude:
- 'lib/active_merchant/billing/compatibility.rb'
- 'lib/active_merchant/billing/gateways/card_connect.rb'
- 'lib/active_merchant/billing/gateways/firstdata_e4.rb'
- - 'lib/active_merchant/billing/gateways/ideal/ideal_base.rb'
- 'lib/active_merchant/billing/gateways/merchant_ware.rb'
- 'lib/active_merchant/billing/gateways/merchant_ware_version_four.rb'
- 'lib/active_merchant/billing/gateways/orbital.rb'
@@ -429,13 +450,12 @@ Style/Attr:
Exclude:
- 'test/unit/gateways/forte_test.rb'
-# Offense count: 3
+# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: percent_q, bare_percent
Style/BarePercentLiterals:
Exclude:
- - 'test/unit/gateways/clearhaus_test.rb'
- 'test/unit/gateways/eway_rapid_test.rb'
- 'test/unit/gateways/orbital_test.rb'
@@ -447,7 +467,7 @@ Style/BlockComments:
- 'test/remote/gateways/remote_netpay_test.rb'
- 'test/remote/gateways/remote_payu_in_test.rb'
-# Offense count: 75
+# Offense count: 77
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods.
# SupportedStyles: line_count_based, semantic, braces_for_chaining
@@ -457,7 +477,7 @@ Style/BlockComments:
Style/BlockDelimiters:
Enabled: false
-# Offense count: 443
+# Offense count: 440
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: braces, no_braces, context_dependent
@@ -479,7 +499,7 @@ Style/ClassAndModuleChildren:
- 'test/unit/gateways/optimal_payment_test.rb'
- 'test/unit/gateways/realex_test.rb'
-# Offense count: 35
+# Offense count: 30
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: is_a?, kind_of?
@@ -510,13 +530,12 @@ Style/ColonMethodCall:
- 'lib/active_merchant/billing/gateways/nmi.rb'
- 'test/unit/gateways/quickpay_v4to7_test.rb'
-# Offense count: 6
+# Offense count: 5
# Cop supports --auto-correct.
# Configuration parameters: Keywords.
# Keywords: TODO, FIXME, OPTIMIZE, HACK, REVIEW
Style/CommentAnnotation:
Exclude:
- - 'lib/active_merchant/billing/gateways/authorize_net_cim.rb'
- 'test/remote/gateways/remote_usa_epay_advanced_test.rb'
- 'test/unit/gateways/authorize_net_cim_test.rb'
- 'test/unit/gateways/usa_epay_advanced_test.rb'
@@ -530,7 +549,7 @@ Style/CommentedKeyword:
- 'test/remote/gateways/remote_cardknox_test.rb'
- 'test/unit/gateways/cardknox_test.rb'
-# Offense count: 23
+# Offense count: 22
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions.
# SupportedStyles: assign_to_condition, assign_inside_condition
@@ -538,6 +557,7 @@ Style/ConditionalAssignment:
Enabled: false
# Offense count: 7
+# Configuration parameters: AllowCoercion.
Style/DateTime:
Exclude:
- 'test/remote/gateways/remote_first_pay_test.rb'
@@ -546,7 +566,7 @@ Style/DateTime:
- 'test/unit/gateways/orbital_test.rb'
- 'test/unit/gateways/paypal/paypal_common_api_test.rb'
-# Offense count: 210
+# Offense count: 211
Style/Documentation:
Enabled: false
@@ -621,7 +641,7 @@ Style/EmptyMethod:
- 'test/unit/gateways/world_net_test.rb'
- 'test/unit/gateways/worldpay_online_payments_test.rb'
-# Offense count: 24
+# Offense count: 23
# Cop supports --auto-correct.
Style/Encoding:
Enabled: false
@@ -642,6 +662,7 @@ Style/ExpandPathArguments:
- 'test/test_helper.rb'
# Offense count: 11
+# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: each, for
Style/For:
@@ -653,7 +674,7 @@ Style/For:
- 'lib/active_merchant/billing/gateways/usa_epay_transaction.rb'
- 'test/remote/gateways/remote_orbital_test.rb'
-# Offense count: 96
+# Offense count: 97
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: format, sprintf, percent
@@ -676,7 +697,7 @@ Style/FormatStringToken:
- 'test/unit/gateways/firstdata_e4_test.rb'
- 'test/unit/gateways/safe_charge_test.rb'
-# Offense count: 677
+# Offense count: 679
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: when_needed, always, never
@@ -693,12 +714,12 @@ Style/GlobalVars:
- 'test/unit/gateways/finansbank_test.rb'
- 'test/unit/gateways/garanti_test.rb'
-# Offense count: 192
+# Offense count: 196
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Enabled: false
-# Offense count: 7424
+# Offense count: 7482
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
@@ -712,7 +733,7 @@ Style/IdenticalConditionalBranches:
- 'lib/active_merchant/billing/gateways/litle.rb'
- 'lib/active_merchant/billing/gateways/payu_latam.rb'
-# Offense count: 15
+# Offense count: 14
Style/IfInsideElse:
Exclude:
- 'lib/active_merchant/billing/credit_card.rb'
@@ -731,11 +752,10 @@ Style/IfInsideElse:
Style/IfUnlessModifier:
Enabled: false
-# Offense count: 3
+# Offense count: 1
Style/IfUnlessModifierOfIfUnless:
Exclude:
- 'lib/active_merchant/billing/gateways/merchant_e_solutions.rb'
- - 'lib/active_merchant/posts_data.rb'
# Offense count: 2
# Cop supports --auto-correct.
@@ -745,27 +765,39 @@ Style/InverseMethods:
- 'lib/active_merchant/billing/gateways/ogone.rb'
- 'lib/active_merchant/billing/gateways/worldpay.rb'
-# Offense count: 31
+# Offense count: 32
# Cop supports --auto-correct.
# Configuration parameters: IgnoredMethods.
Style/MethodCallWithoutArgsParentheses:
Enabled: false
-# Offense count: 626
+# Offense count: 656
Style/MultilineBlockChain:
Enabled: false
-# Offense count: 20
+# Offense count: 15
# Cop supports --auto-correct.
Style/MultilineIfModifier:
- Enabled: false
+ Exclude:
+ - 'lib/active_merchant/billing/compatibility.rb'
+ - 'lib/active_merchant/billing/gateways/authorize_net_cim.rb'
+ - 'lib/active_merchant/billing/gateways/bank_frick.rb'
+ - 'lib/active_merchant/billing/gateways/cenpos.rb'
+ - 'lib/active_merchant/billing/gateways/efsnet.rb'
+ - 'lib/active_merchant/billing/gateways/eway.rb'
+ - 'lib/active_merchant/billing/gateways/flo2cash.rb'
+ - 'lib/active_merchant/billing/gateways/itransact.rb'
+ - 'lib/active_merchant/billing/gateways/monei.rb'
+ - 'lib/active_merchant/billing/gateways/optimal_payment.rb'
+ - 'lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb'
+ - 'lib/active_merchant/billing/gateways/psigate.rb'
+ - 'lib/active_merchant/billing/gateways/realex.rb'
-# Offense count: 7
+# Offense count: 6
# Cop supports --auto-correct.
Style/MultilineIfThen:
Exclude:
- 'lib/active_merchant/billing/gateways/eway_managed.rb'
- - 'lib/active_merchant/connection.rb'
# Offense count: 4
Style/MultilineTernaryOperator:
@@ -780,12 +812,12 @@ Style/MultipleComparison:
Exclude:
- 'lib/active_merchant/billing/gateways/worldpay_online_payments.rb'
-# Offense count: 516
+# Offense count: 530
# Cop supports --auto-correct.
Style/MutableConstant:
Enabled: false
-# Offense count: 21
+# Offense count: 17
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: both, prefix, postfix
@@ -793,7 +825,6 @@ Style/NegatedIf:
Exclude:
- 'lib/active_merchant/billing/credit_card.rb'
- 'lib/active_merchant/billing/gateways/adyen.rb'
- - 'lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb'
- 'lib/active_merchant/billing/gateways/itransact.rb'
- 'lib/active_merchant/billing/gateways/iveri.rb'
- 'lib/active_merchant/billing/gateways/ogone.rb'
@@ -803,12 +834,11 @@ Style/NegatedIf:
- 'lib/support/ssl_verify.rb'
- 'test/remote/gateways/remote_paypal_test.rb'
-# Offense count: 3
+# Offense count: 1
# Cop supports --auto-correct.
Style/NestedModifier:
Exclude:
- 'lib/active_merchant/billing/gateways/merchant_e_solutions.rb'
- - 'lib/active_merchant/posts_data.rb'
# Offense count: 2
# Cop supports --auto-correct.
@@ -827,14 +857,15 @@ Style/Next:
- 'lib/active_merchant/billing/gateways/authorize_net.rb'
- 'lib/support/outbound_hosts.rb'
-# Offense count: 6
+# Offense count: 5
# Cop supports --auto-correct.
+# Configuration parameters: EnforcedStyle.
+# SupportedStyles: predicate, comparison
Style/NilComparison:
Exclude:
- 'lib/active_merchant/billing/gateways/card_stream.rb'
- 'lib/active_merchant/billing/gateways/litle.rb'
- 'lib/active_merchant/billing/gateways/telr.rb'
- - 'lib/active_merchant/billing/gateways/usa_epay_advanced.rb'
- 'test/unit/gateways/braintree_blue_test.rb'
- 'test/unit/gateways/stripe_test.rb'
@@ -853,7 +884,7 @@ Style/Not:
- 'test/test_helper.rb'
- 'test/unit/gateways/braintree_blue_test.rb'
-# Offense count: 20
+# Offense count: 19
# Cop supports --auto-correct.
# Configuration parameters: EnforcedOctalStyle.
# SupportedOctalStyles: zero_with_o, zero_only
@@ -873,15 +904,15 @@ Style/NumericLiteralPrefix:
- 'test/unit/gateways/opp_test.rb'
- 'test/unit/gateways/pay_junction_v2_test.rb'
-# Offense count: 446
+# Offense count: 466
# Cop supports --auto-correct.
# Configuration parameters: Strict.
Style/NumericLiterals:
MinDigits: 17
-# Offense count: 40
+# Offense count: 41
# Cop supports --auto-correct.
-# Configuration parameters: AutoCorrect, EnforcedStyle.
+# Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods.
# SupportedStyles: predicate, comparison
Style/NumericPredicate:
Enabled: false
@@ -897,7 +928,7 @@ Style/OrAssignment:
Style/ParallelAssignment:
Enabled: false
-# Offense count: 877
+# Offense count: 879
# Cop supports --auto-correct.
# Configuration parameters: PreferredDelimiters.
Style/PercentLiteralDelimiters:
@@ -912,7 +943,7 @@ Style/PerlBackrefs:
- 'lib/support/outbound_hosts.rb'
- 'test/unit/gateways/payu_in_test.rb'
-# Offense count: 94
+# Offense count: 96
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: short, verbose
@@ -926,25 +957,25 @@ Style/Proc:
- 'test/unit/credit_card_methods_test.rb'
- 'test/unit/gateways/nab_transact_test.rb'
-# Offense count: 33
+# Offense count: 31
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: compact, exploded
Style/RaiseArgs:
Enabled: false
-# Offense count: 87
+# Offense count: 86
# Cop supports --auto-correct.
# Configuration parameters: AllowMultipleReturnValues.
Style/RedundantReturn:
Enabled: false
-# Offense count: 173
+# Offense count: 179
# Cop supports --auto-correct.
Style/RedundantSelf:
Enabled: false
-# Offense count: 1178
+# Offense count: 1209
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, AllowInnerSlashes.
# SupportedStyles: slashes, percent_r, mixed
@@ -1007,14 +1038,28 @@ Style/SingleLineMethods:
Style/SpecialGlobalVars:
EnforcedStyle: use_perl_names
-# Offense count: 31
+# Offense count: 27
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: single_quotes, double_quotes
Style/StringLiteralsInInterpolation:
- Enabled: false
+ Exclude:
+ - 'lib/active_merchant/billing/gateways/banwire.rb'
+ - 'lib/active_merchant/billing/gateways/cams.rb'
+ - 'lib/active_merchant/billing/gateways/checkout_v2.rb'
+ - 'lib/active_merchant/billing/gateways/credorax.rb'
+ - 'lib/active_merchant/billing/gateways/digitzs.rb'
+ - 'lib/active_merchant/billing/gateways/ebanx.rb'
+ - 'lib/active_merchant/billing/gateways/merchant_one.rb'
+ - 'lib/active_merchant/billing/gateways/micropayment.rb'
+ - 'lib/active_merchant/billing/gateways/pagarme.rb'
+ - 'lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb'
+ - 'lib/active_merchant/billing/gateways/stripe.rb'
+ - 'lib/active_merchant/billing/gateways/usa_epay_advanced.rb'
+ - 'lib/active_merchant/billing/gateways/worldpay.rb'
+ - 'test/unit/gateways/eway_managed_test.rb'
-# Offense count: 307
+# Offense count: 309
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, MinSize.
# SupportedStyles: percent, brackets
@@ -1028,39 +1073,36 @@ Style/SymbolArray:
Style/TrailingCommaInArrayLiteral:
Exclude:
- 'lib/active_merchant/billing/credit_card_methods.rb'
- - 'test/remote/gateways/remote_payflow_express_test.rb'
- 'test/unit/gateways/netaxept_test.rb'
- 'test/unit/gateways/usa_epay_transaction_test.rb'
-# Offense count: 155
+# Offense count: 160
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleForMultiline.
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
Style/TrailingCommaInHashLiteral:
Enabled: false
-# Offense count: 36
+# Offense count: 38
# Cop supports --auto-correct.
# Configuration parameters: AllowNamedUnderscoreVariables.
Style/TrailingUnderscoreVariable:
Enabled: false
-# Offense count: 117
+# Offense count: 119
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, MinSize, WordRegex.
# SupportedStyles: percent, brackets
Style/WordArray:
Enabled: false
-# Offense count: 33
+# Offense count: 34
# Cop supports --auto-correct.
Style/ZeroLengthPredicate:
Enabled: false
-# Offense count: 9190
+# Offense count: 9321
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
- Max: 2484
- Exclude:
- - 'test/unit/gateways/global_collect_test.rb'
+ Max: 2602
diff --git a/Gemfile b/Gemfile
index 8fe123d5eb8..8ce730332ad 100644
--- a/Gemfile
+++ b/Gemfile
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
gemspec
gem 'jruby-openssl', :platforms => :jruby
-gem 'rubocop', '~> 0.58.1', require: false
+gem 'rubocop', '~> 0.60.0', require: false
group :test, :remote_test do
# gateway-specific dependencies, keeping these gems out of the gemspec
From 90e4c10180d03a6f88159cf33bc6a05cfcbb0c43 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Mon, 26 Nov 2018 14:54:01 -0500
Subject: [PATCH 0193/2234] Braintree Blue: actually, really, truly fix nil
address fields
Previously, on Battlestar Galactica, we only filtered out the address
if the fields were nil. But some of our library consumers like to pass
in empty strings, which we treated as actual data, whereas Braintree
Blue weirdly insists "" is not a valid address. Treat empty strings
the same as nil values.
Unit: 57 tests, 150 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote: 66 tests, 378 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
lib/active_merchant/billing/gateways/braintree_blue.rb | 5 +++--
test/remote/gateways/remote_braintree_blue_test.rb | 2 +-
test/unit/gateways/braintree_blue_test.rb | 2 +-
3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb
index 6a263624017..a3ffb37a325 100644
--- a/lib/active_merchant/billing/gateways/braintree_blue.rb
+++ b/lib/active_merchant/billing/gateways/braintree_blue.rb
@@ -39,6 +39,7 @@ module Billing #:nodoc:
#
class BraintreeBlueGateway < Gateway
include BraintreeCommon
+ include Empty
self.display_name = 'Braintree (Blue Platform)'
@@ -261,7 +262,7 @@ def add_credit_card_to_customer(credit_card, options)
}
if options[:billing_address]
address = map_address(options[:billing_address])
- parameters[:credit_card][:billing_address] = address unless address.all? { |_k, v| v.nil? }
+ parameters[:credit_card][:billing_address] = address unless address.all? { |_k, v| empty?(v) }
end
result = @braintree_gateway.credit_card.create(parameters)
@@ -309,7 +310,7 @@ def merge_credit_card_options(parameters, options)
parameters[:credit_card][:options] = valid_options
if options[:billing_address]
address = map_address(options[:billing_address])
- parameters[:credit_card][:billing_address] = address unless address.all? { |_k, v| v.nil? }
+ parameters[:credit_card][:billing_address] = address unless address.all? { |_k, v| empty?(v) }
end
parameters
end
diff --git a/test/remote/gateways/remote_braintree_blue_test.rb b/test/remote/gateways/remote_braintree_blue_test.rb
index b756c862f63..c6cd935e7db 100644
--- a/test/remote/gateways/remote_braintree_blue_test.rb
+++ b/test/remote/gateways/remote_braintree_blue_test.rb
@@ -46,7 +46,7 @@ def test_successful_authorize_with_nil_billing_address_options
:phone => '123-456-7890',
:company => nil,
:address1 => nil,
- :address2 => nil,
+ :address2 => '',
:city => nil,
:state => nil,
:zip => nil,
diff --git a/test/unit/gateways/braintree_blue_test.rb b/test/unit/gateways/braintree_blue_test.rb
index 1a0b83e24cc..0135224cd32 100644
--- a/test/unit/gateways/braintree_blue_test.rb
+++ b/test/unit/gateways/braintree_blue_test.rb
@@ -386,7 +386,7 @@ def test_store_with_nil_billing_address_options
:phone => '123-456-7890',
:company => nil,
:address1 => nil,
- :address2 => nil,
+ :address2 => '',
:city => nil,
:state => nil,
:zip => nil,
From 1253d4108a7040cfdb147d5ce6c74ea71445352d Mon Sep 17 00:00:00 2001
From: Filipe Costa
Date: Thu, 29 Nov 2018 10:58:24 -0500
Subject: [PATCH 0194/2234] Release 1.87.0
---
CHANGELOG | 22 ++++++++++++----------
lib/active_merchant/version.rb | 2 +-
2 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index deb927532a8..5198e278bed 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,15 +1,26 @@
= ActiveMerchant CHANGELOG
== HEAD
-* Clearhaus: update submission data format [bpollack] #3053
+* Barclaycard Smartpay: Improves Error Handling [deedeelavinder] #3026
+* Braintree: Fix passing phone-only billing address [curiousepic] #3025
+* Litle: Capitalize check account type [curiousepic] #3028
+* Braintree: Account for nil billing address fields [curiousepic] #3029
+* Realex: Add verify [kheang] #3030
+* Braintree: Actually account for nil address fields [curiousepic] #3032
+* Mercado Pago: do not infer card type [bpollack] #3038
+* Credorax: allow sending submerchant ID (h3 parameter) [bpollack] #3040
+* Worldpay: Pass stored credential option fields [curiousepic] #3041
* Make behavior of nil CC numbers more consistent [guaguasi] #3010
* Moneris: Adds Credential on File logic [deedeelavinder] #3042
* Adyen: Return AVS and CVC Result [nfarve] #3044
+* Paymentez: Supports phone field, does not send if empty [molbrown] #3043
* Braintree: Account for nil address with existing customer [curiousepic] #3047
* Optimal Payment: Add verify capabilities #3052
+* Moneris: Allows cof_enabled gateway to process non-cof transactions [deedeelavinder] #3051
* Cenpos: update supported countries [bpollack] #3055
* CyberSource: update supported countries [bpollack] #3055
* MiGS: update supported countries [bpollack] #3055
+* Clearhaus: update submission data format [bpollack] #3053
* Forte: Allow void on capture #3059
== Version 1.86.0 (October 26, 2018)
@@ -23,15 +34,6 @@
* Payflow Express: Add phone to returned Response [filipebarcos] #3003
* Authorize.Net: Pass some level 3 fields [curiousepic] #3022
* Add state to the netbanx payload [Girardvjonathan] #3024
-* Barclaycard Smartpay: Improves Error Handling [deedeelavinder] #3026
-* Braintree: Fix passing phone-only billing address [curiousepic] #3025
-* Litle: Capitalize check account type [curiousepic] #3028
-* Braintree: Account for nil billing address fields [curiousepic] #3029
-* Realex: Add verify [kheang] #3030
-* Braintree: Actually account for nil address fields [curiousepic] #3032
-* Credorax: allow sending submerchant ID (h3 parameter) [bpollack] #3040
-* Worldpay: Pass stored credential option fields [curiousepic] #3041
-* Paymentez: Supports phone field, does not send if empty [molbrown] #3043
== Version 1.85.0 (September 28, 2018)
* Authorize.Net: Support custom delimiter for cim [curiousepic] #3001
diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb
index 813ed5dbdd2..54f720d8bf0 100644
--- a/lib/active_merchant/version.rb
+++ b/lib/active_merchant/version.rb
@@ -1,3 +1,3 @@
module ActiveMerchant
- VERSION = '1.86.0'
+ VERSION = '1.87.0'
end
From 3408663549bc8a4fd13dbdea9632746cddf813fa Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Tue, 27 Nov 2018 11:05:30 -0500
Subject: [PATCH 0195/2234] RuboCop: fix Layout/IndentationConsistency
---
.rubocop_todo.yml | 7 -
.../billing/gateways/cardknox.rb | 16 +-
.../billing/gateways/cyber_source.rb | 26 +-
lib/active_merchant/billing/gateways/epay.rb | 18 +-
.../billing/gateways/eway_managed.rb | 26 +-
lib/active_merchant/billing/gateways/litle.rb | 2 +-
.../billing/gateways/netbilling.rb | 16 +-
.../billing/gateways/paystation.rb | 152 ++---
.../billing/gateways/quickpay/quickpay_v10.rb | 300 ++++-----
test/remote/gateways/remote_banwire_test.rb | 16 +-
test/remote/gateways/remote_cardknox_test.rb | 2 +-
.../gateways/remote_merchant_one_test.rb | 54 +-
.../remote_usa_epay_transaction_test.rb | 12 +-
test/unit/gateways/eway_managed_test.rb | 11 +-
test/unit/gateways/netbanx_test.rb | 6 +-
test/unit/gateways/orbital_test.rb | 12 +-
test/unit/gateways/paypal_express_test.rb | 48 +-
test/unit/gateways/paystation_test.rb | 614 +++++++++---------
test/unit/gateways/payway_test.rb | 54 +-
test/unit/gateways/worldpay_test.rb | 6 +-
20 files changed, 695 insertions(+), 703 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 25af39afb54..08a3231d05a 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -74,13 +74,6 @@ Layout/IndentHash:
Layout/IndentHeredoc:
Enabled: false
-# Offense count: 92
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle.
-# SupportedStyles: normal, rails
-Layout/IndentationConsistency:
- Enabled: false
-
# Offense count: 193
# Cop supports --auto-correct.
# Configuration parameters: Width, IgnoredPatterns.
diff --git a/lib/active_merchant/billing/gateways/cardknox.rb b/lib/active_merchant/billing/gateways/cardknox.rb
index 10b3976dc7d..e4dd63bba30 100644
--- a/lib/active_merchant/billing/gateways/cardknox.rb
+++ b/lib/active_merchant/billing/gateways/cardknox.rb
@@ -282,14 +282,14 @@ def parse(body)
def commit(action, source_type, parameters)
response = parse(ssl_post(live_url, post_data(COMMANDS[source_type][action], parameters)))
- Response.new(
- (response[:status] == 'Approved'),
- message_from(response),
- response,
- authorization: authorization_from(response, source_type),
- avs_result: { code: response[:avs_result_code] },
- cvv_result: response[:cvv_result_code]
- )
+ Response.new(
+ (response[:status] == 'Approved'),
+ message_from(response),
+ response,
+ authorization: authorization_from(response, source_type),
+ avs_result: { code: response[:avs_result_code] },
+ cvv_result: response[:cvv_result_code]
+ )
end
def message_from(response)
diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb
index 83f4734a5f0..9bc89b747ce 100644
--- a/lib/active_merchant/billing/gateways/cyber_source.rb
+++ b/lib/active_merchant/billing/gateways/cyber_source.rb
@@ -683,23 +683,23 @@ def lookup_country_code(country_field)
# Where we actually build the full SOAP request using builder
def build_request(body, options)
xml = Builder::XmlMarkup.new :indent => 2
- xml.instruct!
- xml.tag! 's:Envelope', {'xmlns:s' => 'http://schemas.xmlsoap.org/soap/envelope/'} do
- xml.tag! 's:Header' do
- xml.tag! 'wsse:Security', {'s:mustUnderstand' => '1', 'xmlns:wsse' => 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'} do
- xml.tag! 'wsse:UsernameToken' do
- xml.tag! 'wsse:Username', @options[:login]
- xml.tag! 'wsse:Password', @options[:password], 'Type' => 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText'
- end
+ xml.instruct!
+ xml.tag! 's:Envelope', {'xmlns:s' => 'http://schemas.xmlsoap.org/soap/envelope/'} do
+ xml.tag! 's:Header' do
+ xml.tag! 'wsse:Security', {'s:mustUnderstand' => '1', 'xmlns:wsse' => 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'} do
+ xml.tag! 'wsse:UsernameToken' do
+ xml.tag! 'wsse:Username', @options[:login]
+ xml.tag! 'wsse:Password', @options[:password], 'Type' => 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText'
end
end
- xml.tag! 's:Body', {'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema'} do
- xml.tag! 'requestMessage', {'xmlns' => "urn:schemas-cybersource-com:transaction-data-#{XSD_VERSION}"} do
- add_merchant_data(xml, options)
- xml << body
- end
+ end
+ xml.tag! 's:Body', {'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema'} do
+ xml.tag! 'requestMessage', {'xmlns' => "urn:schemas-cybersource-com:transaction-data-#{XSD_VERSION}"} do
+ add_merchant_data(xml, options)
+ xml << body
end
end
+ end
xml.target!
end
diff --git a/lib/active_merchant/billing/gateways/epay.rb b/lib/active_merchant/billing/gateways/epay.rb
index f26a9112a5d..4f33ae1afe8 100644
--- a/lib/active_merchant/billing/gateways/epay.rb
+++ b/lib/active_merchant/billing/gateways/epay.rb
@@ -252,17 +252,17 @@ def make_headers(data, soap_call)
def xml_builder(params, soap_call)
xml = Builder::XmlMarkup.new(:indent => 2)
xml.instruct!
- xml.tag! 'soap:Envelope', { 'xmlns:xsi' => 'http://schemas.xmlsoap.org/soap/envelope/',
- 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema',
- 'xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/' } do
- xml.tag! 'soap:Body' do
- xml.tag! soap_call, { 'xmlns' => "#{self.live_url}remote/payment" } do
- xml.tag! 'merchantnumber', @options[:login]
- xml.tag! 'transactionid', params[:transaction]
- xml.tag! 'amount', params[:amount].to_s if soap_call != 'delete'
- end
+ xml.tag! 'soap:Envelope', { 'xmlns:xsi' => 'http://schemas.xmlsoap.org/soap/envelope/',
+ 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema',
+ 'xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/' } do
+ xml.tag! 'soap:Body' do
+ xml.tag! soap_call, { 'xmlns' => "#{self.live_url}remote/payment" } do
+ xml.tag! 'merchantnumber', @options[:login]
+ xml.tag! 'transactionid', params[:transaction]
+ xml.tag! 'amount', params[:amount].to_s if soap_call != 'delete'
end
end
+ end
xml.target!
end
diff --git a/lib/active_merchant/billing/gateways/eway_managed.rb b/lib/active_merchant/billing/gateways/eway_managed.rb
index 2182bfac70b..9c6101d45e4 100644
--- a/lib/active_merchant/billing/gateways/eway_managed.rb
+++ b/lib/active_merchant/billing/gateways/eway_managed.rb
@@ -242,23 +242,23 @@ def soap_request(arguments, action)
end
xml = Builder::XmlMarkup.new :indent => 2
- xml.instruct!
- xml.tag! 'soap12:Envelope', {'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema', 'xmlns:soap12' => 'http://www.w3.org/2003/05/soap-envelope'} do
- xml.tag! 'soap12:Header' do
- xml.tag! 'eWAYHeader', {'xmlns' => 'https://www.eway.com.au/gateway/managedpayment'} do
- xml.tag! 'eWAYCustomerID', @options[:login]
- xml.tag! 'Username', @options[:username]
- xml.tag! 'Password', @options[:password]
- end
+ xml.instruct!
+ xml.tag! 'soap12:Envelope', {'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema', 'xmlns:soap12' => 'http://www.w3.org/2003/05/soap-envelope'} do
+ xml.tag! 'soap12:Header' do
+ xml.tag! 'eWAYHeader', {'xmlns' => 'https://www.eway.com.au/gateway/managedpayment'} do
+ xml.tag! 'eWAYCustomerID', @options[:login]
+ xml.tag! 'Username', @options[:username]
+ xml.tag! 'Password', @options[:password]
end
- xml.tag! 'soap12:Body' do |x|
- x.tag! action, {'xmlns' => 'https://www.eway.com.au/gateway/managedpayment'} do |y|
- post.each do |key, value|
- y.tag! key, value
- end
+ end
+ xml.tag! 'soap12:Body' do |x|
+ x.tag! action, {'xmlns' => 'https://www.eway.com.au/gateway/managedpayment'} do |y|
+ post.each do |key, value|
+ y.tag! key, value
end
end
end
+ end
xml.target!
end
diff --git a/lib/active_merchant/billing/gateways/litle.rb b/lib/active_merchant/billing/gateways/litle.rb
index 2adaf564609..82b35cc7af6 100644
--- a/lib/active_merchant/billing/gateways/litle.rb
+++ b/lib/active_merchant/billing/gateways/litle.rb
@@ -33,7 +33,7 @@ def purchase(money, payment_method, options={})
end
end
end
- check?(payment_method) ? commit(:echeckSales, request, money) : commit(:sale, request, money)
+ check?(payment_method) ? commit(:echeckSales, request, money) : commit(:sale, request, money)
end
def authorize(money, payment_method, options={})
diff --git a/lib/active_merchant/billing/gateways/netbilling.rb b/lib/active_merchant/billing/gateways/netbilling.rb
index 1cc79fe11fb..296d9e198ad 100644
--- a/lib/active_merchant/billing/gateways/netbilling.rb
+++ b/lib/active_merchant/billing/gateways/netbilling.rb
@@ -143,14 +143,14 @@ def add_address(post, credit_card, options)
post[:bill_state] = billing_address[:state]
end
- if shipping_address = options[:shipping_address]
- post[:ship_name1], post[:ship_name2] = split_names(shipping_address[:name])
- post[:ship_street] = shipping_address[:address1]
- post[:ship_zip] = shipping_address[:zip]
- post[:ship_city] = shipping_address[:city]
- post[:ship_country] = shipping_address[:country]
- post[:ship_state] = shipping_address[:state]
- end
+ if shipping_address = options[:shipping_address]
+ post[:ship_name1], post[:ship_name2] = split_names(shipping_address[:name])
+ post[:ship_street] = shipping_address[:address1]
+ post[:ship_zip] = shipping_address[:zip]
+ post[:ship_city] = shipping_address[:city]
+ post[:ship_country] = shipping_address[:country]
+ post[:ship_state] = shipping_address[:state]
+ end
end
def add_invoice(post, options)
diff --git a/lib/active_merchant/billing/gateways/paystation.rb b/lib/active_merchant/billing/gateways/paystation.rb
index 69a6f8c8b95..0c2afac4358 100644
--- a/lib/active_merchant/billing/gateways/paystation.rb
+++ b/lib/active_merchant/billing/gateways/paystation.rb
@@ -100,101 +100,101 @@ def scrub(transcript)
private
- def new_request
- {
- :pi => @options[:paystation_id], # paystation account id
- :gi => @options[:gateway_id], # paystation gateway id
- '2p' => 't', # two-party transaction type
- :nr => 't', # -- redirect??
- :df => 'yymm' # date format: optional sometimes, required others
- }
- end
-
- def add_customer_data(post, options)
- post[:mc] = options[:customer]
- end
+ def new_request
+ {
+ :pi => @options[:paystation_id], # paystation account id
+ :gi => @options[:gateway_id], # paystation gateway id
+ '2p' => 't', # two-party transaction type
+ :nr => 't', # -- redirect??
+ :df => 'yymm' # date format: optional sometimes, required others
+ }
+ end
- def add_invoice(post, options)
- post[:ms] = generate_unique_id
- post[:mo] = options[:description]
- post[:mr] = options[:order_id]
- end
+ def add_customer_data(post, options)
+ post[:mc] = options[:customer]
+ end
- def add_credit_card(post, credit_card)
- post[:cn] = credit_card.number
- post[:ct] = credit_card.brand
- post[:ex] = format_date(credit_card.month, credit_card.year)
- post[:cc] = credit_card.verification_value if credit_card.verification_value?
- end
+ def add_invoice(post, options)
+ post[:ms] = generate_unique_id
+ post[:mo] = options[:description]
+ post[:mr] = options[:order_id]
+ end
- def add_token(post, token)
- post[:fp] = 't' # turn on "future payments" - what paystation calls Token Billing
- post[:ft] = token
- end
+ def add_credit_card(post, credit_card)
+ post[:cn] = credit_card.number
+ post[:ct] = credit_card.brand
+ post[:ex] = format_date(credit_card.month, credit_card.year)
+ post[:cc] = credit_card.verification_value if credit_card.verification_value?
+ end
- def store_credit_card(post, options)
- post[:fp] = 't' # turn on "future payments" - what paystation calls Token Billing
- post[:fs] = 't' # tells paystation to store right now, not bill
- post[:ft] = options[:token] if options[:token] # specify a token to use that, or let Paystation generate one
- end
+ def add_token(post, token)
+ post[:fp] = 't' # turn on "future payments" - what paystation calls Token Billing
+ post[:ft] = token
+ end
- def add_authorize_flag(post, options)
- post[:pa] = 't' # tells Paystation that this is a pre-auth authorisation payment (account must be in pre-auth mode)
- end
+ def store_credit_card(post, options)
+ post[:fp] = 't' # turn on "future payments" - what paystation calls Token Billing
+ post[:fs] = 't' # tells paystation to store right now, not bill
+ post[:ft] = options[:token] if options[:token] # specify a token to use that, or let Paystation generate one
+ end
- def add_refund_specific_fields(post, authorization)
- post[:rc] = 't'
- post[:rt] = authorization
- end
+ def add_authorize_flag(post, options)
+ post[:pa] = 't' # tells Paystation that this is a pre-auth authorisation payment (account must be in pre-auth mode)
+ end
- def add_authorization_token(post, auth_token, verification_value = nil)
- post[:cp] = 't' # Capture Payment flag – tells Paystation this transaction should be treated as a capture payment
- post[:cx] = auth_token
- post[:cc] = verification_value
- end
+ def add_refund_specific_fields(post, authorization)
+ post[:rc] = 't'
+ post[:rt] = authorization
+ end
- def add_amount(post, money, options)
- post[:am] = amount(money)
- post[:cu] = options[:currency] || currency(money)
- end
+ def add_authorization_token(post, auth_token, verification_value = nil)
+ post[:cp] = 't' # Capture Payment flag – tells Paystation this transaction should be treated as a capture payment
+ post[:cx] = auth_token
+ post[:cc] = verification_value
+ end
- def parse(xml_response)
- response = {}
+ def add_amount(post, money, options)
+ post[:am] = amount(money)
+ post[:cu] = options[:currency] || currency(money)
+ end
- xml = REXML::Document.new(xml_response)
+ def parse(xml_response)
+ response = {}
- xml.elements.each("#{xml.root.name}/*") do |element|
- response[element.name.underscore.to_sym] = element.text
- end
+ xml = REXML::Document.new(xml_response)
- response
+ xml.elements.each("#{xml.root.name}/*") do |element|
+ response[element.name.underscore.to_sym] = element.text
end
- def commit(post)
- post[:tm] = 'T' if test?
- pstn_prefix_params = post.collect { |key, value| "pstn_#{key}=#{CGI.escape(value.to_s)}" }.join('&')
+ response
+ end
- data = ssl_post(self.live_url, "#{pstn_prefix_params}&paystation=_empty")
- response = parse(data)
- message = message_from(response)
+ def commit(post)
+ post[:tm] = 'T' if test?
+ pstn_prefix_params = post.collect { |key, value| "pstn_#{key}=#{CGI.escape(value.to_s)}" }.join('&')
- PaystationResponse.new(success?(response), message, response,
- :test => (response[:tm]&.casecmp('t')&.zero?),
- :authorization => response[:paystation_transaction_id]
- )
- end
+ data = ssl_post(self.live_url, "#{pstn_prefix_params}&paystation=_empty")
+ response = parse(data)
+ message = message_from(response)
- def success?(response)
- (response[:ec] == SUCCESSFUL_RESPONSE_CODE) || (response[:ec] == SUCCESSFUL_FUTURE_PAYMENT)
- end
+ PaystationResponse.new(success?(response), message, response,
+ :test => (response[:tm]&.casecmp('t')&.zero?),
+ :authorization => response[:paystation_transaction_id]
+ )
+ end
- def message_from(response)
- response[:em]
- end
+ def success?(response)
+ (response[:ec] == SUCCESSFUL_RESPONSE_CODE) || (response[:ec] == SUCCESSFUL_FUTURE_PAYMENT)
+ end
- def format_date(month, year)
- "#{format(year, :two_digits)}#{format(month, :two_digits)}"
- end
+ def message_from(response)
+ response[:em]
+ end
+
+ def format_date(month, year)
+ "#{format(year, :two_digits)}#{format(month, :two_digits)}"
+ end
end
diff --git a/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb b/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb
index 10ad00b3ae3..971c703d528 100644
--- a/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb
+++ b/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb
@@ -99,197 +99,197 @@ def scrub(transcript)
private
- def authorization_params(money, credit_card_or_reference, options = {})
- post = {}
-
- add_amount(post, money, options)
- add_credit_card_or_reference(post, credit_card_or_reference)
- add_additional_params(:authorize, post, options)
+ def authorization_params(money, credit_card_or_reference, options = {})
+ post = {}
- post
- end
+ add_amount(post, money, options)
+ add_credit_card_or_reference(post, credit_card_or_reference)
+ add_additional_params(:authorize, post, options)
- def capture_params(money, credit_card, options = {})
- post = {}
+ post
+ end
- add_amount(post, money, options)
- add_additional_params(:capture, post, options)
+ def capture_params(money, credit_card, options = {})
+ post = {}
- post
- end
+ add_amount(post, money, options)
+ add_additional_params(:capture, post, options)
- def create_store(options = {})
- post = {}
- commit('/cards', post)
- end
+ post
+ end
- def authorize_store(identification, credit_card, options = {})
- post = {}
+ def create_store(options = {})
+ post = {}
+ commit('/cards', post)
+ end
- add_credit_card_or_reference(post, credit_card, options)
- commit(synchronized_path("/cards/#{identification}/authorize"), post)
- end
+ def authorize_store(identification, credit_card, options = {})
+ post = {}
- def create_token(identification, options)
- post = {}
- commit(synchronized_path("/cards/#{identification}/tokens"), post)
- end
+ add_credit_card_or_reference(post, credit_card, options)
+ commit(synchronized_path("/cards/#{identification}/authorize"), post)
+ end
- def create_payment(money, options = {})
- post = {}
- add_currency(post, money, options)
- add_invoice(post, options)
- commit('/payments', post)
- end
+ def create_token(identification, options)
+ post = {}
+ commit(synchronized_path("/cards/#{identification}/tokens"), post)
+ end
- def commit(action, params = {})
- success = false
- begin
- response = parse(ssl_post(self.live_url + action, params.to_json, headers))
- success = successful?(response)
- rescue ResponseError => e
- response = response_error(e.response.body)
- rescue JSON::ParserError
- response = json_error(response)
- end
+ def create_payment(money, options = {})
+ post = {}
+ add_currency(post, money, options)
+ add_invoice(post, options)
+ commit('/payments', post)
+ end
- Response.new(success, message_from(success, response), response,
- :test => test?,
- :authorization => authorization_from(response)
- )
+ def commit(action, params = {})
+ success = false
+ begin
+ response = parse(ssl_post(self.live_url + action, params.to_json, headers))
+ success = successful?(response)
+ rescue ResponseError => e
+ response = response_error(e.response.body)
+ rescue JSON::ParserError
+ response = json_error(response)
end
- def authorization_from(response)
- if response['token']
- response['token'].to_s
- else
- response['id'].to_s
- end
- end
+ Response.new(success, message_from(success, response), response,
+ :test => test?,
+ :authorization => authorization_from(response)
+ )
+ end
- def add_currency(post, money, options)
- post[:currency] = options[:currency] || currency(money)
+ def authorization_from(response)
+ if response['token']
+ response['token'].to_s
+ else
+ response['id'].to_s
end
+ end
- def add_amount(post, money, options)
- post[:amount] = options[:amount] || amount(money)
- end
+ def add_currency(post, money, options)
+ post[:currency] = options[:currency] || currency(money)
+ end
- def add_autocapture(post, value)
- post[:auto_capture] = value
- end
+ def add_amount(post, money, options)
+ post[:amount] = options[:amount] || amount(money)
+ end
- def add_order_id(post, options)
- requires!(options, :order_id)
- post[:order_id] = format_order_id(options[:order_id])
- end
+ def add_autocapture(post, value)
+ post[:auto_capture] = value
+ end
- def add_invoice(post, options)
- add_order_id(post, options)
+ def add_order_id(post, options)
+ requires!(options, :order_id)
+ post[:order_id] = format_order_id(options[:order_id])
+ end
- if options[:billing_address]
- post[:invoice_address] = map_address(options[:billing_address])
- end
+ def add_invoice(post, options)
+ add_order_id(post, options)
- if options[:shipping_address]
- post[:shipping_address] = map_address(options[:shipping_address])
- end
+ if options[:billing_address]
+ post[:invoice_address] = map_address(options[:billing_address])
+ end
- [:metadata, :branding_id, :variables].each do |field|
- post[field] = options[field] if options[field]
- end
+ if options[:shipping_address]
+ post[:shipping_address] = map_address(options[:shipping_address])
end
- def add_additional_params(action, post, options = {})
- MD5_CHECK_FIELDS[API_VERSION][action].each do |key|
- key = key.to_sym
- post[key] = options[key] if options[key]
- end
+ [:metadata, :branding_id, :variables].each do |field|
+ post[field] = options[field] if options[field]
end
+ end
- def add_credit_card_or_reference(post, credit_card_or_reference, options = {})
- post[:card] ||= {}
- if credit_card_or_reference.is_a?(String)
- post[:card][:token] = credit_card_or_reference
- else
- post[:card][:number] = credit_card_or_reference.number
- post[:card][:cvd] = credit_card_or_reference.verification_value
- post[:card][:expiration] = expdate(credit_card_or_reference)
- post[:card][:issued_to] = credit_card_or_reference.name
- end
+ def add_additional_params(action, post, options = {})
+ MD5_CHECK_FIELDS[API_VERSION][action].each do |key|
+ key = key.to_sym
+ post[key] = options[key] if options[key]
end
+ end
- def parse(body)
- JSON.parse(body)
+ def add_credit_card_or_reference(post, credit_card_or_reference, options = {})
+ post[:card] ||= {}
+ if credit_card_or_reference.is_a?(String)
+ post[:card][:token] = credit_card_or_reference
+ else
+ post[:card][:number] = credit_card_or_reference.number
+ post[:card][:cvd] = credit_card_or_reference.verification_value
+ post[:card][:expiration] = expdate(credit_card_or_reference)
+ post[:card][:issued_to] = credit_card_or_reference.name
end
+ end
- def successful?(response)
- has_error = response['errors']
- invalid_code = invalid_operation_code?(response)
+ def parse(body)
+ JSON.parse(body)
+ end
- !(has_error || invalid_code)
- end
+ def successful?(response)
+ has_error = response['errors']
+ invalid_code = invalid_operation_code?(response)
- def message_from(success, response)
- success ? 'OK' : (response['message'] || invalid_operation_message(response) || 'Unknown error - please contact QuickPay')
- end
+ !(has_error || invalid_code)
+ end
- def invalid_operation_code?(response)
- if response['operations']
- operation = response['operations'].last
- operation && operation['qp_status_code'] != '20000'
- end
- end
+ def message_from(success, response)
+ success ? 'OK' : (response['message'] || invalid_operation_message(response) || 'Unknown error - please contact QuickPay')
+ end
- def invalid_operation_message(response)
- response['operations'] && response['operations'].last['qp_status_msg']
+ def invalid_operation_code?(response)
+ if response['operations']
+ operation = response['operations'].last
+ operation && operation['qp_status_code'] != '20000'
end
+ end
- def map_address(address)
- return {} if address.nil?
- requires!(address, :name, :address1, :city, :zip, :country)
- country = Country.find(address[:country])
- mapped = {
- :name => address[:name],
- :street => address[:address1],
- :city => address[:city],
- :region => address[:address2],
- :zip_code => address[:zip],
- :country_code => country.code(:alpha3).value
- }
- mapped
- end
+ def invalid_operation_message(response)
+ response['operations'] && response['operations'].last['qp_status_msg']
+ end
- def format_order_id(order_id)
- truncate(order_id.to_s.gsub(/#/, ''), 20)
- end
+ def map_address(address)
+ return {} if address.nil?
+ requires!(address, :name, :address1, :city, :zip, :country)
+ country = Country.find(address[:country])
+ mapped = {
+ :name => address[:name],
+ :street => address[:address1],
+ :city => address[:city],
+ :region => address[:address2],
+ :zip_code => address[:zip],
+ :country_code => country.code(:alpha3).value
+ }
+ mapped
+ end
- def headers
- auth = Base64.strict_encode64(":#{@options[:api_key]}")
- {
- 'Authorization' => 'Basic ' + auth,
- 'User-Agent' => "Quickpay-v#{API_VERSION} ActiveMerchantBindings/#{ActiveMerchant::VERSION}",
- 'Accept' => 'application/json',
- 'Accept-Version' => "v#{API_VERSION}",
- 'Content-Type' => 'application/json'
- }
- end
+ def format_order_id(order_id)
+ truncate(order_id.to_s.gsub(/#/, ''), 20)
+ end
- def response_error(raw_response)
- parse(raw_response)
- rescue JSON::ParserError
- json_error(raw_response)
- end
+ def headers
+ auth = Base64.strict_encode64(":#{@options[:api_key]}")
+ {
+ 'Authorization' => 'Basic ' + auth,
+ 'User-Agent' => "Quickpay-v#{API_VERSION} ActiveMerchantBindings/#{ActiveMerchant::VERSION}",
+ 'Accept' => 'application/json',
+ 'Accept-Version' => "v#{API_VERSION}",
+ 'Content-Type' => 'application/json'
+ }
+ end
- def json_error(raw_response)
- msg = 'Invalid response received from the Quickpay API.'
- msg += " (The raw response returned by the API was #{raw_response.inspect})"
- { 'message' => msg }
- end
+ def response_error(raw_response)
+ parse(raw_response)
+ rescue JSON::ParserError
+ json_error(raw_response)
+ end
- def synchronized_path(path)
- "#{path}?synchronized"
- end
+ def json_error(raw_response)
+ msg = 'Invalid response received from the Quickpay API.'
+ msg += " (The raw response returned by the API was #{raw_response.inspect})"
+ { 'message' => msg }
+ end
+
+ def synchronized_path(path)
+ "#{path}?synchronized"
+ end
end
end
end
diff --git a/test/remote/gateways/remote_banwire_test.rb b/test/remote/gateways/remote_banwire_test.rb
index cb8331a5661..0af462e9a7b 100644
--- a/test/remote/gateways/remote_banwire_test.rb
+++ b/test/remote/gateways/remote_banwire_test.rb
@@ -53,14 +53,14 @@ def test_invalid_login
assert_equal 'ID de cuenta invalido', response.message
end
-def test_transcript_scrubbing
- transcript = capture_transcript(@gateway) do
- @gateway.purchase(@amount, @credit_card, @options)
- end
- clean_transcript = @gateway.scrub(transcript)
+ def test_transcript_scrubbing
+ transcript = capture_transcript(@gateway) do
+ @gateway.purchase(@amount, @credit_card, @options)
+ end
+ clean_transcript = @gateway.scrub(transcript)
- assert_scrubbed(@credit_card.number, clean_transcript)
- assert_scrubbed(@credit_card.verification_value.to_s, clean_transcript)
-end
+ assert_scrubbed(@credit_card.number, clean_transcript)
+ assert_scrubbed(@credit_card.verification_value.to_s, clean_transcript)
+ end
end
diff --git a/test/remote/gateways/remote_cardknox_test.rb b/test/remote/gateways/remote_cardknox_test.rb
index 457c0928f27..211e1e9afcb 100644
--- a/test/remote/gateways/remote_cardknox_test.rb
+++ b/test/remote/gateways/remote_cardknox_test.rb
@@ -37,7 +37,7 @@ def setup
}
}
- @options = {}
+ @options = {}
end
def test_successful_credit_card_purchase
diff --git a/test/remote/gateways/remote_merchant_one_test.rb b/test/remote/gateways/remote_merchant_one_test.rb
index 936cb70235e..2e8969dadc9 100644
--- a/test/remote/gateways/remote_merchant_one_test.rb
+++ b/test/remote/gateways/remote_merchant_one_test.rb
@@ -31,34 +31,34 @@ def test_successful_purchase
assert_equal 'SUCCESS', response.message
end
- def test_unsuccessful_purchase
- assert response = @gateway.purchase(@amount, @declined_card, @options)
- assert_failure response
- assert response.message.include? 'Invalid Credit Card Number'
- end
+ def test_unsuccessful_purchase
+ assert response = @gateway.purchase(@amount, @declined_card, @options)
+ assert_failure response
+ assert response.message.include? 'Invalid Credit Card Number'
+ end
- def test_authorize_and_capture
- amount = @amount
- assert auth = @gateway.authorize(amount, @credit_card, @options)
- assert_success auth
- assert_equal 'SUCCESS', auth.message
- assert auth.authorization, auth.to_yaml
- assert capture = @gateway.capture(amount, auth.authorization)
- assert_success capture
- end
+ def test_authorize_and_capture
+ amount = @amount
+ assert auth = @gateway.authorize(amount, @credit_card, @options)
+ assert_success auth
+ assert_equal 'SUCCESS', auth.message
+ assert auth.authorization, auth.to_yaml
+ assert capture = @gateway.capture(amount, auth.authorization)
+ assert_success capture
+ end
- def test_failed_capture
- assert response = @gateway.capture(@amount, '')
- assert_failure response
- end
+ def test_failed_capture
+ assert response = @gateway.capture(@amount, '')
+ assert_failure response
+ end
- def test_invalid_login
- gateway = MerchantOneGateway.new(
- :username => 'nnn',
- :password => 'nnn'
- )
- assert response = gateway.purchase(@amount, @credit_card, @options)
- assert_failure response
- assert_equal 'Authentication Failed', response.message
- end
+ def test_invalid_login
+ gateway = MerchantOneGateway.new(
+ :username => 'nnn',
+ :password => 'nnn'
+ )
+ assert response = gateway.purchase(@amount, @credit_card, @options)
+ assert_failure response
+ assert_equal 'Authentication Failed', response.message
+ end
end
diff --git a/test/remote/gateways/remote_usa_epay_transaction_test.rb b/test/remote/gateways/remote_usa_epay_transaction_test.rb
index e3afb520134..a99c5c793e4 100644
--- a/test/remote/gateways/remote_usa_epay_transaction_test.rb
+++ b/test/remote/gateways/remote_usa_epay_transaction_test.rb
@@ -43,12 +43,12 @@ def test_successful_authorization_with_manual_entry
assert_success response
end
- def test_successful_purchase_with_manual_entry
- @credit_card.manual_entry = true
- assert response = @gateway.purchase(@amount, @credit_card, @options)
- assert_equal 'Success', response.message
- assert_success response
- end
+ def test_successful_purchase_with_manual_entry
+ @credit_card.manual_entry = true
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
+ assert_equal 'Success', response.message
+ assert_success response
+ end
def test_successful_purchase_with_extra_details
assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:order_id => generate_unique_id, :description => 'socool'))
diff --git a/test/unit/gateways/eway_managed_test.rb b/test/unit/gateways/eway_managed_test.rb
index c322e223579..02666e0bc71 100644
--- a/test/unit/gateways/eway_managed_test.rb
+++ b/test/unit/gateways/eway_managed_test.rb
@@ -372,9 +372,9 @@ def expected_store_request
XML
end
- # Documented here: https://www.eway.com.au/gateway/ManagedPaymentService/managedCreditCardPayment.asmx?op=CreateCustomer
- def expected_purchase_request
- <<-XML
+ # Documented here: https://www.eway.com.au/gateway/ManagedPaymentService/managedCreditCardPayment.asmx?op=CreateCustomer
+ def expected_purchase_request
+ <<-XML
@@ -393,8 +393,8 @@ def expected_purchase_request
- XML
- end
+ XML
+ end
# Documented here: https://www.eway.com.au/gateway/ManagedPaymentService/managedCreditCardPayment.asmx?op=QueryCustomer
def expected_retrieve_request
@@ -416,5 +416,4 @@ def expected_retrieve_request
XML
end
-
end
diff --git a/test/unit/gateways/netbanx_test.rb b/test/unit/gateways/netbanx_test.rb
index ba464b8eac2..cb9af17b688 100644
--- a/test/unit/gateways/netbanx_test.rb
+++ b/test/unit/gateways/netbanx_test.rb
@@ -146,9 +146,9 @@ def test_successful_unstore
assert_success response
assert response.test?
- response = @gateway.unstore('2f840ab3-0e71-4387-bad3-4705e6f4b015')
- assert_success response
- assert response.test?
+ response = @gateway.unstore('2f840ab3-0e71-4387-bad3-4705e6f4b015')
+ assert_success response
+ assert response.test?
end
def test_scrub
diff --git a/test/unit/gateways/orbital_test.rb b/test/unit/gateways/orbital_test.rb
index b79fdac439e..f030672e46c 100644
--- a/test/unit/gateways/orbital_test.rb
+++ b/test/unit/gateways/orbital_test.rb
@@ -219,12 +219,12 @@ def test_truncates_phone
def test_truncates_zip
long_zip = '1234567890123'
- response = stub_comms do
- @gateway.purchase(50, credit_card, :order_id => 1, :billing_address => address(:zip => long_zip))
- end.check_request do |endpoint, data, headers|
- assert_match(/1234567890, data)
- end.respond_with(successful_purchase_response)
- assert_success response
+ response = stub_comms do
+ @gateway.purchase(50, credit_card, :order_id => 1, :billing_address => address(:zip => long_zip))
+ end.check_request do |endpoint, data, headers|
+ assert_match(/1234567890, data)
+ end.respond_with(successful_purchase_response)
+ assert_success response
end
def test_address_format
diff --git a/test/unit/gateways/paypal_express_test.rb b/test/unit/gateways/paypal_express_test.rb
index 0c4f89d6641..1eef9513781 100644
--- a/test/unit/gateways/paypal_express_test.rb
+++ b/test/unit/gateways/paypal_express_test.rb
@@ -1056,8 +1056,8 @@ def response_with_error
RESPONSE
end
- def response_with_errors
- <<-RESPONSE
+ def response_with_errors
+ <<-RESPONSE
@@ -1093,10 +1093,10 @@ def response_with_errors
RESPONSE
- end
+ end
- def response_with_duplicate_errors
- <<-RESPONSE
+ def response_with_duplicate_errors
+ <<-RESPONSE
@@ -1132,10 +1132,10 @@ def response_with_duplicate_errors
RESPONSE
- end
+ end
- def successful_cancel_billing_agreement_response
- <<-RESPONSE
+ def successful_cancel_billing_agreement_response
+ <<-RESPONSE
None
RESPONSE
- end
+ end
- def failed_cancel_billing_agreement_response
- <<-RESPONSE
+ def failed_cancel_billing_agreement_response
+ <<-RESPONSE
PayPalNone
RESPONSE
- end
+ end
- def successful_billing_agreement_details_response
- <<-RESPONSE
+ def successful_billing_agreement_details_response
+ <<-RESPONSE
None
RESPONSE
- end
+ end
- def failure_billing_agreement_details_response
- <<-RESPONSE
+ def failure_billing_agreement_details_response
+ <<-RESPONSE
None
RESPONSE
- end
+ end
- def pre_scrubbed
- <<-TRANSCRIPT
+ def pre_scrubbed
+ <<-TRANSCRIPT
activemerchant-cert-test_api1.example.comERDD3JRFU5H5DQXS
124
@@ -1276,10 +1276,10 @@ def pre_scrubbed
2018-05-24T20:23:54ZSuccessb6dd2a043921b12446549960EC-7KR85820NC734104L
TRANSCRIPT
- end
+ end
- def post_scrubbed
- <<-TRANSCRIPT
+ def post_scrubbed
+ <<-TRANSCRIPT
[FILTERED][FILTERED]
124
@@ -1302,5 +1302,5 @@ def post_scrubbed
2018-05-24T20:23:54ZSuccessb6dd2a043921b12446549960EC-7KR85820NC734104L
TRANSCRIPT
- end
+ end
end
diff --git a/test/unit/gateways/paystation_test.rb b/test/unit/gateways/paystation_test.rb
index 1ed768b1186..c32716c1383 100644
--- a/test/unit/gateways/paystation_test.rb
+++ b/test/unit/gateways/paystation_test.rb
@@ -118,312 +118,312 @@ def test_scrub
private
- def successful_purchase_response
- %(
-
- 0
- Transaction successful
- 0006713018-01
- mastercard
- Store Purchase
- T
- 1
- 123456
- 0008813023-01
- 10000
-
- 8813023
-
- 00
- 0
-
-
- 2011-06-22 00:05:52
- 0
- Transaction successful
- Store Purchase
- T
- 0622
-
- MC
- 12345
- 192.168.0.1
-
-
- 2011-06-22 00:05:52
-
- 2011-06-22 00:05:52
- 0008813023-01
- unknown
- unknown
- )
- end
-
- def failed_purchase_response
- %(
-
- 5
- Insufficient Funds
- 0006713018-01
- mastercard
- Store Purchase
- T
- 1
- 123456
- 0008813018-01
- 10051
-
- 8813018
-
- 51
- 5
-
-
- 2011-06-22 00:05:46
- 5
- Insufficient Funds
- Store Purchase
- T
- 0622
-
- MC
- 123456
- 192.168.0.1
-
-
- 2011-06-22 00:05:46
-
- 2011-06-22 00:05:46
- 0008813018-01
- unknown
- unknown
- )
- end
-
- def successful_store_response
- %(
-
- 34
- Future Payment Saved Ok
-
-
- Store Purchase
- T
- 3e48fa9a6b0fe36177adf7269db7a3c4
-
-
- 0
-
-
-
-
-
-
-
- 2011-07-10 13:58:55
- 34
- Future Payment Saved Ok
- Store Purchase
- T
-
-
-
- 123456
- 192.168.0.1
-
-
- 2011-07-10 13:58:55
-
- 2011-07-10 13:58:55
- 0009062177-01
- justatest1310263135
- unknown
- unknown
- )
- end
-
- def successful_stored_purchase_response
- %(
-
- 0
- Transaction successful
- 0006713018-01
- visa
- Store Purchase
- T
- 0fc70a577f19ae63f651f53c7044640a
- 123456
- 0009062149-01
- 10000
-
- 9062149
-
- 00
- 0
-
-
- 2011-07-10 13:55:00
- 0
- Transaction successful
- Store Purchase
- T
- 0710
-
- VC
- 123456
- 192.168.0.1
-
-
- 2011-07-10 13:55:00
-
- 2011-07-10 13:55:00
- 0009062149-01
- u09fxli14afpnd6022x0z82317beqe9e2w048l9it8286k6lpvz9x27hdal9bl95
- unknown
- unknown
- )
- end
-
- def successful_authorization_response
- %(
-
- 0
- Transaction successful
- 0009062250-01
- visa
- Store Purchase
- T
- b2168af96076522466af4e3d61e5ba0c
- 123456
- 0009062250-01
- 10000
-
- 9062250
-
- 00
- 0
-
-
- 2011-07-10 14:11:00
- 0
- Transaction successful
- Store Purchase
- T
- 0710
-
- VC
- 123456
- 192.168.0.1
-
-
- 2011-07-10 14:11:00
-
- 2011-07-10 14:11:00
- 0009062250-01
- unknown
- unknown
- )
- end
-
- def successful_capture_response
- %(
-
- 0
- Transaction successful
- 0009062289-01
-
- Store Purchase
- T
- 485fdedc81dc83848dd799cd10a869db
- 123456
- 0009062289-01
- 10000
-
- 9062289
-
- 00
- 0
-
-
- 2011-07-10 14:17:36
- 0
- Transaction successful
- Store Purchase
- T
- 0710
-
-
- 123456
- 192.168.0.1
-
-
- 2011-07-10 14:17:36
- 2011-07-10 14:17:36
- 2011-07-10 14:17:36
-
-
- 10000
-
- )
- end
-
- def successful_refund_response
- %(
-
- 0
- Transaction successful
- 0008813023-01
- mastercard
- Store Purchase
- T
- 70ceae1b3f069e41ca7f4350a1180cb1
- 924518
- 0008813023-01
- 10000
-
- en
- 58160420
-
- 00
- 0
-
-
- 2015-06-25 03:23:24
- 0
- Transaction successful
-
- Store Purchase
- 512345XXXXXXX346
- 1305
- refund
- T
- 0625
-
- MC
- 609035
- 173.95.131.239
- Ruby
-
- 2015-06-25 03:23:24
- 2015-06-25 03:23:24
-
-
- 10000
-
- )
- end
-
- def failed_refund_response
- %(
- Error 11: Not enough input parameters.)
- end
-
- def pre_scrubbed
- 'pstn_pi=609035&pstn_gi=PUSHPAY&pstn_2p=t&pstn_nr=t&pstn_df=yymm&pstn_ms=a755b9c84a530aee91dc3077f57294b0&pstn_mo=Store+Purchase&pstn_mr=&pstn_am=&pstn_cu=NZD&pstn_cn=5123456789012346&pstn_ct=visa&pstn_ex=1305&pstn_cc=123&pstn_tm=T&paystation=_empty'
- end
-
- def post_scrubbed
- 'pstn_pi=609035&pstn_gi=PUSHPAY&pstn_2p=t&pstn_nr=t&pstn_df=yymm&pstn_ms=a755b9c84a530aee91dc3077f57294b0&pstn_mo=Store+Purchase&pstn_mr=&pstn_am=&pstn_cu=NZD&pstn_cn=[FILTERED]&pstn_ct=visa&pstn_ex=1305&pstn_cc=[FILTERED]&pstn_tm=T&paystation=_empty'
- end
+ def successful_purchase_response
+ %(
+
+ 0
+ Transaction successful
+ 0006713018-01
+ mastercard
+ Store Purchase
+ T
+ 1
+ 123456
+ 0008813023-01
+ 10000
+
+ 8813023
+
+ 00
+ 0
+
+
+ 2011-06-22 00:05:52
+ 0
+ Transaction successful
+ Store Purchase
+ T
+ 0622
+
+ MC
+ 12345
+ 192.168.0.1
+
+
+ 2011-06-22 00:05:52
+
+ 2011-06-22 00:05:52
+ 0008813023-01
+ unknown
+ unknown
+ )
+ end
+
+ def failed_purchase_response
+ %(
+
+ 5
+ Insufficient Funds
+ 0006713018-01
+ mastercard
+ Store Purchase
+ T
+ 1
+ 123456
+ 0008813018-01
+ 10051
+
+ 8813018
+
+ 51
+ 5
+
+
+ 2011-06-22 00:05:46
+ 5
+ Insufficient Funds
+ Store Purchase
+ T
+ 0622
+
+ MC
+ 123456
+ 192.168.0.1
+
+
+ 2011-06-22 00:05:46
+
+ 2011-06-22 00:05:46
+ 0008813018-01
+ unknown
+ unknown
+ )
+ end
+
+ def successful_store_response
+ %(
+
+ 34
+ Future Payment Saved Ok
+
+
+ Store Purchase
+ T
+ 3e48fa9a6b0fe36177adf7269db7a3c4
+
+
+ 0
+
+
+
+
+
+
+
+ 2011-07-10 13:58:55
+ 34
+ Future Payment Saved Ok
+ Store Purchase
+ T
+
+
+
+ 123456
+ 192.168.0.1
+
+
+ 2011-07-10 13:58:55
+
+ 2011-07-10 13:58:55
+ 0009062177-01
+ justatest1310263135
+ unknown
+ unknown
+ )
+ end
+
+ def successful_stored_purchase_response
+ %(
+
+ 0
+ Transaction successful
+ 0006713018-01
+ visa
+ Store Purchase
+ T
+ 0fc70a577f19ae63f651f53c7044640a
+ 123456
+ 0009062149-01
+ 10000
+
+ 9062149
+
+ 00
+ 0
+
+
+ 2011-07-10 13:55:00
+ 0
+ Transaction successful
+ Store Purchase
+ T
+ 0710
+
+ VC
+ 123456
+ 192.168.0.1
+
+
+ 2011-07-10 13:55:00
+
+ 2011-07-10 13:55:00
+ 0009062149-01
+ u09fxli14afpnd6022x0z82317beqe9e2w048l9it8286k6lpvz9x27hdal9bl95
+ unknown
+ unknown
+ )
+ end
+
+ def successful_authorization_response
+ %(
+
+ 0
+ Transaction successful
+ 0009062250-01
+ visa
+ Store Purchase
+ T
+ b2168af96076522466af4e3d61e5ba0c
+ 123456
+ 0009062250-01
+ 10000
+
+ 9062250
+
+ 00
+ 0
+
+
+ 2011-07-10 14:11:00
+ 0
+ Transaction successful
+ Store Purchase
+ T
+ 0710
+
+ VC
+ 123456
+ 192.168.0.1
+
+
+ 2011-07-10 14:11:00
+
+ 2011-07-10 14:11:00
+ 0009062250-01
+ unknown
+ unknown
+ )
+ end
+
+ def successful_capture_response
+ %(
+
+ 0
+ Transaction successful
+ 0009062289-01
+
+ Store Purchase
+ T
+ 485fdedc81dc83848dd799cd10a869db
+ 123456
+ 0009062289-01
+ 10000
+
+ 9062289
+
+ 00
+ 0
+
+
+ 2011-07-10 14:17:36
+ 0
+ Transaction successful
+ Store Purchase
+ T
+ 0710
+
+
+ 123456
+ 192.168.0.1
+
+
+ 2011-07-10 14:17:36
+ 2011-07-10 14:17:36
+ 2011-07-10 14:17:36
+
+
+ 10000
+
+ )
+ end
+
+ def successful_refund_response
+ %(
+
+ 0
+ Transaction successful
+ 0008813023-01
+ mastercard
+ Store Purchase
+ T
+ 70ceae1b3f069e41ca7f4350a1180cb1
+ 924518
+ 0008813023-01
+ 10000
+
+ en
+ 58160420
+
+ 00
+ 0
+
+
+ 2015-06-25 03:23:24
+ 0
+ Transaction successful
+
+ Store Purchase
+ 512345XXXXXXX346
+ 1305
+ refund
+ T
+ 0625
+
+ MC
+ 609035
+ 173.95.131.239
+ Ruby
+
+ 2015-06-25 03:23:24
+ 2015-06-25 03:23:24
+
+
+ 10000
+
+ )
+ end
+
+ def failed_refund_response
+ %(
+ Error 11: Not enough input parameters.)
+ end
+
+ def pre_scrubbed
+ 'pstn_pi=609035&pstn_gi=PUSHPAY&pstn_2p=t&pstn_nr=t&pstn_df=yymm&pstn_ms=a755b9c84a530aee91dc3077f57294b0&pstn_mo=Store+Purchase&pstn_mr=&pstn_am=&pstn_cu=NZD&pstn_cn=5123456789012346&pstn_ct=visa&pstn_ex=1305&pstn_cc=123&pstn_tm=T&paystation=_empty'
+ end
+
+ def post_scrubbed
+ 'pstn_pi=609035&pstn_gi=PUSHPAY&pstn_2p=t&pstn_nr=t&pstn_df=yymm&pstn_ms=a755b9c84a530aee91dc3077f57294b0&pstn_mo=Store+Purchase&pstn_mr=&pstn_am=&pstn_cu=NZD&pstn_cn=[FILTERED]&pstn_ct=visa&pstn_ex=1305&pstn_cc=[FILTERED]&pstn_tm=T&paystation=_empty'
+ end
end
diff --git a/test/unit/gateways/payway_test.rb b/test/unit/gateways/payway_test.rb
index d72f7a849b0..42a1aa25321 100644
--- a/test/unit/gateways/payway_test.rb
+++ b/test/unit/gateways/payway_test.rb
@@ -219,40 +219,40 @@ def test_store
private
- def successful_response_store
- 'response.responseCode=00'
- end
+ def successful_response_store
+ 'response.responseCode=00'
+ end
- def successful_response_visa
- 'response.summaryCode=0&response.responseCode=08&response.cardSchemeName=VISA'
- end
+ def successful_response_visa
+ 'response.summaryCode=0&response.responseCode=08&response.cardSchemeName=VISA'
+ end
- def successful_response_master_card
- 'response.summaryCode=0&response.responseCode=08&response.cardSchemeName=MASTERCARD'
- end
+ def successful_response_master_card
+ 'response.summaryCode=0&response.responseCode=08&response.cardSchemeName=MASTERCARD'
+ end
- def purchase_with_invalid_credit_card_response
- 'response.summaryCode=1&response.responseCode=14'
- end
+ def purchase_with_invalid_credit_card_response
+ 'response.summaryCode=1&response.responseCode=14'
+ end
- def purchase_with_expired_credit_card_response
- 'response.summaryCode=1&response.responseCode=54'
- end
+ def purchase_with_expired_credit_card_response
+ 'response.summaryCode=1&response.responseCode=54'
+ end
- def purchase_with_invalid_month_response
- 'response.summaryCode=3&response.responseCode=QA'
- end
+ def purchase_with_invalid_month_response
+ 'response.summaryCode=3&response.responseCode=QA'
+ end
- def bad_login_response
- 'response.summaryCode=3&response.responseCode=QH'
- end
+ def bad_login_response
+ 'response.summaryCode=3&response.responseCode=QH'
+ end
- def bad_merchant_response
- 'response.summaryCode=3&response.responseCode=QK'
- end
+ def bad_merchant_response
+ 'response.summaryCode=3&response.responseCode=QK'
+ end
- def certificate
- '------BEGIN CERTIFICATE-----
+ def certificate
+ '------BEGIN CERTIFICATE-----
-MIIDeDCCAmCgAwIBAgIBATANBgkqhkiG9w0BAQUFADBBMRMwEQYDVQQDDApjb2R5
-ZmF1c2VyMRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEzARBgoJkiaJk/IsZAEZFgNj
-b20wHhcNMTMxMTEzMTk1NjE2WhcNMTQxMTEzMTk1NjE2WjBBMRMwEQYDVQQDDApj
@@ -273,5 +273,5 @@ def certificate
-ZJB9YPQZG+vWBdDSca3sUMtvFxpLUFwdKF5APSPOVnhbFJ3vSXY1ulP/R6XW9vnw
-6kkQi2fHhU20ugMzp881Eixr+TjC0RvUerLG7g==
------END CERTIFICATE-----'
- end
+ end
end
diff --git a/test/unit/gateways/worldpay_test.rb b/test/unit/gateways/worldpay_test.rb
index cc4eee1f918..031deef53ff 100644
--- a/test/unit/gateways/worldpay_test.rb
+++ b/test/unit/gateways/worldpay_test.rb
@@ -9,9 +9,9 @@ def setup
:password => 'testpassword'
)
- @amount = 100
- @credit_card = credit_card('4242424242424242')
- @options = {:order_id => 1}
+ @amount = 100
+ @credit_card = credit_card('4242424242424242')
+ @options = {:order_id => 1}
end
def test_successful_authorize
From 08d023ee2403629ff44ad8bb9379324a7ab29fdf Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Tue, 27 Nov 2018 11:08:49 -0500
Subject: [PATCH 0196/2234] RuboCop: fix Layout/IndentationWidth
---
.rubocop_todo.yml | 6 -
.../billing/gateways/authorize_net.rb | 30 ++---
.../billing/gateways/authorize_net_cim.rb | 66 +++++-----
.../billing/gateways/cardknox.rb | 4 +-
.../billing/gateways/eway_managed.rb | 10 +-
lib/active_merchant/billing/gateways/exact.rb | 20 +--
.../billing/gateways/merchant_one.rb | 6 +-
.../billing/gateways/merchant_ware.rb | 8 +-
.../billing/gateways/mundipagg.rb | 2 +-
lib/active_merchant/billing/gateways/ogone.rb | 4 +-
lib/active_merchant/billing/gateways/omise.rb | 10 +-
lib/active_merchant/billing/gateways/opp.rb | 2 +-
.../billing/gateways/paymill.rb | 10 +-
.../billing/gateways/paypal.rb | 2 +-
.../billing/gateways/payu_latam.rb | 2 +-
.../billing/gateways/quickbooks.rb | 4 +-
.../billing/gateways/quickpay/quickpay_v10.rb | 2 +-
lib/active_merchant/billing/gateways/sage.rb | 22 ++--
.../billing/gateways/sage_pay.rb | 10 +-
.../billing/gateways/wirecard.rb | 10 +-
.../gateways/remote_first_giving_test.rb | 8 +-
.../gateways/remote_merchant_one_test.rb | 4 +-
test/remote/gateways/remote_netaxept_test.rb | 94 +++++++-------
.../remote/gateways/remote_payflow_uk_test.rb | 10 +-
.../remote_usa_epay_transaction_test.rb | 8 +-
test/unit/gateways/bpoint_test.rb | 34 ++---
test/unit/gateways/card_stream_test.rb | 2 +-
test/unit/gateways/cardknox_test.rb | 8 +-
test/unit/gateways/elavon_test.rb | 2 +-
test/unit/gateways/eway_test.rb | 8 +-
test/unit/gateways/gateway_test.rb | 8 +-
test/unit/gateways/hps_test.rb | 2 +-
test/unit/gateways/metrics_global_test.rb | 8 +-
test/unit/gateways/moneris_test.rb | 72 +++++------
test/unit/gateways/moneris_us_test.rb | 72 +++++------
test/unit/gateways/netbanx_test.rb | 14 +-
test/unit/gateways/omise_test.rb | 4 +-
test/unit/gateways/opp_test.rb | 4 +-
test/unit/gateways/orbital_test.rb | 16 +--
test/unit/gateways/pagarme_test.rb | 18 +--
test/unit/gateways/payflow_test.rb | 4 +-
.../gateways/paypal/paypal_common_api_test.rb | 2 +-
.../gateways/paypal_digital_goods_test.rb | 120 +++++++++---------
test/unit/gateways/paypal_express_test.rb | 2 +-
test/unit/gateways/trust_commerce_test.rb | 8 +-
.../gateways/usa_epay_transaction_test.rb | 8 +-
test/unit/gateways/verifi_test.rb | 2 +-
test/unit/gateways/visanet_peru_test.rb | 2 +-
test/unit/gateways/worldpay_test.rb | 14 +-
49 files changed, 391 insertions(+), 397 deletions(-)
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 08a3231d05a..b8025e1f862 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -74,12 +74,6 @@ Layout/IndentHash:
Layout/IndentHeredoc:
Enabled: false
-# Offense count: 193
-# Cop supports --auto-correct.
-# Configuration parameters: Width, IgnoredPatterns.
-Layout/IndentationWidth:
- Enabled: false
-
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
diff --git a/lib/active_merchant/billing/gateways/authorize_net.rb b/lib/active_merchant/billing/gateways/authorize_net.rb
index 738bc90a586..a0240cc25ed 100644
--- a/lib/active_merchant/billing/gateways/authorize_net.rb
+++ b/lib/active_merchant/billing/gateways/authorize_net.rb
@@ -837,7 +837,7 @@ def parse_normal(action, body)
response = {action: action}
response[:response_code] = if(element = doc.at_xpath('//transactionResponse/responseCode'))
- (empty?(element.content) ? nil : element.content.to_i)
+ (empty?(element.content) ? nil : element.content.to_i)
end
if(element = doc.at_xpath('//errors/error'))
@@ -855,35 +855,35 @@ def parse_normal(action, body)
end
response[:avs_result_code] = if(element = doc.at_xpath('//avsResultCode'))
- (empty?(element.content) ? nil : element.content)
+ (empty?(element.content) ? nil : element.content)
end
response[:transaction_id] = if(element = doc.at_xpath('//transId'))
- (empty?(element.content) ? nil : element.content)
+ (empty?(element.content) ? nil : element.content)
end
response[:card_code] = if(element = doc.at_xpath('//cvvResultCode'))
- (empty?(element.content) ? nil : element.content)
+ (empty?(element.content) ? nil : element.content)
end
response[:authorization_code] = if(element = doc.at_xpath('//authCode'))
- (empty?(element.content) ? nil : element.content)
+ (empty?(element.content) ? nil : element.content)
end
response[:cardholder_authentication_code] = if(element = doc.at_xpath('//cavvResultCode'))
- (empty?(element.content) ? nil : element.content)
+ (empty?(element.content) ? nil : element.content)
end
response[:account_number] = if(element = doc.at_xpath('//accountNumber'))
- (empty?(element.content) ? nil : element.content[-4..-1])
+ (empty?(element.content) ? nil : element.content[-4..-1])
end
response[:test_request] = if(element = doc.at_xpath('//testRequest'))
- (empty?(element.content) ? nil : element.content)
+ (empty?(element.content) ? nil : element.content)
end
response[:full_response_code] = if(element = doc.at_xpath('//messages/message/code'))
- (empty?(element.content) ? nil : element.content)
+ (empty?(element.content) ? nil : element.content)
end
response
@@ -900,28 +900,28 @@ def parse_cim(body, options)
end
response[:result_code] = if(element = doc.at_xpath('//messages/resultCode'))
- (empty?(element.content) ? nil : element.content)
+ (empty?(element.content) ? nil : element.content)
end
response[:test_request] = if(element = doc.at_xpath('//testRequest'))
- (empty?(element.content) ? nil : element.content)
+ (empty?(element.content) ? nil : element.content)
end
response[:customer_profile_id] = if(element = doc.at_xpath('//customerProfileId'))
- (empty?(element.content) ? nil : element.content)
+ (empty?(element.content) ? nil : element.content)
end
response[:customer_payment_profile_id] = if(element = doc.at_xpath('//customerPaymentProfileIdList/numericString'))
- (empty?(element.content) ? nil : element.content)
+ (empty?(element.content) ? nil : element.content)
end
response[:customer_payment_profile_id] = if(element = doc.at_xpath('//customerPaymentProfileIdList/numericString') ||
doc.at_xpath('//customerPaymentProfileId'))
- (empty?(element.content) ? nil : element.content)
+ (empty?(element.content) ? nil : element.content)
end
response[:direct_response] = if(element = doc.at_xpath('//directResponse'))
- (empty?(element.content) ? nil : element.content)
+ (empty?(element.content) ? nil : element.content)
end
response.merge!(parse_direct_response_elements(response, options))
diff --git a/lib/active_merchant/billing/gateways/authorize_net_cim.rb b/lib/active_merchant/billing/gateways/authorize_net_cim.rb
index 0ca1ec4d7a0..fac2913ff37 100644
--- a/lib/active_merchant/billing/gateways/authorize_net_cim.rb
+++ b/lib/active_merchant/billing/gateways/authorize_net_cim.rb
@@ -380,18 +380,18 @@ def create_customer_profile_transaction(options)
requires!(options[:transaction], :type)
case options[:transaction][:type]
when :void
- requires!(options[:transaction], :trans_id)
+ requires!(options[:transaction], :trans_id)
when :refund
- requires!(options[:transaction], :trans_id) &&
- (
- (options[:transaction][:customer_profile_id] && options[:transaction][:customer_payment_profile_id]) ||
- options[:transaction][:credit_card_number_masked] ||
- (options[:transaction][:bank_routing_number_masked] && options[:transaction][:bank_account_number_masked])
- )
+ requires!(options[:transaction], :trans_id) &&
+ (
+ (options[:transaction][:customer_profile_id] && options[:transaction][:customer_payment_profile_id]) ||
+ options[:transaction][:credit_card_number_masked] ||
+ (options[:transaction][:bank_routing_number_masked] && options[:transaction][:bank_account_number_masked])
+ )
when :prior_auth_capture
- requires!(options[:transaction], :amount, :trans_id)
+ requires!(options[:transaction], :amount, :trans_id)
else
- requires!(options[:transaction], :amount, :customer_profile_id, :customer_payment_profile_id)
+ requires!(options[:transaction], :amount, :customer_profile_id, :customer_payment_profile_id)
end
request = build_request(:create_customer_profile_transaction, options)
commit(:create_customer_profile_transaction, request)
@@ -666,33 +666,33 @@ def add_transaction(xml, transaction)
# The amount to be billed to the customer
case transaction[:type]
when :void
- tag_unless_blank(xml, 'customerProfileId', transaction[:customer_profile_id])
- tag_unless_blank(xml, 'customerPaymentProfileId', transaction[:customer_payment_profile_id])
- tag_unless_blank(xml, 'customerShippingAddressId', transaction[:customer_shipping_address_id])
- xml.tag!('transId', transaction[:trans_id])
+ tag_unless_blank(xml, 'customerProfileId', transaction[:customer_profile_id])
+ tag_unless_blank(xml, 'customerPaymentProfileId', transaction[:customer_payment_profile_id])
+ tag_unless_blank(xml, 'customerShippingAddressId', transaction[:customer_shipping_address_id])
+ xml.tag!('transId', transaction[:trans_id])
when :refund
- xml.tag!('amount', transaction[:amount])
- tag_unless_blank(xml, 'customerProfileId', transaction[:customer_profile_id])
- tag_unless_blank(xml, 'customerPaymentProfileId', transaction[:customer_payment_profile_id])
- tag_unless_blank(xml, 'customerShippingAddressId', transaction[:customer_shipping_address_id])
- tag_unless_blank(xml, 'creditCardNumberMasked', transaction[:credit_card_number_masked])
- tag_unless_blank(xml, 'bankRoutingNumberMasked', transaction[:bank_routing_number_masked])
- tag_unless_blank(xml, 'bankAccountNumberMasked', transaction[:bank_account_number_masked])
- add_order(xml, transaction[:order]) if transaction[:order].present?
- xml.tag!('transId', transaction[:trans_id])
- add_tax(xml, transaction[:tax]) if transaction[:tax]
- add_duty(xml, transaction[:duty]) if transaction[:duty]
- add_shipping(xml, transaction[:shipping]) if transaction[:shipping]
+ xml.tag!('amount', transaction[:amount])
+ tag_unless_blank(xml, 'customerProfileId', transaction[:customer_profile_id])
+ tag_unless_blank(xml, 'customerPaymentProfileId', transaction[:customer_payment_profile_id])
+ tag_unless_blank(xml, 'customerShippingAddressId', transaction[:customer_shipping_address_id])
+ tag_unless_blank(xml, 'creditCardNumberMasked', transaction[:credit_card_number_masked])
+ tag_unless_blank(xml, 'bankRoutingNumberMasked', transaction[:bank_routing_number_masked])
+ tag_unless_blank(xml, 'bankAccountNumberMasked', transaction[:bank_account_number_masked])
+ add_order(xml, transaction[:order]) if transaction[:order].present?
+ xml.tag!('transId', transaction[:trans_id])
+ add_tax(xml, transaction[:tax]) if transaction[:tax]
+ add_duty(xml, transaction[:duty]) if transaction[:duty]
+ add_shipping(xml, transaction[:shipping]) if transaction[:shipping]
when :prior_auth_capture
- xml.tag!('amount', transaction[:amount])
- add_order(xml, transaction[:order]) if transaction[:order].present?
- xml.tag!('transId', transaction[:trans_id])
+ xml.tag!('amount', transaction[:amount])
+ add_order(xml, transaction[:order]) if transaction[:order].present?
+ xml.tag!('transId', transaction[:trans_id])
else
- xml.tag!('amount', transaction[:amount])
- xml.tag!('customerProfileId', transaction[:customer_profile_id])
- xml.tag!('customerPaymentProfileId', transaction[:customer_payment_profile_id])
- xml.tag!('approvalCode', transaction[:approval_code]) if transaction[:type] == :capture_only
- add_order(xml, transaction[:order]) if transaction[:order].present?
+ xml.tag!('amount', transaction[:amount])
+ xml.tag!('customerProfileId', transaction[:customer_profile_id])
+ xml.tag!('customerPaymentProfileId', transaction[:customer_payment_profile_id])
+ xml.tag!('approvalCode', transaction[:approval_code]) if transaction[:type] == :capture_only
+ add_order(xml, transaction[:order]) if transaction[:order].present?
end
if [:auth_capture, :auth_only, :capture_only].include?(transaction[:type])
diff --git a/lib/active_merchant/billing/gateways/cardknox.rb b/lib/active_merchant/billing/gateways/cardknox.rb
index e4dd63bba30..938e6ade478 100644
--- a/lib/active_merchant/billing/gateways/cardknox.rb
+++ b/lib/active_merchant/billing/gateways/cardknox.rb
@@ -81,8 +81,8 @@ def void(authorization, options = {})
def verify(credit_card, options={})
MultiResponse.run(:use_first_response) do |r|
- r.process { authorize(100, credit_card, options) }
- r.process(:ignore_result) { void(r.authorization, options) }
+ r.process { authorize(100, credit_card, options) }
+ r.process(:ignore_result) { void(r.authorization, options) }
end
end
diff --git a/lib/active_merchant/billing/gateways/eway_managed.rb b/lib/active_merchant/billing/gateways/eway_managed.rb
index 9c6101d45e4..fcdd34afbd4 100644
--- a/lib/active_merchant/billing/gateways/eway_managed.rb
+++ b/lib/active_merchant/billing/gateways/eway_managed.rb
@@ -150,7 +150,7 @@ def parse(body)
reply = {}
xml = REXML::Document.new(body)
if root = REXML::XPath.first(xml, '//soap:Fault') then
- reply=parse_fault(root)
+ reply=parse_fault(root)
else
if root = REXML::XPath.first(xml, '//ProcessPaymentResponse/ewayResponse') then
# Successful payment
@@ -232,13 +232,13 @@ def soap_request(arguments, action)
# eWay demands all fields be sent, but contain an empty string if blank
post = case action
when 'QueryCustomer'
- arguments
+ arguments
when 'ProcessPayment'
- default_payment_fields.merge(arguments)
+ default_payment_fields.merge(arguments)
when 'CreateCustomer'
- default_customer_fields.merge(arguments)
+ default_customer_fields.merge(arguments)
when 'UpdateCustomer'
- default_customer_fields.merge(arguments)
+ default_customer_fields.merge(arguments)
end
xml = Builder::XmlMarkup.new :indent => 2
diff --git a/lib/active_merchant/billing/gateways/exact.rb b/lib/active_merchant/billing/gateways/exact.rb
index 06f31316e66..d9649b84e21 100644
--- a/lib/active_merchant/billing/gateways/exact.rb
+++ b/lib/active_merchant/billing/gateways/exact.rb
@@ -160,14 +160,14 @@ def expdate(credit_card)
end
def commit(action, request)
- response = parse(ssl_post(self.live_url, build_request(action, request), POST_HEADERS))
-
- Response.new(successful?(response), message_from(response), response,
- :test => test?,
- :authorization => authorization_from(response),
- :avs_result => { :code => response[:avs] },
- :cvv_result => response[:cvv2]
- )
+ response = parse(ssl_post(self.live_url, build_request(action, request), POST_HEADERS))
+
+ Response.new(successful?(response), message_from(response), response,
+ :test => test?,
+ :authorization => authorization_from(response),
+ :avs_result => { :code => response[:avs] },
+ :cvv_result => response[:cvv2]
+ )
rescue ResponseError => e
case e.response.code
when '401'
@@ -183,9 +183,9 @@ def successful?(response)
def authorization_from(response)
if response[:authorization_num] && response[:transaction_tag]
- "#{response[:authorization_num]};#{response[:transaction_tag]}"
+ "#{response[:authorization_num]};#{response[:transaction_tag]}"
else
- ''
+ ''
end
end
diff --git a/lib/active_merchant/billing/gateways/merchant_one.rb b/lib/active_merchant/billing/gateways/merchant_one.rb
index f2b081c2074..20f60dd0cd2 100644
--- a/lib/active_merchant/billing/gateways/merchant_one.rb
+++ b/lib/active_merchant/billing/gateways/merchant_one.rb
@@ -75,9 +75,9 @@ def add_address(post, creditcard, options)
end
def add_creditcard(post, creditcard)
- post['cvv'] = creditcard.verification_value
- post['ccnumber'] = creditcard.number
- post['ccexp'] = "#{sprintf("%02d", creditcard.month)}#{creditcard.year.to_s[-2, 2]}"
+ post['cvv'] = creditcard.verification_value
+ post['ccnumber'] = creditcard.number
+ post['ccexp'] = "#{sprintf("%02d", creditcard.month)}#{creditcard.year.to_s[-2, 2]}"
end
def commit(action, money, parameters={})
diff --git a/lib/active_merchant/billing/gateways/merchant_ware.rb b/lib/active_merchant/billing/gateways/merchant_ware.rb
index a6d73a2130c..d028024ccb0 100644
--- a/lib/active_merchant/billing/gateways/merchant_ware.rb
+++ b/lib/active_merchant/billing/gateways/merchant_ware.rb
@@ -226,10 +226,10 @@ def add_credit_card(xml, credit_card)
if credit_card.respond_to?(:track_data) && credit_card.track_data.present?
xml.tag! 'trackData', credit_card.track_data
else
- xml.tag! 'strPAN', credit_card.number
- xml.tag! 'strExpDate', expdate(credit_card)
- xml.tag! 'strCardHolder', credit_card.name
- xml.tag! 'strCVCode', credit_card.verification_value if credit_card.verification_value?
+ xml.tag! 'strPAN', credit_card.number
+ xml.tag! 'strExpDate', expdate(credit_card)
+ xml.tag! 'strCardHolder', credit_card.name
+ xml.tag! 'strCVCode', credit_card.verification_value if credit_card.verification_value?
end
end
diff --git a/lib/active_merchant/billing/gateways/mundipagg.rb b/lib/active_merchant/billing/gateways/mundipagg.rb
index cb23e8e6235..aeac34ebe11 100644
--- a/lib/active_merchant/billing/gateways/mundipagg.rb
+++ b/lib/active_merchant/billing/gateways/mundipagg.rb
@@ -224,7 +224,7 @@ def url_for(action, auth = nil)
when 'capture'
"#{url}/charges/#{auth}/capture/"
else
- "#{url}/charges/"
+ "#{url}/charges/"
end
end
diff --git a/lib/active_merchant/billing/gateways/ogone.rb b/lib/active_merchant/billing/gateways/ogone.rb
index 5d6041c887f..883ac94a05a 100644
--- a/lib/active_merchant/billing/gateways/ogone.rb
+++ b/lib/active_merchant/billing/gateways/ogone.rb
@@ -408,8 +408,8 @@ def post_data(action, parameters = {})
def add_signature(parameters)
if @options[:signature].blank?
- ActiveMerchant.deprecated(OGONE_NO_SIGNATURE_DEPRECATION_MESSAGE) unless(@options[:signature_encryptor] == 'none')
- return
+ ActiveMerchant.deprecated(OGONE_NO_SIGNATURE_DEPRECATION_MESSAGE) unless(@options[:signature_encryptor] == 'none')
+ return
end
add_pair parameters, 'SHASign', calculate_signature(parameters, @options[:signature_encryptor], @options[:signature])
diff --git a/lib/active_merchant/billing/gateways/omise.rb b/lib/active_merchant/billing/gateways/omise.rb
index fbb1af839ab..218b099590f 100644
--- a/lib/active_merchant/billing/gateways/omise.rb
+++ b/lib/active_merchant/billing/gateways/omise.rb
@@ -247,15 +247,15 @@ def message_to_standard_error_code_from(response)
message = response['message'] if response['code'] == 'invalid_card'
case message
when /brand not supported/
- STANDARD_ERROR_CODE[:invalid_number]
+ STANDARD_ERROR_CODE[:invalid_number]
when /number is invalid/
- STANDARD_ERROR_CODE[:incorrect_number]
+ STANDARD_ERROR_CODE[:incorrect_number]
when /expiration date cannot be in the past/
- STANDARD_ERROR_CODE[:expired_card]
+ STANDARD_ERROR_CODE[:expired_card]
when /expiration \w+ is invalid/
- STANDARD_ERROR_CODE[:invalid_expiry_date]
+ STANDARD_ERROR_CODE[:invalid_expiry_date]
else
- STANDARD_ERROR_CODE[:processing_error]
+ STANDARD_ERROR_CODE[:processing_error]
end
end
diff --git a/lib/active_merchant/billing/gateways/opp.rb b/lib/active_merchant/billing/gateways/opp.rb
index 03f6e92286e..8c82574a670 100644
--- a/lib/active_merchant/billing/gateways/opp.rb
+++ b/lib/active_merchant/billing/gateways/opp.rb
@@ -189,7 +189,7 @@ def execute_referencing(txtype, money, authorization, options)
end
def add_authentication(post)
- post[:authentication] = { entityId: @options[:entity_id], password: @options[:password], userId: @options[:user_id]}
+ post[:authentication] = { entityId: @options[:entity_id], password: @options[:password], userId: @options[:user_id]}
end
def add_customer_data(post, payment, options)
diff --git a/lib/active_merchant/billing/gateways/paymill.rb b/lib/active_merchant/billing/gateways/paymill.rb
index 01b4cd9ebfb..caf64486d8b 100644
--- a/lib/active_merchant/billing/gateways/paymill.rb
+++ b/lib/active_merchant/billing/gateways/paymill.rb
@@ -129,12 +129,12 @@ def action_with_token(action, money, payment_method, options)
options[:money] = money
case payment_method
when String
- self.send("#{action}_with_token", money, payment_method, options)
+ self.send("#{action}_with_token", money, payment_method, options)
else
- MultiResponse.run do |r|
- r.process { save_card(payment_method, options) }
- r.process { self.send("#{action}_with_token", money, r.authorization, options) }
- end
+ MultiResponse.run do |r|
+ r.process { save_card(payment_method, options) }
+ r.process { self.send("#{action}_with_token", money, r.authorization, options) }
+ end
end
end
diff --git a/lib/active_merchant/billing/gateways/paypal.rb b/lib/active_merchant/billing/gateways/paypal.rb
index 74769690810..465a0dd2b24 100644
--- a/lib/active_merchant/billing/gateways/paypal.rb
+++ b/lib/active_merchant/billing/gateways/paypal.rb
@@ -108,7 +108,7 @@ def credit_card_type(type)
end
def build_response(success, message, response, options = {})
- Response.new(success, message, response, options)
+ Response.new(success, message, response, options)
end
end
end
diff --git a/lib/active_merchant/billing/gateways/payu_latam.rb b/lib/active_merchant/billing/gateways/payu_latam.rb
index 9c73136aca2..1d2b995b083 100644
--- a/lib/active_merchant/billing/gateways/payu_latam.rb
+++ b/lib/active_merchant/billing/gateways/payu_latam.rb
@@ -365,7 +365,7 @@ def success_from(action, response)
when 'verify_credentials'
response['code'] == 'SUCCESS'
when 'refund', 'void'
- response['code'] == 'SUCCESS' && response['transactionResponse'] && (response['transactionResponse']['state'] == 'PENDING' || response['transactionResponse']['state'] == 'APPROVED')
+ response['code'] == 'SUCCESS' && response['transactionResponse'] && (response['transactionResponse']['state'] == 'PENDING' || response['transactionResponse']['state'] == 'APPROVED')
else
response['code'] == 'SUCCESS' && response['transactionResponse'] && (response['transactionResponse']['state'] == 'APPROVED')
end
diff --git a/lib/active_merchant/billing/gateways/quickbooks.rb b/lib/active_merchant/billing/gateways/quickbooks.rb
index 1f73575bdab..6759a57aee6 100644
--- a/lib/active_merchant/billing/gateways/quickbooks.rb
+++ b/lib/active_merchant/billing/gateways/quickbooks.rb
@@ -252,9 +252,9 @@ def cvv_code_from(response)
end
def success?(response)
- return FRAUD_WARNING_CODES.concat(['0']).include?(response['errors'].first['code']) if response['errors']
+ return FRAUD_WARNING_CODES.concat(['0']).include?(response['errors'].first['code']) if response['errors']
- !['DECLINED', 'CANCELLED'].include?(response['status'])
+ !['DECLINED', 'CANCELLED'].include?(response['status'])
end
def message_from(response)
diff --git a/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb b/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb
index 971c703d528..e1b00768287 100644
--- a/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb
+++ b/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb
@@ -163,7 +163,7 @@ def authorization_from(response)
if response['token']
response['token'].to_s
else
- response['id'].to_s
+ response['id'].to_s
end
end
diff --git a/lib/active_merchant/billing/gateways/sage.rb b/lib/active_merchant/billing/gateways/sage.rb
index 52bb573c93e..3f3c9a96bcf 100644
--- a/lib/active_merchant/billing/gateways/sage.rb
+++ b/lib/active_merchant/billing/gateways/sage.rb
@@ -97,17 +97,17 @@ def supports_scrubbing?
end
def scrub(transcript)
- force_utf8(transcript).
- gsub(%r((M_id=)[^&]*), '\1[FILTERED]').
- gsub(%r((M_key=)[^&]*), '\1[FILTERED]').
- gsub(%r((C_cardnumber=)[^&]*), '\1[FILTERED]').
- gsub(%r((C_cvv=)[^&]*), '\1[FILTERED]').
- gsub(%r((C_rte=)[^&]*), '\1[FILTERED]').
- gsub(%r((C_acct=)[^&]*), '\1[FILTERED]').
- gsub(%r((C_ssn=)[^&]*), '\1[FILTERED]').
- gsub(%r(().+()), '\1[FILTERED]\2').
- gsub(%r(().+()), '\1[FILTERED]\2').
- gsub(%r(().+()), '\1[FILTERED]\2')
+ force_utf8(transcript).
+ gsub(%r((M_id=)[^&]*), '\1[FILTERED]').
+ gsub(%r((M_key=)[^&]*), '\1[FILTERED]').
+ gsub(%r((C_cardnumber=)[^&]*), '\1[FILTERED]').
+ gsub(%r((C_cvv=)[^&]*), '\1[FILTERED]').
+ gsub(%r((C_rte=)[^&]*), '\1[FILTERED]').
+ gsub(%r((C_acct=)[^&]*), '\1[FILTERED]').
+ gsub(%r((C_ssn=)[^&]*), '\1[FILTERED]').
+ gsub(%r(().+()), '\1[FILTERED]\2').
+ gsub(%r(().+()), '\1[FILTERED]\2').
+ gsub(%r(().+()), '\1[FILTERED]\2')
end
private
diff --git a/lib/active_merchant/billing/gateways/sage_pay.rb b/lib/active_merchant/billing/gateways/sage_pay.rb
index 449d7306580..a3cd5f7b657 100644
--- a/lib/active_merchant/billing/gateways/sage_pay.rb
+++ b/lib/active_merchant/billing/gateways/sage_pay.rb
@@ -361,11 +361,11 @@ def authorization_from(response, params, action)
when :store
response['Token']
else
- [ params[:VendorTxCode],
- response['VPSTxId'] || params[:VPSTxId],
- response['TxAuthNo'],
- response['SecurityKey'] || params[:SecurityKey],
- action ].join(';')
+ [ params[:VendorTxCode],
+ response['VPSTxId'] || params[:VPSTxId],
+ response['TxAuthNo'],
+ response['SecurityKey'] || params[:SecurityKey],
+ action ].join(';')
end
end
diff --git a/lib/active_merchant/billing/gateways/wirecard.rb b/lib/active_merchant/billing/gateways/wirecard.rb
index 71134e66e2a..21218896b6a 100644
--- a/lib/active_merchant/billing/gateways/wirecard.rb
+++ b/lib/active_merchant/billing/gateways/wirecard.rb
@@ -202,11 +202,11 @@ def build_request(action, money, options)
xml.tag! 'WIRECARD_BXML' do
xml.tag! 'W_REQUEST' do
xml.tag! 'W_JOB' do
- xml.tag! 'JobID', ''
- # UserID for this transaction
- xml.tag! 'BusinessCaseSignature', options[:signature] || options[:login]
- # Create the whole rest of the message
- add_transaction_data(xml, money, options)
+ xml.tag! 'JobID', ''
+ # UserID for this transaction
+ xml.tag! 'BusinessCaseSignature', options[:signature] || options[:login]
+ # Create the whole rest of the message
+ add_transaction_data(xml, money, options)
end
end
end
diff --git a/test/remote/gateways/remote_first_giving_test.rb b/test/remote/gateways/remote_first_giving_test.rb
index 9c689eb81c1..aa37014c925 100644
--- a/test/remote/gateways/remote_first_giving_test.rb
+++ b/test/remote/gateways/remote_first_giving_test.rb
@@ -32,11 +32,11 @@ def test_failed_purchase
end
def test_successful_refund
- assert purchase = @gateway.purchase(@amount, @credit_card, @options)
- assert_success purchase
+ assert purchase = @gateway.purchase(@amount, @credit_card, @options)
+ assert_success purchase
- assert response = @gateway.refund(@amount, purchase.authorization)
- assert_equal 'REFUND_REQUESTED_AWAITING_REFUND', response.message
+ assert response = @gateway.refund(@amount, purchase.authorization)
+ assert_equal 'REFUND_REQUESTED_AWAITING_REFUND', response.message
end
def test_failed_refund
diff --git a/test/remote/gateways/remote_merchant_one_test.rb b/test/remote/gateways/remote_merchant_one_test.rb
index 2e8969dadc9..0e4f98fb23e 100644
--- a/test/remote/gateways/remote_merchant_one_test.rb
+++ b/test/remote/gateways/remote_merchant_one_test.rb
@@ -48,8 +48,8 @@ def test_authorize_and_capture
end
def test_failed_capture
- assert response = @gateway.capture(@amount, '')
- assert_failure response
+ assert response = @gateway.capture(@amount, '')
+ assert_failure response
end
def test_invalid_login
diff --git a/test/remote/gateways/remote_netaxept_test.rb b/test/remote/gateways/remote_netaxept_test.rb
index 6112d9798c9..0ae763f5876 100644
--- a/test/remote/gateways/remote_netaxept_test.rb
+++ b/test/remote/gateways/remote_netaxept_test.rb
@@ -20,24 +20,24 @@ def test_successful_purchase
end
def test_failed_purchase
- assert response = @gateway.purchase(@amount, @declined_card, @options)
- assert_failure response
- assert_match(/failure/i, response.message)
+ assert response = @gateway.purchase(@amount, @declined_card, @options)
+ assert_failure response
+ assert_match(/failure/i, response.message)
end
def test_authorize_and_capture
- assert auth = @gateway.authorize(@amount, @credit_card, @options)
- assert_success auth
- assert_equal 'OK', auth.message
- assert auth.authorization
- assert capture = @gateway.capture(@amount, auth.authorization)
- assert_success capture
+ assert auth = @gateway.authorize(@amount, @credit_card, @options)
+ assert_success auth
+ assert_equal 'OK', auth.message
+ assert auth.authorization
+ assert capture = @gateway.capture(@amount, auth.authorization)
+ assert_success capture
end
def test_failed_capture
- assert response = @gateway.capture(@amount, '')
- assert_failure response
- assert_equal 'Unable to find transaction', response.message
+ assert response = @gateway.capture(@amount, '')
+ assert_failure response
+ assert_equal 'Unable to find transaction', response.message
end
def test_successful_refund
@@ -49,12 +49,12 @@ def test_successful_refund
end
def test_failed_refund
- assert response = @gateway.purchase(@amount, @credit_card, @options)
- assert_success response
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
+ assert_success response
- response = @gateway.refund(@amount+100, response.authorization)
- assert_failure response
- assert_equal 'Unable to credit more than captured amount', response.message
+ response = @gateway.refund(@amount+100, response.authorization)
+ assert_failure response
+ assert_equal 'Unable to credit more than captured amount', response.message
end
def test_successful_void
@@ -66,46 +66,46 @@ def test_successful_void
end
def test_failed_void
- assert response = @gateway.purchase(@amount, @credit_card, @options)
- assert_success response
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
+ assert_success response
- response = @gateway.void(response.authorization)
- assert_failure response
- assert_equal 'Unable to annul, wrong state', response.message
+ response = @gateway.void(response.authorization)
+ assert_failure response
+ assert_equal 'Unable to annul, wrong state', response.message
end
def test_error_in_transaction_setup
- assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:currency => 'BOGG'))
- assert_failure response
- assert_match(/currency code/, response.message)
+ assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:currency => 'BOGG'))
+ assert_failure response
+ assert_match(/currency code/, response.message)
end
def test_successful_amex_purchase
- credit_card = credit_card('378282246310005', :brand => 'american_express')
- assert response = @gateway.purchase(@amount, credit_card, @options)
- assert_success response
- assert_equal 'OK', response.message
+ credit_card = credit_card('378282246310005', :brand => 'american_express')
+ assert response = @gateway.purchase(@amount, credit_card, @options)
+ assert_success response
+ assert_equal 'OK', response.message
end
def test_successful_master_purchase
- credit_card = credit_card('5413000000000000', :brand => 'master')
- assert response = @gateway.purchase(@amount, credit_card, @options)
- assert_success response
- assert_equal 'OK', response.message
+ credit_card = credit_card('5413000000000000', :brand => 'master')
+ assert response = @gateway.purchase(@amount, credit_card, @options)
+ assert_success response
+ assert_equal 'OK', response.message
end
def test_error_in_payment_details
- assert response = @gateway.purchase(@amount, credit_card(''), @options)
- assert_failure response
- assert_equal 'Cardnumber:Required', response.message
+ assert response = @gateway.purchase(@amount, credit_card(''), @options)
+ assert_failure response
+ assert_equal 'Cardnumber:Required', response.message
end
def test_amount_is_not_required_again_when_capturing_authorization
- assert response = @gateway.authorize(@amount, @credit_card, @options)
- assert_success response
+ assert response = @gateway.authorize(@amount, @credit_card, @options)
+ assert_success response
- assert response = @gateway.capture(nil, response.authorization)
- assert_equal 'OK', response.message
+ assert response = @gateway.capture(nil, response.authorization)
+ assert_equal 'OK', response.message
end
def test_query_fails
@@ -115,12 +115,12 @@ def test_query_fails
end
def test_invalid_login
- gateway = NetaxeptGateway.new(
- :login => '',
- :password => ''
- )
- assert response = gateway.purchase(@amount, @credit_card, @options)
- assert_failure response
- assert_match(/Unable to authenticate merchant/, response.message)
+ gateway = NetaxeptGateway.new(
+ :login => '',
+ :password => ''
+ )
+ assert response = gateway.purchase(@amount, @credit_card, @options)
+ assert_failure response
+ assert_match(/Unable to authenticate merchant/, response.message)
end
end
diff --git a/test/remote/gateways/remote_payflow_uk_test.rb b/test/remote/gateways/remote_payflow_uk_test.rb
index 5a5df22e94a..afe6791cfc8 100644
--- a/test/remote/gateways/remote_payflow_uk_test.rb
+++ b/test/remote/gateways/remote_payflow_uk_test.rb
@@ -47,11 +47,11 @@ def test_declined_purchase
end
def test_successful_purchase_solo
- assert response = @gateway.purchase(100000, @solo, @options)
- assert_equal 'Approved', response.message
- assert_success response
- assert response.test?
- assert_not_nil response.authorization
+ assert response = @gateway.purchase(100000, @solo, @options)
+ assert_equal 'Approved', response.message
+ assert_success response
+ assert response.test?
+ assert_not_nil response.authorization
end
def test_no_card_issue_or_card_start_with_switch
diff --git a/test/remote/gateways/remote_usa_epay_transaction_test.rb b/test/remote/gateways/remote_usa_epay_transaction_test.rb
index a99c5c793e4..e4b6cf3f593 100644
--- a/test/remote/gateways/remote_usa_epay_transaction_test.rb
+++ b/test/remote/gateways/remote_usa_epay_transaction_test.rb
@@ -44,10 +44,10 @@ def test_successful_authorization_with_manual_entry
end
def test_successful_purchase_with_manual_entry
- @credit_card.manual_entry = true
- assert response = @gateway.purchase(@amount, @credit_card, @options)
- assert_equal 'Success', response.message
- assert_success response
+ @credit_card.manual_entry = true
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
+ assert_equal 'Success', response.message
+ assert_success response
end
def test_successful_purchase_with_extra_details
diff --git a/test/unit/gateways/bpoint_test.rb b/test/unit/gateways/bpoint_test.rb
index acdad65c45d..384862ab576 100644
--- a/test/unit/gateways/bpoint_test.rb
+++ b/test/unit/gateways/bpoint_test.rb
@@ -399,23 +399,23 @@ def failed_void_response
end
def successful_store_response
- %(
-
-
-
-
-
- 5999992142370790
- 498765...769
- VC
-
-
- SUCCESS
-
-
-
-
- )
+ %(
+
+
+
+
+
+ 5999992142370790
+ 498765...769
+ VC
+
+
+ SUCCESS
+
+
+
+
+ )
end
def failed_store_response
diff --git a/test/unit/gateways/card_stream_test.rb b/test/unit/gateways/card_stream_test.rb
index 340f954a5e7..e7f225346de 100644
--- a/test/unit/gateways/card_stream_test.rb
+++ b/test/unit/gateways/card_stream_test.rb
@@ -347,7 +347,7 @@ def transcript
end
def scrubbed_transcript
- <<-eos
+ <<-eos
POST /direct/ HTTP/1.1\r\nContent-Type: application/x-www-form-urlencoded\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: gateway.cardstream.com\r\nContent-Length: 501\r\n\r\n"
amount=¤cyCode=826&transactionUnique=a017ca2ac0569188517ad8368c36a06d&orderRef=AM+test+purchase&customerName=Longbob+Longsen&cardNumber=[FILTERED]&cardExpiryMonth=12&cardExpiryYear=14&cardCVV=[FILTERED]&customerAddress=Flat+6%2C+Primrose+Rise+347+Lavender+Road&customerPostCode=NN17+8YG+&merchantID=102922&action=SALE&type=1&countryCode=GB&threeDSRequired=N&signature=970b3fe099a85c9922a79af46c2cb798616b9fbd044a921ac5eb46cd1907a5e89b8c720aae59c7eb1d81a59563f209d5db51aa3c270838199f2bfdcbe2c1149d
eos
diff --git a/test/unit/gateways/cardknox_test.rb b/test/unit/gateways/cardknox_test.rb
index cbddf0b4d46..bc10d5e0e70 100644
--- a/test/unit/gateways/cardknox_test.rb
+++ b/test/unit/gateways/cardknox_test.rb
@@ -201,7 +201,7 @@ def test_scrub
private
def purchase_request
- 'xKey=api_key&xVersion=4.5.4&xSoftwareName=Active+Merchant&xSoftwareVersion=1.52.0&xCommand=cc%3Asale&xAmount=1.00&xCardNum=4242424242424242&xCVV=123&xExp=0916&xName=Longbob+Longsen&xBillFirstName=Longbob&xBillLastName=Longsen&xBillCompany=Widgets+Inc&xBillStreet=456+My+Street&xBillStreet2=Apt+1&xBillCity=Ottawa&xBillState=ON&xBillZip=K1C2N6&xBillCountry=CA&xBillPhone=%28555%29555-5555&xShipFirstName=Longbob&xShipLastName=Longsen&xShipCompany=Widgets+Inc&xShipStreet=456+My+Street&xShipStreet2=Apt+1&xShipCity=Ottawa&xShipState=ON&xShipZip=K1C2N6&xShipCountry=CA&xShipPhone=%28555%29555-5555&xStreet=456+My+Street&xZip=K1C2N6'
+ 'xKey=api_key&xVersion=4.5.4&xSoftwareName=Active+Merchant&xSoftwareVersion=1.52.0&xCommand=cc%3Asale&xAmount=1.00&xCardNum=4242424242424242&xCVV=123&xExp=0916&xName=Longbob+Longsen&xBillFirstName=Longbob&xBillLastName=Longsen&xBillCompany=Widgets+Inc&xBillStreet=456+My+Street&xBillStreet2=Apt+1&xBillCity=Ottawa&xBillState=ON&xBillZip=K1C2N6&xBillCountry=CA&xBillPhone=%28555%29555-5555&xShipFirstName=Longbob&xShipLastName=Longsen&xShipCompany=Widgets+Inc&xShipStreet=456+My+Street&xShipStreet2=Apt+1&xShipCity=Ottawa&xShipState=ON&xShipZip=K1C2N6&xShipCountry=CA&xShipPhone=%28555%29555-5555&xStreet=456+My+Street&xZip=K1C2N6'
end
def successful_purchase_response # passed avs and cvv
@@ -256,7 +256,7 @@ def successful_check_refund_void
end
def successful_verify_response
- 'xResult=A&xStatus=Approved&xError=&xRefNum=15314566&xAuthCode=608755&xBatch=&xAvsResultCode=NNN&xAvsResult=Address%3a+No+Match+%26+5+Digit+Zip%3a+No+Match&xCvvResultCode=N&xCvvResult=No+Match&xAuthAmount=1.00&xToken=09dc51aceb98440fbf0847cad2941d45&xMaskedCardNumber=4xxxxxxxxxxx2224&xName=Longbob+Longsen'
+ 'xResult=A&xStatus=Approved&xError=&xRefNum=15314566&xAuthCode=608755&xBatch=&xAvsResultCode=NNN&xAvsResult=Address%3a+No+Match+%26+5+Digit+Zip%3a+No+Match&xCvvResultCode=N&xCvvResult=No+Match&xAuthAmount=1.00&xToken=09dc51aceb98440fbf0847cad2941d45&xMaskedCardNumber=4xxxxxxxxxxx2224&xName=Longbob+Longsen'
end
def failed_verify_response
@@ -264,10 +264,10 @@ def failed_verify_response
end
def pre_scrubbed
- 'xKey=api_key&xVersion=4.5.4&xSoftwareName=Active+Merchant&xSoftwareVersion=1.52.0&xCommand=cc%3Asale&xAmount=1.00&xCardNum=4242424242424242&xCVV=123&xExp=0916&xName=Longbob+Longsen&xBillFirstName=Longbob&xBillLastName=Longsen&xBillCompany=Widgets+Inc&xBillStreet=456+My+Street&xBillStreet2=Apt+1&xBillCity=Ottawa&xBillState=ON&xBillZip=K1C2N6&xBillCountry=CA&xBillPhone=%28555%29555-5555&xShipFirstName=Longbob&xShipLastName=Longsen&xShipCompany=Widgets+Inc&xShipStreet=456+My+Street&xShipStreet2=Apt+1&xShipCity=Ottawa&xShipState=ON&xShipZip=K1C2N6&xShipCountry=CA&xShipPhone=%28555%29555-5555&xStreet=456+My+Street&xZip=K1C2N6'
+ 'xKey=api_key&xVersion=4.5.4&xSoftwareName=Active+Merchant&xSoftwareVersion=1.52.0&xCommand=cc%3Asale&xAmount=1.00&xCardNum=4242424242424242&xCVV=123&xExp=0916&xName=Longbob+Longsen&xBillFirstName=Longbob&xBillLastName=Longsen&xBillCompany=Widgets+Inc&xBillStreet=456+My+Street&xBillStreet2=Apt+1&xBillCity=Ottawa&xBillState=ON&xBillZip=K1C2N6&xBillCountry=CA&xBillPhone=%28555%29555-5555&xShipFirstName=Longbob&xShipLastName=Longsen&xShipCompany=Widgets+Inc&xShipStreet=456+My+Street&xShipStreet2=Apt+1&xShipCity=Ottawa&xShipState=ON&xShipZip=K1C2N6&xShipCountry=CA&xShipPhone=%28555%29555-5555&xStreet=456+My+Street&xZip=K1C2N6'
end
def post_scrubbed
- 'xKey=[FILTERED]&xVersion=4.5.4&xSoftwareName=Active+Merchant&xSoftwareVersion=1.52.0&xCommand=cc%3Asale&xAmount=1.00&xCardNum=[FILTERED]&xCVV=[FILTERED]&xExp=0916&xName=Longbob+Longsen&xBillFirstName=Longbob&xBillLastName=Longsen&xBillCompany=Widgets+Inc&xBillStreet=456+My+Street&xBillStreet2=Apt+1&xBillCity=Ottawa&xBillState=ON&xBillZip=K1C2N6&xBillCountry=CA&xBillPhone=%28555%29555-5555&xShipFirstName=Longbob&xShipLastName=Longsen&xShipCompany=Widgets+Inc&xShipStreet=456+My+Street&xShipStreet2=Apt+1&xShipCity=Ottawa&xShipState=ON&xShipZip=K1C2N6&xShipCountry=CA&xShipPhone=%28555%29555-5555&xStreet=456+My+Street&xZip=K1C2N6'
+ 'xKey=[FILTERED]&xVersion=4.5.4&xSoftwareName=Active+Merchant&xSoftwareVersion=1.52.0&xCommand=cc%3Asale&xAmount=1.00&xCardNum=[FILTERED]&xCVV=[FILTERED]&xExp=0916&xName=Longbob+Longsen&xBillFirstName=Longbob&xBillLastName=Longsen&xBillCompany=Widgets+Inc&xBillStreet=456+My+Street&xBillStreet2=Apt+1&xBillCity=Ottawa&xBillState=ON&xBillZip=K1C2N6&xBillCountry=CA&xBillPhone=%28555%29555-5555&xShipFirstName=Longbob&xShipLastName=Longsen&xShipCompany=Widgets+Inc&xShipStreet=456+My+Street&xShipStreet2=Apt+1&xShipCity=Ottawa&xShipState=ON&xShipZip=K1C2N6&xShipCountry=CA&xShipPhone=%28555%29555-5555&xStreet=456+My+Street&xZip=K1C2N6'
end
end
diff --git a/test/unit/gateways/elavon_test.rb b/test/unit/gateways/elavon_test.rb
index a5456d577d4..cf8557ce0af 100644
--- a/test/unit/gateways/elavon_test.rb
+++ b/test/unit/gateways/elavon_test.rb
@@ -372,7 +372,7 @@ def failed_void_response
end
def invalid_login_response
- <<-RESPONSE
+ <<-RESPONSE
ssl_result=7000\r
ssl_result_message=The VirtualMerchant ID and/or User ID supplied in the authorization request is invalid.\r
RESPONSE
diff --git a/test/unit/gateways/eway_test.rb b/test/unit/gateways/eway_test.rb
index bae6c709504..5c1059163e5 100644
--- a/test/unit/gateways/eway_test.rb
+++ b/test/unit/gateways/eway_test.rb
@@ -70,11 +70,11 @@ def test_failed_refund
end
def test_amount_style
- assert_equal '1034', @gateway.send(:amount, 1034)
+ assert_equal '1034', @gateway.send(:amount, 1034)
- assert_raise(ArgumentError) do
- @gateway.send(:amount, '10.34')
- end
+ assert_raise(ArgumentError) do
+ @gateway.send(:amount, '10.34')
+ end
end
def test_ensure_does_not_respond_to_authorize
diff --git a/test/unit/gateways/gateway_test.rb b/test/unit/gateways/gateway_test.rb
index 56a957f6109..3372ee5de13 100644
--- a/test/unit/gateways/gateway_test.rb
+++ b/test/unit/gateways/gateway_test.rb
@@ -46,11 +46,11 @@ def test_should_be_able_to_look_for_test_mode
end
def test_amount_style
- assert_equal '10.34', @gateway.send(:amount, 1034)
+ assert_equal '10.34', @gateway.send(:amount, 1034)
- assert_raise(ArgumentError) do
- @gateway.send(:amount, '10.34')
- end
+ assert_raise(ArgumentError) do
+ @gateway.send(:amount, '10.34')
+ end
end
def test_card_brand
diff --git a/test/unit/gateways/hps_test.rb b/test/unit/gateways/hps_test.rb
index 107ec989b05..0f85bf5a2cb 100644
--- a/test/unit/gateways/hps_test.rb
+++ b/test/unit/gateways/hps_test.rb
@@ -270,7 +270,7 @@ def failed_charge_response
end
def successful_authorize_response
- <<-RESPONSE
+ <<-RESPONSE
diff --git a/test/unit/gateways/metrics_global_test.rb b/test/unit/gateways/metrics_global_test.rb
index 5cf3c841bff..0184ddfbeff 100644
--- a/test/unit/gateways/metrics_global_test.rb
+++ b/test/unit/gateways/metrics_global_test.rb
@@ -90,12 +90,12 @@ def test_add_duplicate_window_with_duplicate_window
end
def test_purchase_is_valid_csv
- params = { :amount => '1.01' }
+ params = { :amount => '1.01' }
- @gateway.send(:add_creditcard, params, @credit_card)
+ @gateway.send(:add_creditcard, params, @credit_card)
- assert data = @gateway.send(:post_data, 'AUTH_ONLY', params)
- assert_equal post_data_fixture.size, data.size
+ assert data = @gateway.send(:post_data, 'AUTH_ONLY', params)
+ assert_equal post_data_fixture.size, data.size
end
def test_purchase_meets_minimum_requirements
diff --git a/test/unit/gateways/moneris_test.rb b/test/unit/gateways/moneris_test.rb
index a4144b398d5..f1cdffd5488 100644
--- a/test/unit/gateways/moneris_test.rb
+++ b/test/unit/gateways/moneris_test.rb
@@ -122,53 +122,53 @@ def test_refund
end
def test_amount_style
- assert_equal '10.34', @gateway.send(:amount, 1034)
+ assert_equal '10.34', @gateway.send(:amount, 1034)
- assert_raise(ArgumentError) do
- @gateway.send(:amount, '10.34')
- end
+ assert_raise(ArgumentError) do
+ @gateway.send(:amount, '10.34')
+ end
end
def test_preauth_is_valid_xml
- params = {
- :order_id => 'order1',
- :amount => '1.01',
- :pan => '4242424242424242',
- :expdate => '0303',
- :crypt_type => 7,
- }
+ params = {
+ :order_id => 'order1',
+ :amount => '1.01',
+ :pan => '4242424242424242',
+ :expdate => '0303',
+ :crypt_type => 7,
+ }
- assert data = @gateway.send(:post_data, 'preauth', params)
- assert REXML::Document.new(data)
- assert_equal xml_capture_fixture.size, data.size
+ assert data = @gateway.send(:post_data, 'preauth', params)
+ assert REXML::Document.new(data)
+ assert_equal xml_capture_fixture.size, data.size
end
def test_purchase_is_valid_xml
- params = {
- :order_id => 'order1',
- :amount => '1.01',
- :pan => '4242424242424242',
- :expdate => '0303',
- :crypt_type => 7,
- }
+ params = {
+ :order_id => 'order1',
+ :amount => '1.01',
+ :pan => '4242424242424242',
+ :expdate => '0303',
+ :crypt_type => 7,
+ }
- assert data = @gateway.send(:post_data, 'purchase', params)
- assert REXML::Document.new(data)
- assert_equal xml_purchase_fixture.size, data.size
+ assert data = @gateway.send(:post_data, 'purchase', params)
+ assert REXML::Document.new(data)
+ assert_equal xml_purchase_fixture.size, data.size
end
def test_capture_is_valid_xml
- params = {
- :order_id => 'order1',
- :amount => '1.01',
- :pan => '4242424242424242',
- :expdate => '0303',
- :crypt_type => 7,
- }
+ params = {
+ :order_id => 'order1',
+ :amount => '1.01',
+ :pan => '4242424242424242',
+ :expdate => '0303',
+ :crypt_type => 7,
+ }
- assert data = @gateway.send(:post_data, 'preauth', params)
- assert REXML::Document.new(data)
- assert_equal xml_capture_fixture.size, data.size
+ assert data = @gateway.send(:post_data, 'preauth', params)
+ assert REXML::Document.new(data)
+ assert_equal xml_capture_fixture.size, data.size
end
def test_successful_verify
@@ -717,11 +717,11 @@ def failed_void_response
end
def xml_purchase_fixture
- 'store1yesguy1.01424242424242424203037order1'
+ 'store1yesguy1.01424242424242424203037order1'
end
def xml_capture_fixture
- 'store1yesguy1.01424242424242424203037order1'
+ 'store1yesguy1.01424242424242424203037order1'
end
def pre_scrub
diff --git a/test/unit/gateways/moneris_us_test.rb b/test/unit/gateways/moneris_us_test.rb
index 46aa128e20b..b2bff66d3d1 100644
--- a/test/unit/gateways/moneris_us_test.rb
+++ b/test/unit/gateways/moneris_us_test.rb
@@ -90,53 +90,53 @@ def test_failed_verify
end
def test_amount_style
- assert_equal '10.34', @gateway.send(:amount, 1034)
+ assert_equal '10.34', @gateway.send(:amount, 1034)
- assert_raise(ArgumentError) do
- @gateway.send(:amount, '10.34')
- end
+ assert_raise(ArgumentError) do
+ @gateway.send(:amount, '10.34')
+ end
end
def test_preauth_is_valid_xml
- params = {
- :order_id => 'order1',
- :amount => '1.01',
- :pan => '4242424242424242',
- :expdate => '0303',
- :crypt_type => 7,
- }
+ params = {
+ :order_id => 'order1',
+ :amount => '1.01',
+ :pan => '4242424242424242',
+ :expdate => '0303',
+ :crypt_type => 7,
+ }
- assert data = @gateway.send(:post_data, 'us_preauth', params)
- assert REXML::Document.new(data)
- assert_equal xml_capture_fixture.size, data.size
+ assert data = @gateway.send(:post_data, 'us_preauth', params)
+ assert REXML::Document.new(data)
+ assert_equal xml_capture_fixture.size, data.size
end
def test_purchase_is_valid_xml
- params = {
- :order_id => 'order1',
- :amount => '1.01',
- :pan => '4242424242424242',
- :expdate => '0303',
- :crypt_type => 7,
- }
+ params = {
+ :order_id => 'order1',
+ :amount => '1.01',
+ :pan => '4242424242424242',
+ :expdate => '0303',
+ :crypt_type => 7,
+ }
- assert data = @gateway.send(:post_data, 'us_purchase', params)
- assert REXML::Document.new(data)
- assert_equal xml_purchase_fixture.size, data.size
+ assert data = @gateway.send(:post_data, 'us_purchase', params)
+ assert REXML::Document.new(data)
+ assert_equal xml_purchase_fixture.size, data.size
end
def test_capture_is_valid_xml
- params = {
- :order_id => 'order1',
- :amount => '1.01',
- :pan => '4242424242424242',
- :expdate => '0303',
- :crypt_type => 7,
- }
+ params = {
+ :order_id => 'order1',
+ :amount => '1.01',
+ :pan => '4242424242424242',
+ :expdate => '0303',
+ :crypt_type => 7,
+ }
- assert data = @gateway.send(:post_data, 'us_preauth', params)
- assert REXML::Document.new(data)
- assert_equal xml_capture_fixture.size, data.size
+ assert data = @gateway.send(:post_data, 'us_preauth', params)
+ assert REXML::Document.new(data)
+ assert_equal xml_capture_fixture.size, data.size
end
def test_supported_countries
@@ -591,11 +591,11 @@ def successful_echeck_purchase_response
end
def xml_purchase_fixture
- 'monusqa002qatoken1.01424242424242424203037order1'
+ 'monusqa002qatoken1.01424242424242424203037order1'
end
def xml_capture_fixture
- 'monusqa002qatoken1.01424242424242424203037order1'
+ 'monusqa002qatoken1.01424242424242424203037order1'
end
def pre_scrub
diff --git a/test/unit/gateways/netbanx_test.rb b/test/unit/gateways/netbanx_test.rb
index cb9af17b688..a4a424d27f3 100644
--- a/test/unit/gateways/netbanx_test.rb
+++ b/test/unit/gateways/netbanx_test.rb
@@ -140,15 +140,15 @@ def test_successful_purchase_with_token
end
def test_successful_unstore
- @gateway.expects(:ssl_request).twice.returns(successful_unstore_response)
+ @gateway.expects(:ssl_request).twice.returns(successful_unstore_response)
- response = @gateway.unstore('2f840ab3-0e71-4387-bad3-4705e6f4b015|e4a3cd5a-56db-4d9b-97d3-fdd9ab3bd0f4')
- assert_success response
- assert response.test?
+ response = @gateway.unstore('2f840ab3-0e71-4387-bad3-4705e6f4b015|e4a3cd5a-56db-4d9b-97d3-fdd9ab3bd0f4')
+ assert_success response
+ assert response.test?
- response = @gateway.unstore('2f840ab3-0e71-4387-bad3-4705e6f4b015')
- assert_success response
- assert response.test?
+ response = @gateway.unstore('2f840ab3-0e71-4387-bad3-4705e6f4b015')
+ assert_success response
+ assert response.test?
end
def test_scrub
diff --git a/test/unit/gateways/omise_test.rb b/test/unit/gateways/omise_test.rb
index c3e99f0d83c..5c31855fd64 100644
--- a/test/unit/gateways/omise_test.rb
+++ b/test/unit/gateways/omise_test.rb
@@ -39,8 +39,8 @@ def test_scrub
end
def test_gateway_url
- assert_equal 'https://api.omise.co/', OmiseGateway::API_URL
- assert_equal 'https://vault.omise.co/', OmiseGateway::VAULT_URL
+ assert_equal 'https://api.omise.co/', OmiseGateway::API_URL
+ assert_equal 'https://vault.omise.co/', OmiseGateway::VAULT_URL
end
def test_request_headers
diff --git a/test/unit/gateways/opp_test.rb b/test/unit/gateways/opp_test.rb
index 7302649b7da..a59885917d5 100644
--- a/test/unit/gateways/opp_test.rb
+++ b/test/unit/gateways/opp_test.rb
@@ -179,11 +179,11 @@ def test_scrub
private
def pre_scrubbed
- 'paymentType=DB&amount=1.00¤cy=EUR&paymentBrand=VISA&card.holder=Longbob+Longsen&card.number=4200000000000000&card.expiryMonth=05&card.expiryYear=2018& card.cvv=123&billing.street1=456+My+Street&billing.street2=Apt+1&billing.city=Ottawa&billing.state=ON&billing.postcode=K1C2N6&billing.country=CA&authentication.entityId=8a8294174b7ecb28014b9699220015ca&authentication.password=sy6KJsT8&authentication.userId=8a8294174b7ecb28014b9699220015cc'
+ 'paymentType=DB&amount=1.00¤cy=EUR&paymentBrand=VISA&card.holder=Longbob+Longsen&card.number=4200000000000000&card.expiryMonth=05&card.expiryYear=2018& card.cvv=123&billing.street1=456+My+Street&billing.street2=Apt+1&billing.city=Ottawa&billing.state=ON&billing.postcode=K1C2N6&billing.country=CA&authentication.entityId=8a8294174b7ecb28014b9699220015ca&authentication.password=sy6KJsT8&authentication.userId=8a8294174b7ecb28014b9699220015cc'
end
def post_scrubbed
- 'paymentType=DB&amount=1.00¤cy=EUR&paymentBrand=VISA&card.holder=Longbob+Longsen&card.number=[FILTERED]&card.expiryMonth=05&card.expiryYear=2018& card.cvv=[FILTERED]&billing.street1=456+My+Street&billing.street2=Apt+1&billing.city=Ottawa&billing.state=ON&billing.postcode=K1C2N6&billing.country=CA&authentication.entityId=8a8294174b7ecb28014b9699220015ca&authentication.password=[FILTERED]&authentication.userId=8a8294174b7ecb28014b9699220015cc'
+ 'paymentType=DB&amount=1.00¤cy=EUR&paymentBrand=VISA&card.holder=Longbob+Longsen&card.number=[FILTERED]&card.expiryMonth=05&card.expiryYear=2018& card.cvv=[FILTERED]&billing.street1=456+My+Street&billing.street2=Apt+1&billing.city=Ottawa&billing.state=ON&billing.postcode=K1C2N6&billing.country=CA&authentication.entityId=8a8294174b7ecb28014b9699220015ca&authentication.password=[FILTERED]&authentication.userId=8a8294174b7ecb28014b9699220015cc'
end
def successful_response(type, id)
diff --git a/test/unit/gateways/orbital_test.rb b/test/unit/gateways/orbital_test.rb
index f030672e46c..2d3e8d8f3f3 100644
--- a/test/unit/gateways/orbital_test.rb
+++ b/test/unit/gateways/orbital_test.rb
@@ -217,14 +217,14 @@ def test_truncates_phone
end
def test_truncates_zip
- long_zip = '1234567890123'
-
- response = stub_comms do
- @gateway.purchase(50, credit_card, :order_id => 1, :billing_address => address(:zip => long_zip))
- end.check_request do |endpoint, data, headers|
- assert_match(/1234567890, data)
- end.respond_with(successful_purchase_response)
- assert_success response
+ long_zip = '1234567890123'
+
+ response = stub_comms do
+ @gateway.purchase(50, credit_card, :order_id => 1, :billing_address => address(:zip => long_zip))
+ end.check_request do |endpoint, data, headers|
+ assert_match(/1234567890, data)
+ end.respond_with(successful_purchase_response)
+ assert_success response
end
def test_address_format
diff --git a/test/unit/gateways/pagarme_test.rb b/test/unit/gateways/pagarme_test.rb
index 4b12bb2739d..3944a780cd2 100644
--- a/test/unit/gateways/pagarme_test.rb
+++ b/test/unit/gateways/pagarme_test.rb
@@ -614,7 +614,7 @@ def successful_capture_response
end
def failed_capture_response
- <<-FAILED_RESPONSE
+ <<-FAILED_RESPONSE
{
"errors": [
{
@@ -630,7 +630,7 @@ def failed_capture_response
end
def successful_refund_response
- <<-SUCCESS_RESPONSE
+ <<-SUCCESS_RESPONSE
{
"acquirer_name": "development",
"acquirer_response_code": "00",
@@ -688,7 +688,7 @@ def successful_refund_response
end
def failed_refund_response
- <<-FAILED_RESPONSE
+ <<-FAILED_RESPONSE
{
"errors": [
{
@@ -704,7 +704,7 @@ def failed_refund_response
end
def successful_void_response
- <<-SUCCESS_RESPONSE
+ <<-SUCCESS_RESPONSE
{
"acquirer_name": "pagarme",
"acquirer_response_code": "00",
@@ -762,7 +762,7 @@ def successful_void_response
end
def failed_void_response
- <<-FAILED_RESPONSE
+ <<-FAILED_RESPONSE
{
"errors": [
{
@@ -778,7 +778,7 @@ def failed_void_response
end
def successful_verify_response
- <<-SUCCESS_RESPONSE
+ <<-SUCCESS_RESPONSE
{
"acquirer_name": "pagarme",
"acquirer_response_code": "00",
@@ -836,7 +836,7 @@ def successful_verify_response
end
def successful_verify_void_response
- <<-SUCCESS_RESPONSE
+ <<-SUCCESS_RESPONSE
{
"acquirer_name": "pagarme",
"acquirer_response_code": "00",
@@ -894,7 +894,7 @@ def successful_verify_void_response
end
def failed_verify_response
- <<-FAILED_RESPONSE
+ <<-FAILED_RESPONSE
{
"acquirer_name": "pagarme",
"acquirer_response_code": "88",
@@ -968,7 +968,7 @@ def failed_error_response
end
def failed_json_response
- <<-SUCCESS_RESPONSE
+ <<-SUCCESS_RESPONSE
{
foo: bar
}
diff --git a/test/unit/gateways/payflow_test.rb b/test/unit/gateways/payflow_test.rb
index 2ddee59bb92..01a4ed9cb0b 100644
--- a/test/unit/gateways/payflow_test.rb
+++ b/test/unit/gateways/payflow_test.rb
@@ -540,7 +540,7 @@ def successful_recurring_response
end
def start_date_error_recurring_response
- <<-XML
+ <<-XML
0
Field format error: START or NEXTPAYMENTDATE older than last payment date
@@ -553,7 +553,7 @@ def start_date_error_recurring_response
end
def start_date_missing_recurring_response
- <<-XML
+ <<-XML
0
Field format error: START field missing
diff --git a/test/unit/gateways/paypal/paypal_common_api_test.rb b/test/unit/gateways/paypal/paypal_common_api_test.rb
index 588406406e0..49751604ab9 100644
--- a/test/unit/gateways/paypal/paypal_common_api_test.rb
+++ b/test/unit/gateways/paypal/paypal_common_api_test.rb
@@ -86,7 +86,7 @@ def test_build_request_wrapper_plain
def test_build_request_wrapper_with_request_details
result = @gateway.send(:build_request_wrapper, 'Action', :request_details => true) do |xml|
- xml.tag! 'n2:TransactionID', 'baz'
+ xml.tag! 'n2:TransactionID', 'baz'
end
assert_equal 'baz', REXML::XPath.first(REXML::Document.new(result), '//ActionReq/ActionRequest/n2:ActionRequestDetails/n2:TransactionID').text
end
diff --git a/test/unit/gateways/paypal_digital_goods_test.rb b/test/unit/gateways/paypal_digital_goods_test.rb
index ab7cf6c03eb..4b433f38843 100644
--- a/test/unit/gateways/paypal_digital_goods_test.rb
+++ b/test/unit/gateways/paypal_digital_goods_test.rb
@@ -33,45 +33,45 @@ def test_test_redirect_url
end
def test_setup_request_invalid_requests
- assert_raise ArgumentError do
- @gateway.setup_purchase(100,
- :ip => '127.0.0.1',
- :description => 'Test Title',
- :return_url => 'http://return.url',
- :cancel_return_url => 'http://cancel.url')
- end
+ assert_raise ArgumentError do
+ @gateway.setup_purchase(100,
+ :ip => '127.0.0.1',
+ :description => 'Test Title',
+ :return_url => 'http://return.url',
+ :cancel_return_url => 'http://cancel.url')
+ end
- assert_raise ArgumentError do
- @gateway.setup_purchase(100,
- :ip => '127.0.0.1',
- :description => 'Test Title',
- :return_url => 'http://return.url',
- :cancel_return_url => 'http://cancel.url',
- :items => [ ])
- end
+ assert_raise ArgumentError do
+ @gateway.setup_purchase(100,
+ :ip => '127.0.0.1',
+ :description => 'Test Title',
+ :return_url => 'http://return.url',
+ :cancel_return_url => 'http://cancel.url',
+ :items => [ ])
+ end
- assert_raise ArgumentError do
- @gateway.setup_purchase(100,
- :ip => '127.0.0.1',
- :description => 'Test Title',
- :return_url => 'http://return.url',
- :cancel_return_url => 'http://cancel.url',
- :items => [ Hash.new ])
- end
+ assert_raise ArgumentError do
+ @gateway.setup_purchase(100,
+ :ip => '127.0.0.1',
+ :description => 'Test Title',
+ :return_url => 'http://return.url',
+ :cancel_return_url => 'http://cancel.url',
+ :items => [ Hash.new ])
+ end
- assert_raise ArgumentError do
- @gateway.setup_purchase(100,
- :ip => '127.0.0.1',
- :description => 'Test Title',
- :return_url => 'http://return.url',
- :cancel_return_url => 'http://cancel.url',
- :items => [ { :name => 'Charge',
- :number => '1',
- :quantity => '1',
- :amount => 100,
- :description => 'Description',
- :category => 'Physical' } ])
- end
+ assert_raise ArgumentError do
+ @gateway.setup_purchase(100,
+ :ip => '127.0.0.1',
+ :description => 'Test Title',
+ :return_url => 'http://return.url',
+ :cancel_return_url => 'http://cancel.url',
+ :items => [ { :name => 'Charge',
+ :number => '1',
+ :quantity => '1',
+ :amount => 100,
+ :description => 'Description',
+ :category => 'Physical' } ])
+ end
end
def test_build_setup_request_valid
@@ -93,30 +93,30 @@ def test_build_setup_request_valid
private
def successful_setup_response
-"
-
-
-
-
-
-
-
- OMGOMGOMGOMGOMG
-
-
-
-
-
-
- 2011-05-19T20:13:30Z
- Success
- da0ed6bc90ef1
- 72
- 1882144
- EC-0XOMGOMGOMG
-
-
- "
+ "
+
+
+
+
+
+
+
+ OMGOMGOMGOMGOMG
+
+
+
+
+
+
+ 2011-05-19T20:13:30Z
+ Success
+ da0ed6bc90ef1
+ 72
+ 1882144
+ EC-0XOMGOMGOMG
+
+
+ "
end
end
diff --git a/test/unit/gateways/paypal_express_test.rb b/test/unit/gateways/paypal_express_test.rb
index 1eef9513781..61c506558a1 100644
--- a/test/unit/gateways/paypal_express_test.rb
+++ b/test/unit/gateways/paypal_express_test.rb
@@ -779,7 +779,7 @@ def successful_create_billing_agreement_response
end
def successful_authorize_reference_transaction_response
- <<-RESPONSE
+ <<-RESPONSE
diff --git a/test/unit/gateways/trust_commerce_test.rb b/test/unit/gateways/trust_commerce_test.rb
index fbba691fece..08feafb188b 100644
--- a/test/unit/gateways/trust_commerce_test.rb
+++ b/test/unit/gateways/trust_commerce_test.rb
@@ -29,11 +29,11 @@ def test_unsuccessful_purchase
end
def test_amount_style
- assert_equal '1034', @gateway.send(:amount, 1034)
+ assert_equal '1034', @gateway.send(:amount, 1034)
- assert_raise(ArgumentError) do
- @gateway.send(:amount, '10.34')
- end
+ assert_raise(ArgumentError) do
+ @gateway.send(:amount, '10.34')
+ end
end
def test_avs_result
diff --git a/test/unit/gateways/usa_epay_transaction_test.rb b/test/unit/gateways/usa_epay_transaction_test.rb
index 753e74ba13b..5318db9c1f9 100644
--- a/test/unit/gateways/usa_epay_transaction_test.rb
+++ b/test/unit/gateways/usa_epay_transaction_test.rb
@@ -348,11 +348,11 @@ def test_add_test_mode_with_false_test_mode_option
end
def test_amount_style
- assert_equal '10.34', @gateway.send(:amount, 1034)
+ assert_equal '10.34', @gateway.send(:amount, 1034)
- assert_raise(ArgumentError) do
- @gateway.send(:amount, '10.34')
- end
+ assert_raise(ArgumentError) do
+ @gateway.send(:amount, '10.34')
+ end
end
def test_supported_countries
diff --git a/test/unit/gateways/verifi_test.rb b/test/unit/gateways/verifi_test.rb
index 7debaabf3cd..404556b2d6c 100644
--- a/test/unit/gateways/verifi_test.rb
+++ b/test/unit/gateways/verifi_test.rb
@@ -61,7 +61,7 @@ def test_amount_style
assert_equal '10.34', @gateway.send(:amount, 1034)
assert_raise(ArgumentError) do
- @gateway.send(:amount, '10.34')
+ @gateway.send(:amount, '10.34')
end
end
diff --git a/test/unit/gateways/visanet_peru_test.rb b/test/unit/gateways/visanet_peru_test.rb
index bbf3af32b47..49b7a78951b 100644
--- a/test/unit/gateways/visanet_peru_test.rb
+++ b/test/unit/gateways/visanet_peru_test.rb
@@ -299,7 +299,7 @@ def failed_authorize_response_bad_email
end
def successful_capture_response
- '{"errorCode":0,"errorMessage":"OK","transactionUUID":"8517cf68-4820-4224-959b-01c8117385e0","externalTransactionId":"de9dc65c094fb4f1defddc562731af81","transactionDateTime":1519937673906,"transactionDuration":0,"merchantId":"543025501","userTokenId":null,"aliasName":null,"data":{"FECHAYHORA_TX":null,"DSC_ECI":null,"DSC_COD_ACCION":null,"NOM_EMISOR":null,"ESTADO":"Depositado","RESPUESTA":"1","ID_UNICO":null,"NUMORDEN":null,"CODACCION":null,"ETICKET":null,"IMP_AUTORIZADO":null,"DECISIONCS":null,"COD_AUTORIZA":null,"CODTIENDA":"543025501","PAN":null,"ORI_TARJETA":null}}'
+ '{"errorCode":0,"errorMessage":"OK","transactionUUID":"8517cf68-4820-4224-959b-01c8117385e0","externalTransactionId":"de9dc65c094fb4f1defddc562731af81","transactionDateTime":1519937673906,"transactionDuration":0,"merchantId":"543025501","userTokenId":null,"aliasName":null,"data":{"FECHAYHORA_TX":null,"DSC_ECI":null,"DSC_COD_ACCION":null,"NOM_EMISOR":null,"ESTADO":"Depositado","RESPUESTA":"1","ID_UNICO":null,"NUMORDEN":null,"CODACCION":null,"ETICKET":null,"IMP_AUTORIZADO":null,"DECISIONCS":null,"COD_AUTORIZA":null,"CODTIENDA":"543025501","PAN":null,"ORI_TARJETA":null}}'
end
def failed_capture_response
diff --git a/test/unit/gateways/worldpay_test.rb b/test/unit/gateways/worldpay_test.rb
index 031deef53ff..4e129b76d55 100644
--- a/test/unit/gateways/worldpay_test.rb
+++ b/test/unit/gateways/worldpay_test.rb
@@ -4,14 +4,14 @@ class WorldpayTest < Test::Unit::TestCase
include CommStub
def setup
- @gateway = WorldpayGateway.new(
- :login => 'testlogin',
- :password => 'testpassword'
- )
+ @gateway = WorldpayGateway.new(
+ :login => 'testlogin',
+ :password => 'testpassword'
+ )
- @amount = 100
- @credit_card = credit_card('4242424242424242')
- @options = {:order_id => 1}
+ @amount = 100
+ @credit_card = credit_card('4242424242424242')
+ @options = {:order_id => 1}
end
def test_successful_authorize
From 989fd1fb886e23a3a49f51609fe303586d36bbb7 Mon Sep 17 00:00:00 2001
From: Filipe Costa
Date: Thu, 29 Nov 2018 13:22:05 -0500
Subject: [PATCH 0197/2234] Missing CHANGELOG release title (#3066)
---
CHANGELOG | 2 ++
1 file changed, 2 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index 5198e278bed..bdf211e3ffe 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,8 @@
= ActiveMerchant CHANGELOG
== HEAD
+
+== Version 1.87.0 (November 29, 2018)
* Barclaycard Smartpay: Improves Error Handling [deedeelavinder] #3026
* Braintree: Fix passing phone-only billing address [curiousepic] #3025
* Litle: Capitalize check account type [curiousepic] #3028
From 942e902f63cc5d45d788ebf3ef5448d34f6e5c82 Mon Sep 17 00:00:00 2001
From: Edouard Chin
Date: Fri, 30 Nov 2018 14:52:34 +0100
Subject: [PATCH 0198/2234] Remove the upperbound constraint on ActiveSupport:
(#3065)
- During every ActiveSupport major bump, this gemspec needs to be updated,
I think we are being too conservative and having an upperbound limit
doesn't help.
If we wanted to be really conservative we would have to add a
upperbound constraint on the minor version as well (`< 5.x`) since
Rails doesn't follow semver and minor version can introduce breaking
changes.
What I think is better is to remove the upperbound constraint,
and test AM directly on ActiveSupport edge.
Looking at the commit rates on this project, CI would run
largely enough to cover us. But we can also add another safety net
and run travis on a schedule.
---
.travis.yml | 6 ++++++
activemerchant.gemspec | 2 +-
gemfiles/Gemfile.rails_master | 3 +++
3 files changed, 10 insertions(+), 1 deletion(-)
create mode 100644 gemfiles/Gemfile.rails_master
diff --git a/.travis.yml b/.travis.yml
index 68ff33a3358..e2207604777 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -12,6 +12,7 @@ gemfile:
- gemfiles/Gemfile.rails51
- gemfiles/Gemfile.rails50
- gemfiles/Gemfile.rails42
+- gemfiles/Gemfile.rails_master
jobs:
include:
@@ -19,6 +20,11 @@ jobs:
gemfile: Gemfile
script: bundle exec rubocop --parallel
+matrix:
+ exclude:
+ - rvm: 2.3
+ gemfile: 'gemfiles/Gemfile.rails_master'
+
notifications:
email:
on_success: never
diff --git a/activemerchant.gemspec b/activemerchant.gemspec
index 031b34b2576..bb9ea4e14f8 100644
--- a/activemerchant.gemspec
+++ b/activemerchant.gemspec
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
s.has_rdoc = true if Gem::VERSION < '1.7.0'
- s.add_dependency('activesupport', '>= 4.2', '< 6.x')
+ s.add_dependency('activesupport', '>= 4.2')
s.add_dependency('i18n', '>= 0.6.9')
s.add_dependency('builder', '>= 2.1.2', '< 4.0.0')
s.add_dependency('nokogiri', '~> 1.4')
diff --git a/gemfiles/Gemfile.rails_master b/gemfiles/Gemfile.rails_master
new file mode 100644
index 00000000000..04b88ec1b00
--- /dev/null
+++ b/gemfiles/Gemfile.rails_master
@@ -0,0 +1,3 @@
+eval_gemfile '../Gemfile'
+
+gem 'activesupport', github: 'rails/rails'
From 427bccfcfe29605cc4f4e5a1fffdf09025f3c7b1 Mon Sep 17 00:00:00 2001
From: Filipe Costa
Date: Fri, 30 Nov 2018 08:57:57 -0500
Subject: [PATCH 0199/2234] Release v1.88.0
---
CHANGELOG | 3 +++
lib/active_merchant/version.rb | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index bdf211e3ffe..6e44bd12a6b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,9 @@
== HEAD
+== Version 1.88.0 (November 30, 2018)
+* Added ActiveSupport/Rails master support [Edouard-chin] #3065
+
== Version 1.87.0 (November 29, 2018)
* Barclaycard Smartpay: Improves Error Handling [deedeelavinder] #3026
* Braintree: Fix passing phone-only billing address [curiousepic] #3025
diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb
index 54f720d8bf0..5af2175368e 100644
--- a/lib/active_merchant/version.rb
+++ b/lib/active_merchant/version.rb
@@ -1,3 +1,3 @@
module ActiveMerchant
- VERSION = '1.87.0'
+ VERSION = '1.88.0'
end
From 7071f2b9b92c3328bc7c33630cfbe4faece2521b Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Thu, 29 Nov 2018 16:35:09 -0500
Subject: [PATCH 0200/2234] Worldpay: support MasterCard credits
MasterCard and Visa credits do not work the same way, so we were
erroneously counting MasterCard credits as failed. Count them as
successful.
Unit: 40 tests, 227 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote: 28 tests, 111 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/worldpay.rb | 2 +-
test/remote/gateways/remote_worldpay_test.rb | 9 ++++-
test/unit/gateways/worldpay_test.rb | 39 +++++++++++++++++--
4 files changed, 46 insertions(+), 5 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 6e44bd12a6b..122c672609e 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
= ActiveMerchant CHANGELOG
== HEAD
+* Worldpay: handle Visa and MasterCard payouts differently [bpollack] #3068
== Version 1.88.0 (November 30, 2018)
* Added ActiveSupport/Rails master support [Edouard-chin] #3065
diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb
index e5b30d2d6f8..936ef9295d6 100644
--- a/lib/active_merchant/billing/gateways/worldpay.rb
+++ b/lib/active_merchant/billing/gateways/worldpay.rb
@@ -119,7 +119,7 @@ def refund_request(money, authorization, options)
end
def credit_request(money, payment_method, options)
- commit('credit', build_authorization_request(money, payment_method, options), :ok, options)
+ commit('credit', build_authorization_request(money, payment_method, options), :ok, 'SENT_FOR_REFUND', options)
end
def build_request
diff --git a/test/remote/gateways/remote_worldpay_test.rb b/test/remote/gateways/remote_worldpay_test.rb
index f21d674f2a6..c87d9539397 100644
--- a/test/remote/gateways/remote_worldpay_test.rb
+++ b/test/remote/gateways/remote_worldpay_test.rb
@@ -271,12 +271,19 @@ def test_failed_verify
assert_match %r{REFUSED}, response.message
end
- def test_successful_credit_on_cft_gateway
+ def test_successful_visa_credit_on_cft_gateway
credit = @cftgateway.credit(@amount, @credit_card, @options)
assert_success credit
assert_equal 'SUCCESS', credit.message
end
+ def test_successful_mastercard_credit_on_cft_gateway
+ cc = credit_card('5555555555554444')
+ credit = @cftgateway.credit(@amount, cc, @options)
+ assert_success credit
+ assert_equal 'SUCCESS', credit.message
+ end
+
def test_transcript_scrubbing
transcript = capture_transcript(@gateway) do
@gateway.purchase(@amount, @credit_card, @options)
diff --git a/test/unit/gateways/worldpay_test.rb b/test/unit/gateways/worldpay_test.rb
index 4e129b76d55..a1881e04bbc 100644
--- a/test/unit/gateways/worldpay_test.rb
+++ b/test/unit/gateways/worldpay_test.rb
@@ -179,16 +179,26 @@ def test_capture
assert_success response
end
- def test_successful_credit
+ def test_successful_visa_credit
response = stub_comms do
@gateway.credit(@amount, @credit_card, @options)
end.check_request do |endpoint, data, headers|
assert_match(//, data)
- end.respond_with(successful_credit_response)
+ end.respond_with(successful_visa_credit_response)
assert_success response
assert_equal '3d4187536044bd39ad6a289c4339c41c', response.authorization
end
+ def test_successful_mastercard_credit
+ response = stub_comms do
+ @gateway.credit(@amount, @credit_card, @options)
+ end.check_request do |endpoint, data, headers|
+ assert_match(//, data)
+ end.respond_with(successful_mastercard_credit_response)
+ assert_success response
+ assert_equal 'f25257d251b81fb1fd9c210973c941ff', response.authorization
+ end
+
def test_description
stub_comms do
@gateway.authorize(@amount, @credit_card, @options)
@@ -748,7 +758,7 @@ def failed_void_response
REQUEST
end
- def successful_credit_response
+ def successful_visa_credit_response
<<-RESPONSE
+
+
+
+
+
+ ECMC_DEBIT-SSL
+
+ SENT_FOR_REFUND
+
+
+
+
+
+
+
+
+ RESPONSE
+ end
+
def sample_authorization_request
<<-REQUEST
From 1bfa5e9bebc4f656ab13cafddbba8070bb375ab4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tonni=20T=C3=B8lb=C3=B8ll=20Lund=20Aagesen?=
Date: Thu, 15 Nov 2018 11:59:05 +0100
Subject: [PATCH 0201/2234] QuickPay: Update list of supported countries
Closes #3049
---
CHANGELOG | 1 +
README.md | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 122c672609e..d671c7424c1 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,7 @@
== HEAD
* Worldpay: handle Visa and MasterCard payouts differently [bpollack] #3068
+* QuickPay: update supported countries [ta] #3049
== Version 1.88.0 (November 30, 2018)
* Added ActiveSupport/Rails master support [Edouard-chin] #3065
diff --git a/README.md b/README.md
index 5fbec7885ae..fb9dfdc3705 100644
--- a/README.md
+++ b/README.md
@@ -199,7 +199,7 @@ The [ActiveMerchant Wiki](http://github.com/activemerchant/active_merchant/wikis
* [QuickBooks Merchant Services](http://payments.intuit.com/) - US
* [QuickBooks Payments](http://payments.intuit.com/) - US
* [Quantum Gateway](http://www.quantumgateway.com) - US
-* [QuickPay](http://quickpay.net/) - DE, DK, ES, FI, FR, FO, GB, IS, NO, SE
+* [QuickPay](http://quickpay.net/) - AT, BE, BG, CY, CZ, DE, DK, EE, ES, FI, FR, GB, GR, HR, HU, IE, IS, IT, LI, LT, LU, LV, MT, NL, NO, PL, PT, RO, SE SI, SK
* [Qvalent](https://www.qvalent.com/) - AU
* [Raven](http://www.deepcovelabs.com/raven) - AI, AN, AT, AU, BE, BG, BS, BZ, CA, CH, CR, CY, CZ, DE, DK, DM, DO, EE, EL, ES, FI, FR, GB, GG, GI, HK, HR, HU, IE, IL, IM, IN, IT, JE, KN, LI, LT, LU, LV, MH, MT, MY, NL, NO, NZ, PA, PE, PH, PL, PT, RO, RS, SC, SE, SG, SI, SK, UK, US, VG, ZA
* [Realex](http://www.realexpayments.com/) - IE, GB, FR, BE, NL, LU, IT
From 3d1c8b7bec92ac8a3811910186b52f2db33f2173 Mon Sep 17 00:00:00 2001
From: Benjamin Pollack
Date: Tue, 4 Dec 2018 08:48:13 -0500
Subject: [PATCH 0202/2234] Worldpay: set name to 3D when 3DS attempted
Unit: 41 tests, 231 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/worldpay.rb | 2 +-
test/unit/gateways/worldpay_test.rb | 12 ++++++++++++
3 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index d671c7424c1..b319d21db14 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -3,6 +3,7 @@
== HEAD
* Worldpay: handle Visa and MasterCard payouts differently [bpollack] #3068
* QuickPay: update supported countries [ta] #3049
+* WorldPay: set cardholder name to "3D" for 3DS transactions [bpollack] #3071
== Version 1.88.0 (November 30, 2018)
* Added ActiveSupport/Rails master support [Edouard-chin] #3065
diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb
index 936ef9295d6..aca906ae7f4 100644
--- a/lib/active_merchant/billing/gateways/worldpay.rb
+++ b/lib/active_merchant/billing/gateways/worldpay.rb
@@ -237,7 +237,7 @@ def add_payment_method(xml, amount, payment_method, options)
xml.tag! 'date', 'month' => format(payment_method.month, :two_digits), 'year' => format(payment_method.year, :four_digits)
end
- xml.tag! 'cardHolderName', payment_method.name
+ xml.tag! 'cardHolderName', options[:execute_threed] ? '3D' : payment_method.name
xml.tag! 'cvc', payment_method.verification_value
add_address(xml, (options[:billing_address] || options[:address]))
diff --git a/test/unit/gateways/worldpay_test.rb b/test/unit/gateways/worldpay_test.rb
index a1881e04bbc..36e2ba8783d 100644
--- a/test/unit/gateways/worldpay_test.rb
+++ b/test/unit/gateways/worldpay_test.rb
@@ -506,6 +506,18 @@ def test_failed_verify
assert_failure response
end
+ def test_3ds_name_coersion
+ @options[:execute_threed] = true
+ response = stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options)
+ end.check_request do |endpoint, data, headers|
+ if // =~ data
+ assert_match %r{3D}, data
+ end
+ end.respond_with(successful_authorize_response, successful_capture_response)
+ assert_success response
+ end
+
def test_transcript_scrubbing
assert_equal scrubbed_transcript, @gateway.scrub(transcript)
end
From 2821fbdd5941af0880716aa43e23a18f3f26945e Mon Sep 17 00:00:00 2001
From: Niaja
Date: Mon, 26 Nov 2018 16:16:49 -0500
Subject: [PATCH 0203/2234] Authorize.Net: Support refunds for bank accounts
Refunds for bank accounts require a different structure than credit
cards. The routing number, account number and account type must also be
passed in the request.
Loaded suite test/unit/gateways/authorize_net_test
................................................................................................
96 tests, 565 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Loaded suite test/remote/gateways/remote_authorize_net_test
.....................................................................
69 tests, 238 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/authorize_net.rb | 15 ++++++++++++---
test/unit/gateways/authorize_net_test.rb | 14 ++++++++++++++
3 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index b319d21db14..5d0a7938c2a 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -4,6 +4,7 @@
* Worldpay: handle Visa and MasterCard payouts differently [bpollack] #3068
* QuickPay: update supported countries [ta] #3049
* WorldPay: set cardholder name to "3D" for 3DS transactions [bpollack] #3071
+* Authorize.Net: Support refunds for bank accounts [nfarve] #3063
== Version 1.88.0 (November 30, 2018)
* Added ActiveSupport/Rails master support [Edouard-chin] #3065
diff --git a/lib/active_merchant/billing/gateways/authorize_net.rb b/lib/active_merchant/billing/gateways/authorize_net.rb
index a0240cc25ed..ccc8794a05a 100644
--- a/lib/active_merchant/billing/gateways/authorize_net.rb
+++ b/lib/active_merchant/billing/gateways/authorize_net.rb
@@ -339,9 +339,18 @@ def normal_refund(amount, authorization, options)
xml.transactionType('refundTransaction')
xml.amount(amount.nil? ? 0 : amount(amount))
xml.payment do
- xml.creditCard do
- xml.cardNumber(card_number || options[:card_number])
- xml.expirationDate('XXXX')
+ if options[:routing_number]
+ xml.bankAccount do
+ xml.accountType(options[:account_type])
+ xml.routingNumber(options[:routing_number])
+ xml.accountNumber(options[:account_number])
+ xml.nameOnAccount("#{options[:first_name]} #{options[:last_name]}")
+ end
+ else
+ xml.creditCard do
+ xml.cardNumber(card_number || options[:card_number])
+ xml.expirationDate('XXXX')
+ end
end
end
xml.refTransId(transaction_id)
diff --git a/test/unit/gateways/authorize_net_test.rb b/test/unit/gateways/authorize_net_test.rb
index 813c26dfaaf..2cdfde5abcd 100644
--- a/test/unit/gateways/authorize_net_test.rb
+++ b/test/unit/gateways/authorize_net_test.rb
@@ -877,6 +877,20 @@ def test_successful_refund
assert_equal '2214602071#2224#refund', refund.authorization
end
+ def test_successful_bank_refund
+ response = stub_comms do
+ @gateway.refund(50, '12345667', account_type: 'checking', routing_number: '123450987', account_number: '12345667', first_name: 'Louise', last_name: 'Belcher')
+ end.check_request do |endpoint, data, headers|
+ parse(data) do |doc|
+ assert_equal 'checking', doc.at_xpath('//transactionRequest/payment/bankAccount/accountType').content
+ assert_equal '123450987', doc.at_xpath('//transactionRequest/payment/bankAccount/routingNumber').content
+ assert_equal '12345667', doc.at_xpath('//transactionRequest/payment/bankAccount/accountNumber').content
+ assert_equal 'Louise Belcher', doc.at_xpath('//transactionRequest/payment/bankAccount/nameOnAccount').content
+ end
+ end.respond_with(successful_refund_response)
+ assert_success response
+ end
+
def test_refund_passing_extra_info
response = stub_comms do
@gateway.refund(50, '123456789', card_number: @credit_card.number, first_name: 'Bob', last_name: 'Smith', zip: '12345', order_id: '1', description: 'Refund for order 1')
From e7aad1c72559aaef84634d7b8a43b2a8264442ed Mon Sep 17 00:00:00 2001
From: Joe Jackson
Date: Tue, 4 Dec 2018 11:11:20 -0500
Subject: [PATCH 0204/2234] Orbital: coerce merchant_id to string
Orbital merchant IDs were historically strings, but can now also be
integers. To avoid any excitement, coerce them to strings before use.
Unit: 70 tests, 422 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
23 tests, 144 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Closes #3072
---
lib/active_merchant/billing/gateways/orbital.rb | 1 +
test/unit/gateways/orbital_test.rb | 15 +++++++++++++++
2 files changed, 16 insertions(+)
diff --git a/lib/active_merchant/billing/gateways/orbital.rb b/lib/active_merchant/billing/gateways/orbital.rb
index f85b73cd35a..2514617b6da 100644
--- a/lib/active_merchant/billing/gateways/orbital.rb
+++ b/lib/active_merchant/billing/gateways/orbital.rb
@@ -187,6 +187,7 @@ def initialize(options = {})
requires!(options, :merchant_id)
requires!(options, :login, :password) unless options[:ip_authentication]
super
+ @options[:merchant_id] = @options[:merchant_id].to_s
end
# A – Authorization request
diff --git a/test/unit/gateways/orbital_test.rb b/test/unit/gateways/orbital_test.rb
index 2d3e8d8f3f3..6b913222dcd 100644
--- a/test/unit/gateways/orbital_test.rb
+++ b/test/unit/gateways/orbital_test.rb
@@ -153,6 +153,21 @@ def test_order_id_format_for_capture
assert_success response
end
+ def test_numeric_merchant_id_for_caputre
+ gateway = ActiveMerchant::Billing::OrbitalGateway.new(
+ :login => 'login',
+ :password => 'password',
+ :merchant_id => 700000123456
+ )
+
+ response = stub_comms(gateway) do
+ gateway.capture(101, '4A5398CF9B87744GG84A1D30F2F2321C66249416;1', @options)
+ end.check_request do |endpoint, data, headers|
+ assert_match(/700000123456<\/MerchantID>/, data)
+ end.respond_with(successful_purchase_response)
+ assert_success response
+ end
+
def test_expiry_date
year = (DateTime.now + 1.year).strftime('%y')
assert_equal "09#{year}", @gateway.send(:expiry_date, credit_card)
From fdc5468704cb9c0c951a3b9657b7a99d61699524 Mon Sep 17 00:00:00 2001
From: Yosuke Hasumi
Date: Tue, 20 Nov 2018 11:45:12 -0800
Subject: [PATCH 0205/2234] Stripe: allow specifying a reason for refunds
Unit: 130 tests, 698 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote: 67 tests, 313 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Closes #3057
---
CHANGELOG | 3 ++-
lib/active_merchant/billing/gateways/stripe.rb | 1 +
test/remote/gateways/remote_stripe_test.rb | 13 +++++++++++++
test/unit/gateways/stripe_test.rb | 9 +++++++++
4 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 5d0a7938c2a..2f29b7dd084 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -4,7 +4,8 @@
* Worldpay: handle Visa and MasterCard payouts differently [bpollack] #3068
* QuickPay: update supported countries [ta] #3049
* WorldPay: set cardholder name to "3D" for 3DS transactions [bpollack] #3071
-* Authorize.Net: Support refunds for bank accounts [nfarve] #3063
+* Authorize.Net: Support refunds for bank accounts [nfarve] #3063
+* Stripe: support specifying a reason for refunds [yosukehasumi] #3056
== Version 1.88.0 (November 30, 2018)
* Added ActiveSupport/Rails master support [Edouard-chin] #3065
diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb
index 1650c1baf43..4e107af5eaf 100644
--- a/lib/active_merchant/billing/gateways/stripe.rb
+++ b/lib/active_merchant/billing/gateways/stripe.rb
@@ -147,6 +147,7 @@ def refund(money, identification, options = {})
post[:refund_application_fee] = true if options[:refund_application_fee]
post[:reverse_transfer] = options[:reverse_transfer] if options[:reverse_transfer]
post[:metadata] = options[:metadata] if options[:metadata]
+ post[:reason] = options[:reason] if options[:reason]
post[:expand] = [:charge]
MultiResponse.run(:first) do |r|
diff --git a/test/remote/gateways/remote_stripe_test.rb b/test/remote/gateways/remote_stripe_test.rb
index 6be3a6dd4e6..04a5b144138 100644
--- a/test/remote/gateways/remote_stripe_test.rb
+++ b/test/remote/gateways/remote_stripe_test.rb
@@ -254,6 +254,19 @@ def test_successful_refund
assert_success refund
end
+ def test_successful_refund_with_reason
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
+ assert_success response
+ assert response.authorization
+
+ assert refund = @gateway.refund(@amount - 20, response.authorization, reason: 'fraudulent')
+ assert refund.test?
+ refund_id = refund.params['id']
+ assert_equal refund.authorization, refund_id
+ assert_success refund
+ assert_equal 'fraudulent', refund.params['reason']
+ end
+
def test_successful_refund_on_verified_bank_account
customer_id = @verified_bank_account[:customer_id]
bank_account_id = @verified_bank_account[:bank_account_id]
diff --git a/test/unit/gateways/stripe_test.rb b/test/unit/gateways/stripe_test.rb
index 34b53e17927..aa68953ee16 100644
--- a/test/unit/gateways/stripe_test.rb
+++ b/test/unit/gateways/stripe_test.rb
@@ -596,6 +596,15 @@ def test_successful_refund
assert_equal 're_test_refund', response.authorization
end
+ def test_successful_refund_with_reason
+ @gateway.expects(:ssl_request).returns(successful_partially_refunded_response)
+
+ assert response = @gateway.refund(@refund_amount, 'ch_test_charge', reason: 'fraudulent')
+ assert_success response
+
+ assert_equal 're_test_refund', response.authorization
+ end
+
def test_unsuccessful_refund
@gateway.expects(:ssl_request).returns(generic_error_response)
From ab8c6181dbad9c8ce9bb4ae9bd3643fcad170254 Mon Sep 17 00:00:00 2001
From: Adam
Date: Mon, 23 Jul 2018 14:39:01 +1000
Subject: [PATCH 0206/2234] Paybox Direct: add support for XPF currency
Closes #2938
---
lib/active_merchant/billing/gateways/paybox_direct.rb | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/active_merchant/billing/gateways/paybox_direct.rb b/lib/active_merchant/billing/gateways/paybox_direct.rb
index e99d787f210..de236330928 100644
--- a/lib/active_merchant/billing/gateways/paybox_direct.rb
+++ b/lib/active_merchant/billing/gateways/paybox_direct.rb
@@ -34,7 +34,8 @@ class PayboxDirectGateway < Gateway
'CHF'=> '756',
'GBP'=> '826',
'USD'=> '840',
- 'EUR'=> '978'
+ 'EUR'=> '978',
+ 'XPF'=> '953'
}
SUCCESS_CODES = ['00000']
From 9968bb6e44901aa4d9fa339b9db8d41a509a255f Mon Sep 17 00:00:00 2001
From: Niaja
Date: Wed, 5 Dec 2018 10:17:50 -0500
Subject: [PATCH 0207/2234] TrustCommerce: Add ACH Ability
TrustCommerce supports ach transactions for purchase and credit. This
also adds the `aggregator_id` which will become mandatory.
Loaded suite test/remote/gateways/remote_trust_commerce_test
.......
15 tests, 59 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Loaded suite test/unit/gateways/trust_commerce_test
.........
9 tests, 22 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 3 ++-
.../billing/gateways/trust_commerce.rb | 21 +++++++++++++++++++
test/fixtures.yml | 1 +
.../gateways/remote_trust_commerce_test.rb | 18 ++++++++++++++++
test/unit/gateways/trust_commerce_test.rb | 13 +++++++++++-
5 files changed, 54 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 2f29b7dd084..5f5a84ad51d 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -6,6 +6,7 @@
* WorldPay: set cardholder name to "3D" for 3DS transactions [bpollack] #3071
* Authorize.Net: Support refunds for bank accounts [nfarve] #3063
* Stripe: support specifying a reason for refunds [yosukehasumi] #3056
+* TrustCommerce: Add ACH Ability [nfarve] #3073
== Version 1.88.0 (November 30, 2018)
* Added ActiveSupport/Rails master support [Edouard-chin] #3065
@@ -31,7 +32,7 @@
* CyberSource: update supported countries [bpollack] #3055
* MiGS: update supported countries [bpollack] #3055
* Clearhaus: update submission data format [bpollack] #3053
-* Forte: Allow void on capture #3059
+* Forte: Allow void on capture [nfarve] #3059
== Version 1.86.0 (October 26, 2018)
* UsaEpayTransaction: Support UMcheckformat option for echecks [dtykocki] #3002
diff --git a/lib/active_merchant/billing/gateways/trust_commerce.rb b/lib/active_merchant/billing/gateways/trust_commerce.rb
index c10819e6eed..d97cfa0c273 100644
--- a/lib/active_merchant/billing/gateways/trust_commerce.rb
+++ b/lib/active_merchant/billing/gateways/trust_commerce.rb
@@ -153,6 +153,7 @@ def authorize(money, creditcard_or_billing_id, options = {})
}
add_order_id(parameters, options)
+ add_aggregator(parameters, options)
add_customer_data(parameters, options)
add_payment_source(parameters, creditcard_or_billing_id)
add_addresses(parameters, options)
@@ -167,6 +168,7 @@ def purchase(money, creditcard_or_billing_id, options = {})
}
add_order_id(parameters, options)
+ add_aggregator(parameters, options)
add_customer_data(parameters, options)
add_payment_source(parameters, creditcard_or_billing_id)
add_addresses(parameters, options)
@@ -181,6 +183,7 @@ def capture(money, authorization, options = {})
:amount => amount(money),
:transid => authorization,
}
+ add_aggregator(parameters, options)
commit('postauth', parameters)
end
@@ -192,6 +195,7 @@ def refund(money, identification, options = {})
:amount => amount(money),
:transid => identification
}
+ add_aggregator(parameters, options)
commit('credit', parameters)
end
@@ -219,6 +223,7 @@ def void(authorization, options = {})
parameters = {
:transid => authorization,
}
+ add_aggregator(parameters, options)
commit('reversal', parameters)
end
@@ -305,14 +310,30 @@ def scrub(transcript)
private
+ def add_aggregator(params, options)
+ if @options[:aggregator_id]
+ params[:aggregators] = 1
+ params[:aggregator1] = @options[:aggregator_id]
+ end
+ end
+
def add_payment_source(params, source)
if source.is_a?(String)
add_billing_id(params, source)
+ elsif card_brand(source) == 'check'
+ add_check(params, source)
else
add_creditcard(params, source)
end
end
+ def add_check(params, check)
+ params[:media] = 'ach'
+ params[:routing] = check.routing_number
+ params[:account] = check.account_number
+ params[:savings] = 'y' if check.account_type == 'savings'
+ end
+
def add_creditcard(params, creditcard)
params[:media] = 'cc'
params[:name] = creditcard.name
diff --git a/test/fixtures.yml b/test/fixtures.yml
index f1de6db6807..be2d8930f18 100644
--- a/test/fixtures.yml
+++ b/test/fixtures.yml
@@ -1183,6 +1183,7 @@ trexle:
trust_commerce:
login: 'TestMerchant'
password: 'password'
+ aggregator_id: 'abc123'
# Working credentials, no need to replace
usa_epay:
diff --git a/test/remote/gateways/remote_trust_commerce_test.rb b/test/remote/gateways/remote_trust_commerce_test.rb
index 576fde7292a..196ffe26c7f 100644
--- a/test/remote/gateways/remote_trust_commerce_test.rb
+++ b/test/remote/gateways/remote_trust_commerce_test.rb
@@ -5,6 +5,7 @@ def setup
@gateway = TrustCommerceGateway.new(fixtures(:trust_commerce))
@credit_card = credit_card('4111111111111111')
+ @check = check({account_number: 55544433221, routing_number: 789456124})
@amount = 100
@@ -59,6 +60,14 @@ def test_successful_purchase_with_avs
assert !response.authorization.blank?
end
+ def test_successful_purchase_with_check
+ assert response = @gateway.purchase(@amount, @check, @options)
+ assert_match %r{The transaction was successful}, response.message
+
+ assert_success response
+ assert !response.authorization.blank?
+ end
+
def test_unsuccessful_purchase_with_invalid_cvv
@credit_card.verification_value = @invalid_verification_value
assert response = @gateway.purchase(@amount, @credit_card, @options)
@@ -128,6 +137,15 @@ def test_successful_credit
assert_success response
end
+ def test_successful_check_refund
+ purchase = @gateway.purchase(@amount, @check, @options)
+
+ assert response = @gateway.refund(@amount, purchase.authorization)
+
+ assert_match %r{The transaction was successful}, response.message
+ assert_success response
+ end
+
def test_store_failure
assert response = @gateway.store(@credit_card)
diff --git a/test/unit/gateways/trust_commerce_test.rb b/test/unit/gateways/trust_commerce_test.rb
index 08feafb188b..4fedfb09b07 100644
--- a/test/unit/gateways/trust_commerce_test.rb
+++ b/test/unit/gateways/trust_commerce_test.rb
@@ -1,15 +1,18 @@
require 'test_helper'
class TrustCommerceTest < Test::Unit::TestCase
+ include CommStub
def setup
@gateway = TrustCommerceGateway.new(
:login => 'TestMerchant',
- :password => 'password'
+ :password => 'password',
+ :aggregator_id => 'abc123'
)
# Force SSL post
@gateway.stubs(:tclink?).returns(false)
@amount = 100
+ @check = check
@credit_card = credit_card('4111111111111111')
end
@@ -28,6 +31,14 @@ def test_unsuccessful_purchase
assert_failure response
end
+ def test_succesful_purchase_with_check
+ stub_comms do
+ @gateway.purchase(@amount, @check)
+ end.check_request do |endpoint, data, headers|
+ assert_match(%r{aggregator1}, data)
+ end.respond_with(successful_purchase_response)
+ end
+
def test_amount_style
assert_equal '1034', @gateway.send(:amount, 1034)
From 630edd91c87e649f6edd34dd8cbb0092aff70829 Mon Sep 17 00:00:00 2001
From: molbrown
Date: Wed, 5 Dec 2018 10:31:24 -0500
Subject: [PATCH 0208/2234] Payeezy: Support $0 for verify transactions
Payeezy allows $0 authorization. Updating from $1 verify
to $0 to resolve failures for customer.
ENE-59
Closes #3074
Unit Tests:
33 tests, 156 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote Tests:
33 tests, 131 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/payeezy.rb | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 5f5a84ad51d..05c5e5ec02b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -7,6 +7,7 @@
* Authorize.Net: Support refunds for bank accounts [nfarve] #3063
* Stripe: support specifying a reason for refunds [yosukehasumi] #3056
* TrustCommerce: Add ACH Ability [nfarve] #3073
+* Payeezy: Support $0 for verify transactions [molbrown] #3074
== Version 1.88.0 (November 30, 2018)
* Added ActiveSupport/Rails master support [Edouard-chin] #3065
diff --git a/lib/active_merchant/billing/gateways/payeezy.rb b/lib/active_merchant/billing/gateways/payeezy.rb
index 6342bce30d8..cb2e4ff4c13 100644
--- a/lib/active_merchant/billing/gateways/payeezy.rb
+++ b/lib/active_merchant/billing/gateways/payeezy.rb
@@ -94,7 +94,7 @@ def void(authorization, options = {})
def verify(credit_card, options={})
MultiResponse.run(:use_first_response) do |r|
- r.process { authorize(100, credit_card, options) }
+ r.process { authorize(0, credit_card, options) }
r.process(:ignore_result) { void(r.authorization, options) }
end
end
From 5c5931c1732bb62afe3a1781c3af19c6e6d511ca Mon Sep 17 00:00:00 2001
From: Lancelot Carlson
Date: Thu, 29 Nov 2018 22:29:56 -0500
Subject: [PATCH 0209/2234] USA ePay: add bank account type
---
lib/active_merchant/billing/gateways/usa_epay_transaction.rb | 1 +
test/remote/gateways/remote_usa_epay_transaction_test.rb | 2 +-
test/unit/gateways/usa_epay_transaction_test.rb | 3 ++-
3 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb
index 55d6b439956..7e2f7ae0596 100644
--- a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb
+++ b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb
@@ -198,6 +198,7 @@ def add_invoice(post, options)
def add_payment(post, payment, options={})
if payment.respond_to?(:routing_number)
post[:checkformat] = options[:check_format] if options[:check_format]
+ post[:accounttype] = options[:account_type] if options[:account_type]
post[:account] = payment.account_number
post[:routing] = payment.routing_number
post[:name] = payment.name unless payment.name.blank?
diff --git a/test/remote/gateways/remote_usa_epay_transaction_test.rb b/test/remote/gateways/remote_usa_epay_transaction_test.rb
index e4b6cf3f593..a4854c02a37 100644
--- a/test/remote/gateways/remote_usa_epay_transaction_test.rb
+++ b/test/remote/gateways/remote_usa_epay_transaction_test.rb
@@ -30,7 +30,7 @@ def test_successful_purchase_with_echeck
end
def test_successful_purchase_with_echeck_and_extra_options
- extra_options = @options.merge(check_format: 'ARC')
+ extra_options = @options.merge(check_format: 'ARC', account_type: 'savings')
assert response = @gateway.purchase(@amount, @check, extra_options)
assert_equal 'Success', response.message
assert_success response
diff --git a/test/unit/gateways/usa_epay_transaction_test.rb b/test/unit/gateways/usa_epay_transaction_test.rb
index 5318db9c1f9..a9d3f79f939 100644
--- a/test/unit/gateways/usa_epay_transaction_test.rb
+++ b/test/unit/gateways/usa_epay_transaction_test.rb
@@ -55,9 +55,10 @@ def test_successful_request_with_echeck
def test_successful_purchase_with_echeck_and_extra_options
response = stub_comms do
- @gateway.purchase(@amount, @check, @options.merge(check_format: 'ARC'))
+ @gateway.purchase(@amount, @check, @options.merge(check_format: 'ARC', account_type: 'savings'))
end.check_request do |endpoint, data, headers|
assert_match(/UMcheckformat=ARC/, data)
+ assert_match(/UMaccounttype=savings/, data)
end.respond_with(successful_purchase_response_echeck)
assert_equal 'Success', response.message
From 0b76358f219bd71cb699d425d5bf6e10e7da60e4 Mon Sep 17 00:00:00 2001
From: Lancelot Carlson
Date: Thu, 29 Nov 2018 23:41:02 -0500
Subject: [PATCH 0210/2234] USA ePay: support custom fields and line items
---
.../billing/gateways/usa_epay_transaction.rb | 31 +++++++++++++++
.../gateways/usa_epay_transaction_test.rb | 38 +++++++++++++++++++
2 files changed, 69 insertions(+)
diff --git a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb
index 7e2f7ae0596..119de3898e7 100644
--- a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb
+++ b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb
@@ -54,6 +54,8 @@ def authorize(money, credit_card, options = {})
add_customer_data(post, options)
end
add_split_payments(post, options)
+ add_custom_fields(post, options)
+ add_line_items(post, options)
add_test_mode(post, options)
commit(:authorization, post)
@@ -70,6 +72,8 @@ def purchase(money, payment, options = {})
add_customer_data(post, options)
end
add_split_payments(post, options)
+ add_custom_fields(post, options)
+ add_line_items(post, options)
add_test_mode(post, options)
payment.respond_to?(:routing_number) ? commit(:check_purchase, post) : commit(:purchase, post)
@@ -232,6 +236,33 @@ def add_split_payments(post, options)
post['onError'] = options[:on_error] || 'Void'
end
+ # see: https://wiki.usaepay.com/developer/transactionapi#merchant_defined_custom_fields
+ def add_custom_fields(post, options)
+ return unless options[:custom_fields].is_a?(Hash)
+ options[:custom_fields].each do |index, custom|
+ post["custom#{index}"] = custom
+ end
+ end
+
+ # see: https://wiki.usaepay.com/developer/transactionapi#line_item_details
+ def add_line_items(post, options)
+ return unless options[:line_items].is_a?(Array)
+ options[:line_items].each_with_index do |line_item, index|
+ %w(product_ref_num sku name description taxable tax_rate tax_amount commodity_code discount_rate discount_amount).each do |key|
+ post["line#{index}#{key.delete('_')}"] = line_item[key.to_sym] if line_item.has_key?(key.to_sym)
+ end
+
+ {
+ quantity: 'qty',
+ unit: 'um',
+ }.each do |key, umkey|
+ post["line#{index}#{umkey}"] = line_item[key.to_sym] if line_item.has_key?(key.to_sym)
+ end
+
+ post["line#{index}cost"] = amount(line_item[:cost])
+ end
+ end
+
def parse(body)
fields = {}
for line in body.split('&')
diff --git a/test/unit/gateways/usa_epay_transaction_test.rb b/test/unit/gateways/usa_epay_transaction_test.rb
index a9d3f79f939..700bea6fa77 100644
--- a/test/unit/gateways/usa_epay_transaction_test.rb
+++ b/test/unit/gateways/usa_epay_transaction_test.rb
@@ -143,6 +143,44 @@ def test_successful_purchase_split_payment_with_custom_on_error
assert_success response
end
+ def test_successful_purchase_custom_fields
+ response = stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options.merge(
+ :custom_fields => {
+ 1 => 'diablo',
+ 2 => 'mephisto',
+ 3 => 'baal'
+ }
+ ))
+ end.check_request do |endpoint, data, headers|
+ assert_match %r{UMcustom1=diablo}, data
+ assert_match %r{UMcustom2=mephisto}, data
+ assert_match %r{UMcustom3=baal}, data
+ end.respond_with(successful_purchase_response)
+ assert_success response
+ end
+
+ def test_successful_purchase_line_items
+ response = stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options.merge(
+ :line_items => [
+ { :sku=> 'abc123', :cost => 119, :quantity => 1 },
+ { :sku => 'def456', :cost => 200, :quantity => 2, :name => 'an item' },
+ ]
+ ))
+ end.check_request do |endpoint, data, headers|
+ assert_match %r{UMline0sku=abc123}, data
+ assert_match %r{UMline0cost=1.19}, data
+ assert_match %r{UMline0qty=1}, data
+
+ assert_match %r{UMline1sku=def456}, data
+ assert_match %r{UMline1cost=2.00}, data
+ assert_match %r{UMline1qty=2}, data
+ assert_match %r{UMline1name=an\+item}, data
+ end.respond_with(successful_purchase_response)
+ assert_success response
+ end
+
def test_successful_authorize_request
@gateway.expects(:ssl_post).returns(successful_authorize_response)
From 7585caf787931f05166781f1ebc5c7ed139f825a Mon Sep 17 00:00:00 2001
From: Lancelot Carlson
Date: Fri, 30 Nov 2018 00:16:49 -0500
Subject: [PATCH 0211/2234] USA ePay: add support for recurring payments
---
.../billing/gateways/usa_epay_transaction.rb | 19 ++++++++++++++
.../gateways/usa_epay_transaction_test.rb | 25 +++++++++++++++++++
2 files changed, 44 insertions(+)
diff --git a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb
index 119de3898e7..fb0b277a164 100644
--- a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb
+++ b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb
@@ -54,6 +54,7 @@ def authorize(money, credit_card, options = {})
add_customer_data(post, options)
end
add_split_payments(post, options)
+ add_recurring_fields(post, options)
add_custom_fields(post, options)
add_line_items(post, options)
add_test_mode(post, options)
@@ -72,6 +73,7 @@ def purchase(money, payment, options = {})
add_customer_data(post, options)
end
add_split_payments(post, options)
+ add_recurring_fields(post, options)
add_custom_fields(post, options)
add_line_items(post, options)
add_test_mode(post, options)
@@ -236,6 +238,23 @@ def add_split_payments(post, options)
post['onError'] = options[:on_error] || 'Void'
end
+ def add_recurring_fields(post, options)
+ return unless options[:recurring_fields].is_a?(Hash)
+ options[:recurring_fields].each do |key, value|
+ if value == true
+ value = 'yes'
+ elsif value == false
+ next
+ end
+
+ if key == :bill_amount
+ value = amount(value)
+ end
+
+ post[key.to_s.delete('_')] = value
+ end
+ end
+
# see: https://wiki.usaepay.com/developer/transactionapi#merchant_defined_custom_fields
def add_custom_fields(post, options)
return unless options[:custom_fields].is_a?(Hash)
diff --git a/test/unit/gateways/usa_epay_transaction_test.rb b/test/unit/gateways/usa_epay_transaction_test.rb
index 700bea6fa77..260195409da 100644
--- a/test/unit/gateways/usa_epay_transaction_test.rb
+++ b/test/unit/gateways/usa_epay_transaction_test.rb
@@ -143,6 +143,31 @@ def test_successful_purchase_split_payment_with_custom_on_error
assert_success response
end
+ def test_successful_purchase_recurring_fields
+ response = stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options.merge(
+ :recurring_fields => {
+ add_customer: true,
+ schedule: 'quarterly',
+ bill_source_key: 'bill source key',
+ bill_amount: 123,
+ num_left: 5,
+ start: '20501212',
+ recurring_receipt: true
+ }
+ ))
+ end.check_request do |endpoint, data, headers|
+ assert_match %r{UMaddcustomer=yes}, data
+ assert_match %r{UMschedule=quarterly}, data
+ assert_match %r{UMbillsourcekey=bill\+source\+key}, data
+ assert_match %r{UMbillamount=1.23}, data
+ assert_match %r{UMnumleft=5}, data
+ assert_match %r{UMstart=20501212}, data
+ assert_match %r{UMrecurringreceipt=yes}, data
+ end.respond_with(successful_purchase_response)
+ assert_success response
+ end
+
def test_successful_purchase_custom_fields
response = stub_comms do
@gateway.purchase(@amount, @credit_card, @options.merge(
From 25af741645653cc9cd6dd74a845907f618ab7dc0 Mon Sep 17 00:00:00 2001
From: Lance Carlson
Date: Tue, 4 Dec 2018 20:22:49 -0500
Subject: [PATCH 0212/2234] USA ePay: add remote tests for recurring, line
items and custom fields
Closes #3069
---
CHANGELOG | 1 +
.../remote_usa_epay_transaction_test.rb | 40 +++++++++++++++++++
2 files changed, 41 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index 05c5e5ec02b..1e421bcda0c 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -8,6 +8,7 @@
* Stripe: support specifying a reason for refunds [yosukehasumi] #3056
* TrustCommerce: Add ACH Ability [nfarve] #3073
* Payeezy: Support $0 for verify transactions [molbrown] #3074
+* USA ePay: add support for recurring transactions, custom fields, and line items [lancecarlson] #3069
== Version 1.88.0 (November 30, 2018)
* Added ActiveSupport/Rails master support [Edouard-chin] #3065
diff --git a/test/remote/gateways/remote_usa_epay_transaction_test.rb b/test/remote/gateways/remote_usa_epay_transaction_test.rb
index a4854c02a37..52c24f212c9 100644
--- a/test/remote/gateways/remote_usa_epay_transaction_test.rb
+++ b/test/remote/gateways/remote_usa_epay_transaction_test.rb
@@ -68,6 +68,46 @@ def test_successful_purchase_with_email_receipt
assert_success response
end
+ def test_successful_purchase_with_recurring_fields
+ recurring_fields = [
+ add_customer: true,
+ schedule: 'quarterly',
+ bill_source_key: 'bill source key',
+ bill_amount: 123,
+ num_left: 5,
+ start: '20501212',
+ recurring_receipt: true
+ ]
+
+ assert response = @gateway.purchase(@amount, @credit_card, @options.merge(recurring_fields: recurring_fields))
+ assert_equal 'Success', response.message
+ assert_success response
+ end
+
+ def test_successful_purchase_with_custom_fields
+ custom_fields = {
+ 1 => 'multi',
+ 2 => 'pass',
+ 3 => 'korben',
+ 4 => 'dallas'
+ }
+
+ assert response = @gateway.purchase(@amount, @credit_card, @options.merge(custom_fields: custom_fields))
+ assert_equal 'Success', response.message
+ assert_success response
+ end
+
+ def test_successful_purchase_with_line_items
+ line_items = [
+ {sku: 'abc123', cost: 119, quantity: 1},
+ {sku: 'def456', cost: 200, quantity: 2, name: 'an item' }
+ ]
+
+ assert response = @gateway.purchase(@amount, @credit_card, @options.merge(line_items: line_items))
+ assert_equal 'Success', response.message
+ assert_success response
+ end
+
def test_unsuccessful_purchase
# For some reason this will fail with "You have tried this card too
# many times, please contact merchant" unless a unique order id is
From b7974e288a0ce4c00e5028c47b2fd3fa47032a2f Mon Sep 17 00:00:00 2001
From: molbrown
Date: Thu, 6 Dec 2018 14:29:08 -0500
Subject: [PATCH 0213/2234] TrustCommerce: Scrubs password from transcript
ENE-64
Unit:
10 tests, 34 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
16 tests, 56 assertions, 5 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
68.75% passed
- Failures existing on earlier commits, not related to change made in
this commit.
---
lib/active_merchant/billing/gateways/trust_commerce.rb | 1 +
test/unit/gateways/trust_commerce_test.rb | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/active_merchant/billing/gateways/trust_commerce.rb b/lib/active_merchant/billing/gateways/trust_commerce.rb
index d97cfa0c273..40466fcc006 100644
--- a/lib/active_merchant/billing/gateways/trust_commerce.rb
+++ b/lib/active_merchant/billing/gateways/trust_commerce.rb
@@ -305,6 +305,7 @@ def scrub(transcript)
transcript.
gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
gsub(%r((&?cc=)\d*(&?)), '\1[FILTERED]\2').
+ gsub(%r((&?password=)[^&]+(&?)), '\1[FILTERED]\2').
gsub(%r((&?cvv=)\d*(&?)), '\1[FILTERED]\2')
end
diff --git a/test/unit/gateways/trust_commerce_test.rb b/test/unit/gateways/trust_commerce_test.rb
index 4fedfb09b07..e94146db360 100644
--- a/test/unit/gateways/trust_commerce_test.rb
+++ b/test/unit/gateways/trust_commerce_test.rb
@@ -111,7 +111,7 @@ def transcript
def scrubbed_transcript
<<-TRANSCRIPT
-action=sale&demo=y&password=password&custid=TestMerchant&shipto_zip=90001&shipto_state=CA&shipto_city=Somewhere&shipto_address1=123+Test+St.&avs=n&zip=90001&state=CA&city=Somewhere&address1=123+Test+St.&cvv=[FILTERED]&exp=0916&cc=[FILTERED]&name=Longbob+Longsen&media=cc&ip=10.10.10.10&email=cody%40example.com&ticket=%231000.1&amount=100
+action=sale&demo=y&password=[FILTERED]&custid=TestMerchant&shipto_zip=90001&shipto_state=CA&shipto_city=Somewhere&shipto_address1=123+Test+St.&avs=n&zip=90001&state=CA&city=Somewhere&address1=123+Test+St.&cvv=[FILTERED]&exp=0916&cc=[FILTERED]&name=Longbob+Longsen&media=cc&ip=10.10.10.10&email=cody%40example.com&ticket=%231000.1&amount=100
TRANSCRIPT
end
end
From 4ba8ec0789fd297b97a1c9cbfb118acabe534bbe Mon Sep 17 00:00:00 2001
From: David Perry
Date: Wed, 21 Nov 2018 15:10:10 -0500
Subject: [PATCH 0214/2234] Add dLocal gateway
Closes #3709
Unit:
15 tests, 45 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
21 tests, 59 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/d_local.rb | 226 ++++++++++++++++++
test/fixtures.yml | 6 +
test/remote/gateways/remote_d_local_test.rb | 209 ++++++++++++++++
test/unit/gateways/d_local_test.rb | 226 ++++++++++++++++++
5 files changed, 668 insertions(+)
create mode 100644 lib/active_merchant/billing/gateways/d_local.rb
create mode 100644 test/remote/gateways/remote_d_local_test.rb
create mode 100644 test/unit/gateways/d_local_test.rb
diff --git a/CHANGELOG b/CHANGELOG
index 1e421bcda0c..771d5b91d10 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -9,6 +9,7 @@
* TrustCommerce: Add ACH Ability [nfarve] #3073
* Payeezy: Support $0 for verify transactions [molbrown] #3074
* USA ePay: add support for recurring transactions, custom fields, and line items [lancecarlson] #3069
+* Add dLocal gateway [curiousepic] #3709
== Version 1.88.0 (November 30, 2018)
* Added ActiveSupport/Rails master support [Edouard-chin] #3065
diff --git a/lib/active_merchant/billing/gateways/d_local.rb b/lib/active_merchant/billing/gateways/d_local.rb
new file mode 100644
index 00000000000..43027bd7b92
--- /dev/null
+++ b/lib/active_merchant/billing/gateways/d_local.rb
@@ -0,0 +1,226 @@
+module ActiveMerchant #:nodoc:
+ module Billing #:nodoc:
+ class DLocalGateway < Gateway
+ self.test_url = 'https://sandbox.dlocal.com'
+ self.live_url = 'https://api.dlocal.com'
+
+ self.supported_countries = ['AR', 'BR', 'CL', 'CO', 'MX', 'PE', 'UY', 'TR']
+ self.default_currency = 'USD'
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners_club, :maestro]
+
+ self.homepage_url = 'https://dlocal.com/'
+ self.display_name = 'dLocal'
+
+ def initialize(options={})
+ requires!(options, :login, :trans_key)
+ super
+ end
+
+ def purchase(money, payment, options={})
+ post = {}
+ add_auth_purchase_params(post, money, payment, 'purchase', options)
+
+ commit('purchase', post, options)
+ end
+
+ def authorize(money, payment, options={})
+ post = {}
+ add_auth_purchase_params(post, money, payment, 'authorize', options)
+
+ commit('authorize', post, options)
+ end
+
+ def capture(money, authorization, options={})
+ post = {}
+ post[:payment_id] = authorization
+ add_invoice(post, money, options) if money
+ commit('capture', post, options)
+ end
+
+ def refund(money, authorization, options={})
+ post = {}
+ post[:payment_id] = authorization
+ post[:notification_url] = options[:notification_url]
+ add_invoice(post, money, options) if money
+ commit('refund', post, options)
+ end
+
+ def void(authorization, options={})
+ post = {}
+ post[:payment_id] = authorization
+ commit('void', post, options)
+ end
+
+ def verify(credit_card, options={})
+ MultiResponse.run(:use_first_response) do |r|
+ r.process { authorize(100, credit_card, options) }
+ r.process(:ignore_result) { void(r.authorization, options) }
+ end
+ end
+
+ def supports_scrubbing?
+ true
+ end
+
+ def scrub(transcript)
+ transcript.
+ gsub(%r((X-Trans-Key: )\w+), '\1[FILTERED]').
+ gsub(%r((\"number\\\":\\\")\d+), '\1[FILTERED]').
+ gsub(%r((\"cvv\\\":\\\")\d+), '\1[FILTERED]')
+ end
+
+ private
+
+ def add_auth_purchase_params(post, money, card, action, options)
+ add_invoice(post, money, options)
+ post[:payment_method_id] = 'CARD'
+ post[:payment_method_flow] = 'DIRECT'
+ add_country(post, card, options)
+ add_payer(post, card, options)
+ add_card(post, card, action, options)
+ post[:order_id] = options[:order_id] || generate_unique_id
+ post[:description] = options[:description] if options[:description]
+ end
+
+ def add_invoice(post, money, options)
+ post[:amount] = amount(money)
+ post[:currency] = (options[:currency] || currency(money))
+ end
+
+ def add_country(post, card, options)
+ return unless address = options[:billing_address] || options[:address]
+ post[:country] = lookup_country_code(address[:country])
+ end
+
+ def lookup_country_code(country)
+ Country.find(country).code(:alpha2)
+ end
+
+ def add_payer(post, card, options)
+ address = options[:billing_address] || options[:address]
+ post[:payer] = {}
+ post[:payer][:name] = card.name
+ post[:payer][:email] = options[:email] if options[:email]
+ post[:payer][:birth_date] = options[:birth_date] if options[:birth_date]
+ post[:payer][:phone] = address[:phone] if address[:phone]
+ post[:payer][:document] = options[:document] if options[:document]
+ post[:payer][:document2] = options[:document2] if options[:document2]
+ post[:payer][:user_reference] = options[:user_reference] if options[:user_reference]
+ post[:payer][:address] = add_address(post, card, options)
+ end
+
+ def add_address(post, card, options)
+ return unless address = options[:billing_address] || options[:address]
+ address_object = {}
+ address_object[:state] = address[:state] if address[:state]
+ address_object[:city] = address[:city] if address[:city]
+ address_object[:zip_code] = address[:zip_code] if address[:zip_code]
+ address_object[:street] = address[:street] if address[:street]
+ address_object[:number] = address[:number] if address[:number]
+ address_object
+ end
+
+ def add_card(post, card, action, options={})
+ post[:card] = {}
+ post[:card][:holder_name] = card.name
+ post[:card][:expiration_month] = card.month
+ post[:card][:expiration_year] = card.year
+ post[:card][:number] = card.number
+ post[:card][:cvv] = card.verification_value
+ post[:card][:descriptor] = options[:dynamic_descriptor] if options[:dynamic_descriptor]
+ post[:card][:capture] = (action == 'purchase')
+ end
+
+ def parse(body)
+ JSON.parse(body)
+ end
+
+ def commit(action, parameters, options={})
+ url = url(action, parameters, options)
+ post = post_data(action, parameters)
+ begin
+ raw = ssl_post(url, post, headers(post, options))
+ response = parse(raw)
+ rescue ResponseError => e
+ raw = e.response.body
+ response = parse(raw)
+ end
+
+ Response.new(
+ success_from(action, response),
+ message_from(action, response),
+ response,
+ authorization: authorization_from(response),
+ avs_result: AVSResult.new(code: response['some_avs_response_key']),
+ cvv_result: CVVResult.new(response['some_cvv_response_key']),
+ test: test?,
+ error_code: error_code_from(action, response)
+ )
+ end
+
+ # A refund may not be immediate, and return a status_code of 100, "Pending".
+ # Since we aren't handling async notifications of eventual success,
+ # we count 100 as a success.
+ def success_from(action, response)
+ return false unless response['status_code']
+ ['100', '200', '400', '600'].include? response['status_code'].to_s
+ end
+
+ def message_from(action, response)
+ response['status_detail'] || response['message']
+ end
+
+ def authorization_from(response)
+ response['id']
+ end
+
+ def error_code_from(action, response)
+ return if success_from(action, response)
+ code = response['status_code'] || response['code']
+ code&.to_s
+ end
+
+ def url(action, parameters, options={})
+ "#{(test? ? test_url : live_url)}/#{endpoint(action, parameters, options)}/"
+ end
+
+ def endpoint(action, parameters, options)
+ case action
+ when 'purchase'
+ 'secure_payments'
+ when 'authorize'
+ 'secure_payments'
+ when 'refund'
+ 'refunds'
+ when 'capture'
+ "payments/#{parameters[:payment_id]}/capture"
+ when 'void'
+ "payments/#{parameters[:payment_id]}/cancel"
+ end
+ end
+
+ def headers(post, options={})
+ timestamp = Time.now.utc.iso8601
+ headers = {
+ 'Content-Type' => 'application/json',
+ 'X-Date' => timestamp,
+ 'X-Login' => @options[:login],
+ 'X-Trans-Key' => @options[:trans_key],
+ 'Authorization' => signature(post, timestamp)
+ }
+ headers.merge('X-Idempotency-Key' => options[:idempotency_key]) if options[:idempotency_key]
+ headers
+ end
+
+ def signature(post, timestamp)
+ content = "#{@options[:login]}#{timestamp}#{post}"
+ digest = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), @options[:secret_key], content)
+ "V2-HMAC-SHA256, Signature: #{digest}"
+ end
+
+ def post_data(action, parameters = {})
+ parameters.to_json
+ end
+ end
+ end
+end
diff --git a/test/fixtures.yml b/test/fixtures.yml
index be2d8930f18..7ad8b36e3f2 100644
--- a/test/fixtures.yml
+++ b/test/fixtures.yml
@@ -239,6 +239,12 @@ cyber_source:
login: X
password: Y
+# Working credentials, no need to replace
+d_local:
+ login: aeaf9bbfa1
+ trans_key: 9de3769b7e
+ secret_key: ae132899f56162a669b38dab5927862f3
+
data_cash:
login: X
password: Y
diff --git a/test/remote/gateways/remote_d_local_test.rb b/test/remote/gateways/remote_d_local_test.rb
new file mode 100644
index 00000000000..f704e54e5d4
--- /dev/null
+++ b/test/remote/gateways/remote_d_local_test.rb
@@ -0,0 +1,209 @@
+require 'test_helper'
+
+class RemoteDLocalTest < Test::Unit::TestCase
+ def setup
+ @gateway = DLocalGateway.new(fixtures(:d_local))
+
+ @amount = 100
+ @credit_card = credit_card('4111111111111111')
+ # No test card numbers, all txns are approved by default,
+ # but errors can be invoked directly with the `description` field
+ @options = {
+ billing_address: address(country: 'Brazil'),
+ document: '42243309114',
+ currency: 'BRL'
+ }
+ @options_colombia = {
+ billing_address: address(country: 'Colombia'),
+ document: '11186456',
+ currency: 'COP'
+ }
+ @options_argentina = {
+ billing_address: address(country: 'Argentina'),
+ document: '10563145',
+ currency: 'ARS'
+ }
+ @options_mexico = {
+ billing_address: address(country: 'Mexico'),
+ document: '128475869794933',
+ currency: 'MXN'
+ }
+ @options_peru = {
+ billing_address: address(country: 'Peru'),
+ document: '184853849',
+ currency: 'PEN'
+ }
+ end
+
+ def test_successful_purchase
+ response = @gateway.purchase(@amount, @credit_card, @options)
+ assert_success response
+ assert_match 'The payment was paid', response.message
+ end
+
+ def test_successful_purchase_with_more_options
+ options = @options.merge(
+ order_id: '1',
+ ip: '127.0.0.1',
+ email: 'joe@example.com',
+ birth_date: '03-01-1970',
+ document2: '87648987569',
+ idempotency_key: generate_unique_id,
+ user_reference: generate_unique_id
+ )
+
+ response = @gateway.purchase(@amount, @credit_card, options)
+ assert_success response
+ assert_match 'The payment was paid', response.message
+ end
+
+ # You may need dLocal to enable your test account to support individual countries
+ def test_successful_purchase_colombia
+ response = @gateway.purchase(100000, @credit_card, @options_colombia)
+ assert_success response
+ assert_match 'The payment was paid', response.message
+ end
+
+ def test_successful_purchase_argentina
+ response = @gateway.purchase(@amount, @credit_card, @options_argentina)
+ assert_success response
+ assert_match 'The payment was paid', response.message
+ end
+
+ def test_successful_purchase_mexico
+ response = @gateway.purchase(@amount, @credit_card, @options_mexico)
+ assert_success response
+ assert_match 'The payment was paid', response.message
+ end
+
+ def test_successful_purchase_peru
+ response = @gateway.purchase(@amount, @credit_card, @options_peru)
+ assert_success response
+ assert_match 'The payment was paid', response.message
+ end
+
+ def test_failed_purchase
+ response = @gateway.purchase(@amount, @credit_card, @options.merge(description: '300'))
+ assert_failure response
+ assert_match 'The payment was rejected', response.message
+ end
+
+ def test_failed_document_format
+ response = @gateway.purchase(@amount, @credit_card, @options.merge(document: 'bad_document'))
+ assert_failure response
+ assert_match 'Invalid parameter: payer.document', response.message
+ end
+
+ def test_successful_authorize_and_capture
+ auth = @gateway.authorize(@amount, @credit_card, @options)
+ assert_success auth
+ assert_match 'The payment was authorized', auth.message
+
+ assert capture = @gateway.capture(@amount, auth.authorization, @options)
+ assert_success capture
+ assert_match 'The payment was paid', capture.message
+ end
+
+ def test_failed_authorize
+ response = @gateway.authorize(@amount, @credit_card, @options.merge(description: '309'))
+ assert_failure response
+ assert_equal '309', response.error_code
+ assert_match 'Card expired', response.message
+ end
+
+ def test_partial_capture
+ auth = @gateway.authorize(@amount, @credit_card, @options)
+ assert_success auth
+
+ assert capture = @gateway.capture(@amount-1, auth.authorization, @options)
+ assert_success capture
+ end
+
+ def test_failed_capture
+ response = @gateway.capture(@amount, 'bad_id')
+ assert_failure response
+
+ assert_equal '4000', response.error_code
+ assert_match 'Payment not found', response.message
+ end
+
+ def test_successful_refund
+ purchase = @gateway.purchase(@amount, @credit_card, @options)
+ assert_success purchase
+
+ assert refund = @gateway.refund(@amount, purchase.authorization, @options.merge(notification_url: 'http://example.com'))
+ assert_success refund
+ assert_match 'The refund was paid', refund.message
+ end
+
+ def test_partial_refund
+ purchase = @gateway.purchase(@amount, @credit_card, @options)
+ assert_success purchase
+
+ assert refund = @gateway.refund(@amount-1, purchase.authorization, @options.merge(notification_url: 'http://example.com'))
+ assert_success refund
+ end
+
+ def test_failed_refund
+ purchase = @gateway.purchase(@amount, @credit_card, @options)
+ assert_success purchase
+
+ response = @gateway.refund(@amount+1, purchase.authorization, @options.merge(notification_url: 'http://example.com'))
+ assert_failure response
+ assert_match 'Amount exceeded', response.message
+ end
+
+ def test_successful_void
+ auth = @gateway.authorize(@amount, @credit_card, @options)
+ assert_success auth
+
+ assert void = @gateway.void(auth.authorization)
+ assert_success void
+ assert_match 'The payment was cancelled', void.message
+ end
+
+ def test_failed_void
+ auth = @gateway.authorize(@amount, @credit_card, @options)
+ assert_success auth
+
+ assert capture = @gateway.capture(@amount, auth.authorization, @options)
+ assert_success capture
+
+ response = @gateway.void(auth.authorization)
+ assert_failure response
+ assert_match 'Invalid transaction status', response.message
+ end
+
+ def test_successful_verify
+ response = @gateway.verify(@credit_card, @options)
+ assert_success response
+ assert_match %r{The payment was authorized}, response.message
+ end
+
+ def test_failed_verify
+ response = @gateway.verify(@credit_card, @options.merge(description: '315'))
+ assert_failure response
+ assert_equal '315', response.error_code
+ assert_match %r{Invalid security code}, response.message
+ end
+
+ def test_invalid_login
+ gateway = DLocalGateway.new(login: '', trans_key: '', secret_key: '')
+
+ response = gateway.purchase(@amount, @credit_card, @options)
+ assert_failure response
+ assert_match %r{Invalid parameter}, response.message
+ end
+
+ def test_transcript_scrubbing
+ transcript = capture_transcript(@gateway) do
+ @gateway.purchase(@amount, @credit_card, @options)
+ end
+ transcript = @gateway.scrub(transcript)
+
+ assert_scrubbed(@credit_card.number, transcript)
+ assert_scrubbed(@credit_card.verification_value, transcript)
+ assert_scrubbed(@gateway.options[:trans_key], transcript)
+ end
+
+end
diff --git a/test/unit/gateways/d_local_test.rb b/test/unit/gateways/d_local_test.rb
new file mode 100644
index 00000000000..cac863704f9
--- /dev/null
+++ b/test/unit/gateways/d_local_test.rb
@@ -0,0 +1,226 @@
+require 'test_helper'
+
+class DLocalTest < Test::Unit::TestCase
+ def setup
+ @gateway = DLocalGateway.new(login: 'login', trans_key: 'password', secret_key: 'shhhhh_key')
+ @credit_card = credit_card
+ @amount = 100
+
+ @options = {
+ order_id: '1',
+ billing_address: address
+ }
+ end
+
+ def test_successful_purchase
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
+
+ response = @gateway.purchase(@amount, @credit_card, @options)
+ assert_success response
+
+ assert_equal 'D-15104-05b0ec0c-5a1e-470a-b342-eb5f20758ef7', response.authorization
+ assert response.test?
+ end
+
+ def test_failed_purchase
+ @gateway.expects(:ssl_post).returns(failed_purchase_response)
+
+ response = @gateway.purchase(@amount, @credit_card, @options)
+ assert_failure response
+ assert_equal '300', response.error_code
+ end
+
+ def test_successful_authorize
+ @gateway.expects(:ssl_post).returns(successful_authorize_response)
+
+ response = @gateway.authorize(@amount, @credit_card, @options)
+ assert_success response
+
+ assert_equal 'D-15104-be03e883-3e6b-497d-840e-54c8b6209bc3', response.authorization
+ end
+
+ def test_failed_authorize
+ @gateway.expects(:ssl_post).returns(failed_authorize_response)
+
+ response = @gateway.authorize(@amount, @credit_card, @options)
+ assert_failure response
+ assert_equal '309', response.error_code
+ end
+
+ def test_successful_capture
+ @gateway.expects(:ssl_post).returns(successful_capture_response)
+
+ response = @gateway.capture(@amount, 'D-15104-be03e883-3e6b-497d-840e-54c8b6209bc3', @options)
+ assert_success response
+
+ assert_equal 'D-15104-5a914b68-afb8-44f8-a849-8cf09ab6c246', response.authorization
+ end
+
+ def test_failed_capture
+ @gateway.expects(:ssl_post).returns(failed_capture_response)
+
+ response = @gateway.capture(@amount, 'D-15104-be03e883-3e6b-497d-840e-54c8b6209bc3', @options)
+ assert_failure response
+ assert_equal '4000', response.error_code
+ end
+
+ def test_successful_refund
+ @gateway.expects(:ssl_post).returns(successful_refund_response)
+
+ response = @gateway.refund(@amount, 'D-15104-be03e883-3e6b-497d-840e-54c8b6209bc3', @options)
+ assert_success response
+
+ assert_equal 'REF-15104-a9cc29e5-1895-4cec-94bd-aa16c3b92570', response.authorization
+ end
+
+ def test_pending_refund
+ @gateway.expects(:ssl_post).returns(pending_refund_response)
+
+ response = @gateway.refund(@amount, 'D-15104-be03e883-3e6b-497d-840e-54c8b6209bc3', @options)
+ assert_success response
+
+ assert_equal 'REF-15104-a9cc29e5-1895-4cec-94bd-aa16c3b92570', response.authorization
+ end
+
+ def test_failed_refund
+ @gateway.expects(:ssl_post).returns(failed_refund_response)
+
+ response = @gateway.refund(@amount, 'D-15104-be03e883-3e6b-497d-840e-54c8b6209bc3', @options)
+ assert_failure response
+ assert_equal '5007', response.error_code
+ end
+
+ def test_successful_void
+ @gateway.expects(:ssl_post).returns(successful_void_response)
+
+ response = @gateway.void('D-15104-be03e883-3e6b-497d-840e-54c8b6209bc3', @options)
+ assert_success response
+
+ assert_equal 'D-15104-c147279d-14ab-4537-8ba6-e3e1cde0f8d2', response.authorization
+ end
+
+ def test_failed_void
+ @gateway.expects(:ssl_post).returns(failed_void_response)
+
+ response = @gateway.void('D-15104-be03e883-3e6b-497d-840e-54c8b6209bc3', @options)
+ assert_failure response
+
+ assert_equal '5002', response.error_code
+ end
+
+ def test_successful_verify
+ @gateway.expects(:ssl_request).times(2).returns(successful_authorize_response, successful_void_response)
+
+ response = @gateway.verify(@credit_card, @options)
+ assert_success response
+
+ assert_equal 'D-15104-be03e883-3e6b-497d-840e-54c8b6209bc3', response.authorization
+ end
+
+ def test_successful_verify_with_failed_void
+ @gateway.expects(:ssl_request).times(2).returns(successful_authorize_response, failed_void_response)
+
+ response = @gateway.verify(@credit_card, @options)
+ assert_success response
+
+ assert_equal 'D-15104-be03e883-3e6b-497d-840e-54c8b6209bc3', response.authorization
+ end
+
+ def test_failed_verify
+ @gateway.expects(:ssl_post).returns(failed_authorize_response)
+
+ response = @gateway.verify(@credit_card, @options)
+ assert_failure response
+ assert_equal '309', response.error_code
+ end
+
+ def test_scrub
+ assert @gateway.supports_scrubbing?
+ assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed
+ end
+
+ private
+
+ def pre_scrubbed
+ %q(
+ <- "POST /secure_payments/ HTTP/1.1\r\nContent-Type: application/json\r\nX-Date: 2018-12-04T18:24:21Z\r\nX-Login: aeaf9bbfa1\r\nX-Trans-Key: 9de3769b7e\r\nAuthorization: V2-HMAC-SHA256, Signature: d58d0e87a59af50ff974dfeea176c067354682aa74a8ac115912576d4214a776\r\nConnection: close\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nHost: sandbox.dlocal.com\r\nContent-Length: 441\r\n\r\n"
+ <- "{\"amount\":\"1.00\",\"currency\":\"BRL\",\"payment_method_id\":\"CARD\",\"payment_method_type\":\"CARD\",\"payment_method_flow\":\"DIRECT\",\"country\":\"BR\",\"payer\":{\"name\":\"Longbob Longsen\",\"phone\":\"(555)555-5555\",\"document\":\"42243309114\",\"address\":null},\"card\":{\"holder_name\":\"Longbob Longsen\",\"expiration_month\":9,\"expiration_year\":2019,\"number\":\"4111111111111111\",\"cvv\":\"123\",\"capture\":true},\"order_id\":\"62595c5db10fdf7b5d5bb3a16d130992\",\"description\":\"200\"}"
+ -> "HTTP/1.1 200 OK\r\n"
+ -> "Server: Reblaze Secure Web Gateway\r\n"
+ -> "Date: Tue, 04 Dec 2018 18:24:22 GMT\r\n"
+ -> "Content-Type: application/json;charset=utf-8\r\n"
+ -> "Content-Length: 565\r\n"
+ -> "Strict-Transport-Security: max-age=31536000; includeSubDomains\r\n"
+ -> "Via: 1.1 google\r\n"
+ -> "Alt-Svc: clear\r\n"
+ -> "Connection: close\r\n"
+ -> "\r\n"
+ reading 565 bytes...
+ -> "{\"id\":\"D-15104-9f5246d5-34e2-4f63-9d29-380ab1567ec9\",\"amount\":1.00,\"currency\":\"BRL\",\"payment_method_id\":\"CARD\",\"payment_method_type\":\"CARD\",\"payment_method_flow\":\"DIRECT\",\"country\":\"BR\",\"card\":{\"holder_name\":\"Longbob Longsen\",\"expiration_month\":9,\"expiration_year\":2019,\"brand\":\"VI\",\"last4\":\"1111\",\"card_id\":\"CV-434cb5d1-aece-4878-8ce2-24f887fc7ff5\"},\"created_date\":\"2018-12-04T18:24:21.000+0000\",\"approved_date\":\"2018-12-04T18:24:22.000+0000\",\"status\":\"PAID\",\"status_detail\":\"The payment was paid\",\"status_code\":\"200\",\"order_id\":\"62595c5db10fdf7b5d5bb3a16d130992\"}"
+ )
+ end
+
+ def post_scrubbed
+ %q(
+ <- "POST /secure_payments/ HTTP/1.1\r\nContent-Type: application/json\r\nX-Date: 2018-12-04T18:24:21Z\r\nX-Login: aeaf9bbfa1\r\nX-Trans-Key: [FILTERED]\r\nAuthorization: V2-HMAC-SHA256, Signature: d58d0e87a59af50ff974dfeea176c067354682aa74a8ac115912576d4214a776\r\nConnection: close\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nHost: sandbox.dlocal.com\r\nContent-Length: 441\r\n\r\n"
+ <- "{\"amount\":\"1.00\",\"currency\":\"BRL\",\"payment_method_id\":\"CARD\",\"payment_method_type\":\"CARD\",\"payment_method_flow\":\"DIRECT\",\"country\":\"BR\",\"payer\":{\"name\":\"Longbob Longsen\",\"phone\":\"(555)555-5555\",\"document\":\"42243309114\",\"address\":null},\"card\":{\"holder_name\":\"Longbob Longsen\",\"expiration_month\":9,\"expiration_year\":2019,\"number\":\"[FILTERED]\",\"cvv\":\"[FILTERED]\",\"capture\":true},\"order_id\":\"62595c5db10fdf7b5d5bb3a16d130992\",\"description\":\"200\"}"
+ -> "HTTP/1.1 200 OK\r\n"
+ -> "Server: Reblaze Secure Web Gateway\r\n"
+ -> "Date: Tue, 04 Dec 2018 18:24:22 GMT\r\n"
+ -> "Content-Type: application/json;charset=utf-8\r\n"
+ -> "Content-Length: 565\r\n"
+ -> "Strict-Transport-Security: max-age=31536000; includeSubDomains\r\n"
+ -> "Via: 1.1 google\r\n"
+ -> "Alt-Svc: clear\r\n"
+ -> "Connection: close\r\n"
+ -> "\r\n"
+ reading 565 bytes...
+ -> "{\"id\":\"D-15104-9f5246d5-34e2-4f63-9d29-380ab1567ec9\",\"amount\":1.00,\"currency\":\"BRL\",\"payment_method_id\":\"CARD\",\"payment_method_type\":\"CARD\",\"payment_method_flow\":\"DIRECT\",\"country\":\"BR\",\"card\":{\"holder_name\":\"Longbob Longsen\",\"expiration_month\":9,\"expiration_year\":2019,\"brand\":\"VI\",\"last4\":\"1111\",\"card_id\":\"CV-434cb5d1-aece-4878-8ce2-24f887fc7ff5\"},\"created_date\":\"2018-12-04T18:24:21.000+0000\",\"approved_date\":\"2018-12-04T18:24:22.000+0000\",\"status\":\"PAID\",\"status_detail\":\"The payment was paid\",\"status_code\":\"200\",\"order_id\":\"62595c5db10fdf7b5d5bb3a16d130992\"}"
+ )
+ end
+
+ def successful_purchase_response
+ '{"id":"D-15104-05b0ec0c-5a1e-470a-b342-eb5f20758ef7","amount":1.00,"currency":"BRL","payment_method_id":"CARD","payment_method_type":"CARD","payment_method_flow":"DIRECT","country":"BR","card":{"holder_name":"Longbob Longsen","expiration_month":9,"expiration_year":2019,"brand":"VI","last4":"1111","card_id":"CV-993903e4-0b33-48fd-8d9b-99fd6c3f0d1a"},"created_date":"2018-12-06T20:20:41.000+0000","approved_date":"2018-12-06T20:20:42.000+0000","status":"PAID","status_detail":"The payment was paid","status_code":"200","order_id":"15940ef43d39331bc64f31341f8ccd93"}'
+ end
+
+ def failed_purchase_response
+ '{"id":"D-15104-c3027e67-21f8-4308-8c94-06c44ffcea67","amount":1.00,"currency":"BRL","payment_method_id":"CARD","payment_method_type":"CARD","payment_method_flow":"DIRECT","country":"BR","card":{"holder_name":"Longbob Longsen","expiration_month":9,"expiration_year":2019,"brand":"VI","last4":"1111","card_id":"CV-529b0bb1-8b8a-42f4-b5e4-d358ffb2c978"},"created_date":"2018-12-06T20:22:40.000+0000","status":"REJECTED","status_detail":"The payment was rejected.","status_code":"300","order_id":"7aa5cd3200f287fbac51dcee32184260"}'
+ end
+
+ def successful_authorize_response
+ '{"id":"D-15104-be03e883-3e6b-497d-840e-54c8b6209bc3","amount":1.00,"currency":"BRL","payment_method_id":"CARD","payment_method_type":"CARD","payment_method_flow":"DIRECT","country":"BR","card":{"holder_name":"Longbob Longsen","expiration_month":9,"expiration_year":2019,"brand":"VI","last4":"1111","card_id":"CV-ecd897ac-5361-45a1-a407-aaab044ce87e"},"created_date":"2018-12-06T20:24:46.000+0000","approved_date":"2018-12-06T20:24:46.000+0000","status":"AUTHORIZED","status_detail":"The payment was authorized","status_code":"600","order_id":"5694b51b79df484578158d7790b4aacf"}'
+ end
+
+ def failed_authorize_response
+ '{"id":"D-15104-e6ed3df3-1380-46c6-92d4-29f0f567f799","amount":1.00,"currency":"BRL","payment_method_id":"CARD","payment_method_type":"CARD","payment_method_flow":"DIRECT","country":"BR","card":{"holder_name":"Longbob Longsen","expiration_month":9,"expiration_year":2019,"brand":"VI","last4":"1111","card_id":"CV-a6326a1d-b706-4e89-9dff-091d73d85b26"},"created_date":"2018-12-06T20:26:57.000+0000","status":"REJECTED","status_detail":"Card expired.","status_code":"309","order_id":"8ecd3101ba7a9a2d6ccb6465d33ff10d"}'
+ end
+
+ def successful_capture_response
+ '{"id":"D-15104-5a914b68-afb8-44f8-a849-8cf09ab6c246","amount":1.00,"currency":"BRL","payment_method_id":"VI","payment_method_type":"CARD","payment_method_flow":"DIRECT","country":"BR","created_date":"2018-12-06T20:26:17.000+0000","approved_date":"2018-12-06T20:26:18.000+0000","status":"PAID","status_detail":"The payment was paid","status_code":"200","order_id":"f8276e468120faf3e7252e33ac5f9a73"}'
+ end
+
+ def failed_capture_response
+ '{"code":4000,"message":"Payment not found"}'
+ end
+
+ def successful_refund_response
+ '{"id":"REF-15104-a9cc29e5-1895-4cec-94bd-aa16c3b92570","payment_id":"D-15104-f9e16b85-5fc8-40f0-a4d8-4e73a892594f","status":"SUCCESS","currency":"BRL","created_date":"2018-12-06T20:28:37.000+0000","amount":1.00,"status_code":200,"status_detail":"The refund was paid","notification_url":"http://example.com","amount_refunded":1.00,"id_payment":"D-15104-f9e16b85-5fc8-40f0-a4d8-4e73a892594f"}'
+ end
+
+ # I can't invoke a pending response and there is no example in docs, so this response is speculative
+ def pending_refund_response
+ '{"id":"REF-15104-a9cc29e5-1895-4cec-94bd-aa16c3b92570","payment_id":"D-15104-f9e16b85-5fc8-40f0-a4d8-4e73a892594f","status":"PENDING","currency":"BRL","created_date":"2018-12-06T20:28:37.000+0000","amount":1.00,"status_code":100,"status_detail":"The refund is pending","notification_url":"http://example.com","amount_refunded":1.00,"id_payment":"D-15104-f9e16b85-5fc8-40f0-a4d8-4e73a892594f"}'
+ end
+
+ def failed_refund_response
+ '{"code":5007,"message":"Amount exceeded"}'
+ end
+
+ def successful_void_response
+ '{"id":"D-15104-c147279d-14ab-4537-8ba6-e3e1cde0f8d2","amount":1.00,"currency":"BRL","payment_method_id":"VI","payment_method_type":"CARD","payment_method_flow":"DIRECT","country":"BR","created_date":"2018-12-06T20:38:01.000+0000","approved_date":"2018-12-06T20:38:01.000+0000","status":"CANCELLED","status_detail":"The payment was cancelled","status_code":"400","order_id":"46d8978863be935d892cfa3e992f65f3"}'
+ end
+
+ def failed_void_response
+ '{"code":5002,"message":"Invalid transaction status"}'
+ end
+end
From a594e8c7222f427224951d50652df284629a5fe3 Mon Sep 17 00:00:00 2001
From: David Perry
Date: Mon, 10 Dec 2018 13:31:09 -0500
Subject: [PATCH 0215/2234] dLocal: Require secret_key
Closes #3080
Remote:
21 tests, 59 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
15 tests, 45 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/d_local.rb | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 771d5b91d10..55e3f6c07e6 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -10,6 +10,7 @@
* Payeezy: Support $0 for verify transactions [molbrown] #3074
* USA ePay: add support for recurring transactions, custom fields, and line items [lancecarlson] #3069
* Add dLocal gateway [curiousepic] #3709
+* dLocal: Require secret_key [curiousepic] #3080
== Version 1.88.0 (November 30, 2018)
* Added ActiveSupport/Rails master support [Edouard-chin] #3065
diff --git a/lib/active_merchant/billing/gateways/d_local.rb b/lib/active_merchant/billing/gateways/d_local.rb
index 43027bd7b92..deef1687b9b 100644
--- a/lib/active_merchant/billing/gateways/d_local.rb
+++ b/lib/active_merchant/billing/gateways/d_local.rb
@@ -12,7 +12,7 @@ class DLocalGateway < Gateway
self.display_name = 'dLocal'
def initialize(options={})
- requires!(options, :login, :trans_key)
+ requires!(options, :login, :trans_key, :secret_key)
super
end
From e37168c092b5e15ab256198b2b0fe952b32d5220 Mon Sep 17 00:00:00 2001
From: Niaja
Date: Wed, 5 Dec 2018 16:40:01 -0500
Subject: [PATCH 0216/2234] Adyen: Implement 3DS
Allows for 3DS implementation on Adyen gateway.
Loaded suite test/remote/gateways/remote_adyen_test
.....................................
37 tests, 97 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Loaded suite test/unit/gateways/adyen_test
.........................
25 tests, 124 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/adyen.rb | 11 ++++++++++-
test/remote/gateways/remote_adyen_test.rb | 12 ++++++++++++
test/unit/gateways/adyen_test.rb | 19 +++++++++++++++++++
4 files changed, 42 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 55e3f6c07e6..2f21482e4a3 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -11,6 +11,7 @@
* USA ePay: add support for recurring transactions, custom fields, and line items [lancecarlson] #3069
* Add dLocal gateway [curiousepic] #3709
* dLocal: Require secret_key [curiousepic] #3080
+* Adyen: Implement 3DS [nfarve] #3076
== Version 1.88.0 (November 30, 2018)
* Added ActiveSupport/Rails master support [Edouard-chin] #3065
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index 2e7b5ba1eb9..82d3e39385c 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -33,6 +33,9 @@ def initialize(options={})
end
def purchase(money, payment, options={})
+ if options[:execute_threed]
+ authorize(money, payment, options)
+ end
MultiResponse.run do |r|
r.process { authorize(money, payment, options) }
r.process { capture(money, r.authorization, options) }
@@ -48,6 +51,7 @@ def authorize(money, payment, options={})
add_shopper_interaction(post, payment, options)
add_address(post, options)
add_installments(post, options) if options[:installments]
+ add_3ds(post, options) if options[:execute_threed]
commit('authorise', post)
end
@@ -258,6 +262,11 @@ def add_installments(post, options)
}
end
+ def add_3ds(post, options)
+ post[:additionalData] = { executeThreeD: 'true' }
+ post[:browserInfo] = { userAgent: options[:user_agent], acceptHeader: options[:accept_header] }
+ end
+
def parse(body)
return {} if body.blank?
JSON.parse(body)
@@ -315,7 +324,7 @@ def request_headers
def success_from(action, response)
case action.to_s
- when 'authorise'
+ when 'authorise', 'authorise3d'
['Authorised', 'Received', 'RedirectShopper'].include?(response['resultCode'])
when 'capture', 'refund', 'cancel'
response['response'] == "[#{action}-received]"
diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb
index d9f2bfead67..cec2de5001c 100644
--- a/test/remote/gateways/remote_adyen_test.rb
+++ b/test/remote/gateways/remote_adyen_test.rb
@@ -15,6 +15,8 @@ def setup
:brand => 'visa'
)
+ @three_ds_enrolled_card = credit_card('4212345678901237', brand: :visa)
+
@declined_card = credit_card('4000300011112220')
@improperly_branded_maestro = credit_card(
@@ -60,6 +62,16 @@ def test_successful_authorize
assert_equal 'Authorised', response.message
end
+ def test_successful_authorize_with_3ds
+ assert response = @gateway.authorize(@amount, @three_ds_enrolled_card, @options.merge(execute_threed: true))
+ assert response.test?
+ refute response.authorization.blank?
+ assert_equal response.params['resultCode'], 'RedirectShopper'
+ refute response.params['issuerUrl'].blank?
+ refute response.params['md'].blank?
+ refute response.params['paRequest'].blank?
+ end
+
def test_failed_authorize
response = @gateway.authorize(@amount, @declined_card, @options)
assert_failure response
diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb
index abfdee32e92..08642c39387 100644
--- a/test/unit/gateways/adyen_test.rb
+++ b/test/unit/gateways/adyen_test.rb
@@ -19,6 +19,8 @@ def setup
:brand => 'visa'
)
+ @three_ds_enrolled_card = credit_card('4212345678901237', brand: :visa)
+
@apple_pay_card = network_tokenization_credit_card('4111111111111111',
:payment_cryptogram => 'YwAAAAAABaYcCMX/OhNRQAAAAAA=',
:month => '08',
@@ -69,6 +71,19 @@ def test_successful_authorize
assert response.test?
end
+ def test_successful_authorize_with_3ds
+ @gateway.expects(:ssl_post).returns(successful_authorize_with_3ds_response)
+
+ response = @gateway.authorize(@amount, @three_ds_enrolled_card, @options.merge(execute_threed: true))
+ assert response.test?
+ refute response.authorization.blank?
+ assert_equal '#8835440446784145#', response.authorization
+ assert_equal response.params['resultCode'], 'RedirectShopper'
+ refute response.params['issuerUrl'].blank?
+ refute response.params['md'].blank?
+ refute response.params['paRequest'].blank?
+ end
+
def test_failed_authorize
@gateway.expects(:ssl_post).returns(failed_authorize_response)
@@ -432,6 +447,10 @@ def successful_authorize_response
RESPONSE
end
+ def successful_authorize_with_3ds_response
+ '{"pspReference":"8835440446784145","resultCode":"RedirectShopper","issuerUrl":"https:\\/\\/test.adyen.com\\/hpp\\/3d\\/validate.shtml","md":"djIhcWk3MUhlVFlyQ1h2UC9NWmhpVm10Zz09IfIxi5eDMZgG72AUXy7PEU86esY68wr2cunaFo5VRyNPuWg3ZSvEIFuielSuoYol5WhjCH+R6EJTjVqY8eCTt+0wiqHd5btd82NstIc8idJuvg5OCu2j8dYo0Pg7nYxW\\/2vXV9Wy\\/RYvwR8tFfyZVC\\/U2028JuWtP2WxrBTqJ6nV2mDoX2chqMRSmX8xrL6VgiLoEfzCC\\/c+14r77+whHP0Mz96IGFf4BIA2Qo8wi2vrTlccH\\/zkLb5hevvV6QH3s9h0\\/JibcUrpoXH6M903ulGuikTr8oqVjEB9w8\\/WlUuxukHmqqXqAeOPA6gScehs6SpRm45PLpLysCfUricEIDhpPN1QCjjgw8+qVf3Ja1SzwfjCVocU","paRequest":"eNpVUctuwjAQ\\/BXaD2Dt4JCHFkspqVQOBChwriJnBanIAyepoF9fG5LS+jQz612PZ3F31ETxllSnSeKSmiY90CjPZs+h709cIZgQU88XXLjPEtfRO50lfpFu8qqUfMzGDsJATbtWx7RsJabq\\/LJIJHcmwp0i9BQL0otY7qhp10URqXOXa9IIdxnLtCC5jz6i+VO4rY2v7HSdr5ZOIBBuNVRVV7b6Kn3BEAaCnT7JY9vWIUDTt41VVSDYAsLD1bqzqDGDLnkmV\\/HhO9lt2DLesORTiSR+ZckmsmeGYG9glrYkHcZ97jB35PCQe6HrI9x0TAvrQO638cgkYRz1Atb2nehOuC38FdBEralUwy8GhnSpq5LMDRPpL0Z4mJ6\\/2WBVa7ISzj1azw+YQZ6N+FawU3ITCg9YcBtjCYJthX570G\\/ZoH\\/b\\/wFlSqpp"}'
+ end
+
def failed_authorize_response
<<-RESPONSE
{
From 11e6490dfec86375e08bb78854617aecf4381b37 Mon Sep 17 00:00:00 2001
From: Niaja
Date: Mon, 10 Dec 2018 16:30:27 -0500
Subject: [PATCH 0217/2234] Adyen: Add 3DS Fix
Loaded suite test/remote/gateways/remote_adyen_test
.....................................
37 tests, 97 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Loaded suite test/unit/gateways/adyen_test
.........................
25 tests, 124 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/adyen.rb | 9 +++++----
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 2f21482e4a3..990ad7da97e 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -12,6 +12,7 @@
* Add dLocal gateway [curiousepic] #3709
* dLocal: Require secret_key [curiousepic] #3080
* Adyen: Implement 3DS [nfarve] #3076
+* Adyen: Add 3DS Fix [nfarve] #3081
== Version 1.88.0 (November 30, 2018)
* Added ActiveSupport/Rails master support [Edouard-chin] #3065
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index 82d3e39385c..4bf167bd081 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -35,10 +35,11 @@ def initialize(options={})
def purchase(money, payment, options={})
if options[:execute_threed]
authorize(money, payment, options)
- end
- MultiResponse.run do |r|
- r.process { authorize(money, payment, options) }
- r.process { capture(money, r.authorization, options) }
+ else
+ MultiResponse.run do |r|
+ r.process { authorize(money, payment, options) }
+ r.process { capture(money, r.authorization, options) }
+ end
end
end
From 9c1d234eaac89bbebbed5dac6dd51659d7846bed Mon Sep 17 00:00:00 2001
From: Niaja
Date: Fri, 14 Dec 2018 09:56:25 -0500
Subject: [PATCH 0218/2234] Payeezy: Add `stored_credentials`
Adds params for `stored_credentials` to support compliance with Visa/MC.
Loaded suite test/remote/gateways/remote_payeezy_test
..................................
34 tests, 134 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Loaded suite test/unit/gateways/payeezy_test
..................................
34 tests, 162 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/payeezy.rb | 13 +++++++++++
test/remote/gateways/remote_payeezy_test.rb | 13 +++++++++++
test/unit/gateways/payeezy_test.rb | 23 +++++++++++++++++++
4 files changed, 50 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index 990ad7da97e..babe9344a35 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -13,6 +13,7 @@
* dLocal: Require secret_key [curiousepic] #3080
* Adyen: Implement 3DS [nfarve] #3076
* Adyen: Add 3DS Fix [nfarve] #3081
+* Payeezy: Add `stored_credentials` [nfarve] #3083)
== Version 1.88.0 (November 30, 2018)
* Added ActiveSupport/Rails master support [Edouard-chin] #3065
diff --git a/lib/active_merchant/billing/gateways/payeezy.rb b/lib/active_merchant/billing/gateways/payeezy.rb
index cb2e4ff4c13..b1ac0632f4c 100644
--- a/lib/active_merchant/billing/gateways/payeezy.rb
+++ b/lib/active_merchant/billing/gateways/payeezy.rb
@@ -39,6 +39,7 @@ def purchase(amount, payment_method, options = {})
add_address(params, options)
add_amount(params, amount, options)
add_soft_descriptors(params, options)
+ add_stored_credentials(params, options)
commit(params, options)
end
@@ -52,6 +53,7 @@ def authorize(amount, payment_method, options = {})
add_address(params, options)
add_amount(params, amount, options)
add_soft_descriptors(params, options)
+ add_stored_credentials(params, options)
commit(params, options)
end
@@ -244,6 +246,17 @@ def add_soft_descriptors(params, options)
params[:soft_descriptors] = options[:soft_descriptors] if options[:soft_descriptors]
end
+ def add_stored_credentials(params, options)
+ if options[:sequence]
+ params[:stored_credentials] = {}
+ params[:stored_credentials][:cardbrand_original_transaction_id] = options[:cardbrand_original_transaction_id] if options[:cardbrand_original_transaction_id]
+ params[:stored_credentials][:sequence] = options[:sequence]
+ params[:stored_credentials][:initiator] = options[:initiator] if options[:initiator]
+ params[:stored_credentials][:is_scheduled] = options[:is_scheduled]
+ params[:stored_credentials][:auth_type_override] = options[:auth_type_override] if options[:auth_type_override]
+ end
+ end
+
def commit(params, options)
url = base_url(options) + endpoint(params)
diff --git a/test/remote/gateways/remote_payeezy_test.rb b/test/remote/gateways/remote_payeezy_test.rb
index 24871731678..789e500a456 100644
--- a/test/remote/gateways/remote_payeezy_test.rb
+++ b/test/remote/gateways/remote_payeezy_test.rb
@@ -26,6 +26,13 @@ def setup
merchant_contact_info: '8885551212'
}
}
+ @options_stored_credentials = {
+ cardbrand_original_transaction_id: 'abc123',
+ sequence: 'FIRST',
+ is_scheduled: true,
+ initiator: 'MERCHANT',
+ auth_type_override: 'A'
+ }
end
def test_successful_store
@@ -68,6 +75,12 @@ def test_successful_purchase_with_soft_descriptors
assert_success response
end
+ def test_successful_purchase_with_stored_credentials
+ assert response = @gateway.purchase(@amount, @credit_card, @options.merge(@options_stored_credentials))
+ assert_match(/Transaction Normal/, response.message)
+ assert_success response
+ end
+
def test_failed_purchase
@amount = 501300
assert response = @gateway.purchase(@amount, @credit_card, @options)
diff --git a/test/unit/gateways/payeezy_test.rb b/test/unit/gateways/payeezy_test.rb
index 6d95954c196..abc9e1e0131 100644
--- a/test/unit/gateways/payeezy_test.rb
+++ b/test/unit/gateways/payeezy_test.rb
@@ -15,6 +15,13 @@ def setup
:billing_address => address,
:ta_token => '123'
}
+ @options_stored_credentials = {
+ cardbrand_original_transaction_id: 'abc123',
+ sequence: 'FIRST',
+ is_scheduled: true,
+ initiator: 'MERCHANT',
+ auth_type_override: 'A'
+ }
@authorization = 'ET1700|106625152|credit_card|4738'
@reversal_id = SecureRandom.random_number(1000000).to_s
end
@@ -116,6 +123,18 @@ def test_successful_purchase_defaulting_check_number
assert_equal 'Transaction Normal - Approved', response.message
end
+ def test_successful_purchase_with_stored_credentials
+ response = stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options.merge(@options_stored_credentials))
+ end.check_request do |endpoint, data, headers|
+ assert_match(/stored_credentials/, data)
+ end.respond_with(successful_purchase_stored_credentials_response)
+
+ assert_success response
+ assert response.test?
+ assert_equal 'Transaction Normal - Approved', response.message
+ end
+
def test_failed_purchase
@gateway.expects(:ssl_post).raises(failed_purchase_response)
assert response = @gateway.purchase(@amount, @credit_card, @options)
@@ -470,6 +489,10 @@ def successful_purchase_response
RESPONSE
end
+ def successful_purchase_stored_credentials_response
+ '{"correlation_id":"228.4479800174823","transaction_status":"approved","validation_status":"success","transaction_type":"purchase","transaction_id":"ET117353","transaction_tag":"2309866208","method":"credit_card","amount":"100","currency":"USD","avs":"4","cvv2":"M","token":{"token_type":"FDToken","token_data":{"value":"9091469151414242"}},"card":{"type":"Visa","cardholder_name":"Longbob Longsen","card_number":"4242","exp_date":"0919"},"bank_resp_code":"100","bank_message":"Approved","gateway_resp_code":"00","gateway_message":"Transaction Normal","stored_credentials":{"cardbrand_original_transaction_id":"706838021010062"}}'
+ end
+
def successful_purchase_echeck_response
<<-RESPONSE
{\"correlation_id\":\"228.1449688619062\",\"transaction_status\":\"approved\",\"validation_status\":\"success\",\"transaction_type\":\"purchase\",\"transaction_id\":\"ET133078\",\"transaction_tag\":\"69864362\",\"method\":\"tele_check\",\"amount\":\"100\",\"currency\":\"USD\",\"bank_resp_code\":\"100\",\"bank_message\":\"Approved\",\"gateway_resp_code\":\"00\",\"gateway_message\":\"Transaction Normal\",\"tele_check\":{\"accountholder_name\":\"Jim Smith\",\"check_number\":\"1\",\"check_type\":\"P\",\"account_number\":\"8535\",\"routing_number\":\"244183602\"}}
From 7c77c2f1da002a7067fc5b6e588ed20a839051d7 Mon Sep 17 00:00:00 2001
From: Filipe Costa
Date: Mon, 17 Dec 2018 12:00:01 -0500
Subject: [PATCH 0219/2234] Does not fail validation for blank cvv on maestro
cards (#3082)
This change is allowing users to pass `cvv: blank` and pass validation
even when `CreditCard.require_verification_value = true` for maestro,
since cvv length is 0
---
lib/active_merchant/billing/credit_card.rb | 2 +-
test/unit/credit_card_test.rb | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/lib/active_merchant/billing/credit_card.rb b/lib/active_merchant/billing/credit_card.rb
index d48f1d2b769..81f978e5eab 100644
--- a/lib/active_merchant/billing/credit_card.rb
+++ b/lib/active_merchant/billing/credit_card.rb
@@ -362,7 +362,7 @@ def validate_verification_value #:nodoc:
unless valid_card_verification_value?(verification_value, brand)
errors << [:verification_value, "should be #{card_verification_value_length(brand)} digits"]
end
- elsif requires_verification_value?
+ elsif requires_verification_value? && !valid_card_verification_value?(verification_value, brand)
errors << [:verification_value, 'is required']
end
errors
diff --git a/test/unit/credit_card_test.rb b/test/unit/credit_card_test.rb
index fed8dea282f..d31748f17bb 100644
--- a/test/unit/credit_card_test.rb
+++ b/test/unit/credit_card_test.rb
@@ -36,6 +36,11 @@ def test_should_be_a_valid_maestro_card
assert_valid @maestro
end
+ def test_should_be_a_valid_maestro_card_when_require_cvv_is_true
+ CreditCard.require_verification_value = true
+ assert_valid @maestro
+ end
+
def test_cards_with_empty_names_should_not_be_valid
@visa.first_name = ''
@visa.last_name = ''
From 16f9ed76a6d366500f602a691ee597d4c9860210 Mon Sep 17 00:00:00 2001
From: Filipe Costa
Date: Mon, 17 Dec 2018 12:09:00 -0500
Subject: [PATCH 0220/2234] Release v1.89.0
---
CHANGELOG | 6 +++++-
lib/active_merchant/version.rb | 2 +-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index babe9344a35..92f876f6107 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,11 +1,14 @@
= ActiveMerchant CHANGELOG
== HEAD
+
+== Version 1.89.0 (December 17, 2018)
* Worldpay: handle Visa and MasterCard payouts differently [bpollack] #3068
* QuickPay: update supported countries [ta] #3049
* WorldPay: set cardholder name to "3D" for 3DS transactions [bpollack] #3071
* Authorize.Net: Support refunds for bank accounts [nfarve] #3063
* Stripe: support specifying a reason for refunds [yosukehasumi] #3056
+* Paybox Direct: add support for XPF currency [adam-stead] #2938
* TrustCommerce: Add ACH Ability [nfarve] #3073
* Payeezy: Support $0 for verify transactions [molbrown] #3074
* USA ePay: add support for recurring transactions, custom fields, and line items [lancecarlson] #3069
@@ -13,7 +16,8 @@
* dLocal: Require secret_key [curiousepic] #3080
* Adyen: Implement 3DS [nfarve] #3076
* Adyen: Add 3DS Fix [nfarve] #3081
-* Payeezy: Add `stored_credentials` [nfarve] #3083)
+* Payeezy: Add `stored_credentials` [nfarve] #3083
+* Fix CVC validation for 0 length CVC [filipebarcos] #3082
== Version 1.88.0 (November 30, 2018)
* Added ActiveSupport/Rails master support [Edouard-chin] #3065
diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb
index 5af2175368e..c84c00b1c48 100644
--- a/lib/active_merchant/version.rb
+++ b/lib/active_merchant/version.rb
@@ -1,3 +1,3 @@
module ActiveMerchant
- VERSION = '1.88.0'
+ VERSION = '1.89.0'
end
From 00dceeb25848c583af5538e1f25d4ae328047daa Mon Sep 17 00:00:00 2001
From: molbrown
Date: Mon, 17 Dec 2018 11:39:45 -0500
Subject: [PATCH 0221/2234] NMI: Supports vendor_id and processor_id fields
ENE-71
ENE-72
Remote:
34 tests, 111 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
27 tests, 194 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Closes #3085
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/nmi.rb | 10 ++++++++++
test/remote/gateways/remote_nmi_test.rb | 13 +++++++++++++
3 files changed, 24 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index 92f876f6107..f9f5b02b603 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -18,6 +18,7 @@
* Adyen: Add 3DS Fix [nfarve] #3081
* Payeezy: Add `stored_credentials` [nfarve] #3083
* Fix CVC validation for 0 length CVC [filipebarcos] #3082
+* NMI: Supports vendor_id and processor_id fields [molbrown] #3085
== Version 1.88.0 (November 30, 2018)
* Added ActiveSupport/Rails master support [Edouard-chin] #3065
diff --git a/lib/active_merchant/billing/gateways/nmi.rb b/lib/active_merchant/billing/gateways/nmi.rb
index 8591a802945..17b4872e662 100644
--- a/lib/active_merchant/billing/gateways/nmi.rb
+++ b/lib/active_merchant/billing/gateways/nmi.rb
@@ -32,6 +32,7 @@ def purchase(amount, payment_method, options={})
add_invoice(post, amount, options)
add_payment_method(post, payment_method, options)
add_customer_data(post, options)
+ add_vendor_data(post, options)
add_merchant_defined_fields(post, options)
commit('sale', post)
@@ -42,6 +43,7 @@ def authorize(amount, payment_method, options={})
add_invoice(post, amount, options)
add_payment_method(post, payment_method, options)
add_customer_data(post, options)
+ add_vendor_data(post, options)
add_merchant_defined_fields(post, options)
commit('auth', post)
@@ -78,6 +80,7 @@ def credit(amount, payment_method, options={})
add_invoice(post, amount, options)
add_payment_method(post, payment_method, options)
add_customer_data(post, options)
+ add_vendor_data(post, options)
commit('credit', post)
end
@@ -86,6 +89,7 @@ def verify(payment_method, options={})
post = {}
add_payment_method(post, payment_method, options)
add_customer_data(post, options)
+ add_vendor_data(post, options)
add_merchant_defined_fields(post, options)
commit('validate', post)
@@ -96,6 +100,7 @@ def store(payment_method, options = {})
add_invoice(post, nil, options)
add_payment_method(post, payment_method, options)
add_customer_data(post, options)
+ add_vendor_data(post, options)
add_merchant_defined_fields(post, options)
commit('add_customer', post)
@@ -192,6 +197,11 @@ def add_customer_data(post, options)
end
end
+ def add_vendor_data(post, options)
+ post[:vendor_id] = options[:vendor_id] if options[:vendor_id]
+ post[:processor_id] = options[:processor_id] if options[:processor_id]
+ end
+
def add_merchant_defined_fields(post, options)
(1..20).each do |each|
key = "merchant_defined_field_#{each}".to_sym
diff --git a/test/remote/gateways/remote_nmi_test.rb b/test/remote/gateways/remote_nmi_test.rb
index e6d3701994a..1515b496121 100644
--- a/test/remote/gateways/remote_nmi_test.rb
+++ b/test/remote/gateways/remote_nmi_test.rb
@@ -86,6 +86,19 @@ def test_failed_purchase_with_apple_pay_card
assert_equal 'DECLINE', response.message
end
+ def test_successful_purchase_with_additional_options
+ options = @options.merge({
+ customer_id: '234',
+ vendor_id: '456',
+ recurring: true,
+ })
+ assert response = @gateway.purchase(@amount, @credit_card, options)
+ assert_success response
+ assert response.test?
+ assert_equal 'Succeeded', response.message
+ assert response.authorization
+ end
+
def test_successful_authorization
assert response = @gateway.authorize(@amount, @credit_card, @options)
assert_success response
From 3f0e890d8b886a0cd7511d4c1bf8827c0779c0e2 Mon Sep 17 00:00:00 2001
From: David Perry
Date: Thu, 20 Dec 2018 13:23:00 -0500
Subject: [PATCH 0222/2234] Mercado Pago: Support "gateway" processing mode
Includes a few updates to remote tests to account for changes in
gateway/sandbox behavior.
Closes #3087
Remote (1 unrelated failure and 1 for the processing mode specific to
another test account):
18 tests, 46 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
88.8889% passed
Unit:
19 tests, 93 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/mercado_pago.rb | 16 +++++++++++++++
.../gateways/remote_mercado_pago_test.rb | 20 ++++++++++++++++---
3 files changed, 34 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index f9f5b02b603..5f7dae312a0 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
= ActiveMerchant CHANGELOG
== HEAD
+* Mercado Pago: Support "gateway" processing mode [curiousepic] #3087
== Version 1.89.0 (December 17, 2018)
* Worldpay: handle Visa and MasterCard payouts differently [bpollack] #3068
diff --git a/lib/active_merchant/billing/gateways/mercado_pago.rb b/lib/active_merchant/billing/gateways/mercado_pago.rb
index 95a9f372930..79c2612dd25 100644
--- a/lib/active_merchant/billing/gateways/mercado_pago.rb
+++ b/lib/active_merchant/billing/gateways/mercado_pago.rb
@@ -95,6 +95,7 @@ def purchase_request(money, payment, options = {})
add_additional_data(post, options)
add_customer_data(post, payment, options)
add_address(post, options)
+ add_processing_mode(post, options)
post[:binary_mode] = (options[:binary_mode].nil? ? true : options[:binary_mode])
post
end
@@ -105,6 +106,21 @@ def authorize_request(money, payment, options = {})
post
end
+ def add_processing_mode(post, options)
+ return unless options[:processing_mode]
+ post[:processing_mode] = options[:processing_mode]
+ post[:merchant_account_id] = options[:merchant_account_id] if options[:merchant_account_id]
+ add_merchant_services(post, options)
+ end
+
+ def add_merchant_services(post, options)
+ return unless options[:fraud_scoring] || options[:fraud_manual_review]
+ merchant_services = {}
+ merchant_services[:fraud_scoring] = options[:fraud_scoring] if options[:fraud_scoring]
+ merchant_services[:fraud_manual_review] = options[:fraud_manual_review] if options[:fraud_manual_review]
+ post[:merchant_services] = merchant_services
+ end
+
def add_additional_data(post, options)
post[:sponsor_id] = options[:sponsor_id]
post[:device_id] = options[:device_id] if options[:device_id]
diff --git a/test/remote/gateways/remote_mercado_pago_test.rb b/test/remote/gateways/remote_mercado_pago_test.rb
index 54ddaa50072..917e9d316ad 100644
--- a/test/remote/gateways/remote_mercado_pago_test.rb
+++ b/test/remote/gateways/remote_mercado_pago_test.rb
@@ -13,6 +13,13 @@ def setup
email: 'user+br@example.com',
description: 'Store Purchase'
}
+ @processing_options = {
+ binary_mode: false,
+ processing_mode: 'gateway',
+ merchant_account_id: fixtures(:mercado_pago)[:merchant_account_id],
+ fraud_scoring: true,
+ fraud_manual_review: true
+ }
end
def test_successful_purchase
@@ -23,7 +30,14 @@ def test_successful_purchase
def test_successful_purchase_with_binary_false
@options.update(binary_mode: false)
- response = @gateway.purchase(@amount, @credit_card, @options)
+ response = @gateway.authorize(@amount, @credit_card, @options)
+ assert_success response
+ assert_equal 'pending_capture', response.message
+ end
+
+ # Requires setup on merchant account
+ def test_successful_purchase_with_processing_mode_gateway
+ response = @gateway.purchase(@amount, @credit_card, @options.merge(@processing_options))
assert_success response
assert_equal 'accredited', response.message
end
@@ -60,10 +74,10 @@ def test_failed_authorize
end
def test_partial_capture
- auth = @gateway.authorize(@amount, @credit_card, @options)
+ auth = @gateway.authorize(@amount+1, @credit_card, @options)
assert_success auth
- assert capture = @gateway.capture(@amount-1, auth.authorization)
+ assert capture = @gateway.capture(@amount, auth.authorization)
assert_success capture
assert_equal 'accredited', capture.message
end
From 3088619c26127e72c087fa7175a5646238bbe9a1 Mon Sep 17 00:00:00 2001
From: David Perry
Date: Mon, 31 Dec 2018 16:42:31 -0500
Subject: [PATCH 0223/2234] Braintree: Update gem to latest version
In support of adding Level 2 and 3 data fields. Also updates Travis to
exclude a now-incompatible job.
Closes #3091
Blue Remote:
66 tests, 378 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Orange Remote:
21 tests, 91 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Braintree Unit:
6 tests, 6 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Blue Unit:
57 tests, 150 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Orange Unit:
18 tests, 69 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
.travis.yml | 2 ++
CHANGELOG | 1 +
Gemfile | 2 +-
3 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index e2207604777..a43b6cfc204 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -24,6 +24,8 @@ matrix:
exclude:
- rvm: 2.3
gemfile: 'gemfiles/Gemfile.rails_master'
+ - rvm: 2.4
+ gemfile: 'gemfiles/Gemfile.rails_master'
notifications:
email:
diff --git a/CHANGELOG b/CHANGELOG
index 5f7dae312a0..9841ca89eb7 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,7 @@
== HEAD
* Mercado Pago: Support "gateway" processing mode [curiousepic] #3087
+* Braintree: Update gem to latest version [curiousepic] #3091
== Version 1.89.0 (December 17, 2018)
* Worldpay: handle Visa and MasterCard payouts differently [bpollack] #3068
diff --git a/Gemfile b/Gemfile
index 8ce730332ad..3c766be75de 100644
--- a/Gemfile
+++ b/Gemfile
@@ -6,5 +6,5 @@ gem 'rubocop', '~> 0.60.0', require: false
group :test, :remote_test do
# gateway-specific dependencies, keeping these gems out of the gemspec
- gem 'braintree', '>= 2.78.0'
+ gem 'braintree', '>= 2.93.0'
end
From 82a708d1da31eafd7922353833fb8098714555c5 Mon Sep 17 00:00:00 2001
From: Lancelot Carlson
Date: Wed, 2 Jan 2019 15:15:55 -0500
Subject: [PATCH 0224/2234] switch order_id to invoice
---
lib/active_merchant/billing/gateways/usa_epay_transaction.rb | 2 +-
test/unit/gateways/usa_epay_transaction_test.rb | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb
index fb0b277a164..63b140ce237 100644
--- a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb
+++ b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb
@@ -197,7 +197,7 @@ def address_key(prefix, key)
end
def add_invoice(post, options)
- post[:invoice] = options[:order_id]
+ post[:invoice] = options[:invoice]
post[:description] = options[:description]
end
diff --git a/test/unit/gateways/usa_epay_transaction_test.rb b/test/unit/gateways/usa_epay_transaction_test.rb
index 260195409da..76290376212 100644
--- a/test/unit/gateways/usa_epay_transaction_test.rb
+++ b/test/unit/gateways/usa_epay_transaction_test.rb
@@ -78,7 +78,7 @@ def test_unsuccessful_request
def test_successful_purchase_passing_extra_info
response = stub_comms do
- @gateway.purchase(@amount, @credit_card, @options.merge(:order_id => '1337', :description => 'socool'))
+ @gateway.purchase(@amount, @credit_card, @options.merge(:invoice => '1337', :description => 'socool'))
end.check_request do |endpoint, data, headers|
assert_match(/UMinvoice=1337/, data)
assert_match(/UMdescription=socool/, data)
@@ -217,7 +217,7 @@ def test_successful_authorize_request
def test_successful_authorize_passing_extra_info
response = stub_comms do
- @gateway.authorize(@amount, @credit_card, @options.merge(:order_id => '1337', :description => 'socool'))
+ @gateway.authorize(@amount, @credit_card, @options.merge(:invoice => '1337', :description => 'socool'))
end.check_request do |endpoint, data, headers|
assert_match(/UMinvoice=1337/, data)
assert_match(/UMdescription=socool/, data)
From 207c3df74489dfdc43f52411886233e968e5f8fe Mon Sep 17 00:00:00 2001
From: David Perry
Date: Fri, 28 Dec 2018 15:42:25 -0500
Subject: [PATCH 0225/2234] Adyen: Pass arbitrary riskData fields
Closes #3089
Remote:
38 tests, 99 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
26 tests, 127 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/adyen.rb | 8 ++++++++
test/remote/gateways/remote_adyen_test.rb | 15 +++++++++++++++
test/unit/gateways/adyen_test.rb | 8 ++++++++
4 files changed, 32 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index 9841ca89eb7..b2e1b17aab3 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -3,6 +3,7 @@
== HEAD
* Mercado Pago: Support "gateway" processing mode [curiousepic] #3087
* Braintree: Update gem to latest version [curiousepic] #3091
+* Adyen: Pass arbitrary riskData fields [curiousepic] #3089
== Version 1.89.0 (December 17, 2018)
* Worldpay: handle Visa and MasterCard payouts differently [bpollack] #3068
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index 4bf167bd081..fbda0615857 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -159,6 +159,14 @@ def add_extra_data(post, payment, options)
post[:additionalData][:overwriteBrand] = normalize(options[:overwrite_brand]) if options[:overwrite_brand]
post[:additionalData][:customRoutingFlag] = options[:custom_routing_flag] if options[:custom_routing_flag]
post[:additionalData]['paymentdatasource.type'] = NETWORK_TOKENIZATION_CARD_SOURCE[payment.source.to_s] if payment.is_a?(NetworkTokenizationCreditCard)
+ add_risk_data(post, options)
+ end
+
+ def add_risk_data(post, options)
+ risk_data = {}
+ risk_data.merge!(options[:risk_data]) if options[:risk_data]
+
+ post[:additionalData][:riskData] = risk_data unless risk_data.empty?
end
def add_shopper_interaction(post, payment, options={})
diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb
index cec2de5001c..53ca7b7bfa8 100644
--- a/test/remote/gateways/remote_adyen_test.rb
+++ b/test/remote/gateways/remote_adyen_test.rb
@@ -99,6 +99,21 @@ def test_successful_purchase_with_more_options
assert_equal '[capture-received]', response.message
end
+ def test_successful_purchase_with_risk_data
+ options = @options.merge(
+ risk_data:
+ {
+ 'operatingSystem' => 'HAL9000',
+ 'destinationLatitude' => '77.641423',
+ 'destinationLongitude' => '12.9503376'
+ }
+ )
+
+ response = @gateway.purchase(@amount, @credit_card, options)
+ assert_success response
+ assert_equal '[capture-received]', response.message
+ end
+
def test_successful_purchase_with_apple_pay
response = @gateway.purchase(@amount, @apple_pay_card, @options)
assert_success response
diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb
index 08642c39387..8cd354efffc 100644
--- a/test/unit/gateways/adyen_test.rb
+++ b/test/unit/gateways/adyen_test.rb
@@ -147,6 +147,14 @@ def test_custom_routing_sent
end.respond_with(successful_authorize_response)
end
+ def test_risk_data_sent
+ stub_comms do
+ @gateway.authorize(@amount, @credit_card, @options.merge({risk_data: {'operatingSystem' => 'HAL9000'}}))
+ end.check_request do |endpoint, data, headers|
+ assert_equal 'HAL9000', JSON.parse(data)['additionalData']['riskData']['operatingSystem']
+ end.respond_with(successful_authorize_response)
+ end
+
def test_failed_purchase
@gateway.expects(:ssl_post).returns(failed_purchase_response)
From d40f62b8b3e95690187978d20d795ce9adc7df8a Mon Sep 17 00:00:00 2001
From: Lancelot Carlson
Date: Wed, 2 Jan 2019 15:28:14 -0500
Subject: [PATCH 0226/2234] Add support for order_id
---
lib/active_merchant/billing/gateways/usa_epay_transaction.rb | 1 +
test/unit/gateways/usa_epay_transaction_test.rb | 5 +++--
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb
index 63b140ce237..9a0478d5b63 100644
--- a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb
+++ b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb
@@ -198,6 +198,7 @@ def address_key(prefix, key)
def add_invoice(post, options)
post[:invoice] = options[:invoice]
+ post[:orderid] = options[:order_id]
post[:description] = options[:description]
end
diff --git a/test/unit/gateways/usa_epay_transaction_test.rb b/test/unit/gateways/usa_epay_transaction_test.rb
index 76290376212..71baca5fe73 100644
--- a/test/unit/gateways/usa_epay_transaction_test.rb
+++ b/test/unit/gateways/usa_epay_transaction_test.rb
@@ -217,9 +217,10 @@ def test_successful_authorize_request
def test_successful_authorize_passing_extra_info
response = stub_comms do
- @gateway.authorize(@amount, @credit_card, @options.merge(:invoice => '1337', :description => 'socool'))
+ @gateway.authorize(@amount, @credit_card, @options.merge(:invoice => '1337', order_id: 'w00t', :description => 'socool'))
end.check_request do |endpoint, data, headers|
assert_match(/UMinvoice=1337/, data)
+ assert_match(/UMorderid=w00t/, data)
assert_match(/UMdescription=socool/, data)
assert_match(/UMtestmode=0/, data)
end.respond_with(successful_authorize_response)
@@ -531,7 +532,7 @@ def split_names(full_name)
end
def purchase_request
- "UMamount=1.00&UMinvoice=&UMdescription=&UMcard=4242424242424242&UMcvv2=123&UMexpir=09#{@credit_card.year.to_s[-2..-1]}&UMname=Longbob+Longsen&UMbillfname=Jim&UMbilllname=Smith&UMbillcompany=Widgets+Inc&UMbillstreet=456+My+Street&UMbillstreet2=Apt+1&UMbillcity=Ottawa&UMbillstate=ON&UMbillzip=K1C2N6&UMbillcountry=CA&UMbillphone=%28555%29555-5555&UMshipfname=Jim&UMshiplname=Smith&UMshipcompany=Widgets+Inc&UMshipstreet=456+My+Street&UMshipstreet2=Apt+1&UMshipcity=Ottawa&UMshipstate=ON&UMshipzip=K1C2N6&UMshipcountry=CA&UMshipphone=%28555%29555-5555&UMstreet=456+My+Street&UMzip=K1C2N6&UMcommand=cc%3Asale&UMkey=LOGIN&UMsoftware=Active+Merchant&UMtestmode=0"
+ "UMamount=1.00&UMinvoice=&UMorderid=&UMdescription=&UMcard=4242424242424242&UMcvv2=123&UMexpir=09#{@credit_card.year.to_s[-2..-1]}&UMname=Longbob+Longsen&UMbillfname=Jim&UMbilllname=Smith&UMbillcompany=Widgets+Inc&UMbillstreet=456+My+Street&UMbillstreet2=Apt+1&UMbillcity=Ottawa&UMbillstate=ON&UMbillzip=K1C2N6&UMbillcountry=CA&UMbillphone=%28555%29555-5555&UMshipfname=Jim&UMshiplname=Smith&UMshipcompany=Widgets+Inc&UMshipstreet=456+My+Street&UMshipstreet2=Apt+1&UMshipcity=Ottawa&UMshipstate=ON&UMshipzip=K1C2N6&UMshipcountry=CA&UMshipphone=%28555%29555-5555&UMstreet=456+My+Street&UMzip=K1C2N6&UMcommand=cc%3Asale&UMkey=LOGIN&UMsoftware=Active+Merchant&UMtestmode=0"
end
def successful_purchase_response
From bbe6ca8d380bf55e16f29b54b75125581c9cc0c5 Mon Sep 17 00:00:00 2001
From: Lance Carlson
Date: Wed, 2 Jan 2019 19:17:52 -0500
Subject: [PATCH 0227/2234] conflicts merged
---
.../billing/gateways/usa_epay_transaction.rb | 6 +++++-
test/unit/gateways/usa_epay_transaction_test.rb | 4 ++--
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb
index fb0b277a164..9bffcdb3d05 100644
--- a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb
+++ b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb
@@ -204,7 +204,11 @@ def add_invoice(post, options)
def add_payment(post, payment, options={})
if payment.respond_to?(:routing_number)
post[:checkformat] = options[:check_format] if options[:check_format]
- post[:accounttype] = options[:account_type] if options[:account_type]
+ if payment.account_type
+ account_type = payment.account_type.to_s.capitalize
+ raise ArgumentError, 'account_type must be checking or savings' unless %w(Checking Savings).include?(account_type)
+ post[:accounttype] = account_type
+ end
post[:account] = payment.account_number
post[:routing] = payment.routing_number
post[:name] = payment.name unless payment.name.blank?
diff --git a/test/unit/gateways/usa_epay_transaction_test.rb b/test/unit/gateways/usa_epay_transaction_test.rb
index 260195409da..141548d34f9 100644
--- a/test/unit/gateways/usa_epay_transaction_test.rb
+++ b/test/unit/gateways/usa_epay_transaction_test.rb
@@ -55,10 +55,10 @@ def test_successful_request_with_echeck
def test_successful_purchase_with_echeck_and_extra_options
response = stub_comms do
- @gateway.purchase(@amount, @check, @options.merge(check_format: 'ARC', account_type: 'savings'))
+ @gateway.purchase(@amount, check(account_type: 'savings'), @options.merge(check_format: 'ARC'))
end.check_request do |endpoint, data, headers|
assert_match(/UMcheckformat=ARC/, data)
- assert_match(/UMaccounttype=savings/, data)
+ assert_match(/UMaccounttype=Savings/, data)
end.respond_with(successful_purchase_response_echeck)
assert_equal 'Success', response.message
From 52d3b0f2243e44649e35a62dd43cd414f1dc30dd Mon Sep 17 00:00:00 2001
From: David Perry
Date: Thu, 3 Jan 2019 10:59:20 -0500
Subject: [PATCH 0228/2234] Worldpay: Fix cookie header name
Closes #3099
Remote:
28 tests, 111 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
41 tests, 231 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/worldpay.rb | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index b2e1b17aab3..066e6c533f2 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -4,6 +4,7 @@
* Mercado Pago: Support "gateway" processing mode [curiousepic] #3087
* Braintree: Update gem to latest version [curiousepic] #3091
* Adyen: Pass arbitrary riskData fields [curiousepic] #3089
+* Worldpay: Fix cookie header name [curiousepic] #3099
== Version 1.89.0 (December 17, 2018)
* Worldpay: handle Visa and MasterCard payouts differently [bpollack] #3068
diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb
index aca906ae7f4..3531b940a42 100644
--- a/lib/active_merchant/billing/gateways/worldpay.rb
+++ b/lib/active_merchant/billing/gateways/worldpay.rb
@@ -350,7 +350,7 @@ def headers(options)
'Authorization' => encoded_credentials
}
if options[:cookie]
- headers['Set-Cookie'] = options[:cookie] if options[:cookie]
+ headers['Cookie'] = options[:cookie] if options[:cookie]
end
headers
end
From 6bf19afabc5b21ecab3a6debdf5b028d7e3de2b1 Mon Sep 17 00:00:00 2001
From: molbrown
Date: Mon, 31 Dec 2018 12:41:35 -0500
Subject: [PATCH 0229/2234] Paymentez: Adds support for extra_params optional
field Merchant may define custom optional fields in their Paymentez account,
to send with debit requests under extra_params object.
ENE-80
Unit:
19 tests, 77 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
Remote:
20 tests, 47 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
Failures unrelated to this change, have to do with country-specific allowances for
partial capture/ refund.
Closes #3095
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/paymentez.rb | 14 ++++++++++++++
test/remote/gateways/remote_paymentez_test.rb | 12 ++++++++++++
3 files changed, 27 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index 066e6c533f2..bab1514924c 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -5,6 +5,7 @@
* Braintree: Update gem to latest version [curiousepic] #3091
* Adyen: Pass arbitrary riskData fields [curiousepic] #3089
* Worldpay: Fix cookie header name [curiousepic] #3099
+* Paymentez: Adds support for extra_params optional field [molbrown] #3095
== Version 1.89.0 (December 17, 2018)
* Worldpay: handle Visa and MasterCard payouts differently [bpollack] #3068
diff --git a/lib/active_merchant/billing/gateways/paymentez.rb b/lib/active_merchant/billing/gateways/paymentez.rb
index cbdaa48d867..1f2409e72bd 100644
--- a/lib/active_merchant/billing/gateways/paymentez.rb
+++ b/lib/active_merchant/billing/gateways/paymentez.rb
@@ -52,6 +52,7 @@ def purchase(money, payment, options = {})
add_invoice(post, money, options)
add_payment(post, payment)
add_customer_data(post, options)
+ add_extra_params(post, options)
action = payment.is_a?(String) ? 'debit' : 'debit_cc'
commit_transaction(action, post)
@@ -63,6 +64,7 @@ def authorize(money, payment, options = {})
add_invoice(post, money, options)
add_payment(post, payment)
add_customer_data(post, options)
+ add_extra_params(post, options)
commit_transaction('authorize', post)
end
@@ -168,6 +170,18 @@ def add_payment(post, payment)
end
end
+ def add_extra_params(post, options)
+ if options[:extra_params]
+ items = {}
+ options[:extra_params].each do |param|
+ param.each do |key, value|
+ items[key.to_sym] = value
+ end
+ end
+ post[:extra_params] = items
+ end
+ end
+
def parse(body)
JSON.parse(body)
end
diff --git a/test/remote/gateways/remote_paymentez_test.rb b/test/remote/gateways/remote_paymentez_test.rb
index a09a19f1581..f5041384031 100644
--- a/test/remote/gateways/remote_paymentez_test.rb
+++ b/test/remote/gateways/remote_paymentez_test.rb
@@ -59,6 +59,18 @@ def test_successful_purchase_without_phone_option
assert_success response
end
+ def test_successful_purchase_with_extra_params
+ options = {
+ extra_params: {
+ configuration1: 'value1',
+ configuration2: 'value2',
+ configuration3: 'value3'
+ }}
+
+ response = @gateway.purchase(@amount, @credit_card, @options.merge(options))
+ assert_success response
+ end
+
def test_successful_purchase_with_token
store_response = @gateway.store(@credit_card, @options)
assert_success store_response
From 86ea132b6b58d5d75d1a3074cc409222522dbe90 Mon Sep 17 00:00:00 2001
From: David Perry
Date: Mon, 31 Dec 2018 16:33:44 -0500
Subject: [PATCH 0230/2234] Braintree Blue: Support Level 2 and 3 data fields
Also refactors create_transaction_parameters for length.
Closes #3094
Remote:
68 tests, 384 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
57 tests, 150 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/braintree_blue.rb | 72 +++++++++++++------
.../gateways/remote_braintree_blue_test.rb | 45 ++++++++++++
3 files changed, 95 insertions(+), 23 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index bab1514924c..e19bf753dcc 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -6,6 +6,7 @@
* Adyen: Pass arbitrary riskData fields [curiousepic] #3089
* Worldpay: Fix cookie header name [curiousepic] #3099
* Paymentez: Adds support for extra_params optional field [molbrown] #3095
+* Braintree Blue: Support Level 2 and 3 data fields [curiousepic] #3094
== Version 1.89.0 (December 17, 2018)
* Worldpay: handle Visa and MasterCard payouts differently [bpollack] #3068
diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb
index a3ffb37a325..2aaa4da2786 100644
--- a/lib/active_merchant/billing/gateways/braintree_blue.rb
+++ b/lib/active_merchant/billing/gateways/braintree_blue.rb
@@ -445,6 +445,7 @@ def response_code_from_result(result)
def create_transaction(transaction_type, money, credit_card_or_vault_id, options)
transaction_params = create_transaction_parameters(money, credit_card_or_vault_id, options)
+
commit do
result = @braintree_gateway.transaction.send(transaction_type, transaction_params)
response = Response.new(result.success?, message_from_transaction_result(result), response_params(result), response_options(result))
@@ -588,6 +589,54 @@ def create_transaction_parameters(money, credit_card_or_vault_id, options)
parameters[:recurring] = true
end
+ add_payment_method(parameters, credit_card_or_vault_id, options)
+
+ parameters[:billing] = map_address(options[:billing_address]) if options[:billing_address]
+ parameters[:shipping] = map_address(options[:shipping_address]) if options[:shipping_address]
+
+ channel = @options[:channel] || application_id
+ parameters[:channel] = channel if channel
+
+ if options[:descriptor_name] || options[:descriptor_phone] || options[:descriptor_url]
+ parameters[:descriptor] = {
+ name: options[:descriptor_name],
+ phone: options[:descriptor_phone],
+ url: options[:descriptor_url]
+ }
+ end
+
+ if options[:three_d_secure]
+ parameters[:three_d_secure_pass_thru] = {
+ cavv: options[:three_d_secure][:cavv],
+ eci_flag: options[:three_d_secure][:eci],
+ xid: options[:three_d_secure][:xid],
+ }
+ end
+
+ parameters[:tax_amount] = options[:tax_amount] if options[:tax_amount]
+ parameters[:tax_exempt] = options[:tax_exempt] if options[:tax_exempt]
+ parameters[:purchase_order_number] = options[:purchase_order_number] if options[:purchase_order_number]
+
+ parameters[:shipping_amount] = options[:shipping_amount] if options[:shipping_amount]
+ parameters[:discount_amount] = options[:discount_amount] if options[:discount_amount]
+ parameters[:ships_from_postal_code] = options[:ships_from_postal_code] if options[:ships_from_postal_code]
+
+ if options[:line_items]
+ items = []
+ options[:line_items].each do |line_item|
+ item = {}
+ line_item.each do |key, value|
+ item[key.to_sym] = value
+ end
+ items << item
+ end
+ parameters[:line_items] = items
+ end
+
+ parameters
+ end
+
+ def add_payment_method(parameters, credit_card_or_vault_id, options)
if credit_card_or_vault_id.is_a?(String) || credit_card_or_vault_id.is_a?(Integer)
if options[:payment_method_token]
parameters[:payment_method_token] = credit_card_or_vault_id
@@ -634,29 +683,6 @@ def create_transaction_parameters(money, credit_card_or_vault_id, options)
}
end
end
- parameters[:billing] = map_address(options[:billing_address]) if options[:billing_address]
- parameters[:shipping] = map_address(options[:shipping_address]) if options[:shipping_address]
-
- channel = @options[:channel] || application_id
- parameters[:channel] = channel if channel
-
- if options[:descriptor_name] || options[:descriptor_phone] || options[:descriptor_url]
- parameters[:descriptor] = {
- name: options[:descriptor_name],
- phone: options[:descriptor_phone],
- url: options[:descriptor_url]
- }
- end
-
- if options[:three_d_secure]
- parameters[:three_d_secure_pass_thru] = {
- cavv: options[:three_d_secure][:cavv],
- eci_flag: options[:three_d_secure][:eci],
- xid: options[:three_d_secure][:xid],
- }
- end
-
- parameters
end
end
end
diff --git a/test/remote/gateways/remote_braintree_blue_test.rb b/test/remote/gateways/remote_braintree_blue_test.rb
index c6cd935e7db..2f116892bc1 100644
--- a/test/remote/gateways/remote_braintree_blue_test.rb
+++ b/test/remote/gateways/remote_braintree_blue_test.rb
@@ -122,6 +122,51 @@ def test_successful_purchase_using_card_token
assert_equal 'submitted_for_settlement', response.params['braintree_transaction']['status']
end
+ def test_successful_purchase_with_level_2_data
+ assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:tax_amount => '20', :purchase_order_number => '6789'))
+ assert_success response
+ assert_equal '1000 Approved', response.message
+ end
+
+ def test_successful_purchase_with_level_2_and_3_data
+ options = {
+ :tax_amount => '20',
+ :purchase_order_number => '6789',
+ :shipping_amount => '300',
+ :discount_amount => '150',
+ :ships_from_postal_code => '90210',
+ :line_items => [
+ {
+ :name => 'Product Name',
+ :kind => 'debit',
+ :quantity => '10.0000',
+ :unit_amount => '9.5000',
+ :unit_of_measure => 'unit',
+ :total_amount => '95.00',
+ :tax_amount => '5.00',
+ :discount_amount => '0.00',
+ :product_code => '54321',
+ :commodity_code => '98765'
+ },
+ {
+ :name => 'Other Product Name',
+ :kind => 'debit',
+ :quantity => '1.0000',
+ :unit_amount => '2.5000',
+ :unit_of_measure => 'unit',
+ :total_amount => '90.00',
+ :tax_amount => '2.00',
+ :discount_amount => '1.00',
+ :product_code => '54322',
+ :commodity_code => '98766'
+ }
+ ]
+ }
+ assert response = @gateway.purchase(@amount, @credit_card, @options.merge(options))
+ assert_success response
+ assert_equal '1000 Approved', response.message
+ end
+
def test_successful_verify
assert response = @gateway.verify(@credit_card, @options)
assert_success response
From 79390386693a8733c1add19bdd8a14c3a0e1be2d Mon Sep 17 00:00:00 2001
From: David Perry
Date: Thu, 3 Jan 2019 16:29:43 -0500
Subject: [PATCH 0231/2234] Braintree Blue: Refactor line_items field
Removed hilariously redundant code.
Closes #3100
Unit:
57 tests, 150 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
68 tests, 384 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/braintree_blue.rb | 12 +-----------
2 files changed, 2 insertions(+), 11 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index e19bf753dcc..f17e40486a5 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -7,6 +7,7 @@
* Worldpay: Fix cookie header name [curiousepic] #3099
* Paymentez: Adds support for extra_params optional field [molbrown] #3095
* Braintree Blue: Support Level 2 and 3 data fields [curiousepic] #3094
+* Braintree Blue: Refactor line_items field [curiousepic] #3100
== Version 1.89.0 (December 17, 2018)
* Worldpay: handle Visa and MasterCard payouts differently [bpollack] #3068
diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb
index 2aaa4da2786..3427bdd016b 100644
--- a/lib/active_merchant/billing/gateways/braintree_blue.rb
+++ b/lib/active_merchant/billing/gateways/braintree_blue.rb
@@ -621,17 +621,7 @@ def create_transaction_parameters(money, credit_card_or_vault_id, options)
parameters[:discount_amount] = options[:discount_amount] if options[:discount_amount]
parameters[:ships_from_postal_code] = options[:ships_from_postal_code] if options[:ships_from_postal_code]
- if options[:line_items]
- items = []
- options[:line_items].each do |line_item|
- item = {}
- line_item.each do |key, value|
- item[key.to_sym] = value
- end
- items << item
- end
- parameters[:line_items] = items
- end
+ parameters[:line_items] = options[:line_items] if options[:line_items]
parameters
end
From f8403b3e10183bb2480aa1d5de0993033fa557a5 Mon Sep 17 00:00:00 2001
From: Niaja
Date: Wed, 2 Jan 2019 12:24:30 -0500
Subject: [PATCH 0232/2234] TrustCommerce: Use `application_id`
Allows for `application_id` to be used as `aggregatorID`. 3 failing
remotes test unrelated to this change.
- test_store_failure
- test_unstore_failure
- test_recurring_failure
Loaded suite test/unit/gateways/trust_commerce_test
Started
..........
10 tests, 34 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Loaded suite test/remote/gateways/remote_trust_commerce_test
Finished in 32.663168 seconds.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
16 tests, 59 assertions, 3 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
81.25% passed
---
lib/active_merchant/billing/gateways/trust_commerce.rb | 4 ++--
test/unit/gateways/trust_commerce_test.rb | 1 +
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/trust_commerce.rb b/lib/active_merchant/billing/gateways/trust_commerce.rb
index 40466fcc006..420178bca8a 100644
--- a/lib/active_merchant/billing/gateways/trust_commerce.rb
+++ b/lib/active_merchant/billing/gateways/trust_commerce.rb
@@ -312,9 +312,9 @@ def scrub(transcript)
private
def add_aggregator(params, options)
- if @options[:aggregator_id]
+ if @options[:aggregator_id] || application_id != Gateway.application_id
params[:aggregators] = 1
- params[:aggregator1] = @options[:aggregator_id]
+ params[:aggregator1] = @options[:aggregator_id] || application_id
end
end
diff --git a/test/unit/gateways/trust_commerce_test.rb b/test/unit/gateways/trust_commerce_test.rb
index e94146db360..467721f6f9f 100644
--- a/test/unit/gateways/trust_commerce_test.rb
+++ b/test/unit/gateways/trust_commerce_test.rb
@@ -32,6 +32,7 @@ def test_unsuccessful_purchase
end
def test_succesful_purchase_with_check
+ ActiveMerchant::Billing::TrustCommerceGateway.application_id = 'abc123'
stub_comms do
@gateway.purchase(@amount, @check)
end.check_request do |endpoint, data, headers|
From ffec67aa684b2f3505313b63375927db258dc78a Mon Sep 17 00:00:00 2001
From: Niaja
Date: Fri, 4 Jan 2019 12:54:34 -0500
Subject: [PATCH 0233/2234] Update Changelog for #3103
---
CHANGELOG | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG b/CHANGELOG
index f17e40486a5..c070770b64f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -8,6 +8,7 @@
* Paymentez: Adds support for extra_params optional field [molbrown] #3095
* Braintree Blue: Support Level 2 and 3 data fields [curiousepic] #3094
* Braintree Blue: Refactor line_items field [curiousepic] #3100
+* TrustCommerce: Use `application_id` [nfarve] #3103
== Version 1.89.0 (December 17, 2018)
* Worldpay: handle Visa and MasterCard payouts differently [bpollack] #3068
From dbdbdfaa504522cfaa573f8b9bb9f4d92a53b1b4 Mon Sep 17 00:00:00 2001
From: Niaja
Date: Tue, 18 Dec 2018 15:55:33 -0500
Subject: [PATCH 0234/2234] Stripe: Add 3DS Support
Adds 3DS to the Stripe gateway. This includes adding sources, webhooks
and callback verification. Remote tests for 3DS are in their own
file.
Loaded suite test/unit/gateways/stripe_test
.....................................................................................................................................
133 tests, 713 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Loaded suite test/remote/gateways/remote_stripe_3ds_test
.....
5 tests, 21 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Loaded suite test/remote/gateways/remote_stripe_test
...................................................................
67 tests, 313 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/stripe.rb | 27 ++-
.../remote/gateways/remote_stripe_3ds_test.rb | 62 +++++
test/unit/gateways/stripe_test.rb | 229 ++++++++++++++++++
4 files changed, 318 insertions(+), 1 deletion(-)
create mode 100644 test/remote/gateways/remote_stripe_3ds_test.rb
diff --git a/CHANGELOG b/CHANGELOG
index c070770b64f..0aa05558f55 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -9,6 +9,7 @@
* Braintree Blue: Support Level 2 and 3 data fields [curiousepic] #3094
* Braintree Blue: Refactor line_items field [curiousepic] #3100
* TrustCommerce: Use `application_id` [nfarve] #3103
+* Stripe: Add 3DS Support [nfarve] #3086
== Version 1.89.0 (December 17, 2018)
* Worldpay: handle Visa and MasterCard payouts differently [bpollack] #3068
diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb
index 4e107af5eaf..4d152fe1939 100644
--- a/lib/active_merchant/billing/gateways/stripe.rb
+++ b/lib/active_merchant/billing/gateways/stripe.rb
@@ -299,6 +299,31 @@ def type
end
end
+ def create_source(money, payment, type, options = {})
+ post = {}
+ add_amount(post, money, options, true)
+ post[:type] = type
+ if type == 'card'
+ add_creditcard(post, payment, options)
+ post[:card].delete(:name)
+ elsif type == 'three_d_secure'
+ post[:three_d_secure] = {card: payment}
+ post[:redirect] = {return_url: options[:redirect_url]}
+ end
+ commit(:post, 'sources', post, options)
+ end
+
+ def create_webhook_endpoint(options, events)
+ post = {}
+ post[:url] = options[:callback_url]
+ post[:enabled_events] = events
+ commit(:post, 'webhook_endpoints', post, options)
+ end
+
+ def delete_webhook_endpoint(options)
+ commit(:delete, "webhook_endpoints/#{options[:webhook_id]}", {}, options)
+ end
+
def create_post_for_auth_or_purchase(money, payment, options)
post = {}
@@ -581,7 +606,7 @@ def api_request(method, endpoint, parameters = nil, options = {})
def commit(method, url, parameters = nil, options = {})
add_expand_parameters(parameters, options) if parameters
response = api_request(method, url, parameters, options)
-
+ response['webhook_id'] = options[:webhook_id] if options[:webhook_id]
success = success_from(response)
card = card_from_response(response)
diff --git a/test/remote/gateways/remote_stripe_3ds_test.rb b/test/remote/gateways/remote_stripe_3ds_test.rb
new file mode 100644
index 00000000000..ec9650a544e
--- /dev/null
+++ b/test/remote/gateways/remote_stripe_3ds_test.rb
@@ -0,0 +1,62 @@
+require 'test_helper'
+
+class RemoteStripe3DSTest < Test::Unit::TestCase
+ CHARGE_ID_REGEX = /ch_[a-zA-Z\d]{24}/
+
+ def setup
+ @gateway = StripeGateway.new(fixtures(:stripe))
+ @amount = 100
+
+ @options = {
+ :currency => 'USD',
+ :description => 'ActiveMerchant Test Purchase',
+ :email => 'wow@example.com',
+ :execute_threed => true,
+ :redirect_url => 'http://www.example.com/redirect',
+ :callback_url => 'http://www.example.com/callback'
+ }
+ @credit_card = credit_card('4000000000003063')
+ @non_3ds_card = credit_card('378282246310005')
+ end
+
+ def test_create_3ds_card_source
+ assert response = @gateway.send(:create_source, @amount, @credit_card, 'card', @options)
+ assert_success response
+ assert_equal 'source', response.params['object']
+ assert_equal 'chargeable', response.params['status']
+ assert_equal 'required', response.params['card']['three_d_secure']
+ assert_equal 'card', response.params['type']
+ end
+
+ def test_create_non3ds_card_source
+ assert response = @gateway.send(:create_source, @amount, @non_3ds_card, 'card', @options)
+ assert_success response
+ assert_equal 'source', response.params['object']
+ assert_equal 'chargeable', response.params['status']
+ assert_equal 'not_supported', response.params['card']['three_d_secure']
+ assert_equal 'card', response.params['type']
+ end
+
+ def test_create_3ds_source
+ card_source = @gateway.send(:create_source, @amount, @credit_card, 'card', @options)
+ assert response = @gateway.send(:create_source, @amount, card_source.params['id'], 'three_d_secure', @options)
+ assert_success response
+ assert_equal 'source', response.params['object']
+ assert_equal 'pending', response.params['status']
+ assert_equal 'three_d_secure', response.params['type']
+ assert_equal false, response.params['three_d_secure']['authenticated']
+ end
+
+ def test_create_webhook_endpoint
+ response = @gateway.send(:create_webhook_endpoint, @options, ['source.chargeable'])
+ assert_includes response.params['enabled_events'], 'source.chargeable'
+ assert_equal @options[:callback_url], response.params['url']
+ end
+
+ def test_delete_webhook_endpoint
+ webhook = @gateway.send(:create_webhook_endpoint, @options, ['source.chargeable'])
+ response = @gateway.send(:delete_webhook_endpoint, @options.merge(:webhook_id => webhook.params['id']))
+ assert_equal response.params['id'], webhook.params['id']
+ assert_equal true, response.params['deleted']
+ end
+end
diff --git a/test/unit/gateways/stripe_test.rb b/test/unit/gateways/stripe_test.rb
index aa68953ee16..76e7231c712 100644
--- a/test/unit/gateways/stripe_test.rb
+++ b/test/unit/gateways/stripe_test.rb
@@ -7,6 +7,8 @@ def setup
@gateway = StripeGateway.new(:login => 'login')
@credit_card = credit_card()
+ @threeds_card = credit_card('4000000000003063')
+ @non_3ds_card = credit_card('378282246310005')
@amount = 400
@refund_amount = 200
@@ -16,6 +18,11 @@ def setup
:description => 'Test Purchase'
}
+ @threeds_options = {
+ :execute_threed => true,
+ :callback_url => 'http://www.example.com/callback'
+ }
+
@apple_pay_payment_token = apple_pay_payment_token
@emv_credit_card = credit_card_with_icc_data
@payment_token = StripeGateway::StripePaymentToken.new(token_params)
@@ -1414,6 +1421,41 @@ def test_passing_stripe_account_header
@gateway.purchase(@amount, @credit_card, @options)
end
+ def test_3ds_source_creation
+ @gateway.expects(:ssl_request).twice.returns(threeds_first_sources_created_response, threeds_second_sources_created_response)
+ card_source = @gateway.send(:create_source, @amount, @threeds_card, 'card', @options.merge(@threeds_options))
+ assert_success card_source
+ response = @gateway.send(:create_source, @amount, card_source.params['id'], 'three_d_secure', @options)
+ assert_equal 'source', response.params['object']
+ assert_equal 'pending', response.params['status']
+ assert_equal 'three_d_secure', response.params['type']
+ assert_equal false, response.params['three_d_secure']['authenticated']
+ end
+
+ def test_non3ds_card_source_creation
+ @gateway.expects(:ssl_request).returns(non_3ds_sources_create_response)
+ response = @gateway.send(:create_source, @amount, @non_3ds_card, 'card', @options.merge(@threeds_options))
+ assert_equal 'source', response.params['object']
+ assert_equal 'chargeable', response.params['status']
+ assert_equal 'card', response.params['type']
+ assert_equal 'not_supported', response.params['card']['three_d_secure']
+ end
+
+ def test_webhook_creation
+ @gateway.expects(:ssl_request).returns(webhook_event_creation_response)
+ response = @gateway.send(:create_webhook_endpoint, @options.merge(@threeds_options), ['source.chargeable'])
+ assert_includes response.params['enabled_events'], 'source.chargeable'
+ assert_equal @options.merge(@threeds_options)[:callback_url], response.params['url']
+ end
+
+ def test_webhook_deletion
+ @gateway.expects(:ssl_request).twice.returns(webhook_event_creation_response, webhook_event_deletion_response)
+ webhook = @gateway.send(:create_webhook_endpoint, @options.merge(@threeds_options), ['source.chargeable'])
+ response = @gateway.send(:delete_webhook_endpoint, @options.merge(:webhook_id => webhook.params['id']))
+ assert_equal response.params['id'], webhook.params['id']
+ assert_equal true, response.params['deleted']
+ end
+
def test_verify_good_credentials
@gateway.expects(:raw_ssl_request).returns(credentials_are_legit_response)
assert @gateway.verify_credentials
@@ -2415,4 +2457,191 @@ def token_params
'used' => false
}
end
+
+ def threeds_first_sources_created_response
+ <<-RESPONSE
+ {
+ "id": "src_1Dj5lqAWOtgoysogqA4CJX9Y",
+ "object": "source",
+ "amount": null,
+ "card": {
+ "exp_month": 9,
+ "exp_year": 2019,
+ "brand": "Visa",
+ "country": "US",
+ "cvc_check": "unchecked",
+ "fingerprint": "53W491Mwz0OMuEJr",
+ "funding": "credit",
+ "last4": "3063",
+ "three_d_secure": "required",
+ "name": null,
+ "address_line1_check": null,
+ "address_zip_check": null,
+ "tokenization_method": null,
+ "dynamic_last4": null
+ },
+ "client_secret": "src_client_secret_EBShsJorDXd6WD521kRIQlbP",
+ "created": 1545228694,
+ "currency": null,
+ "flow": "none",
+ "livemode": false,
+ "metadata": {
+ },
+ "owner": {
+ "address": null,
+ "email": null,
+ "name": null,
+ "phone": null,
+ "verified_address": null,
+ "verified_email": null,
+ "verified_name": null,
+ "verified_phone": null
+ },
+ "statement_descriptor": null,
+ "status": "chargeable",
+ "type": "card",
+ "usage": "reusable"
+ }
+ RESPONSE
+ end
+
+ def threeds_second_sources_created_response
+ <<-RESPONSE
+ {
+ "id": "src_1Dj5lrAWOtgoysog910mc8oS",
+ "object": "source",
+ "amount": 100,
+ "client_secret": "src_client_secret_EBShU4HfxQAw2bVGMxvRECO1",
+ "created": 1545228695,
+ "currency": "usd",
+ "flow": "redirect",
+ "livemode": false,
+ "metadata": {
+ },
+ "owner": {
+ "address": {
+ "city": null,
+ "country": null,
+ "line1": "",
+ "line2": null,
+ "postal_code": null,
+ "state": null
+ },
+ "email": null,
+ "name": null,
+ "phone": null,
+ "verified_address": null,
+ "verified_email": null,
+ "verified_name": null,
+ "verified_phone": null
+ },
+ "redirect": {
+ "failure_reason": null,
+ "return_url": "http://www.example.com/callback",
+ "status": "pending",
+ "url": "https://hooks.stripe.com/redirect/authenticate/src_1Dj5lrAWOtgoysog910mc8oS?client_secret=src_client_secret_EBShU4HfxQAw2bVGMxvRECO1"
+ },
+ "statement_descriptor": null,
+ "status": "pending",
+ "three_d_secure": {
+ "card": "src_1Dj5lqAWOtgoysogqA4CJX9Y",
+ "brand": "Visa",
+ "country": "US",
+ "cvc_check": "unchecked",
+ "exp_month": 9,
+ "exp_year": 2019,
+ "fingerprint": "53W491Mwz0OMuEJr",
+ "funding": "credit",
+ "last4": "3063",
+ "three_d_secure": "required",
+ "customer": null,
+ "authenticated": false,
+ "name": null,
+ "address_line1_check": null,
+ "address_zip_check": null,
+ "tokenization_method": null,
+ "dynamic_last4": null
+ },
+ "type": "three_d_secure",
+ "usage": "single_use"
+ }
+ RESPONSE
+ end
+
+ def non_3ds_sources_create_response
+ <<-RESPONSE
+ {
+ "id": "src_1Dj5yAAWOtgoysogPB6hwOa1",
+ "object": "source",
+ "amount": null,
+ "card": {
+ "exp_month": 9,
+ "exp_year": 2019,
+ "brand": "American Express",
+ "country": "US",
+ "cvc_check": "unchecked",
+ "fingerprint": "DjZpoV89lmOMsJLF",
+ "funding": "credit",
+ "last4": "0005",
+ "three_d_secure": "not_supported",
+ "name": null,
+ "address_line1_check": null,
+ "address_zip_check": null,
+ "tokenization_method": null,
+ "dynamic_last4": null
+ },
+ "client_secret": "src_client_secret_EBStgH6cBMsODApAChcj9Kkq",
+ "created": 1545229458,
+ "currency": null,
+ "flow": "none",
+ "livemode": false,
+ "metadata": {
+ },
+ "owner": {
+ "address": null,
+ "email": null,
+ "name": null,
+ "phone": null,
+ "verified_address": null,
+ "verified_email": null,
+ "verified_name": null,
+ "verified_phone": null
+ },
+ "statement_descriptor": null,
+ "status": "chargeable",
+ "type": "card",
+ "usage": "reusable"
+ }
+ RESPONSE
+ end
+
+ def webhook_event_creation_response
+ <<-RESPONSE
+ {
+ "id": "we_1Dj8GvAWOtgoysogAW1V5FFm",
+ "object": "webhook_endpoint",
+ "application": null,
+ "created": 1545238309,
+ "enabled_events": [
+ "source.chargeable",
+ "source.failed",
+ "source.canceled"
+ ],
+ "livemode": false,
+ "secret": "whsec_sJVAv7f1rddt1bNhouoDvxwQbZ8t0Pgn",
+ "status": "enabled",
+ "url": "http://www.example.com/callback"
+ }
+ RESPONSE
+ end
+
+ def webhook_event_deletion_response
+ <<-RESPONSE
+ {
+ "id": "we_1Dj8GvAWOtgoysogAW1V5FFm",
+ "object": "webhook_endpoint",
+ "deleted": true
+ }
+ RESPONSE
+ end
end
From c7668d721bd88185800928fdc67064b51b1ab084 Mon Sep 17 00:00:00 2001
From: Michael Elfassy
Date: Tue, 8 Jan 2019 15:57:37 -0500
Subject: [PATCH 0235/2234] Release v1.90.0
---
CHANGELOG | 2 ++
lib/active_merchant/version.rb | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 0aa05558f55..4637da2fdb3 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,8 @@
= ActiveMerchant CHANGELOG
== HEAD
+
+== Version 1.90.0 (January 8, 2019)
* Mercado Pago: Support "gateway" processing mode [curiousepic] #3087
* Braintree: Update gem to latest version [curiousepic] #3091
* Adyen: Pass arbitrary riskData fields [curiousepic] #3089
diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb
index c84c00b1c48..2bf8655247f 100644
--- a/lib/active_merchant/version.rb
+++ b/lib/active_merchant/version.rb
@@ -1,3 +1,3 @@
module ActiveMerchant
- VERSION = '1.89.0'
+ VERSION = '1.90.0'
end
From a85dc1243f4ccf592dfa8ba05f41e1d8a230ec18 Mon Sep 17 00:00:00 2001
From: Niaja
Date: Thu, 10 Jan 2019 11:45:09 -0500
Subject: [PATCH 0236/2234] WorldPay: Pull CVC and AVS Result from Response
Pull out the appropriate values from the response.
Loaded suite test/remote/gateways/remote_worldpay_test
.............................
29 tests, 116 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Loaded suite test/unit/gateways/worldpay_test
.........................................
41 tests, 231 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
lib/active_merchant/billing/gateways/worldpay.rb | 5 ++++-
test/remote/gateways/remote_worldpay_test.rb | 9 +++++++++
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb
index 3531b940a42..fedc9677f99 100644
--- a/lib/active_merchant/billing/gateways/worldpay.rb
+++ b/lib/active_merchant/billing/gateways/worldpay.rb
@@ -370,7 +370,10 @@ def commit(action, request, *success_criteria, options)
raw,
:authorization => authorization_from(raw),
:error_code => error_code_from(success, raw),
- :test => test?)
+ :test => test?,
+ :avs_result => AVSResult.new(code: AVS_CODE_MAP[raw[:avs_result_code_description]]),
+ :cvv_result => CVVResult.new(CVC_CODE_MAP[raw[:cvc_result_code_description]])
+ )
rescue ActiveMerchant::ResponseError => e
if e.response.code.to_s == '401'
return Response.new(false, 'Invalid credentials', {}, :test => test?)
diff --git a/test/remote/gateways/remote_worldpay_test.rb b/test/remote/gateways/remote_worldpay_test.rb
index c87d9539397..2009f01838a 100644
--- a/test/remote/gateways/remote_worldpay_test.rb
+++ b/test/remote/gateways/remote_worldpay_test.rb
@@ -23,6 +23,15 @@ def test_successful_purchase
assert_equal 'SUCCESS', response.message
end
+ def test_successful_authorize_avs_and_cvv
+ card = credit_card('4111111111111111', :verification_value => 555)
+ assert response = @gateway.authorize(@amount, card, @options.merge(billing_address: address.update(zip: 'CCCC')))
+ assert_success response
+ assert_equal 'SUCCESS', response.message
+ assert_match %r{Street address does not match, but 5-digit postal code matches}, response.avs_result['message']
+ assert_match %r{CVV matches}, response.cvv_result['message']
+ end
+
def test_successful_purchase_with_hcg_additional_data
@options[:hcg_additional_data] = {
key1: 'value1',
From 05313b675d268e003c225791a8445435cdb51795 Mon Sep 17 00:00:00 2001
From: Niaja
Date: Thu, 10 Jan 2019 13:45:33 -0500
Subject: [PATCH 0237/2234] Revert "WorldPay: Pull CVC and AVS Result from
Response"
This reverts commit a85dc1243f4ccf592dfa8ba05f41e1d8a230ec18.
---
lib/active_merchant/billing/gateways/worldpay.rb | 5 +----
test/remote/gateways/remote_worldpay_test.rb | 9 ---------
2 files changed, 1 insertion(+), 13 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb
index fedc9677f99..3531b940a42 100644
--- a/lib/active_merchant/billing/gateways/worldpay.rb
+++ b/lib/active_merchant/billing/gateways/worldpay.rb
@@ -370,10 +370,7 @@ def commit(action, request, *success_criteria, options)
raw,
:authorization => authorization_from(raw),
:error_code => error_code_from(success, raw),
- :test => test?,
- :avs_result => AVSResult.new(code: AVS_CODE_MAP[raw[:avs_result_code_description]]),
- :cvv_result => CVVResult.new(CVC_CODE_MAP[raw[:cvc_result_code_description]])
- )
+ :test => test?)
rescue ActiveMerchant::ResponseError => e
if e.response.code.to_s == '401'
return Response.new(false, 'Invalid credentials', {}, :test => test?)
diff --git a/test/remote/gateways/remote_worldpay_test.rb b/test/remote/gateways/remote_worldpay_test.rb
index 2009f01838a..c87d9539397 100644
--- a/test/remote/gateways/remote_worldpay_test.rb
+++ b/test/remote/gateways/remote_worldpay_test.rb
@@ -23,15 +23,6 @@ def test_successful_purchase
assert_equal 'SUCCESS', response.message
end
- def test_successful_authorize_avs_and_cvv
- card = credit_card('4111111111111111', :verification_value => 555)
- assert response = @gateway.authorize(@amount, card, @options.merge(billing_address: address.update(zip: 'CCCC')))
- assert_success response
- assert_equal 'SUCCESS', response.message
- assert_match %r{Street address does not match, but 5-digit postal code matches}, response.avs_result['message']
- assert_match %r{CVV matches}, response.cvv_result['message']
- end
-
def test_successful_purchase_with_hcg_additional_data
@options[:hcg_additional_data] = {
key1: 'value1',
From 18c284134b4288095ac4cd4b2e3464cecd2e089a Mon Sep 17 00:00:00 2001
From: Niaja
Date: Thu, 10 Jan 2019 11:45:09 -0500
Subject: [PATCH 0238/2234] WorldPay: Pull CVC and AVS Result from Response
Pull out the appropriate values from the response.
Loaded suite test/remote/gateways/remote_worldpay_test
.............................
29 tests, 116 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Loaded suite test/unit/gateways/worldpay_test
.........................................
41 tests, 231 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 2 ++
lib/active_merchant/billing/gateways/worldpay.rb | 5 ++++-
test/remote/gateways/remote_worldpay_test.rb | 9 +++++++++
3 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 4637da2fdb3..58ba4078b88 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -12,6 +12,8 @@
* Braintree Blue: Refactor line_items field [curiousepic] #3100
* TrustCommerce: Use `application_id` [nfarve] #3103
* Stripe: Add 3DS Support [nfarve] #3086
+* WorldPay: Pull CVC and AVS Result from Response [nfarve] #3106
+
== Version 1.89.0 (December 17, 2018)
* Worldpay: handle Visa and MasterCard payouts differently [bpollack] #3068
diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb
index 3531b940a42..fedc9677f99 100644
--- a/lib/active_merchant/billing/gateways/worldpay.rb
+++ b/lib/active_merchant/billing/gateways/worldpay.rb
@@ -370,7 +370,10 @@ def commit(action, request, *success_criteria, options)
raw,
:authorization => authorization_from(raw),
:error_code => error_code_from(success, raw),
- :test => test?)
+ :test => test?,
+ :avs_result => AVSResult.new(code: AVS_CODE_MAP[raw[:avs_result_code_description]]),
+ :cvv_result => CVVResult.new(CVC_CODE_MAP[raw[:cvc_result_code_description]])
+ )
rescue ActiveMerchant::ResponseError => e
if e.response.code.to_s == '401'
return Response.new(false, 'Invalid credentials', {}, :test => test?)
diff --git a/test/remote/gateways/remote_worldpay_test.rb b/test/remote/gateways/remote_worldpay_test.rb
index c87d9539397..2009f01838a 100644
--- a/test/remote/gateways/remote_worldpay_test.rb
+++ b/test/remote/gateways/remote_worldpay_test.rb
@@ -23,6 +23,15 @@ def test_successful_purchase
assert_equal 'SUCCESS', response.message
end
+ def test_successful_authorize_avs_and_cvv
+ card = credit_card('4111111111111111', :verification_value => 555)
+ assert response = @gateway.authorize(@amount, card, @options.merge(billing_address: address.update(zip: 'CCCC')))
+ assert_success response
+ assert_equal 'SUCCESS', response.message
+ assert_match %r{Street address does not match, but 5-digit postal code matches}, response.avs_result['message']
+ assert_match %r{CVV matches}, response.cvv_result['message']
+ end
+
def test_successful_purchase_with_hcg_additional_data
@options[:hcg_additional_data] = {
key1: 'value1',
From 8ce019528da984dd01796f3a6be8effde9b84ef8 Mon Sep 17 00:00:00 2001
From: Niaja
Date: Thu, 10 Jan 2019 14:56:32 -0500
Subject: [PATCH 0239/2234] Worldpay: Add AVS and CVC Mapping
Somehow in the process of squashing, the map needed to add avs and cvc
mapping was lost.
Loaded suite test/remote/gateways/remote_worldpay_test
29 tests, 116 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Loaded suite test/unit/gateways/worldpay_test
41 tests, 231 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/worldpay.rb | 20 +++++++++++++++++++
2 files changed, 21 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index 58ba4078b88..23f7c06816e 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -13,6 +13,7 @@
* TrustCommerce: Use `application_id` [nfarve] #3103
* Stripe: Add 3DS Support [nfarve] #3086
* WorldPay: Pull CVC and AVS Result from Response [nfarve] #3106
+* Worldpay: Add AVS and CVC Mapping [nfarve] #3107
== Version 1.89.0 (December 17, 2018)
diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb
index fedc9677f99..422b2801f5e 100644
--- a/lib/active_merchant/billing/gateways/worldpay.rb
+++ b/lib/active_merchant/billing/gateways/worldpay.rb
@@ -23,6 +23,26 @@ class WorldpayGateway < Gateway
'diners_club' => 'DINERS-SSL',
}
+ AVS_CODE_MAP = {
+ 'A' => 'M', # Match
+ 'B' => 'P', # Postcode matches, address not verified
+ 'C' => 'Z', # Postcode matches, address does not match
+ 'D' => 'B', # Address matched; postcode not checked
+ 'E' => 'I', # Address and postal code not checked
+ 'F' => 'A', # Address matches, postcode does not match
+ 'G' => 'C', # Address does not match, postcode not checked
+ 'H' => 'I', # Address and postcode not provided
+ 'I' => 'C', # Address not checked postcode does not match
+ 'J' => 'C', # Address and postcode does not match
+ }
+
+ CVC_CODE_MAP = {
+ 'A' => 'M', # CVV matches
+ 'B' => 'P', # Not provided
+ 'C' => 'P', # Not checked
+ 'D' => 'N', # Does not match
+ }
+
def initialize(options = {})
requires!(options, :login, :password)
super
From f9a3033eae924ff915d029496e5306716c404116 Mon Sep 17 00:00:00 2001
From: molbrown
Date: Thu, 10 Jan 2019 14:47:09 -0500
Subject: [PATCH 0240/2234] Paymentez: Fixes extra_params field Simpler method
to add JSON object to request in extra_params, and fixes buggy behavior.
ENE-80
Unit Tests:
19 tests, 77 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote Tests:
20 tests, 47 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
Failures unrelated to this change, have to do with country-specific allowances for
partial capture/ refund.
Closes #3108
---
CHANGELOG | 6 +++---
lib/active_merchant/billing/gateways/paymentez.rb | 13 ++++---------
2 files changed, 7 insertions(+), 12 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 23f7c06816e..67b0c651ef3 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,9 @@
= ActiveMerchant CHANGELOG
== HEAD
+* WorldPay: Pull CVC and AVS Result from Response [nfarve] #3106
+* Worldpay: Add AVS and CVC Mapping [nfarve] #3107
+* Paymentez: Fixes extra_params field [molbrown] #3108
== Version 1.90.0 (January 8, 2019)
* Mercado Pago: Support "gateway" processing mode [curiousepic] #3087
@@ -12,9 +15,6 @@
* Braintree Blue: Refactor line_items field [curiousepic] #3100
* TrustCommerce: Use `application_id` [nfarve] #3103
* Stripe: Add 3DS Support [nfarve] #3086
-* WorldPay: Pull CVC and AVS Result from Response [nfarve] #3106
-* Worldpay: Add AVS and CVC Mapping [nfarve] #3107
-
== Version 1.89.0 (December 17, 2018)
* Worldpay: handle Visa and MasterCard payouts differently [bpollack] #3068
diff --git a/lib/active_merchant/billing/gateways/paymentez.rb b/lib/active_merchant/billing/gateways/paymentez.rb
index 1f2409e72bd..f93a4bed6fa 100644
--- a/lib/active_merchant/billing/gateways/paymentez.rb
+++ b/lib/active_merchant/billing/gateways/paymentez.rb
@@ -171,15 +171,10 @@ def add_payment(post, payment)
end
def add_extra_params(post, options)
- if options[:extra_params]
- items = {}
- options[:extra_params].each do |param|
- param.each do |key, value|
- items[key.to_sym] = value
- end
- end
- post[:extra_params] = items
- end
+ extra_params = {}
+ extra_params.merge!(options[:extra_params]) if options[:extra_params]
+
+ post['extra_params'] = extra_params unless extra_params.empty?
end
def parse(body)
From f8718d8741aeb5325fd7073779c8ce86c2d7dc4f Mon Sep 17 00:00:00 2001
From: Lancelot Carlson
Date: Mon, 31 Dec 2018 15:18:32 -0500
Subject: [PATCH 0241/2234] extra argument checking on custom fields, allow qty
to be passed in addition to quantity
---
.../billing/gateways/usa_epay_transaction.rb | 5 +++-
.../gateways/usa_epay_transaction_test.rb | 28 +++++++++++++++++++
2 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb
index fb0b277a164..13b225fad28 100644
--- a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb
+++ b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb
@@ -258,7 +258,10 @@ def add_recurring_fields(post, options)
# see: https://wiki.usaepay.com/developer/transactionapi#merchant_defined_custom_fields
def add_custom_fields(post, options)
return unless options[:custom_fields].is_a?(Hash)
+
options[:custom_fields].each do |index, custom|
+ raise ArgumentError.new('Cannot specify custom field with index 0') if index.to_i.zero?
+
post["custom#{index}"] = custom
end
end
@@ -267,7 +270,7 @@ def add_custom_fields(post, options)
def add_line_items(post, options)
return unless options[:line_items].is_a?(Array)
options[:line_items].each_with_index do |line_item, index|
- %w(product_ref_num sku name description taxable tax_rate tax_amount commodity_code discount_rate discount_amount).each do |key|
+ %w(product_ref_num sku qty name description taxable tax_rate tax_amount commodity_code discount_rate discount_amount).each do |key|
post["line#{index}#{key.delete('_')}"] = line_item[key.to_sym] if line_item.has_key?(key.to_sym)
end
diff --git a/test/unit/gateways/usa_epay_transaction_test.rb b/test/unit/gateways/usa_epay_transaction_test.rb
index 260195409da..cf2679ababc 100644
--- a/test/unit/gateways/usa_epay_transaction_test.rb
+++ b/test/unit/gateways/usa_epay_transaction_test.rb
@@ -185,12 +185,37 @@ def test_successful_purchase_custom_fields
assert_success response
end
+ def test_first_index_guard_on_custom_fields
+ assert_raise(ArgumentError) do
+ @gateway.purchase(@amount, @credit_card, @options.merge(
+ :custom_fields => {
+ 0 => 'butcher',
+ 1 => 'diablo',
+ 2 => 'mephisto',
+ 3 => 'baal'
+ }
+ ))
+ end
+
+ assert_raise(ArgumentError) do
+ @gateway.purchase(@amount, @credit_card, @options.merge(
+ :custom_fields => {
+ '0' => 'butcher',
+ '1' => 'diablo',
+ '2' => 'mephisto',
+ '3' => 'baal'
+ }
+ ))
+ end
+ end
+
def test_successful_purchase_line_items
response = stub_comms do
@gateway.purchase(@amount, @credit_card, @options.merge(
:line_items => [
{ :sku=> 'abc123', :cost => 119, :quantity => 1 },
{ :sku => 'def456', :cost => 200, :quantity => 2, :name => 'an item' },
+ { :cost => 300, :qty => 4 }
]
))
end.check_request do |endpoint, data, headers|
@@ -202,6 +227,9 @@ def test_successful_purchase_line_items
assert_match %r{UMline1cost=2.00}, data
assert_match %r{UMline1qty=2}, data
assert_match %r{UMline1name=an\+item}, data
+
+ assert_match %r{UMline2cost=3.00}, data
+ assert_match %r{UMline2qty=4}, data
end.respond_with(successful_purchase_response)
assert_success response
end
From a290873c4daff2903f760ddcddba9e317deab387 Mon Sep 17 00:00:00 2001
From: molbrown
Date: Tue, 15 Jan 2019 15:41:10 -0500
Subject: [PATCH 0242/2234] Adyen: Handles blank state address field
Sends N/A if state field is not populated. Resolves validation errors from sending blank state field.
ECS-102
Remote:
39 tests, 100 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
26 tests, 127 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/adyen.rb | 2 +-
test/remote/gateways/remote_adyen_test.rb | 6 ++++++
test/unit/gateways/adyen_test.rb | 3 ++-
4 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 13c900f6544..0fa1476f8f1 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -7,6 +7,7 @@
* Improved support for account_type using Check class's account_type instead [lancecarlson] #3097
* USA Epay: Allow quantity to be passed and check custom fields [lancecarlson] #3090
* Fix usaepay transaction invoice [lancecarlson] #3093
+* Adyen: Handles blank state address field [molbrown] #3113
== Version 1.90.0 (January 8, 2019)
* Mercado Pago: Support "gateway" processing mode [curiousepic] #3087
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index fbda0615857..bbb6e5f0e16 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -187,7 +187,7 @@ def add_address(post, options)
post[:card][:billingAddress][:houseNumberOrName] = address[:address2] || 'N/A'
post[:card][:billingAddress][:postalCode] = address[:zip] if address[:zip]
post[:card][:billingAddress][:city] = address[:city] || 'N/A'
- post[:card][:billingAddress][:stateOrProvince] = address[:state] if address[:state]
+ post[:card][:billingAddress][:stateOrProvince] = address[:state] || 'N/A'
post[:card][:billingAddress][:country] = address[:country] if address[:country]
end
end
diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb
index 53ca7b7bfa8..952973281e3 100644
--- a/test/remote/gateways/remote_adyen_test.rb
+++ b/test/remote/gateways/remote_adyen_test.rb
@@ -327,6 +327,12 @@ def test_missing_house_number_or_name_for_purchase
assert_success response
end
+ def test_missing_state_for_purchase
+ @options[:billing_address].delete(:state)
+ response = @gateway.authorize(@amount, @credit_card, @options)
+ assert_success response
+ end
+
def test_invalid_country_for_purchase
@options[:billing_address][:country] = ''
response = @gateway.authorize(@amount, @credit_card, @options)
diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb
index 8cd354efffc..09b80f9ab76 100644
--- a/test/unit/gateways/adyen_test.rb
+++ b/test/unit/gateways/adyen_test.rb
@@ -262,12 +262,13 @@ def test_add_address
post = {:card => {:billingAddress => {}}}
@options[:billing_address].delete(:address1)
@options[:billing_address].delete(:address2)
+ @options[:billing_address].delete(:state)
@gateway.send(:add_address, post, @options)
assert_equal 'N/A', post[:card][:billingAddress][:street]
assert_equal 'N/A', post[:card][:billingAddress][:houseNumberOrName]
+ assert_equal 'N/A', post[:card][:billingAddress][:stateOrProvince]
assert_equal @options[:billing_address][:zip], post[:card][:billingAddress][:postalCode]
assert_equal @options[:billing_address][:city], post[:card][:billingAddress][:city]
- assert_equal @options[:billing_address][:state], post[:card][:billingAddress][:stateOrProvince]
assert_equal @options[:billing_address][:country], post[:card][:billingAddress][:country]
end
From 467c1cd483ceb6f2a5d6a70ad8a992881043dde3 Mon Sep 17 00:00:00 2001
From: David Perry
Date: Tue, 15 Jan 2019 14:02:07 -0500
Subject: [PATCH 0243/2234] Braintree: Pass all country fields
According to Braintree docs, sending Level 3 data requires the presence
of the shipping country in alpha3 format. Since we can't easily
determine which format should be sent in various situations, default to
sending all formats that are present (which seems permissible, from
remote testing), and then ensure the alpha3 is sent by using the Country
module.
Closes #3112
Unit:
57 tests, 150 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
68 tests, 384 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/braintree_blue.rb | 16 +++++++---------
.../gateways/remote_braintree_blue_test.rb | 2 +-
test/unit/gateways/braintree_blue_test.rb | 3 ++-
4 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 0fa1476f8f1..2d1ce01187f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -8,6 +8,7 @@
* USA Epay: Allow quantity to be passed and check custom fields [lancecarlson] #3090
* Fix usaepay transaction invoice [lancecarlson] #3093
* Adyen: Handles blank state address field [molbrown] #3113
+* Braintree: Send all country fields [curiousepic] #3112
== Version 1.90.0 (January 8, 2019)
* Mercado Pago: Support "gateway" processing mode [curiousepic] #3087
diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb
index 3427bdd016b..b4dd74da3e5 100644
--- a/lib/active_merchant/billing/gateways/braintree_blue.rb
+++ b/lib/active_merchant/billing/gateways/braintree_blue.rb
@@ -324,15 +324,13 @@ def map_address(address)
:region => address[:state],
:postal_code => scrub_zip(address[:zip]),
}
- if address[:country] || address[:country_code_alpha2]
- mapped[:country_code_alpha2] = (address[:country] || address[:country_code_alpha2])
- elsif address[:country_name]
- mapped[:country_name] = address[:country_name]
- elsif address[:country_code_alpha3]
- mapped[:country_code_alpha3] = address[:country_code_alpha3]
- elsif address[:country_code_numeric]
- mapped[:country_code_numeric] = address[:country_code_numeric]
- end
+
+ mapped[:country_code_alpha2] = (address[:country] || address[:country_code_alpha2]) if address[:country] || address[:country_code_alpha2]
+ mapped[:country_name] = address[:country_name] if address[:country_name]
+ mapped[:country_code_alpha3] = address[:country_code_alpha3] if address[:country_code_alpha3]
+ mapped[:country_code_alpha3] ||= Country.find(address[:country]).code(:alpha3).value if address[:country]
+ mapped[:country_code_numeric] = address[:country_code_numeric] if address[:country_code_numeric]
+
mapped
end
diff --git a/test/remote/gateways/remote_braintree_blue_test.rb b/test/remote/gateways/remote_braintree_blue_test.rb
index 2f116892bc1..1ab371e1f92 100644
--- a/test/remote/gateways/remote_braintree_blue_test.rb
+++ b/test/remote/gateways/remote_braintree_blue_test.rb
@@ -12,7 +12,7 @@ def setup
@options = {
:order_id => '1',
- :billing_address => address(:country_name => 'United States of America'),
+ :billing_address => address(:country_name => 'Canada'),
:description => 'Store Purchase'
}
end
diff --git a/test/unit/gateways/braintree_blue_test.rb b/test/unit/gateways/braintree_blue_test.rb
index 0135224cd32..0c466cecabf 100644
--- a/test/unit/gateways/braintree_blue_test.rb
+++ b/test/unit/gateways/braintree_blue_test.rb
@@ -576,7 +576,8 @@ def test_merge_credit_card_options_handles_billing_address
:locality => 'Chicago',
:region => 'Illinois',
:postal_code => '60622',
- :country_code_alpha2 => 'US'
+ :country_code_alpha2 => 'US',
+ :country_code_alpha3 => 'USA'
},
:options => {}
}
From a427610459934a8068287d1270ad41c34c634624 Mon Sep 17 00:00:00 2001
From: David Perry
Date: Wed, 16 Jan 2019 16:14:26 -0500
Subject: [PATCH 0244/2234] Braintree: Account for empty string countries
The prior change using the Country module didn't guard against empty
string country fields.
Closes #3115
Remote:
68 tests, 384 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
57 tests, 150 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/braintree_blue.rb | 4 +++-
test/remote/gateways/remote_braintree_blue_test.rb | 4 ++--
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 2d1ce01187f..7e71f604034 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -9,6 +9,7 @@
* Fix usaepay transaction invoice [lancecarlson] #3093
* Adyen: Handles blank state address field [molbrown] #3113
* Braintree: Send all country fields [curiousepic] #3112
+* Braintree: Account for empty string countries [curiousepic] #3115
== Version 1.90.0 (January 8, 2019)
* Mercado Pago: Support "gateway" processing mode [curiousepic] #3087
diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb
index b4dd74da3e5..50333d91af7 100644
--- a/lib/active_merchant/billing/gateways/braintree_blue.rb
+++ b/lib/active_merchant/billing/gateways/braintree_blue.rb
@@ -328,7 +328,9 @@ def map_address(address)
mapped[:country_code_alpha2] = (address[:country] || address[:country_code_alpha2]) if address[:country] || address[:country_code_alpha2]
mapped[:country_name] = address[:country_name] if address[:country_name]
mapped[:country_code_alpha3] = address[:country_code_alpha3] if address[:country_code_alpha3]
- mapped[:country_code_alpha3] ||= Country.find(address[:country]).code(:alpha3).value if address[:country]
+ unless address[:country].blank?
+ mapped[:country_code_alpha3] ||= Country.find(address[:country]).code(:alpha3).value
+ end
mapped[:country_code_numeric] = address[:country_code_numeric] if address[:country_code_numeric]
mapped
diff --git a/test/remote/gateways/remote_braintree_blue_test.rb b/test/remote/gateways/remote_braintree_blue_test.rb
index 1ab371e1f92..2e755a182b5 100644
--- a/test/remote/gateways/remote_braintree_blue_test.rb
+++ b/test/remote/gateways/remote_braintree_blue_test.rb
@@ -38,7 +38,7 @@ def test_successful_authorize
assert_equal 'authorized', response.params['braintree_transaction']['status']
end
- def test_successful_authorize_with_nil_billing_address_options
+ def test_successful_authorize_with_nil_and_empty_billing_address_options
credit_card = credit_card('5105105105105100')
options = {
:billing_address => {
@@ -50,7 +50,7 @@ def test_successful_authorize_with_nil_billing_address_options
:city => nil,
:state => nil,
:zip => nil,
- :country_name => nil
+ :country => ''
}
}
assert response = @gateway.authorize(@amount, credit_card, options)
From ea2ad89766320e404061cc5e92cd2906e210bc70 Mon Sep 17 00:00:00 2001
From: Jared Knipp
Date: Wed, 16 Jan 2019 13:48:04 -0500
Subject: [PATCH 0245/2234] Orbital - Support for stored credentials framework
Add support for Stored Credentials Framework (Cardholder vs Merchant
Initiated transactions).
Update the XSD schema in remote tests to the latest version since we
upgraded the API version for stored credentials.
ECS-91
Remote:
25 tests, 148 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
71 tests, 427 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
closes #3117
---
CHANGELOG | 1 +
.../billing/gateways/orbital.rb | 9 +-
test/remote/gateways/remote_orbital_test.rb | 25 +
.../{Request_PTI54.xsd => Request_PTI77.xsd} | 2044 +++++++++--------
test/unit/gateways/orbital_test.rb | 19 +-
5 files changed, 1144 insertions(+), 954 deletions(-)
rename test/schema/orbital/{Request_PTI54.xsd => Request_PTI77.xsd} (81%)
mode change 100644 => 100755
diff --git a/CHANGELOG b/CHANGELOG
index 7e71f604034..b1baa8c23af 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
= ActiveMerchant CHANGELOG
== HEAD
+* Orbital: Support for stored credentials framework [jknipp] #3117
* WorldPay: Pull CVC and AVS Result from Response [nfarve] #3106
* Worldpay: Add AVS and CVC Mapping [nfarve] #3107
* Paymentez: Fixes extra_params field [molbrown] #3108
diff --git a/lib/active_merchant/billing/gateways/orbital.rb b/lib/active_merchant/billing/gateways/orbital.rb
index 2514617b6da..81e1fd0563a 100644
--- a/lib/active_merchant/billing/gateways/orbital.rb
+++ b/lib/active_merchant/billing/gateways/orbital.rb
@@ -30,7 +30,7 @@ module Billing #:nodoc:
class OrbitalGateway < Gateway
include Empty
- API_VERSION = '7.1'
+ API_VERSION = '7.7'
POST_HEADERS = {
'MIME-Version' => '1.1',
@@ -506,6 +506,12 @@ def add_managed_billing(xml, options)
end
end
+ def add_stored_credentials(xml, parameters)
+ xml.tag! :MITMsgType, parameters[:mit_msg_type] if parameters[:mit_msg_type]
+ xml.tag! :MITStoredCredentialInd, parameters[:mit_stored_credential_ind] if parameters[:mit_stored_credential_ind]
+ xml.tag! :MITSubmittedTransactionID, parameters[:mit_submitted_transaction_id] if parameters[:mit_submitted_transaction_id]
+ end
+
def parse(body)
response = {}
xml = REXML::Document.new(body)
@@ -635,6 +641,7 @@ def build_new_order_xml(action, money, creditcard, parameters = {})
end
add_level_2_purchase(xml, parameters)
+ add_stored_credentials(xml, parameters)
end
end
xml.target!
diff --git a/test/remote/gateways/remote_orbital_test.rb b/test/remote/gateways/remote_orbital_test.rb
index 62fe766500c..4f94ca697b6 100644
--- a/test/remote/gateways/remote_orbital_test.rb
+++ b/test/remote/gateways/remote_orbital_test.rb
@@ -132,6 +132,31 @@ def test_successful_purchase_with_discover_network_tokenization_credit_card
assert_false response.authorization.blank?
end
+ def test_successful_purchase_with_mit_stored_credentials
+ mit_stored_credentials = {
+ mit_msg_type: 'MUSE',
+ mit_stored_credential_ind: 'Y',
+ mit_submitted_transaction_id: 'abcdefg12345678'
+ }
+
+ response = @gateway.purchase(@amount, @credit_card, @options.merge(mit_stored_credentials))
+
+ assert_success response
+ assert_equal 'Approved', response.message
+ end
+
+ def test_successful_purchase_with_cit_stored_credentials
+ cit_options = {
+ mit_msg_type: 'CUSE',
+ mit_stored_credential_ind: 'Y'
+ }
+
+ response = @gateway.purchase(@amount, @credit_card, @options.merge(cit_options))
+
+ assert_success response
+ assert_equal 'Approved', response.message
+ end
+
# Amounts of x.01 will fail
def test_unsuccessful_purchase
assert response = @gateway.purchase(101, @declined_card, @options)
diff --git a/test/schema/orbital/Request_PTI54.xsd b/test/schema/orbital/Request_PTI77.xsd
old mode 100644
new mode 100755
similarity index 81%
rename from test/schema/orbital/Request_PTI54.xsd
rename to test/schema/orbital/Request_PTI77.xsd
index 0a75e3a164d..bcae535f6f5
--- a/test/schema/orbital/Request_PTI54.xsd
+++ b/test/schema/orbital/Request_PTI77.xsd
@@ -1,951 +1,1093 @@
-
-
-
-
- Top level element for all XML request transaction types
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- New order Transaction Types
-
-
-
-
-
- Auth Only No Capture
-
-
-
-
- Auth and Capture
-
-
-
-
- Force Auth No Capture and no online authorization
-
-
-
-
- Force Auth No Capture and no online authorization
-
-
-
-
- Force Auth and Capture no online authorization
-
-
-
-
- Refund and Capture no online authorization
-
-
-
-
-
-
- New order Industry Types
-
-
-
-
-
- Ecommerce transaction
-
-
-
-
- Recurring Payment transaction
-
-
-
-
- Mail Order Telephone Order transaction
-
-
-
-
- Interactive Voice Response
-
-
-
-
- Interactive Voice Response
-
-
-
-
-
-
-
-
-
-
-
- Tax not provided
-
-
-
-
- Tax included
-
-
-
-
- Non-taxable transaction
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Stratus
-
-
-
-
- Tandam
-
-
-
-
-
-
-
-
-
-
-
- No mapping to order data
-
-
-
-
- Use customer reference for OrderID
-
-
-
-
- Use customer reference for both Order Id and Order Description
-
-
-
-
- Use customer reference for Order Description
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Auto Generate the CustomerRefNum
-
-
-
-
- Use OrderID as the CustomerRefNum
-
-
-
-
- Use CustomerRefNum Element
-
-
-
-
- Use the description as the CustomerRefNum
-
-
-
-
- Ignore. We will Ignore this entry if it's passed in the XML
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- American Express
-
-
-
-
- Carte Blanche
-
-
-
-
- Diners Club
-
-
-
-
- Discover
-
-
-
-
- GE Twinpay Credit
-
-
-
-
- GECC Private Label Credit
-
-
-
-
- JCB
-
-
-
-
- Mastercard
-
-
-
-
- Visa
-
-
-
-
- GE Twinpay Debit
-
-
-
-
- Switch / Solo
-
-
-
-
- Electronic Check
-
-
-
-
- Flex Cache
-
-
-
-
- European Direct Debit
-
-
-
-
- Bill Me Later
-
-
-
-
- PINLess Debit
-
-
-
-
- International Maestro
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Credit Card
-
-
-
-
- Swith/Solo
-
-
-
-
- Electronic Check
-
-
-
-
- PINLess Debit
-
-
-
-
- European Direct Debit
-
-
-
-
- International Maestro
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- United States
-
-
-
-
- Canada
-
-
-
-
- Germany
-
-
-
-
- Great Britain
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Yes
-
-
-
-
- Yes
-
-
-
-
- No
-
-
-
-
- No
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Authenticated
-
-
-
-
- Attempted
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- First Recurring Transaction
-
-
-
-
- Subsequent Recurring Transactions
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+ Top level element for all XML request transaction types
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ New order Transaction Types
+
+
+
+
+
+ Auth Only No Capture
+
+
+
+
+ Auth and Capture
+
+
+
+
+ Force Auth No Capture and no online authorization
+
+
+
+
+ Force Auth No Capture and no online authorization
+
+
+
+
+ Force Auth and Capture no online authorization
+
+
+
+
+ Refund and Capture no online authorization
+
+
+
+
+
+
+ New order Industry Types
+
+
+
+
+
+ Ecommerce transaction
+
+
+
+
+ Recurring Payment transaction
+
+
+
+
+ Mail Order Telephone Order transaction
+
+
+
+
+ Interactive Voice Response
+
+
+
+
+ Interactive Voice Response
+
+
+
+
+
+
+
+
+
+
+
+ Tax not provided
+
+
+
+
+ Tax included
+
+
+
+
+ Non-taxable transaction
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Stratus
+
+
+
+
+ Tandam
+
+
+
+
+
+
+
+
+
+
+
+ No mapping to order data
+
+
+
+
+ Use customer reference for OrderID
+
+
+
+
+ Use customer reference for both Order Id and Order Description
+
+
+
+
+ Use customer reference for Order Description
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Auto Generate the CustomerRefNum
+
+
+
+
+ Use OrderID as the CustomerRefNum
+
+
+
+
+ Use CustomerRefNum Element
+
+
+
+
+ Use the description as the CustomerRefNum
+
+
+
+
+ Ignore. We will Ignore this entry if it's passed in the XML
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ American Express
+
+
+
+
+ Carte Blanche
+
+
+
+
+ Diners Club
+
+
+
+
+ Discover
+
+
+
+
+ GE Twinpay Credit
+
+
+
+
+ GECC Private Label Credit
+
+
+
+
+ JCB
+
+
+
+
+ Mastercard
+
+
+
+
+ Visa
+
+
+
+
+ GE Twinpay Debit
+
+
+
+
+ Switch / Solo
+
+
+
+
+ Electronic Check
+
+
+
+
+ Flex Cache
+
+
+
+
+ European Direct Debit
+
+
+
+
+ Bill Me Later
+
+
+
+
+ PINLess Debit
+
+
+
+
+ International Maestro
+
+
+
+
+ ChaseNet Credit
+
+
+
+
+ ChaseNet Signature Debit
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Credit Card
+
+
+
+
+ Swith/Solo
+
+
+
+
+ Electronic Check
+
+
+
+
+ PINLess Debit
+
+
+
+
+ European Direct Debit
+
+
+
+
+ International Maestro
+
+
+
+
+ International Maestro
+
+
+
+
+ International Maestro
+
+
+
+
+ International Maestro
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ United States
+
+
+
+
+ Canada
+
+
+
+
+ Germany
+
+
+
+
+ Great Britain
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Yes
+
+
+
+
+ Yes
+
+
+
+
+ No
+
+
+
+
+ No
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ First Recurring Transaction
+
+
+
+
+ Subsequent Recurring Transactions
+
+
+
+
+ First Installment Transaction
+
+
+
+
+ Subsequent Installment Transactions
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/unit/gateways/orbital_test.rb b/test/unit/gateways/orbital_test.rb
index 6b913222dcd..996e5334c4e 100644
--- a/test/unit/gateways/orbital_test.rb
+++ b/test/unit/gateways/orbital_test.rb
@@ -31,6 +31,11 @@ def setup
}
@options = { :order_id => '1'}
+ @options_stored_credentials = {
+ mit_msg_type: 'MUSE',
+ mit_stored_credential_ind: 'Y',
+ mit_submitted_transaction_id: '123456abcdef'
+ }
end
def test_successful_purchase
@@ -388,6 +393,16 @@ def test_dest_address
assert_success response
end
+ def test_successful_purchase_with_stored_credentials
+ stub_comms do
+ @gateway.purchase(50, credit_card, @options.merge(@options_stored_credentials))
+ end.check_request do |endpoint, data, headers|
+ assert_match %{#{@options_stored_credentials[:mit_msg_type]}}, data
+ assert_match %{#{@options_stored_credentials[:mit_stored_credential_ind]}}, data
+ assert_match %{#{@options_stored_credentials[:mit_submitted_transaction_id]}}, data
+ end.respond_with(successful_purchase_response)
+ end
+
def test_default_managed_billing
response = stub_comms do
assert_deprecation_warning(Gateway::RECURRING_DEPRECATION_MESSAGE) do
@@ -567,7 +582,7 @@ def test_american_requests_adhere_to_xml_schema
response = stub_comms do
@gateway.purchase(50, credit_card, :order_id => 1, :billing_address => address)
end.check_request do |endpoint, data, headers|
- schema_file = File.read("#{File.dirname(__FILE__)}/../../schema/orbital/Request_PTI54.xsd")
+ schema_file = File.read("#{File.dirname(__FILE__)}/../../schema/orbital/Request_PTI77.xsd")
doc = Nokogiri::XML(data)
xsd = Nokogiri::XML::Schema(schema_file)
assert xsd.valid?(doc), 'Request does not adhere to DTD'
@@ -579,7 +594,7 @@ def test_german_requests_adhere_to_xml_schema
response = stub_comms do
@gateway.purchase(50, credit_card, :order_id => 1, :billing_address => address(:country => 'DE'))
end.check_request do |endpoint, data, headers|
- schema_file = File.read("#{File.dirname(__FILE__)}/../../schema/orbital/Request_PTI54.xsd")
+ schema_file = File.read("#{File.dirname(__FILE__)}/../../schema/orbital/Request_PTI77.xsd")
doc = Nokogiri::XML(data)
xsd = Nokogiri::XML::Schema(schema_file)
assert xsd.valid?(doc), 'Request does not adhere to DTD'
From 38ee3ef55f7d6e661df45cad4d9736303e86d013 Mon Sep 17 00:00:00 2001
From: Jared Knipp
Date: Mon, 21 Jan 2019 13:09:34 -0600
Subject: [PATCH 0246/2234] Openpay: Fix successful transaction(s) marked as
failed
Some Openpay transaction response objects are including an error_code
field that was previously only present in error responses. Now we will
check for the existence of the error_code field and a non-nil/blank
error code.
ECS-97
Remote:
24 tests, 80 assertions, 4 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
83.3333% passed
Unit:
20 tests, 103 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/openpay.rb | 2 +-
test/unit/gateways/openpay_test.rb | 12 ++++++++----
3 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index b1baa8c23af..0235bf493b3 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
= ActiveMerchant CHANGELOG
== HEAD
+* Openpay: Fix for marking successful transaction(s) as failed [jknipp] #3121
* Orbital: Support for stored credentials framework [jknipp] #3117
* WorldPay: Pull CVC and AVS Result from Response [nfarve] #3106
* Worldpay: Add AVS and CVC Mapping [nfarve] #3107
diff --git a/lib/active_merchant/billing/gateways/openpay.rb b/lib/active_merchant/billing/gateways/openpay.rb
index 778729f4cbd..166f1f44b43 100644
--- a/lib/active_merchant/billing/gateways/openpay.rb
+++ b/lib/active_merchant/billing/gateways/openpay.rb
@@ -205,7 +205,7 @@ def http_request(method, resource, parameters={}, options={})
end
def error?(response)
- response.key?('error_code')
+ response['error_code'] && !response['error_code'].blank?
end
def response_error(raw_response)
diff --git a/test/unit/gateways/openpay_test.rb b/test/unit/gateways/openpay_test.rb
index 7355647e382..5c15f77e489 100644
--- a/test/unit/gateways/openpay_test.rb
+++ b/test/unit/gateways/openpay_test.rb
@@ -311,7 +311,8 @@ def successful_refunded_response
"creation_date": "2014-01-20T17:08:43-06:00",
"description": "Store Purchase",
"error_message": null,
- "order_id": null
+ "order_id": null,
+ "error_code": null
}
RESPONSE
end
@@ -345,7 +346,8 @@ def successful_capture_response
"creation_date": "2014-01-18T21:01:10-06:00",
"description": "Store Purchase",
"error_message": null,
- "order_id": null
+ "order_id": null,
+ "error_code": null
}
RESPONSE
end
@@ -379,7 +381,8 @@ def successful_authorization_response
"creation_date": "2014-01-18T21:01:10-06:00",
"description": "Store Purchase",
"error_message": null,
- "order_id": null
+ "order_id": null,
+ "error_code": null
}
RESPONSE
end
@@ -421,7 +424,8 @@ def successful_purchase_response(status = 'completed')
"creation_date": "2014-01-18T21:49:38-06:00",
"description": "Store Purchase",
"error_message": null,
- "order_id": null
+ "order_id": null,
+ "error_code": null
}
RESPONSE
end
From ae0d324b85356636a7876eb44565a3760bc0e537 Mon Sep 17 00:00:00 2001
From: molbrown
Date: Thu, 17 Jan 2019 14:56:56 -0500
Subject: [PATCH 0247/2234] Braintree: Adds support for transaction_source
Braintree has deprecated the recurring field in lieu of the transaction_source parameter which allows a 'recurring' value. For now, Braintree still allows both fields to be sent.
ECS-97
Remote:
69 tests, 389 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
58 tests, 151 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Closes #3120
---
CHANGELOG | 5 +++--
lib/active_merchant/billing/gateways/braintree_blue.rb | 4 +++-
test/remote/gateways/remote_braintree_blue_test.rb | 10 ++++++++++
test/unit/gateways/braintree_blue_test.rb | 8 ++++++++
4 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 0235bf493b3..1ed5e07cbda 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,8 +1,6 @@
= ActiveMerchant CHANGELOG
== HEAD
-* Openpay: Fix for marking successful transaction(s) as failed [jknipp] #3121
-* Orbital: Support for stored credentials framework [jknipp] #3117
* WorldPay: Pull CVC and AVS Result from Response [nfarve] #3106
* Worldpay: Add AVS and CVC Mapping [nfarve] #3107
* Paymentez: Fixes extra_params field [molbrown] #3108
@@ -12,6 +10,9 @@
* Adyen: Handles blank state address field [molbrown] #3113
* Braintree: Send all country fields [curiousepic] #3112
* Braintree: Account for empty string countries [curiousepic] #3115
+* Orbital: Support for stored credentials framework [jknipp] #3117
+* Openpay: Fix for marking successful transaction(s) as failed [jknipp] #3121
+* Braintree: Adds support for transaction_source [molbrown] #3120
== Version 1.90.0 (January 8, 2019)
* Mercado Pago: Support "gateway" processing mode [curiousepic] #3087
diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb
index 50333d91af7..21d5741ae86 100644
--- a/lib/active_merchant/billing/gateways/braintree_blue.rb
+++ b/lib/active_merchant/billing/gateways/braintree_blue.rb
@@ -585,7 +585,9 @@ def create_transaction_parameters(money, credit_card_or_vault_id, options)
parameters[:merchant_account_id] = merchant_account_id
end
- if options[:recurring]
+ if options[:transaction_source]
+ parameters[:transaction_source] = options[:transaction_source]
+ elsif options[:recurring]
parameters[:recurring] = true
end
diff --git a/test/remote/gateways/remote_braintree_blue_test.rb b/test/remote/gateways/remote_braintree_blue_test.rb
index 2e755a182b5..c24abe26cb2 100644
--- a/test/remote/gateways/remote_braintree_blue_test.rb
+++ b/test/remote/gateways/remote_braintree_blue_test.rb
@@ -426,6 +426,16 @@ def test_purchase_with_store_using_specified_customer_id
assert_equal '510510', @braintree_backend.customer.find(response.params['customer_vault_id']).credit_cards[0].bin
end
+ def test_purchase_with_transaction_source
+ assert response = @gateway.store(@credit_card)
+ assert_success response
+ customer_vault_id = response.params['customer_vault_id']
+
+ assert response = @gateway.purchase(@amount, customer_vault_id, @options.merge(:transaction_source => 'unscheduled'))
+ assert_success response
+ assert_equal '1000 Approved', response.message
+ end
+
def test_purchase_using_specified_payment_method_token
assert response = @gateway.store(
credit_card('4111111111111111',
diff --git a/test/unit/gateways/braintree_blue_test.rb b/test/unit/gateways/braintree_blue_test.rb
index 0c466cecabf..b1397107579 100644
--- a/test/unit/gateways/braintree_blue_test.rb
+++ b/test/unit/gateways/braintree_blue_test.rb
@@ -678,6 +678,14 @@ def test_passes_recurring_flag
@gateway.purchase(100, credit_card('41111111111111111111'))
end
+ def test_passes_transaction_source
+ Braintree::TransactionGateway.any_instance.expects(:sale).with do |params|
+ (params[:transaction_source] == 'recurring')
+ (params[:recurring] == nil)
+ end.returns(braintree_result)
+ @gateway.purchase(100, credit_card('41111111111111111111'), :transaction_source => 'recurring', :recurring => true)
+ end
+
def test_configured_logger_has_a_default
# The default is actually provided by the Braintree gem, but we
# assert its presence in order to show ActiveMerchant need not
From 1f9a7c59889bbe38ea35abdc196c66d8b8d99189 Mon Sep 17 00:00:00 2001
From: molbrown
Date: Fri, 7 Dec 2018 15:41:25 -0500
Subject: [PATCH 0248/2234] Blue Snap: Supports Level 2/3 data
Adds fields to enable Level 2/ Level 3 data, with existing
Nokogiri-Builder request structure for this gateway.
ENE-61
Unit:
19 tests, 73 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
26 tests, 76 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
92.3077% passed
- Unrelated failures, caused by updated error messages and store functionality.
Closes #3122
---
CHANGELOG | 1 +
.../billing/gateways/blue_snap.rb | 35 +++++++++++++
test/remote/gateways/remote_blue_snap_test.rb | 52 +++++++++++++++++++
3 files changed, 88 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index 1ed5e07cbda..edd0b49843d 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -13,6 +13,7 @@
* Orbital: Support for stored credentials framework [jknipp] #3117
* Openpay: Fix for marking successful transaction(s) as failed [jknipp] #3121
* Braintree: Adds support for transaction_source [molbrown] #3120
+* Blue Snap: Supports Level 2/3 data [molbrown] #3122
== Version 1.90.0 (January 8, 2019)
* Mercado Pago: Support "gateway" processing mode [curiousepic] #3087
diff --git a/lib/active_merchant/billing/gateways/blue_snap.rb b/lib/active_merchant/billing/gateways/blue_snap.rb
index 8c55f6910b7..0a94f2ecfb8 100644
--- a/lib/active_merchant/billing/gateways/blue_snap.rb
+++ b/lib/active_merchant/billing/gateways/blue_snap.rb
@@ -191,6 +191,7 @@ def add_order(doc, options)
doc.send('merchant-transaction-id', truncate(options[:order_id], 50)) if options[:order_id]
doc.send('soft-descriptor', options[:soft_descriptor]) if options[:soft_descriptor]
add_description(doc, options[:description]) if options[:description]
+ add_level_3_data(doc, options)
end
def add_address(doc, options)
@@ -204,6 +205,40 @@ def add_address(doc, options)
doc.zip(address[:zip]) if address[:zip]
end
+ def add_level_3_data(doc, options)
+ doc.send('level-3-data') do
+ send_when_present(doc, :customer_reference_number, options)
+ send_when_present(doc, :sales_tax_amount, options)
+ send_when_present(doc, :freight_amount, options)
+ send_when_present(doc, :duty_amount, options)
+ send_when_present(doc, :destination_zip_code, options)
+ send_when_present(doc, :destination_country_code, options)
+ send_when_present(doc, :ship_from_zip_code, options)
+ send_when_present(doc, :discount_amount, options)
+ send_when_present(doc, :tax_amount, options)
+ send_when_present(doc, :tax_rate, options)
+ add_level_3_data_items(doc, options[:level_3_data_items]) if options[:level_3_data_items]
+ end
+ end
+
+ def send_when_present(doc, options_key, options, xml_element_name = nil)
+ return unless options[options_key]
+ xml_element_name ||= options_key.to_s
+
+ doc.send(xml_element_name.dasherize, options[options_key])
+ end
+
+ def add_level_3_data_items(doc, items)
+ items.each do |item|
+ doc.send('level-3-data-item') do
+ item.each do |key, value|
+ key = key.to_s.dasherize
+ doc.send(key, value)
+ end
+ end
+ end
+ end
+
def add_authorization(doc, authorization)
doc.send('transaction-id', authorization)
end
diff --git a/test/remote/gateways/remote_blue_snap_test.rb b/test/remote/gateways/remote_blue_snap_test.rb
index 8f3604241a5..0258e313994 100644
--- a/test/remote/gateways/remote_blue_snap_test.rb
+++ b/test/remote/gateways/remote_blue_snap_test.rb
@@ -44,6 +44,58 @@ def test_successful_purchase_with_currency
assert_equal 'CAD', response.params['currency']
end
+ def test_successful_purchase_with_level3_data
+ l_three_visa = credit_card('4111111111111111', month: 2, year: 2023)
+ options = @options.merge({
+ customer_reference_number: '1234A',
+ sales_tax_amount: 0.6,
+ freight_amount: 0,
+ duty_amount: 0,
+ destination_zip_code: 12345,
+ destination_country_code: 'us',
+ ship_from_zip_code: 12345,
+ discount_amount: 0,
+ tax_amount: 0.6,
+ tax_rate: 6.0,
+ level_3_data_items: [
+ {
+ line_item_total: 9.00,
+ description: 'test_desc',
+ product_code: 'test_code',
+ item_quantity: 1.0,
+ tax_rate: 6.0,
+ tax_amount: 0.60,
+ unit_of_measure: 'lb',
+ commodity_code: 123,
+ discount_indicator: 'Y',
+ gross_net_indicator: 'Y',
+ tax_type: 'test',
+ unit_cost: 10.00
+ },
+ {
+ line_item_total: 9.00,
+ description: 'test_2',
+ product_code: 'test_2',
+ item_quantity: 1.0,
+ tax_rate: 7.0,
+ tax_amount: 0.70,
+ unit_of_measure: 'lb',
+ commodity_code: 123,
+ discount_indicator: 'Y',
+ gross_net_indicator: 'Y',
+ tax_type: 'test',
+ unit_cost: 14.00
+ }
+ ]
+ })
+ response = @gateway.purchase(@amount, l_three_visa, options)
+
+ assert_success response
+ assert_equal 'Success', response.message
+ assert_equal '1234A', response.params['customer-reference-number']
+ assert_equal '9', response.params['line-item-total']
+ end
+
def test_failed_purchase
response = @gateway.purchase(@amount, @declined_card, @options)
assert_failure response
From 1eac0b3bfab97816aeec0d81c8033d665c6acf25 Mon Sep 17 00:00:00 2001
From: David Santoso
Date: Tue, 22 Jan 2019 14:39:18 -0500
Subject: [PATCH 0249/2234] Moneris: Remove redundant card on file guard clause
This removes the @cof_enabled instance variable set in the gateway's
initializer. At various points within the adapter it's referenced as a
guard clause to adding card on file (stored credential) fields, however
the method to add those specific fields are guarded themselves by the
presence of specific keys with the options parameters making the
instance variable itself redundant.
Unit:
37 tests, 188 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
31 tests, 123 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Closes #3123
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/moneris.rb | 7 +++----
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index edd0b49843d..9fbcccad2c6 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -14,6 +14,7 @@
* Openpay: Fix for marking successful transaction(s) as failed [jknipp] #3121
* Braintree: Adds support for transaction_source [molbrown] #3120
* Blue Snap: Supports Level 2/3 data [molbrown] #3122
+* Moneris: Remove redundant card on file guard clause [davidsantoso] #3123
== Version 1.90.0 (January 8, 2019)
* Mercado Pago: Support "gateway" processing mode [curiousepic] #3087
diff --git a/lib/active_merchant/billing/gateways/moneris.rb b/lib/active_merchant/billing/gateways/moneris.rb
index 9410a306b0a..f17f0e28acd 100644
--- a/lib/active_merchant/billing/gateways/moneris.rb
+++ b/lib/active_merchant/billing/gateways/moneris.rb
@@ -33,7 +33,6 @@ def initialize(options = {})
requires!(options, :login, :password)
@cvv_enabled = options[:cvv_enabled]
@avs_enabled = options[:avs_enabled]
- @cof_enabled = options[:cof_enabled]
options[:crypt_type] = 7 unless options.has_key?(:crypt_type)
super
end
@@ -51,7 +50,7 @@ def authorize(money, creditcard_or_datakey, options = {})
post[:order_id] = options[:order_id]
post[:address] = options[:billing_address] || options[:address]
post[:crypt_type] = options[:crypt_type] || @options[:crypt_type]
- add_cof(post, options) if @cof_enabled
+ add_cof(post, options)
action = if post[:cavv]
'cavv_preauth'
elsif post[:data_key].blank?
@@ -74,7 +73,7 @@ def purchase(money, creditcard_or_datakey, options = {})
post[:order_id] = options[:order_id]
post[:address] = options[:billing_address] || options[:address]
post[:crypt_type] = options[:crypt_type] || @options[:crypt_type]
- add_cof(post, options) if @cof_enabled
+ add_cof(post, options)
action = if post[:cavv]
'cavv_purchase'
elsif post[:data_key].blank?
@@ -293,7 +292,7 @@ def transaction_element(action, parameters)
when :cvd_info
transaction.add_element(cvd_element(parameters[:cvd_value])) if @cvv_enabled
when :cof_info
- transaction.add_element(credential_on_file(parameters)) if @cof_enabled && cof_details_present?(parameters)
+ transaction.add_element(credential_on_file(parameters)) if cof_details_present?(parameters)
else
transaction.add_element(key.to_s).text = parameters[key] unless parameters[key].blank?
end
From bcb1246c232ef97a4b9c615f75a2e34a23a0a1bf Mon Sep 17 00:00:00 2001
From: molbrown
Date: Wed, 23 Jan 2019 16:02:26 -0500
Subject: [PATCH 0250/2234] Revert 'Blue Snap: Supports Level 2/3 data'
---
CHANGELOG | 1 -
.../billing/gateways/blue_snap.rb | 35 -------------
test/remote/gateways/remote_blue_snap_test.rb | 52 -------------------
3 files changed, 88 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 9fbcccad2c6..3adbba2e8e1 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -13,7 +13,6 @@
* Orbital: Support for stored credentials framework [jknipp] #3117
* Openpay: Fix for marking successful transaction(s) as failed [jknipp] #3121
* Braintree: Adds support for transaction_source [molbrown] #3120
-* Blue Snap: Supports Level 2/3 data [molbrown] #3122
* Moneris: Remove redundant card on file guard clause [davidsantoso] #3123
== Version 1.90.0 (January 8, 2019)
diff --git a/lib/active_merchant/billing/gateways/blue_snap.rb b/lib/active_merchant/billing/gateways/blue_snap.rb
index 0a94f2ecfb8..8c55f6910b7 100644
--- a/lib/active_merchant/billing/gateways/blue_snap.rb
+++ b/lib/active_merchant/billing/gateways/blue_snap.rb
@@ -191,7 +191,6 @@ def add_order(doc, options)
doc.send('merchant-transaction-id', truncate(options[:order_id], 50)) if options[:order_id]
doc.send('soft-descriptor', options[:soft_descriptor]) if options[:soft_descriptor]
add_description(doc, options[:description]) if options[:description]
- add_level_3_data(doc, options)
end
def add_address(doc, options)
@@ -205,40 +204,6 @@ def add_address(doc, options)
doc.zip(address[:zip]) if address[:zip]
end
- def add_level_3_data(doc, options)
- doc.send('level-3-data') do
- send_when_present(doc, :customer_reference_number, options)
- send_when_present(doc, :sales_tax_amount, options)
- send_when_present(doc, :freight_amount, options)
- send_when_present(doc, :duty_amount, options)
- send_when_present(doc, :destination_zip_code, options)
- send_when_present(doc, :destination_country_code, options)
- send_when_present(doc, :ship_from_zip_code, options)
- send_when_present(doc, :discount_amount, options)
- send_when_present(doc, :tax_amount, options)
- send_when_present(doc, :tax_rate, options)
- add_level_3_data_items(doc, options[:level_3_data_items]) if options[:level_3_data_items]
- end
- end
-
- def send_when_present(doc, options_key, options, xml_element_name = nil)
- return unless options[options_key]
- xml_element_name ||= options_key.to_s
-
- doc.send(xml_element_name.dasherize, options[options_key])
- end
-
- def add_level_3_data_items(doc, items)
- items.each do |item|
- doc.send('level-3-data-item') do
- item.each do |key, value|
- key = key.to_s.dasherize
- doc.send(key, value)
- end
- end
- end
- end
-
def add_authorization(doc, authorization)
doc.send('transaction-id', authorization)
end
diff --git a/test/remote/gateways/remote_blue_snap_test.rb b/test/remote/gateways/remote_blue_snap_test.rb
index 0258e313994..8f3604241a5 100644
--- a/test/remote/gateways/remote_blue_snap_test.rb
+++ b/test/remote/gateways/remote_blue_snap_test.rb
@@ -44,58 +44,6 @@ def test_successful_purchase_with_currency
assert_equal 'CAD', response.params['currency']
end
- def test_successful_purchase_with_level3_data
- l_three_visa = credit_card('4111111111111111', month: 2, year: 2023)
- options = @options.merge({
- customer_reference_number: '1234A',
- sales_tax_amount: 0.6,
- freight_amount: 0,
- duty_amount: 0,
- destination_zip_code: 12345,
- destination_country_code: 'us',
- ship_from_zip_code: 12345,
- discount_amount: 0,
- tax_amount: 0.6,
- tax_rate: 6.0,
- level_3_data_items: [
- {
- line_item_total: 9.00,
- description: 'test_desc',
- product_code: 'test_code',
- item_quantity: 1.0,
- tax_rate: 6.0,
- tax_amount: 0.60,
- unit_of_measure: 'lb',
- commodity_code: 123,
- discount_indicator: 'Y',
- gross_net_indicator: 'Y',
- tax_type: 'test',
- unit_cost: 10.00
- },
- {
- line_item_total: 9.00,
- description: 'test_2',
- product_code: 'test_2',
- item_quantity: 1.0,
- tax_rate: 7.0,
- tax_amount: 0.70,
- unit_of_measure: 'lb',
- commodity_code: 123,
- discount_indicator: 'Y',
- gross_net_indicator: 'Y',
- tax_type: 'test',
- unit_cost: 14.00
- }
- ]
- })
- response = @gateway.purchase(@amount, l_three_visa, options)
-
- assert_success response
- assert_equal 'Success', response.message
- assert_equal '1234A', response.params['customer-reference-number']
- assert_equal '9', response.params['line-item-total']
- end
-
def test_failed_purchase
response = @gateway.purchase(@amount, @declined_card, @options)
assert_failure response
From 634cc988b1bed7682261400a5cb819f2c4c59756 Mon Sep 17 00:00:00 2001
From: David Santoso
Date: Thu, 24 Jan 2019 11:28:37 -0500
Subject: [PATCH 0251/2234] Update Moneris tests to reflect the removal of an
initializer
---
test/remote/gateways/remote_moneris_test.rb | 8 ++++----
test/unit/gateways/moneris_test.rb | 2 --
2 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/test/remote/gateways/remote_moneris_test.rb b/test/remote/gateways/remote_moneris_test.rb
index 1e4308bc62d..50a36e13d26 100644
--- a/test/remote/gateways/remote_moneris_test.rb
+++ b/test/remote/gateways/remote_moneris_test.rb
@@ -22,7 +22,7 @@ def test_successful_purchase
end
def test_successful_first_purchase_with_credential_on_file
- gateway = MonerisGateway.new(fixtures(:moneris).merge(cof_enabled: true))
+ gateway = MonerisGateway.new(fixtures(:moneris))
assert response = gateway.purchase(@amount, @credit_card, @options.merge(issuer_id: '', payment_indicator: 'C', payment_information: '0'))
assert_success response
assert_equal 'Approved', response.message
@@ -31,7 +31,7 @@ def test_successful_first_purchase_with_credential_on_file
end
def test_successful_purchase_with_cof_enabled_and_no_cof_options
- gateway = MonerisGateway.new(fixtures(:moneris).merge(cof_enabled: true))
+ gateway = MonerisGateway.new(fixtures(:moneris))
assert response = gateway.purchase(@amount, @credit_card, @options)
assert_success response
assert_equal 'Approved', response.message
@@ -39,7 +39,7 @@ def test_successful_purchase_with_cof_enabled_and_no_cof_options
end
def test_successful_non_cof_purchase_with_cof_enabled_and_only_issuer_id_sent
- gateway = MonerisGateway.new(fixtures(:moneris).merge(cof_enabled: true))
+ gateway = MonerisGateway.new(fixtures(:moneris))
assert response = gateway.purchase(@amount, @credit_card, @options.merge(issuer_id: ''))
assert_success response
assert_equal 'Approved', response.message
@@ -48,7 +48,7 @@ def test_successful_non_cof_purchase_with_cof_enabled_and_only_issuer_id_sent
end
def test_successful_subsequent_purchase_with_credential_on_file
- gateway = MonerisGateway.new(fixtures(:moneris).merge(cof_enabled: true))
+ gateway = MonerisGateway.new(fixtures(:moneris))
assert response = gateway.authorize(
@amount,
@credit_card,
diff --git a/test/unit/gateways/moneris_test.rb b/test/unit/gateways/moneris_test.rb
index f1cdffd5488..6db462a335d 100644
--- a/test/unit/gateways/moneris_test.rb
+++ b/test/unit/gateways/moneris_test.rb
@@ -34,7 +34,6 @@ def test_successful_first_purchase_with_credential_on_file
gateway = MonerisGateway.new(
:login => 'store3',
:password => 'yesguy',
- :cof_enabled => true
)
gateway.expects(:ssl_post).returns(successful_first_cof_purchase_response)
assert response = gateway.purchase(
@@ -56,7 +55,6 @@ def test_successful_subsequent_purchase_with_credential_on_file
gateway = MonerisGateway.new(
:login => 'store3',
:password => 'yesguy',
- :cof_enabled => true
)
gateway.expects(:ssl_post).returns(successful_first_cof_authorize_response)
assert response = gateway.authorize(
From 069c81854ce8ec03b131245c5f31cbaa8c4400a1 Mon Sep 17 00:00:00 2001
From: molbrown
Date: Fri, 25 Jan 2019 09:48:33 -0500
Subject: [PATCH 0252/2234] Rubocop: Style/TrailingCommaInArguments
---
test/unit/gateways/moneris_test.rb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/unit/gateways/moneris_test.rb b/test/unit/gateways/moneris_test.rb
index 6db462a335d..cf1ece63e0b 100644
--- a/test/unit/gateways/moneris_test.rb
+++ b/test/unit/gateways/moneris_test.rb
@@ -33,7 +33,7 @@ def test_successful_purchase
def test_successful_first_purchase_with_credential_on_file
gateway = MonerisGateway.new(
:login => 'store3',
- :password => 'yesguy',
+ :password => 'yesguy'
)
gateway.expects(:ssl_post).returns(successful_first_cof_purchase_response)
assert response = gateway.purchase(
@@ -54,7 +54,7 @@ def test_successful_first_purchase_with_credential_on_file
def test_successful_subsequent_purchase_with_credential_on_file
gateway = MonerisGateway.new(
:login => 'store3',
- :password => 'yesguy',
+ :password => 'yesguy'
)
gateway.expects(:ssl_post).returns(successful_first_cof_authorize_response)
assert response = gateway.authorize(
From e47a5a9d422ea3b897170a87b641def47d5ab153 Mon Sep 17 00:00:00 2001
From: molbrown
Date: Fri, 25 Jan 2019 10:26:34 -0500
Subject: [PATCH 0253/2234] Switch order of Romania country codes
ROU is more current country code than ROM. Switched order so ROU is
populated over ROM, but Romania values can still be accessed via ROM
code.
ECS-120
Unit tests:
13 tests, 27 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Closes #3125
---
CHANGELOG | 1 +
lib/active_merchant/country.rb | 2 +-
test/unit/country_test.rb | 6 ++++++
3 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 3adbba2e8e1..289ef69618c 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -14,6 +14,7 @@
* Openpay: Fix for marking successful transaction(s) as failed [jknipp] #3121
* Braintree: Adds support for transaction_source [molbrown] #3120
* Moneris: Remove redundant card on file guard clause [davidsantoso] #3123
+* Switch order of Romania country codes [molbrown] #3125
== Version 1.90.0 (January 8, 2019)
* Mercado Pago: Support "gateway" processing mode [curiousepic] #3087
diff --git a/lib/active_merchant/country.rb b/lib/active_merchant/country.rb
index bdc25799900..e6db5cb3e28 100644
--- a/lib/active_merchant/country.rb
+++ b/lib/active_merchant/country.rb
@@ -245,8 +245,8 @@ def to_s
{ alpha2: 'PR', name: 'Puerto Rico', alpha3: 'PRI', numeric: '630' },
{ alpha2: 'QA', name: 'Qatar', alpha3: 'QAT', numeric: '634' },
{ alpha2: 'RE', name: 'Reunion', alpha3: 'REU', numeric: '638' },
- { alpha2: 'RO', name: 'Romania', alpha3: 'ROM', numeric: '642' },
{ alpha2: 'RO', name: 'Romania', alpha3: 'ROU', numeric: '642' },
+ { alpha2: 'RO', name: 'Romania', alpha3: 'ROM', numeric: '642' },
{ alpha2: 'RU', name: 'Russian Federation', alpha3: 'RUS', numeric: '643' },
{ alpha2: 'RW', name: 'Rwanda', alpha3: 'RWA', numeric: '646' },
{ alpha2: 'BL', name: 'Saint Barthélemy', alpha3: 'BLM', numeric: '652' },
diff --git a/test/unit/country_test.rb b/test/unit/country_test.rb
index d9dcae71b07..6251e6fa095 100644
--- a/test/unit/country_test.rb
+++ b/test/unit/country_test.rb
@@ -65,6 +65,12 @@ def test_find_romania
country = ActiveMerchant::Country.find('ROU')
assert_equal 'RO', country.code(:alpha2).value
+
+ country = ActiveMerchant::Country.find('Romania')
+ assert_equal 'ROU', country.code(:alpha3).value
+
+ country = ActiveMerchant::Country.find('Romania')
+ assert_not_equal 'ROM', country.code(:alpha3).value
end
def test_raise_on_nil_name
From b66b0908c6f73105b1b095515f73f3d1e0497911 Mon Sep 17 00:00:00 2001
From: molbrown
Date: Wed, 23 Jan 2019 17:05:42 -0500
Subject: [PATCH 0254/2234] Blue Snap: Supports Level 2/3 data
Adds fields to enable Level 2/ Level 3 data, with existing
Nokogiri-Builder request structure for this gateway.
ECS-61
Unit:
20 tests, 76 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
26 tests, 76 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
92.3077% passed
Unrelated failures, caused by updated error messages and store functionality.
Closes #3126
---
CHANGELOG | 1 +
.../billing/gateways/blue_snap.rb | 36 +++++++++++++
test/remote/gateways/remote_blue_snap_test.rb | 52 +++++++++++++++++++
test/unit/gateways/blue_snap_test.rb | 9 ++++
4 files changed, 98 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index 289ef69618c..2b8c2df49b2 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -15,6 +15,7 @@
* Braintree: Adds support for transaction_source [molbrown] #3120
* Moneris: Remove redundant card on file guard clause [davidsantoso] #3123
* Switch order of Romania country codes [molbrown] #3125
+* Blue Snap: Supports Level 2/3 data [molbrown] #3126
== Version 1.90.0 (January 8, 2019)
* Mercado Pago: Support "gateway" processing mode [curiousepic] #3087
diff --git a/lib/active_merchant/billing/gateways/blue_snap.rb b/lib/active_merchant/billing/gateways/blue_snap.rb
index 8c55f6910b7..a76f5338b72 100644
--- a/lib/active_merchant/billing/gateways/blue_snap.rb
+++ b/lib/active_merchant/billing/gateways/blue_snap.rb
@@ -191,6 +191,7 @@ def add_order(doc, options)
doc.send('merchant-transaction-id', truncate(options[:order_id], 50)) if options[:order_id]
doc.send('soft-descriptor', options[:soft_descriptor]) if options[:soft_descriptor]
add_description(doc, options[:description]) if options[:description]
+ add_level_3_data(doc, options)
end
def add_address(doc, options)
@@ -204,6 +205,41 @@ def add_address(doc, options)
doc.zip(address[:zip]) if address[:zip]
end
+ def add_level_3_data(doc, options)
+ return unless options[:customer_reference_number]
+ doc.send('level-3-data') do
+ send_when_present(doc, :customer_reference_number, options)
+ send_when_present(doc, :sales_tax_amount, options)
+ send_when_present(doc, :freight_amount, options)
+ send_when_present(doc, :duty_amount, options)
+ send_when_present(doc, :destination_zip_code, options)
+ send_when_present(doc, :destination_country_code, options)
+ send_when_present(doc, :ship_from_zip_code, options)
+ send_when_present(doc, :discount_amount, options)
+ send_when_present(doc, :tax_amount, options)
+ send_when_present(doc, :tax_rate, options)
+ add_level_3_data_items(doc, options[:level_3_data_items]) if options[:level_3_data_items]
+ end
+ end
+
+ def send_when_present(doc, options_key, options, xml_element_name = nil)
+ return unless options[options_key]
+ xml_element_name ||= options_key.to_s
+
+ doc.send(xml_element_name.dasherize, options[options_key])
+ end
+
+ def add_level_3_data_items(doc, items)
+ items.each do |item|
+ doc.send('level-3-data-item') do
+ item.each do |key, value|
+ key = key.to_s.dasherize
+ doc.send(key, value)
+ end
+ end
+ end
+ end
+
def add_authorization(doc, authorization)
doc.send('transaction-id', authorization)
end
diff --git a/test/remote/gateways/remote_blue_snap_test.rb b/test/remote/gateways/remote_blue_snap_test.rb
index 8f3604241a5..0258e313994 100644
--- a/test/remote/gateways/remote_blue_snap_test.rb
+++ b/test/remote/gateways/remote_blue_snap_test.rb
@@ -44,6 +44,58 @@ def test_successful_purchase_with_currency
assert_equal 'CAD', response.params['currency']
end
+ def test_successful_purchase_with_level3_data
+ l_three_visa = credit_card('4111111111111111', month: 2, year: 2023)
+ options = @options.merge({
+ customer_reference_number: '1234A',
+ sales_tax_amount: 0.6,
+ freight_amount: 0,
+ duty_amount: 0,
+ destination_zip_code: 12345,
+ destination_country_code: 'us',
+ ship_from_zip_code: 12345,
+ discount_amount: 0,
+ tax_amount: 0.6,
+ tax_rate: 6.0,
+ level_3_data_items: [
+ {
+ line_item_total: 9.00,
+ description: 'test_desc',
+ product_code: 'test_code',
+ item_quantity: 1.0,
+ tax_rate: 6.0,
+ tax_amount: 0.60,
+ unit_of_measure: 'lb',
+ commodity_code: 123,
+ discount_indicator: 'Y',
+ gross_net_indicator: 'Y',
+ tax_type: 'test',
+ unit_cost: 10.00
+ },
+ {
+ line_item_total: 9.00,
+ description: 'test_2',
+ product_code: 'test_2',
+ item_quantity: 1.0,
+ tax_rate: 7.0,
+ tax_amount: 0.70,
+ unit_of_measure: 'lb',
+ commodity_code: 123,
+ discount_indicator: 'Y',
+ gross_net_indicator: 'Y',
+ tax_type: 'test',
+ unit_cost: 14.00
+ }
+ ]
+ })
+ response = @gateway.purchase(@amount, l_three_visa, options)
+
+ assert_success response
+ assert_equal 'Success', response.message
+ assert_equal '1234A', response.params['customer-reference-number']
+ assert_equal '9', response.params['line-item-total']
+ end
+
def test_failed_purchase
response = @gateway.purchase(@amount, @declined_card, @options)
assert_failure response
diff --git a/test/unit/gateways/blue_snap_test.rb b/test/unit/gateways/blue_snap_test.rb
index 444e43832af..d7b00a50b08 100644
--- a/test/unit/gateways/blue_snap_test.rb
+++ b/test/unit/gateways/blue_snap_test.rb
@@ -150,6 +150,15 @@ def test_failed_forbidden_response
assert_equal 'You are not authorized to perform this request due to inappropriate role permissions.', response.message
end
+ def test_does_not_send_level_3_when_empty
+ response = stub_comms(@gateway, :raw_ssl_request) do
+ @gateway.purchase(@amount, @credit_card, @options)
+ end.check_request do |type, endpoint, data, headers|
+ assert_not_match(/level-3-data/, data)
+ end.respond_with(successful_purchase_response)
+ assert_success response
+ end
+
def test_scrub
assert @gateway.supports_scrubbing?
assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed
From 6e322292315723305dfca9f5b817634e56db9926 Mon Sep 17 00:00:00 2001
From: Jared Knipp
Date: Tue, 29 Jan 2019 17:01:17 -0600
Subject: [PATCH 0255/2234] BlueSnap: Support personal_identification_number
Add support for GSF personal_identification_number, which is required
for transactions in Brazil.
Expand supported countries to include LATAM countries supported by Blue
Snap.
ECS-110
Unit:
19 tests, 74 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
25 tests, 74 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Closes #3128
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/blue_snap.rb | 3 ++-
test/remote/gateways/remote_blue_snap_test.rb | 12 +++++++-----
test/unit/gateways/blue_snap_test.rb | 10 +++++++++-
4 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 2b8c2df49b2..f005add0f28 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -16,6 +16,7 @@
* Moneris: Remove redundant card on file guard clause [davidsantoso] #3123
* Switch order of Romania country codes [molbrown] #3125
* Blue Snap: Supports Level 2/3 data [molbrown] #3126
+* Blue Snap: Support personal_identification_number [jknipp] #3128
== Version 1.90.0 (January 8, 2019)
* Mercado Pago: Support "gateway" processing mode [curiousepic] #3087
diff --git a/lib/active_merchant/billing/gateways/blue_snap.rb b/lib/active_merchant/billing/gateways/blue_snap.rb
index a76f5338b72..5fb0996c987 100644
--- a/lib/active_merchant/billing/gateways/blue_snap.rb
+++ b/lib/active_merchant/billing/gateways/blue_snap.rb
@@ -5,7 +5,7 @@ module Billing
class BlueSnapGateway < Gateway
self.test_url = 'https://sandbox.bluesnap.com/services/2'
self.live_url = 'https://ws.bluesnap.com/services/2'
- self.supported_countries = %w(US CA GB AT BE BG HR CY CZ DK EE FI FR DE GR HU IE IT LV LT LU MT NL PL PT RO SK SI ES SE)
+ self.supported_countries = %w(US CA GB AT BE BG HR CY CZ DK EE FI FR DE GR HU IE IT LV LT LU MT NL PL PT RO SK SI ES SE AR BO BR BZ CL CO CR DO EC GF GP GT HN HT MF MQ MX NI PA PE PR PY SV UY VE)
self.default_currency = 'USD'
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners_club, :maestro]
@@ -164,6 +164,7 @@ def add_amount(doc, money, options)
def add_personal_info(doc, credit_card, options)
doc.send('first-name', credit_card.first_name)
doc.send('last-name', credit_card.last_name)
+ doc.send('personal-identification-number', options[:personal_identification_number]) if options[:personal_identification_number]
doc.email(options[:email]) if options[:email]
add_address(doc, options)
end
diff --git a/test/remote/gateways/remote_blue_snap_test.rb b/test/remote/gateways/remote_blue_snap_test.rb
index 0258e313994..f24a5194a18 100644
--- a/test/remote/gateways/remote_blue_snap_test.rb
+++ b/test/remote/gateways/remote_blue_snap_test.rb
@@ -7,6 +7,7 @@ def setup
@amount = 100
@credit_card = credit_card('4263982640269299')
@declined_card = credit_card('4917484589897107', month: 1, year: 2023)
+ @invalid_card = credit_card('4917484589897106', month: 1, year: 2023)
@options = { billing_address: address }
end
@@ -28,7 +29,8 @@ def test_successful_purchase_with_more_options
ip: '127.0.0.1',
email: 'joe@example.com',
description: 'Product Description',
- soft_descriptor: 'OnCardStatement'
+ soft_descriptor: 'OnCardStatement',
+ personal_identification_number: 'CNPJ'
})
response = @gateway.purchase(@amount, @credit_card, more_options)
@@ -193,7 +195,7 @@ def test_successful_verify
def test_failed_verify
response = @gateway.verify(@declined_card, @options)
assert_failure response
- assert_match(/Authorization has failed for this transaction/, response.message)
+ assert_match(/Transaction failed because of payment processing failure/, response.message)
end
def test_successful_store
@@ -208,11 +210,11 @@ def test_successful_store
end
def test_failed_store
- assert response = @gateway.store(@declined_card, @options)
+ assert response = @gateway.store(@invalid_card, @options)
assert_failure response
- assert_match(/Transaction failed because of payment processing failure/, response.message)
- assert_equal '14002', response.error_code
+ assert_match(/'Card Number' should be a valid Credit Card/, response.message)
+ assert_equal '10001', response.error_code
end
def test_successful_purchase_using_stored_card
diff --git a/test/unit/gateways/blue_snap_test.rb b/test/unit/gateways/blue_snap_test.rb
index d7b00a50b08..b4fa22c495c 100644
--- a/test/unit/gateways/blue_snap_test.rb
+++ b/test/unit/gateways/blue_snap_test.rb
@@ -7,7 +7,7 @@ def setup
@gateway = BlueSnapGateway.new(api_username: 'login', api_password: 'password')
@credit_card = credit_card
@amount = 100
- @options = { order_id: '1' }
+ @options = { order_id: '1', personal_identification_number: 'CNPJ' }
end
def test_successful_purchase
@@ -31,6 +31,7 @@ def test_successful_authorize
@gateway.authorize(@amount, @credit_card, @options)
end.check_request do |type, endpoint, data, headers|
assert_match 'false', data
+ assert_match 'CNPJ', data
end.respond_with(successful_authorize_response)
assert_success response
assert_equal '1012082893', response.authorization
@@ -211,6 +212,7 @@ def successful_purchase_response
ON
Ottawa
K1C2N6
+ CNPJ
9299
@@ -260,6 +262,7 @@ def successful_authorize_response
ON
Ottawa
K1C2N6
+ CNPJ
9299
@@ -308,6 +311,7 @@ def successful_capture_response
ON
Ottawa
K1C2N6
+ CNPJ
9299
@@ -356,6 +360,7 @@ def successful_refund_response
ON
Ottawa
K1C2N6
+ CNPJ
9299
@@ -404,6 +409,7 @@ def successful_void_response
ON
Ottawa
K1C2N6
+ CNPJ
9299
@@ -452,6 +458,7 @@ def successful_verify_response
ON
Ottawa
K1C2N6
+ CNPJ
9299
@@ -493,6 +500,7 @@ def successful_store_response
ON
Ottawa
K1C2N6
+ CNPJ
USD
From 1c10a218aebdce9dccc3bc201dd306036e031f44 Mon Sep 17 00:00:00 2001
From: molbrown
Date: Wed, 30 Jan 2019 15:57:33 -0500
Subject: [PATCH 0256/2234] ProPay: Send 9 digit zip code without dash
According to ProPay's docs, the dash should not be included for 9 digit
zip codes.
ECS-125
Unit:
17 tests, 71 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Closes #3129
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/pro_pay.rb | 2 +-
test/unit/gateways/pro_pay_test.rb | 11 ++++++++++-
3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index f005add0f28..eef22e024f0 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -17,6 +17,7 @@
* Switch order of Romania country codes [molbrown] #3125
* Blue Snap: Supports Level 2/3 data [molbrown] #3126
* Blue Snap: Support personal_identification_number [jknipp] #3128
+* ProPay: Send 9 digit zip code without dash [molbrown] #3129
== Version 1.90.0 (January 8, 2019)
* Mercado Pago: Support "gateway" processing mode [curiousepic] #3087
diff --git a/lib/active_merchant/billing/gateways/pro_pay.rb b/lib/active_merchant/billing/gateways/pro_pay.rb
index d70b1539bb0..dd286ad6fcb 100644
--- a/lib/active_merchant/billing/gateways/pro_pay.rb
+++ b/lib/active_merchant/billing/gateways/pro_pay.rb
@@ -234,7 +234,7 @@ def add_address(xml, options)
xml.aptNum address[:address2]
xml.city address[:city]
xml.state address[:state]
- xml.zip address[:zip]
+ xml.zip address[:zip].to_s.delete('-')
end
end
diff --git a/test/unit/gateways/pro_pay_test.rb b/test/unit/gateways/pro_pay_test.rb
index b6704553ff2..3064da173bd 100644
--- a/test/unit/gateways/pro_pay_test.rb
+++ b/test/unit/gateways/pro_pay_test.rb
@@ -1,5 +1,4 @@
require 'test_helper'
-
class ProPayTest < Test::Unit::TestCase
include CommStub
@@ -153,6 +152,16 @@ def test_scrub
assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed
end
+ def test_does_not_send_dashed_zip_code
+ options = @options.merge(billing_address: address.update(zip: '12345-3456'))
+
+ stub_comms do
+ @gateway.purchase(@amount, @credit_card, options)
+ end.check_request do |endpoint, data, headers|
+ assert_match(/123453456, data)
+ end.respond_with(successful_purchase_response)
+ end
+
private
def pre_scrubbed
From 72a6ed7076e1ac80092411ac811c63f3e498c18d Mon Sep 17 00:00:00 2001
From: Ruthan
Date: Tue, 29 Jan 2019 13:19:16 -0500
Subject: [PATCH 0257/2234] Append error messages to Cecabank response
---
lib/active_merchant/billing/gateways/cecabank.rb | 15 +++++++++++++--
test/unit/gateways/cecabank_test.rb | 1 +
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/cecabank.rb b/lib/active_merchant/billing/gateways/cecabank.rb
index 0b7cf8bc86d..ba73965d48a 100644
--- a/lib/active_merchant/billing/gateways/cecabank.rb
+++ b/lib/active_merchant/billing/gateways/cecabank.rb
@@ -173,13 +173,24 @@ def commit(action, parameters)
response = parse(xml)
Response.new(
response[:success],
- response[:message],
+ message_from(response),
response,
:test => test?,
- :authorization => build_authorization(response)
+ :authorization => build_authorization(response),
+ :error_code => response[:error_code]
)
end
+ def message_from(response)
+ if response[:message] == 'ERROR' && response[:error_message]
+ response[:error_message]
+ elsif response[:error_message]
+ "#{response[:message]} #{response[:error_message]}"
+ else
+ response[:message]
+ end
+ end
+
def post_data(params)
return nil unless params
diff --git a/test/unit/gateways/cecabank_test.rb b/test/unit/gateways/cecabank_test.rb
index f58aa10e620..87ad7e20ab5 100644
--- a/test/unit/gateways/cecabank_test.rb
+++ b/test/unit/gateways/cecabank_test.rb
@@ -53,6 +53,7 @@ def test_unsuccessful_request
assert response = @gateway.purchase(@amount, @credit_card, @options)
assert_failure response
+ assert_match(/Formato CVV2\/CVC2 no valido/, response.message)
assert response.test?
end
From 3c99c858834caa2b0f5d3da4e63178de8aac5b08 Mon Sep 17 00:00:00 2001
From: Ruthan
Date: Thu, 31 Jan 2019 10:55:40 -0500
Subject: [PATCH 0258/2234] Update changelog with #3127
---
CHANGELOG | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG b/CHANGELOG
index eef22e024f0..4a9af6731f2 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -18,6 +18,7 @@
* Blue Snap: Supports Level 2/3 data [molbrown] #3126
* Blue Snap: Support personal_identification_number [jknipp] #3128
* ProPay: Send 9 digit zip code without dash [molbrown] #3129
+* Cecabank: Append error text to message [therufs] #3127
== Version 1.90.0 (January 8, 2019)
* Mercado Pago: Support "gateway" processing mode [curiousepic] #3087
From 45d43b8aedb748f3e6aa3d3eaa36344a251cfe70 Mon Sep 17 00:00:00 2001
From: Ruthan
Date: Fri, 18 Jan 2019 11:04:54 -0500
Subject: [PATCH 0259/2234] Adyen: Map AVS codes
---
lib/active_merchant/billing/gateways/adyen.rb | 38 ++++++++++---------
test/unit/gateways/adyen_test.rb | 13 +++++++
2 files changed, 34 insertions(+), 17 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index bbb6e5f0e16..11ef131a4e0 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -110,24 +110,28 @@ def scrub(transcript)
AVS_MAPPING = {
'0' => 'R', # Unknown
- '1' => 'A', # Address matches, postal code doesn't
- '2' => 'N', # Neither postal code nor address match
- '3' => 'R', # AVS unavailable
- '4' => 'E', # AVS not supported for this card type
- '5' => 'U', # No AVS data provided
- '6' => 'Z', # Postal code matches, address doesn't match
- '7' => 'D', # Both postal code and address match
- '8' => 'U', # Address not checked, postal code unknown
- '9' => 'B', # Address matches, postal code unknown
- '10' => 'N', # Address doesn't match, postal code unknown
- '11' => 'U', # Postal code not checked, address unknown
- '12' => 'B', # Address matches, postal code not checked
- '13' => 'U', # Address doesn't match, postal code not checked
- '14' => 'P', # Postal code matches, address unknown
- '15' => 'P', # Postal code matches, address not checked
- '16' => 'N', # Postal code doesn't match, address unknown
+ '1' => 'A', # Address matches, postal code doesn't
+ '2' => 'N', # Neither postal code nor address match
+ '3' => 'R', # AVS unavailable
+ '4' => 'E', # AVS not supported for this card type
+ '5' => 'U', # No AVS data provided
+ '6' => 'Z', # Postal code matches, address doesn't match
+ '7' => 'D', # Both postal code and address match
+ '8' => 'U', # Address not checked, postal code unknown
+ '9' => 'B', # Address matches, postal code unknown
+ '10' => 'N', # Address doesn't match, postal code unknown
+ '11' => 'U', # Postal code not checked, address unknown
+ '12' => 'B', # Address matches, postal code not checked
+ '13' => 'U', # Address doesn't match, postal code not checked
+ '14' => 'P', # Postal code matches, address unknown
+ '15' => 'P', # Postal code matches, address not checked
+ '16' => 'N', # Postal code doesn't match, address unknown
'17' => 'U', # Postal code doesn't match, address not checked
- '18' => 'I' # Neither postal code nor address were checked
+ '18' => 'I', # Neither postal code nor address were checked
+ '20' => 'V', # Name, address and postal code matches.
+ '23' => 'F', # Postal code matches, name doesn't match.
+ '24' => 'H', # Both postal code and address matches, name doesn't match.
+ '25' => 'T' # Address matches, name doesn't match.
}
CVC_MAPPING = {
diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb
index 09b80f9ab76..3ebb510da71 100644
--- a/test/unit/gateways/adyen_test.rb
+++ b/test/unit/gateways/adyen_test.rb
@@ -295,6 +295,13 @@ def test_authorize_with_network_tokenization_credit_card
assert_success response
end
+ def test_extended_avs_response
+ response = stub_comms do
+ @gateway.verify(@credit_card, @options)
+ end.respond_with(extended_avs_response)
+ assert_equal 'Card member\'s name, billing address, and billing postal code match.', response.avs_result['message']
+ end
+
private
def pre_scrubbed
@@ -567,4 +574,10 @@ def failed_store_response
{"pspReference":"8835205393394754","refusalReason":"Refused","resultCode":"Refused"}
RESPONSE
end
+
+ def extended_avs_response
+ <<-RESPONSE
+ {\"additionalData\":{\"cvcResult\":\"1 Matches\",\"cvcResultRaw\":\"Y\",\"avsResult\":\"20 Name, address and zip match\",\"avsResultRaw\":\"M\"}}
+ RESPONSE
+ end
end
From cb3a1f7981c10e60dbeeb4094674861e915d7787 Mon Sep 17 00:00:00 2001
From: Ruthan
Date: Thu, 31 Jan 2019 14:31:03 -0500
Subject: [PATCH 0260/2234] Update changelog with #3119
---
CHANGELOG | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG b/CHANGELOG
index 4a9af6731f2..1d97d226680 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -19,6 +19,7 @@
* Blue Snap: Support personal_identification_number [jknipp] #3128
* ProPay: Send 9 digit zip code without dash [molbrown] #3129
* Cecabank: Append error text to message [therufs] #3127
+* Adyen: Extend AVS code mappings [therufs] #3119
== Version 1.90.0 (January 8, 2019)
* Mercado Pago: Support "gateway" processing mode [curiousepic] #3087
From 29995432677c7e54ec29d32a3964d8bf4406252e Mon Sep 17 00:00:00 2001
From: David Perry
Date: Thu, 31 Jan 2019 16:52:31 -0500
Subject: [PATCH 0261/2234] NMI: Add customer id to authorization on store
Previously authorizations for the store action were empty. Now we return
the relevant customer_vault_id as the authorization to use in subsequent
transactions.
Closes #3130
Remote:
34 tests, 110 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
27 tests, 195 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/nmi.rb | 10 ++++++----
test/remote/gateways/remote_nmi_test.rb | 11 +++++------
test/unit/gateways/nmi_test.rb | 3 ++-
4 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 1d97d226680..2cbdfef9655 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -20,6 +20,7 @@
* ProPay: Send 9 digit zip code without dash [molbrown] #3129
* Cecabank: Append error text to message [therufs] #3127
* Adyen: Extend AVS code mappings [therufs] #3119
+* NMI: Add customer id to authorization on store [curiousepic] #3130
== Version 1.90.0 (January 8, 2019)
* Mercado Pago: Support "gateway" processing mode [curiousepic] #3087
diff --git a/lib/active_merchant/billing/gateways/nmi.rb b/lib/active_merchant/billing/gateways/nmi.rb
index 17b4872e662..5b3c452e39f 100644
--- a/lib/active_merchant/billing/gateways/nmi.rb
+++ b/lib/active_merchant/billing/gateways/nmi.rb
@@ -144,7 +144,8 @@ def add_invoice(post, money, options)
def add_payment_method(post, payment_method, options)
if(payment_method.is_a?(String))
- post[:customer_vault_id] = payment_method
+ customer_vault_id, _ = split_authorization(payment_method)
+ post[:customer_vault_id] = customer_vault_id
elsif payment_method.is_a?(NetworkTokenizationCreditCard)
post[:ccnumber] = payment_method.number
post[:ccexp] = exp_date(payment_method)
@@ -236,15 +237,16 @@ def commit(action, params)
succeeded,
message_from(succeeded, response),
response,
- authorization: authorization_from(response, params[:payment]),
+ authorization: authorization_from(response, params[:payment], action),
avs_result: AVSResult.new(code: response[:avsresponse]),
cvv_result: CVVResult.new(response[:cvvresponse]),
test: test?
)
end
- def authorization_from(response, payment_type)
- [ response[:transactionid], payment_type ].join('#')
+ def authorization_from(response, payment_type, action)
+ authorization = (action == 'add_customer' ? response[:customer_vault_id] : response[:transactionid])
+ [ authorization, payment_type ].join('#')
end
def split_authorization(authorization)
diff --git a/test/remote/gateways/remote_nmi_test.rb b/test/remote/gateways/remote_nmi_test.rb
index 1515b496121..b4fbc9ff01a 100644
--- a/test/remote/gateways/remote_nmi_test.rb
+++ b/test/remote/gateways/remote_nmi_test.rb
@@ -202,39 +202,38 @@ def test_successful_store
response = @gateway.store(@credit_card, @options)
assert_success response
assert_equal 'Succeeded', response.message
- assert response.params['customer_vault_id']
+ assert response.authorization.include?(response.params['customer_vault_id'])
end
def test_failed_store
card = credit_card(year: 2010)
response = @gateway.store(card, @options)
assert_failure response
- assert_nil response.params['customer_vault_id']
end
def test_successful_store_with_echeck
response = @gateway.store(@check, @options)
assert_success response
assert_equal 'Succeeded', response.message
- assert response.params['customer_vault_id']
+ assert response.authorization.include?(response.params['customer_vault_id'])
end
def test_successful_store_and_purchase
- vault_id = @gateway.store(@credit_card, @options).params['customer_vault_id']
+ vault_id = @gateway.store(@credit_card, @options).authorization
purchase = @gateway.purchase(@amount, vault_id, @options)
assert_success purchase
assert_equal 'Succeeded', purchase.message
end
def test_successful_store_and_auth
- vault_id = @gateway.store(@credit_card, @options).params['customer_vault_id']
+ vault_id = @gateway.store(@credit_card, @options).authorization
auth = @gateway.authorize(@amount, vault_id, @options)
assert_success auth
assert_equal 'Succeeded', auth.message
end
def test_successful_store_and_credit
- vault_id = @gateway.store(@credit_card, @options).params['customer_vault_id']
+ vault_id = @gateway.store(@credit_card, @options).authorization
credit = @gateway.credit(@amount, vault_id, @options)
assert_success credit
assert_equal 'Succeeded', credit.message
diff --git a/test/unit/gateways/nmi_test.rb b/test/unit/gateways/nmi_test.rb
index f7f7d3c0030..5c0ee07d25c 100644
--- a/test/unit/gateways/nmi_test.rb
+++ b/test/unit/gateways/nmi_test.rb
@@ -272,6 +272,7 @@ def test_successful_store
assert response.test?
assert_equal 'Succeeded', response.message
assert response.params['customer_vault_id']
+ assert response.authorization.include?(response.params['customer_vault_id'])
end
def test_failed_store
@@ -303,7 +304,7 @@ def test_successful_store_with_echeck
assert_success response
assert response.test?
assert_equal 'Succeeded', response.message
- assert response.params['customer_vault_id']
+ assert response.authorization.include?(response.params['customer_vault_id'])
end
def test_avs_result
From 67259721a5c9e9bb78ecd014d1bc077568de3ac8 Mon Sep 17 00:00:00 2001
From: David Perry
Date: Fri, 1 Feb 2019 15:29:54 -0500
Subject: [PATCH 0262/2234] Trans First Express: Don't pass blank name field
Closes #3133
Remote (Failures probably due to changes to sandbox, relevant remote
test does pass):
34 tests, 83 assertions, 9 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
71.875% passed
Unit:
21 tests, 103 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../trans_first_transaction_express.rb | 6 ++---
...te_trans_first_transaction_express_test.rb | 26 +++++++++++++++++++
3 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 2cbdfef9655..27f6c3ea31b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -21,6 +21,7 @@
* Cecabank: Append error text to message [therufs] #3127
* Adyen: Extend AVS code mappings [therufs] #3119
* NMI: Add customer id to authorization on store [curiousepic] #3130
+* Trans First Express: Don't pass blank name field [curiousepic] #3133
== Version 1.90.0 (January 8, 2019)
* Mercado Pago: Support "gateway" processing mode [curiousepic] #3087
diff --git a/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb b/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb
index e9ac1ac2a9f..fe94ffe357b 100644
--- a/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb
+++ b/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb
@@ -532,7 +532,7 @@ def add_pan(doc, payment_method)
def add_contact(doc, fullname, options)
doc['v1'].contact do
- doc['v1'].fullName fullname
+ doc['v1'].fullName fullname unless fullname.blank?
doc['v1'].coName options[:company_name] if options[:company_name]
doc['v1'].title options[:title] if options[:title]
@@ -557,7 +557,7 @@ def add_contact(doc, fullname, options)
if (shipping_address = options[:shipping_address])
doc['v1'].ship do
- doc['v1'].fullName fullname
+ doc['v1'].fullName fullname unless fullname.blank?
doc['v1'].addrLn1 shipping_address[:address1] if shipping_address[:address1]
doc['v1'].addrLn2 shipping_address[:address2] if shipping_address[:address2]
doc['v1'].city shipping_address[:city] if shipping_address[:city]
@@ -572,7 +572,7 @@ def add_contact(doc, fullname, options)
def add_name(doc, payment_method)
doc['v1'].contact do
- doc['v1'].fullName payment_method.name
+ doc['v1'].fullName payment_method.name unless payment_method.name.blank?
end
end
diff --git a/test/remote/gateways/remote_trans_first_transaction_express_test.rb b/test/remote/gateways/remote_trans_first_transaction_express_test.rb
index 32f0f08a199..9a97eee54f0 100644
--- a/test/remote/gateways/remote_trans_first_transaction_express_test.rb
+++ b/test/remote/gateways/remote_trans_first_transaction_express_test.rb
@@ -109,6 +109,32 @@ def test_successful_purchase_with_empty_string_cvv
assert_equal 'Succeeded', response.message
end
+ def test_successful_purchase_without_name
+ credit_card_opts = {
+ :number => 4485896261017708,
+ :month => Date.new((Time.now.year + 1), 9, 30).month,
+ :year => Date.new((Time.now.year + 1), 9, 30).year,
+ :first_name => '',
+ :last_name => ''
+ }
+
+ credit_card = CreditCard.new(credit_card_opts)
+ response = @gateway.purchase(@amount, credit_card, @options)
+ assert_success response
+ assert_equal 'Succeeded', response.message
+
+ credit_card_opts = {
+ :number => 4485896261017708,
+ :month => Date.new((Time.now.year + 1), 9, 30).month,
+ :year => Date.new((Time.now.year + 1), 9, 30).year
+ }
+
+ credit_card = CreditCard.new(credit_card_opts)
+ response = @gateway.purchase(@amount, credit_card, @options)
+ assert_success response
+ assert_equal 'Succeeded', response.message
+ end
+
def test_successful_purchase_with_echeck
assert response = @gateway.purchase(@amount, @check, @options)
assert_success response
From 154cd4137aedc0acd077159c23f19acc7050a379 Mon Sep 17 00:00:00 2001
From: Jared Knipp
Date: Fri, 1 Feb 2019 13:45:03 -0600
Subject: [PATCH 0263/2234] TrustCommerce: Send full name on ACH transactions
Support sending full name for ACH transactions in require name field.
ECS-137
Unit:
10 tests, 35 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
16 tests, 59 assertions, 3 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
81.25% passed
closes #3132
---
CHANGELOG | 4 ++++
lib/active_merchant/billing/gateways/trust_commerce.rb | 1 +
test/unit/gateways/trust_commerce_test.rb | 1 +
3 files changed, 6 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index 27f6c3ea31b..df0e2aed84a 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -21,7 +21,11 @@
* Cecabank: Append error text to message [therufs] #3127
* Adyen: Extend AVS code mappings [therufs] #3119
* NMI: Add customer id to authorization on store [curiousepic] #3130
+<<<<<<< HEAD
* Trans First Express: Don't pass blank name field [curiousepic] #3133
+=======
+* TrustCommerce: Send full name on ACH transactions [jknipp] #3132
+>>>>>>> TrustCommerce: Send full name on ACH transactions
== Version 1.90.0 (January 8, 2019)
* Mercado Pago: Support "gateway" processing mode [curiousepic] #3087
diff --git a/lib/active_merchant/billing/gateways/trust_commerce.rb b/lib/active_merchant/billing/gateways/trust_commerce.rb
index 420178bca8a..767fe06ccb9 100644
--- a/lib/active_merchant/billing/gateways/trust_commerce.rb
+++ b/lib/active_merchant/billing/gateways/trust_commerce.rb
@@ -333,6 +333,7 @@ def add_check(params, check)
params[:routing] = check.routing_number
params[:account] = check.account_number
params[:savings] = 'y' if check.account_type == 'savings'
+ params[:name] = check.name
end
def add_creditcard(params, creditcard)
diff --git a/test/unit/gateways/trust_commerce_test.rb b/test/unit/gateways/trust_commerce_test.rb
index 467721f6f9f..9221ae96d46 100644
--- a/test/unit/gateways/trust_commerce_test.rb
+++ b/test/unit/gateways/trust_commerce_test.rb
@@ -37,6 +37,7 @@ def test_succesful_purchase_with_check
@gateway.purchase(@amount, @check)
end.check_request do |endpoint, data, headers|
assert_match(%r{aggregator1}, data)
+ assert_match(%r{name=Jim\+Smith}, data)
end.respond_with(successful_purchase_response)
end
From 58f9f15a8a818e9087f9c073659cb279e81053e3 Mon Sep 17 00:00:00 2001
From: Jared Knipp
Date: Fri, 1 Feb 2019 15:47:18 -0600
Subject: [PATCH 0264/2234] Fix Changelog
---
CHANGELOG | 3 ---
1 file changed, 3 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index df0e2aed84a..605f0b96dfb 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -21,11 +21,8 @@
* Cecabank: Append error text to message [therufs] #3127
* Adyen: Extend AVS code mappings [therufs] #3119
* NMI: Add customer id to authorization on store [curiousepic] #3130
-<<<<<<< HEAD
* Trans First Express: Don't pass blank name field [curiousepic] #3133
-=======
* TrustCommerce: Send full name on ACH transactions [jknipp] #3132
->>>>>>> TrustCommerce: Send full name on ACH transactions
== Version 1.90.0 (January 8, 2019)
* Mercado Pago: Support "gateway" processing mode [curiousepic] #3087
From 84d9f007a0b4f40423864b512f0d7107bd6f6389 Mon Sep 17 00:00:00 2001
From: David Perry
Date: Mon, 4 Feb 2019 15:49:27 -0500
Subject: [PATCH 0265/2234] Qvalent: Map CVV Result to responses
Closes #3135
Remote:
19 tests, 63 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
18 tests, 86 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/qvalent.rb | 11 ++++++++++
test/remote/gateways/remote_qvalent_test.rb | 2 +-
test/unit/gateways/qvalent_test.rb | 20 ++++++++++++++++++-
4 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 605f0b96dfb..1ea9c71132a 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -23,6 +23,7 @@
* NMI: Add customer id to authorization on store [curiousepic] #3130
* Trans First Express: Don't pass blank name field [curiousepic] #3133
* TrustCommerce: Send full name on ACH transactions [jknipp] #3132
+* Qvalent: Map CVV Result to responses [curiousepic] #3135
== Version 1.90.0 (January 8, 2019)
* Mercado Pago: Support "gateway" processing mode [curiousepic] #3087
diff --git a/lib/active_merchant/billing/gateways/qvalent.rb b/lib/active_merchant/billing/gateways/qvalent.rb
index 46c43aae0cd..10b693cd0c5 100644
--- a/lib/active_merchant/billing/gateways/qvalent.rb
+++ b/lib/active_merchant/billing/gateways/qvalent.rb
@@ -12,6 +12,10 @@ class QvalentGateway < Gateway
self.money_format = :cents
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners]
+ CVV_CODE_MAPPING = {
+ 'S' => 'D'
+ }
+
def initialize(options={})
requires!(options, :username, :password, :merchant, :pem, :pem_password)
super
@@ -168,11 +172,18 @@ def commit(action, post)
message_from(succeeded, raw),
raw,
authorization: raw['response.orderNumber'] || raw['response.customerReferenceNumber'],
+ cvv_result: cvv_result(succeeded, raw),
error_code: error_code_from(succeeded, raw),
test: test?
)
end
+ def cvv_result(succeeded, raw)
+ return unless succeeded
+ code = CVV_CODE_MAPPING[raw['response.cvnResponse']] || raw['response.cvnResponse']
+ CVVResult.new(code)
+ end
+
def headers
{
'Content-Type' => 'application/x-www-form-urlencoded'
diff --git a/test/remote/gateways/remote_qvalent_test.rb b/test/remote/gateways/remote_qvalent_test.rb
index 9c21e25b889..cc610703d86 100644
--- a/test/remote/gateways/remote_qvalent_test.rb
+++ b/test/remote/gateways/remote_qvalent_test.rb
@@ -25,7 +25,7 @@ def test_invalid_login
pem_password: 'bad'
)
- assert_raise ActiveMerchant::ClientCertificateError do
+ assert_raise OpenSSL::X509::CertificateError do
gateway.purchase(@amount, @credit_card, @options)
end
end
diff --git a/test/unit/gateways/qvalent_test.rb b/test/unit/gateways/qvalent_test.rb
index f7fa337755a..1582e39388c 100644
--- a/test/unit/gateways/qvalent_test.rb
+++ b/test/unit/gateways/qvalent_test.rb
@@ -24,6 +24,7 @@ def test_successful_purchase
assert_success response
assert_equal '5d53a33d960c46d00f5dc061947d998c', response.authorization
+ assert_equal 'M', response.cvv_result['code']
assert response.test?
end
@@ -186,6 +187,15 @@ def test_3d_secure_fields
assert_success response
end
+ def test_cvv_result
+ response = stub_comms do
+ @gateway.purchase(@amount, @credit_card)
+ end.respond_with(mapped_cvv_response)
+
+ assert_success response
+ assert_equal 'D', response.cvv_result['code']
+ end
+
def test_transcript_scrubbing
assert_equal scrubbed_transcript, @gateway.scrub(transcript)
end
@@ -194,7 +204,8 @@ def test_transcript_scrubbing
def successful_purchase_response
%(
- response.summaryCode=0\r\nresponse.responseCode=08\r\nresponse.text=Honour with identification\r\nresponse.referenceNo=723907124\r\nresponse.orderNumber=5d53a33d960c46d00f5dc061947d998c\r\nresponse.RRN=723907124 \r\nresponse.settlementDate=20150228\r\nresponse.transactionDate=28-FEB-2015 09:34:15\r\nresponse.cardSchemeName=VISA\r\nresponse.creditGroup=VI/BC/MC\r\nresponse.previousTxn=0\r\nresponse.end\r\n
+ response.summaryCode=0\r\nresponse.responseCode=08\r\nresponse.text=Honour with identification\r\nresponse.referenceNo=723907124\r\nresponse.orderNumber=5d53a33d960c46d00f5dc061947d998c\r\nresponse.RRN=723907124 \r\nresponse.settlementDate=20150228\r\nresponse.transactionDate=28-FEB-2015 09:34:15\r\nresponse.cardSchemeName=VISA\r\nresponse.creditGroup=VI/BC/MC\r\nresponse.previousTxn=0\r\nresponse.cvnResponse=M
+\r\nresponse.end\r\n
)
end
@@ -281,6 +292,13 @@ def empty_purchase_response
)
end
+ def mapped_cvv_response
+ %(
+ response.summaryCode=0\r\nresponse.responseCode=08\r\nresponse.text=Honour with identification\r\nresponse.referenceNo=723907124\r\nresponse.orderNumber=5d53a33d960c46d00f5dc061947d998c\r\nresponse.RRN=723907124 \r\nresponse.settlementDate=20150228\r\nresponse.transactionDate=28-FEB-2015 09:34:15\r\nresponse.cardSchemeName=VISA\r\nresponse.creditGroup=VI/BC/MC\r\nresponse.previousTxn=0\r\nresponse.cvnResponse=S
+\r\nresponse.end\r\n
+ )
+ end
+
def transcript
%(
opening connection to ccapi.client.support.qvalent.com:443...
From 5e49de4d4408354bad29f07dedf0def9efbfe747 Mon Sep 17 00:00:00 2001
From: David Perry
Date: Tue, 5 Feb 2019 14:34:52 -0500
Subject: [PATCH 0266/2234] Card Connect: Handle 401s as responses
Closes #3137
Remote (1 unrelated failure for echeck related to amount):
23 tests, 54 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
95.6522% passed
Unit:
21 tests, 89 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/card_connect.rb | 3 +++
test/remote/gateways/remote_card_connect_test.rb | 7 ++++---
3 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 1ea9c71132a..a4f5a2624a6 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -24,6 +24,7 @@
* Trans First Express: Don't pass blank name field [curiousepic] #3133
* TrustCommerce: Send full name on ACH transactions [jknipp] #3132
* Qvalent: Map CVV Result to responses [curiousepic] #3135
+* Card Connect: Handle 401s as responses [curiousepic] #3137
== Version 1.90.0 (January 8, 2019)
* Mercado Pago: Support "gateway" processing mode [curiousepic] #3087
diff --git a/lib/active_merchant/billing/gateways/card_connect.rb b/lib/active_merchant/billing/gateways/card_connect.rb
index c4630cf0697..62903dec0ff 100644
--- a/lib/active_merchant/billing/gateways/card_connect.rb
+++ b/lib/active_merchant/billing/gateways/card_connect.rb
@@ -281,6 +281,9 @@ def commit(action, parameters, verb: :put, path: '')
test: test?,
error_code: error_code_from(response)
)
+ rescue ResponseError => e
+ return Response.new(false, 'Unable to authenticate. Please check your credentials.', {}, :test => test?) if e.response.code == '401'
+ raise
end
def success_from(response)
diff --git a/test/remote/gateways/remote_card_connect_test.rb b/test/remote/gateways/remote_card_connect_test.rb
index 10cf459c550..61f587cd168 100644
--- a/test/remote/gateways/remote_card_connect_test.rb
+++ b/test/remote/gateways/remote_card_connect_test.rb
@@ -201,9 +201,10 @@ def test_failed_unstore
def test_invalid_login
gateway = CardConnectGateway.new(username: '', password: '', merchant_id: '')
- assert_raises(ActiveMerchant::ResponseError) do
- gateway.purchase(@amount, @credit_card, @options)
- end
+ response = gateway.purchase(@amount, @credit_card, @options)
+
+ assert_failure response
+ assert_match %r{Unable to authenticate. Please check your credentials.}, response.message
end
def test_transcript_scrubbing
From b12da5a8b1737f91b8f570512582c1f79904922f Mon Sep 17 00:00:00 2001
From: David Santoso
Date: Mon, 4 Feb 2019 15:11:39 -0500
Subject: [PATCH 0267/2234] Worldpay: Introduce normalized stored credential
options
The Visa/Mastercard Stored Credentials Framework is becoming standard
functionality across all gateways. There are a few gateways in Active
Merchant which support sending in very specific fields in the options
hash which will be set while building a auth/purchase request. However
Active Merchant should be a consistent interface to gateways and to that
end, this commit is introducing a new normalized hash which contains
a standard set of fields by which the proper logic should be able to
construct a correct stored credentials request to any gateway.
The hash takes the following structure:
{
stored_credential: {
inital_transaction: Boolean, # either true or false
recurring: Boolean, # either true or false
initiator: String, # either "merchant" or "cardholder"
network_transaction_id: String # returned card network transaction id
}
}
With those 4 bits of information, you should be able to successfully add
the necessary fields to any gateway request. Note that there should be
logic to add the necessary values in the request (see this commit as an
example) and not all gateways will need or accept all those fields.
In many ways this is similar to normalizing address fields in that
Active Merchant always expects and address hash to use a field `zip`
instead of something like `postalCode`. However the downside to this
setup is that there is no field level validation which we get with
something like an Active Merchant CreditCard.
Lastly, this commit also allows for the specific fields to also be sent
to maintain backwards compatibility with anyone who might already be
using the specific fields.
---
CHANGELOG | 1 +
.../billing/gateways/worldpay.rb | 24 ++++++++++++-
test/remote/gateways/remote_worldpay_test.rb | 34 +++++++++++++++++++
3 files changed, 58 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index a4f5a2624a6..7caae457f78 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -25,6 +25,7 @@
* TrustCommerce: Send full name on ACH transactions [jknipp] #3132
* Qvalent: Map CVV Result to responses [curiousepic] #3135
* Card Connect: Handle 401s as responses [curiousepic] #3137
+* Worldpay: Introduce normalized stored credential options [davidsantoso] #3134
== Version 1.90.0 (January 8, 2019)
* Mercado Pago: Support "gateway" processing mode [curiousepic] #3087
diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb
index 422b2801f5e..5be1ea1a733 100644
--- a/lib/active_merchant/billing/gateways/worldpay.rb
+++ b/lib/active_merchant/billing/gateways/worldpay.rb
@@ -268,12 +268,34 @@ def add_payment_method(xml, amount, payment_method, options)
xml.tag! 'session', 'shopperIPAddress' => options[:ip] if options[:ip]
xml.tag! 'session', 'id' => options[:session_id] if options[:session_id]
end
- add_stored_credential_options(xml, options) if options[:stored_credential_usage]
+ add_stored_credential_options(xml, options)
end
end
end
def add_stored_credential_options(xml, options={})
+ if options[:stored_credential]
+ add_stored_credential_using_normalized_fields(xml, options)
+ else
+ add_stored_credential_using_gateway_specific_fields(xml, options)
+ end
+ end
+
+ def add_stored_credential_using_normalized_fields(xml, options)
+ if options[:stored_credential][:initial_transaction]
+ xml.tag! 'storedCredentials', 'usage' => 'FIRST'
+ else
+ reason = options[:stored_credential][:recurring] ? 'RECURRING' : 'UNSCHEDULED'
+
+ xml.tag! 'storedCredentials', 'usage' => 'USED', 'merchantInitiatedReason' => reason do
+ xml.tag! 'schemeTransactionIdentifier', options[:stored_credential][:network_transaction_id] if options[:stored_credential][:network_transaction_id]
+ end
+ end
+ end
+
+ def add_stored_credential_using_gateway_specific_fields(xml, options)
+ return unless options[:stored_credential_usage]
+
if options[:stored_credential_initiated_reason]
xml.tag! 'storedCredentials', 'usage' => options[:stored_credential_usage], 'merchantInitiatedReason' => options[:stored_credential_initiated_reason] do
xml.tag! 'schemeTransactionIdentifier', options[:stored_credential_transaction_id] if options[:stored_credential_transaction_id]
diff --git a/test/remote/gateways/remote_worldpay_test.rb b/test/remote/gateways/remote_worldpay_test.rb
index 2009f01838a..9cddc0413aa 100644
--- a/test/remote/gateways/remote_worldpay_test.rb
+++ b/test/remote/gateways/remote_worldpay_test.rb
@@ -124,6 +124,40 @@ def test_successful_authorize_with_3ds
refute first_message.params['session_id'].blank?
end
+ def test_successful_auth_and_capture_with_normalized_stored_credential
+ stored_credential_params = {
+ initial_transaction: true,
+ recurring: false,
+ initiator: 'merchant',
+ network_transaction_id: nil
+ }
+
+ assert auth = @gateway.authorize(@amount, @credit_card, @options.merge({stored_credential: stored_credential_params}))
+ assert_success auth
+ assert auth.authorization
+ assert auth.params['scheme_response']
+ assert auth.params['transaction_identifier']
+
+ assert capture = @gateway.capture(@amount, auth.authorization, authorization_validated: true)
+ assert_success capture
+
+ @options[:order_id] = generate_unique_id
+ @options[:stored_credential] = {
+ initial_transaction: false,
+ recurring: false,
+ initiator: 'merchant',
+ network_transaction_id: auth.params['transaction_identifier']
+ }
+
+ assert next_auth = @gateway.authorize(@amount, @credit_card, @options)
+ assert next_auth.authorization
+ assert next_auth.params['scheme_response']
+ assert next_auth.params['transaction_identifier']
+
+ assert capture = @gateway.capture(@amount, next_auth.authorization, authorization_validated: true)
+ assert_success capture
+ end
+
def test_successful_auth_and_capture_with_stored_cred_options
assert auth = @gateway.authorize(@amount, @credit_card, @options.merge(stored_credential_usage: 'FIRST'))
assert_success auth
From 30b0d4a2a70587ea18028b315cdd3908d0a1256f Mon Sep 17 00:00:00 2001
From: David Santoso
Date: Sat, 9 Feb 2019 10:19:41 -0500
Subject: [PATCH 0268/2234] Worldpay: Adjust use of normalized stored
credentials hash
Previously the new/beta normalized stored credential hash was using a
boolean value to indicate if a transaction was part of a recurring
transaction or not. However, this did not allow for the case of gateways
(like Worldpay) to take into account transactions that are part of an
installment. This adjusts the previously "recurring" field to use the
name "transaction_type" which accepts a string of either:
- "installment"
- "recurring"
- "unscheduled"
This should allow more flexibility to for other gateways that also have
the notion of a payment that is part of an installment.
Note that this normalized hash is still in "beta" use. The hash
structure itself may change and until there is solid use around it
across multiple gateways, it will likely be a defined-yet-not-enforced
hash rather than an object which provides guarantees around field
values.
Closes #3139
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/worldpay.rb | 6 +++++-
test/remote/gateways/remote_worldpay_test.rb | 4 ++--
3 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 7caae457f78..7a18c24cef6 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -26,6 +26,7 @@
* Qvalent: Map CVV Result to responses [curiousepic] #3135
* Card Connect: Handle 401s as responses [curiousepic] #3137
* Worldpay: Introduce normalized stored credential options [davidsantoso] #3134
+* Worldpay: Adjust use of normalized stored credentials hash [davidsantoso] #3139
== Version 1.90.0 (January 8, 2019)
* Mercado Pago: Support "gateway" processing mode [curiousepic] #3087
diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb
index 5be1ea1a733..ddf902f2bf8 100644
--- a/lib/active_merchant/billing/gateways/worldpay.rb
+++ b/lib/active_merchant/billing/gateways/worldpay.rb
@@ -285,7 +285,11 @@ def add_stored_credential_using_normalized_fields(xml, options)
if options[:stored_credential][:initial_transaction]
xml.tag! 'storedCredentials', 'usage' => 'FIRST'
else
- reason = options[:stored_credential][:recurring] ? 'RECURRING' : 'UNSCHEDULED'
+ reason = case options[:stored_credential][:reason_type]
+ when 'installment' then 'INSTALMENT'
+ when 'recurring' then 'RECURRING'
+ when 'unscheduled' then 'UNSCHEDULED'
+ end
xml.tag! 'storedCredentials', 'usage' => 'USED', 'merchantInitiatedReason' => reason do
xml.tag! 'schemeTransactionIdentifier', options[:stored_credential][:network_transaction_id] if options[:stored_credential][:network_transaction_id]
diff --git a/test/remote/gateways/remote_worldpay_test.rb b/test/remote/gateways/remote_worldpay_test.rb
index 9cddc0413aa..baa7345bacc 100644
--- a/test/remote/gateways/remote_worldpay_test.rb
+++ b/test/remote/gateways/remote_worldpay_test.rb
@@ -127,7 +127,7 @@ def test_successful_authorize_with_3ds
def test_successful_auth_and_capture_with_normalized_stored_credential
stored_credential_params = {
initial_transaction: true,
- recurring: false,
+ reason_type: 'unscheduled',
initiator: 'merchant',
network_transaction_id: nil
}
@@ -144,7 +144,7 @@ def test_successful_auth_and_capture_with_normalized_stored_credential
@options[:order_id] = generate_unique_id
@options[:stored_credential] = {
initial_transaction: false,
- recurring: false,
+ reason_type: 'installment',
initiator: 'merchant',
network_transaction_id: auth.params['transaction_identifier']
}
From 24030392307620e22ca58eeb9fd8db0139ef513e Mon Sep 17 00:00:00 2001
From: molbrown
Date: Wed, 6 Feb 2019 13:13:51 -0500
Subject: [PATCH 0269/2234] Adyen: Enable Dynamic 3DS
Allows for initiating Dynamic 3DS by passing browserInfo without
executeThreeD. Merchant account must be set up for Dynamic 3DS.
ECS-131
Unit:
27 tests, 130 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
41 tests, 111 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Closes #3138
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/adyen.rb | 7 ++---
test/remote/gateways/remote_adyen_test.rb | 26 +++++++++++++++++++
3 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 7a18c24cef6..46c2c4029c2 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -27,6 +27,7 @@
* Card Connect: Handle 401s as responses [curiousepic] #3137
* Worldpay: Introduce normalized stored credential options [davidsantoso] #3134
* Worldpay: Adjust use of normalized stored credentials hash [davidsantoso] #3139
+* Adyen: Enable Dynamic 3DS [molbrown] #3138
== Version 1.90.0 (January 8, 2019)
* Mercado Pago: Support "gateway" processing mode [curiousepic] #3087
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index 11ef131a4e0..46e455479fc 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -33,7 +33,7 @@ def initialize(options={})
end
def purchase(money, payment, options={})
- if options[:execute_threed]
+ if options[:execute_threed] || options[:threed_dynamic]
authorize(money, payment, options)
else
MultiResponse.run do |r|
@@ -52,7 +52,7 @@ def authorize(money, payment, options={})
add_shopper_interaction(post, payment, options)
add_address(post, options)
add_installments(post, options) if options[:installments]
- add_3ds(post, options) if options[:execute_threed]
+ add_3ds(post, options)
commit('authorise', post)
end
@@ -276,8 +276,9 @@ def add_installments(post, options)
end
def add_3ds(post, options)
- post[:additionalData] = { executeThreeD: 'true' }
+ return unless options[:execute_threed] || options[:threed_dynamic]
post[:browserInfo] = { userAgent: options[:user_agent], acceptHeader: options[:accept_header] }
+ post[:additionalData] = { executeThreeD: 'true' } if options[:execute_threed]
end
def parse(body)
diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb
index 952973281e3..340bbfde7a9 100644
--- a/test/remote/gateways/remote_adyen_test.rb
+++ b/test/remote/gateways/remote_adyen_test.rb
@@ -72,6 +72,32 @@ def test_successful_authorize_with_3ds
refute response.params['paRequest'].blank?
end
+ def test_successful_authorize_with_3ds_dynamic
+ assert response = @gateway.authorize(@amount, @three_ds_enrolled_card, @options.merge(threed_dynamic: true))
+ assert response.test?
+ refute response.authorization.blank?
+ assert_equal response.params['resultCode'], 'RedirectShopper'
+ refute response.params['issuerUrl'].blank?
+ refute response.params['md'].blank?
+ refute response.params['paRequest'].blank?
+ end
+
+ # with rule set in merchant account to skip 3DS for cards of this brand
+ def test_successful_authorize_with_3ds_dynamic_rule_broken
+ mastercard_threed = credit_card('5212345678901234',
+ :month => 10,
+ :year => 2020,
+ :first_name => 'John',
+ :last_name => 'Smith',
+ :verification_value => '737',
+ :brand => 'mastercard'
+ )
+ assert response = @gateway.authorize(@amount, mastercard_threed, @options.merge(threed_dynamic: true))
+ assert response.test?
+ refute response.authorization.blank?
+ assert_equal response.params['resultCode'], 'Authorised'
+ end
+
def test_failed_authorize
response = @gateway.authorize(@amount, @declined_card, @options)
assert_failure response
From 96ac972259781f918d94841e3ad46099e9ef6c2b Mon Sep 17 00:00:00 2001
From: David Perry
Date: Thu, 14 Feb 2019 14:46:51 -0500
Subject: [PATCH 0270/2234] Fat Zebra: Support voids
This requires keeping track of actions in order to properly choose the
url for voiding refunds since it is different from refunding purchases.
Closes #3142
Remote (1 unrelated failure):
22 tests, 78 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
95.4545% passed
Unit:
17 tests, 89 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/fat_zebra.rb | 27 ++++++++++++-----
test/remote/gateways/remote_fat_zebra_test.rb | 30 +++++++++++++++++--
test/unit/gateways/fat_zebra_test.rb | 18 +++++------
4 files changed, 57 insertions(+), 19 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 46c2c4029c2..5a9acc76d07 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -28,6 +28,7 @@
* Worldpay: Introduce normalized stored credential options [davidsantoso] #3134
* Worldpay: Adjust use of normalized stored credentials hash [davidsantoso] #3139
* Adyen: Enable Dynamic 3DS [molbrown] #3138
+* Fat Zebra: Support voids [curiousepic] #3142
== Version 1.90.0 (January 8, 2019)
* Mercado Pago: Support "gateway" processing mode [curiousepic] #3087
diff --git a/lib/active_merchant/billing/gateways/fat_zebra.rb b/lib/active_merchant/billing/gateways/fat_zebra.rb
index 93d25df692a..7a37c767304 100644
--- a/lib/active_merchant/billing/gateways/fat_zebra.rb
+++ b/lib/active_merchant/billing/gateways/fat_zebra.rb
@@ -46,14 +46,17 @@ def authorize(money, creditcard, options = {})
end
def capture(money, authorization, options = {})
+ txn_id, _ = authorization.to_s.split('|')
post = {}
+
add_amount(post, money, options)
add_extra_options(post, options)
- commit(:post, "purchases/#{CGI.escape(authorization)}/capture", post)
+ commit(:post, "purchases/#{CGI.escape(txn_id)}/capture", post)
end
- def refund(money, txn_id, options={})
+ def refund(money, authorization, options={})
+ txn_id, _ = authorization.to_s.split('|')
post = {}
add_extra_options(post, options)
@@ -64,8 +67,15 @@ def refund(money, txn_id, options={})
commit(:post, 'refunds', post)
end
+ def void(authorization, options={})
+ txn_id, endpoint = authorization.to_s.split('|')
+
+ commit(:post, "#{endpoint}/void?id=#{txn_id}", {})
+ end
+
def store(creditcard, options={})
post = {}
+
add_creditcard(post, creditcard)
commit(:post, 'credit_cards', post)
@@ -97,7 +107,8 @@ def add_creditcard(post, creditcard, options = {})
post[:cvv] = creditcard.verification_value if creditcard.verification_value?
post[:card_holder] = creditcard.name if creditcard.name
elsif creditcard.is_a?(String)
- post[:card_token] = creditcard
+ id, _ = creditcard.to_s.split('|')
+ post[:card_token] = id
post[:cvv] = options[:cvv]
elsif creditcard.is_a?(Hash)
ActiveMerchant.deprecated 'Passing the credit card as a Hash is deprecated. Use a String and put the (optional) CVV in the options hash instead.'
@@ -141,7 +152,7 @@ def commit(method, uri, parameters=nil)
message_from(response),
response,
:test => response['test'],
- :authorization => authorization_from(response, success)
+ :authorization => authorization_from(response, success, uri)
)
end
@@ -149,13 +160,15 @@ def success_from(response)
(
response['successful'] &&
response['response'] &&
- (response['response']['successful'] || response['response']['token'])
+ (response['response']['successful'] || response['response']['token'] || response['response']['response_code'] == '00')
)
end
- def authorization_from(response, success)
+ def authorization_from(response, success, uri)
+ endpoint = uri.split('/')[0]
if success
- (response['response']['id'] || response['response']['token'])
+ id = response['response']['id'] || response['response']['token']
+ "#{id}|#{endpoint}"
else
nil
end
diff --git a/test/remote/gateways/remote_fat_zebra_test.rb b/test/remote/gateways/remote_fat_zebra_test.rb
index dd4d594751e..b519f94d355 100644
--- a/test/remote/gateways/remote_fat_zebra_test.rb
+++ b/test/remote/gateways/remote_fat_zebra_test.rb
@@ -93,7 +93,7 @@ def test_unsuccessful_purchase
end
def test_refund
- purchase = @gateway.purchase(@amount, @credit_card, @options)
+ assert purchase = @gateway.purchase(@amount, @credit_card, @options)
assert response = @gateway.refund(@amount, purchase.authorization, @options)
assert_success response
@@ -103,16 +103,40 @@ def test_refund
def test_invalid_refund
@gateway.purchase(@amount, @credit_card, @options)
- assert response = @gateway.refund(@amount, nil, @options)
+ assert response = @gateway.refund(@amount, '', @options)
assert_failure response
assert_match %r{Invalid credit card for unmatched refund}, response.message
end
+ def test_successful_void
+ auth = @gateway.authorize(@amount, @credit_card, @options)
+
+ assert response = @gateway.void(auth.authorization, @options)
+ assert_success response
+ assert_match %r{Voided}, response.message
+ end
+
+ def test_successful_void_refund
+ purchase = @gateway.purchase(@amount, @credit_card, @options)
+ puts purchase.inspect
+ refund = @gateway.refund(@amount, purchase.authorization, @options)
+
+ assert response = @gateway.void(refund.authorization, @options)
+ assert_success response
+ assert_match %r{Voided}, response.message
+ end
+
+ def test_failed_void
+ assert response = @gateway.void('123', @options)
+ assert_failure response
+ assert_match %r{Not Found}, response.message
+ end
+
def test_store
assert card = @gateway.store(@credit_card)
assert_success card
- assert_false card.authorization.nil?
+ assert_false card.authorization == nil
end
def test_purchase_with_token
diff --git a/test/unit/gateways/fat_zebra_test.rb b/test/unit/gateways/fat_zebra_test.rb
index e802111c648..4b319c1ce18 100644
--- a/test/unit/gateways/fat_zebra_test.rb
+++ b/test/unit/gateways/fat_zebra_test.rb
@@ -25,7 +25,7 @@ def test_successful_purchase
assert response = @gateway.purchase(@amount, @credit_card, @options)
assert_success response
- assert_equal '001-P-12345AA', response.authorization
+ assert_equal '001-P-12345AA|purchases', response.authorization
assert response.test?
end
@@ -37,7 +37,7 @@ def test_successful_purchase_with_token
assert response = @gateway.purchase(@amount, 'e1q7dbj2', @options)
assert_success response
- assert_equal '001-P-12345AA', response.authorization
+ assert_equal '001-P-12345AA|purchases', response.authorization
assert response.test?
end
@@ -49,7 +49,7 @@ def test_successful_purchase_with_token_string
assert response = @gateway.purchase(@amount, 'e1q7dbj2', @options)
assert_success response
- assert_equal '001-P-12345AA', response.authorization
+ assert_equal '001-P-12345AA|purchases', response.authorization
assert response.test?
end
@@ -61,7 +61,7 @@ def test_successful_multi_currency_purchase
assert response = @gateway.purchase(@amount, 'e1q7dbj2', @options.merge(:currency => 'USD'))
assert_success response
- assert_equal '001-P-12345AA', response.authorization
+ assert_equal '001-P-12345AA|purchases', response.authorization
assert response.test?
end
@@ -82,7 +82,7 @@ def test_successful_purchase_with_descriptor
assert response = @gateway.purchase(@amount, 'e1q7dbj2', @options.merge(:merchant => 'Merchant', :merchant_location => 'Location'))
assert_success response
- assert_equal '001-P-12345AA', response.authorization
+ assert_equal '001-P-12345AA|purchases', response.authorization
assert response.test?
end
@@ -94,7 +94,7 @@ def test_successful_authorization
assert response = @gateway.authorize(@amount, 'e1q7dbj2', @options)
assert_success response
- assert_equal '001-P-12345AA', response.authorization
+ assert_equal '001-P-12345AA|purchases', response.authorization
assert response.test?
end
@@ -105,7 +105,7 @@ def test_successful_capture
response = @gateway.capture(@amount, 'e1q7dbj2', @options)
assert_success response
- assert_equal '001-P-12345AA', response.authorization
+ assert_equal '001-P-12345AA|purchases', response.authorization
assert response.test?
end
@@ -147,7 +147,7 @@ def test_successful_tokenization
assert response = @gateway.store(@credit_card)
assert_success response
- assert_equal 'e1q7dbj2', response.authorization
+ assert_equal 'e1q7dbj2|credit_cards', response.authorization
end
def test_unsuccessful_tokenization
@@ -162,7 +162,7 @@ def test_successful_refund
assert response = @gateway.refund(100, 'TEST')
assert_success response
- assert_equal '003-R-7MNIUMY6', response.authorization
+ assert_equal '003-R-7MNIUMY6|refunds', response.authorization
assert response.test?
end
From f70a668e12ec7692d33cab1c71b392fe3b7b4682 Mon Sep 17 00:00:00 2001
From: payfirma1 <47611274+payfirma1@users.noreply.github.com>
Date: Mon, 18 Feb 2019 10:48:46 -0800
Subject: [PATCH 0271/2234] Merrco partial refunds fix (#3141)
As per the Pay safe API documentation and our discussion with their representative we know that the merchantRefNum has to be unique each time we communicate with the API. Also we specifically asked that if the merchantRefNum has to be the order id, to which the answer was no. It can be any random string, as long as it is unique each time.
---
lib/active_merchant/billing/gateways/netbanx.rb | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lib/active_merchant/billing/gateways/netbanx.rb b/lib/active_merchant/billing/gateways/netbanx.rb
index 901efd4ddfb..88e53fe1298 100644
--- a/lib/active_merchant/billing/gateways/netbanx.rb
+++ b/lib/active_merchant/billing/gateways/netbanx.rb
@@ -55,6 +55,10 @@ def refund(money, authorization, options={})
post = {}
add_invoice(post, money, options)
+ # Setting merchantRefNumber to a unique id for each refund
+ # This is to support multiple partial refunds for the same order
+ post[:merchantRefNum] = SecureRandom.uuid
+
commit(:post, "settlements/#{authorization}/refunds", post)
end
From 67be186d0c16e6bdba77e6d7f11c51ebfae19b4d Mon Sep 17 00:00:00 2001
From: Jared Knipp
Date: Fri, 15 Feb 2019 14:23:59 -0600
Subject: [PATCH 0272/2234] BlueSnap: Support ACH/ECP payments
Add support for ACH/ECP/echeck payments.
ECS-60
Unit:
25 tests, 97 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
33 tests, 103 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
closes #3143
---
CHANGELOG | 1 +
.../billing/gateways/blue_snap.rb | 182 +++++++++++++++---
test/remote/gateways/remote_blue_snap_test.rb | 71 +++++++
test/unit/gateways/blue_snap_test.rb | 165 ++++++++++++++++
4 files changed, 387 insertions(+), 32 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 5a9acc76d07..9e7131e5134 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -29,6 +29,7 @@
* Worldpay: Adjust use of normalized stored credentials hash [davidsantoso] #3139
* Adyen: Enable Dynamic 3DS [molbrown] #3138
* Fat Zebra: Support voids [curiousepic] #3142
+* Blue Snap: Support ACH/ECP payments [jknipp] #3143
== Version 1.90.0 (January 8, 2019)
* Mercado Pago: Support "gateway" processing mode [curiousepic] #3087
diff --git a/lib/active_merchant/billing/gateways/blue_snap.rb b/lib/active_merchant/billing/gateways/blue_snap.rb
index 5fb0996c987..bf839cbff40 100644
--- a/lib/active_merchant/billing/gateways/blue_snap.rb
+++ b/lib/active_merchant/billing/gateways/blue_snap.rb
@@ -59,14 +59,27 @@ class BlueSnapGateway < Gateway
'line1: N, zip: N, name: N' => 'N',
}
+ BANK_ACCOUNT_TYPE_MAPPING = {
+ 'personal_checking' => 'CONSUMER_CHECKING',
+ 'personal_savings' => 'CONSUMER_SAVINGS',
+ 'business_checking' => 'CORPORATE_CHECKING',
+ 'business_savings' => 'CORPORATE_SAVINGS'
+ }
+
def initialize(options={})
requires!(options, :api_username, :api_password)
super
end
def purchase(money, payment_method, options={})
- commit(:purchase) do |doc|
- add_auth_purchase(doc, money, payment_method, options)
+ payment_method_details = PaymentMethodDetails.new(payment_method)
+
+ commit(:purchase, :post, payment_method_details) do |doc|
+ if payment_method_details.alt_transaction?
+ add_alt_transaction_purchase(doc, money, payment_method_details, options)
+ else
+ add_auth_purchase(doc, money, payment_method, options)
+ end
end
end
@@ -102,18 +115,33 @@ def verify(payment_method, options={})
authorize(0, payment_method, options)
end
- def store(credit_card, options = {})
- commit(:store) do |doc|
- add_personal_info(doc, credit_card, options)
+ def store(payment_method, options = {})
+ payment_method_details = PaymentMethodDetails.new(payment_method)
+
+ commit(:store, :post, payment_method_details) do |doc|
+ add_personal_info(doc, payment_method, options)
+ add_echeck_company(doc, payment_method) if payment_method_details.check?
doc.send('payment-sources') do
- doc.send('credit-card-info') do
- add_credit_card(doc, credit_card)
- end
+ payment_method_details.check? ? store_echeck(doc, payment_method) : store_credit_card(doc, payment_method)
end
add_order(doc, options)
end
end
+ def store_credit_card(doc, payment_method)
+ doc.send('credit-card-info') do
+ add_credit_card(doc, payment_method)
+ end
+ end
+
+ def store_echeck(doc, payment_method)
+ doc.send('ecp-info') do
+ doc.send('ecp') do
+ add_echeck(doc, payment_method)
+ end
+ end
+ end
+
def verify_credentials
begin
ssl_get(url.to_s, headers)
@@ -132,7 +160,9 @@ def scrub(transcript)
transcript.
gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
gsub(%r(().+()), '\1[FILTERED]\2').
- gsub(%r(().+()), '\1[FILTERED]\2')
+ gsub(%r(().+()), '\1[FILTERED]\2').
+ gsub(%r((<(?:public-)?account-number>).+((?:public-)?account-number>)), '\1[FILTERED]\2').
+ gsub(%r((<(?:public-)?routing-number>).+((?:public-)?routing-number>)), '\1[FILTERED]\2')
end
private
@@ -142,9 +172,7 @@ def add_auth_purchase(doc, money, payment_method, options)
add_order(doc, options)
doc.send('storeCard', options[:store_card] || false)
add_amount(doc, money, options)
- doc.send('transaction-fraud-info') do
- doc.send('shopper-ip-address', options[:ip]) if options[:ip]
- end
+ add_fraud_info(doc, options)
if payment_method.is_a?(String)
doc.send('vaulted-shopper-id', payment_method)
@@ -161,9 +189,9 @@ def add_amount(doc, money, options)
doc.currency(options[:currency] || currency(money))
end
- def add_personal_info(doc, credit_card, options)
- doc.send('first-name', credit_card.first_name)
- doc.send('last-name', credit_card.last_name)
+ def add_personal_info(doc, payment_method, options)
+ doc.send('first-name', payment_method.first_name)
+ doc.send('last-name', payment_method.last_name)
doc.send('personal-identification-number', options[:personal_identification_number]) if options[:personal_identification_number]
doc.email(options[:email]) if options[:email]
add_address(doc, options)
@@ -245,6 +273,53 @@ def add_authorization(doc, authorization)
doc.send('transaction-id', authorization)
end
+ def add_fraud_info(doc, options)
+ doc.send('transaction-fraud-info') do
+ doc.send('shopper-ip-address', options[:ip]) if options[:ip]
+ end
+ end
+
+ def add_alt_transaction_purchase(doc, money, payment_method_details, options)
+ doc.send('merchant-transaction-id', truncate(options[:order_id], 50)) if options[:order_id]
+ doc.send('soft-descriptor', options[:soft_descriptor]) if options[:soft_descriptor]
+ add_amount(doc, money, options)
+
+ vaulted_shopper_id = payment_method_details.vaulted_shopper_id
+ doc.send('vaulted-shopper-id', vaulted_shopper_id) if vaulted_shopper_id
+
+ if payment_method_details.check?
+ add_echeck_transaction(doc, payment_method_details.payment_method, options, vaulted_shopper_id.present?)
+ end
+
+ add_fraud_info(doc, options)
+ add_description(doc, options)
+ end
+
+ def add_echeck_transaction(doc, check, options, vaulted_shopper)
+ unless vaulted_shopper
+ doc.send('payer-info') do
+ add_personal_info(doc, check, options)
+ add_echeck_company(doc, check)
+ end
+ end
+
+ doc.send('ecp-transaction') do
+ add_echeck(doc, check) unless vaulted_shopper
+ end
+
+ doc.send('authorized-by-shopper', options[:authorized_by_shopper])
+ end
+
+ def add_echeck_company(doc, check)
+ doc.send('company-name', truncate(check.name, 50)) if check.account_holder_type = 'business'
+ end
+
+ def add_echeck(doc, check)
+ doc.send('account-number', check.account_number)
+ doc.send('routing-number', check.routing_number)
+ doc.send('account-type', BANK_ACCOUNT_TYPE_MAPPING["#{check.account_holder_type}_#{check.account_type}"])
+ end
+
def parse(response)
return bad_authentication_response if response.code.to_i == 401
return forbidden_response(response.body) if response.code.to_i == 403
@@ -273,15 +348,15 @@ def parse_element(parsed, node)
end
end
- def api_request(action, request, verb)
- ssl_request(verb, url(action), request, headers)
+ def api_request(action, request, verb, payment_method_details)
+ ssl_request(verb, url(action, payment_method_details), request, headers)
rescue ResponseError => e
e.response
end
- def commit(action, verb = :post)
- request = build_xml_request(action) { |doc| yield(doc) }
- response = api_request(action, request, verb)
+ def commit(action, verb = :post, payment_method_details = PaymentMethodDetails.new())
+ request = build_xml_request(action, payment_method_details) { |doc| yield(doc) }
+ response = api_request(action, request, verb, payment_method_details)
parsed = parse(response)
succeeded = success_from(action, response)
@@ -289,7 +364,7 @@ def commit(action, verb = :post)
succeeded,
message_from(succeeded, parsed),
parsed,
- authorization: authorization_from(action, parsed),
+ authorization: authorization_from(action, parsed, payment_method_details),
avs_result: avs_result(parsed),
cvv_result: cvv_result(parsed),
error_code: error_code_from(parsed),
@@ -297,9 +372,9 @@ def commit(action, verb = :post)
)
end
- def url(action = nil)
+ def url(action = nil, payment_method_details = PaymentMethodDetails.new())
base = test? ? test_url : live_url
- resource = action == :store ? 'vaulted-shoppers' : 'transactions'
+ resource = action == :store ? 'vaulted-shoppers' : payment_method_details.resource_url
"#{base}/#{resource}"
end
@@ -324,13 +399,15 @@ def message_from(succeeded, parsed_response)
parsed_response['description']
end
- def authorization_from(action, parsed_response)
- action == :store ? vaulted_shopper_id(parsed_response) : parsed_response['transaction-id']
+ def authorization_from(action, parsed_response, payment_method_details)
+ action == :store ? vaulted_shopper_id(parsed_response, payment_method_details) : parsed_response['transaction-id']
end
- def vaulted_shopper_id(parsed_response)
+ def vaulted_shopper_id(parsed_response, payment_method_details)
return nil unless parsed_response['content-location-header']
- parsed_response['content-location-header'].split('/').last
+ vaulted_shopper_id = parsed_response['content-location-header'].split('/').last
+ vaulted_shopper_id += "|#{payment_method_details.payment_method_type}" if payment_method_details.alt_transaction?
+ vaulted_shopper_id
end
def error_code_from(parsed_response)
@@ -343,8 +420,8 @@ def root_attributes
}
end
- def root_element(action)
- action == :store ? 'vaulted-shopper' : 'card-transaction'
+ def root_element(action, payment_method_details)
+ action == :store ? 'vaulted-shopper' : payment_method_details.root_element
end
def headers
@@ -354,10 +431,10 @@ def headers
}
end
- def build_xml_request(action)
+ def build_xml_request(action, payment_method_details)
builder = Nokogiri::XML::Builder.new
- builder.__send__(root_element(action), root_attributes) do |doc|
- doc.send('card-transaction-type', TRANSACTIONS[action]) if TRANSACTIONS[action]
+ builder.__send__(root_element(action, payment_method_details), root_attributes) do |doc|
+ doc.send('card-transaction-type', TRANSACTIONS[action]) if TRANSACTIONS[action] && !payment_method_details.alt_transaction?
yield(doc)
end
builder.doc.root.to_xml
@@ -380,5 +457,46 @@ def forbidden_response(body)
{ 'description' => body }
end
end
+
+ class PaymentMethodDetails
+ attr_reader :payment_method, :vaulted_shopper_id, :payment_method_type
+
+ def initialize(payment_method = nil)
+ @payment_method = payment_method
+ @payment_method_type = nil
+ parse(payment_method)
+ end
+
+ def check?
+ @payment_method.is_a?(Check) || @payment_method_type == 'check'
+ end
+
+ def alt_transaction?
+ check?
+ end
+
+ def root_element
+ alt_transaction? ? 'alt-transaction' : 'card-transaction'
+ end
+
+ def resource_url
+ alt_transaction? ? 'alt-transactions' : 'transactions'
+ end
+
+ private
+
+ def parse(payment_method)
+ return unless payment_method
+
+ if payment_method.is_a?(String)
+ @vaulted_shopper_id, payment_method_type = payment_method.split('|')
+ @payment_method_type = payment_method_type if payment_method_type.present?
+ elsif payment_method.is_a?(Check)
+ @payment_method_type = payment_method.type
+ else
+ @payment_method_type = 'credit_card'
+ end
+ end
+ end
end
end
diff --git a/test/remote/gateways/remote_blue_snap_test.rb b/test/remote/gateways/remote_blue_snap_test.rb
index f24a5194a18..39511e0940a 100644
--- a/test/remote/gateways/remote_blue_snap_test.rb
+++ b/test/remote/gateways/remote_blue_snap_test.rb
@@ -9,6 +9,19 @@ def setup
@declined_card = credit_card('4917484589897107', month: 1, year: 2023)
@invalid_card = credit_card('4917484589897106', month: 1, year: 2023)
@options = { billing_address: address }
+
+ @check = check
+ @invalid_check = check(:routing_number => '123456', :account_number => '123456789')
+ @valid_check_options = {
+ billing_address: {
+ address1: '123 Street',
+ address2: 'Apt 1',
+ city: 'Happy City',
+ state: 'CA',
+ zip: '94901'
+ },
+ authorized_by_shopper: true
+ }
end
def test_successful_purchase
@@ -98,6 +111,12 @@ def test_successful_purchase_with_level3_data
assert_equal '9', response.params['line-item-total']
end
+ def test_successful_echeck_purchase
+ response = @gateway.purchase(@amount, @check, @options.merge(@valid_check_options))
+ assert_success response
+ assert_equal 'Success', response.message
+ end
+
def test_failed_purchase
response = @gateway.purchase(@amount, @declined_card, @options)
assert_failure response
@@ -119,6 +138,20 @@ def test_avs_result
assert_equal 'I', response.avs_result['code']
end
+ def test_failed_echeck_purchase
+ response = @gateway.purchase(@amount, @invalid_check, @options.merge(@valid_check_options))
+ assert_failure response
+ assert_match(/ECP data validity check failed/, response.message)
+ assert_equal '10001', response.error_code
+ end
+
+ def test_failed_unauthorized_echeck_purchase
+ response = @gateway.purchase(@amount, @check, @options.merge({authorized_by_shopper: false}))
+ assert_failure response
+ assert_match(/The payment was not authorized by shopper/, response.message)
+ assert_equal '16004', response.error_code
+ end
+
def test_successful_authorize_and_capture
auth = @gateway.authorize(@amount, @credit_card, @options)
assert_success auth
@@ -209,6 +242,15 @@ def test_successful_store
assert_match(/services\/2\/vaulted-shoppers/, response.params['content-location-header'])
end
+ def test_successful_echeck_store
+ assert response = @gateway.store(@check, @options.merge(@valid_check_options))
+
+ assert_success response
+ assert_equal 'Success', response.message
+ assert response.authorization
+ assert_match(/services\/2\/vaulted-shoppers/, response.params['content-location-header'])
+ end
+
def test_failed_store
assert response = @gateway.store(@invalid_card, @options)
@@ -217,6 +259,14 @@ def test_failed_store
assert_equal '10001', response.error_code
end
+ def test_failed_echeck_store
+ assert response = @gateway.store(@invalid_check, @options)
+
+ assert_failure response
+ assert_match(/ECP data validity check failed/, response.message)
+ assert_equal '10001', response.error_code
+ end
+
def test_successful_purchase_using_stored_card
assert store_response = @gateway.store(@credit_card, @options)
assert_success store_response
@@ -226,6 +276,16 @@ def test_successful_purchase_using_stored_card
assert_equal 'Success', response.message
end
+ def test_successful_purchase_using_stored_echeck
+ assert store_response = @gateway.store(@check, @options.merge(@valid_check_options))
+ assert_success store_response
+ assert_match(/check/, store_response.authorization)
+
+ response = @gateway.purchase(@amount, store_response.authorization, @options.merge({authorized_by_shopper: true}))
+ assert_success response
+ assert_equal 'Success', response.message
+ end
+
def test_successful_authorize_using_stored_card
assert store_response = @gateway.store(@credit_card, @options)
assert_success store_response
@@ -261,4 +321,15 @@ def test_transcript_scrubbing
assert_scrubbed(@gateway.options[:api_password], transcript)
end
+ def test_transcript_scrubbing_with_echeck
+ transcript = capture_transcript(@gateway) do
+ @gateway.purchase(@amount, @check, @valid_check_options)
+ end
+ transcript = @gateway.scrub(transcript)
+
+ assert_scrubbed(@check.account_number, transcript)
+ assert_scrubbed(@check.routing_number, transcript)
+ assert_scrubbed(@gateway.options[:api_password], transcript)
+ end
+
end
diff --git a/test/unit/gateways/blue_snap_test.rb b/test/unit/gateways/blue_snap_test.rb
index b4fa22c495c..a2512bcff42 100644
--- a/test/unit/gateways/blue_snap_test.rb
+++ b/test/unit/gateways/blue_snap_test.rb
@@ -6,8 +6,19 @@ class BlueSnapTest < Test::Unit::TestCase
def setup
@gateway = BlueSnapGateway.new(api_username: 'login', api_password: 'password')
@credit_card = credit_card
+ @check = check
@amount = 100
@options = { order_id: '1', personal_identification_number: 'CNPJ' }
+ @valid_check_options = {
+ billing_address: {
+ address1: '123 Street',
+ address2: 'Apt 1',
+ city: 'Happy City',
+ state: 'CA',
+ zip: '94901'
+ },
+ authorized_by_shopper: true
+ }
end
def test_successful_purchase
@@ -18,6 +29,14 @@ def test_successful_purchase
assert_equal '1012082839', response.authorization
end
+ def test_successful_echeck_purchase
+ @gateway.expects(:raw_ssl_request).returns(successful_echeck_purchase_response)
+
+ response = @gateway.purchase(@amount, @check, @options.merge(@valid_check_options))
+ assert_success response
+ assert_equal '1019803029', response.authorization
+ end
+
def test_failed_purchase
@gateway.expects(:raw_ssl_request).returns(failed_purchase_response)
@@ -26,6 +45,14 @@ def test_failed_purchase
assert_equal '14002', response.error_code
end
+ def test_failed_echeck_purchase
+ @gateway.expects(:raw_ssl_request).returns(failed_echeck_purchase_response)
+
+ response = @gateway.purchase(@amount, @credit_card, @options)
+ assert_failure response
+ assert_equal '16004', response.error_code
+ end
+
def test_successful_authorize
response = stub_comms(@gateway, :raw_ssl_request) do
@gateway.authorize(@amount, @credit_card, @options)
@@ -117,6 +144,14 @@ def test_successful_store
assert_equal '20936441', response.authorization
end
+ def test_successful_echeck_store
+ @gateway.expects(:raw_ssl_request).returns(successful_echeck_store_response)
+
+ response = @gateway.store(@check, @options)
+ assert_success response
+ assert_equal '23844081|check', response.authorization
+ end
+
def test_failed_store
@gateway.expects(:raw_ssl_request).returns(failed_store_response)
@@ -125,6 +160,14 @@ def test_failed_store
assert_equal '14002', response.error_code
end
+ def test_failed_echeck_store
+ @gateway.expects(:raw_ssl_request).returns(failed_echeck_store_response)
+
+ response = @gateway.store(@check, @options)
+ assert_failure response
+ assert_equal '10001', response.error_code
+ end
+
def test_currency_added_correctly
stub_comms(@gateway, :raw_ssl_request) do
@gateway.purchase(@amount, @credit_card, @options.merge(currency: 'CAD'))
@@ -165,6 +208,11 @@ def test_scrub
assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed
end
+ def test_echeck_scrub
+ assert @gateway.supports_scrubbing?
+ assert_equal @gateway.scrub(pre_scrubbed_echeck), post_scrubbed_echeck
+ end
+
private
def pre_scrubbed
@@ -181,6 +229,20 @@ def pre_scrubbed
}
end
+ def pre_scrubbed_echeck
+ %q{
+ opening connection to sandbox.bluesnap.com:443...
+ opened
+ starting SSL for sandbox.bluesnap.com:443...
+ SSL established
+ <- "POST /services/2/alt-transactions HTTP/1.1\r\nContent-Type: application/xml\r\nAuthorization: Basic QVBJXzE0NjExNzM3MTY2NTc2NzM0MDQyMzpuZll3VHg4ZkZBdkpxQlhjeHF3Qzg=\r\nConnection: close\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nHost: sandbox.bluesnap.com\r\nContent-Length: 973\r\n\r\n"
+ <- "\n 1.00\n USD\n \n Jim\n Smith\n CA\n Happy City\n 94901\n Jim Smith\n \n \n 15378535\n 244183602\n CORPORATE_CHECKING\n \n true\n \n "
+ -> "HTTP/1.1 200 200\r\n"
+ -> "Set-Cookie: JSESSIONID=65D503B9785EA6641D4757EA568A6532; Path=/services; Secure; HttpOnly\r\n"
+ -> "Connection: close\r\n"
+ }
+ end
+
def post_scrubbed
%q{
opening connection to sandbox.bluesnap.com:443...
@@ -195,6 +257,20 @@ def post_scrubbed
}
end
+ def post_scrubbed_echeck
+ %q{
+ opening connection to sandbox.bluesnap.com:443...
+ opened
+ starting SSL for sandbox.bluesnap.com:443...
+ SSL established
+ <- "POST /services/2/alt-transactions HTTP/1.1\r\nContent-Type: application/xml\r\nAuthorization: Basic [FILTERED]=\r\nConnection: close\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nHost: sandbox.bluesnap.com\r\nContent-Length: 973\r\n\r\n"
+ <- "\n 1.00\n USD\n \n Jim\n Smith\n CA\n Happy City\n 94901\n Jim Smith\n \n \n [FILTERED]\n [FILTERED]\n CORPORATE_CHECKING\n \n true\n \n "
+ -> "HTTP/1.1 200 200\r\n"
+ -> "Set-Cookie: JSESSIONID=65D503B9785EA6641D4757EA568A6532; Path=/services; Secure; HttpOnly\r\n"
+ -> "Connection: close\r\n"
+ }
+ end
+
def successful_purchase_response
MockResponse.succeeded <<-XML
@@ -230,6 +306,33 @@ def successful_purchase_response
XML
end
+ def successful_echeck_purchase_response
+ MockResponse.succeeded <<-XML
+
+
+ 1019803029
+ 1.00
+ USD
+
+ Jim
+ Smith
+ CA
+ Happy City
+ 94901
+ Jim Smith
+
+
+ 15378535
+ 244183602
+ CORPORATE_CHECKING
+
+
+ PENDING
+
+
+ XML
+ end
+
def failed_purchase_response
body = <<-XML
@@ -245,6 +348,21 @@ def failed_purchase_response
MockResponse.failed(body, 400)
end
+ def failed_echeck_purchase_response
+ body = <<-XML
+
+
+
+ PAYMENT_NOT_AUTHORIZED_BY_SHOPPER
+ 16004
+ The payment was not authorized by shopper. Missing/Invalid 'authorized-by-shopper' element.
+
+
+ XML
+
+ MockResponse.failed(body, 400)
+ end
+
def successful_authorize_response
MockResponse.succeeded <<-XML
@@ -529,6 +647,39 @@ def successful_store_response
response
end
+ def successful_echeck_store_response
+ response = MockResponse.succeeded <<-XML
+
+
+ 23844081
+ Jim
+ Smith
+ Happy City
+ 94901
+ Jim Smith
+ USD
+
+
+
+ Jim
+ Smith
+
+ Jim Smith
+
+
+ 15378535
+ 244183602
+ CORPORATE_CHECKING
+
+
+
+
+ XML
+
+ response.headers = { 'content-location' => 'https://sandbox.bluesnap.com/services/2/vaulted-shoppers/23844081' }
+ response
+ end
+
def failed_store_response
body = <<-XML
@@ -543,6 +694,20 @@ def failed_store_response
MockResponse.failed(body, 400)
end
+ def failed_echeck_store_response
+ body = <<-XML
+
+
+
+ VALIDATION_GENERAL_FAILURE
+ 10001
+ ECP data validity check failed
+
+
+ XML
+ MockResponse.failed(body, 400)
+ end
+
def forbidden_response
MockResponse.new(403, 'You are not authorized to perform this request due to inappropriate role permissions.')
end
From f3ea80bb3d8298e8fb3d25f317fb7fce209fc0df Mon Sep 17 00:00:00 2001
From: Jared Knipp
Date: Mon, 18 Feb 2019 15:54:30 -0600
Subject: [PATCH 0273/2234] BlueSnap: Fix Card-on-File field typo
ECS-60
Unit:
25 tests, 97 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
33 tests, 103 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/blue_snap.rb | 2 +-
test/unit/gateways/blue_snap_test.rb | 2 +-
3 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 9e7131e5134..4c6d4405c08 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -30,6 +30,7 @@
* Adyen: Enable Dynamic 3DS [molbrown] #3138
* Fat Zebra: Support voids [curiousepic] #3142
* Blue Snap: Support ACH/ECP payments [jknipp] #3143
+* Blue Snap: Fix Card-on-File field typo [jknipp] #3143
== Version 1.90.0 (January 8, 2019)
* Mercado Pago: Support "gateway" processing mode [curiousepic] #3087
diff --git a/lib/active_merchant/billing/gateways/blue_snap.rb b/lib/active_merchant/billing/gateways/blue_snap.rb
index bf839cbff40..0b0eabb2c45 100644
--- a/lib/active_merchant/billing/gateways/blue_snap.rb
+++ b/lib/active_merchant/billing/gateways/blue_snap.rb
@@ -170,7 +170,7 @@ def scrub(transcript)
def add_auth_purchase(doc, money, payment_method, options)
doc.send('recurring-transaction', options[:recurring] ? 'RECURRING' : 'ECOMMERCE')
add_order(doc, options)
- doc.send('storeCard', options[:store_card] || false)
+ doc.send('store-card', options[:store_card] || false)
add_amount(doc, money, options)
add_fraud_info(doc, options)
diff --git a/test/unit/gateways/blue_snap_test.rb b/test/unit/gateways/blue_snap_test.rb
index a2512bcff42..c3cb84bea00 100644
--- a/test/unit/gateways/blue_snap_test.rb
+++ b/test/unit/gateways/blue_snap_test.rb
@@ -57,7 +57,7 @@ def test_successful_authorize
response = stub_comms(@gateway, :raw_ssl_request) do
@gateway.authorize(@amount, @credit_card, @options)
end.check_request do |type, endpoint, data, headers|
- assert_match 'false', data
+ assert_match 'false', data
assert_match 'CNPJ', data
end.respond_with(successful_authorize_response)
assert_success response
From 497b0a638e40c53085427c92fb662f23226d480b Mon Sep 17 00:00:00 2001
From: Jared Knipp
Date: Mon, 18 Feb 2019 16:31:40 -0600
Subject: [PATCH 0274/2234] Fat Zebra: Fix Rubocop error in unit test
Unit:
17 tests, 89 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
ECS-
Unit:
Remote:
---
test/remote/gateways/remote_fat_zebra_test.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/remote/gateways/remote_fat_zebra_test.rb b/test/remote/gateways/remote_fat_zebra_test.rb
index b519f94d355..fa0ad80219b 100644
--- a/test/remote/gateways/remote_fat_zebra_test.rb
+++ b/test/remote/gateways/remote_fat_zebra_test.rb
@@ -136,7 +136,7 @@ def test_store
assert card = @gateway.store(@credit_card)
assert_success card
- assert_false card.authorization == nil
+ assert_not_nil card.authorization
end
def test_purchase_with_token
From 65dfd6e1b755bc022f5124fb4149a58a77578d93 Mon Sep 17 00:00:00 2001
From: InfraRuby Vision
Date: Fri, 7 Apr 2017 03:22:46 +0000
Subject: [PATCH 0275/2234] Add Bambora gateway
Combine username and account number into one field for Bambora gateway
Fix warning in Bambora remote tests
---
README.md | 1 +
.../billing/gateways/bambora.rb | 179 +++++++++++++++
lib/active_merchant/billing/gateways/ipp.rb | 1 +
test/fixtures.yml | 8 +
.../gateways/remote_bambora_ready_test.rb | 77 +++++++
test/remote/gateways/remote_bambora_test.rb | 77 +++++++
test/unit/gateways/bambora_ready_test.rb | 105 +++++++++
test/unit/gateways/bambora_test.rb | 211 ++++++++++++++++++
8 files changed, 659 insertions(+)
create mode 100644 lib/active_merchant/billing/gateways/bambora.rb
create mode 100644 test/remote/gateways/remote_bambora_ready_test.rb
create mode 100644 test/remote/gateways/remote_bambora_test.rb
create mode 100644 test/unit/gateways/bambora_ready_test.rb
create mode 100644 test/unit/gateways/bambora_test.rb
diff --git a/README.md b/README.md
index fb9dfdc3705..c14a98e1a0d 100644
--- a/README.md
+++ b/README.md
@@ -92,6 +92,7 @@ The [ActiveMerchant Wiki](http://github.com/activemerchant/active_merchant/wikis
* [Authorize.Net](http://www.authorize.net/) - AD, AT, AU, BE, BG, CA, CH, CY, CZ, DE, DK, ES, FI, FR, GB, GB, GI, GR, HU, IE, IT, LI, LU, MC, MT, NL, NO, PL, PT, RO, SE, SI, SK, SM, TR, US, VA
* [Axcess MS](http://www.axcessms.com/) - AD, AT, BE, BG, BR, CA, CH, CY, CZ, DE, DK, EE, ES, FI, FO, FR, GB, GI, GR, HR, HU, IE, IL, IM, IS, IT, LI, LT, LU, LV, MC, MT, MX, NL, NO, PL, PT, RO, RU, SE, SI, SK, TR, US, VA
* [Balanced](https://www.balancedpayments.com/) - US
+* [Bambora](http://www.bambora.com/) - AU, NZ
* [Bank Frick](http://www.bankfrickacquiring.com/) - LI, US
* [Banwire](http://www.banwire.com/) - MX
* [Barclays ePDQ Extra Plus](http://www.barclaycard.co.uk/business/accepting-payments/epdq-ecomm/) - GB
diff --git a/lib/active_merchant/billing/gateways/bambora.rb b/lib/active_merchant/billing/gateways/bambora.rb
new file mode 100644
index 00000000000..6371927c03b
--- /dev/null
+++ b/lib/active_merchant/billing/gateways/bambora.rb
@@ -0,0 +1,179 @@
+require "nokogiri"
+
+module ActiveMerchant #:nodoc:
+ module Billing #:nodoc:
+ class BamboraGateway < Gateway
+ self.live_url = 'https://www.bambora.co.nz/interface/api/dts.asmx'
+ self.test_url = 'https://demo.bambora.co.nz/interface/api/dts.asmx'
+
+ self.supported_countries = ['AU', 'NZ']
+ self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :jcb]
+
+ self.homepage_url = 'http://www.bambora.com/'
+ self.display_name = 'Bambora'
+
+ self.money_format = :cents
+
+ STANDARD_ERROR_CODE_MAPPING = {
+ "05" => STANDARD_ERROR_CODE[:card_declined],
+ "06" => STANDARD_ERROR_CODE[:processing_error],
+ "14" => STANDARD_ERROR_CODE[:invalid_number],
+ "54" => STANDARD_ERROR_CODE[:expired_card],
+ }
+
+ def initialize(options={})
+ requires!(options, :username, :password)
+ super
+ end
+
+ def purchase(money, payment, options={})
+ commit("SubmitSinglePayment") do |xml|
+ xml.Transaction do
+ xml.CustRef options[:order_id]
+ add_amount(xml, money)
+ xml.TrnType "1"
+ add_credit_card(xml, payment)
+ add_credentials(xml)
+ xml.TrnSource options[:ip]
+ end
+ end
+ end
+
+ def authorize(money, payment, options={})
+ commit("SubmitSinglePayment") do |xml|
+ xml.Transaction do
+ xml.CustRef options[:order_id]
+ add_amount(xml, money)
+ xml.TrnType "2"
+ add_credit_card(xml, payment)
+ add_credentials(xml)
+ xml.TrnSource options[:ip]
+ end
+ end
+ end
+
+ def capture(money, authorization, options={})
+ commit("SubmitSingleCapture") do |xml|
+ xml.Capture do
+ xml.Receipt authorization
+ add_amount(xml, money)
+ add_credentials(xml)
+ end
+ end
+ end
+
+ def refund(money, authorization, options={})
+ commit("SubmitSingleRefund") do |xml|
+ xml.Refund do
+ xml.Receipt authorization
+ add_amount(xml, money)
+ add_credentials(xml)
+ end
+ end
+ end
+
+ def supports_scrubbing?
+ true
+ end
+
+ def scrub(transcript)
+ transcript.
+ gsub(%r(()[^<]+(<))i, '\1[FILTERED]\2').
+ gsub(%r(()[^<]+(<))i, '\1[FILTERED]\2').
+ gsub(%r(()[^<]+(<))i, '\1[FILTERED]\2')
+ end
+
+ private
+
+ def add_credentials(xml)
+ username, account_number = options[:username].split(":")
+ unless account_number.nil?
+ xml.AccountNumber account_number
+ end
+ xml.Security do
+ xml.UserName username
+ xml.Password @options[:password]
+ end
+ end
+
+ def add_amount(xml, money)
+ xml.Amount amount(money)
+ end
+
+ def add_credit_card(xml, payment)
+ xml.CreditCard :Registered => "False" do
+ xml.CardNumber payment.number
+ xml.ExpM format(payment.month, :two_digits)
+ xml.ExpY format(payment.year, :four_digits)
+ xml.CVN payment.verification_value
+ xml.CardHolderName payment.name
+ end
+ end
+
+ def parse(body)
+ element = Nokogiri::XML(body).root.first_element_child.first_element_child
+
+ response = {}
+ doc = Nokogiri::XML(element)
+ doc.root.elements.each do |e|
+ response[e.name.underscore.to_sym] = e.inner_text
+ end
+ response
+ end
+
+ def commit(action, &block)
+ headers = {
+ "Content-Type" => "text/xml; charset=utf-8",
+ "SOAPAction" => "http://www.ippayments.com.au/interface/api/dts/#{action}",
+ }
+ response = parse(ssl_post(commit_url, new_submit_xml(action, &block), headers))
+
+ Response.new(
+ success_from(response),
+ message_from(response),
+ response,
+ authorization: authorization_from(response),
+ error_code: error_code_from(response),
+ test: test?,
+ )
+ end
+
+ def new_submit_xml(action)
+ xml = Builder::XmlMarkup.new(indent: 2)
+ xml.instruct!
+ xml.soap :Envelope, "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance", "xmlns:xsd" => "http://www.w3.org/2001/XMLSchema", "xmlns:soap" => "http://schemas.xmlsoap.org/soap/envelope/" do
+ xml.soap :Body do
+ xml.__send__(action, "xmlns" => "http://www.ippayments.com.au/interface/api/dts") do
+ xml.trnXML do
+ inner_xml = Builder::XmlMarkup.new(indent: 2)
+ yield(inner_xml)
+ xml.cdata!(inner_xml.target!)
+ end
+ end
+ end
+ end
+ xml.target!
+ end
+
+ def commit_url
+ (test? ? test_url : live_url)
+ end
+
+ def success_from(response)
+ (response[:response_code] == "0")
+ end
+
+ def error_code_from(response)
+ STANDARD_ERROR_CODE_MAPPING[response[:declined_code]]
+ end
+
+ def message_from(response)
+ response[:declined_message]
+ end
+
+ def authorization_from(response)
+ response[:receipt]
+ end
+ end
+ end
+end
diff --git a/lib/active_merchant/billing/gateways/ipp.rb b/lib/active_merchant/billing/gateways/ipp.rb
index 7813de28e1c..49bcaf764f8 100644
--- a/lib/active_merchant/billing/gateways/ipp.rb
+++ b/lib/active_merchant/billing/gateways/ipp.rb
@@ -22,6 +22,7 @@ class IppGateway < Gateway
}
def initialize(options={})
+ ActiveMerchant.deprecated("IPP gateway is now named Bambora")
requires!(options, :username, :password)
super
end
diff --git a/test/fixtures.yml b/test/fixtures.yml
index 7ad8b36e3f2..e4b7cbc7040 100644
--- a/test/fixtures.yml
+++ b/test/fixtures.yml
@@ -36,6 +36,14 @@ axcessms:
balanced:
login: 'e1c5ad38d1c711e1b36c026ba7e239a9'
+bambora:
+ username: nmi.api
+ password: qwerty123
+
+bambora_ready:
+ username: nmi.api:747
+ password: qwerty123
+
# Bank Frick doesn't provide public testing data
bank_frick:
sender: sender-uuid
diff --git a/test/remote/gateways/remote_bambora_ready_test.rb b/test/remote/gateways/remote_bambora_ready_test.rb
new file mode 100644
index 00000000000..374c43c6276
--- /dev/null
+++ b/test/remote/gateways/remote_bambora_ready_test.rb
@@ -0,0 +1,77 @@
+require 'test_helper'
+
+class RemoteBamboraReadyTest < Test::Unit::TestCase
+ def setup
+ @gateway = BamboraGateway.new(fixtures(:bambora_ready))
+
+ @credit_card = credit_card('4005550000000001')
+
+ @options = {
+ order_id: '1',
+ billing_address: address,
+ description: 'Store Purchase',
+ }
+ end
+
+ def test_transcript_scrubbing
+ transcript = capture_transcript(@gateway) do
+ @gateway.purchase(200, @credit_card, @options)
+ end
+ transcript = @gateway.scrub(transcript)
+
+ assert_scrubbed(@credit_card.number, transcript)
+ assert_scrubbed(@credit_card.verification_value, transcript)
+ assert_scrubbed(@gateway.options[:password], transcript)
+ end
+
+ def test_successful_purchase
+ response = @gateway.purchase(200, @credit_card, @options)
+ assert_success response
+ assert_equal '', response.message
+ end
+
+ def test_failed_purchase
+ response = @gateway.purchase(105, @credit_card, @options)
+ assert_failure response
+ end
+
+ def test_successful_authorize_and_capture
+ response = @gateway.authorize(200, @credit_card, @options)
+ assert_success response
+ response = @gateway.capture(200, response.authorization)
+ assert_success response
+ end
+
+ def test_failed_authorize
+ response = @gateway.authorize(105, @credit_card, @options)
+ assert_failure response
+ end
+
+ def test_failed_capture
+ response = @gateway.capture(200, '')
+ assert_failure response
+ end
+
+ def test_successful_refund
+ response = @gateway.purchase(200, @credit_card, @options)
+ response = @gateway.refund(200, response.authorization, @options)
+ assert_success response
+ assert_equal '', response.message
+ end
+
+ def test_failed_refund
+ response = @gateway.purchase(200, @credit_card, @options)
+ response = @gateway.refund(105, response.authorization, @options)
+ assert_failure response
+ assert_equal 'Do Not Honour', response.message
+ end
+
+ def test_invalid_login
+ gateway = BamboraGateway.new(
+ username: '',
+ password: '',
+ )
+ response = gateway.purchase(200, @credit_card, @options)
+ assert_failure response
+ end
+end
diff --git a/test/remote/gateways/remote_bambora_test.rb b/test/remote/gateways/remote_bambora_test.rb
new file mode 100644
index 00000000000..0582fce8bd4
--- /dev/null
+++ b/test/remote/gateways/remote_bambora_test.rb
@@ -0,0 +1,77 @@
+require 'test_helper'
+
+class RemoteBamboraTest < Test::Unit::TestCase
+ def setup
+ @gateway = BamboraGateway.new(fixtures(:bambora))
+
+ @credit_card = credit_card('4005550000000001')
+
+ @options = {
+ order_id: '1',
+ billing_address: address,
+ description: 'Store Purchase',
+ }
+ end
+
+ def test_transcript_scrubbing
+ transcript = capture_transcript(@gateway) do
+ @gateway.purchase(200, @credit_card, @options)
+ end
+ transcript = @gateway.scrub(transcript)
+
+ assert_scrubbed(@credit_card.number, transcript)
+ assert_scrubbed(@credit_card.verification_value, transcript)
+ assert_scrubbed(@gateway.options[:password], transcript)
+ end
+
+ def test_successful_purchase
+ response = @gateway.purchase(200, @credit_card, @options)
+ assert_success response
+ assert_equal '', response.message
+ end
+
+ def test_failed_purchase
+ response = @gateway.purchase(105, @credit_card, @options)
+ assert_failure response
+ end
+
+ def test_successful_authorize_and_capture
+ response = @gateway.authorize(200, @credit_card, @options)
+ assert_success response
+ response = @gateway.capture(200, response.authorization)
+ assert_success response
+ end
+
+ def test_failed_authorize
+ response = @gateway.authorize(105, @credit_card, @options)
+ assert_failure response
+ end
+
+ def test_failed_capture
+ response = @gateway.capture(200, '')
+ assert_failure response
+ end
+
+ def test_successful_refund
+ response = @gateway.purchase(200, @credit_card, @options)
+ response = @gateway.refund(200, response.authorization, @options)
+ assert_success response
+ assert_equal '', response.message
+ end
+
+ def test_failed_refund
+ response = @gateway.purchase(200, @credit_card, @options)
+ response = @gateway.refund(105, response.authorization, @options)
+ assert_failure response
+ assert_equal 'Do Not Honour', response.message
+ end
+
+ def test_invalid_login
+ gateway = BamboraGateway.new(
+ username: '',
+ password: '',
+ )
+ response = gateway.purchase(200, @credit_card, @options)
+ assert_failure response
+ end
+end
diff --git a/test/unit/gateways/bambora_ready_test.rb b/test/unit/gateways/bambora_ready_test.rb
new file mode 100644
index 00000000000..d11589f4faa
--- /dev/null
+++ b/test/unit/gateways/bambora_ready_test.rb
@@ -0,0 +1,105 @@
+require 'test_helper'
+
+class BamboraReadyTest < Test::Unit::TestCase
+ include CommStub
+
+ def setup
+ @gateway = BamboraGateway.new(
+ username: 'username:123',
+ password: 'password',
+ )
+
+ @amount = 100
+ @credit_card = credit_card
+ end
+
+ def test_successful_purchase
+ response = stub_comms do
+ @gateway.purchase(@amount, @credit_card, order_id: 1)
+ end.check_request do |endpoint, data, headers|
+ assert_match(%r{username<}, data)
+ assert_match(%r{password<}, data)
+ assert_match(%r{123<}, data)
+ assert_match(%r{1<}, data)
+ assert_match(%r{100<}, data)
+ assert_match(%r{1<}, data)
+ assert_match(%r{#{@credit_card.number}<}, data)
+ assert_match(%r{#{"%02d" % @credit_card.month}<}, data)
+ assert_match(%r{#{@credit_card.year}<}, data)
+ assert_match(%r{#{@credit_card.verification_value}<}, data)
+ assert_match(%r{#{@credit_card.name}<}, data)
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_scrub
+ assert @gateway.supports_scrubbing?
+ assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed
+ end
+
+ private
+
+ def pre_scrubbed
+ <<-'PRE_SCRUBBED'
+opening connection to demo.ippayments.com.au:443...
+opened
+starting SSL for demo.ippayments.com.au:443...
+SSL established
+<- "POST /interface/api/dts.asmx HTTP/1.1\r\nContent-Type: text/xml; charset=utf-8\r\nSoapaction: http://www.ippayments.com.au/interface/api/dts/SubmitSinglePayment\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: demo.ippayments.com.au\r\nContent-Length: 822\r\n\r\n"
+<- "\n\n \n \n \n \n 1\n \n 1\n \n 4005550000000001\n 09\n 2015\n 123\n Longbob Longsen\n \n 123\n \n nmi.api\n qwerty123\n \n \n\n]]>\n \n \n \n\n"
+-> "HTTP/1.1 200 OK\r\n"
+-> "Server: Microsoft-IIS/6.0\r\n"
+-> "X-Robots-Tag: noindex\r\n"
+-> "X-Powered-By: ASP.NET\r\n"
+-> "Cache-Control: private, max-age=0\r\n"
+-> "Content-Type: text/xml; charset=utf-8\r\n"
+-> "Content-Length: 767\r\n"
+-> "Date: Fri, 19 Dec 2014 19:55:13 GMT\r\n"
+-> "Connection: close\r\n"
+-> "\r\n"
+reading 767 bytes...
+-> "<Response>\r\n\t<ResponseCode>1</ResponseCode>\r\n\t<Timestamp>20-Dec-2014 06:55:17</Timestamp>\r\n\t<Receipt></Receipt>\r\n\t<SettlementDate></SettlementDate>\r\n\t<DeclinedCode>183</DeclinedCode>\r\n\t<DeclinedMessage>Exception parsing transaction XML</DeclinedMessage>\r\n</Response>\r\n"
+read 767 bytes
+Conn close
+ PRE_SCRUBBED
+ end
+
+ def post_scrubbed
+ <<-'POST_SCRUBBED'
+opening connection to demo.ippayments.com.au:443...
+opened
+starting SSL for demo.ippayments.com.au:443...
+SSL established
+<- "POST /interface/api/dts.asmx HTTP/1.1\r\nContent-Type: text/xml; charset=utf-8\r\nSoapaction: http://www.ippayments.com.au/interface/api/dts/SubmitSinglePayment\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: demo.ippayments.com.au\r\nContent-Length: 822\r\n\r\n"
+<- "\n\n \n \n \n \n 1\n \n 1\n \n [FILTERED]\n 09\n 2015\n [FILTERED]\n Longbob Longsen\n \n 123\n \n nmi.api\n [FILTERED]\n \n \n\n]]>\n \n \n \n\n"
+-> "HTTP/1.1 200 OK\r\n"
+-> "Server: Microsoft-IIS/6.0\r\n"
+-> "X-Robots-Tag: noindex\r\n"
+-> "X-Powered-By: ASP.NET\r\n"
+-> "Cache-Control: private, max-age=0\r\n"
+-> "Content-Type: text/xml; charset=utf-8\r\n"
+-> "Content-Length: 767\r\n"
+-> "Date: Fri, 19 Dec 2014 19:55:13 GMT\r\n"
+-> "Connection: close\r\n"
+-> "\r\n"
+reading 767 bytes...
+-> "<Response>\r\n\t<ResponseCode>1</ResponseCode>\r\n\t<Timestamp>20-Dec-2014 06:55:17</Timestamp>\r\n\t<Receipt></Receipt>\r\n\t<SettlementDate></SettlementDate>\r\n\t<DeclinedCode>183</DeclinedCode>\r\n\t<DeclinedMessage>Exception parsing transaction XML</DeclinedMessage>\r\n</Response>\r\n"
+read 767 bytes
+Conn close
+ POST_SCRUBBED
+ end
+
+ def successful_purchase_response
+ <<-XML
+<Response>
+ <ResponseCode>0</ResponseCode>
+ <Timestamp>20-Dec-2014 04:07:39</Timestamp>
+ <Receipt>89435577</Receipt>
+ <SettlementDate>22-Dec-2014</SettlementDate>
+ <DeclinedCode></DeclinedCode>
+ <DeclinedMessage></DeclinedMessage>
+</Response>
+
+ XML
+ end
+end
diff --git a/test/unit/gateways/bambora_test.rb b/test/unit/gateways/bambora_test.rb
new file mode 100644
index 00000000000..2df9eef36ea
--- /dev/null
+++ b/test/unit/gateways/bambora_test.rb
@@ -0,0 +1,211 @@
+require 'test_helper'
+
+class BamboraTest < Test::Unit::TestCase
+ include CommStub
+
+ def setup
+ @gateway = BamboraGateway.new(
+ username: 'username',
+ password: 'password',
+ )
+
+ @amount = 100
+ @credit_card = credit_card
+ end
+
+ def test_successful_purchase
+ response = stub_comms do
+ @gateway.purchase(@amount, @credit_card, order_id: 1)
+ end.check_request do |endpoint, data, headers|
+ assert_match(%r{username<}, data)
+ assert_match(%r{password<}, data)
+ assert_match(%r{1<}, data)
+ assert_match(%r{100<}, data)
+ assert_match(%r{1<}, data)
+ assert_match(%r{#{@credit_card.number}<}, data)
+ assert_match(%r{#{"%02d" % @credit_card.month}<}, data)
+ assert_match(%r{#{@credit_card.year}<}, data)
+ assert_match(%r{#{@credit_card.verification_value}<}, data)
+ assert_match(%r{#{@credit_card.name}<}, data)
+ end.respond_with(successful_purchase_response)
+
+ assert_success response
+ assert_equal "89435577", response.authorization
+ end
+
+ def test_failed_purchase
+ response = stub_comms do
+ @gateway.purchase(@amount, @credit_card)
+ end.respond_with(failed_purchase_response)
+
+ assert_failure response
+ assert_equal "Do Not Honour", response.message
+ assert_equal Gateway::STANDARD_ERROR_CODE[:card_declined], response.error_code
+ assert_equal "", response.authorization
+ end
+
+ def test_successful_authorize
+ response = stub_comms do
+ @gateway.authorize(@amount, @credit_card, order_id: 1)
+ end.check_request do |endpoint, data, headers|
+ assert_match(%r{1<}, data)
+ assert_match(%r{2<}, data)
+ end.respond_with(successful_authorize_response)
+
+ assert_success response
+ assert_equal "89435583", response.authorization
+ end
+
+ def test_successful_capture
+ response = stub_comms do
+ @gateway.capture(@amount, "receipt")
+ end.check_request do |endpoint, data, headers|
+ assert_match(%r{receipt<}, data)
+ assert_match(%r{100<}, data)
+ end.respond_with(successful_capture_response)
+
+ assert_success response
+ end
+
+ def test_successful_refund
+ response = stub_comms do
+ @gateway.refund(@amount, "receipt")
+ end.check_request do |endpoint, data, headers|
+ assert_match(%r{receipt<}, data)
+ assert_match(%r{100<}, data)
+ end.respond_with(successful_refund_response)
+
+ assert_success response
+ end
+
+ def test_scrub
+ assert @gateway.supports_scrubbing?
+ assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed
+ end
+
+ private
+
+ def pre_scrubbed
+ <<-'PRE_SCRUBBED'
+opening connection to demo.ippayments.com.au:443...
+opened
+starting SSL for demo.ippayments.com.au:443...
+SSL established
+<- "POST /interface/api/dts.asmx HTTP/1.1\r\nContent-Type: text/xml; charset=utf-8\r\nSoapaction: http://www.ippayments.com.au/interface/api/dts/SubmitSinglePayment\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: demo.ippayments.com.au\r\nContent-Length: 822\r\n\r\n"
+<- "\n\n \n \n \n \n 1\n \n 1\n \n 4005550000000001\n 09\n 2015\n 123\n Longbob Longsen\n \n \n nmi.api\n qwerty123\n \n \n\n]]>\n \n \n \n\n"
+-> "HTTP/1.1 200 OK\r\n"
+-> "Server: Microsoft-IIS/6.0\r\n"
+-> "X-Robots-Tag: noindex\r\n"
+-> "X-Powered-By: ASP.NET\r\n"
+-> "Cache-Control: private, max-age=0\r\n"
+-> "Content-Type: text/xml; charset=utf-8\r\n"
+-> "Content-Length: 767\r\n"
+-> "Date: Fri, 19 Dec 2014 19:55:13 GMT\r\n"
+-> "Connection: close\r\n"
+-> "\r\n"
+reading 767 bytes...
+-> "<Response>\r\n\t<ResponseCode>1</ResponseCode>\r\n\t<Timestamp>20-Dec-2014 06:55:17</Timestamp>\r\n\t<Receipt></Receipt>\r\n\t<SettlementDate></SettlementDate>\r\n\t<DeclinedCode>183</DeclinedCode>\r\n\t<DeclinedMessage>Exception parsing transaction XML</DeclinedMessage>\r\n</Response>\r\n"
+read 767 bytes
+Conn close
+ PRE_SCRUBBED
+ end
+
+ def post_scrubbed
+ <<-'POST_SCRUBBED'
+opening connection to demo.ippayments.com.au:443...
+opened
+starting SSL for demo.ippayments.com.au:443...
+SSL established
+<- "POST /interface/api/dts.asmx HTTP/1.1\r\nContent-Type: text/xml; charset=utf-8\r\nSoapaction: http://www.ippayments.com.au/interface/api/dts/SubmitSinglePayment\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: demo.ippayments.com.au\r\nContent-Length: 822\r\n\r\n"
+<- "\n\n \n \n \n \n 1\n \n 1\n \n [FILTERED]\n 09\n 2015\n [FILTERED]\n Longbob Longsen\n \n \n nmi.api\n [FILTERED]\n \n \n\n]]>\n \n \n \n\n"
+-> "HTTP/1.1 200 OK\r\n"
+-> "Server: Microsoft-IIS/6.0\r\n"
+-> "X-Robots-Tag: noindex\r\n"
+-> "X-Powered-By: ASP.NET\r\n"
+-> "Cache-Control: private, max-age=0\r\n"
+-> "Content-Type: text/xml; charset=utf-8\r\n"
+-> "Content-Length: 767\r\n"
+-> "Date: Fri, 19 Dec 2014 19:55:13 GMT\r\n"
+-> "Connection: close\r\n"
+-> "\r\n"
+reading 767 bytes...
+-> "<Response>\r\n\t<ResponseCode>1</ResponseCode>\r\n\t<Timestamp>20-Dec-2014 06:55:17</Timestamp>\r\n\t<Receipt></Receipt>\r\n\t<SettlementDate></SettlementDate>\r\n\t<DeclinedCode>183</DeclinedCode>\r\n\t<DeclinedMessage>Exception parsing transaction XML</DeclinedMessage>\r\n</Response>\r\n"
+read 767 bytes
+Conn close
+ POST_SCRUBBED
+ end
+
+ def successful_purchase_response
+ <<-XML
+<Response>
+ <ResponseCode>0</ResponseCode>
+ <Timestamp>20-Dec-2014 04:07:39</Timestamp>
+ <Receipt>89435577</Receipt>
+ <SettlementDate>22-Dec-2014</SettlementDate>
+ <DeclinedCode></DeclinedCode>
+ <DeclinedMessage></DeclinedMessage>
+</Response>
+
+ XML
+ end
+
+ def failed_purchase_response
+ <<-XML
+<Response>
+ <ResponseCode>1</ResponseCode>
+ <Timestamp>20-Dec-2014 04:14:56</Timestamp>
+ <Receipt></Receipt>
+ <SettlementDate>22-Dec-2014</SettlementDate>
+ <DeclinedCode>05</DeclinedCode>
+ <DeclinedMessage>Do Not Honour</DeclinedMessage>
+</Response>
+
+ XML
+ end
+
+ def successful_authorize_response
+ <<-XML
+<Response>
+ <ResponseCode>0</ResponseCode>
+ <Timestamp>20-Dec-2014 04:18:13</Timestamp>
+ <Receipt>89435583</Receipt>
+ <SettlementDate>22-Dec-2014</SettlementDate>
+ <DeclinedCode></DeclinedCode>
+ <DeclinedMessage></DeclinedMessage>
+</Response>
+
+ XML
+ end
+
+ def successful_capture_response
+ <<-XML
+<Response>
+ <ResponseCode>0</ResponseCode>
+ <Timestamp>20-Dec-2014 04:18:15</Timestamp>
+ <Receipt>89435584</Receipt>
+ <SettlementDate>22-Dec-2014</SettlementDate>
+ <DeclinedCode></DeclinedCode>
+ <DeclinedMessage></DeclinedMessage>
+</Response>
+
+ XML
+ end
+
+ def successful_refund_response
+ <<-XML
+<Response>
+ <ResponseCode>0</ResponseCode>
+ <Timestamp>20-Dec-2014 04:24:51</Timestamp>
+ <Receipt>89435596</Receipt>
+ <SettlementDate>22-Dec-2014</SettlementDate>
+ <DeclinedCode></DeclinedCode>
+ <DeclinedMessage></DeclinedMessage>
+</Response>
+
+ XML
+ end
+end
From 776f0735d81d69ec46d943644dd65b175ba7ea10 Mon Sep 17 00:00:00 2001
From: molbrown
Date: Mon, 18 Feb 2019 14:49:15 -0500
Subject: [PATCH 0276/2234] Bambora Asia-Pacific: Updates Gateway
Renames to Bambora Asia-Pacific, removes Bambora Ready, adds
void action
ECS-159
Unit:
7 tests, 47 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
11 tests, 20 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Closes #3145
---
CHANGELOG | 2 +
README.md | 2 +-
.../gateways/{bambora.rb => bambora_apac.rb} | 69 ++++++------
lib/active_merchant/billing/gateways/ipp.rb | 2 +-
test/fixtures.yml | 4 -
...dy_test.rb => remote_bambora_apac_test.rb} | 23 +++-
test/remote/gateways/remote_bambora_test.rb | 77 -------------
.../{bambora_test.rb => bambora_apac_test.rb} | 39 +++++--
test/unit/gateways/bambora_ready_test.rb | 105 ------------------
9 files changed, 91 insertions(+), 232 deletions(-)
rename lib/active_merchant/billing/gateways/{bambora.rb => bambora_apac.rb} (68%)
rename test/remote/gateways/{remote_bambora_ready_test.rb => remote_bambora_apac_test.rb} (75%)
delete mode 100644 test/remote/gateways/remote_bambora_test.rb
rename test/unit/gateways/{bambora_test.rb => bambora_apac_test.rb} (89%)
delete mode 100644 test/unit/gateways/bambora_ready_test.rb
diff --git a/CHANGELOG b/CHANGELOG
index 4c6d4405c08..555c2e907bf 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -31,6 +31,8 @@
* Fat Zebra: Support voids [curiousepic] #3142
* Blue Snap: Support ACH/ECP payments [jknipp] #3143
* Blue Snap: Fix Card-on-File field typo [jknipp] #3143
+* Add Bambora gateway [InfraRuby] #3145
+* Bambora Asia-Pacific: Updates Gateway [molbrown] #3145
== Version 1.90.0 (January 8, 2019)
* Mercado Pago: Support "gateway" processing mode [curiousepic] #3087
diff --git a/README.md b/README.md
index c14a98e1a0d..ddf4a57de39 100644
--- a/README.md
+++ b/README.md
@@ -92,7 +92,7 @@ The [ActiveMerchant Wiki](http://github.com/activemerchant/active_merchant/wikis
* [Authorize.Net](http://www.authorize.net/) - AD, AT, AU, BE, BG, CA, CH, CY, CZ, DE, DK, ES, FI, FR, GB, GB, GI, GR, HU, IE, IT, LI, LU, MC, MT, NL, NO, PL, PT, RO, SE, SI, SK, SM, TR, US, VA
* [Axcess MS](http://www.axcessms.com/) - AD, AT, BE, BG, BR, CA, CH, CY, CZ, DE, DK, EE, ES, FI, FO, FR, GB, GI, GR, HR, HU, IE, IL, IM, IS, IT, LI, LT, LU, LV, MC, MT, MX, NL, NO, PL, PT, RO, RU, SE, SI, SK, TR, US, VA
* [Balanced](https://www.balancedpayments.com/) - US
-* [Bambora](http://www.bambora.com/) - AU, NZ
+* [Bambora Asia-Pacific](http://www.bambora.com/) - AU, NZ
* [Bank Frick](http://www.bankfrickacquiring.com/) - LI, US
* [Banwire](http://www.banwire.com/) - MX
* [Barclays ePDQ Extra Plus](http://www.barclaycard.co.uk/business/accepting-payments/epdq-ecomm/) - GB
diff --git a/lib/active_merchant/billing/gateways/bambora.rb b/lib/active_merchant/billing/gateways/bambora_apac.rb
similarity index 68%
rename from lib/active_merchant/billing/gateways/bambora.rb
rename to lib/active_merchant/billing/gateways/bambora_apac.rb
index 6371927c03b..bcf4b9d8b62 100644
--- a/lib/active_merchant/billing/gateways/bambora.rb
+++ b/lib/active_merchant/billing/gateways/bambora_apac.rb
@@ -1,8 +1,8 @@
-require "nokogiri"
+require 'nokogiri'
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
- class BamboraGateway < Gateway
+ class BamboraApacGateway < Gateway
self.live_url = 'https://www.bambora.co.nz/interface/api/dts.asmx'
self.test_url = 'https://demo.bambora.co.nz/interface/api/dts.asmx'
@@ -10,15 +10,15 @@ class BamboraGateway < Gateway
self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :jcb]
self.homepage_url = 'http://www.bambora.com/'
- self.display_name = 'Bambora'
+ self.display_name = 'Bambora Asia-Pacific'
self.money_format = :cents
STANDARD_ERROR_CODE_MAPPING = {
- "05" => STANDARD_ERROR_CODE[:card_declined],
- "06" => STANDARD_ERROR_CODE[:processing_error],
- "14" => STANDARD_ERROR_CODE[:invalid_number],
- "54" => STANDARD_ERROR_CODE[:expired_card],
+ '05' => STANDARD_ERROR_CODE[:card_declined],
+ '06' => STANDARD_ERROR_CODE[:processing_error],
+ '14' => STANDARD_ERROR_CODE[:invalid_number],
+ '54' => STANDARD_ERROR_CODE[:expired_card],
}
def initialize(options={})
@@ -27,47 +27,57 @@ def initialize(options={})
end
def purchase(money, payment, options={})
- commit("SubmitSinglePayment") do |xml|
+ commit('SubmitSinglePayment') do |xml|
xml.Transaction do
xml.CustRef options[:order_id]
add_amount(xml, money)
- xml.TrnType "1"
+ xml.TrnType '1'
add_credit_card(xml, payment)
- add_credentials(xml)
+ add_credentials(xml, options)
xml.TrnSource options[:ip]
end
end
end
def authorize(money, payment, options={})
- commit("SubmitSinglePayment") do |xml|
+ commit('SubmitSinglePayment') do |xml|
xml.Transaction do
xml.CustRef options[:order_id]
add_amount(xml, money)
- xml.TrnType "2"
+ xml.TrnType '2'
add_credit_card(xml, payment)
- add_credentials(xml)
+ add_credentials(xml, options)
xml.TrnSource options[:ip]
end
end
end
def capture(money, authorization, options={})
- commit("SubmitSingleCapture") do |xml|
+ commit('SubmitSingleCapture') do |xml|
xml.Capture do
xml.Receipt authorization
add_amount(xml, money)
- add_credentials(xml)
+ add_credentials(xml, options)
end
end
end
def refund(money, authorization, options={})
- commit("SubmitSingleRefund") do |xml|
+ commit('SubmitSingleRefund') do |xml|
xml.Refund do
xml.Receipt authorization
add_amount(xml, money)
- add_credentials(xml)
+ add_credentials(xml, options)
+ end
+ end
+ end
+
+ def void(money, authorization, options={})
+ commit('SubmitSingleVoid') do |xml|
+ xml.Void do
+ xml.Receipt authorization
+ add_amount(xml, money)
+ add_credentials(xml, options)
end
end
end
@@ -85,13 +95,10 @@ def scrub(transcript)
private
- def add_credentials(xml)
- username, account_number = options[:username].split(":")
- unless account_number.nil?
- xml.AccountNumber account_number
- end
+ def add_credentials(xml, options)
+ xml.AccountNumber options[:account_number] if options[:account_number]
xml.Security do
- xml.UserName username
+ xml.UserName @options[:username]
xml.Password @options[:password]
end
end
@@ -101,7 +108,7 @@ def add_amount(xml, money)
end
def add_credit_card(xml, payment)
- xml.CreditCard :Registered => "False" do
+ xml.CreditCard :Registered => 'False' do
xml.CardNumber payment.number
xml.ExpM format(payment.month, :two_digits)
xml.ExpY format(payment.year, :four_digits)
@@ -123,8 +130,8 @@ def parse(body)
def commit(action, &block)
headers = {
- "Content-Type" => "text/xml; charset=utf-8",
- "SOAPAction" => "http://www.ippayments.com.au/interface/api/dts/#{action}",
+ 'Content-Type' => 'text/xml; charset=utf-8',
+ 'SOAPAction' => "http://www.ippayments.com.au/interface/api/dts/#{action}",
}
response = parse(ssl_post(commit_url, new_submit_xml(action, &block), headers))
@@ -134,16 +141,16 @@ def commit(action, &block)
response,
authorization: authorization_from(response),
error_code: error_code_from(response),
- test: test?,
+ test: test?
)
end
def new_submit_xml(action)
xml = Builder::XmlMarkup.new(indent: 2)
xml.instruct!
- xml.soap :Envelope, "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance", "xmlns:xsd" => "http://www.w3.org/2001/XMLSchema", "xmlns:soap" => "http://schemas.xmlsoap.org/soap/envelope/" do
+ xml.soap :Envelope, 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema', 'xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/' do
xml.soap :Body do
- xml.__send__(action, "xmlns" => "http://www.ippayments.com.au/interface/api/dts") do
+ xml.__send__(action, 'xmlns' => 'http://www.ippayments.com.au/interface/api/dts') do
xml.trnXML do
inner_xml = Builder::XmlMarkup.new(indent: 2)
yield(inner_xml)
@@ -156,11 +163,11 @@ def new_submit_xml(action)
end
def commit_url
- (test? ? test_url : live_url)
+ test? ? test_url : live_url
end
def success_from(response)
- (response[:response_code] == "0")
+ response[:response_code] == '0'
end
def error_code_from(response)
diff --git a/lib/active_merchant/billing/gateways/ipp.rb b/lib/active_merchant/billing/gateways/ipp.rb
index 49bcaf764f8..fa672636787 100644
--- a/lib/active_merchant/billing/gateways/ipp.rb
+++ b/lib/active_merchant/billing/gateways/ipp.rb
@@ -22,7 +22,7 @@ class IppGateway < Gateway
}
def initialize(options={})
- ActiveMerchant.deprecated("IPP gateway is now named Bambora")
+ ActiveMerchant.deprecated('IPP gateway is now named Bambora Asia-Pacific')
requires!(options, :username, :password)
super
end
diff --git a/test/fixtures.yml b/test/fixtures.yml
index e4b7cbc7040..b1cdab09cc3 100644
--- a/test/fixtures.yml
+++ b/test/fixtures.yml
@@ -40,10 +40,6 @@ bambora:
username: nmi.api
password: qwerty123
-bambora_ready:
- username: nmi.api:747
- password: qwerty123
-
# Bank Frick doesn't provide public testing data
bank_frick:
sender: sender-uuid
diff --git a/test/remote/gateways/remote_bambora_ready_test.rb b/test/remote/gateways/remote_bambora_apac_test.rb
similarity index 75%
rename from test/remote/gateways/remote_bambora_ready_test.rb
rename to test/remote/gateways/remote_bambora_apac_test.rb
index 374c43c6276..a8d75d74690 100644
--- a/test/remote/gateways/remote_bambora_ready_test.rb
+++ b/test/remote/gateways/remote_bambora_apac_test.rb
@@ -1,8 +1,8 @@
require 'test_helper'
-class RemoteBamboraReadyTest < Test::Unit::TestCase
+class RemoteBamboraApacTest < Test::Unit::TestCase
def setup
- @gateway = BamboraGateway.new(fixtures(:bambora_ready))
+ @gateway = BamboraApacGateway.new(fixtures(:bambora))
@credit_card = credit_card('4005550000000001')
@@ -66,10 +66,25 @@ def test_failed_refund
assert_equal 'Do Not Honour', response.message
end
+ def test_successful_void
+ response = @gateway.purchase(200, @credit_card, @options)
+ assert_success response
+ response = @gateway.void(200, response.authorization)
+ assert_success response
+ end
+
+ def test_failed_void
+ response = @gateway.purchase(200, @credit_card, @options)
+ assert_success response
+ response = @gateway.void(200, 123)
+ assert_failure response
+ assert_equal 'Cannot find matching transaction to VOID', response.message
+ end
+
def test_invalid_login
- gateway = BamboraGateway.new(
+ gateway = BamboraApacGateway.new(
username: '',
- password: '',
+ password: ''
)
response = gateway.purchase(200, @credit_card, @options)
assert_failure response
diff --git a/test/remote/gateways/remote_bambora_test.rb b/test/remote/gateways/remote_bambora_test.rb
deleted file mode 100644
index 0582fce8bd4..00000000000
--- a/test/remote/gateways/remote_bambora_test.rb
+++ /dev/null
@@ -1,77 +0,0 @@
-require 'test_helper'
-
-class RemoteBamboraTest < Test::Unit::TestCase
- def setup
- @gateway = BamboraGateway.new(fixtures(:bambora))
-
- @credit_card = credit_card('4005550000000001')
-
- @options = {
- order_id: '1',
- billing_address: address,
- description: 'Store Purchase',
- }
- end
-
- def test_transcript_scrubbing
- transcript = capture_transcript(@gateway) do
- @gateway.purchase(200, @credit_card, @options)
- end
- transcript = @gateway.scrub(transcript)
-
- assert_scrubbed(@credit_card.number, transcript)
- assert_scrubbed(@credit_card.verification_value, transcript)
- assert_scrubbed(@gateway.options[:password], transcript)
- end
-
- def test_successful_purchase
- response = @gateway.purchase(200, @credit_card, @options)
- assert_success response
- assert_equal '', response.message
- end
-
- def test_failed_purchase
- response = @gateway.purchase(105, @credit_card, @options)
- assert_failure response
- end
-
- def test_successful_authorize_and_capture
- response = @gateway.authorize(200, @credit_card, @options)
- assert_success response
- response = @gateway.capture(200, response.authorization)
- assert_success response
- end
-
- def test_failed_authorize
- response = @gateway.authorize(105, @credit_card, @options)
- assert_failure response
- end
-
- def test_failed_capture
- response = @gateway.capture(200, '')
- assert_failure response
- end
-
- def test_successful_refund
- response = @gateway.purchase(200, @credit_card, @options)
- response = @gateway.refund(200, response.authorization, @options)
- assert_success response
- assert_equal '', response.message
- end
-
- def test_failed_refund
- response = @gateway.purchase(200, @credit_card, @options)
- response = @gateway.refund(105, response.authorization, @options)
- assert_failure response
- assert_equal 'Do Not Honour', response.message
- end
-
- def test_invalid_login
- gateway = BamboraGateway.new(
- username: '',
- password: '',
- )
- response = gateway.purchase(200, @credit_card, @options)
- assert_failure response
- end
-end
diff --git a/test/unit/gateways/bambora_test.rb b/test/unit/gateways/bambora_apac_test.rb
similarity index 89%
rename from test/unit/gateways/bambora_test.rb
rename to test/unit/gateways/bambora_apac_test.rb
index 2df9eef36ea..3b4e62c2977 100644
--- a/test/unit/gateways/bambora_test.rb
+++ b/test/unit/gateways/bambora_apac_test.rb
@@ -1,12 +1,12 @@
require 'test_helper'
-class BamboraTest < Test::Unit::TestCase
+class BamboraApacTest < Test::Unit::TestCase
include CommStub
def setup
- @gateway = BamboraGateway.new(
+ @gateway = BamboraApacGateway.new(
username: 'username',
- password: 'password',
+ password: 'password'
)
@amount = 100
@@ -31,7 +31,7 @@ def test_successful_purchase
end.respond_with(successful_purchase_response)
assert_success response
- assert_equal "89435577", response.authorization
+ assert_equal '89435577', response.authorization
end
def test_failed_purchase
@@ -40,9 +40,9 @@ def test_failed_purchase
end.respond_with(failed_purchase_response)
assert_failure response
- assert_equal "Do Not Honour", response.message
+ assert_equal 'Do Not Honour', response.message
assert_equal Gateway::STANDARD_ERROR_CODE[:card_declined], response.error_code
- assert_equal "", response.authorization
+ assert_equal '', response.authorization
end
def test_successful_authorize
@@ -55,12 +55,12 @@ def test_successful_authorize
end.respond_with(successful_authorize_response)
assert_success response
- assert_equal "89435583", response.authorization
+ assert_equal '89435583', response.authorization
end
def test_successful_capture
response = stub_comms do
- @gateway.capture(@amount, "receipt")
+ @gateway.capture(@amount, 'receipt')
end.check_request do |endpoint, data, headers|
assert_match(%r{receipt<}, data)
@@ -72,7 +72,7 @@ def test_successful_capture
def test_successful_refund
response = stub_comms do
- @gateway.refund(@amount, "receipt")
+ @gateway.refund(@amount, 'receipt')
end.check_request do |endpoint, data, headers|
assert_match(%r{receipt<}, data)
@@ -82,6 +82,16 @@ def test_successful_refund
assert_success response
end
+ def test_successful_void
+ response = stub_comms do
+ @gateway.void(@amount, 'receipt')
+ end.check_request do |endpoint, data, headers|
+ assert_match(%r{
XML
end
+
+ def successful_void_response
+ <<-XML
+<Response>
+ <ResponseCode>0</ResponseCode>
+ <DeclinedCode></DeclinedCode>
+ <DeclinedMessage></DeclinedMessage>
+ </Response>
+
+ XML
+ end
end
diff --git a/test/unit/gateways/bambora_ready_test.rb b/test/unit/gateways/bambora_ready_test.rb
deleted file mode 100644
index d11589f4faa..00000000000
--- a/test/unit/gateways/bambora_ready_test.rb
+++ /dev/null
@@ -1,105 +0,0 @@
-require 'test_helper'
-
-class BamboraReadyTest < Test::Unit::TestCase
- include CommStub
-
- def setup
- @gateway = BamboraGateway.new(
- username: 'username:123',
- password: 'password',
- )
-
- @amount = 100
- @credit_card = credit_card
- end
-
- def test_successful_purchase
- response = stub_comms do
- @gateway.purchase(@amount, @credit_card, order_id: 1)
- end.check_request do |endpoint, data, headers|
- assert_match(%r{username<}, data)
- assert_match(%r{password<}, data)
- assert_match(%r{123<}, data)
- assert_match(%r{1<}, data)
- assert_match(%r{100<}, data)
- assert_match(%r{1<}, data)
- assert_match(%r{#{@credit_card.number}<}, data)
- assert_match(%r{#{"%02d" % @credit_card.month}<}, data)
- assert_match(%r{#{@credit_card.year}<}, data)
- assert_match(%r{#{@credit_card.verification_value}<}, data)
- assert_match(%r{#{@credit_card.name}<}, data)
- end.respond_with(successful_purchase_response)
- end
-
- def test_scrub
- assert @gateway.supports_scrubbing?
- assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed
- end
-
- private
-
- def pre_scrubbed
- <<-'PRE_SCRUBBED'
-opening connection to demo.ippayments.com.au:443...
-opened
-starting SSL for demo.ippayments.com.au:443...
-SSL established
-<- "POST /interface/api/dts.asmx HTTP/1.1\r\nContent-Type: text/xml; charset=utf-8\r\nSoapaction: http://www.ippayments.com.au/interface/api/dts/SubmitSinglePayment\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: demo.ippayments.com.au\r\nContent-Length: 822\r\n\r\n"
-<- "\n\n \n \n \n \n 1\n \n 1\n \n 4005550000000001\n 09\n 2015\n 123\n Longbob Longsen\n \n 123\n \n nmi.api\n qwerty123\n \n \n\n]]>\n \n \n \n\n"
--> "HTTP/1.1 200 OK\r\n"
--> "Server: Microsoft-IIS/6.0\r\n"
--> "X-Robots-Tag: noindex\r\n"
--> "X-Powered-By: ASP.NET\r\n"
--> "Cache-Control: private, max-age=0\r\n"
--> "Content-Type: text/xml; charset=utf-8\r\n"
--> "Content-Length: 767\r\n"
--> "Date: Fri, 19 Dec 2014 19:55:13 GMT\r\n"
--> "Connection: close\r\n"
--> "\r\n"
-reading 767 bytes...
--> "<Response>\r\n\t<ResponseCode>1</ResponseCode>\r\n\t<Timestamp>20-Dec-2014 06:55:17</Timestamp>\r\n\t<Receipt></Receipt>\r\n\t<SettlementDate></SettlementDate>\r\n\t<DeclinedCode>183</DeclinedCode>\r\n\t<DeclinedMessage>Exception parsing transaction XML</DeclinedMessage>\r\n</Response>\r\n"
-read 767 bytes
-Conn close
- PRE_SCRUBBED
- end
-
- def post_scrubbed
- <<-'POST_SCRUBBED'
-opening connection to demo.ippayments.com.au:443...
-opened
-starting SSL for demo.ippayments.com.au:443...
-SSL established
-<- "POST /interface/api/dts.asmx HTTP/1.1\r\nContent-Type: text/xml; charset=utf-8\r\nSoapaction: http://www.ippayments.com.au/interface/api/dts/SubmitSinglePayment\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: demo.ippayments.com.au\r\nContent-Length: 822\r\n\r\n"
-<- "\n\n \n \n \n \n 1\n \n 1\n \n [FILTERED]\n 09\n 2015\n [FILTERED]\n Longbob Longsen\n \n 123\n \n nmi.api\n [FILTERED]\n \n \n\n]]>\n \n \n \n\n"
--> "HTTP/1.1 200 OK\r\n"
--> "Server: Microsoft-IIS/6.0\r\n"
--> "X-Robots-Tag: noindex\r\n"
--> "X-Powered-By: ASP.NET\r\n"
--> "Cache-Control: private, max-age=0\r\n"
--> "Content-Type: text/xml; charset=utf-8\r\n"
--> "Content-Length: 767\r\n"
--> "Date: Fri, 19 Dec 2014 19:55:13 GMT\r\n"
--> "Connection: close\r\n"
--> "\r\n"
-reading 767 bytes...
--> "<Response>\r\n\t<ResponseCode>1</ResponseCode>\r\n\t<Timestamp>20-Dec-2014 06:55:17</Timestamp>\r\n\t<Receipt></Receipt>\r\n\t<SettlementDate></SettlementDate>\r\n\t<DeclinedCode>183</DeclinedCode>\r\n\t<DeclinedMessage>Exception parsing transaction XML</DeclinedMessage>\r\n</Response>\r\n"
-read 767 bytes
-Conn close
- POST_SCRUBBED
- end
-
- def successful_purchase_response
- <<-XML
-<Response>
- <ResponseCode>0</ResponseCode>
- <Timestamp>20-Dec-2014 04:07:39</Timestamp>
- <Receipt>89435577</Receipt>
- <SettlementDate>22-Dec-2014</SettlementDate>
- <DeclinedCode></DeclinedCode>
- <DeclinedMessage></DeclinedMessage>
-</Response>
-
- XML
- end
-end
From 8c8b03f6bdbe91c90c6fd3ee40e0f53aace05d93 Mon Sep 17 00:00:00 2001
From: Jared Knipp
Date: Fri, 1 Feb 2019 10:55:56 -0600
Subject: [PATCH 0277/2234] PaymentExpress: Support ClientInfo field
Adds support for the ClientInfo field used to send the customer's IP
address.
ECS-124
Unit:
34 tests, 249 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
15 tests, 70 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
closes #3131
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/payment_express.rb | 5 ++++-
test/remote/gateways/remote_payment_express_test.rb | 7 +++++++
test/unit/gateways/payment_express_test.rb | 8 ++++++++
4 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 555c2e907bf..8f87c66d453 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -33,6 +33,7 @@
* Blue Snap: Fix Card-on-File field typo [jknipp] #3143
* Add Bambora gateway [InfraRuby] #3145
* Bambora Asia-Pacific: Updates Gateway [molbrown] #3145
+* PaymentExpress: Support ClientInfo field [jknipp] #3131
== Version 1.90.0 (January 8, 2019)
* Mercado Pago: Support "gateway" processing mode [curiousepic] #3087
diff --git a/lib/active_merchant/billing/gateways/payment_express.rb b/lib/active_merchant/billing/gateways/payment_express.rb
index d3e28786d8e..a739c0fd146 100644
--- a/lib/active_merchant/billing/gateways/payment_express.rb
+++ b/lib/active_merchant/billing/gateways/payment_express.rb
@@ -241,7 +241,8 @@ def add_address_verification_data(xml, options)
# :client_type => :web, # Possible values are: :web, :ivr, :moto, :unattended, :internet, or :recurring
# :txn_data1 => "String up to 255 characters",
# :txn_data2 => "String up to 255 characters",
- # :txn_data3 => "String up to 255 characters"
+ # :txn_data3 => "String up to 255 characters",
+ # :client_info => "String up to 15 characters. The IP address of the user who processed the transaction."
# }
#
# +:client_type+, while not documented for PxPost, will be sent as
@@ -277,6 +278,8 @@ def add_optional_elements(xml, options)
xml.add_element('TxnData1').text = options[:txn_data1].to_s.slice(0, 255) unless options[:txn_data1].blank?
xml.add_element('TxnData2').text = options[:txn_data2].to_s.slice(0, 255) unless options[:txn_data2].blank?
xml.add_element('TxnData3').text = options[:txn_data3].to_s.slice(0, 255) unless options[:txn_data3].blank?
+
+ xml.add_element('ClientInfo').text = options[:client_info] if options[:client_info]
end
def new_transaction
diff --git a/test/remote/gateways/remote_payment_express_test.rb b/test/remote/gateways/remote_payment_express_test.rb
index 355f1830817..86381fbcdd7 100644
--- a/test/remote/gateways/remote_payment_express_test.rb
+++ b/test/remote/gateways/remote_payment_express_test.rb
@@ -31,6 +31,13 @@ def test_successful_purchase_with_reference_id
assert_not_nil response.authorization
end
+ def test_successful_purchase_with_client_info
+ assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:client_info => '192.168.0.1'))
+ assert_success response
+ assert_equal 'The Transaction was approved', response.message
+ assert_not_nil response.authorization
+ end
+
def test_declined_purchase
assert response = @gateway.purchase(@amount, credit_card('5431111111111228'), @options)
assert_match %r{declined}i, response.message
diff --git a/test/unit/gateways/payment_express_test.rb b/test/unit/gateways/payment_express_test.rb
index 54489838560..6f9a9374eee 100644
--- a/test/unit/gateways/payment_express_test.rb
+++ b/test/unit/gateways/payment_express_test.rb
@@ -242,6 +242,14 @@ def test_pass_client_type_as_symbol_for_unknown_type_omits_element
end
end
+ def test_pass_client_info
+ options = {:client_info => '192.168.0.1'}
+
+ perform_each_transaction_type_with_request_body_assertions(options) do |body|
+ assert_match(/192.168.0.1<\/ClientInfo>/, body)
+ end
+ end
+
def test_purchase_truncates_order_id_to_16_chars
stub_comms do
@gateway.purchase(@amount, @visa, {:order_id => '16chars---------EXTRA'})
From 8d70616d9b5b122e71078a667572e52ec111bfb9 Mon Sep 17 00:00:00 2001
From: Chris Kruger
Date: Thu, 3 Jan 2019 14:54:57 +0800
Subject: [PATCH 0278/2234] Pin: Use contemporary Pin Payments URL
Unit:
37 tests, 112 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
16 tests, 46 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
closes #3098
---
README.md | 2 +-
lib/active_merchant/billing/gateways/pin.rb | 8 +++---
test/remote/gateways/remote_pin_test.rb | 2 +-
test/unit/gateways/pin_test.rb | 30 ++++++++++-----------
4 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/README.md b/README.md
index ddf4a57de39..3f3dc7e3125 100644
--- a/README.md
+++ b/README.md
@@ -193,7 +193,7 @@ The [ActiveMerchant Wiki](http://github.com/activemerchant/active_merchant/wikis
* [Paystation](http://paystation.co.nz) - NZ
* [Pay Way](http://www.payway.com.au) - AU
* [PayU India](https://www.payu.in/) - IN
-* [Pin Payments](http://www.pin.net.au/) - AU
+* [Pin Payments](http://www.pinpayments.com/) - AU
* [Plug'n Pay](http://www.plugnpay.com/) - US
* [Psigate](http://www.psigate.com/) - CA
* [PSL Payment Solutions](http://www.paymentsolutionsltd.com/) - GB
diff --git a/lib/active_merchant/billing/gateways/pin.rb b/lib/active_merchant/billing/gateways/pin.rb
index 676ffb6f7af..87fb7f7d7e2 100644
--- a/lib/active_merchant/billing/gateways/pin.rb
+++ b/lib/active_merchant/billing/gateways/pin.rb
@@ -1,14 +1,14 @@
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
class PinGateway < Gateway
- self.test_url = 'https://test-api.pin.net.au/1'
- self.live_url = 'https://api.pin.net.au/1'
+ self.test_url = 'https://test-api.pinpayments.com/1'
+ self.live_url = 'https://api.pinpayments.com/1'
self.default_currency = 'AUD'
self.money_format = :cents
self.supported_countries = ['AU']
self.supported_cardtypes = [:visa, :master, :american_express]
- self.homepage_url = 'http://www.pin.net.au/'
+ self.homepage_url = 'http://www.pinpayments.com/'
self.display_name = 'Pin Payments'
def initialize(options = {})
@@ -200,7 +200,7 @@ def error_response(body)
end
def unparsable_response(raw_response)
- message = 'Invalid JSON response received from Pin Payments. Please contact support@pin.net.au if you continue to receive this message.'
+ message = 'Invalid JSON response received from Pin Payments. Please contact support@pinpayments.com if you continue to receive this message.'
message += " (The raw response returned by the API was #{raw_response.inspect})"
return Response.new(false, message)
end
diff --git a/test/remote/gateways/remote_pin_test.rb b/test/remote/gateways/remote_pin_test.rb
index e9851eacdf6..2539bc8b616 100644
--- a/test/remote/gateways/remote_pin_test.rb
+++ b/test/remote/gateways/remote_pin_test.rb
@@ -10,7 +10,7 @@ def setup
@declined_card = credit_card('4100000000000001')
@options = {
- :email => 'roland@pin.net.au',
+ :email => 'roland@pinpayments.com',
:ip => '203.59.39.62',
:order_id => '1',
:billing_address => address,
diff --git a/test/unit/gateways/pin_test.rb b/test/unit/gateways/pin_test.rb
index 33a27b55a56..7bc943aee13 100644
--- a/test/unit/gateways/pin_test.rb
+++ b/test/unit/gateways/pin_test.rb
@@ -8,7 +8,7 @@ def setup
@amount = 100
@options = {
- :email => 'roland@pin.net.au',
+ :email => 'roland@pinpayments.com',
:billing_address => address,
:description => 'Store Purchase',
:ip => '127.0.0.1'
@@ -30,11 +30,11 @@ def test_money_format
end
def test_url
- assert_equal 'https://test-api.pin.net.au/1', PinGateway.test_url
+ assert_equal 'https://test-api.pinpayments.com/1', PinGateway.test_url
end
def test_live_url
- assert_equal 'https://api.pin.net.au/1', PinGateway.live_url
+ assert_equal 'https://api.pinpayments.com/1', PinGateway.live_url
end
def test_supported_countries
@@ -66,7 +66,7 @@ def test_successful_purchase
headers = {}
@gateway.stubs(:headers).returns(headers)
@gateway.stubs(:post_data).returns(post_data)
- @gateway.expects(:ssl_request).with(:post, 'https://test-api.pin.net.au/1/charges', post_data, headers).returns(successful_purchase_response)
+ @gateway.expects(:ssl_request).with(:post, 'https://test-api.pinpayments.com/1/charges', post_data, headers).returns(successful_purchase_response)
assert response = @gateway.purchase(@amount, @credit_card, @options)
assert_success response
@@ -120,7 +120,7 @@ def test_unsuccessful_store
def test_successful_update
token = 'cus_05p0n7UFPmcyCNjD8c6HdA'
- @gateway.expects(:ssl_request).with(:put, "https://test-api.pin.net.au/1/customers/#{token}", instance_of(String), instance_of(Hash)).returns(successful_customer_store_response)
+ @gateway.expects(:ssl_request).with(:put, "https://test-api.pinpayments.com/1/customers/#{token}", instance_of(String), instance_of(Hash)).returns(successful_customer_store_response)
assert response = @gateway.update('cus_05p0n7UFPmcyCNjD8c6HdA', @credit_card, @options)
assert_success response
assert_equal 'cus_05p0n7UFPmcyCNjD8c6HdA', response.authorization
@@ -130,7 +130,7 @@ def test_successful_update
def test_successful_refund
token = 'ch_encBuMDf17qTabmVjDsQlg'
- @gateway.expects(:ssl_request).with(:post, "https://test-api.pin.net.au/1/charges/#{token}/refunds", {:amount => '100'}.to_json, instance_of(Hash)).returns(successful_refund_response)
+ @gateway.expects(:ssl_request).with(:post, "https://test-api.pinpayments.com/1/charges/#{token}/refunds", {:amount => '100'}.to_json, instance_of(Hash)).returns(successful_refund_response)
assert response = @gateway.refund(100, token)
assert_equal 'rf_d2C7M6Mn4z2m3APqarNN6w', response.authorization
@@ -140,7 +140,7 @@ def test_successful_refund
def test_unsuccessful_refund
token = 'ch_encBuMDf17qTabmVjDsQlg'
- @gateway.expects(:ssl_request).with(:post, "https://test-api.pin.net.au/1/charges/#{token}/refunds", {:amount => '100'}.to_json, instance_of(Hash)).returns(failed_refund_response)
+ @gateway.expects(:ssl_request).with(:post, "https://test-api.pinpayments.com/1/charges/#{token}/refunds", {:amount => '100'}.to_json, instance_of(Hash)).returns(failed_refund_response)
assert response = @gateway.refund(100, token)
assert_failure response
@@ -153,7 +153,7 @@ def test_successful_authorize
headers = {}
@gateway.stubs(:headers).returns(headers)
@gateway.stubs(:post_data).returns(post_data)
- @gateway.expects(:ssl_request).with(:post, 'https://test-api.pin.net.au/1/charges', post_data, headers).returns(successful_purchase_response)
+ @gateway.expects(:ssl_request).with(:post, 'https://test-api.pinpayments.com/1/charges', post_data, headers).returns(successful_purchase_response)
assert response = @gateway.authorize(@amount, @credit_card, @options)
assert_success response
@@ -168,7 +168,7 @@ def test_successful_capture
token = 'ch_encBuMDf17qTabmVjDsQlg'
@gateway.stubs(:headers).returns(headers)
@gateway.stubs(:post_data).returns(post_data)
- @gateway.expects(:ssl_request).with(:put, "https://test-api.pin.net.au/1/charges/#{token}/capture", post_data, headers).returns(successful_capture_response)
+ @gateway.expects(:ssl_request).with(:put, "https://test-api.pinpayments.com/1/charges/#{token}/capture", post_data, headers).returns(successful_capture_response)
assert response = @gateway.capture(100, token)
assert_success response
@@ -225,7 +225,7 @@ def test_add_customer_data
@gateway.send(:add_customer_data, post, @options)
- assert_equal 'roland@pin.net.au', post[:email]
+ assert_equal 'roland@pinpayments.com', post[:email]
assert_equal '127.0.0.1', post[:ip_address]
end
@@ -327,7 +327,7 @@ def successful_purchase_response
"amount":400,
"currency":"AUD",
"description":"test charge",
- "email":"roland@pin.net.au",
+ "email":"roland@pinpayments.com",
"ip_address":"203.192.1.172",
"created_at":"2013-01-14T03:00:41Z",
"status_message":"Success!",
@@ -407,7 +407,7 @@ def successful_customer_store_response
'{
"response":{
"token":"cus_05p0n7UFPmcyCNjD8c6HdA",
- "email":"roland@pin.net.au",
+ "email":"roland@pinpayments.com",
"created_at":"2013-01-16T03:16:11Z",
"card":{
"token":"card__o8I8GmoXDF0d35LEDZbNQ",
@@ -473,7 +473,7 @@ def successful_capture_response
"amount":400,
"currency":"AUD",
"description":"test charge",
- "email":"roland@pin.net.au",
+ "email":"roland@pinpayments.com",
"ip_address":"203.192.1.172",
"created_at":"2013-01-14T03:00:41Z",
"status_message":"Success!",
@@ -504,7 +504,7 @@ def transcript
'{
"amount":"100",
"currency":"AUD",
- "email":"roland@pin.net.au",
+ "email":"roland@pinpayments.com",
"ip_address":"203.59.39.62",
"description":"Store Purchase 1437598192",
"card":{
@@ -526,7 +526,7 @@ def scrubbed_transcript
'{
"amount":"100",
"currency":"AUD",
- "email":"roland@pin.net.au",
+ "email":"roland@pinpayments.com",
"ip_address":"203.59.39.62",
"description":"Store Purchase 1437598192",
"card":{
From 997c0a80eda6c1833a8c960a07e2b20eb9f72d88 Mon Sep 17 00:00:00 2001
From: Ruthan
Date: Fri, 15 Feb 2019 15:36:40 -0500
Subject: [PATCH 0279/2234] Concatenate card and customer token
Pinpayments handles stored cards by assigning them to a user. It seems that if
a card is associated with a user the card must be used with the customer ID
rather than the card's, and since a card can only be associated with one user,
it's not clear that the card ID generated when a card is stored will ever
actually be reusable (see the [Customer API docs](https://pinpayments.com/developers/api-reference/customers#put-customer) since cards are
irretrievable once they are replaced.
The possible use case for stored card IDs is that customers may have multiple
cards if one is set as primary. Other stored cards may not be able to be used
until/unless they are set as primary.
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/pin.rb | 17 +++++++++++++++--
test/unit/gateways/pin_test.rb | 10 +++++-----
3 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 8f87c66d453..fee2e7d24db 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -34,6 +34,7 @@
* Add Bambora gateway [InfraRuby] #3145
* Bambora Asia-Pacific: Updates Gateway [molbrown] #3145
* PaymentExpress: Support ClientInfo field [jknipp] #3131
+* Pin Payments: Concatenate card and customer tokens when storing card [therufs] #3144
== Version 1.90.0 (January 8, 2019)
* Mercado Pago: Support "gateway" processing mode [curiousepic] #3087
diff --git a/lib/active_merchant/billing/gateways/pin.rb b/lib/active_merchant/billing/gateways/pin.rb
index 87fb7f7d7e2..89e92895980 100644
--- a/lib/active_merchant/billing/gateways/pin.rb
+++ b/lib/active_merchant/billing/gateways/pin.rb
@@ -67,6 +67,7 @@ def capture(money, token, options = {})
# Updates the credit card for the customer.
def update(token, creditcard, options = {})
post = {}
+ token = get_customer_token(token)
add_creditcard(post, creditcard)
add_customer_data(post, options)
@@ -137,13 +138,21 @@ def add_creditcard(post, creditcard)
)
elsif creditcard.kind_of?(String)
if creditcard =~ /^card_/
- post[:card_token] = creditcard
+ post[:card_token] = get_card_token(creditcard)
else
post[:customer_token] = creditcard
end
end
end
+ def get_customer_token(token)
+ token.split(/;(?=cus)/).last
+ end
+
+ def get_card_token(token)
+ token.split(/;(?=cus)/).first
+ end
+
def add_metadata(post, options)
post[:metadata] = options[:metadata] if options[:metadata]
end
@@ -206,7 +215,11 @@ def unparsable_response(raw_response)
end
def token(response)
- response['token']
+ if response['token'].start_with?('cus')
+ "#{response.dig('card', 'token')};#{response['token']}"
+ else
+ response['token']
+ end
end
def parse(body)
diff --git a/test/unit/gateways/pin_test.rb b/test/unit/gateways/pin_test.rb
index 7bc943aee13..1d448d2203b 100644
--- a/test/unit/gateways/pin_test.rb
+++ b/test/unit/gateways/pin_test.rb
@@ -101,16 +101,16 @@ def test_unparsable_body_of_failed_response
end
def test_successful_store
- @gateway.expects(:ssl_request).returns(successful_store_response)
+ @gateway.expects(:ssl_request).returns(successful_customer_store_response)
assert response = @gateway.store(@credit_card, @options)
assert_success response
- assert_equal 'card_sVOs8D9nANoNgDc38NvKow', response.authorization
- assert_equal JSON.parse(successful_store_response), response.params
+ assert_equal 'card__o8I8GmoXDF0d35LEDZbNQ;cus_05p0n7UFPmcyCNjD8c6HdA', response.authorization
+ assert_equal JSON.parse(successful_customer_store_response), response.params
assert response.test?
end
def test_unsuccessful_store
- @gateway.expects(:ssl_request).returns(failed_store_response)
+ @gateway.expects(:ssl_request).returns(failed_customer_store_response)
assert response = @gateway.store(@credit_card, @options)
assert_failure response
@@ -123,7 +123,7 @@ def test_successful_update
@gateway.expects(:ssl_request).with(:put, "https://test-api.pinpayments.com/1/customers/#{token}", instance_of(String), instance_of(Hash)).returns(successful_customer_store_response)
assert response = @gateway.update('cus_05p0n7UFPmcyCNjD8c6HdA', @credit_card, @options)
assert_success response
- assert_equal 'cus_05p0n7UFPmcyCNjD8c6HdA', response.authorization
+ assert_equal 'card__o8I8GmoXDF0d35LEDZbNQ;cus_05p0n7UFPmcyCNjD8c6HdA', response.authorization
assert_equal JSON.parse(successful_customer_store_response), response.params
assert response.test?
end
From 31db9e6926656301bc0dcc7afdc5d6c9aa5bc579 Mon Sep 17 00:00:00 2001
From: Lance Carlson
Date: Mon, 14 Jan 2019 23:13:20 -0500
Subject: [PATCH 0280/2234] USA ePay: Handle symbol keys in custom fields
Unit:
38 tests, 30 assertions, 20 failures, 17 errors, 0 pendings, 0 omissions, 0 notifications
2.63158% passed
Remote:
Advanced
40 tests, 56 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Transaction
29 tests, 110 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
closes #3111
---
lib/active_merchant/billing/gateways/usa_epay_transaction.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb
index be8bda95912..5b1931fb3a5 100644
--- a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb
+++ b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb
@@ -265,7 +265,7 @@ def add_custom_fields(post, options)
return unless options[:custom_fields].is_a?(Hash)
options[:custom_fields].each do |index, custom|
- raise ArgumentError.new('Cannot specify custom field with index 0') if index.to_i.zero?
+ raise ArgumentError.new('Cannot specify custom field with index 0') if index.to_s.to_i.zero?
post["custom#{index}"] = custom
end
From c05d4cae80d09c159bcb5e2ab041accc31845047 Mon Sep 17 00:00:00 2001
From: Martin Madsen
Date: Mon, 17 Dec 2018 13:26:08 +1000
Subject: [PATCH 0281/2234] Update dead link to feature matrix
Update link to be http
closes #3084
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 3f3dc7e3125..c026e93ae86 100644
--- a/README.md
+++ b/README.md
@@ -86,7 +86,7 @@ For more in-depth documentation and tutorials, see [GettingStarted.md](GettingSt
## Supported Payment Gateways
-The [ActiveMerchant Wiki](http://github.com/activemerchant/active_merchant/wikis) contains a [table of features supported by each gateway](http://github.com/activemerchant/active_merchant/wikis/gatewayfeaturematrix).
+The [ActiveMerchant Wiki](https://github.com/activemerchant/active_merchant/wikis) contains a [table of features supported by each gateway](https://github.com/activemerchant/active_merchant/wiki/Gateway-Feature-Matrix).
* [Authorize.Net CIM](http://www.authorize.net/) - US
* [Authorize.Net](http://www.authorize.net/) - AD, AT, AU, BE, BG, CA, CH, CY, CZ, DE, DK, ES, FI, FR, GB, GB, GI, GR, HU, IE, IT, LI, LU, MC, MT, NL, NO, PL, PT, RO, SE, SI, SK, SM, TR, US, VA
From dc9fb68868f82085f42fbe84ee491be465643358 Mon Sep 17 00:00:00 2001
From: Prashanth Chandra
Date: Tue, 19 Feb 2019 16:38:41 +0800
Subject: [PATCH 0282/2234] Allow Discover card numbers longer than 16 digits
Detect Discover cards that are longer than 16 digits in length
---
lib/active_merchant/billing/credit_card_methods.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/active_merchant/billing/credit_card_methods.rb b/lib/active_merchant/billing/credit_card_methods.rb
index 05f07e46667..ac87c50c4f4 100644
--- a/lib/active_merchant/billing/credit_card_methods.rb
+++ b/lib/active_merchant/billing/credit_card_methods.rb
@@ -5,7 +5,7 @@ module CreditCardMethods
CARD_COMPANY_DETECTORS = {
'visa' => ->(num) { num =~ /^4\d{12}(\d{3})?(\d{3})?$/ },
'master' => ->(num) { num&.size == 16 && in_bin_range?(num.slice(0, 6), MASTERCARD_RANGES) },
- 'discover' => ->(num) { num =~ /^(6011|65\d{2}|64[4-9]\d)\d{12}|(62\d{14})$/ },
+ 'discover' => ->(num) { num =~ /^(6011|65\d{2}|64[4-9]\d)\d{12,15}|(62\d{14,17})$/ },
'american_express' => ->(num) { num =~ /^3[47]\d{13}$/ },
'diners_club' => ->(num) { num =~ /^3(0[0-5]|[68]\d)\d{11}$/ },
'jcb' => ->(num) { num =~ /^35(28|29|[3-8]\d)\d{12}$/ },
From 16422f8b397adb740a911c95dc0bb882afc9a54a Mon Sep 17 00:00:00 2001
From: Jared Knipp
Date: Fri, 22 Feb 2019 09:55:03 -0600
Subject: [PATCH 0283/2234] Update Changelog
---
CHANGELOG | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG b/CHANGELOG
index fee2e7d24db..143a9a05248 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -35,6 +35,7 @@
* Bambora Asia-Pacific: Updates Gateway [molbrown] #3145
* PaymentExpress: Support ClientInfo field [jknipp] #3131
* Pin Payments: Concatenate card and customer tokens when storing card [therufs] #3144
+* Update Discover regex to allow card numbers longer than 16 digits [prashcr] #3146
== Version 1.90.0 (January 8, 2019)
* Mercado Pago: Support "gateway" processing mode [curiousepic] #3087
From 7766ca8f407d0a3a494f5d5f5224231f9a93b69d Mon Sep 17 00:00:00 2001
From: Pierre Nespo
Date: Fri, 22 Feb 2019 11:37:17 -0500
Subject: [PATCH 0284/2234] Bump to 1.91.0
---
CHANGELOG | 5 ++++-
lib/active_merchant/version.rb | 2 +-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 143a9a05248..09d496a389a 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,8 @@
= ActiveMerchant CHANGELOG
== HEAD
+
+== Version 1.91.0 (February 22, 2019)
* WorldPay: Pull CVC and AVS Result from Response [nfarve] #3106
* Worldpay: Add AVS and CVC Mapping [nfarve] #3107
* Paymentez: Fixes extra_params field [molbrown] #3108
@@ -18,7 +20,6 @@
* Blue Snap: Supports Level 2/3 data [molbrown] #3126
* Blue Snap: Support personal_identification_number [jknipp] #3128
* ProPay: Send 9 digit zip code without dash [molbrown] #3129
-* Cecabank: Append error text to message [therufs] #3127
* Adyen: Extend AVS code mappings [therufs] #3119
* NMI: Add customer id to authorization on store [curiousepic] #3130
* Trans First Express: Don't pass blank name field [curiousepic] #3133
@@ -36,6 +37,7 @@
* PaymentExpress: Support ClientInfo field [jknipp] #3131
* Pin Payments: Concatenate card and customer tokens when storing card [therufs] #3144
* Update Discover regex to allow card numbers longer than 16 digits [prashcr] #3146
+* Merrco partial refunds fix [payfirma1] #3141
== Version 1.90.0 (January 8, 2019)
* Mercado Pago: Support "gateway" processing mode [curiousepic] #3087
@@ -47,6 +49,7 @@
* Braintree Blue: Refactor line_items field [curiousepic] #3100
* TrustCommerce: Use `application_id` [nfarve] #3103
* Stripe: Add 3DS Support [nfarve] #3086
+* Cecabank: Append error text to message [therufs] #3127
== Version 1.89.0 (December 17, 2018)
* Worldpay: handle Visa and MasterCard payouts differently [bpollack] #3068
diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb
index 2bf8655247f..e9a183351bf 100644
--- a/lib/active_merchant/version.rb
+++ b/lib/active_merchant/version.rb
@@ -1,3 +1,3 @@
module ActiveMerchant
- VERSION = '1.90.0'
+ VERSION = '1.91.0'
end
From 48171551e30e73e4ec04470f59f359215848a4ef Mon Sep 17 00:00:00 2001
From: Jared Knipp
Date: Fri, 22 Feb 2019 17:02:35 -0600
Subject: [PATCH 0285/2234] BluePay: Send IP address with requests
Add the IP address to all Blue Pay requests when available.
ECS-165
Unit:
26 tests, 125 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
15 tests, 73 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
closes #3149
---
CHANGELOG | 1 +
.../billing/gateways/blue_pay.rb | 18 +++---
test/remote/gateways/remote_blue_pay_test.rb | 5 +-
test/unit/gateways/blue_pay_test.rb | 56 +++++++++++++++----
4 files changed, 58 insertions(+), 22 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 09d496a389a..cd9edf5b3c8 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -38,6 +38,7 @@
* Pin Payments: Concatenate card and customer tokens when storing card [therufs] #3144
* Update Discover regex to allow card numbers longer than 16 digits [prashcr] #3146
* Merrco partial refunds fix [payfirma1] #3141
+* BluePay: Send customer IP address when provided [jknipp] #3149
== Version 1.90.0 (January 8, 2019)
* Mercado Pago: Support "gateway" processing mode [curiousepic] #3087
diff --git a/lib/active_merchant/billing/gateways/blue_pay.rb b/lib/active_merchant/billing/gateways/blue_pay.rb
index b80ffcc2575..e275b649dfe 100644
--- a/lib/active_merchant/billing/gateways/blue_pay.rb
+++ b/lib/active_merchant/billing/gateways/blue_pay.rb
@@ -24,7 +24,7 @@ class BluePayGateway < Gateway
'REBID' => :rebid,
'TRANS_TYPE' => :trans_type,
'PAYMENT_ACCOUNT_MASK' => :acct_mask,
- 'CARD_TYPE' => :card_type,
+ 'CARD_TYPE' => :card_type
}
REBILL_FIELD_MAP = {
@@ -41,6 +41,7 @@ class BluePayGateway < Gateway
'REB_AMOUNT' => :rebill_amount,
'NEXT_AMOUNT' => :next_amount,
'USUAL_DATE' => :undoc_usual_date, # Not found in the bp20rebadmin API doc.
+ 'CUST_TOKEN' => :cust_token
}
self.supported_countries = ['US', 'CA']
@@ -84,7 +85,7 @@ def authorize(money, payment_object, options = {})
add_rebill(post, options) if options[:rebill]
add_duplicate_override(post, options)
post[:TRANS_TYPE] = 'AUTH'
- commit('AUTH_ONLY', money, post)
+ commit('AUTH_ONLY', money, post, options)
end
# Perform a purchase, which is essentially an authorization and capture in a single operation.
@@ -107,7 +108,7 @@ def purchase(money, payment_object, options = {})
add_rebill(post, options) if options[:rebill]
add_duplicate_override(post, options)
post[:TRANS_TYPE] = 'SALE'
- commit('AUTH_CAPTURE', money, post)
+ commit('AUTH_CAPTURE', money, post, options)
end
# Captures the funds from an authorize transaction.
@@ -123,7 +124,7 @@ def capture(money, identification, options = {})
add_customer_data(post, options)
post[:MASTER_ID] = identification
post[:TRANS_TYPE] = 'CAPTURE'
- commit('PRIOR_AUTH_CAPTURE', money, post)
+ commit('PRIOR_AUTH_CAPTURE', money, post, options)
end
# Void a previous transaction
@@ -136,7 +137,7 @@ def void(identification, options = {})
post = {}
post[:MASTER_ID] = identification
post[:TRANS_TYPE] = 'VOID'
- commit('VOID', nil, post)
+ commit('VOID', nil, post, options)
end
# Performs a credit.
@@ -169,7 +170,7 @@ def refund(money, identification, options = {})
add_invoice(post, options)
add_address(post, options)
add_customer_data(post, options)
- commit('CREDIT', money, post)
+ commit('CREDIT', money, post, options)
end
def credit(money, payment_object, options = {})
@@ -189,7 +190,7 @@ def credit(money, payment_object, options = {})
add_invoice(post, options)
add_address(post, options)
add_customer_data(post, options)
- commit('CREDIT', money, post)
+ commit('CREDIT', money, post, options)
end
# Create a new recurring payment.
@@ -313,10 +314,11 @@ def scrub(transcript)
private
- def commit(action, money, fields)
+ def commit(action, money, fields, options = {})
fields[:AMOUNT] = amount(money) unless(fields[:TRANS_TYPE] == 'VOID' || action == 'rebill')
fields[:MODE] = (test? ? 'TEST' : 'LIVE')
fields[:ACCOUNT_ID] = @options[:login]
+ fields[:CUSTOMER_IP] = options[:ip] if options[:ip]
if action == 'rebill'
url = rebilling_url
diff --git a/test/remote/gateways/remote_blue_pay_test.rb b/test/remote/gateways/remote_blue_pay_test.rb
index ee6b779e1b9..4c0fc7b5477 100644
--- a/test/remote/gateways/remote_blue_pay_test.rb
+++ b/test/remote/gateways/remote_blue_pay_test.rb
@@ -10,7 +10,8 @@ def setup
@options = {
:order_id => generate_unique_id,
:billing_address => address,
- :description => 'Store purchase'
+ :description => 'Store purchase',
+ :ip => '192.168.0.1'
}
@recurring_options = {
@@ -36,7 +37,7 @@ def test_successful_purchase_with_check
assert response = @gateway.purchase(@amount, check, @options.merge(:email=>'foo@example.com'))
assert_success response
assert response.test?
- assert_equal 'This transaction has been approved', response.message
+ assert_equal 'App ACH Sale', response.message
assert response.authorization
end
diff --git a/test/unit/gateways/blue_pay_test.rb b/test/unit/gateways/blue_pay_test.rb
index b4b040f5c43..df8f4e62022 100644
--- a/test/unit/gateways/blue_pay_test.rb
+++ b/test/unit/gateways/blue_pay_test.rb
@@ -20,29 +20,43 @@ def setup
@credit_card = credit_card
@rebill_id = '100096219669'
@rebill_status = 'active'
+ @options = {ip: '192.168.0.1'}
end
def test_successful_authorization
- @gateway.expects(:ssl_post).returns(RSP[:approved_auth])
- assert response = @gateway.authorize(@amount, @credit_card)
+ response = stub_comms do
+ @gateway.authorize(@amount, @credit_card, @options)
+ end.check_request do |endpoint, data, headers|
+ assert_match(/CUSTOMER_IP=192.168.0.1/, data)
+ end.respond_with(RSP[:approved_auth])
+
+ assert response
assert_instance_of Response, response
assert_success response
assert_equal '100134203758', response.authorization
end
def test_successful_purchase
- @gateway.expects(:ssl_post).returns(RSP[:approved_purchase])
+ response = stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options)
+ end.check_request do |endpoint, data, headers|
+ assert_match(/CUSTOMER_IP=192.168.0.1/, data)
+ end.respond_with(RSP[:approved_purchase])
- assert response = @gateway.purchase(@amount, @credit_card)
+ assert response
assert_instance_of Response, response
assert_success response
assert_equal '100134203767', response.authorization
end
def test_failed_authorization
- @gateway.expects(:ssl_post).returns(RSP[:declined])
+ response = stub_comms do
+ @gateway.authorize(@amount, @credit_card, @options)
+ end.check_request do |endpoint, data, headers|
+ assert_match(/CUSTOMER_IP=192.168.0.1/, data)
+ end.respond_with(RSP[:declined])
- assert response = @gateway.authorize(@amount, @credit_card)
+ assert response
assert_instance_of Response, response
assert_failure response
assert_equal '100000000150', response.authorization
@@ -105,26 +119,38 @@ def test_purchase_meets_minimum_requirements
end
def test_successful_refund
- @gateway.expects(:ssl_post).returns(successful_refund_response)
- assert response = @gateway.refund(@amount, '100134230412', :card_number => @credit_card.number)
+ response = stub_comms do
+ @gateway.refund(@amount, '100134230412', @options.merge({:card_number => @credit_card.number}))
+ end.check_request do |endpoint, data, headers|
+ assert_match(/CUSTOMER_IP=192\.168\.0\.1/, data)
+ end.respond_with(successful_refund_response)
+
+ assert response
assert_success response
assert_equal 'This transaction has been approved', response.message
end
def test_refund_passing_extra_info
response = stub_comms do
- @gateway.refund(50, '123456789', :card_number => @credit_card.number, :first_name => 'Bob', :last_name => 'Smith', :zip => '12345')
+ @gateway.refund(50, '123456789', @options.merge({:card_number => @credit_card.number, :first_name => 'Bob', :last_name => 'Smith', :zip => '12345'}))
end.check_request do |endpoint, data, headers|
assert_match(/NAME1=Bob/, data)
assert_match(/NAME2=Smith/, data)
assert_match(/ZIP=12345/, data)
+ assert_match(/CUSTOMER_IP=192\.168\.0\.1/, data)
end.respond_with(successful_purchase_response)
+
assert_success response
end
def test_failed_refund
- @gateway.expects(:ssl_post).returns(failed_refund_response)
- assert response = @gateway.refund(@amount, '123456789', :card_number => @credit_card.number)
+ response = stub_comms do
+ @gateway.refund(@amount, '123456789', @options.merge({:card_number => @credit_card.number}))
+ end.check_request do |endpoint, data, headers|
+ assert_match(/CUSTOMER_IP=192\.168\.0\.1/, data)
+ end.respond_with(failed_refund_response)
+
+ assert response
assert_failure response
assert_equal 'The referenced transaction does not meet the criteria for issuing a credit', response.message
end
@@ -132,7 +158,13 @@ def test_failed_refund
def test_deprecated_credit
@gateway.expects(:ssl_post).returns(successful_purchase_response)
assert_deprecation_warning('credit should only be used to credit a payment method') do
- assert response = @gateway.credit(@amount, '123456789', :card_number => @credit_card.number)
+ response = stub_comms do
+ @gateway.credit(@amount, '123456789', @options.merge({:card_number => @credit_card.number}))
+ end.check_request do |endpoint, data, headers|
+ assert_match(/CUSTOMER_IP=192\.168\.0\.1/, data)
+ end.respond_with(failed_refund_response)
+
+ assert response
assert_success response
assert_equal 'This transaction has been approved', response.message
end
From a43079ee7fa8e2fe7aa72ff777cffaa507b002f4 Mon Sep 17 00:00:00 2001
From: Jared Knipp
Date: Mon, 25 Feb 2019 10:19:56 -0600
Subject: [PATCH 0286/2234] PaymentExpress: Use ip field for client_info
Use the built in ip field instead of a gateway specific field for
sending the ip address with requests.
ECS-124
Unit:
34 tests, 249 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
15 tests, 70 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
closes #3150
---
CHANGELOG | 3 ++-
.../billing/gateways/payment_express.rb | 12 ++++++++----
test/remote/gateways/remote_payment_express_test.rb | 4 ++--
test/unit/gateways/payment_express_test.rb | 4 ++--
4 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index cd9edf5b3c8..d64a33c271f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,8 @@
= ActiveMerchant CHANGELOG
== HEAD
+* BluePay: Send customer IP address when provided [jknipp] #3149
+* PaymentExpress: Use ip field for client_info field [jknipp] #3150
== Version 1.91.0 (February 22, 2019)
* WorldPay: Pull CVC and AVS Result from Response [nfarve] #3106
@@ -38,7 +40,6 @@
* Pin Payments: Concatenate card and customer tokens when storing card [therufs] #3144
* Update Discover regex to allow card numbers longer than 16 digits [prashcr] #3146
* Merrco partial refunds fix [payfirma1] #3141
-* BluePay: Send customer IP address when provided [jknipp] #3149
== Version 1.90.0 (January 8, 2019)
* Mercado Pago: Support "gateway" processing mode [curiousepic] #3087
diff --git a/lib/active_merchant/billing/gateways/payment_express.rb b/lib/active_merchant/billing/gateways/payment_express.rb
index a739c0fd146..ff89eb8cb08 100644
--- a/lib/active_merchant/billing/gateways/payment_express.rb
+++ b/lib/active_merchant/billing/gateways/payment_express.rb
@@ -153,6 +153,7 @@ def build_purchase_or_authorization_request(money, payment_source, options)
add_invoice(result, options)
add_address_verification_data(result, options)
add_optional_elements(result, options)
+ add_ip(result, options)
result
end
@@ -163,6 +164,7 @@ def build_capture_or_credit_request(money, identification, options)
add_invoice(result, options)
add_reference(result, identification)
add_optional_elements(result, options)
+ add_ip(result, options)
result
end
@@ -172,6 +174,7 @@ def build_token_request(credit_card, options)
add_amount(result, 100, options) # need to make an auth request for $1
add_token_request(result, options)
add_optional_elements(result, options)
+ add_ip(result, options)
result
end
@@ -233,6 +236,10 @@ def add_address_verification_data(xml, options)
xml.add_element('AvsPostCode').text = address[:zip]
end
+ def add_ip(xml, options)
+ xml.add_element('ClientInfo').text = options[:ip] if options[:ip]
+ end
+
# The options hash may contain optional data which will be passed
# through the specialized optional fields at PaymentExpress
# as follows:
@@ -241,8 +248,7 @@ def add_address_verification_data(xml, options)
# :client_type => :web, # Possible values are: :web, :ivr, :moto, :unattended, :internet, or :recurring
# :txn_data1 => "String up to 255 characters",
# :txn_data2 => "String up to 255 characters",
- # :txn_data3 => "String up to 255 characters",
- # :client_info => "String up to 15 characters. The IP address of the user who processed the transaction."
+ # :txn_data3 => "String up to 255 characters"
# }
#
# +:client_type+, while not documented for PxPost, will be sent as
@@ -278,8 +284,6 @@ def add_optional_elements(xml, options)
xml.add_element('TxnData1').text = options[:txn_data1].to_s.slice(0, 255) unless options[:txn_data1].blank?
xml.add_element('TxnData2').text = options[:txn_data2].to_s.slice(0, 255) unless options[:txn_data2].blank?
xml.add_element('TxnData3').text = options[:txn_data3].to_s.slice(0, 255) unless options[:txn_data3].blank?
-
- xml.add_element('ClientInfo').text = options[:client_info] if options[:client_info]
end
def new_transaction
diff --git a/test/remote/gateways/remote_payment_express_test.rb b/test/remote/gateways/remote_payment_express_test.rb
index 86381fbcdd7..a2d2a3b0135 100644
--- a/test/remote/gateways/remote_payment_express_test.rb
+++ b/test/remote/gateways/remote_payment_express_test.rb
@@ -31,8 +31,8 @@ def test_successful_purchase_with_reference_id
assert_not_nil response.authorization
end
- def test_successful_purchase_with_client_info
- assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:client_info => '192.168.0.1'))
+ def test_successful_purchase_with_ip
+ assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:ip => '192.168.0.1'))
assert_success response
assert_equal 'The Transaction was approved', response.message
assert_not_nil response.authorization
diff --git a/test/unit/gateways/payment_express_test.rb b/test/unit/gateways/payment_express_test.rb
index 6f9a9374eee..cf15aa1ad92 100644
--- a/test/unit/gateways/payment_express_test.rb
+++ b/test/unit/gateways/payment_express_test.rb
@@ -242,8 +242,8 @@ def test_pass_client_type_as_symbol_for_unknown_type_omits_element
end
end
- def test_pass_client_info
- options = {:client_info => '192.168.0.1'}
+ def test_pass_ip_as_client_info
+ options = {:ip => '192.168.0.1'}
perform_each_transaction_type_with_request_body_assertions(options) do |body|
assert_match(/192.168.0.1<\/ClientInfo>/, body)
From bbee8bcb6bd5ef9e4439dac9e898a9b23fd49d6d Mon Sep 17 00:00:00 2001
From: molbrown
Date: Tue, 19 Feb 2019 14:22:10 -0500
Subject: [PATCH 0287/2234] Bambora Asia-Pacific: Adds Store
ECS-159
Unit:
7 tests, 47 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
15 tests, 30 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Closes #3147
---
CHANGELOG | 1 +
.../billing/gateways/bambora_apac.rb | 68 +++++++++++++++----
test/fixtures.yml | 2 +-
.../gateways/remote_bambora_apac_test.rb | 36 +++++++++-
4 files changed, 89 insertions(+), 18 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index d64a33c271f..ad7abfc404f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -3,6 +3,7 @@
== HEAD
* BluePay: Send customer IP address when provided [jknipp] #3149
* PaymentExpress: Use ip field for client_info field [jknipp] #3150
+* Bambora Asia-Pacific: Adds Store [molbrown] #3147
== Version 1.91.0 (February 22, 2019)
* WorldPay: Pull CVC and AVS Result from Response [nfarve] #3106
diff --git a/lib/active_merchant/billing/gateways/bambora_apac.rb b/lib/active_merchant/billing/gateways/bambora_apac.rb
index bcf4b9d8b62..6cfe3a82bdc 100644
--- a/lib/active_merchant/billing/gateways/bambora_apac.rb
+++ b/lib/active_merchant/billing/gateways/bambora_apac.rb
@@ -3,8 +3,8 @@
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
class BamboraApacGateway < Gateway
- self.live_url = 'https://www.bambora.co.nz/interface/api/dts.asmx'
- self.test_url = 'https://demo.bambora.co.nz/interface/api/dts.asmx'
+ self.live_url = 'https://www.bambora.co.nz/interface/api'
+ self.test_url = 'https://demo.bambora.co.nz/interface/api'
self.supported_countries = ['AU', 'NZ']
self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :jcb]
@@ -32,7 +32,7 @@ def purchase(money, payment, options={})
xml.CustRef options[:order_id]
add_amount(xml, money)
xml.TrnType '1'
- add_credit_card(xml, payment)
+ add_payment(xml, payment)
add_credentials(xml, options)
xml.TrnSource options[:ip]
end
@@ -45,7 +45,7 @@ def authorize(money, payment, options={})
xml.CustRef options[:order_id]
add_amount(xml, money)
xml.TrnType '2'
- add_credit_card(xml, payment)
+ add_payment(xml, payment)
add_credentials(xml, options)
xml.TrnSource options[:ip]
end
@@ -82,6 +82,19 @@ def void(money, authorization, options={})
end
end
+ def store(payment, options={})
+ commit('TokeniseCreditCard') do |xml|
+ xml.TokeniseCreditCard do
+ xml.CardNumber payment.number
+ xml.ExpM format(payment.month, :two_digits)
+ xml.ExpY format(payment.year, :four_digits)
+ xml.TokeniseAlgorithmID options[:tokenise_algorithm_id] || 2
+ xml.UserName @options[:username]
+ xml.Password @options[:password]
+ end
+ end
+ end
+
def supports_scrubbing?
true
end
@@ -107,6 +120,21 @@ def add_amount(xml, money)
xml.Amount amount(money)
end
+ def add_payment(xml, payment)
+ if payment.is_a?(String)
+ add_token(xml, payment)
+ else
+ add_credit_card(xml, payment)
+ end
+ end
+
+ def add_token(xml, payment)
+ xml.CreditCard do
+ xml.TokeniseAlgorithmID options[:tokenise_algorithm_id] || 2
+ xml.CardNumber payment
+ end
+ end
+
def add_credit_card(xml, payment)
xml.CreditCard :Registered => 'False' do
xml.CardNumber payment.number
@@ -131,9 +159,9 @@ def parse(body)
def commit(action, &block)
headers = {
'Content-Type' => 'text/xml; charset=utf-8',
- 'SOAPAction' => "http://www.ippayments.com.au/interface/api/dts/#{action}",
+ 'SOAPAction' => "http://www.ippayments.com.au/interface/api/#{endpoint(action)}/#{action}"
}
- response = parse(ssl_post(commit_url, new_submit_xml(action, &block), headers))
+ response = parse(ssl_post("#{commit_url}/#{endpoint(action)}.asmx", new_submit_xml(action, &block), headers))
Response.new(
success_from(response),
@@ -150,11 +178,19 @@ def new_submit_xml(action)
xml.instruct!
xml.soap :Envelope, 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema', 'xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/' do
xml.soap :Body do
- xml.__send__(action, 'xmlns' => 'http://www.ippayments.com.au/interface/api/dts') do
- xml.trnXML do
- inner_xml = Builder::XmlMarkup.new(indent: 2)
- yield(inner_xml)
- xml.cdata!(inner_xml.target!)
+ xml.__send__(action, 'xmlns' => "http://www.ippayments.com.au/interface/api/#{endpoint(action)}") do
+ if action == 'TokeniseCreditCard'
+ xml.tokeniseCreditCardXML do
+ inner_xml = Builder::XmlMarkup.new(indent: 2)
+ yield(inner_xml)
+ xml.cdata!(inner_xml.target!)
+ end
+ else
+ xml.trnXML do
+ inner_xml = Builder::XmlMarkup.new(indent: 2)
+ yield(inner_xml)
+ xml.cdata!(inner_xml.target!)
+ end
end
end
end
@@ -162,12 +198,16 @@ def new_submit_xml(action)
xml.target!
end
+ def endpoint(action)
+ action == 'TokeniseCreditCard' ? 'sipp' : 'dts'
+ end
+
def commit_url
test? ? test_url : live_url
end
def success_from(response)
- response[:response_code] == '0'
+ response[:response_code] == '0' || response[:return_value] == '0'
end
def error_code_from(response)
@@ -175,11 +215,11 @@ def error_code_from(response)
end
def message_from(response)
- response[:declined_message]
+ success_from(response) ? 'Succeeded' : response[:declined_message]
end
def authorization_from(response)
- response[:receipt]
+ response[:receipt] || response[:token]
end
end
end
diff --git a/test/fixtures.yml b/test/fixtures.yml
index b1cdab09cc3..e58150b1857 100644
--- a/test/fixtures.yml
+++ b/test/fixtures.yml
@@ -36,7 +36,7 @@ axcessms:
balanced:
login: 'e1c5ad38d1c711e1b36c026ba7e239a9'
-bambora:
+bambora_apac:
username: nmi.api
password: qwerty123
diff --git a/test/remote/gateways/remote_bambora_apac_test.rb b/test/remote/gateways/remote_bambora_apac_test.rb
index a8d75d74690..896f0d17865 100644
--- a/test/remote/gateways/remote_bambora_apac_test.rb
+++ b/test/remote/gateways/remote_bambora_apac_test.rb
@@ -2,7 +2,7 @@
class RemoteBamboraApacTest < Test::Unit::TestCase
def setup
- @gateway = BamboraApacGateway.new(fixtures(:bambora))
+ @gateway = BamboraApacGateway.new(fixtures(:bambora_apac))
@credit_card = credit_card('4005550000000001')
@@ -27,7 +27,7 @@ def test_transcript_scrubbing
def test_successful_purchase
response = @gateway.purchase(200, @credit_card, @options)
assert_success response
- assert_equal '', response.message
+ assert_equal 'Succeeded', response.message
end
def test_failed_purchase
@@ -56,7 +56,7 @@ def test_successful_refund
response = @gateway.purchase(200, @credit_card, @options)
response = @gateway.refund(200, response.authorization, @options)
assert_success response
- assert_equal '', response.message
+ assert_equal 'Succeeded', response.message
end
def test_failed_refund
@@ -81,6 +81,36 @@ def test_failed_void
assert_equal 'Cannot find matching transaction to VOID', response.message
end
+ def test_successful_store
+ response = @gateway.store(@credit_card, @options)
+ assert_success response
+ end
+
+ def test_failed_store
+ bad_credit_card = credit_card(nil)
+
+ response = @gateway.store(bad_credit_card, @options)
+ assert_failure response
+ end
+
+ def test_successful_purchase_using_stored_card
+ assert store_response = @gateway.store(@credit_card, @options)
+ assert_success store_response
+
+ response = @gateway.purchase(500, store_response.authorization, @options)
+ assert_success response
+ assert_equal 'Succeeded', response.message
+ end
+
+ def test_successful_authorize_using_stored_card
+ assert store_response = @gateway.store(@credit_card, @options)
+ assert_success store_response
+
+ response = @gateway.authorize(500, store_response.authorization, @options)
+ assert_success response
+ assert_equal 'Succeeded', response.message
+ end
+
def test_invalid_login
gateway = BamboraApacGateway.new(
username: '',
From 29e080592bd0053d3cb03b25d97ac8c1e303c339 Mon Sep 17 00:00:00 2001
From: David Perry
Date: Thu, 21 Feb 2019 16:36:58 -0500
Subject: [PATCH 0288/2234] Orbital: Pass normalized stored credential fields
This retains the prior Orbital-specific stored credential data fields,
and allows those to override the normalized hash in a piecewise manner,
since the hash does not support all message types allowable by Orbital.
Closes #3148
Remote: 28 tests, 154 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit: 74 tests, 441 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/orbital.rb | 30 +++++++++--
test/remote/gateways/remote_orbital_test.rb | 48 +++++++++++++++++
test/unit/gateways/orbital_test.rb | 54 ++++++++++++++++++-
4 files changed, 129 insertions(+), 4 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index ad7abfc404f..40bb71a7b14 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -4,6 +4,7 @@
* BluePay: Send customer IP address when provided [jknipp] #3149
* PaymentExpress: Use ip field for client_info field [jknipp] #3150
* Bambora Asia-Pacific: Adds Store [molbrown] #3147
+* Orbital: Pass normalized stored credential fields [curiousepic] #3148
== Version 1.91.0 (February 22, 2019)
* WorldPay: Pull CVC and AVS Result from Response [nfarve] #3106
diff --git a/lib/active_merchant/billing/gateways/orbital.rb b/lib/active_merchant/billing/gateways/orbital.rb
index 81e1fd0563a..93246833526 100644
--- a/lib/active_merchant/billing/gateways/orbital.rb
+++ b/lib/active_merchant/billing/gateways/orbital.rb
@@ -507,9 +507,33 @@ def add_managed_billing(xml, options)
end
def add_stored_credentials(xml, parameters)
- xml.tag! :MITMsgType, parameters[:mit_msg_type] if parameters[:mit_msg_type]
- xml.tag! :MITStoredCredentialInd, parameters[:mit_stored_credential_ind] if parameters[:mit_stored_credential_ind]
- xml.tag! :MITSubmittedTransactionID, parameters[:mit_submitted_transaction_id] if parameters[:mit_submitted_transaction_id]
+ return unless parameters[:mit_stored_credential_ind] == 'Y' || parameters[:stored_credential] && !parameters[:stored_credential].values.all?(&:nil?)
+ if msg_type = get_msg_type(parameters)
+ xml.tag! :MITMsgType, msg_type
+ end
+ xml.tag! :MITStoredCredentialInd, 'Y'
+ if parameters[:mit_submitted_transaction_id]
+ xml.tag! :MITSubmittedTransactionID, parameters[:mit_submitted_transaction_id]
+ elsif parameters.dig(:stored_credential, :network_transaction_id) && parameters.dig(:stored_credential, :initiator) == 'merchant'
+ xml.tag! :MITSubmittedTransactionID, parameters[:stored_credential][:network_transaction_id]
+ end
+ end
+
+ def get_msg_type(parameters)
+ return parameters[:mit_msg_type] if parameters[:mit_msg_type]
+ return 'CSTO' if parameters[:stored_credential][:initial_transaction]
+ return unless parameters[:stored_credential][:initiator] && parameters[:stored_credential][:reason_type]
+ initiator = case parameters[:stored_credential][:initiator]
+ when 'customer' then 'C'
+ when 'merchant' then 'M'
+ end
+ reason = case parameters[:stored_credential][:reason_type]
+ when 'recurring' then 'REC'
+ when 'installment' then 'INS'
+ when 'unscheduled' then 'USE'
+ end
+
+ "#{initiator}#{reason}"
end
def parse(body)
diff --git a/test/remote/gateways/remote_orbital_test.rb b/test/remote/gateways/remote_orbital_test.rb
index 4f94ca697b6..f85e53c28d3 100644
--- a/test/remote/gateways/remote_orbital_test.rb
+++ b/test/remote/gateways/remote_orbital_test.rb
@@ -157,6 +157,54 @@ def test_successful_purchase_with_cit_stored_credentials
assert_equal 'Approved', response.message
end
+ def test_successful_purchase_with_normalized_mit_stored_credentials
+ stored_credential = {
+ stored_credential: {
+ initial_transaction: false,
+ initiator: 'merchant',
+ reason_type: 'unscheduled',
+ network_transaction_id: 'abcdefg12345678'
+ }
+ }
+
+ response = @gateway.purchase(@amount, @credit_card, @options.merge(stored_credential))
+
+ assert_success response
+ assert_equal 'Approved', response.message
+ end
+
+ def test_successful_purchase_with_normalized_cit_stored_credentials
+ stored_credential = {
+ stored_credential: {
+ initial_transaction: true,
+ initiator: 'customer',
+ reason_type: 'unscheduled'
+ }
+ }
+
+ response = @gateway.purchase(@amount, @credit_card, @options.merge(stored_credential))
+
+ assert_success response
+ assert_equal 'Approved', response.message
+ end
+
+ def test_successful_purchase_with_overridden_normalized_stored_credentials
+ stored_credential = {
+ stored_credential: {
+ initial_transaction: false,
+ initiator: 'merchant',
+ reason_type: 'unscheduled',
+ network_transaction_id: 'abcdefg12345678'
+ },
+ mit_msg_type: 'MRSB'
+ }
+
+ response = @gateway.purchase(@amount, @credit_card, @options.merge(stored_credential))
+
+ assert_success response
+ assert_equal 'Approved', response.message
+ end
+
# Amounts of x.01 will fail
def test_unsuccessful_purchase
assert response = @gateway.purchase(101, @declined_card, @options)
diff --git a/test/unit/gateways/orbital_test.rb b/test/unit/gateways/orbital_test.rb
index 996e5334c4e..ff003e438da 100644
--- a/test/unit/gateways/orbital_test.rb
+++ b/test/unit/gateways/orbital_test.rb
@@ -32,10 +32,24 @@ def setup
@options = { :order_id => '1'}
@options_stored_credentials = {
- mit_msg_type: 'MUSE',
+ mit_msg_type: 'MRSB',
mit_stored_credential_ind: 'Y',
mit_submitted_transaction_id: '123456abcdef'
}
+ @normalized_mit_stored_credential = {
+ stored_credential: {
+ initial_transaction: false,
+ initiator: 'merchant',
+ reason_type: 'unscheduled',
+ network_transaction_id: 'abcdefg12345678'
+ }
+ }
+ @normalized_initial_stored_credential = {
+ stored_credential: {
+ initial_transaction: true,
+ initiator: 'customer'
+ }
+ }
end
def test_successful_purchase
@@ -393,6 +407,15 @@ def test_dest_address
assert_success response
end
+ def test_successful_purchase_with_negative_stored_credentials_indicator
+ stub_comms do
+ @gateway.purchase(50, credit_card, @options.merge(mit_stored_credential_ind: 'N'))
+ end.check_request do |endpoint, data, headers|
+ assert_no_match //, data
+ assert_no_match //, data
+ end.respond_with(successful_purchase_response)
+ end
+
def test_successful_purchase_with_stored_credentials
stub_comms do
@gateway.purchase(50, credit_card, @options.merge(@options_stored_credentials))
@@ -403,6 +426,35 @@ def test_successful_purchase_with_stored_credentials
end.respond_with(successful_purchase_response)
end
+ def test_successful_purchase_with_normalized_stored_credentials
+ stub_comms do
+ @gateway.purchase(50, credit_card, @options.merge(@normalized_mit_stored_credential))
+ end.check_request do |endpoint, data, headers|
+ assert_match %{MUSE}, data
+ assert_match %{Y}, data
+ assert_match %{abcdefg12345678}, data
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_successful_initial_purchase_with_normalized_stored_credentials
+ stub_comms do
+ @gateway.purchase(50, credit_card, @options.merge(@normalized_initial_stored_credential))
+ end.check_request do |endpoint, data, headers|
+ assert_match %{CSTO}, data
+ assert_match %{Y}, data
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_successful_purchase_with_overridden_normalized_stored_credentials
+ stub_comms do
+ @gateway.purchase(50, credit_card, @options.merge(@normalized_mit_stored_credential).merge(@options_stored_credentials))
+ end.check_request do |endpoint, data, headers|
+ assert_match %{MRSB}, data
+ assert_match %{Y}, data
+ assert_match %{123456abcdef}, data
+ end.respond_with(successful_purchase_response)
+ end
+
def test_default_managed_billing
response = stub_comms do
assert_deprecation_warning(Gateway::RECURRING_DEPRECATION_MESSAGE) do
From d8b15aa678bd01a953e57d34627f1862177d6cfa Mon Sep 17 00:00:00 2001
From: David Perry
Date: Wed, 27 Feb 2019 14:34:08 -0500
Subject: [PATCH 0289/2234] Fix Rubocop error in Orbital unit test
Unit:
75 tests, 445 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
test/unit/gateways/orbital_test.rb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/unit/gateways/orbital_test.rb b/test/unit/gateways/orbital_test.rb
index ff003e438da..1ef99beb2db 100644
--- a/test/unit/gateways/orbital_test.rb
+++ b/test/unit/gateways/orbital_test.rb
@@ -411,8 +411,8 @@ def test_successful_purchase_with_negative_stored_credentials_indicator
stub_comms do
@gateway.purchase(50, credit_card, @options.merge(mit_stored_credential_ind: 'N'))
end.check_request do |endpoint, data, headers|
- assert_no_match //, data
- assert_no_match //, data
+ assert_no_match(//, data)
+ assert_no_match(//, data)
end.respond_with(successful_purchase_response)
end
From e7052387b810e04533bc4824c1c03fcd13c435dc Mon Sep 17 00:00:00 2001
From: DeeDee Lavinder
Date: Mon, 25 Feb 2019 13:53:09 -0500
Subject: [PATCH 0290/2234] Adds ELO card type
This adds ELO bin ranges and ELO brand logic in general. ELO is in a
partnership with Discover and is part of the Discover Global Network.
Using the ELO BIN ranges before the Discover regex allows those cards
to be identified correctly.
It also adds `elo` as a supported cardtype for the Adyen gateway.
Unit Tests
27 tests, 132 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications 100% passed
Remote Tests
45 tests, 122 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications 100% passed
---
lib/active_merchant/billing/credit_card.rb | 2 +
.../billing/credit_card_methods.rb | 13 ++++
lib/active_merchant/billing/gateways/adyen.rb | 2 +-
test/remote/gateways/remote_adyen_test.rb | 59 +++++++++++++++++++
test/unit/credit_card_methods_test.rb | 6 ++
test/unit/gateways/adyen_test.rb | 37 ++++++++++++
6 files changed, 118 insertions(+), 1 deletion(-)
diff --git a/lib/active_merchant/billing/credit_card.rb b/lib/active_merchant/billing/credit_card.rb
index 81f978e5eab..a14bc726c6a 100644
--- a/lib/active_merchant/billing/credit_card.rb
+++ b/lib/active_merchant/billing/credit_card.rb
@@ -18,6 +18,7 @@ module Billing #:nodoc:
# * Dankort
# * Maestro
# * Forbrugsforeningen
+ # * Elo
#
# For testing purposes, use the 'bogus' credit card brand. This skips the vast majority of
# validations, allowing you to focus on your core concerns until you're ready to be more concerned
@@ -88,6 +89,7 @@ def number=(value)
# * +'dankort'+
# * +'maestro'+
# * +'forbrugsforeningen'+
+ # * +'elo'+
#
# Or, if you wish to test your implementation, +'bogus'+.
#
diff --git a/lib/active_merchant/billing/credit_card_methods.rb b/lib/active_merchant/billing/credit_card_methods.rb
index ac87c50c4f4..47ad881355f 100644
--- a/lib/active_merchant/billing/credit_card_methods.rb
+++ b/lib/active_merchant/billing/credit_card_methods.rb
@@ -5,6 +5,7 @@ module CreditCardMethods
CARD_COMPANY_DETECTORS = {
'visa' => ->(num) { num =~ /^4\d{12}(\d{3})?(\d{3})?$/ },
'master' => ->(num) { num&.size == 16 && in_bin_range?(num.slice(0, 6), MASTERCARD_RANGES) },
+ 'elo' => ->(num) { num&.size == 16 && in_bin_range?(num.slice(0, 6), ELO_RANGES) },
'discover' => ->(num) { num =~ /^(6011|65\d{2}|64[4-9]\d)\d{12,15}|(62\d{14,17})$/ },
'american_express' => ->(num) { num =~ /^3[47]\d{13}$/ },
'diners_club' => ->(num) { num =~ /^3(0[0-5]|[68]\d)\d{11}$/ },
@@ -66,6 +67,18 @@ module CreditCardMethods
(670000..679999),
]
+ # https://dev.elo.com.br/apis/tabela-de-bins, download csv from left sidebar
+ ELO_RANGES = [
+ 506707..506708, 506715..506715, 506718..506722, 506724..506724, 506726..506736, 506739..506739, 506741..506743,
+ 506745..506747, 506753..506753, 506774..506776, 506778..506778, 509000..509001, 509003..509003, 509007..509007,
+ 509020..509022, 509035..509035, 509039..509042, 509045..509045, 509048..509048, 509051..509071, 509073..509074,
+ 509077..509080, 509084..509084, 509091..509094, 509098..509098, 509100..509100, 509104..509104, 509106..509109,
+ 627780..627780, 636368..636368, 650031..650033, 650035..650045, 650047..650047, 650406..650410, 650434..650436,
+ 650439..650439, 650485..650504, 650506..650530, 650577..650580, 650582..650591, 650721..650727, 650901..650922,
+ 650928..650928, 650938..650939, 650946..650948, 650954..650955, 650962..650963, 650967..650967, 650971..650971,
+ 651652..651667, 651675..651678, 655000..655010, 655012..655015, 655051..655052, 655056..655057
+ ]
+
def self.included(base)
base.extend(ClassMethods)
end
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index 46e455479fc..73789688028 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -9,7 +9,7 @@ class AdyenGateway < Gateway
self.supported_countries = ['AT', 'AU', 'BE', 'BG', 'BR', 'CH', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GB', 'GI', 'GR', 'HK', 'HU', 'IE', 'IS', 'IT', 'LI', 'LT', 'LU', 'LV', 'MC', 'MT', 'MX', 'NL', 'NO', 'PL', 'PT', 'RO', 'SE', 'SG', 'SK', 'SI', 'US']
self.default_currency = 'USD'
- self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :jcb, :dankort, :maestro, :discover]
+ self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :jcb, :dankort, :maestro, :discover, :elo]
self.money_format = :cents
diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb
index 340bbfde7a9..9c964702ae7 100644
--- a/test/remote/gateways/remote_adyen_test.rb
+++ b/test/remote/gateways/remote_adyen_test.rb
@@ -15,6 +15,15 @@ def setup
:brand => 'visa'
)
+ @elo_credit_card = credit_card('5066 9911 1111 1118',
+ :month => 10,
+ :year => 2020,
+ :first_name => 'John',
+ :last_name => 'Smith',
+ :verification_value => '737',
+ :brand => 'elo'
+ )
+
@three_ds_enrolled_card = credit_card('4212345678901237', brand: :visa)
@declined_card = credit_card('4000300011112220')
@@ -158,6 +167,12 @@ def test_successful_purchase_with_google_pay
assert_equal '[capture-received]', response.message
end
+ def test_successful_purchase_with_elo_card
+ response = @gateway.purchase(@amount, @elo_credit_card, @options.merge(currency: 'BRL'))
+ assert_success response
+ assert_equal '[capture-received]', response.message
+ end
+
def test_failed_purchase
response = @gateway.purchase(@amount, @declined_card, @options)
assert_failure response
@@ -173,6 +188,15 @@ def test_successful_authorize_and_capture
assert_equal '[capture-received]', capture.message
end
+ def test_successful_authorize_and_capture_with_elo_card
+ auth = @gateway.authorize(@amount, @elo_credit_card, @options)
+ assert_success auth
+
+ assert capture = @gateway.capture(@amount, auth.authorization)
+ assert_success capture
+ assert_equal '[capture-received]', capture.message
+ end
+
def test_partial_capture
auth = @gateway.authorize(@amount, @credit_card, @options)
assert_success auth
@@ -196,6 +220,15 @@ def test_successful_refund
assert_equal '[refund-received]', refund.message
end
+ def test_successful_refund_with_elo_card
+ purchase = @gateway.purchase(@amount, @elo_credit_card, @options)
+ assert_success purchase
+
+ assert refund = @gateway.refund(@amount, purchase.authorization)
+ assert_success refund
+ assert_equal '[refund-received]', refund.message
+ end
+
def test_partial_refund
purchase = @gateway.purchase(@amount, @credit_card, @options)
assert_success purchase
@@ -219,6 +252,15 @@ def test_successful_void
assert_equal '[cancel-received]', void.message
end
+ def test_successful_void_with_elo_card
+ auth = @gateway.authorize(@amount, @elo_credit_card, @options)
+ assert_success auth
+
+ assert void = @gateway.void(auth.authorization)
+ assert_success void
+ assert_equal '[cancel-received]', void.message
+ end
+
def test_failed_void
response = @gateway.void('')
assert_failure response
@@ -233,6 +275,14 @@ def test_successful_store
assert_equal 'Authorised', response.message
end
+ def test_successful_store_with_elo_card
+ assert response = @gateway.store(@elo_credit_card, @options)
+
+ assert_success response
+ assert !response.authorization.split('#')[2].nil?
+ assert_equal 'Authorised', response.message
+ end
+
def test_failed_store
assert response = @gateway.store(@declined_card, @options)
@@ -249,6 +299,15 @@ def test_successful_purchase_using_stored_card
assert_equal '[capture-received]', response.message
end
+ def test_successful_purchase_using_stored_elo_card
+ assert store_response = @gateway.store(@elo_credit_card, @options)
+ assert_success store_response
+
+ response = @gateway.purchase(@amount, store_response.authorization, @options)
+ assert_success response
+ assert_equal '[capture-received]', response.message
+ end
+
def test_successful_authorize_using_stored_card
assert store_response = @gateway.store(@credit_card, @options)
assert_success store_response
diff --git a/test/unit/credit_card_methods_test.rb b/test/unit/credit_card_methods_test.rb
index da6211e1a7f..24e643e8eb4 100644
--- a/test/unit/credit_card_methods_test.rb
+++ b/test/unit/credit_card_methods_test.rb
@@ -132,6 +132,12 @@ def test_should_detect_vr_card
assert_equal 'vr', CreditCard.brand?('63703644957644')
end
+ def test_should_detect_elo_card
+ assert_equal 'elo', CreditCard.brand?('5090510000000000')
+ assert_equal 'elo', CreditCard.brand?('5067530000000000')
+ assert_equal 'elo', CreditCard.brand?('6509550000000000')
+ end
+
def test_should_detect_when_an_argument_brand_does_not_match_calculated_brand
assert CreditCard.matching_brand?('4175001000000000', 'visa')
assert_false CreditCard.matching_brand?('4175001000000000', 'master')
diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb
index 3ebb510da71..9c6a759b5f6 100644
--- a/test/unit/gateways/adyen_test.rb
+++ b/test/unit/gateways/adyen_test.rb
@@ -19,6 +19,15 @@ def setup
:brand => 'visa'
)
+ @elo_credit_card = credit_card('5066 9911 1111 1118',
+ :month => 10,
+ :year => 2020,
+ :first_name => 'John',
+ :last_name => 'Smith',
+ :verification_value => '737',
+ :brand => 'elo'
+ )
+
@three_ds_enrolled_card = credit_card('4212345678901237', brand: :visa)
@apple_pay_card = network_tokenization_credit_card('4111111111111111',
@@ -117,6 +126,15 @@ def test_successful_purchase
assert response.test?
end
+ def test_successful_purchase_with_elo_card
+ response = stub_comms do
+ @gateway.purchase(@amount, @elo_credit_card, @options)
+ end.respond_with(successful_authorize_with_elo_response, successful_capture_with_elo_repsonse)
+ assert_success response
+ assert_equal '8835511210681145#8835511210689965#', response.authorization
+ assert response.test?
+ end
+
def test_successful_maestro_purchase
response = stub_comms do
@gateway.purchase(@amount, @credit_card, @options.merge({selected_brand: 'maestro', overwrite_brand: 'true'}))
@@ -448,6 +466,25 @@ def failed_purchase_response
RESPONSE
end
+ def successful_authorize_with_elo_response
+ <<-RESPONSE
+ {
+ "pspReference":"8835511210681145",
+ "resultCode":"Authorised",
+ "authCode":"98696"
+ }
+ RESPONSE
+ end
+
+ def successful_capture_with_elo_repsonse
+ <<-RESPONSE
+ {
+ "pspReference":"8835511210689965",
+ "response":"[capture-received]"
+ }
+ RESPONSE
+ end
+
def successful_authorize_response
<<-RESPONSE
{
From b47d2f738eddadd46aae263cd2dfa300ad01f1d4 Mon Sep 17 00:00:00 2001
From: DeeDee Lavinder
Date: Mon, 4 Mar 2019 08:16:39 -0500
Subject: [PATCH 0291/2234] Adds entry to changelog for Elo Card
Closes #3153
---
CHANGELOG | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG b/CHANGELOG
index 40bb71a7b14..495e016c7c4 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -5,6 +5,7 @@
* PaymentExpress: Use ip field for client_info field [jknipp] #3150
* Bambora Asia-Pacific: Adds Store [molbrown] #3147
* Orbital: Pass normalized stored credential fields [curiousepic] #3148
+* Adds Elo card type in general and specifically to Adyen [deedeelavinder] #3153
== Version 1.91.0 (February 22, 2019)
* WorldPay: Pull CVC and AVS Result from Response [nfarve] #3106
From 81625443efcab62809f4296e2363eb047c28c320 Mon Sep 17 00:00:00 2001
From: molbrown
Date: Fri, 1 Mar 2019 11:19:34 -0500
Subject: [PATCH 0292/2234] Adyen: Idempotency for non-purchase requests
Support of Idempotency-Key for all actions except purchase, due to
multi-key requirement (design still pending).
ECS-166
Unit:
29 tests, 139 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
43 tests, 120 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Closes #3157
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/adyen.rb | 22 +++++++-----
test/remote/gateways/remote_adyen_test.rb | 35 ++++++++++++++++---
test/unit/gateways/adyen_test.rb | 20 +++++++++++
4 files changed, 65 insertions(+), 13 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 495e016c7c4..c04d5b7d6e3 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -6,6 +6,7 @@
* Bambora Asia-Pacific: Adds Store [molbrown] #3147
* Orbital: Pass normalized stored credential fields [curiousepic] #3148
* Adds Elo card type in general and specifically to Adyen [deedeelavinder] #3153
+* Adyen: Idempotency for non-purchase requests [molbrown] #3157
== Version 1.91.0 (February 22, 2019)
* WorldPay: Pull CVC and AVS Result from Response [nfarve] #3106
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index 73789688028..3b660688861 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -37,6 +37,7 @@ def purchase(money, payment, options={})
authorize(money, payment, options)
else
MultiResponse.run do |r|
+ options[:idempotency_key] = nil
r.process { authorize(money, payment, options) }
r.process { capture(money, r.authorization, options) }
end
@@ -53,27 +54,27 @@ def authorize(money, payment, options={})
add_address(post, options)
add_installments(post, options) if options[:installments]
add_3ds(post, options)
- commit('authorise', post)
+ commit('authorise', post, options)
end
def capture(money, authorization, options={})
post = init_post(options)
add_invoice_for_modification(post, money, options)
add_reference(post, authorization, options)
- commit('capture', post)
+ commit('capture', post, options)
end
def refund(money, authorization, options={})
post = init_post(options)
add_invoice_for_modification(post, money, options)
add_original_reference(post, authorization, options)
- commit('refund', post)
+ commit('refund', post, options)
end
def void(authorization, options={})
post = init_post(options)
add_reference(post, authorization, options)
- commit('cancel', post)
+ commit('cancel', post, options)
end
def store(credit_card, options={})
@@ -84,12 +85,13 @@ def store(credit_card, options={})
add_extra_data(post, credit_card, options)
add_recurring_contract(post, options)
add_address(post, options)
- commit('authorise', post)
+ commit('authorise', post, options)
end
def verify(credit_card, options={})
MultiResponse.run(:use_first_response) do |r|
r.process { authorize(0, credit_card, options) }
+ options[:idempotency_key] = nil
r.process(:ignore_result) { void(r.authorization, options) }
end
end
@@ -286,9 +288,9 @@ def parse(body)
JSON.parse(body)
end
- def commit(action, parameters)
+ def commit(action, parameters, options)
begin
- raw_response = ssl_post("#{url}/#{action}", post_data(action, parameters), request_headers)
+ raw_response = ssl_post("#{url}/#{action}", post_data(action, parameters), request_headers(action, options))
response = parse(raw_response)
rescue ResponseError => e
raw_response = e.response.body
@@ -329,11 +331,13 @@ def basic_auth
Base64.strict_encode64("#{@username}:#{@password}")
end
- def request_headers
- {
+ def request_headers(action, options)
+ headers = {
'Content-Type' => 'application/json',
'Authorization' => "Basic #{basic_auth}"
}
+ headers['Idempotency-Key'] = options[:idempotency_key] if options[:idempotency_key]
+ headers
end
def success_from(action, response)
diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb
index 9c964702ae7..6c840699aba 100644
--- a/test/remote/gateways/remote_adyen_test.rb
+++ b/test/remote/gateways/remote_adyen_test.rb
@@ -71,6 +71,18 @@ def test_successful_authorize
assert_equal 'Authorised', response.message
end
+ def test_successful_authorize_with_idempotency_key
+ options = @options.merge(idempotency_key: 'test123')
+ response = @gateway.authorize(@amount, @credit_card, options)
+ assert_success response
+ assert_equal 'Authorised', response.message
+ first_auth = response.authorization
+
+ response = @gateway.authorize(@amount, @credit_card, options)
+ assert_success response
+ assert_equal response.authorization, first_auth
+ end
+
def test_successful_authorize_with_3ds
assert response = @gateway.authorize(@amount, @three_ds_enrolled_card, @options.merge(execute_threed: true))
assert response.test?
@@ -110,7 +122,7 @@ def test_successful_authorize_with_3ds_dynamic_rule_broken
def test_failed_authorize
response = @gateway.authorize(@amount, @declined_card, @options)
assert_failure response
- assert_equal 'Refused', response.message
+ assert_equal 'CVC Declined', response.message
end
def test_successful_purchase
@@ -176,7 +188,7 @@ def test_successful_purchase_with_elo_card
def test_failed_purchase
response = @gateway.purchase(@amount, @declined_card, @options)
assert_failure response
- assert_equal 'Refused', response.message
+ assert_equal 'CVC Declined', response.message
end
def test_successful_authorize_and_capture
@@ -287,7 +299,7 @@ def test_failed_store
assert response = @gateway.store(@declined_card, @options)
assert_failure response
- assert_equal 'Refused', response.message
+ assert_equal 'CVC Declined', response.message
end
def test_successful_purchase_using_stored_card
@@ -326,7 +338,22 @@ def test_successful_verify
def test_failed_verify
response = @gateway.verify(@declined_card, @options)
assert_failure response
- assert_match 'Refused', response.message
+ assert_match 'CVC Declined', response.message
+ end
+
+ def test_verify_with_idempotency_key
+ options = @options.merge(idempotency_key: 'test123')
+ response = @gateway.authorize(0, @credit_card, options)
+ assert_success response
+ assert_equal 'Authorised', response.message
+ first_auth = response.authorization
+
+ response = @gateway.verify(@credit_card, options)
+ assert_success response
+ assert_equal response.authorization, first_auth
+
+ response = @gateway.void(first_auth, @options)
+ assert_success response
end
def test_invalid_login
diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb
index 9c6a759b5f6..0acbccdc1be 100644
--- a/test/unit/gateways/adyen_test.rb
+++ b/test/unit/gateways/adyen_test.rb
@@ -320,6 +320,26 @@ def test_extended_avs_response
assert_equal 'Card member\'s name, billing address, and billing postal code match.', response.avs_result['message']
end
+ def test_optional_idempotency_key_header
+ options = @options.merge(:idempotency_key => 'test123')
+ response = stub_comms do
+ @gateway.authorize(@amount, @credit_card, options)
+ end.check_request do |endpoint, data, headers|
+ assert headers['Idempotency-Key']
+ end.respond_with(successful_authorize_response)
+ assert_success response
+ end
+
+ def test_optional_idempotency_key_header_excluded_on_purchase
+ options = @options.merge(:idempotency_key => 'test123')
+ response = stub_comms do
+ @gateway.purchase(@amount, @credit_card, options)
+ end.check_request do |endpoint, data, headers|
+ refute headers['Idempotency-Key']
+ end.respond_with(successful_authorize_response, successful_capture_response)
+ assert_success response
+ end
+
private
def pre_scrubbed
From 21b1bd5ea12d902388d7062768b201ee7a1b12cc Mon Sep 17 00:00:00 2001
From: molbrown
Date: Tue, 5 Mar 2019 10:28:49 -0500
Subject: [PATCH 0293/2234] Revert "Adyen: Idempotency for non-purchase
requests"
This reverts commit 81625443efcab62809f4296e2363eb047c28c320.
---
CHANGELOG | 1 -
lib/active_merchant/billing/gateways/adyen.rb | 22 +++++-------
test/remote/gateways/remote_adyen_test.rb | 35 +++----------------
test/unit/gateways/adyen_test.rb | 20 -----------
4 files changed, 13 insertions(+), 65 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index c04d5b7d6e3..495e016c7c4 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -6,7 +6,6 @@
* Bambora Asia-Pacific: Adds Store [molbrown] #3147
* Orbital: Pass normalized stored credential fields [curiousepic] #3148
* Adds Elo card type in general and specifically to Adyen [deedeelavinder] #3153
-* Adyen: Idempotency for non-purchase requests [molbrown] #3157
== Version 1.91.0 (February 22, 2019)
* WorldPay: Pull CVC and AVS Result from Response [nfarve] #3106
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index 3b660688861..73789688028 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -37,7 +37,6 @@ def purchase(money, payment, options={})
authorize(money, payment, options)
else
MultiResponse.run do |r|
- options[:idempotency_key] = nil
r.process { authorize(money, payment, options) }
r.process { capture(money, r.authorization, options) }
end
@@ -54,27 +53,27 @@ def authorize(money, payment, options={})
add_address(post, options)
add_installments(post, options) if options[:installments]
add_3ds(post, options)
- commit('authorise', post, options)
+ commit('authorise', post)
end
def capture(money, authorization, options={})
post = init_post(options)
add_invoice_for_modification(post, money, options)
add_reference(post, authorization, options)
- commit('capture', post, options)
+ commit('capture', post)
end
def refund(money, authorization, options={})
post = init_post(options)
add_invoice_for_modification(post, money, options)
add_original_reference(post, authorization, options)
- commit('refund', post, options)
+ commit('refund', post)
end
def void(authorization, options={})
post = init_post(options)
add_reference(post, authorization, options)
- commit('cancel', post, options)
+ commit('cancel', post)
end
def store(credit_card, options={})
@@ -85,13 +84,12 @@ def store(credit_card, options={})
add_extra_data(post, credit_card, options)
add_recurring_contract(post, options)
add_address(post, options)
- commit('authorise', post, options)
+ commit('authorise', post)
end
def verify(credit_card, options={})
MultiResponse.run(:use_first_response) do |r|
r.process { authorize(0, credit_card, options) }
- options[:idempotency_key] = nil
r.process(:ignore_result) { void(r.authorization, options) }
end
end
@@ -288,9 +286,9 @@ def parse(body)
JSON.parse(body)
end
- def commit(action, parameters, options)
+ def commit(action, parameters)
begin
- raw_response = ssl_post("#{url}/#{action}", post_data(action, parameters), request_headers(action, options))
+ raw_response = ssl_post("#{url}/#{action}", post_data(action, parameters), request_headers)
response = parse(raw_response)
rescue ResponseError => e
raw_response = e.response.body
@@ -331,13 +329,11 @@ def basic_auth
Base64.strict_encode64("#{@username}:#{@password}")
end
- def request_headers(action, options)
- headers = {
+ def request_headers
+ {
'Content-Type' => 'application/json',
'Authorization' => "Basic #{basic_auth}"
}
- headers['Idempotency-Key'] = options[:idempotency_key] if options[:idempotency_key]
- headers
end
def success_from(action, response)
diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb
index 6c840699aba..9c964702ae7 100644
--- a/test/remote/gateways/remote_adyen_test.rb
+++ b/test/remote/gateways/remote_adyen_test.rb
@@ -71,18 +71,6 @@ def test_successful_authorize
assert_equal 'Authorised', response.message
end
- def test_successful_authorize_with_idempotency_key
- options = @options.merge(idempotency_key: 'test123')
- response = @gateway.authorize(@amount, @credit_card, options)
- assert_success response
- assert_equal 'Authorised', response.message
- first_auth = response.authorization
-
- response = @gateway.authorize(@amount, @credit_card, options)
- assert_success response
- assert_equal response.authorization, first_auth
- end
-
def test_successful_authorize_with_3ds
assert response = @gateway.authorize(@amount, @three_ds_enrolled_card, @options.merge(execute_threed: true))
assert response.test?
@@ -122,7 +110,7 @@ def test_successful_authorize_with_3ds_dynamic_rule_broken
def test_failed_authorize
response = @gateway.authorize(@amount, @declined_card, @options)
assert_failure response
- assert_equal 'CVC Declined', response.message
+ assert_equal 'Refused', response.message
end
def test_successful_purchase
@@ -188,7 +176,7 @@ def test_successful_purchase_with_elo_card
def test_failed_purchase
response = @gateway.purchase(@amount, @declined_card, @options)
assert_failure response
- assert_equal 'CVC Declined', response.message
+ assert_equal 'Refused', response.message
end
def test_successful_authorize_and_capture
@@ -299,7 +287,7 @@ def test_failed_store
assert response = @gateway.store(@declined_card, @options)
assert_failure response
- assert_equal 'CVC Declined', response.message
+ assert_equal 'Refused', response.message
end
def test_successful_purchase_using_stored_card
@@ -338,22 +326,7 @@ def test_successful_verify
def test_failed_verify
response = @gateway.verify(@declined_card, @options)
assert_failure response
- assert_match 'CVC Declined', response.message
- end
-
- def test_verify_with_idempotency_key
- options = @options.merge(idempotency_key: 'test123')
- response = @gateway.authorize(0, @credit_card, options)
- assert_success response
- assert_equal 'Authorised', response.message
- first_auth = response.authorization
-
- response = @gateway.verify(@credit_card, options)
- assert_success response
- assert_equal response.authorization, first_auth
-
- response = @gateway.void(first_auth, @options)
- assert_success response
+ assert_match 'Refused', response.message
end
def test_invalid_login
diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb
index 0acbccdc1be..9c6a759b5f6 100644
--- a/test/unit/gateways/adyen_test.rb
+++ b/test/unit/gateways/adyen_test.rb
@@ -320,26 +320,6 @@ def test_extended_avs_response
assert_equal 'Card member\'s name, billing address, and billing postal code match.', response.avs_result['message']
end
- def test_optional_idempotency_key_header
- options = @options.merge(:idempotency_key => 'test123')
- response = stub_comms do
- @gateway.authorize(@amount, @credit_card, options)
- end.check_request do |endpoint, data, headers|
- assert headers['Idempotency-Key']
- end.respond_with(successful_authorize_response)
- assert_success response
- end
-
- def test_optional_idempotency_key_header_excluded_on_purchase
- options = @options.merge(:idempotency_key => 'test123')
- response = stub_comms do
- @gateway.purchase(@amount, @credit_card, options)
- end.check_request do |endpoint, data, headers|
- refute headers['Idempotency-Key']
- end.respond_with(successful_authorize_response, successful_capture_response)
- assert_success response
- end
-
private
def pre_scrubbed
From 2183de5e559f26f267e7199ce2c80eedd65dd1e8 Mon Sep 17 00:00:00 2001
From: DeeDee Lavinder
Date: Mon, 4 Mar 2019 08:52:05 -0500
Subject: [PATCH 0294/2234] Mercado Pago: Adds Elo card type
Unit Tests:
22 tests, 111 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
Remote Tests:
22 tests, 61 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
90.9091% passed
(Two failures, for partial capture and processing mode, are unrelated.)
---
CHANGELOG | 1 +
.../billing/gateways/mercado_pago.rb | 2 +-
.../gateways/remote_mercado_pago_test.rb | 41 +++++++++++++
test/unit/gateways/mercado_pago_test.rb | 58 +++++++++++++++++++
4 files changed, 101 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 495e016c7c4..b1d8b239951 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -6,6 +6,7 @@
* Bambora Asia-Pacific: Adds Store [molbrown] #3147
* Orbital: Pass normalized stored credential fields [curiousepic] #3148
* Adds Elo card type in general and specifically to Adyen [deedeelavinder] #3153
+* Mercado Pago: Adds Elo card type [deedeelavinder] #3156
== Version 1.91.0 (February 22, 2019)
* WorldPay: Pull CVC and AVS Result from Response [nfarve] #3106
diff --git a/lib/active_merchant/billing/gateways/mercado_pago.rb b/lib/active_merchant/billing/gateways/mercado_pago.rb
index 79c2612dd25..f8bcc688fb7 100644
--- a/lib/active_merchant/billing/gateways/mercado_pago.rb
+++ b/lib/active_merchant/billing/gateways/mercado_pago.rb
@@ -4,7 +4,7 @@ class MercadoPagoGateway < Gateway
self.live_url = self.test_url = 'https://api.mercadopago.com/v1'
self.supported_countries = ['AR', 'BR', 'CL', 'CO', 'MX', 'PE', 'UY']
- self.supported_cardtypes = [:visa, :master, :american_express]
+ self.supported_cardtypes = [:visa, :master, :american_express, :elo]
self.homepage_url = 'https://www.mercadopago.com/'
self.display_name = 'Mercado Pago'
diff --git a/test/remote/gateways/remote_mercado_pago_test.rb b/test/remote/gateways/remote_mercado_pago_test.rb
index 917e9d316ad..d715d49d04d 100644
--- a/test/remote/gateways/remote_mercado_pago_test.rb
+++ b/test/remote/gateways/remote_mercado_pago_test.rb
@@ -6,6 +6,13 @@ def setup
@amount = 500
@credit_card = credit_card('4509953566233704')
+ @elo_credit_card = credit_card('5067268650517446',
+ :month => 10,
+ :year => 2020,
+ :first_name => 'John',
+ :last_name => 'Smith',
+ :verification_value => '737'
+ )
@declined_card = credit_card('4000300011112220')
@options = {
billing_address: address,
@@ -28,6 +35,12 @@ def test_successful_purchase
assert_equal 'accredited', response.message
end
+ def test_successful_purchase_with_elo
+ response = @gateway.purchase(@amount, @elo_credit_card, @options)
+ assert_success response
+ assert_equal 'accredited', response.message
+ end
+
def test_successful_purchase_with_binary_false
@options.update(binary_mode: false)
response = @gateway.authorize(@amount, @credit_card, @options)
@@ -67,6 +80,16 @@ def test_successful_authorize_and_capture
assert_equal 'accredited', capture.message
end
+ def test_successful_authorize_and_capture_with_elo
+ auth = @gateway.authorize(@amount, @elo_credit_card, @options)
+ assert_success auth
+ assert_equal 'pending_capture', auth.message
+
+ assert capture = @gateway.capture(@amount, auth.authorization)
+ assert_success capture
+ assert_equal 'accredited', capture.message
+ end
+
def test_failed_authorize
response = @gateway.authorize(@amount, @declined_card, @options)
assert_failure response
@@ -97,6 +120,15 @@ def test_successful_refund
assert_equal nil, refund.message
end
+ def test_successful_refund_with_elo
+ purchase = @gateway.purchase(@amount, @elo_credit_card, @options)
+ assert_success purchase
+
+ assert refund = @gateway.refund(@amount, purchase.authorization)
+ assert_success refund
+ assert_equal nil, refund.message
+ end
+
def test_partial_refund
purchase = @gateway.purchase(@amount, @credit_card, @options)
assert_success purchase
@@ -120,6 +152,15 @@ def test_successful_void
assert_equal 'by_collector', void.message
end
+ def test_successful_void_with_elo
+ auth = @gateway.authorize(@amount, @elo_credit_card, @options)
+ assert_success auth
+
+ assert void = @gateway.void(auth.authorization)
+ assert_success void
+ assert_equal 'by_collector', void.message
+ end
+
def test_failed_void
response = @gateway.void('')
assert_failure response
diff --git a/test/unit/gateways/mercado_pago_test.rb b/test/unit/gateways/mercado_pago_test.rb
index 9139432254c..3690b766f46 100644
--- a/test/unit/gateways/mercado_pago_test.rb
+++ b/test/unit/gateways/mercado_pago_test.rb
@@ -6,6 +6,13 @@ class MercadoPagoTest < Test::Unit::TestCase
def setup
@gateway = MercadoPagoGateway.new(access_token: 'access_token')
@credit_card = credit_card
+ @elo_credit_card = credit_card('5067268650517446',
+ :month => 10,
+ :year => 2020,
+ :first_name => 'John',
+ :last_name => 'Smith',
+ :verification_value => '737'
+ )
@amount = 100
@options = {
@@ -26,6 +33,17 @@ def test_successful_purchase
assert response.test?
end
+ def test_successful_purchase_with_elo
+ @gateway.expects(:ssl_post).at_most(2).returns(successful_purchase_with_elo_response)
+
+ response = @gateway.purchase(@amount, @elo_credit_card, @options)
+ assert_success response
+
+ assert_equal '18044843|1.0', response.authorization
+ assert_equal 'accredited', response.message
+ assert response.test?
+ end
+
def test_failed_purchase
@gateway.expects(:ssl_post).at_most(2).returns(failed_purchase_response)
@@ -46,6 +64,17 @@ def test_successful_authorize
assert response.test?
end
+ def test_successful_authorize_with_elo
+ @gateway.expects(:ssl_post).at_most(2).returns(successful_authorize_with_elo_response)
+
+ response = @gateway.authorize(@amount, @elo_credit_card, @options)
+ assert_success response
+
+ assert_equal '18044850|1.0', response.authorization
+ assert_equal 'pending_capture', response.message
+ assert response.test?
+ end
+
def test_failed_authorize
@gateway.expects(:ssl_post).at_most(2).returns(failed_authorize_response)
@@ -66,6 +95,17 @@ def test_successful_capture
assert response.test?
end
+ def test_successful_capture_with_elo
+ @gateway.expects(:ssl_request).returns(successful_capture_with_elo_response)
+
+ response = @gateway.capture(@amount, 'authorization|amount')
+ assert_success response
+
+ assert_equal '18044850|1.0', response.authorization
+ assert_equal 'accredited', response.message
+ assert response.test?
+ end
+
def test_failed_capture
@gateway.expects(:ssl_request).returns(failed_capture_response)
@@ -333,6 +373,12 @@ def successful_purchase_response
)
end
+ def successful_purchase_with_elo_response
+ %(
+ {"id":18044843,"date_created":"2019-03-04T09:39:21.000-04:00","date_approved":"2019-03-04T09:39:22.000-04:00","date_last_updated":"2019-03-04T09:39:22.000-04:00","date_of_expiration":null,"money_release_date":"2019-03-18T09:39:22.000-04:00","operation_type":"regular_payment","issuer_id":"687","payment_method_id":"elo","payment_type_id":"credit_card","status":"approved","status_detail":"accredited","currency_id":"BRL","description":"Store Purchase","live_mode":false,"sponsor_id":null,"authorization_code":null,"money_release_schema":null,"taxes_amount":0,"counter_currency":null,"shipping_amount":0,"pos_id":null,"store_id":null,"collector_id":263489584,"payer":{"first_name":"Test","last_name":"Test","email":"test_user_80507629@testuser.com","identification":{"number":"32659430","type":"DNI"},"phone":{"area_code":"01","number":"1111-1111","extension":""},"type":"registered","entity_type":null,"id":"412997143"},"metadata":{},"additional_info":{"payer":{"address":{"zip_code":"K1C2N6","street_name":"456 My Street Apt 1"}},"shipments":{"receiver_address":{"zip_code":"K1C2N6","street_name":"456 My Street Apt 1"}}},"order":{},"external_reference":"6cc551da28909403939d024cd067a65f","transaction_amount":5,"transaction_amount_refunded":0,"coupon_amount":0,"differential_pricing_id":null,"deduction_schema":null,"transaction_details":{"net_received_amount":4.75,"total_paid_amount":5,"overpaid_amount":0,"external_resource_url":null,"installment_amount":5,"financial_institution":null,"payment_method_reference_id":null,"payable_deferral_period":null,"acquirer_reference":null},"fee_details":[{"type":"mercadopago_fee","amount":0.25,"fee_payer":"collector"}],"captured":true,"binary_mode":true,"call_for_authorize_id":null,"statement_descriptor":"MERCADOPAGO","installments":1,"card":{"id":null,"first_six_digits":"506726","last_four_digits":"7446","expiration_month":10,"expiration_year":2020,"date_created":"2019-03-04T09:39:21.000-04:00","date_last_updated":"2019-03-04T09:39:21.000-04:00","cardholder":{"name":"John Smith","identification":{"number":null,"type":null}}},"notification_url":null,"refunds":[],"processing_mode":"aggregator","merchant_account_id":null,"acquirer":null,"merchant_number":null,"acquirer_reconciliation":[]}
+ )
+ end
+
def failed_purchase_response
%(
{"id":4142297,"date_created":"2017-07-06T10:13:32.000-04:00","date_approved":null,"date_last_updated":"2017-07-06T10:13:32.000-04:00","date_of_expiration":null,"money_release_date":null,"operation_type":"regular_payment","issuer_id":"166","payment_method_id":"visa","payment_type_id":"credit_card","status":"rejected","status_detail":"cc_rejected_other_reason","currency_id":"MXN","description":"Store Purchase","live_mode":false,"sponsor_id":null,"authorization_code":null,"related_exchange_rate":null,"collector_id":261735089,"payer":{"type":"guest","id":null,"email":"user@example.com","identification":{"type":null,"number":null},"phone":{"area_code":null,"number":null,"extension":""},"first_name":"First User","last_name":"User","entity_type":null},"metadata":{},"additional_info":{"payer":{"address":{"zip_code":"K1C2N6","street_name":"My Street","street_number":"456"}}},"order":{"type":"mercadopago","id":"830943860538524456"},"external_reference":null,"transaction_amount":5,"transaction_amount_refunded":0,"coupon_amount":0,"differential_pricing_id":null,"deduction_schema":null,"transaction_details":{"net_received_amount":0,"total_paid_amount":5,"overpaid_amount":0,"external_resource_url":null,"installment_amount":5,"financial_institution":null,"payment_method_reference_id":null,"payable_deferral_period":null,"acquirer_reference":null},"fee_details":[],"captured":true,"binary_mode":false,"call_for_authorize_id":null,"statement_descriptor":"WWW.MERCADOPAGO.COM","installments":1,"card":{"id":null,"first_six_digits":"400030","last_four_digits":"2220","expiration_month":9,"expiration_year":2018,"date_created":"2017-07-06T10:13:32.000-04:00","date_last_updated":"2017-07-06T10:13:32.000-04:00","cardholder":{"name":"Longbob Longsen","identification":{"number":null,"type":null}}},"notification_url":null,"refunds":[],"processing_mode":null,"merchant_account_id":null,"acquirer":null,"merchant_number":null}
@@ -345,6 +391,12 @@ def successful_authorize_response
)
end
+ def successful_authorize_with_elo_response
+ %(
+ {"id":18044850,"date_created":"2019-03-04T09:44:37.000-04:00","date_approved":null,"date_last_updated":"2019-03-04T09:44:40.000-04:00","date_of_expiration":null,"money_release_date":null,"operation_type":"regular_payment","issuer_id":"687","payment_method_id":"elo","payment_type_id":"credit_card","status":"authorized","status_detail":"pending_capture","currency_id":"BRL","description":"Store Purchase","live_mode":false,"sponsor_id":null,"authorization_code":null,"money_release_schema":null,"taxes_amount":0,"counter_currency":null,"shipping_amount":0,"pos_id":null,"store_id":null,"collector_id":263489584,"payer":{"first_name":"Test","last_name":"Test","email":"test_user_80507629@testuser.com","identification":{"number":"32659430","type":"DNI"},"phone":{"area_code":"01","number":"1111-1111","extension":""},"type":"registered","entity_type":null,"id":"413001901"},"metadata":{},"additional_info":{"payer":{"address":{"zip_code":"K1C2N6","street_name":"456 My Street Apt 1"}},"shipments":{"receiver_address":{"zip_code":"K1C2N6","street_name":"456 My Street Apt 1"}}},"order":{},"external_reference":"24cd4658b9ea6dbf164f9fb9f67e5e78","transaction_amount":5,"transaction_amount_refunded":0,"coupon_amount":0,"differential_pricing_id":null,"deduction_schema":null,"transaction_details":{"net_received_amount":0,"total_paid_amount":5,"overpaid_amount":0,"external_resource_url":null,"installment_amount":5,"financial_institution":null,"payment_method_reference_id":null,"payable_deferral_period":null,"acquirer_reference":null},"fee_details":[],"captured":false,"binary_mode":true,"call_for_authorize_id":null,"statement_descriptor":"MERCADOPAGO","installments":1,"card":{"id":null,"first_six_digits":"506726","last_four_digits":"7446","expiration_month":10,"expiration_year":2020,"date_created":"2019-03-04T09:44:37.000-04:00","date_last_updated":"2019-03-04T09:44:37.000-04:00","cardholder":{"name":"John Smith","identification":{"number":null,"type":null}}},"notification_url":null,"refunds":[],"processing_mode":"aggregator","merchant_account_id":null,"acquirer":null,"merchant_number":null,"acquirer_reconciliation":[]}
+ )
+ end
+
def failed_authorize_response
%(
{"id":4261953,"date_created":"2017-07-13T14:25:33.000-04:00","date_approved":null,"date_last_updated":"2017-07-13T14:25:33.000-04:00","date_of_expiration":null,"money_release_date":null,"operation_type":"regular_payment","issuer_id":"25","payment_method_id":"visa","payment_type_id":"credit_card","status":"rejected","status_detail":"cc_rejected_other_reason","currency_id":"BRL","description":"Store Purchase","live_mode":false,"sponsor_id":null,"authorization_code":null,"related_exchange_rate":null,"collector_id":263489584,"payer":{"type":"guest","id":null,"email":"user+br@example.com","identification":{"type":null,"number":null},"phone":{"area_code":null,"number":null,"extension":null},"first_name":null,"last_name":null,"entity_type":null},"metadata":{},"additional_info":{"payer":{"address":{"zip_code":"K1C2N6","street_name":"My Street","street_number":"456"}}},"order":{"type":"mercadopago","id":"7528376941458928221"},"external_reference":null,"transaction_amount":5,"transaction_amount_refunded":0,"coupon_amount":0,"differential_pricing_id":null,"deduction_schema":null,"transaction_details":{"net_received_amount":0,"total_paid_amount":5,"overpaid_amount":0,"external_resource_url":null,"installment_amount":5,"financial_institution":null,"payment_method_reference_id":null,"payable_deferral_period":null,"acquirer_reference":null},"fee_details":[],"captured":false,"binary_mode":false,"call_for_authorize_id":null,"statement_descriptor":"WWW.MERCADOPAGO.COM","installments":1,"card":{"id":null,"first_six_digits":"400030","last_four_digits":"2220","expiration_month":9,"expiration_year":2018,"date_created":"2017-07-13T14:25:33.000-04:00","date_last_updated":"2017-07-13T14:25:33.000-04:00","cardholder":{"name":"Longbob Longsen","identification":{"number":null,"type":null}}},"notification_url":null,"refunds":[],"processing_mode":"aggregator","merchant_account_id":null,"acquirer":null,"merchant_number":null}
@@ -357,6 +409,12 @@ def successful_capture_response
)
end
+ def successful_capture_with_elo_response
+ %(
+ {"id":18044850,"date_created":"2019-03-04T09:44:37.000-04:00","date_approved":"2019-03-04T09:44:41.000-04:00","date_last_updated":"2019-03-04T09:44:41.000-04:00","date_of_expiration":null,"money_release_date":"2019-03-18T09:44:41.000-04:00","operation_type":"regular_payment","issuer_id":"687","payment_method_id":"elo","payment_type_id":"credit_card","status":"approved","status_detail":"accredited","currency_id":"BRL","description":"Store Purchase","live_mode":false,"sponsor_id":null,"authorization_code":null,"money_release_schema":null,"taxes_amount":0,"counter_currency":null,"shipping_amount":0,"pos_id":null,"store_id":null,"collector_id":263489584,"payer":{"first_name":"Test","last_name":"Test","email":"test_user_80507629@testuser.com","identification":{"number":"32659430","type":"DNI"},"phone":{"area_code":"01","number":"1111-1111","extension":""},"type":"registered","entity_type":null,"id":"413001901"},"metadata":{},"additional_info":{"payer":{"address":{"zip_code":"K1C2N6","street_name":"456 My Street Apt 1"}},"shipments":{"receiver_address":{"zip_code":"K1C2N6","street_name":"456 My Street Apt 1"}}},"order":{},"external_reference":"24cd4658b9ea6dbf164f9fb9f67e5e78","transaction_amount":5,"transaction_amount_refunded":0,"coupon_amount":0,"differential_pricing_id":null,"deduction_schema":null,"transaction_details":{"net_received_amount":4.75,"total_paid_amount":5,"overpaid_amount":0,"external_resource_url":null,"installment_amount":5,"financial_institution":null,"payment_method_reference_id":null,"payable_deferral_period":null,"acquirer_reference":null},"fee_details":[{"type":"mercadopago_fee","amount":0.25,"fee_payer":"collector"}],"captured":true,"binary_mode":true,"call_for_authorize_id":null,"statement_descriptor":"MERCADOPAGO","installments":1,"card":{"id":null,"first_six_digits":"506726","last_four_digits":"7446","expiration_month":10,"expiration_year":2020,"date_created":"2019-03-04T09:44:37.000-04:00","date_last_updated":"2019-03-04T09:44:37.000-04:00","cardholder":{"name":"John Smith","identification":{"number":null,"type":null}}},"notification_url":null,"refunds":[],"processing_mode":"aggregator","merchant_account_id":null,"acquirer":null,"merchant_number":null,"acquirer_reconciliation":[]}
+ )
+ end
+
def failed_capture_response
%(
{"message":"Method not allowed","error":"method_not_allowed","status":405,"cause":[{"code":"Method not allowed","description":"Method not allowed","data":null}]}
From 645264b8804b07f05dd6cfe784ab648e6c20063d Mon Sep 17 00:00:00 2001
From: Zeb DeOs
Date: Wed, 6 Mar 2019 15:39:43 -0500
Subject: [PATCH 0295/2234] Litle: implement stored credentials
Implement stored credential support for the Litle/Vantive gateway by way
of the new normalized stored credential hash.
ECS-138
Unit:
44 tests, 195 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
42 tests, 196 assertions, 10 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
76.1905% passed
(10 remote test failures pre-existed this commit and are unrelated to
addition of stored credentials. They were not trivial for me to fix this
go-around and may have something to do with some of the older remote
tests using canned responses from previous version of the cnpAPI than we
currently target.)
closes #3155
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/litle.rb | 64 ++++-
test/remote/gateways/remote_litle_test.rb | 220 +++++++++++++++++-
test/unit/gateways/litle_test.rb | 202 ++++++++++++++++
4 files changed, 483 insertions(+), 4 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index b1d8b239951..c61bb536c50 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -7,6 +7,7 @@
* Orbital: Pass normalized stored credential fields [curiousepic] #3148
* Adds Elo card type in general and specifically to Adyen [deedeelavinder] #3153
* Mercado Pago: Adds Elo card type [deedeelavinder] #3156
+* Litle: Add support for stored credentials [bayprogrammer] #3155
== Version 1.91.0 (February 22, 2019)
* WorldPay: Pull CVC and AVS Result from Response [nfarve] #3106
diff --git a/lib/active_merchant/billing/gateways/litle.rb b/lib/active_merchant/billing/gateways/litle.rb
index 82b35cc7af6..2a871d892d0 100644
--- a/lib/active_merchant/billing/gateways/litle.rb
+++ b/lib/active_merchant/billing/gateways/litle.rb
@@ -3,7 +3,7 @@
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
class LitleGateway < Gateway
- SCHEMA_VERSION = '9.12'
+ SCHEMA_VERSION = '9.14'
self.test_url = 'https://www.testvantivcnp.com/sandbox/communicator/online'
self.live_url = 'https://payments.vantivcnp.com/vap/communicator/online'
@@ -223,6 +223,7 @@ def add_auth_purchase_params(doc, money, payment_method, options)
add_descriptor(doc, options)
add_merchant_data(doc, options)
add_debt_repayment(doc, options)
+ add_stored_credential_params(doc, options)
end
def add_merchant_data(doc, options={})
@@ -293,6 +294,38 @@ def add_payment_method(doc, payment_method, options)
end
end
+ def add_stored_credential_params(doc, options={})
+ return unless options[:stored_credential]
+
+ if options[:stored_credential][:initial_transaction]
+ add_stored_credential_params_initial(doc, options)
+ else
+ add_stored_credential_params_used(doc, options)
+ end
+ end
+
+ def add_stored_credential_params_initial(doc, options)
+ case options[:stored_credential][:reason_type]
+ when 'unscheduled'
+ doc.processingType('initialCOF')
+ when 'installment'
+ doc.processingType('initialInstallment')
+ when 'recurring'
+ doc.processingType('initialRecurring')
+ end
+ end
+
+ def add_stored_credential_params_used(doc, options)
+ if options[:stored_credential][:reason_type] == 'unscheduled'
+ if options[:stored_credential][:initiator] == 'merchant'
+ doc.processingType('merchantInitiatedCOF')
+ else
+ doc.processingType('cardholderInitiatedCOF')
+ end
+ end
+ doc.originalNetworkTransactionId(options[:stored_credential][:network_transaction_id])
+ end
+
def add_billing_address(doc, payment_method, options)
return if payment_method.is_a?(String)
@@ -332,8 +365,9 @@ def add_address(doc, address)
end
def add_order_source(doc, payment_method, options)
- if options[:order_source]
- doc.orderSource(options[:order_source])
+ order_source = order_source(options)
+ if order_source
+ doc.orderSource(order_source)
elsif payment_method.is_a?(NetworkTokenizationCreditCard) && payment_method.source == :apple_pay
doc.orderSource('applepay')
elsif payment_method.is_a?(NetworkTokenizationCreditCard) && payment_method.source == :android_pay
@@ -345,6 +379,30 @@ def add_order_source(doc, payment_method, options)
end
end
+ def order_source(options={})
+ return options[:order_source] unless options[:stored_credential]
+ order_source = nil
+
+ case options[:stored_credential][:reason_type]
+ when 'unscheduled'
+ if options[:stored_credential][:initiator] == 'merchant'
+ # For merchant-initiated, we should always set order source to
+ # 'ecommerce'
+ order_source = 'ecommerce'
+ else
+ # For cardholder-initiated, we rely on #add_order_source's
+ # default logic to set orderSource appropriately
+ order_source = options[:order_source]
+ end
+ when 'installment'
+ order_source = 'installment'
+ when 'recurring'
+ order_source = 'recurring'
+ end
+
+ order_source
+ end
+
def add_pos(doc, payment_method)
return unless payment_method.respond_to?(:track_data) && payment_method.track_data.present?
diff --git a/test/remote/gateways/remote_litle_test.rb b/test/remote/gateways/remote_litle_test.rb
index 6fd3107832f..fb7759cde92 100644
--- a/test/remote/gateways/remote_litle_test.rb
+++ b/test/remote/gateways/remote_litle_test.rb
@@ -213,7 +213,7 @@ def test_unsuccessful_purchase
assert_equal 'Insufficient Funds', response.message
end
- def test_authorization_capture_refund_void
+ def test_authorize_capture_refund_void
assert auth = @gateway.authorize(10010, @credit_card1, @options)
assert_success auth
assert_equal 'Approved', auth.message
@@ -231,6 +231,224 @@ def test_authorization_capture_refund_void
assert_equal 'Approved', void.message
end
+ def test_authorize_and_capture_with_stored_credential_recurring
+ credit_card = CreditCard.new(@credit_card_hash.merge(
+ number: '4100200300011001',
+ month: '05',
+ year: '2021',
+ verification_value: '463'
+ ))
+
+ initial_options = @options.merge(
+ order_id: 'Net_Id1',
+ stored_credential: {
+ initial_transaction: true,
+ reason_type: 'recurring',
+ initiator: 'merchant',
+ network_transaction_id: nil
+ }
+ )
+ assert auth = @gateway.authorize(4999, credit_card, initial_options)
+ assert_success auth
+ assert_equal 'Approved', auth.message
+ assert network_transaction_id = auth.params['networkTransactionId']
+
+ assert capture = @gateway.capture(4999, auth.authorization)
+ assert_success capture
+ assert_equal 'Approved', capture.message
+
+ used_options = @options.merge(
+ order_id: 'Net_Id1a',
+ stored_credential: {
+ initial_transaction: false,
+ reason_type: 'recurring',
+ initiator: 'merchant',
+ network_transaction_id: network_transaction_id
+ }
+ )
+ assert auth = @gateway.authorize(4999, credit_card, used_options)
+ assert_success auth
+ assert_equal 'Approved', auth.message
+
+ assert capture = @gateway.capture(4999, auth.authorization)
+ assert_success capture
+ assert_equal 'Approved', capture.message
+ end
+
+ def test_authorize_and_capture_with_stored_credential_installment
+ credit_card = CreditCard.new(@credit_card_hash.merge(
+ number: '4457010000000009',
+ month: '01',
+ year: '2021',
+ verification_value: '349'
+ ))
+
+ initial_options = @options.merge(
+ order_id: 'Net_Id2',
+ stored_credential: {
+ initial_transaction: true,
+ reason_type: 'installment',
+ initiator: 'merchant',
+ network_transaction_id: nil
+ }
+ )
+ assert auth = @gateway.authorize(5500, credit_card, initial_options)
+ assert_success auth
+ assert_equal 'Approved', auth.message
+ assert network_transaction_id = auth.params['networkTransactionId']
+
+ assert capture = @gateway.capture(5500, auth.authorization)
+ assert_success capture
+ assert_equal 'Approved', capture.message
+
+ used_options = @options.merge(
+ order_id: 'Net_Id2a',
+ stored_credential: {
+ initial_transaction: false,
+ reason_type: 'installment',
+ initiator: 'merchant',
+ network_transaction_id: network_transaction_id
+ }
+ )
+ assert auth = @gateway.authorize(5500, credit_card, used_options)
+ assert_success auth
+ assert_equal 'Approved', auth.message
+
+ assert capture = @gateway.capture(5500, auth.authorization)
+ assert_success capture
+ assert_equal 'Approved', capture.message
+ end
+
+ def test_authorize_and_capture_with_stored_credential_mit_card_on_file
+ credit_card = CreditCard.new(@credit_card_hash.merge(
+ number: '4457000800000002',
+ month: '01',
+ year: '2021',
+ verification_value: '349'
+ ))
+
+ initial_options = @options.merge(
+ order_id: 'Net_Id3',
+ stored_credential: {
+ initial_transaction: true,
+ reason_type: 'unscheduled',
+ initiator: 'merchant',
+ network_transaction_id: nil
+ }
+ )
+ assert auth = @gateway.authorize(5500, credit_card, initial_options)
+ assert_success auth
+ assert_equal 'Approved', auth.message
+ assert network_transaction_id = auth.params['networkTransactionId']
+
+ assert capture = @gateway.capture(5500, auth.authorization)
+ assert_success capture
+ assert_equal 'Approved', capture.message
+
+ used_options = @options.merge(
+ order_id: 'Net_Id3a',
+ stored_credential: {
+ initial_transaction: false,
+ reason_type: 'unscheduled',
+ initiator: 'merchant',
+ network_transaction_id: network_transaction_id
+ }
+ )
+ assert auth = @gateway.authorize(2500, credit_card, used_options)
+ assert_success auth
+ assert_equal 'Approved', auth.message
+
+ assert capture = @gateway.capture(2500, auth.authorization)
+ assert_success capture
+ assert_equal 'Approved', capture.message
+ end
+
+ def test_authorize_and_capture_with_stored_credential_cit_card_on_file
+ credit_card = CreditCard.new(@credit_card_hash.merge(
+ number: '4457000800000002',
+ month: '01',
+ year: '2021',
+ verification_value: '349'
+ ))
+
+ initial_options = @options.merge(
+ order_id: 'Net_Id3',
+ stored_credential: {
+ initial_transaction: true,
+ reason_type: 'unscheduled',
+ initiator: 'cardholder',
+ network_transaction_id: nil
+ }
+ )
+ assert auth = @gateway.authorize(5500, credit_card, initial_options)
+ assert_success auth
+ assert_equal 'Approved', auth.message
+ assert network_transaction_id = auth.params['networkTransactionId']
+
+ assert capture = @gateway.capture(5500, auth.authorization)
+ assert_success capture
+ assert_equal 'Approved', capture.message
+
+ used_options = @options.merge(
+ order_id: 'Net_Id3b',
+ stored_credential: {
+ initial_transaction: false,
+ reason_type: 'unscheduled',
+ initiator: 'cardholder',
+ network_transaction_id: network_transaction_id
+ }
+ )
+ assert auth = @gateway.authorize(4000, credit_card, used_options)
+ assert_success auth
+ assert_equal 'Approved', auth.message
+
+ assert capture = @gateway.capture(4000, auth.authorization)
+ assert_success capture
+ assert_equal 'Approved', capture.message
+ end
+
+ def test_purchase_with_stored_credential_cit_card_on_file_non_ecommerce
+ credit_card = CreditCard.new(@credit_card_hash.merge(
+ number: '4457000800000002',
+ month: '01',
+ year: '2021',
+ verification_value: '349'
+ ))
+
+ initial_options = @options.merge(
+ order_id: 'Net_Id3',
+ order_source: '3dsAuthenticated',
+ xid: 'BwABBJQ1AgAAAAAgJDUCAAAAAAA=',
+ cavv: 'BwABBJQ1AgAAAAAgJDUCAAAAAAA=',
+ stored_credential: {
+ initial_transaction: true,
+ reason_type: 'unscheduled',
+ initiator: 'cardholder',
+ network_transaction_id: nil
+ }
+ )
+ assert auth = @gateway.purchase(5500, credit_card, initial_options)
+ assert_success auth
+ assert_equal 'Approved', auth.message
+ assert network_transaction_id = auth.params['networkTransactionId']
+
+ used_options = @options.merge(
+ order_id: 'Net_Id3b',
+ order_source: '3dsAuthenticated',
+ xid: 'BwABBJQ1AgAAAAAgJDUCAAAAAAA=',
+ cavv: 'BwABBJQ1AgAAAAAgJDUCAAAAAAA=',
+ stored_credential: {
+ initial_transaction: false,
+ reason_type: 'unscheduled',
+ initiator: 'cardholder',
+ network_transaction_id: network_transaction_id
+ }
+ )
+ assert auth = @gateway.purchase(4000, credit_card, used_options)
+ assert_success auth
+ assert_equal 'Approved', auth.message
+ end
+
def test_void_with_echeck
options = @options.merge({
order_id: '42',
diff --git a/test/unit/gateways/litle_test.rb b/test/unit/gateways/litle_test.rb
index 00538933ec8..2eafd178f35 100644
--- a/test/unit/gateways/litle_test.rb
+++ b/test/unit/gateways/litle_test.rb
@@ -388,6 +388,188 @@ def test_unsuccessful_xml_schema_validation
assert_equal '1', response.params['response']
end
+ def test_stored_credential_cit_card_on_file_initial
+ options = @options.merge(
+ stored_credential: {
+ initial_transaction: true,
+ reason_type: 'unscheduled',
+ initiator: 'cardholder',
+ network_transaction_id: nil
+ }
+ )
+
+ response = stub_comms do
+ @gateway.authorize(@amount, @credit_card, options)
+ end.check_request do |endpoint, data, headers|
+ assert_match(%r(initialCOF), data)
+ end.respond_with(successful_authorize_stored_credentials)
+
+ assert_success response
+ end
+
+ def test_stored_credential_cit_card_on_file_used
+ options = @options.merge(
+ stored_credential: {
+ initial_transaction: false,
+ reason_type: 'unscheduled',
+ initiator: 'cardholder',
+ network_transaction_id: network_transaction_id
+ }
+ )
+
+ response = stub_comms do
+ @gateway.authorize(@amount, @credit_card, options)
+ end.check_request do |endpoint, data, headers|
+ assert_match(%r(cardholderInitiatedCOF), data)
+ assert_match(%r(#{network_transaction_id}), data)
+ assert_match(%r(ecommerce), data)
+ end.respond_with(successful_authorize_stored_credentials)
+
+ assert_success response
+ end
+
+ def test_stored_credential_cit_cof_doesnt_override_order_source
+ options = @options.merge(
+ order_source: '3dsAuthenticated',
+ xid: 'BwABBJQ1AgAAAAAgJDUCAAAAAAA=',
+ cavv: 'BwABBJQ1AgAAAAAgJDUCAAAAAAA=',
+ stored_credential: {
+ initial_transaction: false,
+ reason_type: 'unscheduled',
+ initiator: 'cardholder',
+ network_transaction_id: network_transaction_id
+ }
+ )
+
+ response = stub_comms do
+ @gateway.authorize(@amount, @credit_card, options)
+ end.check_request do |endpoint, data, headers|
+ assert_match(%r(cardholderInitiatedCOF), data)
+ assert_match(%r(#{network_transaction_id}), data)
+ assert_match(%r(3dsAuthenticated), data)
+ end.respond_with(successful_authorize_stored_credentials)
+
+ assert_success response
+ end
+
+ def test_stored_credential_mit_card_on_file_initial
+ options = @options.merge(
+ stored_credential: {
+ initial_transaction: true,
+ reason_type: 'unscheduled',
+ initiator: 'merchant',
+ network_transaction_id: nil
+ }
+ )
+
+ response = stub_comms do
+ @gateway.authorize(@amount, @credit_card, options)
+ end.check_request do |endpoint, data, headers|
+ assert_match(%r(initialCOF), data)
+ end.respond_with(successful_authorize_stored_credentials)
+
+ assert_success response
+ end
+
+ def test_stored_credential_mit_card_on_file_used
+ options = @options.merge(
+ stored_credential: {
+ initial_transaction: false,
+ reason_type: 'unscheduled',
+ initiator: 'merchant',
+ network_transaction_id: network_transaction_id
+ }
+ )
+
+ response = stub_comms do
+ @gateway.authorize(@amount, @credit_card, options)
+ end.check_request do |endpoint, data, headers|
+ assert_match(%r(merchantInitiatedCOF), data)
+ assert_match(%r(#{network_transaction_id}), data)
+ assert_match(%r(ecommerce), data)
+ end.respond_with(successful_authorize_stored_credentials)
+
+ assert_success response
+ end
+
+ def test_stored_credential_installment_initial
+ options = @options.merge(
+ stored_credential: {
+ initial_transaction: true,
+ reason_type: 'installment',
+ initiator: 'merchant',
+ network_transaction_id: nil
+ }
+ )
+
+ response = stub_comms do
+ @gateway.authorize(@amount, @credit_card, options)
+ end.check_request do |endpoint, data, headers|
+ assert_match(%r(initialInstallment), data)
+ end.respond_with(successful_authorize_stored_credentials)
+
+ assert_success response
+ end
+
+ def test_stored_credential_installment_used
+ options = @options.merge(
+ stored_credential: {
+ initial_transaction: false,
+ reason_type: 'installment',
+ initiator: 'merchant',
+ network_transaction_id: network_transaction_id
+ }
+ )
+
+ response = stub_comms do
+ @gateway.authorize(@amount, @credit_card, options)
+ end.check_request do |endpoint, data, headers|
+ assert_match(%r(#{network_transaction_id}), data)
+ assert_match(%r(installment), data)
+ end.respond_with(successful_authorize_stored_credentials)
+
+ assert_success response
+ end
+
+ def test_stored_credential_recurring_initial
+ options = @options.merge(
+ stored_credential: {
+ initial_transaction: true,
+ reason_type: 'recurring',
+ initiator: 'merchant',
+ network_transaction_id: nil
+ }
+ )
+
+ response = stub_comms do
+ @gateway.authorize(@amount, @credit_card, options)
+ end.check_request do |endpoint, data, headers|
+ assert_match(%r(initialRecurring), data)
+ end.respond_with(successful_authorize_stored_credentials)
+
+ assert_success response
+ end
+
+ def test_stored_credential_recurring_used
+ options = @options.merge(
+ stored_credential: {
+ initial_transaction: false,
+ reason_type: 'recurring',
+ initiator: 'merchant',
+ network_transaction_id: network_transaction_id
+ }
+ )
+
+ response = stub_comms do
+ @gateway.authorize(@amount, @credit_card, options)
+ end.check_request do |endpoint, data, headers|
+ assert_match(%r(#{network_transaction_id}), data)
+ assert_match(%r(recurring), data)
+ end.respond_with(successful_authorize_stored_credentials)
+
+ assert_success response
+ end
+
def test_scrub
assert_equal @gateway.scrub(pre_scrub), post_scrub
end
@@ -398,6 +580,10 @@ def test_supports_scrubbing?
private
+ def network_transaction_id
+ '63225578415568556365452427825'
+ end
+
def successful_purchase_response
%(
@@ -431,6 +617,22 @@ def successful_purchase_with_echeck_response
)
end
+ def successful_authorize_stored_credentials
+ %(
+
+
+ 991939023768015826
+ 1
+ 000
+ Approved
+ 2019-02-26T17:45:29.885
+ 75045
+ 63225578415568556365452427825
+
+
+ )
+ end
+
def failed_purchase_response
%(
From 825008a75d73c137008996a9955e8b8e13fb72f4 Mon Sep 17 00:00:00 2001
From: Zeb DeOs
Date: Wed, 6 Mar 2019 14:38:36 -0500
Subject: [PATCH 0296/2234] Adyen: Correctly process risk_data option
This fixes how we pass risk data to Adyen via the `risk_data` option.
Adyen requires provided risk data elements to be included directly under
`additionalData`, not in a sub-hash, with keys prefixed with
`riskdata.`.
ECS-200
Unit:
29 tests, 140 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
47 tests, 133 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
closes #3161
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/adyen.rb | 8 ++++----
test/unit/gateways/adyen_test.rb | 18 +++++++++++++++++-
3 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index c61bb536c50..70dd9cd8d9e 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -8,6 +8,7 @@
* Adds Elo card type in general and specifically to Adyen [deedeelavinder] #3153
* Mercado Pago: Adds Elo card type [deedeelavinder] #3156
* Litle: Add support for stored credentials [bayprogrammer] #3155
+* Adyen: Correctly process risk_data option [bayprogrammer] #3161
== Version 1.91.0 (February 22, 2019)
* WorldPay: Pull CVC and AVS Result from Response [nfarve] #3106
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index 73789688028..94634aa86f5 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -167,10 +167,10 @@ def add_extra_data(post, payment, options)
end
def add_risk_data(post, options)
- risk_data = {}
- risk_data.merge!(options[:risk_data]) if options[:risk_data]
-
- post[:additionalData][:riskData] = risk_data unless risk_data.empty?
+ if (risk_data = options[:risk_data])
+ risk_data = Hash[risk_data.map { |k, v| ["riskdata.#{k}", v] }]
+ post[:additionalData].merge!(risk_data)
+ end
end
def add_shopper_interaction(post, payment, options={})
diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb
index 9c6a759b5f6..5b68f781121 100644
--- a/test/unit/gateways/adyen_test.rb
+++ b/test/unit/gateways/adyen_test.rb
@@ -169,7 +169,23 @@ def test_risk_data_sent
stub_comms do
@gateway.authorize(@amount, @credit_card, @options.merge({risk_data: {'operatingSystem' => 'HAL9000'}}))
end.check_request do |endpoint, data, headers|
- assert_equal 'HAL9000', JSON.parse(data)['additionalData']['riskData']['operatingSystem']
+ assert_equal 'HAL9000', JSON.parse(data)['additionalData']['riskdata.operatingSystem']
+ end.respond_with(successful_authorize_response)
+ end
+
+ def test_risk_data_complex_data
+ stub_comms do
+ risk_data = {
+ 'deliveryMethod' => 'express',
+ 'basket.item.productTitle' => 'Blue T Shirt',
+ 'promotions.promotion.promotionName' => 'Big Sale promotion'
+ }
+ @gateway.authorize(@amount, @credit_card, @options.merge({risk_data: risk_data}))
+ end.check_request do |endpoint, data, headers|
+ parsed = JSON.parse(data)
+ assert_equal 'express', parsed['additionalData']['riskdata.deliveryMethod']
+ assert_equal 'Blue T Shirt', parsed['additionalData']['riskdata.basket.item.productTitle']
+ assert_equal 'Big Sale promotion', parsed['additionalData']['riskdata.promotions.promotion.promotionName']
end.respond_with(successful_authorize_response)
end
From 88b906e2afd3955492d5439a334ba84e7da5407c Mon Sep 17 00:00:00 2001
From: DeeDee Lavinder
Date: Wed, 6 Mar 2019 12:22:54 -0500
Subject: [PATCH 0297/2234] Paymentez: Adds Elo
Adds Elo card type.
Unit Tests:
23 tests, 95 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
Remote Tests:
26 tests, 60 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
92.3077% passed
(Both of these failures are unrelated to the changes included. They have
to do with `capture` and succeed when run individually.)
---
CHANGELOG | 1 +
.../billing/gateways/paymentez.rb | 5 +-
test/remote/gateways/remote_paymentez_test.rb | 54 ++++++-
test/unit/gateways/paymentez_test.rb | 136 ++++++++++++++++++
4 files changed, 192 insertions(+), 4 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 70dd9cd8d9e..60c3a3858e2 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -9,6 +9,7 @@
* Mercado Pago: Adds Elo card type [deedeelavinder] #3156
* Litle: Add support for stored credentials [bayprogrammer] #3155
* Adyen: Correctly process risk_data option [bayprogrammer] #3161
+* Paymentez: Adds Elo card type [deedeelavinder] #3162
== Version 1.91.0 (February 22, 2019)
* WorldPay: Pull CVC and AVS Result from Response [nfarve] #3106
diff --git a/lib/active_merchant/billing/gateways/paymentez.rb b/lib/active_merchant/billing/gateways/paymentez.rb
index f93a4bed6fa..50463010ea2 100644
--- a/lib/active_merchant/billing/gateways/paymentez.rb
+++ b/lib/active_merchant/billing/gateways/paymentez.rb
@@ -9,7 +9,7 @@ class PaymentezGateway < Gateway #:nodoc:
self.supported_countries = %w[MX EC VE CO BR CL]
self.default_currency = 'USD'
- self.supported_cardtypes = %i[visa master american_express diners_club]
+ self.supported_cardtypes = %i[visa master american_express diners_club elo]
self.homepage_url = 'https://secure.paymentez.com/'
self.display_name = 'Paymentez'
@@ -38,7 +38,8 @@ class PaymentezGateway < Gateway #:nodoc:
'visa' => 'vi',
'master' => 'mc',
'american_express' => 'ax',
- 'diners_club' => 'di'
+ 'diners_club' => 'di',
+ 'elo' => 'el'
}.freeze
def initialize(options = {})
diff --git a/test/remote/gateways/remote_paymentez_test.rb b/test/remote/gateways/remote_paymentez_test.rb
index f5041384031..831b61b07ca 100644
--- a/test/remote/gateways/remote_paymentez_test.rb
+++ b/test/remote/gateways/remote_paymentez_test.rb
@@ -6,6 +6,14 @@ def setup
@amount = 100
@credit_card = credit_card('4111111111111111', verification_value: '666')
+ @elo_credit_card = credit_card('6362970000457013',
+ :month => 10,
+ :year => 2020,
+ :first_name => 'John',
+ :last_name => 'Smith',
+ :verification_value => '737',
+ :brand => 'elo'
+ )
@declined_card = credit_card('4242424242424242', verification_value: '666')
@options = {
billing_address: address,
@@ -22,6 +30,11 @@ def test_successful_purchase
assert_success response
end
+ def test_successful_purchase_with_elo
+ response = @gateway.purchase(@amount, @elo_credit_card, @options)
+ assert_success response
+ end
+
def test_successful_purchase_with_more_options
options = {
order_id: '1',
@@ -89,7 +102,15 @@ def test_successful_refund
auth = @gateway.purchase(@amount, @credit_card, @options)
assert_success auth
- assert refund = @gateway.refund(@amount, @credit_card, @options)
+ assert refund = @gateway.refund(@amount, auth.authorization, @options)
+ assert_success refund
+ end
+
+ def test_successful_refund_with_elo
+ auth = @gateway.purchase(@amount, @elo_credit_card, @options)
+ assert_success auth
+
+ assert refund = @gateway.refund(@amount, auth.authorization, @options)
assert_success refund
end
@@ -101,6 +122,14 @@ def test_successful_void
assert_success void
end
+ def test_successful_void_with_elo
+ auth = @gateway.purchase(@amount, @elo_credit_card, @options)
+ assert_success auth
+
+ assert void = @gateway.void(auth.authorization)
+ assert_success void
+ end
+
def test_failed_void
response = @gateway.void('')
assert_failure response
@@ -116,6 +145,14 @@ def test_successful_authorize_and_capture
assert_equal 'Response by mock', capture.message
end
+ def test_successful_authorize_and_capture_with_elo
+ auth = @gateway.authorize(@amount, @elo_credit_card, @options)
+ assert_success auth
+ assert capture = @gateway.capture(@amount, auth.authorization)
+ assert_success capture
+ assert_equal 'Response by mock', capture.message
+ end
+
def test_successful_authorize_and_capture_with_token
store_response = @gateway.store(@credit_card, @options)
assert_success store_response
@@ -159,6 +196,11 @@ def test_store
assert_success response
end
+ def test_store_with_elo
+ response = @gateway.store(@elo_credit_card, @options)
+ assert_success response
+ end
+
def test_unstore
response = @gateway.store(@credit_card, @options)
assert_success response
@@ -167,12 +209,20 @@ def test_unstore
assert_success response
end
+ def test_unstore_with_elo
+ response = @gateway.store(@elo_credit_card, @options)
+ assert_success response
+ auth = response.authorization
+ response = @gateway.unstore(auth, @options)
+ assert_success response
+ end
+
def test_invalid_login
gateway = PaymentezGateway.new(application_code: '9z8y7w6x', app_key: '1a2b3c4d')
response = gateway.purchase(@amount, @credit_card, @options)
assert_failure response
- assert_equal 'BackendResponseException', response.message
+ assert_equal 'BackendResponseError', response.message
assert_equal Gateway::STANDARD_ERROR_CODE[:config_error], response.error_code
end
diff --git a/test/unit/gateways/paymentez_test.rb b/test/unit/gateways/paymentez_test.rb
index 331c283b417..3e6df5428e6 100644
--- a/test/unit/gateways/paymentez_test.rb
+++ b/test/unit/gateways/paymentez_test.rb
@@ -6,6 +6,14 @@ class PaymentezTest < Test::Unit::TestCase
def setup
@gateway = PaymentezGateway.new(application_code: 'foo', app_key: 'bar')
@credit_card = credit_card
+ @elo_credit_card = credit_card('6362970000457013',
+ :month => 10,
+ :year => 2020,
+ :first_name => 'John',
+ :last_name => 'Smith',
+ :verification_value => '737',
+ :brand => 'elo'
+ )
@amount = 100
@options = {
@@ -27,6 +35,16 @@ def test_successful_purchase
assert response.test?
end
+ def test_successful_purchase_with_elo
+ @gateway.expects(:ssl_post).returns(successful_purchase_with_elo_response)
+
+ response = @gateway.purchase(@amount, @elo_credit_card, @options)
+ assert_success response
+
+ assert_equal 'CI-14952', response.authorization
+ assert response.test?
+ end
+
def test_successful_purchase_with_token
@gateway.expects(:ssl_post).returns(successful_purchase_response)
@@ -63,6 +81,15 @@ def test_successful_authorize
assert response.test?
end
+ def test_successful_authorize_with_elo
+ @gateway.stubs(:ssl_post).returns(successful_authorize_with_elo_response)
+
+ response = @gateway.authorize(@amount, @elo_credit_card, @options)
+ assert_success response
+ assert_equal 'CI-14953', response.authorization
+ assert response.test?
+ end
+
def test_successful_authorize_with_token
@gateway.stubs(:ssl_post).returns(successful_authorize_response)
@@ -89,6 +116,15 @@ def test_successful_capture
assert response.test?
end
+ def test_successful_capture_with_elo
+ @gateway.expects(:ssl_post).returns(successful_capture_with_elo_response)
+
+ response = @gateway.capture(nil, '1234', @options)
+ assert_success response
+ assert_equal 'CI-14953', response.authorization
+ assert response.test?
+ end
+
def test_successful_capture_with_amount
@gateway.expects(:ssl_post).returns(successful_capture_response)
@@ -155,6 +191,14 @@ def test_simple_store
assert_equal '14436664108567261211', response.authorization
end
+ def test_simple_store_with_elo
+ @gateway.expects(:ssl_post).returns(successful_store_with_elo_response)
+
+ response = @gateway.store(@elo_credit_card, @options)
+ assert_success response
+ assert_equal '15550938907932827845', response.authorization
+ end
+
def test_complex_store
@gateway.stubs(:ssl_post).returns(already_stored_response, successful_unstore_response, successful_store_response)
@@ -252,6 +296,34 @@ def successful_purchase_response
'
end
+ def successful_purchase_with_elo_response
+ '
+ {
+ "transaction": {
+ "status": "success",
+ "payment_date": "2019-03-06T16:47:13.430",
+ "amount": 1,
+ "authorization_code": "TEST00",
+ "installments": 1,
+ "dev_reference": "Testing",
+ "message": "Response by mock",
+ "carrier_code": null,
+ "id": "CI-14952",
+ "status_detail": 3
+ },
+ "card": {
+ "bin": "636297",
+ "expiry_year": "2020",
+ "expiry_month": "10",
+ "transaction_reference": "CI-14952",
+ "type": "el",
+ "number": "7013",
+ "origin": "Paymentez"
+ }
+ }
+ '
+ end
+
def failed_purchase_response
'
{
@@ -308,6 +380,36 @@ def successful_authorize_response
'
end
+ def successful_authorize_with_elo_response
+ '
+ {
+ "transaction": {
+ "status": "success",
+ "payment_date": "2019-03-06T16:53:36.336",
+ "amount": 1,
+ "authorization_code": "TEST00",
+ "installments": 1,
+ "dev_reference": "Testing",
+ "message": "Response by mock",
+ "carrier_code": null,
+ "id": "CI-14953",
+ "status_detail": 0
+ },
+ "card": {
+ "bin": "636297",
+ "status": "",
+ "token": "",
+ "expiry_year": "2020",
+ "expiry_month": "10",
+ "transaction_reference": "CI-14953",
+ "type": "el",
+ "number": "7013",
+ "origin": "Paymentez"
+ }
+ }
+ '
+ end
+
def failed_authorize_response
'
{
@@ -367,6 +469,36 @@ def successful_capture_response
'
end
+ def successful_capture_with_elo_response
+ '
+ {
+ "transaction": {
+ "status": "success",
+ "payment_date": "2019-03-06T16:53:36",
+ "amount": 1,
+ "authorization_code": "TEST00",
+ "installments": 1,
+ "dev_reference": "Testing",
+ "message": "Response by mock",
+ "carrier_code": null,
+ "id": "CI-14953",
+ "status_detail": 3
+ },
+ "card": {
+ "bin": "636297",
+ "status": "",
+ "token": "",
+ "expiry_year": "2020",
+ "expiry_month": "10",
+ "transaction_reference": "CI-14953",
+ "type": "el",
+ "number": "7013",
+ "origin": "Paymentez"
+ }
+ }
+ '
+ end
+
def failed_capture_response
'{"error": {"type": "Carrier not supported", "help": "", "description": "{}"}}'
end
@@ -394,6 +526,10 @@ def successful_store_response
'{"card": {"bin": "411111", "status": "valid", "token": "14436664108567261211", "message": "", "expiry_year": "2018", "expiry_month": "9", "transaction_reference": "PR-959", "type": "vi", "number": "1111"}}'
end
+ def successful_store_with_elo_response
+ '{"card": {"bin": "636297", "status": "valid", "token": "15550938907932827845", "message": "", "expiry_year": "2020", "expiry_month": "10", "transaction_reference": "CI-14956", "type": "el", "number": "7013", "origin": "Paymentez"}}'
+ end
+
def failed_store_response
'
{
From c3c26d0453c9850d99275de794cb09f7c18b8105 Mon Sep 17 00:00:00 2001
From: DeeDee Lavinder
Date: Wed, 6 Mar 2019 17:00:25 -0500
Subject: [PATCH 0298/2234] WorldPay: Adds Elo
This adds `elo` to `supported_cardtypes`.
Unit Tests:
44 tests, 242 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
Remote Tests:
33 tests, 138 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/worldpay.rb | 3 +-
test/remote/gateways/remote_worldpay_test.rb | 27 +++++
test/unit/gateways/worldpay_test.rb | 111 ++++++++++++++++++
4 files changed, 141 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 60c3a3858e2..da5b4f8f751 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -10,6 +10,7 @@
* Litle: Add support for stored credentials [bayprogrammer] #3155
* Adyen: Correctly process risk_data option [bayprogrammer] #3161
* Paymentez: Adds Elo card type [deedeelavinder] #3162
+* WorldPay: Adds Elo card type [deedeelavinder] #3163
== Version 1.91.0 (February 22, 2019)
* WorldPay: Pull CVC and AVS Result from Response [nfarve] #3106
diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb
index ddf902f2bf8..8dda0632953 100644
--- a/lib/active_merchant/billing/gateways/worldpay.rb
+++ b/lib/active_merchant/billing/gateways/worldpay.rb
@@ -7,7 +7,7 @@ class WorldpayGateway < Gateway
self.default_currency = 'GBP'
self.money_format = :cents
self.supported_countries = %w(HK GB AU AD AR BE BR CA CH CN CO CR CY CZ DE DK ES FI FR GI GR HU IE IN IT JP LI LU MC MT MY MX NL NO NZ PA PE PL PT SE SG SI SM TR UM VA)
- self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :maestro]
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :maestro, :elo]
self.currencies_without_fractions = %w(HUF IDR ISK JPY KRW)
self.currencies_with_three_decimal_places = %w(BHD KWD OMR RSD TND)
self.homepage_url = 'http://www.worldpay.com/'
@@ -21,6 +21,7 @@ class WorldpayGateway < Gateway
'jcb' => 'JCB-SSL',
'maestro' => 'MAESTRO-SSL',
'diners_club' => 'DINERS-SSL',
+ 'elo' => 'ELO-SSL'
}
AVS_CODE_MAP = {
diff --git a/test/remote/gateways/remote_worldpay_test.rb b/test/remote/gateways/remote_worldpay_test.rb
index baa7345bacc..0a134e6456b 100644
--- a/test/remote/gateways/remote_worldpay_test.rb
+++ b/test/remote/gateways/remote_worldpay_test.rb
@@ -8,6 +8,14 @@ def setup
@amount = 100
@credit_card = credit_card('4111111111111111')
+ @elo_credit_card = credit_card('4514 1600 0000 0008',
+ :month => 10,
+ :year => 2020,
+ :first_name => 'John',
+ :last_name => 'Smith',
+ :verification_value => '737',
+ :brand => 'elo'
+ )
@declined_card = credit_card('4111111111111111', :first_name => nil, :last_name => 'REFUSED')
@threeDS_card = credit_card('4111111111111111', :first_name => nil, :last_name => '3D')
@@ -23,6 +31,12 @@ def test_successful_purchase
assert_equal 'SUCCESS', response.message
end
+ def test_successful_purchase_with_elo
+ assert response = @gateway.purchase(@amount, @elo_credit_card, @options.merge(currency: 'BRL'))
+ assert_success response
+ assert_equal 'SUCCESS', response.message
+ end
+
def test_successful_authorize_avs_and_cvv
card = credit_card('4111111111111111', :verification_value => 555)
assert response = @gateway.authorize(@amount, card, @options.merge(billing_address: address.update(zip: 'CCCC')))
@@ -250,6 +264,13 @@ def test_void
assert void.params['cancel_received_order_code']
end
+ def test_void_with_elo
+ assert_success response = @gateway.authorize(@amount, @elo_credit_card, @options.merge(currency: 'BRL'))
+ assert_success void = @gateway.void(response.authorization, authorization_validated: true)
+ assert_equal 'SUCCESS', void.message
+ assert void.params['cancel_received_order_code']
+ end
+
def test_void_nonexistent_transaction
assert_failure response = @gateway.void('non_existent_authorization')
assert_equal 'Could not find payment for order', response.message
@@ -308,6 +329,12 @@ def test_successful_verify
assert_match %r{SUCCESS}, response.message
end
+ def test_successful_verify_with_elo
+ response = @gateway.verify(@elo_credit_card, @options.merge(currency: 'BRL'))
+ assert_success response
+ assert_match %r{SUCCESS}, response.message
+ end
+
def test_failed_verify
response = @gateway.verify(@declined_card, @options)
assert_failure response
diff --git a/test/unit/gateways/worldpay_test.rb b/test/unit/gateways/worldpay_test.rb
index 36e2ba8783d..dd63e4e11cf 100644
--- a/test/unit/gateways/worldpay_test.rb
+++ b/test/unit/gateways/worldpay_test.rb
@@ -11,6 +11,14 @@ def setup
@amount = 100
@credit_card = credit_card('4242424242424242')
+ @elo_credit_card = credit_card('4514 1600 0000 0008',
+ :month => 10,
+ :year => 2020,
+ :first_name => 'John',
+ :last_name => 'Smith',
+ :verification_value => '737',
+ :brand => 'elo'
+ )
@options = {:order_id => 1}
end
@@ -83,6 +91,13 @@ def test_successful_purchase
assert_success response
end
+ def test_successful_purchase_with_elo
+ response = stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options.merge(currency: 'BRL'))
+ end.respond_with(successful_authorize_with_elo_response, successful_capture_with_elo_response)
+ assert_success response
+ end
+
def test_purchase_passes_correct_currency
response = stub_comms do
@gateway.purchase(@amount, @credit_card, @options.merge(currency: 'CAD'))
@@ -124,6 +139,15 @@ def test_successful_void
assert_equal '924e810350efc21a989e0ac7727ce43b', response.params['cancel_received_order_code']
end
+ def test_successful_void_with_elo
+ response = stub_comms do
+ @gateway.void(@options[:order_id], @options)
+ end.respond_with(successful_void_inquiry_with_elo_response, successful_void_with_elo_response)
+ assert_success response
+ assert_equal 'SUCCESS', response.message
+ assert_equal '3a10f83fb9bb765488d0b3eb153879d7', response.params['cancel_received_order_code']
+ end
+
def test_void_fails_unless_status_is_authorized
response = stub_comms do
@gateway.void(@options[:order_id], @options)
@@ -492,6 +516,13 @@ def test_successful_verify
assert_success response
end
+ def test_successful_verify_with_elo
+ @gateway.expects(:ssl_post).times(2).returns(successful_authorize_with_elo_response, successful_void_with_elo_response)
+
+ response = @gateway.verify(@elo_credit_card, @options.merge(currency: 'BRL'))
+ assert_success response
+ end
+
def test_successful_verify_with_failed_void
@gateway.expects(:ssl_post).times(2).returns(successful_authorize_response, failed_void_response)
@@ -584,6 +615,86 @@ def successful_capture_response
RESPONSE
end
+ def successful_authorize_with_elo_response
+ <<-RESPONSE
+
+
+
+
+
+
+ ELO-SSL
+
+ AUTHORISED
+
+
+
+
+
+ 4514********0008
+
+
+
+
+
+ RESPONSE
+ end
+
+ def successful_capture_with_elo_response
+ <<-RESPONSE
+
+
+
+
+
+
+
+
+
+
+
+ RESPONSE
+ end
+
+ def successful_void_inquiry_with_elo_response
+ <<-RESPONSE
+
+
+
+
+
+
+ ELO-SSL
+
+ AUTHORISED
+
+
+
+
+
+ 4514********0008
+
+
+
+
+
+ RESPONSE
+ end
+
+ def successful_void_with_elo_response
+ <<-RESPONSE
+
+
+
+
+
+
+
+
+
+ RESPONSE
+ end
+
def successful_inquiry_response
<<-RESPONSE
From 3f3b5b213009a76fc95088592f679052b6368f03 Mon Sep 17 00:00:00 2001
From: molbrown
Date: Fri, 1 Mar 2019 11:19:34 -0500
Subject: [PATCH 0299/2234] Adyen: Idempotency for non-purchase requests
Support of Idempotency-Key for all actions except purchase, due to
multi-key requirement (design still pending).
ECS-166
Unit:
31 tests, 149 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
49 tests, 142 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Closes #3164
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/adyen.rb | 22 ++++++++-------
test/remote/gateways/remote_adyen_test.rb | 27 +++++++++++++++++++
test/unit/gateways/adyen_test.rb | 20 ++++++++++++++
4 files changed, 61 insertions(+), 9 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index da5b4f8f751..67a5e26ec02 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -11,6 +11,7 @@
* Adyen: Correctly process risk_data option [bayprogrammer] #3161
* Paymentez: Adds Elo card type [deedeelavinder] #3162
* WorldPay: Adds Elo card type [deedeelavinder] #3163
+* Adyen: Idempotency for non-purchase requests [molbrown] #3164
== Version 1.91.0 (February 22, 2019)
* WorldPay: Pull CVC and AVS Result from Response [nfarve] #3106
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index 94634aa86f5..70c5b7e920b 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -33,6 +33,7 @@ def initialize(options={})
end
def purchase(money, payment, options={})
+ options[:idempotency_key] = nil
if options[:execute_threed] || options[:threed_dynamic]
authorize(money, payment, options)
else
@@ -53,27 +54,27 @@ def authorize(money, payment, options={})
add_address(post, options)
add_installments(post, options) if options[:installments]
add_3ds(post, options)
- commit('authorise', post)
+ commit('authorise', post, options)
end
def capture(money, authorization, options={})
post = init_post(options)
add_invoice_for_modification(post, money, options)
add_reference(post, authorization, options)
- commit('capture', post)
+ commit('capture', post, options)
end
def refund(money, authorization, options={})
post = init_post(options)
add_invoice_for_modification(post, money, options)
add_original_reference(post, authorization, options)
- commit('refund', post)
+ commit('refund', post, options)
end
def void(authorization, options={})
post = init_post(options)
add_reference(post, authorization, options)
- commit('cancel', post)
+ commit('cancel', post, options)
end
def store(credit_card, options={})
@@ -84,12 +85,13 @@ def store(credit_card, options={})
add_extra_data(post, credit_card, options)
add_recurring_contract(post, options)
add_address(post, options)
- commit('authorise', post)
+ commit('authorise', post, options)
end
def verify(credit_card, options={})
MultiResponse.run(:use_first_response) do |r|
r.process { authorize(0, credit_card, options) }
+ options[:idempotency_key] = nil
r.process(:ignore_result) { void(r.authorization, options) }
end
end
@@ -286,9 +288,9 @@ def parse(body)
JSON.parse(body)
end
- def commit(action, parameters)
+ def commit(action, parameters, options)
begin
- raw_response = ssl_post("#{url}/#{action}", post_data(action, parameters), request_headers)
+ raw_response = ssl_post("#{url}/#{action}", post_data(action, parameters), request_headers(options))
response = parse(raw_response)
rescue ResponseError => e
raw_response = e.response.body
@@ -329,11 +331,13 @@ def basic_auth
Base64.strict_encode64("#{@username}:#{@password}")
end
- def request_headers
- {
+ def request_headers(options)
+ headers = {
'Content-Type' => 'application/json',
'Authorization' => "Basic #{basic_auth}"
}
+ headers['Idempotency-Key'] = options[:idempotency_key] if options[:idempotency_key]
+ headers
end
def success_from(action, response)
diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb
index 9c964702ae7..f84f13add55 100644
--- a/test/remote/gateways/remote_adyen_test.rb
+++ b/test/remote/gateways/remote_adyen_test.rb
@@ -71,6 +71,18 @@ def test_successful_authorize
assert_equal 'Authorised', response.message
end
+ def test_successful_authorize_with_idempotency_key
+ options = @options.merge(idempotency_key: 'test123')
+ response = @gateway.authorize(@amount, @credit_card, options)
+ assert_success response
+ assert_equal 'Authorised', response.message
+ first_auth = response.authorization
+
+ response = @gateway.authorize(@amount, @credit_card, options)
+ assert_success response
+ assert_equal response.authorization, first_auth
+ end
+
def test_successful_authorize_with_3ds
assert response = @gateway.authorize(@amount, @three_ds_enrolled_card, @options.merge(execute_threed: true))
assert response.test?
@@ -329,6 +341,21 @@ def test_failed_verify
assert_match 'Refused', response.message
end
+ def test_verify_with_idempotency_key
+ options = @options.merge(idempotency_key: 'test123')
+ response = @gateway.authorize(0, @credit_card, options)
+ assert_success response
+ assert_equal 'Authorised', response.message
+ first_auth = response.authorization
+
+ response = @gateway.verify(@credit_card, options)
+ assert_success response
+ assert_equal response.authorization, first_auth
+
+ response = @gateway.void(first_auth, @options)
+ assert_success response
+ end
+
def test_invalid_login
gateway = AdyenGateway.new(username: '', password: '', merchant_account: '')
diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb
index 5b68f781121..15a3eeec1a4 100644
--- a/test/unit/gateways/adyen_test.rb
+++ b/test/unit/gateways/adyen_test.rb
@@ -336,6 +336,26 @@ def test_extended_avs_response
assert_equal 'Card member\'s name, billing address, and billing postal code match.', response.avs_result['message']
end
+ def test_optional_idempotency_key_header
+ options = @options.merge(:idempotency_key => 'test123')
+ response = stub_comms do
+ @gateway.authorize(@amount, @credit_card, options)
+ end.check_request do |endpoint, data, headers|
+ assert headers['Idempotency-Key']
+ end.respond_with(successful_authorize_response)
+ assert_success response
+ end
+
+ def test_optional_idempotency_key_header_excluded_on_purchase
+ options = @options.merge(:idempotency_key => 'test123')
+ response = stub_comms do
+ @gateway.purchase(@amount, @credit_card, options)
+ end.check_request do |endpoint, data, headers|
+ refute headers['Idempotency-Key']
+ end.respond_with(successful_authorize_response, successful_capture_response)
+ assert_success response
+ end
+
private
def pre_scrubbed
From e34621f18b41815d50037031e48bf8e7b7a4afde Mon Sep 17 00:00:00 2001
From: David Perry
Date: Tue, 5 Mar 2019 12:06:27 -0500
Subject: [PATCH 0300/2234] FirstData e4 v27: Support v28 url and stored creds
Involves updating response parsing to handle nested elements.
Closes #3165
Remote:
26 tests, 110 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
31 tests, 146 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/firstdata_e4_v27.rb | 45 ++++++-
.../gateways/remote_firstdata_e4_v27_test.rb | 49 +++++++
test/unit/gateways/firstdata_e4_v27_test.rb | 120 ++++++++++++++++++
4 files changed, 212 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 67a5e26ec02..5bd7b2219fb 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -12,6 +12,7 @@
* Paymentez: Adds Elo card type [deedeelavinder] #3162
* WorldPay: Adds Elo card type [deedeelavinder] #3163
* Adyen: Idempotency for non-purchase requests [molbrown] #3164
+* FirstData e4 v27: Support v28 url and stored creds [curiousepic] #3165
== Version 1.91.0 (February 22, 2019)
* WorldPay: Pull CVC and AVS Result from Response [nfarve] #3106
diff --git a/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb b/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb
index 31c16f7d1e5..4124139a7ca 100644
--- a/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb
+++ b/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb
@@ -1,8 +1,8 @@
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
class FirstdataE4V27Gateway < Gateway
- self.test_url = 'https://api.demo.globalgatewaye4.firstdata.com/transaction/v27'
- self.live_url = 'https://api.globalgatewaye4.firstdata.com/transaction/v27'
+ self.test_url = 'https://api.demo.globalgatewaye4.firstdata.com/transaction/v28'
+ self.live_url = 'https://api.globalgatewaye4.firstdata.com/transaction/v28'
TRANSACTIONS = {
sale: '00',
@@ -148,6 +148,7 @@ def build_sale_or_authorization_request(money, credit_card_or_store_authorizatio
add_credit_card_token(xml, credit_card_or_store_authorization, options)
else
add_credit_card(xml, credit_card_or_store_authorization, options)
+ add_stored_credentials(xml, credit_card_or_store_authorization, options)
end
add_address(xml, options)
@@ -312,6 +313,35 @@ def add_level_3(xml, options)
xml.tag!('Level3') { |x| x << options[:level_3] } if options[:level_3]
end
+ def add_stored_credentials(xml, card, options)
+ return unless options[:stored_credential]
+ xml.tag! 'StoredCredentials' do
+ xml.tag! 'Indicator', stored_credential_indicator(xml, card, options)
+ if initiator = options.dig(:stored_credential, :initiator)
+ xml.tag! initiator == 'merchant' ? 'M' : 'C'
+ end
+ if reason_type = options.dig(:stored_credential, :reason_type)
+ xml.tag! 'Schedule', reason_type == 'unscheduled' ? 'U' : 'S'
+ end
+ xml.tag! 'AuthorizationTypeOverride', options[:authorization_type_override] if options[:authorization_type_override]
+ if network_transaction_id = options[:stored_credential][:network_transaction_id]
+ xml.tag! 'TransactionId', network_transaction_id
+ else
+ xml.tag! 'TransactionId', 'new'
+ end
+ xml.tag! 'OriginalAmount', options[:original_amount] if options[:original_amount]
+ xml.tag! 'ProtectbuyIndicator', options[:protectbuy_indicator] if options[:protectbuy_indicator]
+ end
+ end
+
+ def stored_credential_indicator(xml, card, options)
+ if card.brand == 'master' || options.dig(:stored_credential, :initial_transaction) == false
+ 'S'
+ else
+ '1'
+ end
+ end
+
def expdate(credit_card)
"#{format(credit_card.month, :two_digits)}#{format(credit_card.year, :two_digits)}"
end
@@ -438,9 +468,18 @@ def parse(xml)
def parse_elements(response, root)
root.elements.to_a.each do |node|
- response[node.name.gsub(/EXact/, 'Exact').underscore.to_sym] = (node.text || '').strip
+ if node.has_elements?
+ parse_elements(response, node)
+ else
+ response[name_node(root, node)] = (node.text || '').strip
+ end
end
end
+
+ def name_node(root, node)
+ parent = root.name unless root.name == 'TransactionResult'
+ "#{parent}#{node.name}".gsub(/EXact/, 'Exact').underscore.to_sym
+ end
end
end
end
diff --git a/test/remote/gateways/remote_firstdata_e4_v27_test.rb b/test/remote/gateways/remote_firstdata_e4_v27_test.rb
index 4233159fc39..0bf4fc8c79c 100644
--- a/test/remote/gateways/remote_firstdata_e4_v27_test.rb
+++ b/test/remote/gateways/remote_firstdata_e4_v27_test.rb
@@ -4,6 +4,7 @@ class RemoteFirstdataE4V27Test < Test::Unit::TestCase
def setup
@gateway = FirstdataE4V27Gateway.new(fixtures(:firstdata_e4_v27))
@credit_card = credit_card
+ @credit_card_master = credit_card('5500000000000004', :brand => 'master')
@bad_credit_card = credit_card('4111111111111113')
@credit_card_with_track_data = credit_card_with_track_data('4003000123456781')
@amount = 100
@@ -78,6 +79,54 @@ def test_successful_purchase_with_card_authentication
assert_success response
end
+ def test_successful_purchase_with_stored_credentials_initial
+ stored_credential = {
+ stored_credential: {
+ initial_transaction: true,
+ reason_type: 'unscheduled',
+ initiator: 'customer'
+ }
+ }
+ assert response = @gateway.purchase(@amount, @credit_card, @options.merge(stored_credential))
+ assert_match(/Transaction Normal/, response.message)
+ assert_success response
+ assert_equal '1', response.params['stored_credentials_indicator']
+ assert_equal 'U', response.params['stored_credentials_schedule']
+ assert_not_nil response.params['stored_credentials_transaction_id']
+ end
+
+ def test_successful_purchase_with_stored_credentials_initial_master
+ stored_credential = {
+ stored_credential: {
+ initial_transaction: true,
+ reason_type: 'unscheduled',
+ initiator: 'customer'
+ }
+ }
+ assert response = @gateway.purchase(@amount, @credit_card_master, @options.merge(stored_credential))
+ assert_match(/Transaction Normal/, response.message)
+ assert_success response
+ assert_equal 'S', response.params['stored_credentials_indicator']
+ assert_equal 'U', response.params['stored_credentials_schedule']
+ assert_not_nil response.params['stored_credentials_transaction_id']
+ end
+
+ def test_successful_purchase_with_stored_credentials_subsequent_recurring
+ stored_credential = {
+ stored_credential: {
+ initial_transaction: false,
+ reason_type: 'recurring',
+ initiator: 'merchant'
+ }
+ }
+ assert response = @gateway.purchase(@amount, @credit_card, @options.merge(stored_credential))
+ assert_match(/Transaction Normal/, response.message)
+ assert_success response
+ assert_equal 'S', response.params['stored_credentials_indicator']
+ assert_equal 'S', response.params['stored_credentials_schedule']
+ assert_not_nil response.params['stored_credentials_transaction_id']
+ end
+
def test_unsuccessful_purchase
# ask for error 13 response (Amount Error) via dollar amount 5,000 + error
@amount = 501300
diff --git a/test/unit/gateways/firstdata_e4_v27_test.rb b/test/unit/gateways/firstdata_e4_v27_test.rb
index 77c51017ffe..8e4b4371c8a 100644
--- a/test/unit/gateways/firstdata_e4_v27_test.rb
+++ b/test/unit/gateways/firstdata_e4_v27_test.rb
@@ -59,6 +59,26 @@ def test_successful_purchase_with_wallet
assert_success response
end
+ def test_successful_purchase_with_stored_credentials
+ stored_credential = {
+ stored_credential: {
+ initial_transaction: true,
+ reason_type: 'unscheduled',
+ initiator: 'customer'
+ }
+ }
+ response = stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options.merge(stored_credential))
+ end.check_request do |endpoint, data, headers|
+ assert_match(/Indicator>1, data)
+ assert_match(/Schedule>U, data)
+ assert_match(/TransactionId>new, data)
+ end.respond_with(successful_purchase_response_with_stored_credentials)
+
+ assert_success response
+ assert_equal '732602247202501', response.params['stored_credentials_transaction_id']
+ end
+
def test_successful_void
@gateway.expects(:ssl_post).returns(successful_void_response)
assert response = @gateway.void(@authorization, @options)
@@ -483,6 +503,106 @@ def successful_purchase_response
RESPONSE
end
+ def successful_purchase_response_with_stored_credentials
+ <<-RESPONSE
+
+
+ AD1234-56
+
+ 00
+ 47.38
+
+ ############1111
+ 106625152
+
+
+
+ ET1700
+ 0913
+ Fred Burfle
+ 0
+
+
+
+
+
+
+
+
+
+
+
+ 77
+
+
+
+ 1.1.1.10
+
+ false
+ true
+ 00
+ Transaction Normal
+ 100
+ Approved
+
+ 000040
+ U
+ M
+ 3146117
+
+ USD
+
+ false
+ Friendly Inc DEMO0983
+ 123 King St
+ Toronto
+ Ontario
+ Canada
+ L7Z 3K8
+
+ 8938737759041111
+ =========== TRANSACTION RECORD ==========
+Friendly Inc DEMO0983
+123 King St
+Toronto, ON L7Z 3K8
+Canada
+
+
+TYPE: Purchase
+
+ACCT: Visa $ 47.38 USD
+
+CARD NUMBER : ############1111
+DATE/TIME : 28 Sep 12 07:54:48
+REFERENCE # : 000040 M
+AUTHOR. # : ET120454
+TRANS. REF. : 77
+
+ Approved - Thank You 100
+
+
+Please retain this copy for your records.
+
+Cardholder will pay above amount to card
+issuer pursuant to cardholder agreement.
+=========================================
+
+ 456 My Street
+ Apt 1
+ Ottawa
+ ON
+ K1C2N6
+ CA
+
+
+ 1
+ U
+ 732602247202501
+
+
+ RESPONSE
+ end
+
def successful_purchase_response_without_transarmor
<<-RESPONSE
From e00c4115f67880bd7f40829a4dffbf70bb7ff926 Mon Sep 17 00:00:00 2001
From: Zeb DeOs
Date: Tue, 12 Mar 2019 15:33:38 -0400
Subject: [PATCH 0301/2234] WorldPay: Fix element order for 3DS + stored cred
WorldPay's XML DTD requires that the `session` comes after
`storedCredentials`. When using stored credential options with a 3DS
request we were ending up with the elements being generated in the wrong
order. This fixes the issue and ensures `storedCredentials` precede
`session` when both are to be included in the request document.
ECS-219
Unit:
44 tests, 242 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote
35 tests, 154 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Closes #3172
---
CHANGELOG | 1 +
.../billing/gateways/worldpay.rb | 2 +-
test/remote/gateways/remote_worldpay_test.rb | 52 ++++++++++++++++++-
3 files changed, 53 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 5bd7b2219fb..240ecc1bf47 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -13,6 +13,7 @@
* WorldPay: Adds Elo card type [deedeelavinder] #3163
* Adyen: Idempotency for non-purchase requests [molbrown] #3164
* FirstData e4 v27: Support v28 url and stored creds [curiousepic] #3165
+* WorldPay: Fix element order for 3DS + stored cred [bayprogrammer] #3172
== Version 1.91.0 (February 22, 2019)
* WorldPay: Pull CVC and AVS Result from Response [nfarve] #3106
diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb
index 8dda0632953..85acadd565e 100644
--- a/lib/active_merchant/billing/gateways/worldpay.rb
+++ b/lib/active_merchant/billing/gateways/worldpay.rb
@@ -263,13 +263,13 @@ def add_payment_method(xml, amount, payment_method, options)
add_address(xml, (options[:billing_address] || options[:address]))
end
+ add_stored_credential_options(xml, options)
if options[:ip] && options[:session_id]
xml.tag! 'session', 'shopperIPAddress' => options[:ip], 'id' => options[:session_id]
else
xml.tag! 'session', 'shopperIPAddress' => options[:ip] if options[:ip]
xml.tag! 'session', 'id' => options[:session_id] if options[:session_id]
end
- add_stored_credential_options(xml, options)
end
end
end
diff --git a/test/remote/gateways/remote_worldpay_test.rb b/test/remote/gateways/remote_worldpay_test.rb
index 0a134e6456b..bad6a7dec22 100644
--- a/test/remote/gateways/remote_worldpay_test.rb
+++ b/test/remote/gateways/remote_worldpay_test.rb
@@ -172,7 +172,7 @@ def test_successful_auth_and_capture_with_normalized_stored_credential
assert_success capture
end
- def test_successful_auth_and_capture_with_stored_cred_options
+ def test_successful_auth_and_capture_with_gateway_specific_stored_credentials
assert auth = @gateway.authorize(@amount, @credit_card, @options.merge(stored_credential_usage: 'FIRST'))
assert_success auth
assert auth.authorization
@@ -197,6 +197,56 @@ def test_successful_auth_and_capture_with_stored_cred_options
assert_success capture
end
+ def test_successful_authorize_with_3ds_with_normalized_stored_credentials
+ session_id = generate_unique_id
+ stored_credential_params = {
+ initial_transaction: true,
+ reason_type: 'unscheduled',
+ initiator: 'merchant',
+ network_transaction_id: nil
+ }
+ options = @options.merge(
+ {
+ execute_threed: true,
+ accept_header: 'text/html',
+ user_agent: 'Mozilla/5.0',
+ session_id: session_id,
+ ip: '127.0.0.1',
+ cookie: 'machine=32423423',
+ stored_credential: stored_credential_params
+ })
+ assert first_message = @gateway.authorize(@amount, @threeDS_card, options)
+ assert_equal "A transaction status of 'AUTHORISED' is required.", first_message.message
+ assert first_message.test?
+ refute first_message.authorization.blank?
+ refute first_message.params['issuer_url'].blank?
+ refute first_message.params['pa_request'].blank?
+ refute first_message.params['cookie'].blank?
+ refute first_message.params['session_id'].blank?
+ end
+
+ def test_successful_authorize_with_3ds_with_gateway_specific_stored_credentials
+ session_id = generate_unique_id
+ options = @options.merge(
+ {
+ execute_threed: true,
+ accept_header: 'text/html',
+ user_agent: 'Mozilla/5.0',
+ session_id: session_id,
+ ip: '127.0.0.1',
+ cookie: 'machine=32423423',
+ stored_credential_usage: 'FIRST'
+ })
+ assert first_message = @gateway.authorize(@amount, @threeDS_card, options)
+ assert_equal "A transaction status of 'AUTHORISED' is required.", first_message.message
+ assert first_message.test?
+ refute first_message.authorization.blank?
+ refute first_message.params['issuer_url'].blank?
+ refute first_message.params['pa_request'].blank?
+ refute first_message.params['cookie'].blank?
+ refute first_message.params['session_id'].blank?
+ end
+
# Fails currently because the sandbox doesn't actually validate the stored_credential options
# def test_failed_authorize_with_bad_stored_cred_options
# assert auth = @gateway.authorize(@amount, @credit_card, @options.merge(stored_credential_usage: 'FIRST'))
From 0629575fb906642bc30960f7896ed4591f872fbe Mon Sep 17 00:00:00 2001
From: Jared Knipp
Date: Tue, 12 Mar 2019 10:35:20 -0500
Subject: [PATCH 0302/2234] Braintree: Add risk data fields to response
Explicitly add the risk data fields to the active merchant response, if
they are provided.
ECS-210
Unit:
59 tests, 158 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
71 tests, 407 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
closes #3169
---
CHANGELOG | 1 +
.../billing/gateways/braintree_blue.rb | 12 ++++++++
.../gateways/remote_braintree_blue_test.rb | 28 +++++++++++++++++++
test/unit/gateways/braintree_blue_test.rb | 15 ++++++++++
4 files changed, 56 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index 240ecc1bf47..c23fe859017 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -14,6 +14,7 @@
* Adyen: Idempotency for non-purchase requests [molbrown] #3164
* FirstData e4 v27: Support v28 url and stored creds [curiousepic] #3165
* WorldPay: Fix element order for 3DS + stored cred [bayprogrammer] #3172
+* Braintree: Add risk data to returned response [jknipp] #3169
== Version 1.91.0 (February 22, 2019)
* WorldPay: Pull CVC and AVS Result from Response [nfarve] #3106
diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb
index 21d5741ae86..bff4f0b0e12 100644
--- a/lib/active_merchant/billing/gateways/braintree_blue.rb
+++ b/lib/active_merchant/billing/gateways/braintree_blue.rb
@@ -543,6 +543,17 @@ def transaction_hash(result)
'token' => transaction.credit_card_details.token
}
+ if transaction.risk_data
+ risk_data = {
+ 'id' => transaction.risk_data.id,
+ 'decision' => transaction.risk_data.decision,
+ 'device_data_captured' => transaction.risk_data.device_data_captured,
+ 'fraud_service_provider' => transaction.risk_data.fraud_service_provider
+ }
+ else
+ risk_data = nil
+ end
+
{
'order_id' => transaction.order_id,
'amount' => transaction.amount.to_s,
@@ -553,6 +564,7 @@ def transaction_hash(result)
'shipping_details' => shipping_details,
'vault_customer' => vault_customer,
'merchant_account_id' => transaction.merchant_account_id,
+ 'risk_data' => risk_data,
'processor_response_code' => response_code_from_result(result)
}
end
diff --git a/test/remote/gateways/remote_braintree_blue_test.rb b/test/remote/gateways/remote_braintree_blue_test.rb
index c24abe26cb2..dc32dd9611e 100644
--- a/test/remote/gateways/remote_braintree_blue_test.rb
+++ b/test/remote/gateways/remote_braintree_blue_test.rb
@@ -179,6 +179,20 @@ def test_failed_verify
assert_match %r{number is not an accepted test number}, response.message
end
+ def test_successful_verify_with_device_data
+ # Requires Advanced Fraud Tools to be enabled
+ assert response = @gateway.verify(@credit_card, @options.merge({device_data: 'device data for verify'}))
+ assert_success response
+ assert_equal '1000 Approved', response.message
+
+ assert transaction = response.params['braintree_transaction']
+ assert transaction['risk_data']
+ assert transaction['risk_data']['id']
+ assert_equal 'Approve', transaction['risk_data']['decision']
+ assert_equal false, transaction['risk_data']['device_data_captured']
+ assert_equal 'kount', transaction['risk_data']['fraud_service_provider']
+ end
+
def test_successful_validate_on_store
card = credit_card('4111111111111111', :verification_value => '101')
assert response = @gateway.store(card, :verify_card => true)
@@ -403,6 +417,20 @@ def test_successful_purchase_with_skip_advanced_fraud_checking_option
assert_equal 'submitted_for_settlement', response.params['braintree_transaction']['status']
end
+ def test_successful_purchase_with_device_data
+ # Requires Advanced Fraud Tools to be enabled
+ assert response = @gateway.purchase(@amount, @credit_card, @options.merge(device_data: 'device data for purchase'))
+ assert_success response
+ assert_equal '1000 Approved', response.message
+
+ assert transaction = response.params['braintree_transaction']
+ assert transaction['risk_data']
+ assert transaction['risk_data']['id']
+ assert_equal 'Approve', transaction['risk_data']['decision']
+ assert_equal false, transaction['risk_data']['device_data_captured']
+ assert_equal 'kount', transaction['risk_data']['fraud_service_provider']
+ end
+
def test_purchase_with_store_using_random_customer_id
assert response = @gateway.purchase(
@amount, credit_card('5105105105105100'), @options.merge(:store => true)
diff --git a/test/unit/gateways/braintree_blue_test.rb b/test/unit/gateways/braintree_blue_test.rb
index b1397107579..ad3a1f1a848 100644
--- a/test/unit/gateways/braintree_blue_test.rb
+++ b/test/unit/gateways/braintree_blue_test.rb
@@ -754,6 +754,21 @@ def test_successful_purchase_with_descriptor
@gateway.purchase(100, credit_card('41111111111111111111'), descriptor_name: 'wow*productname', descriptor_phone: '4443331112', descriptor_url: 'wow.com')
end
+ def test_successful_purchase_with_device_data
+ Braintree::TransactionGateway.any_instance.expects(:sale).with do |params|
+ (params[:device_data] == 'device data string')
+ end.returns(braintree_result({risk_data: {id: 123456, decision: 'Decline', device_data_captured: true, fraud_service_provider: 'kount'}}))
+
+ response = @gateway.purchase(100, credit_card('41111111111111111111'), device_data: 'device data string')
+
+ assert transaction = response.params['braintree_transaction']
+ assert transaction['risk_data']
+ assert_equal 123456, transaction['risk_data']['id']
+ assert_equal 'Decline', transaction['risk_data']['decision']
+ assert_equal true, transaction['risk_data']['device_data_captured']
+ assert_equal 'kount', transaction['risk_data']['fraud_service_provider']
+ end
+
def test_apple_pay_card
Braintree::TransactionGateway.any_instance.expects(:sale).
with(
From 6da405c00a0a2ae1e0137cc1483da4354a42fe0d Mon Sep 17 00:00:00 2001
From: molbrown
Date: Fri, 8 Mar 2019 16:47:03 -0500
Subject: [PATCH 0303/2234] Adyen: Support idempotency on purchase
Adding capability to send Idempotency-Key on the MultiResponse purchase
action. Modifies a single key so it can be re-used for the capture
request. User can safely re-try `purchase` with the original key since
both requests are idempotent and the key is modified in a fixed way.
Unit:
30 tests, 144 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
50 tests, 146 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
ECS-198
Closes #3168
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/adyen.rb | 8 ++++++--
test/remote/gateways/remote_adyen_test.rb | 12 ++++++++++++
test/unit/gateways/adyen_test.rb | 10 ----------
4 files changed, 19 insertions(+), 12 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index c23fe859017..39669a5a50d 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -15,6 +15,7 @@
* FirstData e4 v27: Support v28 url and stored creds [curiousepic] #3165
* WorldPay: Fix element order for 3DS + stored cred [bayprogrammer] #3172
* Braintree: Add risk data to returned response [jknipp] #3169
+* Adyen: Support idempotency on purchase [molbrown] #3168
== Version 1.91.0 (February 22, 2019)
* WorldPay: Pull CVC and AVS Result from Response [nfarve] #3106
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index 70c5b7e920b..681c37f857e 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -33,13 +33,12 @@ def initialize(options={})
end
def purchase(money, payment, options={})
- options[:idempotency_key] = nil
if options[:execute_threed] || options[:threed_dynamic]
authorize(money, payment, options)
else
MultiResponse.run do |r|
r.process { authorize(money, payment, options) }
- r.process { capture(money, r.authorization, options) }
+ r.process { capture(money, r.authorization, capture_options(options)) }
end
end
end
@@ -241,6 +240,11 @@ def add_card(post, credit_card)
post[:card] = card
end
+ def capture_options(options)
+ return options.merge(idempotency_key: "#{options[:idempotency_key]}-cap") if options[:idempotency_key]
+ options
+ end
+
def add_reference(post, authorization, options = {})
_, psp_reference, _ = authorization.split('#')
post[:originalReference] = single_reference(authorization) || psp_reference
diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb
index f84f13add55..3a42c92c548 100644
--- a/test/remote/gateways/remote_adyen_test.rb
+++ b/test/remote/gateways/remote_adyen_test.rb
@@ -161,6 +161,18 @@ def test_successful_purchase_with_risk_data
assert_equal '[capture-received]', response.message
end
+ def test_successful_purchase_with_idempotency_key
+ options = @options.merge(idempotency_key: 'testkey45678')
+ response = @gateway.purchase(@amount, @credit_card, options)
+ assert_success response
+ assert_equal '[capture-received]', response.message
+ first_auth = response.authorization
+
+ response = @gateway.purchase(@amount, @credit_card, options)
+ assert_success response
+ assert_equal response.authorization, first_auth
+ end
+
def test_successful_purchase_with_apple_pay
response = @gateway.purchase(@amount, @apple_pay_card, @options)
assert_success response
diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb
index 15a3eeec1a4..3df8cff60f3 100644
--- a/test/unit/gateways/adyen_test.rb
+++ b/test/unit/gateways/adyen_test.rb
@@ -346,16 +346,6 @@ def test_optional_idempotency_key_header
assert_success response
end
- def test_optional_idempotency_key_header_excluded_on_purchase
- options = @options.merge(:idempotency_key => 'test123')
- response = stub_comms do
- @gateway.purchase(@amount, @credit_card, options)
- end.check_request do |endpoint, data, headers|
- refute headers['Idempotency-Key']
- end.respond_with(successful_authorize_response, successful_capture_response)
- assert_success response
- end
-
private
def pre_scrubbed
From ab0c84dd0bcecd1b5cf37e01af417f0ca52e5413 Mon Sep 17 00:00:00 2001
From: Dilan Nebioglu
Date: Wed, 20 Mar 2019 10:44:43 -0400
Subject: [PATCH 0304/2234] Add 3DS parameters to Worldpay (#3175)
Add parameters that we receive after doing 3DS with an external MPI.
---
.../billing/gateways/worldpay.rb | 10 +++++
test/remote/gateways/remote_worldpay_test.rb | 37 +++++++++++++++++++
test/unit/gateways/worldpay_test.rb | 35 ++++++++++++++++++
3 files changed, 82 insertions(+)
diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb
index 85acadd565e..ca4cf11a316 100644
--- a/lib/active_merchant/billing/gateways/worldpay.rb
+++ b/lib/active_merchant/billing/gateways/worldpay.rb
@@ -270,6 +270,16 @@ def add_payment_method(xml, amount, payment_method, options)
xml.tag! 'session', 'shopperIPAddress' => options[:ip] if options[:ip]
xml.tag! 'session', 'id' => options[:session_id] if options[:session_id]
end
+
+ if three_d_secure = options[:three_d_secure]
+ xml.tag! 'info3DSecure' do
+ xml.tag! 'threeDSVersion', three_d_secure[:version]
+ xid_tag = three_d_secure[:version] =~ /^2/ ? 'dsTransactionId' : 'xid'
+ xml.tag! xid_tag, three_d_secure[:xid]
+ xml.tag! 'cavv', three_d_secure[:cavv]
+ xml.tag! 'eci', three_d_secure[:eci]
+ end
+ end
end
end
end
diff --git a/test/remote/gateways/remote_worldpay_test.rb b/test/remote/gateways/remote_worldpay_test.rb
index bad6a7dec22..03f5c0c4fd4 100644
--- a/test/remote/gateways/remote_worldpay_test.rb
+++ b/test/remote/gateways/remote_worldpay_test.rb
@@ -18,6 +18,7 @@ def setup
)
@declined_card = credit_card('4111111111111111', :first_name => nil, :last_name => 'REFUSED')
@threeDS_card = credit_card('4111111111111111', :first_name => nil, :last_name => '3D')
+ @threeDS_card_external_MPI = credit_card('4444333322221111', :first_name => 'AA', :last_name => 'BD')
@options = {
order_id: generate_unique_id,
@@ -285,6 +286,42 @@ def test_failed_authorize_with_3ds
assert first_message.params['pa_request'].blank?
end
+ def test_3ds_version_1_parameters_pass_thru
+ options = @options.merge(
+ {
+ three_d_secure: {
+ version: '1.0.2',
+ xid: '',
+ cavv: 'MAAAAAAAAAAAAAAAAAAAAAAAAAA=',
+ eci: '05'
+ }
+ }
+ )
+
+ assert response = @gateway.authorize(@amount, @threeDS_card_external_MPI, @options.merge(options))
+ assert response.test?
+ assert response.success?
+ assert response.params['last_event'] || response.params['ok']
+ end
+
+ def test_3ds_version_2_parameters_pass_thru
+ options = @options.merge(
+ {
+ three_d_secure: {
+ version: '2.1.0',
+ xid: 'A' * 40,
+ cavv: 'MAAAAAAAAAAAAAAAAAAAAAAAAAA=',
+ eci: '05'
+ }
+ }
+ )
+
+ assert response = @gateway.authorize(@amount, @threeDS_card_external_MPI, @options.merge(options))
+ assert response.test?
+ assert response.success?
+ assert response.params['last_event'] || response.params['ok']
+ end
+
def test_failed_capture
assert response = @gateway.capture(@amount, 'bogus')
assert_failure response
diff --git a/test/unit/gateways/worldpay_test.rb b/test/unit/gateways/worldpay_test.rb
index dd63e4e11cf..1810f8d22ae 100644
--- a/test/unit/gateways/worldpay_test.rb
+++ b/test/unit/gateways/worldpay_test.rb
@@ -553,8 +553,43 @@ def test_transcript_scrubbing
assert_equal scrubbed_transcript, @gateway.scrub(transcript)
end
+ def test_3ds_version_1_request
+ stub_comms do
+ @gateway.authorize(@amount, @credit_card, @options.merge(three_d_secure_option('1.0.2')))
+ end.check_request do |endpoint, data, headers|
+ assert_match %r{}, data
+ assert_match %r{eci}, data
+ assert_match %r{cavv}, data
+ assert_match %r{xid}, data
+ assert_match %r{1.0.2}, data
+ end.respond_with(successful_authorize_response)
+ end
+
+ def test_3ds_version_2_request
+ stub_comms do
+ @gateway.authorize(@amount, @credit_card, @options.merge(three_d_secure_option('2.1.0')))
+ end.check_request do |endpoint, data, headers|
+ assert_match %r{}, data
+ assert_match %r{eci}, data
+ assert_match %r{cavv}, data
+ assert_match %r{xid}, data
+ assert_match %r{2.1.0}, data
+ end.respond_with(successful_authorize_response)
+ end
+
private
+ def three_d_secure_option(version)
+ {
+ three_d_secure: {
+ eci: 'eci',
+ cavv: 'cavv',
+ xid: 'xid',
+ version: version
+ }
+ }
+ end
+
def successful_authorize_response
<<-RESPONSE
From 8e48034d9ff2978c8d6ceff2f868f74ae5e2edf1 Mon Sep 17 00:00:00 2001
From: Manon Deloupy
Date: Wed, 20 Mar 2019 11:00:01 -0400
Subject: [PATCH 0305/2234] QuickPay v10: Add 3DS params (#3173)
---
.../billing/gateways/quickpay/quickpay_v10.rb | 8 +++++-
.../gateways/remote_quickpay_v10_test.rb | 17 +++++++++++++
test/unit/gateways/quickpay_v10_test.rb | 25 ++++++++++++++++++-
3 files changed, 48 insertions(+), 2 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb b/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb
index e1b00768287..565890a150e 100644
--- a/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb
+++ b/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb
@@ -103,7 +103,7 @@ def authorization_params(money, credit_card_or_reference, options = {})
post = {}
add_amount(post, money, options)
- add_credit_card_or_reference(post, credit_card_or_reference)
+ add_credit_card_or_reference(post, credit_card_or_reference, options)
add_additional_params(:authorize, post, options)
post
@@ -217,6 +217,12 @@ def add_credit_card_or_reference(post, credit_card_or_reference, options = {})
post[:card][:expiration] = expdate(credit_card_or_reference)
post[:card][:issued_to] = credit_card_or_reference.name
end
+
+ if options[:three_d_secure]
+ post[:card][:cavv]= options.dig(:three_d_secure, :cavv)
+ post[:card][:eci] = options.dig(:three_d_secure, :eci)
+ post[:card][:xav] = options.dig(:three_d_secure, :xid)
+ end
end
def parse(body)
diff --git a/test/remote/gateways/remote_quickpay_v10_test.rb b/test/remote/gateways/remote_quickpay_v10_test.rb
index 4a349cecafd..8c71fcb1742 100644
--- a/test/remote/gateways/remote_quickpay_v10_test.rb
+++ b/test/remote/gateways/remote_quickpay_v10_test.rb
@@ -95,6 +95,23 @@ def test_successful_authorize_and_capture
assert_equal 'OK', capture.message
end
+ def test_successful_authorize_and_capture_with_3ds
+ options = @options.merge(
+ three_d_secure: {
+ cavv: '1234',
+ eci: '1234',
+ xid: '1234'
+ }
+ )
+ assert auth = @gateway.authorize(@amount, @valid_card, options)
+ assert_success auth
+ assert_equal 'OK', auth.message
+ assert auth.authorization
+ assert capture = @gateway.capture(@amount, auth.authorization)
+ assert_success capture
+ assert_equal 'OK', capture.message
+ end
+
def test_unsuccessful_authorize_and_capture
assert auth = @gateway.authorize(@amount, @capture_rejected_card, @options)
assert_success auth
diff --git a/test/unit/gateways/quickpay_v10_test.rb b/test/unit/gateways/quickpay_v10_test.rb
index 61bec826b5d..f07f13cc03e 100644
--- a/test/unit/gateways/quickpay_v10_test.rb
+++ b/test/unit/gateways/quickpay_v10_test.rb
@@ -58,6 +58,30 @@ def test_successful_authorization
end.respond_with(successful_payment_response, successful_authorization_response)
end
+ def test_successful_authorization_with_3ds
+ options = @options.merge(
+ three_d_secure: {
+ cavv: '1234',
+ eci: '1234',
+ xid: '1234'
+ }
+ )
+ stub_comms do
+ assert response = @gateway.authorize(@amount, @credit_card, options)
+ assert_success response
+ assert_equal '1145', response.authorization
+ assert response.test?
+ end.check_request do |endpoint, data, headers|
+ parsed_data = parse(data)
+ if parsed_data['order_id']
+ assert_match %r{/payments}, endpoint
+ assert_match '1.1.1.1', options[:customer_ip]
+ else
+ assert_match %r{/payments/\d+/authorize}, endpoint
+ end
+ end.respond_with(successful_payment_response, successful_authorization_response)
+ end
+
def test_successful_void
stub_comms do
assert response = @gateway.void(1145)
@@ -284,5 +308,4 @@ def scrubbed_transcript
D, [2015-08-17T11:44:26.710099 #75027] DEBUG -- : {"amount":"100","card":{"number":"[FILTERED]","cvd":"[FILTERED]","expiration":"1609","issued_to":"Longbob Longsen"},"auto_capture":false}
)
end
-
end
From 153f33c3d4ae8144435d4704a1f4c27c80790ab1 Mon Sep 17 00:00:00 2001
From: Philibert Dugas
Date: Wed, 20 Mar 2019 14:03:00 -0400
Subject: [PATCH 0306/2234] Allow to pass empty `landing_page` parameter
(#3176)
* Allow to pass empty `landing_page` parameter
PayPal has logic in their javascript to determine if a visitor
should see the sign-in page or the guest checkout page.
This kicks in only when the landing_page parameter is not sent and the
logic is based off cookies.
* Reuse allow_guest_checkout
---
lib/active_merchant/billing/gateways/paypal_express.rb | 4 +++-
test/unit/gateways/paypal_express_test.rb | 7 +++++++
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/lib/active_merchant/billing/gateways/paypal_express.rb b/lib/active_merchant/billing/gateways/paypal_express.rb
index cc5dde222d4..60d659437f9 100644
--- a/lib/active_merchant/billing/gateways/paypal_express.rb
+++ b/lib/active_merchant/billing/gateways/paypal_express.rb
@@ -146,7 +146,9 @@ def build_setup_request(action, money, options)
xml.tag! 'n2:cpp-payflow-color', options[:background_color] unless options[:background_color].blank?
if options[:allow_guest_checkout]
xml.tag! 'n2:SolutionType', 'Sole'
- xml.tag! 'n2:LandingPage', options[:landing_page] || 'Billing'
+ unless options[:paypal_chooses_landing_page]
+ xml.tag! 'n2:LandingPage', options[:landing_page] || 'Billing'
+ end
end
xml.tag! 'n2:BuyerEmail', options[:email] unless options[:email].blank?
diff --git a/test/unit/gateways/paypal_express_test.rb b/test/unit/gateways/paypal_express_test.rb
index 61c506558a1..be0274025f8 100644
--- a/test/unit/gateways/paypal_express_test.rb
+++ b/test/unit/gateways/paypal_express_test.rb
@@ -642,6 +642,13 @@ def test_allow_guest_checkout
assert_equal 'Billing', REXML::XPath.first(xml, '//n2:LandingPage').text
end
+ def test_paypal_chooses_landing_page
+ xml = REXML::Document.new(@gateway.send(:build_setup_request, 'SetExpressCheckout', 10, {:allow_guest_checkout => true, :paypal_chooses_landing_page=> true}))
+
+ assert_equal 'Sole', REXML::XPath.first(xml, '//n2:SolutionType').text
+ assert_nil REXML::XPath.first(xml, '//n2:LandingPage')
+ end
+
def test_not_adds_brand_name_if_not_specified
xml = REXML::Document.new(@gateway.send(:build_setup_request, 'SetExpressCheckout', 10, {}))
From 90a551572ddd4c60bcf6b2f34ede750fd131fc8f Mon Sep 17 00:00:00 2001
From: David Perry
Date: Thu, 21 Mar 2019 15:26:08 -0400
Subject: [PATCH 0307/2234] Adyen: Pass phone, statement, device_fingerprint
Remote:
51 tests, 147 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
30 tests, 144 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/adyen.rb | 3 +++
test/remote/gateways/remote_adyen_test.rb | 8 +++++++-
3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 39669a5a50d..d73cc0f92f8 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -16,6 +16,7 @@
* WorldPay: Fix element order for 3DS + stored cred [bayprogrammer] #3172
* Braintree: Add risk data to returned response [jknipp] #3169
* Adyen: Support idempotency on purchase [molbrown] #3168
+* Adyen: Pass phone, statement, device_fingerprint [curiousepic] #3178
== Version 1.91.0 (February 22, 2019)
* WorldPay: Pull CVC and AVS Result from Response [nfarve] #3106
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index 681c37f857e..ea06e42f420 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -152,9 +152,11 @@ def scrub(transcript)
}
def add_extra_data(post, payment, options)
+ post[:telephoneNumber] = options[:billing_address][:phone] if options[:billing_address][:phone]
post[:shopperEmail] = options[:shopper_email] if options[:shopper_email]
post[:shopperIP] = options[:shopper_ip] if options[:shopper_ip]
post[:shopperReference] = options[:shopper_reference] if options[:shopper_reference]
+ post[:shopperStatement] = options[:shopper_statement] if options[:shopper_statement]
post[:fraudOffset] = options[:fraud_offset] if options[:fraud_offset]
post[:selectedBrand] = options[:selected_brand] if options[:selected_brand]
post[:selectedBrand] ||= NETWORK_TOKENIZATION_CARD_SOURCE[payment.source.to_s] if payment.is_a?(NetworkTokenizationCreditCard)
@@ -164,6 +166,7 @@ def add_extra_data(post, payment, options)
post[:additionalData][:overwriteBrand] = normalize(options[:overwrite_brand]) if options[:overwrite_brand]
post[:additionalData][:customRoutingFlag] = options[:custom_routing_flag] if options[:custom_routing_flag]
post[:additionalData]['paymentdatasource.type'] = NETWORK_TOKENIZATION_CARD_SOURCE[payment.source.to_s] if payment.is_a?(NetworkTokenizationCreditCard)
+ post[:deviceFingerprint] = options[:device_fingerprint] if options[:device_fingerprint]
add_risk_data(post, options)
end
diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb
index 3a42c92c548..bf43ddcb806 100644
--- a/test/remote/gateways/remote_adyen_test.rb
+++ b/test/remote/gateways/remote_adyen_test.rb
@@ -140,7 +140,7 @@ def test_successful_purchase_no_cvv
end
def test_successful_purchase_with_more_options
- options = @options.merge!(fraudOffset: '1', installments: 2)
+ options = @options.merge!(fraudOffset: '1', installments: 2, shopper_statement: 'statement note', device_fingerprint: 'm7Cmrf++0cW4P6XfF7m/rA')
response = @gateway.purchase(@amount, @credit_card, options)
assert_success response
assert_equal '[capture-received]', response.message
@@ -470,4 +470,10 @@ def test_invalid_state_for_purchase
assert_failure response
assert_match Gateway::STANDARD_ERROR_CODE[:incorrect_address], response.error_code
end
+
+ def test_missing_phone_for_purchase
+ @options[:billing_address].delete(:phone)
+ response = @gateway.authorize(@amount, @credit_card, @options)
+ assert_success response
+ end
end
From 477453d6449e2dc8c98e5944a960dfe9b0e26c42 Mon Sep 17 00:00:00 2001
From: David Perry
Date: Fri, 22 Mar 2019 15:43:11 -0400
Subject: [PATCH 0308/2234] Adyen: Fix adding phone from billing address
Now checking for presence of a billing_address in options before
adding the phone.
Remote:
52 tests, 149 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
30 tests, 144 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/adyen.rb | 2 +-
test/remote/gateways/remote_adyen_test.rb | 14 ++++++++++++++
3 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index d73cc0f92f8..b1be7c34fa8 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -17,6 +17,7 @@
* Braintree: Add risk data to returned response [jknipp] #3169
* Adyen: Support idempotency on purchase [molbrown] #3168
* Adyen: Pass phone, statement, device_fingerprint [curiousepic] #3178
+* Adyen: Fix adding phone from billing address [curiousepic] #3179
== Version 1.91.0 (February 22, 2019)
* WorldPay: Pull CVC and AVS Result from Response [nfarve] #3106
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index ea06e42f420..b72ae0c5396 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -152,7 +152,7 @@ def scrub(transcript)
}
def add_extra_data(post, payment, options)
- post[:telephoneNumber] = options[:billing_address][:phone] if options[:billing_address][:phone]
+ post[:telephoneNumber] = options[:billing_address][:phone] if options.dig(:billing_address, :phone)
post[:shopperEmail] = options[:shopper_email] if options[:shopper_email]
post[:shopperIP] = options[:shopper_ip] if options[:shopper_ip]
post[:shopperReference] = options[:shopper_reference] if options[:shopper_reference]
diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb
index bf43ddcb806..10629ddbbb1 100644
--- a/test/remote/gateways/remote_adyen_test.rb
+++ b/test/remote/gateways/remote_adyen_test.rb
@@ -119,6 +119,20 @@ def test_successful_authorize_with_3ds_dynamic_rule_broken
assert_equal response.params['resultCode'], 'Authorised'
end
+ def test_successful_authorize_with_no_address
+ options = {
+ reference: '345123',
+ shopper_email: 'john.smith@test.com',
+ shopper_ip: '77.110.174.153',
+ shopper_reference: 'John Smith',
+ order_id: '123',
+ recurring_processing_model: 'CardOnFile'
+ }
+ response = @gateway.authorize(@amount, @credit_card, options)
+ assert_success response
+ assert_equal 'Authorised', response.message
+ end
+
def test_failed_authorize
response = @gateway.authorize(@amount, @declined_card, @options)
assert_failure response
From 2541ce5c7dad35000bcb8713ea665d2acdda26c1 Mon Sep 17 00:00:00 2001
From: molbrown
Date: Fri, 22 Mar 2019 17:17:52 -0400
Subject: [PATCH 0309/2234] Fix partial or missing address exceptions
NilClass errors noted in attempted transactions for DLocal and Mundipagg gateways,
due to absent objects. Made small fixes that will avoid this error.
Mundipagg Unit tests:
17 tests, 76 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
DLocal Unit tests:
16 tests, 48 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Closes #3180
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/d_local.rb | 2 +-
lib/active_merchant/billing/gateways/mundipagg.rb | 4 ++--
test/unit/gateways/d_local_test.rb | 9 +++++++++
test/unit/gateways/mundipagg_test.rb | 14 ++++++++++++++
5 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index b1be7c34fa8..c7377ac35a1 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -18,6 +18,7 @@
* Adyen: Support idempotency on purchase [molbrown] #3168
* Adyen: Pass phone, statement, device_fingerprint [curiousepic] #3178
* Adyen: Fix adding phone from billing address [curiousepic] #3179
+* Fix partial or missing address exceptions [molbrown] #3180
== Version 1.91.0 (February 22, 2019)
* WorldPay: Pull CVC and AVS Result from Response [nfarve] #3106
diff --git a/lib/active_merchant/billing/gateways/d_local.rb b/lib/active_merchant/billing/gateways/d_local.rb
index deef1687b9b..2218501942a 100644
--- a/lib/active_merchant/billing/gateways/d_local.rb
+++ b/lib/active_merchant/billing/gateways/d_local.rb
@@ -102,7 +102,7 @@ def add_payer(post, card, options)
post[:payer][:name] = card.name
post[:payer][:email] = options[:email] if options[:email]
post[:payer][:birth_date] = options[:birth_date] if options[:birth_date]
- post[:payer][:phone] = address[:phone] if address[:phone]
+ post[:payer][:phone] = address[:phone] if address && address[:phone]
post[:payer][:document] = options[:document] if options[:document]
post[:payer][:document2] = options[:document2] if options[:document2]
post[:payer][:user_reference] = options[:user_reference] if options[:user_reference]
diff --git a/lib/active_merchant/billing/gateways/mundipagg.rb b/lib/active_merchant/billing/gateways/mundipagg.rb
index aeac34ebe11..04f39464ab4 100644
--- a/lib/active_merchant/billing/gateways/mundipagg.rb
+++ b/lib/active_merchant/billing/gateways/mundipagg.rb
@@ -128,8 +128,8 @@ def add_billing_address(post, type, options)
def add_shipping_address(post, options)
if address = options[:shipping_address]
post[:address] = {}
- post[:address][:street] = address[:address1].match(/\D+/)[0].strip if address[:address1]
- post[:address][:number] = address[:address1].match(/\d+/)[0] if address[:address1]
+ post[:address][:street] = address[:address1].match(/\D+/)[0].strip if address[:address1]&.match(/\D+/)
+ post[:address][:number] = address[:address1].match(/\d+/)[0] if address[:address1]&.match(/\d+/)
post[:address][:compliment] = address[:address2] if address[:address2]
post[:address][:city] = address[:city] if address[:city]
post[:address][:state] = address[:state] if address[:state]
diff --git a/test/unit/gateways/d_local_test.rb b/test/unit/gateways/d_local_test.rb
index cac863704f9..744ba53cbc2 100644
--- a/test/unit/gateways/d_local_test.rb
+++ b/test/unit/gateways/d_local_test.rb
@@ -39,6 +39,15 @@ def test_successful_authorize
assert_equal 'D-15104-be03e883-3e6b-497d-840e-54c8b6209bc3', response.authorization
end
+ def test_successful_authorize_without_address
+ @gateway.expects(:ssl_post).returns(successful_authorize_response)
+
+ response = @gateway.authorize(@amount, @credit_card, @options.delete(:billing_address))
+ assert_success response
+
+ assert_equal 'D-15104-be03e883-3e6b-497d-840e-54c8b6209bc3', response.authorization
+ end
+
def test_failed_authorize
@gateway.expects(:ssl_post).returns(failed_authorize_response)
diff --git a/test/unit/gateways/mundipagg_test.rb b/test/unit/gateways/mundipagg_test.rb
index 208ddba3a5d..93b023f3f44 100644
--- a/test/unit/gateways/mundipagg_test.rb
+++ b/test/unit/gateways/mundipagg_test.rb
@@ -63,6 +63,20 @@ def test_successful_authorize
assert response.test?
end
+ def test_successful_authorize_with_partially_missing_address
+ shipping_address = {
+ country: 'BR',
+ address1: 'Foster St.'
+ }
+
+ @gateway.expects(:ssl_post).returns(successful_authorize_response)
+ response = @gateway.authorize(@amount, @credit_card, @options.merge(shipping_address: shipping_address))
+ assert_success response
+
+ assert_equal 'ch_gm5wrlGMI2Fb0x6K', response.authorization
+ assert response.test?
+ end
+
def test_failed_authorize
@gateway.expects(:ssl_post).returns(failed_authorize_response)
From f050ae9110060ac59fb4c17e265cba0c35b01d90 Mon Sep 17 00:00:00 2001
From: molbrown
Date: Wed, 20 Mar 2019 14:32:31 -0400
Subject: [PATCH 0310/2234] Adyen: Update to support normalized stored
credential fields
Adapter already supports defining shopperInteraction and
recurringProcessingModel directly. Adding ability to define these fields
using the normalized hash (which can be overidden by passing the fields
directly). Maintains using verification value or Network Tokenization
cards to define shopperInteraction.
ECS-213
Unit:
32 tests, 152 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
52 tests, 149 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Closes #3182
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/adyen.rb | 22 ++++++++++--
test/remote/gateways/remote_adyen_test.rb | 2 +-
test/unit/gateways/adyen_test.rb | 35 ++++++++++++++++++-
4 files changed, 55 insertions(+), 5 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index c7377ac35a1..e29101b2ba2 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -19,6 +19,7 @@
* Adyen: Pass phone, statement, device_fingerprint [curiousepic] #3178
* Adyen: Fix adding phone from billing address [curiousepic] #3179
* Fix partial or missing address exceptions [molbrown] #3180
+Adyen: Update to support normalized stored credential fields [molbrown] #3182
== Version 1.91.0 (February 22, 2019)
* WorldPay: Pull CVC and AVS Result from Response [nfarve] #3106
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index b72ae0c5396..23bcc2e5119 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -49,7 +49,7 @@ def authorize(money, payment, options={})
add_invoice(post, money, options)
add_payment(post, payment)
add_extra_data(post, payment, options)
- add_shopper_interaction(post, payment, options)
+ add_stored_credentials(post, payment, options)
add_address(post, options)
add_installments(post, options) if options[:installments]
add_3ds(post, options)
@@ -82,6 +82,7 @@ def store(credit_card, options={})
add_invoice(post, 0, options)
add_payment(post, credit_card)
add_extra_data(post, credit_card, options)
+ add_stored_credentials(post, credit_card, options)
add_recurring_contract(post, options)
add_address(post, options)
commit('authorise', post, options)
@@ -177,8 +178,13 @@ def add_risk_data(post, options)
end
end
+ def add_stored_credentials(post, payment, options)
+ add_shopper_interaction(post, payment, options)
+ add_recurring_processing_model(post, options)
+ end
+
def add_shopper_interaction(post, payment, options={})
- if (payment.respond_to?(:verification_value) && payment.verification_value) || payment.is_a?(NetworkTokenizationCreditCard)
+ if options.dig(:stored_credential, :initial_transaction) || (payment.respond_to?(:verification_value) && payment.verification_value) || payment.is_a?(NetworkTokenizationCreditCard)
shopper_interaction = 'Ecommerce'
else
shopper_interaction = 'ContAuth'
@@ -187,6 +193,17 @@ def add_shopper_interaction(post, payment, options={})
post[:shopperInteraction] = options[:shopper_interaction] || shopper_interaction
end
+ def add_recurring_processing_model(post, options)
+ return unless options.dig(:stored_credential, :reason_type) || options[:recurring_processing_model]
+ if options.dig(:stored_credential, :reason_type) && options[:stored_credential][:reason_type] == 'unscheduled'
+ recurring_processing_model = 'CardOnFile'
+ else
+ recurring_processing_model = 'Subscription'
+ end
+
+ post[:recurringProcessingModel] = options[:recurring_processing_model] || recurring_processing_model
+ end
+
def add_address(post, options)
return unless post[:card]&.kind_of?(Hash)
if (address = options[:billing_address] || options[:address]) && address[:country]
@@ -206,7 +223,6 @@ def add_invoice(post, money, options)
currency: options[:currency] || currency(money)
}
post[:amount] = amount
- post[:recurringProcessingModel] = options[:recurring_processing_model] if options[:recurring_processing_model]
end
def add_invoice_for_modification(post, money, options)
diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb
index 10629ddbbb1..cdfe7f29828 100644
--- a/test/remote/gateways/remote_adyen_test.rb
+++ b/test/remote/gateways/remote_adyen_test.rb
@@ -61,7 +61,7 @@ def setup
shopper_reference: 'John Smith',
billing_address: address(),
order_id: '123',
- recurring_processing_model: 'CardOnFile'
+ stored_credential: {reason_type: 'unscheduled'}
}
end
diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb
index 3df8cff60f3..8b503ec2be2 100644
--- a/test/unit/gateways/adyen_test.rb
+++ b/test/unit/gateways/adyen_test.rb
@@ -45,7 +45,21 @@ def setup
shopper_reference: 'John Smith',
order_id: '345123',
installments: 2,
- recurring_processing_model: 'CardOnFile'
+ stored_credential: {reason_type: 'unscheduled'}
+ }
+
+ @normalized_initial_stored_credential = {
+ stored_credential: {
+ initial_transaction: true,
+ reason_type: 'unscheduled'
+ }
+ }
+
+ @normalized_stored_credential = {
+ stored_credential: {
+ initial_transaction: false,
+ reason_type: 'recurring'
+ }
}
end
@@ -189,6 +203,25 @@ def test_risk_data_complex_data
end.respond_with(successful_authorize_response)
end
+ def test_successful_authorize_with_normalized_stored_credentials
+ @credit_card.verification_value = nil
+ stub_comms do
+ @gateway.authorize(50, @credit_card, @options.merge(@normalized_stored_credential))
+ end.check_request do |endpoint, data, headers|
+ assert_match(/"shopperInteraction":"ContAuth"/, data)
+ assert_match(/"recurringProcessingModel":"Subscription"/, data)
+ end.respond_with(successful_authorize_response)
+ end
+
+ def test_successful_initial_authorize_with_normalized_stored_credentials
+ stub_comms do
+ @gateway.authorize(50, @credit_card, @options.merge(@normalized_initial_stored_credential))
+ end.check_request do |endpoint, data, headers|
+ assert_match(/"shopperInteraction":"Ecommerce"/, data)
+ assert_match(/"recurringProcessingModel":"CardOnFile"/, data)
+ end.respond_with(successful_authorize_response)
+ end
+
def test_failed_purchase
@gateway.expects(:ssl_post).returns(failed_purchase_response)
From f8961d25991ca22d58efd42f2617bef5fcc0e91b Mon Sep 17 00:00:00 2001
From: Anna Gyergyai <33272949+AnnaGyergyai@users.noreply.github.com>
Date: Wed, 27 Mar 2019 16:34:57 -0400
Subject: [PATCH 0311/2234] Realex: Add 3DS (#3170)
---
.../billing/gateways/realex.rb | 16 ++++-
test/remote/gateways/remote_realex_test.rb | 15 +++++
test/unit/gateways/realex_test.rb | 58 +++++++++++++++++++
3 files changed, 88 insertions(+), 1 deletion(-)
diff --git a/lib/active_merchant/billing/gateways/realex.rb b/lib/active_merchant/billing/gateways/realex.rb
index ca0b91517b3..9b8798b2cc4 100644
--- a/lib/active_merchant/billing/gateways/realex.rb
+++ b/lib/active_merchant/billing/gateways/realex.rb
@@ -145,7 +145,11 @@ def build_purchase_or_authorization_request(action, money, credit_card, options)
add_card(xml, credit_card)
xml.tag! 'autosettle', 'flag' => auto_settle_flag(action)
add_signed_digest(xml, timestamp, @options[:login], sanitize_order_id(options[:order_id]), amount(money), (options[:currency] || currency(money)), credit_card.number)
- add_network_tokenization_card(xml, credit_card) if credit_card.is_a?(NetworkTokenizationCreditCard)
+ if credit_card.is_a?(NetworkTokenizationCreditCard)
+ add_network_tokenization_card(xml, credit_card)
+ else
+ add_three_d_secure(xml, options)
+ end
add_comments(xml, options)
add_address_and_customer_info(xml, options)
end
@@ -284,6 +288,16 @@ def add_network_tokenization_card(xml, payment)
end
end
+ def add_three_d_secure(xml, options)
+ if options[:three_d_secure]
+ xml.tag! 'mpi' do
+ xml.tag! 'cavv', options[:three_d_secure][:cavv]
+ xml.tag! 'eci', options[:three_d_secure][:eci]
+ xml.tag! 'xid', options[:three_d_secure][:xid]
+ end
+ end
+ end
+
def format_address_code(address)
code = [address[:zip].to_s, address[:address1].to_s + address[:address2].to_s]
code.collect { |e| e.gsub(/\D/, '') }.reject(&:empty?).join('|')
diff --git a/test/remote/gateways/remote_realex_test.rb b/test/remote/gateways/remote_realex_test.rb
index b8280a6d8bc..ec80321697b 100644
--- a/test/remote/gateways/remote_realex_test.rb
+++ b/test/remote/gateways/remote_realex_test.rb
@@ -115,6 +115,21 @@ def test_realex_purchase_with_apple_pay_declined
assert_match %r{DECLINED}i, response.message
end
+ def test_realex_purchase_with_three_d_secure
+ response = @gateway.purchase(
+ 1000,
+ @visa,
+ three_d_secure: {
+ eci: '05', xid: '05', cavv: '05'
+ },
+ :order_id => generate_unique_id,
+ :description => 'Test Realex with 3DS'
+ )
+ assert_success response
+ assert response.test?
+ assert_equal 'Successful', response.message
+ end
+
def test_realex_purchase_referral_b
[ @visa_referral_b, @mastercard_referral_b ].each do |card|
response = @gateway.purchase(@amount, card,
diff --git a/test/unit/gateways/realex_test.rb b/test/unit/gateways/realex_test.rb
index b0b5e92859b..2223ffd06fe 100644
--- a/test/unit/gateways/realex_test.rb
+++ b/test/unit/gateways/realex_test.rb
@@ -339,6 +339,64 @@ def test_transcript_scrubbing
assert_equal scrubbed_transcript, @gateway.scrub(transcript)
end
+ def test_three_d_secure
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
+
+ options = {
+ :order_id => '1',
+ :three_d_secure => {
+ :cavv => '1234',
+ :eci => '1234',
+ :xid => '1234'
+ }
+ }
+
+ response = @gateway.authorize(@amount, @credit_card, options)
+ assert_equal 'M', response.cvv_result['code']
+ end
+
+ def test_auth_xml_with_three_d_secure
+ options = {
+ :order_id => '1',
+ :three_d_secure => {
+ :cavv => '1234',
+ :eci => '1234',
+ :xid => '1234'
+ }
+ }
+
+ @gateway.expects(:new_timestamp).returns('20090824160201')
+
+ valid_auth_request_xml = <<-SRC
+
+ your_merchant_id
+ your_account
+ 1
+ 100
+
+ 4263971921001307
+ 0808
+ Longbob Longsen
+ VISA
+
+
+
+
+
+
+
+ 3499d7bc8dbacdcfba2286bd74916d026bae630f
+
+ 1234
+ 1234
+ 1234
+
+
+SRC
+
+ assert_xml_equal valid_auth_request_xml, @gateway.build_purchase_or_authorization_request(:authorization, @amount, @credit_card, options)
+ end
+
private
def successful_purchase_response
From 077cba4f621bd3efab332c8fc4847ca6fb5b50d3 Mon Sep 17 00:00:00 2001
From: molbrown
Date: Fri, 29 Mar 2019 09:59:35 -0400
Subject: [PATCH 0312/2234] DLocal: Send country as string
ECS-246
Unit:
17 tests, 67 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
21 tests, 59 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Closes #3183
---
CHANGELOG | 2 +-
lib/active_merchant/billing/gateways/d_local.rb | 2 +-
test/unit/gateways/d_local_test.rb | 10 ++++++++++
3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index e29101b2ba2..dc458c18c4e 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -19,7 +19,7 @@
* Adyen: Pass phone, statement, device_fingerprint [curiousepic] #3178
* Adyen: Fix adding phone from billing address [curiousepic] #3179
* Fix partial or missing address exceptions [molbrown] #3180
-Adyen: Update to support normalized stored credential fields [molbrown] #3182
+* Adyen: Update to support normalized stored credential fields [molbrown] #3182
== Version 1.91.0 (February 22, 2019)
* WorldPay: Pull CVC and AVS Result from Response [nfarve] #3106
diff --git a/lib/active_merchant/billing/gateways/d_local.rb b/lib/active_merchant/billing/gateways/d_local.rb
index 2218501942a..781e29cfe3c 100644
--- a/lib/active_merchant/billing/gateways/d_local.rb
+++ b/lib/active_merchant/billing/gateways/d_local.rb
@@ -93,7 +93,7 @@ def add_country(post, card, options)
end
def lookup_country_code(country)
- Country.find(country).code(:alpha2)
+ Country.find(country).code(:alpha2).value
end
def add_payer(post, card, options)
diff --git a/test/unit/gateways/d_local_test.rb b/test/unit/gateways/d_local_test.rb
index 744ba53cbc2..bb4d1df6aac 100644
--- a/test/unit/gateways/d_local_test.rb
+++ b/test/unit/gateways/d_local_test.rb
@@ -1,6 +1,8 @@
require 'test_helper'
class DLocalTest < Test::Unit::TestCase
+ include CommStub
+
def setup
@gateway = DLocalGateway.new(login: 'login', trans_key: 'password', secret_key: 'shhhhh_key')
@credit_card = credit_card
@@ -48,6 +50,14 @@ def test_successful_authorize_without_address
assert_equal 'D-15104-be03e883-3e6b-497d-840e-54c8b6209bc3', response.authorization
end
+ def test_passing_country_as_string
+ stub_comms(@gateway, :ssl_request) do
+ @gateway.authorize(@amount, @credit_card, @options)
+ end.check_request do |method, endpoint, data, headers|
+ assert_match(/"country\":\"CA\"/, data)
+ end.respond_with(successful_authorize_response)
+ end
+
def test_failed_authorize
@gateway.expects(:ssl_post).returns(failed_authorize_response)
From b16d6565357e10a40f943c2c0b77ba8e45399488 Mon Sep 17 00:00:00 2001
From: Zeb DeOs
Date: Tue, 19 Mar 2019 13:47:38 -0400
Subject: [PATCH 0313/2234] VisaNet Peru: Always include DSC_COD_ACCION
Always include the action code description (DSC_COD_ACCION), when
available.
This also adds a test[1] to ensure the logic[2] is correct for our
stashing the message in the options hash for retrying a full refund if a
partial refund fails.
[1] https://github.com/activemerchant/active_merchant/pull/3174#issue-260959877
[2] https://github.com/activemerchant/active_merchant/pull/2772#discussion_r174914253
ECS-173
Unit:
15 tests, 75 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
18 tests, 27 assertions, 16 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
11.1111% passed
(Please note that most of the remote tests are failing because our test
credentials are invalid and we've not been able to get new/valid
credentials as of the time of this commit).
Closes #3174
---
CHANGELOG | 1 +
.../billing/gateways/visanet_peru.rb | 32 +++++---
.../gateways/remote_visanet_peru_test.rb | 8 +-
test/unit/gateways/visanet_peru_test.rb | 75 ++++++++++++++++++-
4 files changed, 103 insertions(+), 13 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index dc458c18c4e..717c65866b4 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -20,6 +20,7 @@
* Adyen: Fix adding phone from billing address [curiousepic] #3179
* Fix partial or missing address exceptions [molbrown] #3180
* Adyen: Update to support normalized stored credential fields [molbrown] #3182
+* VisaNet Peru: Always include DSC_COD_ACCION [bayprogrammer] #3174
== Version 1.91.0 (February 22, 2019)
* WorldPay: Pull CVC and AVS Result from Response [nfarve] #3106
diff --git a/lib/active_merchant/billing/gateways/visanet_peru.rb b/lib/active_merchant/billing/gateways/visanet_peru.rb
index 70999dc58ee..49473abc2f6 100644
--- a/lib/active_merchant/billing/gateways/visanet_peru.rb
+++ b/lib/active_merchant/billing/gateways/visanet_peru.rb
@@ -57,7 +57,10 @@ def refund(amount, authorization, options={})
response = commit('cancelDeposit', params, options)
return response if response.success? || split_authorization(authorization).length == 1 || !options[:force_full_refund_if_unsettled]
- # Attempt RefundSingleTransaction if unsettled
+ # Attempt RefundSingleTransaction if unsettled (and stash the original
+ # response message so it will be included it in the follow-up response
+ # message)
+ options[:error_message] = response.message
prepare_refund_data(params, authorization, options)
commit('refund', params, options)
end
@@ -197,15 +200,24 @@ def success_from(response)
end
def message_from(response, options, action)
- if empty?(response['errorMessage']) || response['errorMessage'] == '[ ]'
- action == 'refund' ? "#{response['data']['DSC_COD_ACCION']}, #{options[:error_message]}" : response['data']['DSC_COD_ACCION']
- elsif action == 'refund'
- message = "#{response['errorMessage']}, #{options[:error_message]}"
- options[:error_message] = response['errorMessage']
- message
- else
- response['errorMessage']
- end
+ message_from_messages(
+ response['errorMessage'],
+ action_code_description(response),
+ options[:error_message]
+ )
+ end
+
+ def message_from_messages(*args)
+ args.reject { |m| error_message_empty?(m) }.join(' | ')
+ end
+
+ def action_code_description(response)
+ return nil unless response['data']
+ response['data']['DSC_COD_ACCION']
+ end
+
+ def error_message_empty?(error_message)
+ empty?(error_message) || error_message == '[ ]'
end
def response_error(raw_response, options, action)
diff --git a/test/remote/gateways/remote_visanet_peru_test.rb b/test/remote/gateways/remote_visanet_peru_test.rb
index d596f4b451e..950705e68b5 100644
--- a/test/remote/gateways/remote_visanet_peru_test.rb
+++ b/test/remote/gateways/remote_visanet_peru_test.rb
@@ -73,17 +73,21 @@ def test_successful_authorize_fractional_amount
assert_equal '1.99', response.params['data']['IMP_AUTORIZADO']
end
- def test_failed_authorize
+ def test_failed_authorize_declined_card
response = @gateway.authorize(@amount, @declined_card, @options)
assert_failure response
assert_equal 400, response.error_code
assert_equal 'Operacion Denegada.', response.message
+ end
+ def test_failed_authorize_bad_email
@options[:email] = 'cybersource@reject.com'
response = @gateway.authorize(@amount, @credit_card, @options)
assert_failure response
assert_equal 400, response.error_code
- assert_equal 'REJECT', response.message
+
+ # this also exercises message joining for errorMessage and DSC_COD_ACCION when both are present
+ assert_equal 'REJECT | Operacion denegada', response.message
end
def test_failed_capture
diff --git a/test/unit/gateways/visanet_peru_test.rb b/test/unit/gateways/visanet_peru_test.rb
index 49b7a78951b..c58840c78a0 100644
--- a/test/unit/gateways/visanet_peru_test.rb
+++ b/test/unit/gateways/visanet_peru_test.rb
@@ -60,7 +60,7 @@ def test_failed_authorize
response = @gateway.authorize(@amount, @credit_card, @options)
assert_failure response
assert_equal 400, response.error_code
- assert_equal 'REJECT', response.message
+ assert_equal 'REJECT | Operacion denegada', response.message
end
def test_successful_capture
@@ -104,6 +104,27 @@ def test_failed_refund
assert_equal 400, response.error_code
end
+ def test_failed_full_refund_when_unsettled
+ @gateway.expects(:ssl_request).with(:put, any_parameters).returns(failed_refund_response)
+ @gateway.expects(:ssl_request).with(:post, any_parameters).returns(failed_refund_with_action_code_response)
+ response = @gateway.refund(@amount, '122333444|444333221', force_full_refund_if_unsettled: true)
+ assert_failure response
+ assert_equal("Operacion Denegada. | [ 'NUMORDEN 122333444 no se encuentra registrado', 'No se realizo la anulacion del deposito' ]", response.message)
+ assert_equal 400, response.error_code
+ end
+
+ def test_failed_full_refund_when_unsettled_additional_message_concatenation
+ @gateway.expects(:ssl_request).with(:put, any_parameters).returns(failed_refund_with_message_and_action_code_response)
+ @gateway.expects(:ssl_request).with(:post, any_parameters).returns(failed_refund_with_message_and_action_code_response_2)
+ first_msg = 'No se realizo la anulacion del deposito'
+ first_dsc = 'Operacion Denegada.'
+ second_msg = 'Mal funcionamiento de la inteligencia artificial'
+ second_dsc = 'Lo siento Dave, me temo que no puedo hacer eso.'
+
+ response = @gateway.refund(@amount, '122333444|444333221', force_full_refund_if_unsettled: true)
+ assert_equal("#{second_msg} | #{second_dsc} | #{first_msg} | #{first_dsc}", response.message)
+ end
+
def test_successful_void
@gateway.expects(:ssl_request).returns(successful_authorize_response)
response = @gateway.authorize(@amount, @credit_card, @options)
@@ -446,4 +467,56 @@ def failed_refund_response
}
RESPONSE
end
+
+ def failed_refund_with_action_code_response
+ <<-RESPONSE
+ {
+ "errorCode": 400,
+ "errorMessage": "[ ]",
+ "data": {
+ "ESTADO": "",
+ "RESPUESTA": "2",
+ "DSC_COD_ACCION": "Operacion Denegada."
+ },
+ "transactionLog": {
+
+ }
+ }
+ RESPONSE
+ end
+
+ def failed_refund_with_message_and_action_code_response
+ <<-RESPONSE
+ {
+ "errorCode": 400,
+ "errorMessage": "No se realizo la anulacion del deposito",
+ "data": {
+ "ESTADO": "",
+ "RESPUESTA": "2",
+ "DSC_COD_ACCION": "Operacion Denegada."
+ },
+ "transactionLog": {
+
+ }
+ }
+ RESPONSE
+ end
+
+ def failed_refund_with_message_and_action_code_response_2
+ <<-RESPONSE
+ {
+ "errorCode": 400,
+ "errorMessage": "Mal funcionamiento de la inteligencia artificial",
+ "data": {
+ "ESTADO": "",
+ "RESPUESTA": "2",
+ "DSC_COD_ACCION": "Lo siento Dave, me temo que no puedo hacer eso."
+ },
+ "transactionLog": {
+
+ }
+ }
+ RESPONSE
+ end
+
end
From 415059daf8050d8d1e8140c7de9bb0e9b91faa8a Mon Sep 17 00:00:00 2001
From: David Perry
Date: Thu, 4 Apr 2019 16:17:56 -0400
Subject: [PATCH 0314/2234] Adyen: Support adjust action
This adds support for Adyen's adjustAuthorization action, which can
change the amount of a prior authorization, either increasing or
decreasing the amount and extending the auth period. There is no other
precedent for this type of action in ActiveMerchant, but it seems very
straightforward and simple to support, similar to other followup actions
like refunds and voids.
Closes #3190
Remote:
55 tests, 163 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
34 tests, 161 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/adyen.rb | 9 ++++-
test/remote/gateways/remote_adyen_test.rb | 30 ++++++++++++++++
test/unit/gateways/adyen_test.rb | 35 +++++++++++++++++++
4 files changed, 74 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 717c65866b4..ccff5f329ba 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -21,6 +21,7 @@
* Fix partial or missing address exceptions [molbrown] #3180
* Adyen: Update to support normalized stored credential fields [molbrown] #3182
* VisaNet Peru: Always include DSC_COD_ACCION [bayprogrammer] #3174
+* Adyen: Support adjust action [curiousepic] #3190
== Version 1.91.0 (February 22, 2019)
* WorldPay: Pull CVC and AVS Result from Response [nfarve] #3106
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index 23bcc2e5119..0b52f43c6de 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -76,6 +76,13 @@ def void(authorization, options={})
commit('cancel', post, options)
end
+ def adjust(money, authorization, options={})
+ post = init_post(options)
+ add_invoice_for_modification(post, money, options)
+ add_reference(post, authorization, options)
+ commit('adjustAuthorisation', post, options)
+ end
+
def store(credit_card, options={})
requires!(options, :order_id)
post = init_post(options)
@@ -367,7 +374,7 @@ def success_from(action, response)
case action.to_s
when 'authorise', 'authorise3d'
['Authorised', 'Received', 'RedirectShopper'].include?(response['resultCode'])
- when 'capture', 'refund', 'cancel'
+ when 'capture', 'refund', 'cancel', 'adjustAuthorisation'
response['response'] == "[#{action}-received]"
else
false
diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb
index cdfe7f29828..7c27a48a1f7 100644
--- a/test/remote/gateways/remote_adyen_test.rb
+++ b/test/remote/gateways/remote_adyen_test.rb
@@ -305,6 +305,36 @@ def test_failed_void
assert_equal 'Original pspReference required for this operation', response.message
end
+ def test_successful_adjust
+ authorize = @gateway.authorize(@amount, @credit_card, @options)
+ assert_success authorize
+
+ assert adjust = @gateway.adjust(200, authorize.authorization)
+ assert_success adjust
+ assert_equal '[adjustAuthorisation-received]', adjust.message
+ end
+
+ def test_successful_adjust_and_capture
+ authorize = @gateway.authorize(@amount, @credit_card, @options)
+ assert_success authorize
+
+ assert adjust = @gateway.adjust(200, authorize.authorization)
+ assert_success adjust
+ assert_equal '[adjustAuthorisation-received]', adjust.message
+
+ assert capture = @gateway.capture(200, authorize.authorization)
+ assert_success capture
+ end
+
+ def test_failed_adjust
+ auth = @gateway.authorize(@amount, @credit_card, @options)
+ assert_success auth
+
+ assert response = @gateway.adjust(200, '')
+ assert_failure response
+ assert_equal 'Original pspReference required for this operation', response.message
+ end
+
def test_successful_store
assert response = @gateway.store(@credit_card, @options)
diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb
index 8b503ec2be2..b173186fe29 100644
--- a/test/unit/gateways/adyen_test.rb
+++ b/test/unit/gateways/adyen_test.rb
@@ -270,6 +270,21 @@ def test_failed_void
assert_failure response
end
+ def test_successful_adjust
+ @gateway.expects(:ssl_post).returns(successful_adjust_response)
+ response = @gateway.adjust(200, '8835544088660594')
+ assert_equal '8835544088660594#8835544088660594#', response.authorization
+ assert_equal '[adjustAuthorisation-received]', response.message
+ assert response.test?
+ end
+
+ def test_failed_adjust
+ @gateway.expects(:ssl_post).returns(failed_adjust_response)
+ response = @gateway.adjust(200, '')
+ assert_equal 'Original pspReference required for this operation', response.message
+ assert_failure response
+ end
+
def test_successful_store
response = stub_comms do
@gateway.store(@credit_card, @options)
@@ -633,6 +648,26 @@ def failed_void_response
RESPONSE
end
+ def successful_adjust_response
+ <<-RESPONSE
+ {
+ "pspReference": "8835544088660594",
+ "response": "[adjustAuthorisation-received]"
+ }
+ RESPONSE
+ end
+
+ def failed_adjust_response
+ <<-RESPONSE
+ {
+ "status":422,
+ "errorCode":"167",
+ "message":"Original pspReference required for this operation",
+ "errorType":"validation"
+ }
+ RESPONSE
+ end
+
def successful_verify_response
<<-RESPONSE
{
From 42875273cc475e4cb0c8605b9b5a3d97fb00302a Mon Sep 17 00:00:00 2001
From: Ruthan
Date: Mon, 1 Apr 2019 23:22:33 -0400
Subject: [PATCH 0315/2234] Cybersource: Support stored credentials
---
CHANGELOG | 1 +
.../billing/gateways/cyber_source.rb | 34 +-
.../gateways/remote_cyber_source_test.rb | 48 +
.../CyberSourceTransaction_1.153.xsd | 4770 +++++++++++++++++
test/unit/gateways/cyber_source_test.rb | 56 +
5 files changed, 4907 insertions(+), 2 deletions(-)
create mode 100644 test/schema/cyber_source/CyberSourceTransaction_1.153.xsd
diff --git a/CHANGELOG b/CHANGELOG
index ccff5f329ba..0ca5c2a9397 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -22,6 +22,7 @@
* Adyen: Update to support normalized stored credential fields [molbrown] #3182
* VisaNet Peru: Always include DSC_COD_ACCION [bayprogrammer] #3174
* Adyen: Support adjust action [curiousepic] #3190
+* CyberSource: Add support for stored credentials [therufs] #3185
== Version 1.91.0 (February 22, 2019)
* WorldPay: Pull CVC and AVS Result from Response [nfarve] #3106
diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb
index 9bc89b747ce..6f8afd7e6a0 100644
--- a/lib/active_merchant/billing/gateways/cyber_source.rb
+++ b/lib/active_merchant/billing/gateways/cyber_source.rb
@@ -24,7 +24,7 @@ class CyberSourceGateway < Gateway
self.test_url = 'https://ics2wstesta.ic3.com/commerce/1.x/transactionProcessor'
self.live_url = 'https://ics2wsa.ic3.com/commerce/1.x/transactionProcessor'
- XSD_VERSION = '1.121'
+ XSD_VERSION = '1.153'
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb, :dankort, :maestro]
self.supported_countries = %w(US BR CA CN DK FI FR DE IN JP MX NO SE GB SG LB)
@@ -260,6 +260,7 @@ def build_auth_request(money, creditcard_or_reference, options)
add_threeds_services(xml, options)
add_payment_network_token(xml) if network_tokenization?(creditcard_or_reference)
add_business_rules_data(xml, creditcard_or_reference, options)
+ add_stored_credential_options(xml, options)
xml.target!
end
@@ -513,7 +514,24 @@ def add_auth_service(xml, payment_method, options)
if network_tokenization?(payment_method)
add_auth_network_tokenization(xml, payment_method, options)
else
- xml.tag! 'ccAuthService', {'run' => 'true'}
+ xml.tag! 'ccAuthService', {'run' => 'true'} do
+ check_for_stored_cred_commerce_indicator(xml, options)
+ end
+ end
+ end
+
+ def check_for_stored_cred_commerce_indicator(xml, options)
+ return unless options[:stored_credential]
+ if commerce_indicator(options)
+ xml.tag!('commerceIndicator', commerce_indicator(options))
+ end
+ end
+
+ def commerce_indicator(options)
+ return if options[:stored_credential][:initial_transaction]
+ case options[:stored_credential][:reason_type]
+ when 'installment' then 'install'
+ when 'recurring' then 'recurring'
end
end
@@ -680,6 +698,18 @@ def lookup_country_code(country_field)
country_code&.code(:alpha2)
end
+ def add_stored_credential_options(xml, options={})
+ return unless options[:stored_credential]
+ if options[:stored_credential][:initial_transaction]
+ xml.tag! 'subsequentAuthFirst', 'true'
+ elsif options[:stored_credential][:reason_type] == 'unscheduled'
+ xml.tag! 'subsequentAuth', 'true'
+ xml.tag! 'subsequentAuthTransactionID', options[:stored_credential][:network_transaction_id]
+ else
+ xml.tag! 'subsequentAuthTransactionID', options[:stored_credential][:network_transaction_id]
+ end
+ end
+
# Where we actually build the full SOAP request using builder
def build_request(body, options)
xml = Builder::XmlMarkup.new :indent => 2
diff --git a/test/remote/gateways/remote_cyber_source_test.rb b/test/remote/gateways/remote_cyber_source_test.rb
index eca6db9a23e..2eef0084348 100644
--- a/test/remote/gateways/remote_cyber_source_test.rb
+++ b/test/remote/gateways/remote_cyber_source_test.rb
@@ -432,6 +432,54 @@ def test_failed_3ds_validate_authorize_request
assert !response.success?
end
+ def test_successful_first_unscheduled_cof_transaction
+ @options[:stored_credential] = {
+ :initiator => 'cardholder',
+ :reason_type => 'unscheduled',
+ :initial_transaction => true,
+ :network_transaction_id => ''
+ }
+ assert response = @gateway.authorize(@amount, @credit_card, @options)
+ assert_equal 'Successful transaction', response.message
+ assert_success response
+ end
+
+ def test_successful_subsequent_unscheduled_cof_transaction
+ @options[:stored_credential] = {
+ :initiator => 'merchant',
+ :reason_type => 'unscheduled',
+ :initial_transaction => false,
+ :network_transaction_id => '016150703802094'
+ }
+ assert response = @gateway.authorize(@amount, @credit_card, @options)
+ assert_equal 'Successful transaction', response.message
+ assert_success response
+ end
+
+ def test_successful_first_recurring_cof_transaction
+ @options[:stored_credential] = {
+ :initiator => 'cardholder',
+ :reason_type => 'recurring',
+ :initial_transaction => true,
+ :network_transaction_id => ''
+ }
+ assert response = @gateway.authorize(@amount, @credit_card, @options)
+ assert_equal 'Successful transaction', response.message
+ assert_success response
+ end
+
+ def test_successful_subsequent_recurring_cof_transaction
+ @options[:stored_credential] = {
+ :initiator => 'merchant',
+ :reason_type => 'recurring',
+ :initial_transaction => false,
+ :network_transaction_id => '016150703802094'
+ }
+ assert response = @gateway.authorize(@amount, @credit_card, @options)
+ assert_equal 'Successful transaction', response.message
+ assert_success response
+ end
+
def pares
<<-PARES
eNqdmFuTqkgSgN+N8D90zD46M4B3J+yOKO6goNyFN25yEUHkUsiv31K7T/ec6dg9u75YlWRlZVVmflWw1uNrGNJa6DfX8G0thVXlRuFLErz+tgm67sRlbJr3ky4G9LWn8N/e1nughtVD4dFawFAodT8OqbBx4NLdj/o8y3JqKlavSLsNr1VS5G/En/if4zX20UUTXf3Yzeu3teuXpCC/TeerMTFfY+/d9Tm8CvRbEB7dJqvX2LO7xj7H7Zt7q0JOd0nwpo3VacjVvMc4pZcXfcjFpMqLc6UHr2vsrrEO3Dp8G+P4Ap+PZy/E9C+c+AtfrrGHfH25mwPnokG2CRxfY18Fa7Q71zD3b2/LKXr0o7cOu0uRh0gDre1He419+nZx8zf87z+kepeu9cPbuk7OX31a3X0iFmvsIV9XtVs31Zu9xt5ba99t2zcAAAksNjsr4N5MVctyGIaN2H6E1vpQWYd+8obPkFPo/zEKZFFxTer4fHf174I1dncFe4Tzba0lUY4mu4Yv3TnLURDjur78hWEQwj/h5M/iGmHIYRzDVxhSCKok+tdvz1FhIOTH4n8aRrl5kSe+myW9W6PEkMI6LoKXH759Z0ZX75YITGWoP5CpP3ximv9xl+ATYoZsYt8b/bKyX5nlZ2evlftHFbvEfYKfDL2t1fAY3jMifDFU4fW3f/1KZdBJFFb1/+PKhxtfLXzYM92sCd8qN5U5lrrNDZOFzkiecUIszvyCVJjXj3FPzTX2w/f3hT2j+GW3noobXm8xXJ3KK2aZztNbVdsLWbbOASZgzSY45eYqFNiK5ReRNLKbzvZSIDJj+zqBzIEkIx1L9ZTabYeDJa/MV51fF9A0dxDvxzf5CiPmttuVVBLHxmZSNp53lnBcJzh+IS3YpejKebycHjQlvMggwkvHdZjhYBHf8M1R4ikKjHxMGxlCfuCv+IqmxjTRk9GMnO2ynnXsWMvZSYdlk+Vmvpz1pVns4v05ugRWIGZNMhxUGLzoqs+VDe14Jtzli63TT06WBvpJg2+2UVLie+5mgGDlEVjip+7EmZhCvRdndtQHmKm0vaUDejhYTRgglbR5qysx6I1gf+vTyWJ3ahaXNOWBUrXRYnwasbKlbi3XsJLNuA3g6+uXrHqPzCa8PSNxmKElubX7bGmNl4Z+LbuIEJT8SrnXIMnd7IUOz8XLI4DX3192xucDQGlI8NmnijOiqR/+/rJ9lRCvCqSv6a+7OCl+f6FeDW2N/TzPY2IqvNbJEdUVwqUkCLTVo32vtAhAgQSRQAFNgLRii5vCEeLWl4HCsKQCoJMyWwmcOEAYDBlLlGlKHa2DLRnJ5nCAhkoksypca9nxKfDvUhIUEmvIsX9WL96ZrZTxqvYs82aPjQi1bz7NaBIJHhYpCEXplJ2GA8ea4a7lXCRVgUxk06ai0DSoDecg4wIvE3ZC0ooOQhbinUQzNyn1OzkFM5kWXSS7PWVKNxx8SCV+2VE9EJ8+2TrITF1ScEjBh3WBgere5bJWUpb3ld9lPAMd+e6JNxGQJS4F9vuKdObLigRGbj2LyPyznEmqAZmnxS0DO9o+iCfXmsUeRZIKIXW8Djy0Tw8rks4yX62omWctI2Oc5d7ZvKGokEIKZDI6lfEp4VYQJ+9RAGBHAWUJ7s+HAyraoB4DSmYSEIl4LuOMDMYCIZJ71pj7U99OwbapLHXFMLI66s7eKosO9qmWU56LwmJCul2tccin+XTKE4tV7EatfZaSNCQFH9bYXMNCetuoK2kl0SN6An3f3xmIMwGIT8KlZZS5pV/wpTIz8FzIF9fhIK6EhVLuzEDAg4MI+sybxjVzA/TGuEmsEHDZbZFBtjKxdKfgilSRZDLRoGjQmpWlzUEZGeJ+7CK6jCNPPgQe2ZInYsxH5YEWZoId7i5G2RJNax3USyCJo1OXS/jNLKdCtZiMSaCR4jKPaXvXqjl/6Et+OMBDRoth7MfSnLa3o7ItpxyV8CZcmjrVbJtyWykIypti158qotvx1VkJTm48GzeYBAUaKIAsJhUcDkL9mUO8KjEgBUCiIEdZFKcBjhsxAkpL5cjGxN7nzMYgZElgguweT/ugZg5F0s5BfGT2cGCPWdzRQfCwpkzRoa8YasSpRuIhBMUdRVxBGyn1FouIkytA/p5XKp4iAEO2AMZRSKQkIPDhgLC0ZSKTIV5IsXXC55ue+a566chmgKyLBwZfHlr7igWzo4Dn4m63WjXm3kMV3G7GNc3KJz9Ur5pt1AxBnafhdFf03bi2pnQlT8pZhWNWN7Mu+6RtWe/I6AbUz1wcFd6puR7FdrSYDwcYP5lcIsJ0ZNh7zOxcqcSFOjoUhaui645OzZ5qHGeazOnrqlxJ1+2eSJtTNOo7bBrgyvIanQyHuh9xP/PqO4BROI0Alp6/AOzbLYAh/asAo/t78d0L1ZdQ/mVerrZ+yoQSCZ+wiqCpjNmbw2WNbXW0NyZqFNzU0Uh0dHgTEUqqABnwhAENTjfNUu9WLs751LE60N8xINGsmvkTJTLOqzag/g624UDS72hjelmXP9GmKz9kEmf/R7DR4Ak2ZEmdQv7pz4YmzU84fQHYHWZ+DjomBcrTYiVRuig6KJ1R5Z5dhD5kiRQeewAg3Jqc2SOv+8ASIgVnYOQsf9558pl8OIIWJ4KCQ4u+QWKmIqgK7g5MOZ+0XJ4jemPuucVRUPf5rma5LL6U7RxuXQ4ax+NodrIvC4k53wRDanhGdkGrnhJRq2/UajccHM67ebQItvRyk3PEnFrl1y5dFuT0PEFYMqbn0dG2dlx+js/7Yt7HZFuSVXvsV5OYiTYHec4EG7kxo+GgKfvamoPtDhry3CPLjaJN7okBAJeGPTl7z5+AgQolAQC3wBZtwRGA7U2ViJFJcmnxxgo+jjHdwGGkjs0G5UYccOYJ7XDmP7IgS+9QkEj8YY2OFIsk1WUi3MTJQTed7U3A2YUW3Vh3OND14irp4PiAhSYxHA2siFSZKN1jhOVFme2MOa7LKcst80SEKId+OjqM+9GBjoxIIZfNxsBWkyVmbmYUa4iJghm7gzu+8jeiAxMvJwhiR80zcl4FSr2Q01jx442ebHWlimZHrNQymRgOto7dtFMgbPTdxmG4ayKWQJ+Lp3K0OcQ1rU2jtLyw+XKXOqWoLo7ulVFHgTebYaLWXho+Sr1OPy7AcHCGCar/njbEqWk2ib1Z6iWb3cbm1eTZ6PVXIdCmCAJJ+AEBEYh0tx8xmanGGwngHKWVnCZ4E/qRkgaQ+OgfpYOS+5vi+XoroMHnreA/3XIQBP7LPefzlvPj1oBuOd3zlsOKrYegcC+p4YCPfRmFv5NSZiLpNpR1cLPusvQhw3/IUnIqKRWknr5yDBRNo2dkCVSPmdGNAUBGH8cXr2f29z15gBBCTrfuBb66/SokhoP/gglTIqUPSEjvkNC88QpHo0kEguNHRIaDj5igJAWIBjKgKTJRNmSkUNPwevRaVWGow9Vezev9QtlZJaWDcZpjs3SywiKsxD0p8RVKHQ6u49ExWZz6zY28KaVz4ntbnC0nGDi0G9GFeM2id5cJkwbRKezMS2ZrYcnsZzuDlqaRqx0XJS9F5h6VycYt8nF7TfnOCimzY5NpNyWLIBPzY4ZhNZdu8FKm+3pxwqZyqLHWzSsT5f2mQACop8+THcXu42wXhB5bmeepaHFBHFcOzM7lZZr4DPOPs/073eHgQ5sGD22dBAZE4SSx/vtijxSQsEuSy0gWSqEshkxiw9xVEJhqg78mbmrU3nxGzJe1fLxwDDO59rxHzgrpzPiHrvK8WlDJpo33y3MdhU7GZ81W6fFSHfnjYpbBcDjo4CLNjoAvSxRlLaU2W76plphc5At/tEhKra8VXiLN0FuM59Ddt5zgHZitL1vFyttHamkZ44sToxvD5ubwK/BtsWOfr03Yj1epz5esx7ekx8eu+/ePrx/B/g0UAjN8
diff --git a/test/schema/cyber_source/CyberSourceTransaction_1.153.xsd b/test/schema/cyber_source/CyberSourceTransaction_1.153.xsd
new file mode 100644
index 00000000000..1bd9f4a1b04
--- /dev/null
+++ b/test/schema/cyber_source/CyberSourceTransaction_1.153.xsd
@@ -0,0 +1,4770 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/unit/gateways/cyber_source_test.rb b/test/unit/gateways/cyber_source_test.rb
index 77602767222..cbec9080e33 100644
--- a/test/unit/gateways/cyber_source_test.rb
+++ b/test/unit/gateways/cyber_source_test.rb
@@ -425,6 +425,62 @@ def test_successful_auth_with_network_tokenization_for_amex
assert_success response
end
+ def test_successful_auth_first_unscheduled_stored_cred
+ @gateway.stubs(:ssl_post).returns(successful_authorization_response)
+ @options[:stored_credential] = {
+ :initiator => 'cardholder',
+ :reason_type => 'unscheduled',
+ :initial_transaction => true,
+ :network_transaction_id => ''
+ }
+ assert response = @gateway.authorize(@amount, @credit_card, @options)
+ assert_equal Response, response.class
+ assert response.success?
+ assert response.test?
+ end
+
+ def test_successful_auth_subsequent_unscheduled_stored_cred
+ @gateway.stubs(:ssl_post).returns(successful_authorization_response)
+ @options[:stored_credential] = {
+ :initiator => 'merchant',
+ :reason_type => 'unscheduled',
+ :initial_transaction => false,
+ :network_transaction_id => '016150703802094'
+ }
+ assert response = @gateway.authorize(@amount, @credit_card, @options)
+ assert_equal Response, response.class
+ assert response.success?
+ assert response.test?
+ end
+
+ def test_successful_auth_first_recurring_stored_cred
+ @gateway.stubs(:ssl_post).returns(successful_authorization_response)
+ @options[:stored_credential] = {
+ :initiator => 'cardholder',
+ :reason_type => 'recurring',
+ :initial_transaction => true,
+ :network_transaction_id => ''
+ }
+ assert response = @gateway.authorize(@amount, @credit_card, @options)
+ assert_equal Response, response.class
+ assert response.success?
+ assert response.test?
+ end
+
+ def test_successful_auth_subsequent_recurring_stored_cred
+ @gateway.stubs(:ssl_post).returns(successful_authorization_response)
+ @options[:stored_credential] = {
+ :initiator => 'merchant',
+ :reason_type => 'recurring',
+ :initial_transaction => false,
+ :network_transaction_id => '016150703802094'
+ }
+ assert response = @gateway.authorize(@amount, @credit_card, @options)
+ assert_equal Response, response.class
+ assert response.success?
+ assert response.test?
+ end
+
def test_nonfractional_currency_handling
@gateway.expects(:ssl_post).with do |host, request_body|
assert_match %r(1), request_body
From 62d22bb73844f02783c44555d0f6a1e033d657c1 Mon Sep 17 00:00:00 2001
From: Krystian Czesak
Date: Mon, 8 Apr 2019 14:54:01 -0400
Subject: [PATCH 0316/2234] Release v.1.92.0
---
CHANGELOG | 2 ++
lib/active_merchant/version.rb | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 0ca5c2a9397..15faa09cb92 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,8 @@
= ActiveMerchant CHANGELOG
== HEAD
+
+== Version 1.91.0 (April 8, 2019)
* BluePay: Send customer IP address when provided [jknipp] #3149
* PaymentExpress: Use ip field for client_info field [jknipp] #3150
* Bambora Asia-Pacific: Adds Store [molbrown] #3147
diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb
index e9a183351bf..8b854fa637f 100644
--- a/lib/active_merchant/version.rb
+++ b/lib/active_merchant/version.rb
@@ -1,3 +1,3 @@
module ActiveMerchant
- VERSION = '1.91.0'
+ VERSION = '1.92.0'
end
From 1c57a64b7b2b283b67f8c424008baa71b3ef380b Mon Sep 17 00:00:00 2001
From: Jason Webster
Date: Thu, 11 Apr 2019 13:49:41 -0400
Subject: [PATCH 0317/2234] Do not consider a refund unsuccessful if only
refunding the fee failed (#3188)
Fixes https://github.com/activemerchant/active_merchant/issues/3116
When specifying the `refund_fee_amount` on a Refund using the Stripe
gateway, Active Merchant makes three different API requests:
1. Issue the actual refund against the charge
2. Fetch the charge to get the application fee identifier
3. Issue the application fee refund against the original application fee
Currently, if either 2 or 3 fail while 1 succeeds, the `#refund`
method's response is a failure, which is not true. This process is not
transactional. The refund had succeeded and is not rolled back, which
isn't possible to do anyway.
---
CHANGELOG | 2 +
.../billing/gateways/stripe.rb | 41 ++++++-------------
test/unit/gateways/stripe_test.rb | 11 +++--
3 files changed, 20 insertions(+), 34 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 15faa09cb92..b1f5578273d 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,8 @@
== HEAD
+* Stripe: Do not consider a refund unsuccessful if only refunding the fee failed [jasonwebster] #3188
+
== Version 1.91.0 (April 8, 2019)
* BluePay: Send customer IP address when provided [jknipp] #3149
* PaymentExpress: Use ip field for client_info field [jknipp] #3150
diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb
index 4d152fe1939..ea9fed24bb6 100644
--- a/lib/active_merchant/billing/gateways/stripe.rb
+++ b/lib/active_merchant/billing/gateways/stripe.rb
@@ -150,14 +150,21 @@ def refund(money, identification, options = {})
post[:reason] = options[:reason] if options[:reason]
post[:expand] = [:charge]
- MultiResponse.run(:first) do |r|
- r.process { commit(:post, "charges/#{CGI.escape(identification)}/refunds", post, options) }
+ response = commit(:post, "charges/#{CGI.escape(identification)}/refunds", post, options)
- if options[:refund_fee_amount] && options[:refund_fee_amount].to_s != '0'
- r.process { fetch_application_fee(identification, options) }
- r.process { refund_application_fee(options[:refund_fee_amount].to_i, application_fee_from_response(r.responses.last), options) }
+ if options[:refund_fee_amount] && options[:refund_fee_amount].to_s != '0'
+ charge = api_request(:get, "charges/#{CGI.escape(identification)}", nil, options)
+
+ if application_fee = charge['application_fee']
+ fee_refund_options = {
+ currency: options[:currency], # currency isn't used by Stripe here, but we need it for #add_amount
+ key: @fee_refund_api_key
+ }
+ refund_application_fee(options[:refund_fee_amount].to_i, application_fee, fee_refund_options)
end
end
+
+ response
end
def verify(payment, options = {})
@@ -168,21 +175,10 @@ def verify(payment, options = {})
end
end
- def application_fee_from_response(response)
- return unless response.success?
- response.params['application_fee'] unless response.params['application_fee'].empty?
- end
-
def refund_application_fee(money, identification, options = {})
- return Response.new(false, 'Application fee id could not be found') unless identification
-
post = {}
add_amount(post, money, options)
- options[:key] = @fee_refund_api_key if @fee_refund_api_key
- options.delete(:stripe_account)
-
- refund_fee = commit(:post, "application_fees/#{CGI.escape(identification)}/refunds", post, options)
- application_fee_response!(refund_fee, "Application fee could not be refunded: #{refund_fee.message}")
+ commit(:post, "application_fees/#{CGI.escape(identification)}/refunds", post, options)
end
# Note: creating a new credit card will not change the customer's existing default credit card (use :set_default => true)
@@ -516,17 +512,6 @@ def add_emv_metadata(post, creditcard)
post[:metadata][:card_read_method] = creditcard.read_method if creditcard.respond_to?(:read_method)
end
- def fetch_application_fee(identification, options = {})
- options[:key] = @fee_refund_api_key
-
- fetch_charge = commit(:get, "charges/#{CGI.escape(identification)}", nil, options)
- application_fee_response!(fetch_charge, "Application fee id could not be retrieved: #{fetch_charge.message}")
- end
-
- def application_fee_response!(response, message)
- response.success? ? response : Response.new(false, message)
- end
-
def parse(body)
JSON.parse(body)
end
diff --git a/test/unit/gateways/stripe_test.rb b/test/unit/gateways/stripe_test.rb
index 76e7231c712..9dffa51d540 100644
--- a/test/unit/gateways/stripe_test.rb
+++ b/test/unit/gateways/stripe_test.rb
@@ -686,7 +686,7 @@ def test_successful_refund_with_refund_fee_amount
end
# What is the significance of this??? it's to test that the first response is used as primary. so identical to above with an extra assertion
- def test_refund_with_fee_response_gives_a_charge_authorization
+ def test_refund_with_fee_response_responds_with_the_refund_authorization
s = sequence('request')
@gateway.expects(:ssl_request).returns(successful_partially_refunded_response).in_sequence(s)
@gateway.expects(:ssl_request).returns(successful_fetch_application_fee_response).in_sequence(s)
@@ -697,24 +697,23 @@ def test_refund_with_fee_response_gives_a_charge_authorization
assert_equal 're_test_refund', response.authorization
end
- def test_unsuccessful_refund_with_refund_fee_amount_when_application_fee_id_not_found
+ def test_successful_refund_with_failed_fee_refund_fetch
s = sequence('request')
@gateway.expects(:ssl_request).returns(successful_partially_refunded_response).in_sequence(s)
@gateway.expects(:ssl_request).returns(unsuccessful_fetch_application_fee_response).in_sequence(s)
assert response = @gateway.refund(@refund_amount, 'ch_test_charge', :refund_fee_amount => 100)
- assert_failure response
- assert_match(/^Application fee id could not be retrieved/, response.message)
+ assert_success response
end
- def test_unsuccessful_refund_with_refund_fee_amount_when_refunding_application_fee
+ def test_successful_refund_with_failed_fee_refund
s = sequence('request')
@gateway.expects(:ssl_request).returns(successful_partially_refunded_response).in_sequence(s)
@gateway.expects(:ssl_request).returns(successful_fetch_application_fee_response).in_sequence(s)
@gateway.expects(:ssl_request).returns(generic_error_response).in_sequence(s)
assert response = @gateway.refund(@refund_amount, 'ch_test_charge', :refund_fee_amount => 100)
- assert_failure response
+ assert_success response
end
def test_successful_verify
From ecaaa2268c131711dd3bd7a27ba379fc09460549 Mon Sep 17 00:00:00 2001
From: Jared Knipp
Date: Tue, 9 Apr 2019 15:19:29 -0500
Subject: [PATCH 0318/2234] Stripe: Fix webhook creation for connected account
Don't send the Stripe connect account id when creating webhooks. Instead
indicate the webhook should receive events from the connected
account, if the stripe account is present.
ECS-242
Unit:
134 tests, 719 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
67 tests, 313 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote 3DS Tests:
7 tests, 26 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote Connect Tests:
4 tests, 14 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
close #3193
---
CHANGELOG | 2 +-
lib/active_merchant/billing/gateways/stripe.rb | 2 ++
test/remote/gateways/remote_stripe_3ds_test.rb | 15 +++++++++++++++
3 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index b1f5578273d..f5907e18e73 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,8 +1,8 @@
= ActiveMerchant CHANGELOG
== HEAD
-
* Stripe: Do not consider a refund unsuccessful if only refunding the fee failed [jasonwebster] #3188
+* Stripe: Fix webhook creation for connected account [jknipp] #3193
== Version 1.91.0 (April 8, 2019)
* BluePay: Send customer IP address when provided [jknipp] #3149
diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb
index ea9fed24bb6..cde3f0b6d13 100644
--- a/lib/active_merchant/billing/gateways/stripe.rb
+++ b/lib/active_merchant/billing/gateways/stripe.rb
@@ -313,6 +313,8 @@ def create_webhook_endpoint(options, events)
post = {}
post[:url] = options[:callback_url]
post[:enabled_events] = events
+ post[:connect] = true if options[:stripe_account]
+ options.delete(:stripe_account)
commit(:post, 'webhook_endpoints', post, options)
end
diff --git a/test/remote/gateways/remote_stripe_3ds_test.rb b/test/remote/gateways/remote_stripe_3ds_test.rb
index ec9650a544e..8a1a8a39c36 100644
--- a/test/remote/gateways/remote_stripe_3ds_test.rb
+++ b/test/remote/gateways/remote_stripe_3ds_test.rb
@@ -17,6 +17,8 @@ def setup
}
@credit_card = credit_card('4000000000003063')
@non_3ds_card = credit_card('378282246310005')
+
+ @stripe_account = fixtures(:stripe_destination)[:stripe_user_id]
end
def test_create_3ds_card_source
@@ -53,10 +55,23 @@ def test_create_webhook_endpoint
assert_equal @options[:callback_url], response.params['url']
end
+ def test_create_webhook_endpoint_on_connected_account
+ response = @gateway.send(:create_webhook_endpoint, @options.merge({stripe_account: @stripe_account}), ['source.chargeable'])
+ assert_includes response.params['enabled_events'], 'source.chargeable'
+ assert_equal @options[:callback_url], response.params['url']
+ end
+
def test_delete_webhook_endpoint
webhook = @gateway.send(:create_webhook_endpoint, @options, ['source.chargeable'])
response = @gateway.send(:delete_webhook_endpoint, @options.merge(:webhook_id => webhook.params['id']))
assert_equal response.params['id'], webhook.params['id']
assert_equal true, response.params['deleted']
end
+
+ def test_delete_webhook_endpoint_on_connected_account
+ webhook = @gateway.send(:create_webhook_endpoint, @options.merge({stripe_account: @stripe_account}), ['source.chargeable'])
+ response = @gateway.send(:delete_webhook_endpoint, @options.merge(:webhook_id => webhook.params['id']))
+ assert_equal response.params['id'], webhook.params['id']
+ assert_equal true, response.params['deleted']
+ end
end
From 33c66d8453c60b33bcbf9b51f80407284751807e Mon Sep 17 00:00:00 2001
From: David Santoso
Date: Mon, 8 Apr 2019 16:49:14 -0400
Subject: [PATCH 0319/2234] Adyen: Upgrade to v40 API
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The primary driver behind this is to ensure that we can use this
adapater for 3DS 2.0 transactions given the appropriate fields are in
place. However, considering this is quite a major jump in version
support it deserves it's own commit.
Note that the two remote tests that have been changed are because the
Adyen API no longer seems to return errors for a blank state or country
in the billing address. However I should note that looking at the Adyen
API reference for billingAddress, it appears as though country is
required. Though that may be a typo in their documentation.
https://docs.adyen.com/api-explorer/#/Payment/v40/authorise
Remote Test Run:
➜ ruby -Itest test/remote/gateways/remote_adyen_test.rb
Loaded suite test/remote/gateways/remote_adyen_test
Started
.......................................................
Finished in 62.034313 seconds.
55 tests, 161 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
0.89 tests/s, 2.60 assertions/s
---
lib/active_merchant/billing/gateways/adyen.rb | 4 ++--
test/remote/gateways/remote_adyen_test.rb | 10 ++++------
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index 0b52f43c6de..770d85c0c08 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -4,8 +4,8 @@ class AdyenGateway < Gateway
# we recommend setting up merchant-specific endpoints.
# https://docs.adyen.com/developers/api-manual#apiendpoints
- self.test_url = 'https://pal-test.adyen.com/pal/servlet/Payment/v18'
- self.live_url = 'https://pal-live.adyen.com/pal/servlet/Payment/v18'
+ self.test_url = 'https://pal-test.adyen.com/pal/servlet/Payment/v40'
+ self.live_url = 'https://pal-live.adyen.com/pal/servlet/Payment/v40'
self.supported_countries = ['AT', 'AU', 'BE', 'BG', 'BR', 'CH', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GB', 'GI', 'GR', 'HK', 'HU', 'IE', 'IS', 'IT', 'LI', 'LT', 'LU', 'LV', 'MC', 'MT', 'MX', 'NL', 'NO', 'PL', 'PT', 'RO', 'SE', 'SG', 'SK', 'SI', 'US']
self.default_currency = 'USD'
diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb
index 7c27a48a1f7..c0f0cc4bbfa 100644
--- a/test/remote/gateways/remote_adyen_test.rb
+++ b/test/remote/gateways/remote_adyen_test.rb
@@ -501,18 +501,16 @@ def test_missing_state_for_purchase
assert_success response
end
- def test_invalid_country_for_purchase
+ def test_blank_country_for_purchase
@options[:billing_address][:country] = ''
response = @gateway.authorize(@amount, @credit_card, @options)
- assert_failure response
- assert_match Gateway::STANDARD_ERROR_CODE[:incorrect_address], response.error_code
+ assert_success response
end
- def test_invalid_state_for_purchase
+ def test_blank_state_for_purchase
@options[:billing_address][:state] = ''
response = @gateway.authorize(@amount, @credit_card, @options)
- assert_failure response
- assert_match Gateway::STANDARD_ERROR_CODE[:incorrect_address], response.error_code
+ assert_success response
end
def test_missing_phone_for_purchase
From defcfb78de6cee869398ff9fcee8c1ad9b45120a Mon Sep 17 00:00:00 2001
From: David Santoso
Date: Tue, 16 Apr 2019 10:10:54 -0400
Subject: [PATCH 0320/2234] Update the changelog with previous Adyen update
---
CHANGELOG | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG b/CHANGELOG
index f5907e18e73..063bb71aaaa 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -3,6 +3,7 @@
== HEAD
* Stripe: Do not consider a refund unsuccessful if only refunding the fee failed [jasonwebster] #3188
* Stripe: Fix webhook creation for connected account [jknipp] #3193
+* Adyen: Upgrade to v40 API version [davidsantoso] #3192
== Version 1.91.0 (April 8, 2019)
* BluePay: Send customer IP address when provided [jknipp] #3149
From 03c6fa30731a0881cc4817c318ae8d087b1021a6 Mon Sep 17 00:00:00 2001
From: Filipe Costa
Date: Thu, 18 Apr 2019 10:00:29 -0400
Subject: [PATCH 0321/2234] Release v1.93.0
---
CHANGELOG | 3 ++-
lib/active_merchant/version.rb | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 063bb71aaaa..942449d13e1 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,11 +1,12 @@
= ActiveMerchant CHANGELOG
== HEAD
+== Version 1.93.0 (April 18, 2019)
* Stripe: Do not consider a refund unsuccessful if only refunding the fee failed [jasonwebster] #3188
* Stripe: Fix webhook creation for connected account [jknipp] #3193
* Adyen: Upgrade to v40 API version [davidsantoso] #3192
-== Version 1.91.0 (April 8, 2019)
+== Version 1.92.0 (April 8, 2019)
* BluePay: Send customer IP address when provided [jknipp] #3149
* PaymentExpress: Use ip field for client_info field [jknipp] #3150
* Bambora Asia-Pacific: Adds Store [molbrown] #3147
diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb
index 8b854fa637f..a2e7f741aee 100644
--- a/lib/active_merchant/version.rb
+++ b/lib/active_merchant/version.rb
@@ -1,3 +1,3 @@
module ActiveMerchant
- VERSION = '1.92.0'
+ VERSION = '1.93.0'
end
From 88eb8960f7a91b218f27a893cf888bfb297691ae Mon Sep 17 00:00:00 2001
From: dtykocki
Date: Mon, 15 Apr 2019 14:30:42 -0400
Subject: [PATCH 0322/2234] Fix number lengths for both VR and Sodexo
When first implemented, we were under the impression that these card
types only supported 14 digits. After some production usage and confirmation
from the card issuers, it turns out they only support 16 digits. This
modifies the brand detection mechanism ensure 16 digit numbers are
supported.
Unit:
4044 tests, 69009 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications
100% passed
Mundipagg Remote:
23 tests, 58 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 2 +
.../billing/credit_card_methods.rb | 4 +-
test/remote/gateways/remote_mundipagg_test.rb | 43 ++++++++++++++++---
test/unit/credit_card_methods_test.rb | 4 +-
4 files changed, 42 insertions(+), 11 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 942449d13e1..bdb426a5ac8 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,8 @@
= ActiveMerchant CHANGELOG
== HEAD
+* Mundipagg: Fix number lengths for both VR and Sodexo [dtykocki] #3195
+
== Version 1.93.0 (April 18, 2019)
* Stripe: Do not consider a refund unsuccessful if only refunding the fee failed [jasonwebster] #3188
* Stripe: Fix webhook creation for connected account [jknipp] #3193
diff --git a/lib/active_merchant/billing/credit_card_methods.rb b/lib/active_merchant/billing/credit_card_methods.rb
index 47ad881355f..2e18135062b 100644
--- a/lib/active_merchant/billing/credit_card_methods.rb
+++ b/lib/active_merchant/billing/credit_card_methods.rb
@@ -13,8 +13,8 @@ module CreditCardMethods
'dankort' => ->(num) { num =~ /^5019\d{12}$/ },
'maestro' => ->(num) { (12..19).cover?(num&.size) && in_bin_range?(num.slice(0, 6), MAESTRO_RANGES) },
'forbrugsforeningen' => ->(num) { num =~ /^600722\d{10}$/ },
- 'sodexo' => ->(num) { num =~ /^(606071|603389|606070|606069|606068|600818)\d{8}$/ },
- 'vr' => ->(num) { num =~ /^(627416|637036)\d{8}$/ },
+ 'sodexo' => ->(num) { num =~ /^(606071|603389|606070|606069|606068|600818)\d{10}$/ },
+ 'vr' => ->(num) { num =~ /^(627416|637036)\d{10}$/ },
'carnet' => lambda { |num|
num&.size == 16 && (
in_bin_range?(num.slice(0, 6), CARNET_RANGES) ||
diff --git a/test/remote/gateways/remote_mundipagg_test.rb b/test/remote/gateways/remote_mundipagg_test.rb
index 39846fea222..bc74b69b5f6 100644
--- a/test/remote/gateways/remote_mundipagg_test.rb
+++ b/test/remote/gateways/remote_mundipagg_test.rb
@@ -7,7 +7,11 @@ def setup
@amount = 100
@credit_card = credit_card('4000100011112224')
@declined_card = credit_card('4000300011112220')
- @voucher = credit_card('60607044957644', brand: 'sodexo')
+ @sodexo_voucher = credit_card('6060704495764400', brand: 'sodexo')
+ # Mundipagg only allows certain card numbers for success and failure scenarios.
+ # As such, we cannot use a card number with a BIN belonging to VR.
+ # See https://docs.mundipagg.com/docs/simulador-de-voucher.
+ @vr_voucher = credit_card('4000000000000010', brand: 'vr')
@options = {
billing_address: address({neighborhood: 'Sesame Street'}),
description: 'Store Purchase'
@@ -39,9 +43,16 @@ def test_successful_purchase_with_more_options
assert_success response
end
- def test_successful_purchase_with_voucher
+ def test_successful_purchase_with_sodexo_voucher
@options.update(holder_document: '93095135270')
- response = @gateway.purchase(@amount, @voucher, @options)
+ response = @gateway.purchase(@amount, @sodexo_voucher, @options)
+ assert_success response
+ assert_equal 'Simulator|Transação de simulação autorizada com sucesso', response.message
+ end
+
+ def test_successful_purchase_with_vr_voucher
+ @options.update(holder_document: '93095135270')
+ response = @gateway.purchase(@amount, @vr_voucher, @options)
assert_success response
assert_equal 'Simulator|Transação de simulação autorizada com sucesso', response.message
end
@@ -111,18 +122,36 @@ def test_successful_void
assert_success void
end
- def test_successful_void_with_voucher
+ def test_successful_void_with_sodexo_voucher
@options.update(holder_document: '93095135270')
- auth = @gateway.purchase(@amount, @voucher, @options)
+ auth = @gateway.purchase(@amount, @sodexo_voucher, @options)
assert_success auth
assert void = @gateway.void(auth.authorization)
assert_success void
end
- def test_successful_refund_with_voucher
+ def test_successful_void_with_vr_voucher
+ @options.update(holder_document: '93095135270')
+ auth = @gateway.purchase(@amount, @vr_voucher, @options)
+ assert_success auth
+
+ assert void = @gateway.void(auth.authorization)
+ assert_success void
+ end
+
+ def test_successful_refund_with_sodexo_voucher
+ @options.update(holder_document: '93095135270')
+ auth = @gateway.purchase(@amount, @sodexo_voucher, @options)
+ assert_success auth
+
+ assert void = @gateway.refund(1, auth.authorization)
+ assert_success void
+ end
+
+ def test_successful_refund_with_vr_voucher
@options.update(holder_document: '93095135270')
- auth = @gateway.purchase(@amount, @voucher, @options)
+ auth = @gateway.purchase(@amount, @vr_voucher, @options)
assert_success auth
assert void = @gateway.refund(1, auth.authorization)
diff --git a/test/unit/credit_card_methods_test.rb b/test/unit/credit_card_methods_test.rb
index 24e643e8eb4..1eab03bb838 100644
--- a/test/unit/credit_card_methods_test.rb
+++ b/test/unit/credit_card_methods_test.rb
@@ -125,11 +125,11 @@ def test_should_detect_forbrugsforeningen
end
def test_should_detect_sodexo_card
- assert_equal 'sodexo', CreditCard.brand?('60606944957644')
+ assert_equal 'sodexo', CreditCard.brand?('6060694495764400')
end
def test_should_detect_vr_card
- assert_equal 'vr', CreditCard.brand?('63703644957644')
+ assert_equal 'vr', CreditCard.brand?('6370364495764400')
end
def test_should_detect_elo_card
From 5e981528eba280e1bddcbef656aaa60813a1c318 Mon Sep 17 00:00:00 2001
From: Jared Knipp
Date: Tue, 23 Apr 2019 15:48:23 -0500
Subject: [PATCH 0323/2234] Stripe: Support show and list webhook endpoints
Add support for listing and showing webhook endpoints.
ECS-289
Unit:
134 tests, 718 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
67 tests, 313 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote Stripe 3DS:
10 tests, 50 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
closes #3196
---
CHANGELOG | 1 +
.../billing/gateways/stripe.rb | 12 ++++
.../remote/gateways/remote_stripe_3ds_test.rb | 55 +++++++++++++++++++
3 files changed, 68 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index bdb426a5ac8..5bc8953204a 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,7 @@
== HEAD
* Mundipagg: Fix number lengths for both VR and Sodexo [dtykocki] #3195
+* Stripe: Support show and list webhook endpoints [jknipp] #3196
== Version 1.93.0 (April 18, 2019)
* Stripe: Do not consider a refund unsuccessful if only refunding the fee failed [jasonwebster] #3188
diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb
index cde3f0b6d13..33c51a01fc4 100644
--- a/lib/active_merchant/billing/gateways/stripe.rb
+++ b/lib/active_merchant/billing/gateways/stripe.rb
@@ -322,6 +322,18 @@ def delete_webhook_endpoint(options)
commit(:delete, "webhook_endpoints/#{options[:webhook_id]}", {}, options)
end
+ def show_webhook_endpoint(options)
+ options.delete(:stripe_account)
+ commit(:get, "webhook_endpoints/#{options[:webhook_id]}", nil, options)
+ end
+
+ def list_webhook_endpoints(options)
+ params = {}
+ params[:limit] = options[:limit] if options[:limit]
+ options.delete(:stripe_account)
+ commit(:get, "webhook_endpoints?#{post_data(params)}", nil, options)
+ end
+
def create_post_for_auth_or_purchase(money, payment, options)
post = {}
diff --git a/test/remote/gateways/remote_stripe_3ds_test.rb b/test/remote/gateways/remote_stripe_3ds_test.rb
index 8a1a8a39c36..151b9d772f0 100644
--- a/test/remote/gateways/remote_stripe_3ds_test.rb
+++ b/test/remote/gateways/remote_stripe_3ds_test.rb
@@ -53,12 +53,22 @@ def test_create_webhook_endpoint
response = @gateway.send(:create_webhook_endpoint, @options, ['source.chargeable'])
assert_includes response.params['enabled_events'], 'source.chargeable'
assert_equal @options[:callback_url], response.params['url']
+ assert_equal 'enabled', response.params['status']
+ assert_nil response.params['application']
+
+ deleted_response = @gateway.send(:delete_webhook_endpoint, @options.merge(:webhook_id => response.params['id']))
+ assert_equal true, deleted_response.params['deleted']
end
def test_create_webhook_endpoint_on_connected_account
response = @gateway.send(:create_webhook_endpoint, @options.merge({stripe_account: @stripe_account}), ['source.chargeable'])
assert_includes response.params['enabled_events'], 'source.chargeable'
assert_equal @options[:callback_url], response.params['url']
+ assert_equal 'enabled', response.params['status']
+ assert_not_nil response.params['application']
+
+ deleted_response = @gateway.send(:delete_webhook_endpoint, @options.merge(:webhook_id => response.params['id']))
+ assert_equal true, deleted_response.params['deleted']
end
def test_delete_webhook_endpoint
@@ -74,4 +84,49 @@ def test_delete_webhook_endpoint_on_connected_account
assert_equal response.params['id'], webhook.params['id']
assert_equal true, response.params['deleted']
end
+
+ def test_show_webhook_endpoint
+ webhook = @gateway.send(:create_webhook_endpoint, @options, ['source.chargeable'])
+ response = @gateway.send(:show_webhook_endpoint, @options.merge(:webhook_id => webhook.params['id']))
+ assert_includes response.params['enabled_events'], 'source.chargeable'
+ assert_equal @options[:callback_url], response.params['url']
+ assert_equal 'enabled', response.params['status']
+ assert_nil response.params['application']
+
+ deleted_response = @gateway.send(:delete_webhook_endpoint, @options.merge(:webhook_id => response.params['id']))
+ assert_equal true, deleted_response.params['deleted']
+ end
+
+ def test_show_webhook_endpoint_on_connected_account
+ webhook = @gateway.send(:create_webhook_endpoint, @options.merge({stripe_account: @stripe_account}), ['source.chargeable'])
+ response = @gateway.send(:show_webhook_endpoint, @options.merge({:webhook_id => webhook.params['id'], stripe_account: @stripe_account}))
+
+ assert_includes response.params['enabled_events'], 'source.chargeable'
+ assert_equal @options[:callback_url], response.params['url']
+ assert_equal 'enabled', response.params['status']
+ assert_not_nil response.params['application']
+
+ deleted_response = @gateway.send(:delete_webhook_endpoint, @options.merge(:webhook_id => response.params['id']))
+ assert_equal true, deleted_response.params['deleted']
+ end
+
+ def test_list_webhook_endpoints
+ webhook1 = @gateway.send(:create_webhook_endpoint, @options, ['source.chargeable'])
+ webhook2 = @gateway.send(:create_webhook_endpoint, @options.merge({stripe_account: @stripe_account}), ['source.chargeable'])
+ assert_nil webhook1.params['application']
+ assert_not_nil webhook2.params['application']
+
+ response = @gateway.send(:list_webhook_endpoints, @options.merge({limit: 100}))
+ assert_not_nil response.params
+ assert_equal 'list', response.params['object']
+ assert response.params['data'].size >= 2
+ webhook_id_set = Set.new(response.params['data'].map { |webhook| webhook['id'] }.uniq)
+ assert Set[webhook1.params['id'], webhook2.params['id']].subset?(webhook_id_set)
+
+ deleted_response1 = @gateway.send(:delete_webhook_endpoint, @options.merge(:webhook_id => webhook1.params['id']))
+ deleted_response2 = @gateway.send(:delete_webhook_endpoint, @options.merge(:webhook_id => webhook2.params['id']))
+ assert_equal true, deleted_response1.params['deleted']
+ assert_equal true, deleted_response2.params['deleted']
+ end
+
end
From 3bdd079c81d5b7dcd0a7fff4dc29390d09630aa8 Mon Sep 17 00:00:00 2001
From: Nicolas Maalouf
Date: Thu, 25 Apr 2019 17:38:58 +0100
Subject: [PATCH 0324/2234] Migrate CheckoutV2Gateway integration to Unified
Payments Api and add 3DS support with third party MPI (#3181)
* Fix Checkout.com V2 Sandbox URL
* Fix success response code validation
* Fix success response code validation v2
* Improve success response validation logic
* Add list of currencies without fractions
* Add localized_amount support to add_invoice function
* Remove redefinition of currencies_without_fractions
* Add test for Void Authorize with AVS rule
* Align with main repo
* Migrate to unified payments API
* Add 3rd party MPI 3DS support
* Migrate tests to Unified Payments API
* Add third party MPI tests
* Fix 3DS test syntax error
* Syntax fixes
* Fix metadata array initialisation
* Test fixes
* Update response success validation. Fix test
* Fix billing_descriptor conditional inclusion
* Improve payment source identification
* Refund payment ID fix
* Fix setting response ID for capture actions
* Fix remote tests
* Retrieve payment ID from capture responses
* Fix 3DS payload handling
* Fix 3DS syntax error
* Move capture conditional payment ID to successful responses only
* Fix condition to parse payment ID from href link
* Remove trailing whitespaces
* Empty line removed
* Fix metadata
---
.../billing/gateways/checkout_v2.rb | 115 ++++---
.../gateways/remote_checkout_v2_test.rb | 37 +-
test/unit/gateways/checkout_v2_test.rb | 317 ++++++++----------
3 files changed, 234 insertions(+), 235 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/checkout_v2.rb b/lib/active_merchant/billing/gateways/checkout_v2.rb
index 6289c2a0811..06538a0a806 100644
--- a/lib/active_merchant/billing/gateways/checkout_v2.rb
+++ b/lib/active_merchant/billing/gateways/checkout_v2.rb
@@ -1,15 +1,15 @@
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
class CheckoutV2Gateway < Gateway
- self.display_name = 'Checkout.com V2 Gateway'
+ self.display_name = 'Checkout.com Unified Payments'
self.homepage_url = 'https://www.checkout.com/'
- self.live_url = 'https://api2.checkout.com/v2'
- self.test_url = 'https://sandbox.checkout.com/api2/v2'
+ self.live_url = 'https://api.checkout.com'
+ self.test_url = 'https://api.sandbox.checkout.com'
self.supported_countries = ['AD', 'AE', 'AT', 'BE', 'BG', 'CH', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FO', 'FI', 'FR', 'GB', 'GI', 'GL', 'GR', 'HR', 'HU', 'IE', 'IS', 'IL', 'IT', 'LI', 'LT', 'LU', 'LV', 'MC', 'MT', 'NL', 'NO', 'PL', 'PT', 'RO', 'SE', 'SI', 'SM', 'SK', 'SJ', 'TR', 'VA']
self.default_currency = 'USD'
self.money_format = :cents
- self.supported_cardtypes = [:visa, :master, :american_express, :diners_club]
+ self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :maestro, :discover]
def initialize(options={})
requires!(options, :secret_key)
@@ -30,11 +30,12 @@ def purchase(amount, payment_method, options={})
def authorize(amount, payment_method, options={})
post = {}
- post[:autoCapture] = 'n'
+ post[:capture] = false
add_invoice(post, amount, options)
add_payment_method(post, payment_method)
add_customer_data(post, options)
add_transaction_data(post, options)
+ add_3ds(post, options)
commit(:authorize, post)
end
@@ -81,49 +82,69 @@ def scrub(transcript)
private
def add_invoice(post, money, options)
- post[:value] = localized_amount(money, options[:currency])
- post[:trackId] = options[:order_id]
+ post[:amount] = localized_amount(money, options[:currency])
+ post[:reference] = options[:order_id]
post[:currency] = options[:currency] || currency(money)
- post[:descriptor] = {}
- post[:descriptor][:name] = options[:descriptor_name] if options[:descriptor_name]
- post[:descriptor][:city] = options[:descriptor_city] if options[:descriptor_city]
+ if options[:descriptor_name] || options[:descriptor_city]
+ post[:billing_descriptor] = {}
+ post[:billing_descriptor][:name] = options[:descriptor_name] if options[:descriptor_name]
+ post[:billing_descriptor][:city] = options[:descriptor_city] if options[:descriptor_city]
+ end
+ post[:metadata] = {}
+ post[:metadata][:udf5] = application_id || 'ActiveMerchant'
end
def add_payment_method(post, payment_method)
- post[:card] = {}
- post[:card][:name] = payment_method.name
- post[:card][:number] = payment_method.number
- post[:card][:cvv] = payment_method.verification_value
- post[:card][:expiryYear] = format(payment_method.year, :four_digits)
- post[:card][:expiryMonth] = format(payment_method.month, :two_digits)
+ post[:source] = {}
+ post[:source][:type] = 'card'
+ post[:source][:name] = payment_method.name
+ post[:source][:number] = payment_method.number
+ post[:source][:cvv] = payment_method.verification_value
+ post[:source][:expiry_year] = format(payment_method.year, :four_digits)
+ post[:source][:expiry_month] = format(payment_method.month, :two_digits)
end
def add_customer_data(post, options)
- post[:email] = options[:email] || 'unspecified@example.com'
- post[:customerIp] = options[:ip] if options[:ip]
+ post[:customer] = {}
+ post[:customer][:email] = options[:email] || nil
+ post[:payment_ip] = options[:ip] if options[:ip]
address = options[:billing_address]
- if(address && post[:card])
- post[:card][:billingDetails] = {}
- post[:card][:billingDetails][:addressLine1] = address[:address1]
- post[:card][:billingDetails][:addressLine2] = address[:address2]
- post[:card][:billingDetails][:city] = address[:city]
- post[:card][:billingDetails][:state] = address[:state]
- post[:card][:billingDetails][:country] = address[:country]
- post[:card][:billingDetails][:postcode] = address[:zip]
- post[:card][:billingDetails][:phone] = { number: address[:phone] } unless address[:phone].blank?
+ if(address && post[:source])
+ post[:source][:billing_address] = {}
+ post[:source][:billing_address][:address_line1] = address[:address1] if address[:address1]
+ post[:source][:billing_address][:address_line2] = address[:address2] if address[:address2]
+ post[:source][:billing_address][:city] = address[:city] if address[:city]
+ post[:source][:billing_address][:state] = address[:state] if address[:state]
+ post[:source][:billing_address][:country] = address[:country] if address[:country]
+ post[:source][:billing_address][:zip] = address[:zip] if address[:zip]
+ post[:source][:phone] = { number: address[:phone] } unless address[:phone].blank?
end
end
def add_transaction_data(post, options={})
- post[:cardOnFile] = true if options[:card_on_file] == true
- post[:transactionIndicator] = options[:transaction_indicator] || 1
- post[:previousChargeId] = options[:previous_charge_id] if options[:previous_charge_id]
+ post[:card_on_file] = true if options[:card_on_file] == true
+ post[:payment_type] = 'Regular' if options[:transaction_indicator] == 1
+ post[:payment_type] = 'Recurring' if options[:transaction_indicator] == 2
+ post[:previous_payment_id] = options[:previous_charge_id] if options[:previous_charge_id]
+ end
+
+ def add_3ds(post, options)
+ if options[:three_d_secure]
+ post[:'3ds'] = {}
+ post[:'3ds'][:enabled] = true
+ post[:'3ds'][:eci] = options[:eci] if options[:eci]
+ post[:'3ds'][:cryptogram] = options[:cavv] if options[:cavv]
+ post[:'3ds'][:xid] = options[:xid] if options[:xid]
+ end
end
def commit(action, post, authorization = nil)
begin
raw_response = ssl_post(url(post, action, authorization), post.to_json, headers)
response = parse(raw_response)
+ if action == :capture && response.key?('_links')
+ response['id'] = response['_links']['payment']['href'].split('/')[-1]
+ end
rescue ResponseError => e
raise unless(e.response.code.to_s =~ /4\d\d/)
response = parse(e.response.body)
@@ -160,9 +181,15 @@ def headers
def url(post, action, authorization)
if action == :authorize
- "#{base_url}/charges/card"
+ "#{base_url}/payments"
+ elsif action == :capture
+ "#{base_url}/payments/#{authorization}/captures"
+ elsif action == :refund
+ "#{base_url}/payments/#{authorization}/refunds"
+ elsif action == :void
+ "#{base_url}/payments/#{authorization}/voids"
else
- "#{base_url}/charges/#{authorization}/#{action}"
+ "#{base_url}/payments/#{authorization}/#{action}"
end
end
@@ -171,33 +198,33 @@ def base_url
end
def avs_result(response)
- response['card'] && response['card']['avsCheck'] ? AVSResult.new(code: response['card']['avsCheck']) : nil
+ response['source'] && response['source']['avs_check'] ? AVSResult.new(code: response['source']['avs_check']) : nil
end
def cvv_result(response)
- response['card'] && response['card']['cvvCheck'] ? CVVResult.new(response['card']['cvvCheck']) : nil
+ response['source'] && response['source']['cvv_check'] ? CVVResult.new(response['source']['cvv_check']) : nil
end
def parse(body)
JSON.parse(body)
rescue JSON::ParserError
{
- 'message' => 'Invalid JSON response received from CheckoutV2Gateway. Please contact CheckoutV2Gateway if you continue to receive this message.',
+ 'message' => 'Invalid JSON response received from Checkout.com Unified Payments Gateway. Please contact Checkout.com if you continue to receive this message.',
'raw_response' => scrub(body)
}
end
def success_from(response)
- (response['responseCode'] == '10000' && !response['responseMessage'].start_with?('40')) || response['responseCode'] == '10100'
+ response['response_summary'] == 'Approved' || response.key?('action_id')
end
def message_from(succeeded, response)
if succeeded
'Succeeded'
- elsif response['errors']
- response['message'] + ': ' + response['errors'].first
+ elsif response['error_type']
+ response['error_type'] + ': ' + response['error_codes'].first
else
- response['responseMessage'] || response['message'] || 'Unable to read error message'
+ response['response_summary'] || response['response_code'] || 'Unable to read error message'
end
end
@@ -220,12 +247,12 @@ def authorization_from(raw)
def error_code_from(succeeded, response)
return if succeeded
- if response['errorCode'] && response['errorMessageCodes']
- "#{response["errorCode"]}: #{response["errorMessageCodes"].join(", ")}"
- elsif response['errorCode']
- response['errorCode']
+ if response['error_type'] && response['error_codes']
+ "#{response["error_type"]}: #{response["error_codes"].join(", ")}"
+ elsif response['error_type']
+ response['error_type']
else
- STANDARD_ERROR_CODE_MAPPING[response['responseCode']]
+ STANDARD_ERROR_CODE_MAPPING[response['response_code']]
end
end
end
diff --git a/test/remote/gateways/remote_checkout_v2_test.rb b/test/remote/gateways/remote_checkout_v2_test.rb
index 893347aa7f8..94e3762ce20 100644
--- a/test/remote/gateways/remote_checkout_v2_test.rb
+++ b/test/remote/gateways/remote_checkout_v2_test.rb
@@ -5,9 +5,9 @@ def setup
@gateway = CheckoutV2Gateway.new(fixtures(:checkout_v2))
@amount = 200
- @credit_card = credit_card('4242424242424242', verification_value: '100', month: '6', year: '2018')
+ @credit_card = credit_card('4242424242424242', verification_value: '100', month: '6', year: '2025')
@expired_card = credit_card('4242424242424242', verification_value: '100', month: '6', year: '2010')
- @declined_card = credit_card('4000300011112220')
+ @declined_card = credit_card('42424242424242424', verification_value: '234', month: '6', year: '2025')
@options = {
order_id: '1',
@@ -18,7 +18,13 @@ def setup
@additional_options = @options.merge(
card_on_file: true,
transaction_indicator: 2,
- previous_charge_id: 'charge_12312'
+ previous_charge_id: 'pay_123'
+ )
+ @additional_options_3ds = @options.merge(
+ execute_threed: true,
+ eci: '05',
+ cryptogram: '1234',
+ xid: '1234'
)
end
@@ -103,19 +109,19 @@ def test_successful_purchase_with_ip
def test_failed_purchase
response = @gateway.purchase(@amount, @declined_card, @options)
assert_failure response
- assert_equal 'Invalid Card Number', response.message
+ assert_equal 'request_invalid: card_number_invalid', response.message
end
def test_avs_failed_purchase
- response = @gateway.purchase(@amount, @credit_card, billing_address: address.update(address1: 'Test_A'))
+ response = @gateway.purchase(@amount, @declined_card, billing_address: address.update(address1: 'Test_A'))
assert_failure response
- assert_equal '40111 - Street Match Only', response.message
+ assert_equal 'request_invalid: card_number_invalid', response.message
end
def test_avs_failed_authorize
- response = @gateway.authorize(@amount, @credit_card, billing_address: address.update(address1: 'Test_A'))
+ response = @gateway.authorize(@amount, @declined_card, billing_address: address.update(address1: 'Test_A'))
assert_failure response
- assert_equal '40111 - Street Match Only', response.message
+ assert_equal 'request_invalid: card_number_invalid', response.message
end
def test_successful_authorize_and_capture
@@ -134,6 +140,14 @@ def test_successful_authorize_and_capture_with_additional_options
assert_success capture
end
+ def test_successful_authorize_and_capture_with_3ds
+ auth = @gateway.authorize(@amount, @credit_card, @additional_options_3ds)
+ assert_success auth
+
+ assert capture = @gateway.capture(nil, auth.authorization)
+ assert_success capture
+ end
+
def test_failed_authorize
response = @gateway.authorize(@amount, @declined_card, @options)
assert_failure response
@@ -195,14 +209,13 @@ def test_successful_verify
def test_failed_verify
response = @gateway.verify(@declined_card, @options)
assert_failure response
- assert_match %r{Invalid Card Number}, response.message
- assert_equal Gateway::STANDARD_ERROR_CODE[:invalid_number], response.error_code
+ assert_match %r{request_invalid: card_number_invalid}, response.message
end
def test_expired_card_returns_error_code
response = @gateway.purchase(@amount, @expired_card, @options)
assert_failure response
- assert_equal 'Validation error: Expired Card', response.message
- assert_equal '70000: 70077', response.error_code
+ assert_equal 'request_invalid: card_expired', response.message
+ assert_equal 'request_invalid: card_expired', response.error_code
end
end
diff --git a/test/unit/gateways/checkout_v2_test.rb b/test/unit/gateways/checkout_v2_test.rb
index bb3f1eda89a..0c9701ac164 100644
--- a/test/unit/gateways/checkout_v2_test.rb
+++ b/test/unit/gateways/checkout_v2_test.rb
@@ -18,7 +18,7 @@ def test_successful_purchase
end.respond_with(successful_purchase_response)
assert_success response
- assert_equal 'charge_test_941CA9CE174U76BD29C8', response.authorization
+ assert_equal 'pay_fj3xswqe3emuxckocjx6td73ni', response.authorization
assert response.test?
end
@@ -64,7 +64,7 @@ def test_purchase_with_additional_fields
response = stub_comms do
@gateway.purchase(@amount, @credit_card, {descriptor_city: 'london', descriptor_name: 'sherlock'})
end.check_request do |endpoint, data, headers|
- assert_match(/"descriptor\":{\"name\":\"sherlock\",\"city\":\"london\"}/, data)
+ assert_match(/"billing_descriptor\":{\"name\":\"sherlock\",\"city\":\"london\"}/, data)
end.respond_with(successful_purchase_response)
assert_success response
@@ -84,7 +84,7 @@ def test_successful_authorize_and_capture
end.respond_with(successful_authorize_response)
assert_success response
- assert_equal 'charge_test_AF1A29AD350Q748C7EA8', response.authorization
+ assert_equal 'pay_fj3xswqe3emuxckocjx6td73ni', response.authorization
capture = stub_comms do
@gateway.capture(@amount, response.authorization)
@@ -98,17 +98,38 @@ def test_successful_authorize_and_capture_with_additional_options
options = {
card_on_file: true,
transaction_indicator: 2,
- previous_charge_id: 'charge_123'
+ previous_charge_id: 'pay_123'
}
@gateway.authorize(@amount, @credit_card, options)
end.check_request do |endpoint, data, headers|
- assert_match(%r{"cardOnFile":true}, data)
- assert_match(%r{"transactionIndicator":2}, data)
- assert_match(%r{"previousChargeId":"charge_123"}, data)
+ assert_match(%r{"card_on_file":true}, data)
+ assert_match(%r{"payment_type":"Recurring"}, data)
+ assert_match(%r{"previous_payment_id":"pay_123"}, data)
end.respond_with(successful_authorize_response)
assert_success response
- assert_equal 'charge_test_AF1A29AD350Q748C7EA8', response.authorization
+ assert_equal 'pay_fj3xswqe3emuxckocjx6td73ni', response.authorization
+
+ capture = stub_comms do
+ @gateway.capture(@amount, response.authorization)
+ end.respond_with(successful_capture_response)
+
+ assert_success capture
+ end
+
+ def test_successful_authorize_and_capture_with_3ds
+ response = stub_comms do
+ options = {
+ execute_threed: true,
+ eci: '05',
+ cryptogram: '1234',
+ xid: '1234'
+ }
+ @gateway.authorize(@amount, @credit_card, options)
+ end.respond_with(successful_authorize_response)
+
+ assert_success response
+ assert_equal 'pay_fj3xswqe3emuxckocjx6td73ni', response.authorization
capture = stub_comms do
@gateway.capture(@amount, response.authorization)
@@ -141,7 +162,7 @@ def test_successful_void
end.respond_with(successful_authorize_response)
assert_success response
- assert_equal 'charge_test_AF1A29AD350Q748C7EA8', response.authorization
+ assert_equal 'pay_fj3xswqe3emuxckocjx6td73ni', response.authorization
void = stub_comms do
@gateway.void(response.authorization)
@@ -164,7 +185,7 @@ def test_successful_refund
end.respond_with(successful_purchase_response)
assert_success response
- assert_equal 'charge_test_941CA9CE174U76BD29C8', response.authorization
+ assert_equal 'pay_fj3xswqe3emuxckocjx6td73ni', response.authorization
refund = stub_comms do
@gateway.refund(@amount, response.authorization)
@@ -207,7 +228,7 @@ def test_invalid_json
end.respond_with(invalid_json_response)
assert_failure response
- assert_match %r{Invalid JSON response}, response.message
+ assert_match %r{Unable to read error message}, response.message
end
def test_error_code_returned
@@ -216,7 +237,7 @@ def test_error_code_returned
end.respond_with(error_code_response)
assert_failure response
- assert_match(/70000: 70077/, response.error_code)
+ assert_match(/request_invalid: card_expired/, response.error_code)
end
def test_supported_countries
@@ -227,38 +248,35 @@ def test_supported_countries
def pre_scrubbed
%q(
- <- "POST /v2/charges/card HTTP/1.1\r\nContent-Type: application/json;charset=UTF-8\r\nAuthorization: sk_test_ab12301d-e432-4ea7-97d1-569809518aaf\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: api2.checkout.com\r\nContent-Length: 346\r\n\r\n"
- <- "{\"autoCapture\":\"n\",\"value\":\"200\",\"trackId\":\"1\",\"currency\":\"USD\",\"card\":{\"name\":\"Longbob Longsen\",\"number\":\"4242424242424242\",\"cvv\":\"100\",\"expiryYear\":\"2018\"
+ <- "POST /payments HTTP/1.1\r\nContent-Type: application/json;charset=UTF-8\r\nAuthorization: sk_test_ab12301d-e432-4ea7-97d1-569809518aaf\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: api.checkout.com\r\nContent-Length: 346\r\n\r\n"
+ <- "{\"capture\":false,\"amount\":\"200\",\"reference\":\"1\",\"currency\":\"USD\",\"source\":{\"type\":\"card\",\"name\":\"Longbob Longsen\",\"number\":\"4242424242424242\",\"cvv\":\"100\",\"expiry_year\":\"2025\"
)
end
def post_scrubbed
%q(
- <- "POST /v2/charges/card HTTP/1.1\r\nContent-Type: application/json;charset=UTF-8\r\nAuthorization: [FILTERED]\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: api2.checkout.com\r\nContent-Length: 346\r\n\r\n"
- <- "{\"autoCapture\":\"n\",\"value\":\"200\",\"trackId\":\"1\",\"currency\":\"USD\",\"card\":{\"name\":\"Longbob Longsen\",\"number\":\"[FILTERED]\",\"cvv\":\"[FILTERED]\",\"expiryYear\":\"2018\"
+ <- "POST /payments HTTP/1.1\r\nContent-Type: application/json;charset=UTF-8\r\nAuthorization: [FILTERED]\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: api.checkout.com\r\nContent-Length: 346\r\n\r\n"
+ <- "{\"capture\":false,\"amount\":\"200\",\"reference\":\"1\",\"currency\":\"USD\",\"source\":{\"type\":\"card\",\"name\":\"Longbob Longsen\",\"number\":\"[FILTERED]\",\"cvv\":\"[FILTERED]\",\"expiry_year\":\"2025\"
)
end
def successful_purchase_response
%(
{
- "id":"charge_test_941CA9CE174U76BD29C8",
- "liveMode":false,
- "created":"2015-05-27T20:45:58Z",
- "value":200.0,
+ "id":"pay_fj3xswqe3emuxckocjx6td73ni",
+ "amount":200,
"currency":"USD",
- "trackId":"1",
- "description":null,
- "email":"longbob.longsen@gmail.com",
- "chargeMode":1,
- "transactionIndicator":1,
- "customerIp":null,
- "responseMessage":"Approved",
- "responseAdvancedInfo":"Approved",
- "responseCode":"10000",
- "card": {
- "cvvCheck":"Y",
- "avsCheck":"S"
+ "reference":"1",
+ "response_summary": "Approved",
+ "response_code":"10000",
+ "customer": {
+ "id": "cus_zvnv7gsblfjuxppycd7bx4erue",
+ "email": "longbob.longsen@example.com",
+ "name": "Sarah Mitchell"
+ },
+ "source": {
+ "cvv_check":"Y",
+ "avs_check":"S"
}
}
)
@@ -267,21 +285,18 @@ def successful_purchase_response
def failed_purchase_response
%(
{
- "id":"charge_test_941CA9CE174U76BD29C8",
- "liveMode":false,
- "created":"2015-05-27T20:45:58Z",
- "value":200.0,
+ "id":"pay_awjzhfj776gulbp2nuslj4agbu",
+ "amount":200,
"currency":"USD",
- "trackId":"1",
- "description":null,
- "email":"longbob.longsen@gmail.com",
- "chargeMode":1,
- "transactionIndicator":1,
- "customerIp":null,
- "responseMessage":"Invalid Card Number",
- "responseAdvancedInfo":"If credit card number contains characters other digits, or bank does not recognize this number as a valid credit card number",
- "responseCode":"20014",
- "card": {
+ "reference":"1",
+ "response_summary": "Invalid Card Number",
+ "response_code":"20014",
+ "customer": {
+ "id": "cus_zvnv7gsblfjuxppycd7bx4erue",
+ "email": "longbob.longsen@example.com",
+ "name": "Sarah Mitchell"
+ },
+ "source": {
"cvvCheck":"Y",
"avsCheck":"S"
}
@@ -291,66 +306,61 @@ def failed_purchase_response
def successful_authorize_response
%(
- {
- "id":"charge_test_AF1A29AD350Q748C7EA8",
- "liveMode":false,
- "created":"2017-11-13T14:05:27Z",
- "value":200,
- "currency":"USD",
- "trackId":"1",
- "description":null,
- "email":"longbob.longsen@example.com",
- "chargeMode":1,
- "transactionIndicator":1,
- "customerIp":null,
- "responseMessage":"Approved",
- "responseAdvancedInfo":"Approved",
- "responseCode":"10000",
- "status":"Authorised",
- "authCode":"923189",
- "isCascaded":false,
- "autoCapture":"N",
- "autoCapTime":0.0,
- "card":{"customerId":
- "cust_12DCEB24-ACEA-48AB-BEF2-35A3C09BE581",
- "expiryMonth":"06",
- "expiryYear":"2018",
- "billingDetails":{
- "addressLine1":"456 My Street",
- "addressLine2":"Apt 1",
- "postcode":"K1C2N6",
- "country":"CA",
- "city":"Ottawa",
- "state":"ON",
- "phone":{"number":"(555)555-5555"}
- },
- "id":"card_CFA314F4-388D-4CF4-BE6F-940D894C9E64",
- "last4":"4242",
- "bin":"424242",
- "paymentMethod":"Visa",
- "fingerprint":"F639CAB2745BEE4140BF86DF6B6D6E255C5945AAC3788D923FA047EA4C208622",
- "name":"Longbob Longsen",
- "cvvCheck":"Y",
- "avsCheck":"S"
+ {
+ "id": "pay_fj3xswqe3emuxckocjx6td73ni",
+ "action_id": "act_fj3xswqe3emuxckocjx6td73ni",
+ "amount": 200,
+ "currency": "USD",
+ "approved": true,
+ "status": "Authorized",
+ "auth_code": "858188",
+ "eci": "05",
+ "scheme_id": "638284745624527",
+ "response_code": "10000",
+ "response_summary": "Approved",
+ "risk": {
+ "flagged": false
},
- "riskCheck":true,
- "customerPaymentPlans":null,
- "metadata":{},
- "shippingDetails":{
- "addressLine1":null,
- "addressLine2":null,
- "postcode":null,
- "country":null,
- "city":null,
- "state":null,
- "phone":{}
+ "source": {
+ "id": "src_nq6m5dqvxmsunhtzf7adymbq3i",
+ "type": "card",
+ "expiry_month": 8,
+ "expiry_year": 2025,
+ "name": "Sarah Mitchell",
+ "scheme": "Visa",
+ "last4": "4242",
+ "fingerprint": "5CD3B9CB15338683110959D165562D23084E1FF564F420FE9A990DF0BCD093FC",
+ "bin": "424242",
+ "card_type": "Credit",
+ "card_category": "Consumer",
+ "issuer": "JPMORGAN CHASE BANK NA",
+ "issuer_country": "US",
+ "product_id": "A",
+ "product_type": "Visa Traditional",
+ "avs_check": "S",
+ "cvv_check": "Y"
},
- "products":[],
- "udf1":null,
- "udf2":null,
- "udf3":null,
- "udf4":null,
- "udf5":null
+ "customer": {
+ "id": "cus_ssxcidkqvfde7lfn5n7xzmgv2a",
+ "email": "longbob.longsen@example.com",
+ "name": "Sarah Mitchell"
+ },
+ "processed_on": "2019-03-24T10:14:32Z",
+ "reference": "ORD-5023-4E89",
+ "_links": {
+ "self": {
+ "href": "https://api.sandbox.checkout.com/payments/pay_fj3xswqe3emuxckocjx6td73ni"
+ },
+ "actions": {
+ "href": "https://api.sandbox.checkout.com/payments/pay_fj3xswqe3emuxckocjx6td73ni/actions"
+ },
+ "capture": {
+ "href": "https://api.sandbox.checkout.com/payments/pay_fj3xswqe3emuxckocjx6td73ni/captures"
+ },
+ "void": {
+ "href": "https://api.sandbox.checkout.com/payments/pay_fj3xswqe3emuxckocjx6td73ni/voids"
+ }
+ }
}
)
end
@@ -358,125 +368,74 @@ def successful_authorize_response
def failed_authorize_response
%(
{
- "id":"charge_test_941CA9CE174U76BD29C8",
- "liveMode":false,
- "created":"2015-05-27T20:45:58Z",
- "value":200.0,
+ "id":"pay_awjzhfj776gulbp2nuslj4agbu",
+ "amount":200,
"currency":"USD",
- "trackId":"1",
- "description":null,
- "email":"longbob.longsen@gmail.com",
- "chargeMode":1,
- "transactionIndicator":1,
- "customerIp":null,
- "responseMessage":"Invalid Card Number",
- "responseAdvancedInfo":"If credit card number contains characters other digits, or bank does not recognize this number as a valid credit card number",
- "responseCode":"20014"
+ "reference":"1",
+ "customer": {
+ "id": "cus_zvnv7gsblfjuxppycd7bx4erue",
+ "email": "longbob.longsen@example.com",
+ "name": "Sarah Mitchell"
+ },
+ "response_summary": "Invalid Card Number",
+ "response_code":"20014"
}
)
end
def successful_capture_response
%(
- {
- "id":"charge_test_941CA9CE174U76BD29C8",
- "liveMode":false,
- "created":"2015-05-27T20:45:58Z",
- "value":200.0,
- "currency":"USD",
- "trackId":"1",
- "description":null,
- "email":"longbob.longsen@gmail.com",
- "chargeMode":1,
- "transactionIndicator":1,
- "customerIp":null,
- "responseMessage":"Captured",
- "responseAdvancedInfo":"Captured",
- "responseCode":"10000"
- }
+ {
+ "action_id": "act_2f56bhkau5dubequbv5aa6w4qi",
+ "reference": "1"
+ }
)
end
def failed_capture_response
%(
- {
- "errorCode":"405",
- "message":"You tried to access the endpoint with an invalid method",
- }
)
end
def successful_refund_response
%(
- {
- "id":"charge_test_941CA9CE174U76BD29C8",
- "liveMode":false,
- "created":"2015-05-27T20:45:58Z",
- "value":200.0,
- "currency":"USD",
- "trackId":"1",
- "description":null,
- "email":"longbob.longsen@gmail.com",
- "chargeMode":1,
- "transactionIndicator":1,
- "customerIp":null,
- "responseMessage":"Refunded",
- "responseAdvancedInfo":"Refunded",
- "responseCode":"10000"
- }
+ {
+ "action_id": "act_2f56bhkau5dubequbv5aa6w4qi",
+ "reference": "1"
+ }
)
end
def failed_refund_response
%(
- {
- "errorCode":"405",
- "message":"You tried to access the endpoint with an invalid method",
- }
)
end
def successful_void_response
%(
- {
- "id":"charge_test_941CA9CE174U76BD29C8",
- "liveMode":false,
- "created":"2015-05-27T20:45:58Z",
- "value":200.0,
- "currency":"USD",
- "trackId":"1",
- "description":null,
- "email":"longbob.longsen@gmail.com",
- "chargeMode":1,
- "transactionIndicator":1,
- "customerIp":null,
- "responseMessage":"Voided",
- "responseAdvancedInfo":"Voided",
- "responseCode":"10000"
- }
+ {
+ "action_id": "act_2f56bhkau5dubequbv5aa6w4qi",
+ "reference": "1"
+ }
)
end
def failed_void_response
%(
- {
- "errorCode":"405",
- "message":"You tried to access the endpoint with an invalid method",
- }
)
end
def invalid_json_response
%(
{
- "id": "charge_test_123456",
+ "id": "pay_123",
)
end
def error_code_response
%(
{
- "eventId":"1b206f69-b4db-4259-9713-b72dfe0f19da","errorCode":"70000","message":"Validation error","errorMessageCodes":["70077"],"errors":["Expired Card"]
+ "request_id": "e5a3ce6f-a4e9-4445-9ec7-e5975e9a6213","error_type": "request_invalid","error_codes": ["card_expired"]
}
)
end
From de8425876570df38aa52c43e6542d5fd9b863bad Mon Sep 17 00:00:00 2001
From: Geoff Catlin
Date: Thu, 25 Apr 2019 15:05:53 -0400
Subject: [PATCH 0325/2234] CardConnect: Add frontendid parameter to requests
Add `frontendid` parameter to request bodies using the gateway's
application_id as the value. This enables CardConnect to internally
account for their costs by attributing transactions to the originating
application / platform associated with the frontendid.
ECS-287
Closes #3198
Unit:
22 tests, 92 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
23 tests, 55 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/card_connect.rb | 1 +
test/unit/gateways/card_connect_test.rb | 11 +++++++++++
3 files changed, 13 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index 5bc8953204a..ff906b3022e 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -3,6 +3,7 @@
== HEAD
* Mundipagg: Fix number lengths for both VR and Sodexo [dtykocki] #3195
* Stripe: Support show and list webhook endpoints [jknipp] #3196
+* CardConnect: Add frontendid parameter to requests [gcatlin] #3198
== Version 1.93.0 (April 18, 2019)
* Stripe: Do not consider a refund unsuccessful if only refunding the fee failed [jasonwebster] #3188
diff --git a/lib/active_merchant/billing/gateways/card_connect.rb b/lib/active_merchant/billing/gateways/card_connect.rb
index 62903dec0ff..e467d8dbf55 100644
--- a/lib/active_merchant/billing/gateways/card_connect.rb
+++ b/lib/active_merchant/billing/gateways/card_connect.rb
@@ -267,6 +267,7 @@ def url(action, path)
end
def commit(action, parameters, verb: :put, path: '')
+ parameters[:frontendid] = application_id
parameters[:merchid] = @options[:merchant_id]
url = url(action, path)
response = parse(ssl_request(verb, url, post_data(parameters), headers))
diff --git a/test/unit/gateways/card_connect_test.rb b/test/unit/gateways/card_connect_test.rb
index e4a49a1541b..c4736f57616 100644
--- a/test/unit/gateways/card_connect_test.rb
+++ b/test/unit/gateways/card_connect_test.rb
@@ -199,6 +199,17 @@ def test_scrub
assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed
end
+ def test_frontendid_is_added_to_post_data_parameters
+ @gateway.class.application_id = 'my_app'
+ stub_comms(@gateway, :ssl_request) do
+ @gateway.purchase(@amount, @credit_card, @options)
+ end.check_request do |_, _, body|
+ assert_equal 'my_app', JSON.parse(body)['frontendid']
+ end.respond_with(successful_purchase_response)
+ ensure
+ @gateway.class.application_id = nil
+ end
+
private
def pre_scrubbed
From 969b602aded3903d3342f1abcda117f9e0ec6bb0 Mon Sep 17 00:00:00 2001
From: Niaja
Date: Mon, 29 Apr 2019 10:24:41 -0400
Subject: [PATCH 0326/2234] Adyen: Correct formatting of Billing Address
With the upgrade of Adyen to version 40, the billing address was removed
from the card object. This corrects the format and returns the two tests
that fail when you pass an incorrect country or state. In order to see
AVS results you may need to make some configuration changes to your
account.
https://docs.adyen.com/developers/api-reference/payments-api#paymentresultadditionaldata
Loaded suite test/remote/gateways/remote_adyen_test
........................................................
56 tests, 166 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Loaded suite test/unit/gateways/adyen_test
Started
..................................
34 tests, 161 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/adyen.rb | 14 ++++----
test/remote/gateways/remote_adyen_test.rb | 33 +++++++++++++++++--
test/unit/gateways/adyen_test.rb | 12 +++----
4 files changed, 45 insertions(+), 15 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index ff906b3022e..a9225431fbf 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -4,6 +4,7 @@
* Mundipagg: Fix number lengths for both VR and Sodexo [dtykocki] #3195
* Stripe: Support show and list webhook endpoints [jknipp] #3196
* CardConnect: Add frontendid parameter to requests [gcatlin] #3198
+* Adyen: Correct formatting of Billing Address [nfarve] #3200
== Version 1.93.0 (April 18, 2019)
* Stripe: Do not consider a refund unsuccessful if only refunding the fee failed [jasonwebster] #3188
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index 770d85c0c08..1e84f35a7b0 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -214,13 +214,13 @@ def add_recurring_processing_model(post, options)
def add_address(post, options)
return unless post[:card]&.kind_of?(Hash)
if (address = options[:billing_address] || options[:address]) && address[:country]
- post[:card][:billingAddress] = {}
- post[:card][:billingAddress][:street] = address[:address1] || 'N/A'
- post[:card][:billingAddress][:houseNumberOrName] = address[:address2] || 'N/A'
- post[:card][:billingAddress][:postalCode] = address[:zip] if address[:zip]
- post[:card][:billingAddress][:city] = address[:city] || 'N/A'
- post[:card][:billingAddress][:stateOrProvince] = address[:state] || 'N/A'
- post[:card][:billingAddress][:country] = address[:country] if address[:country]
+ post[:billingAddress] = {}
+ post[:billingAddress][:street] = address[:address1] || 'N/A'
+ post[:billingAddress][:houseNumberOrName] = address[:address2] || 'N/A'
+ post[:billingAddress][:postalCode] = address[:zip] if address[:zip]
+ post[:billingAddress][:city] = address[:city] || 'N/A'
+ post[:billingAddress][:stateOrProvince] = address[:state] || 'N/A'
+ post[:billingAddress][:country] = address[:country] if address[:country]
end
end
diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb
index c0f0cc4bbfa..f39e7287c2f 100644
--- a/test/remote/gateways/remote_adyen_test.rb
+++ b/test/remote/gateways/remote_adyen_test.rb
@@ -15,6 +15,15 @@ def setup
:brand => 'visa'
)
+ @avs_credit_card = credit_card('4400000000000008',
+ :month => 10,
+ :year => 2020,
+ :first_name => 'John',
+ :last_name => 'Smith',
+ :verification_value => '737',
+ :brand => 'visa'
+ )
+
@elo_credit_card = credit_card('5066 9911 1111 1118',
:month => 10,
:year => 2020,
@@ -71,6 +80,24 @@ def test_successful_authorize
assert_equal 'Authorised', response.message
end
+ def test_successful_authorize_avs
+ # Account configuration may need to be done: https://docs.adyen.com/developers/api-reference/payments-api#paymentresultadditionaldata
+ options = @options.update({
+ billing_address: {
+ address1: 'Infinite Loop',
+ address2: 1,
+ country: 'US',
+ city: 'Cupertino',
+ state: 'CA',
+ zip: '95014'
+ }
+ })
+ response = @gateway.authorize(@amount, @avs_credit_card, options)
+ assert_success response
+ assert_equal 'Authorised', response.message
+ assert_equal 'D', response.avs_result['code']
+ end
+
def test_successful_authorize_with_idempotency_key
options = @options.merge(idempotency_key: 'test123')
response = @gateway.authorize(@amount, @credit_card, options)
@@ -504,13 +531,15 @@ def test_missing_state_for_purchase
def test_blank_country_for_purchase
@options[:billing_address][:country] = ''
response = @gateway.authorize(@amount, @credit_card, @options)
- assert_success response
+ assert_failure response
+ assert_match Gateway::STANDARD_ERROR_CODE[:incorrect_address], response.error_code
end
def test_blank_state_for_purchase
@options[:billing_address][:state] = ''
response = @gateway.authorize(@amount, @credit_card, @options)
- assert_success response
+ assert_failure response
+ assert_match Gateway::STANDARD_ERROR_CODE[:incorrect_address], response.error_code
end
def test_missing_phone_for_purchase
diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb
index b173186fe29..21e50725d52 100644
--- a/test/unit/gateways/adyen_test.rb
+++ b/test/unit/gateways/adyen_test.rb
@@ -346,12 +346,12 @@ def test_add_address
@options[:billing_address].delete(:address2)
@options[:billing_address].delete(:state)
@gateway.send(:add_address, post, @options)
- assert_equal 'N/A', post[:card][:billingAddress][:street]
- assert_equal 'N/A', post[:card][:billingAddress][:houseNumberOrName]
- assert_equal 'N/A', post[:card][:billingAddress][:stateOrProvince]
- assert_equal @options[:billing_address][:zip], post[:card][:billingAddress][:postalCode]
- assert_equal @options[:billing_address][:city], post[:card][:billingAddress][:city]
- assert_equal @options[:billing_address][:country], post[:card][:billingAddress][:country]
+ assert_equal 'N/A', post[:billingAddress][:street]
+ assert_equal 'N/A', post[:billingAddress][:houseNumberOrName]
+ assert_equal 'N/A', post[:billingAddress][:stateOrProvince]
+ assert_equal @options[:billing_address][:zip], post[:billingAddress][:postalCode]
+ assert_equal @options[:billing_address][:city], post[:billingAddress][:city]
+ assert_equal @options[:billing_address][:country], post[:billingAddress][:country]
end
def test_authorize_with_network_tokenization_credit_card_no_name
From f5e2fb0a12e050bc31082418703f29fbbc1f73f6 Mon Sep 17 00:00:00 2001
From: Jared Knipp
Date: Tue, 30 Apr 2019 17:08:25 -0500
Subject: [PATCH 0327/2234] Stripe: Show payment source
Add support for showing a payment source such as a card or 3DS payment
source.
Unit:
134 tests, 718 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
67 tests, 313 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote Stripe 3DS:
11 tests, 57 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
ECS-289
closes #3202
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/stripe.rb | 4 ++++
test/remote/gateways/remote_stripe_3ds_test.rb | 12 ++++++++++++
3 files changed, 17 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index a9225431fbf..7fa39359b9a 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -5,6 +5,7 @@
* Stripe: Support show and list webhook endpoints [jknipp] #3196
* CardConnect: Add frontendid parameter to requests [gcatlin] #3198
* Adyen: Correct formatting of Billing Address [nfarve] #3200
+* Stripe: Stripe: Show payment source [jknipp] #3202
== Version 1.93.0 (April 18, 2019)
* Stripe: Do not consider a refund unsuccessful if only refunding the fee failed [jasonwebster] #3188
diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb
index 33c51a01fc4..35950da4764 100644
--- a/lib/active_merchant/billing/gateways/stripe.rb
+++ b/lib/active_merchant/billing/gateways/stripe.rb
@@ -309,6 +309,10 @@ def create_source(money, payment, type, options = {})
commit(:post, 'sources', post, options)
end
+ def show_source(source_id, options)
+ commit(:get, "sources/#{source_id}", nil, options)
+ end
+
def create_webhook_endpoint(options, events)
post = {}
post[:url] = options[:callback_url]
diff --git a/test/remote/gateways/remote_stripe_3ds_test.rb b/test/remote/gateways/remote_stripe_3ds_test.rb
index 151b9d772f0..3231ce99993 100644
--- a/test/remote/gateways/remote_stripe_3ds_test.rb
+++ b/test/remote/gateways/remote_stripe_3ds_test.rb
@@ -49,6 +49,18 @@ def test_create_3ds_source
assert_equal false, response.params['three_d_secure']['authenticated']
end
+ def test_show_3ds_source
+ card_source = @gateway.send(:create_source, @amount, @credit_card, 'card', @options)
+ assert three_d_secure_source = @gateway.send(:create_source, @amount, card_source.params['id'], 'three_d_secure', @options)
+ assert_success three_d_secure_source
+
+ assert response = @gateway.send(:show_source, three_d_secure_source.params['id'], @options)
+ assert_equal 'source', response.params['object']
+ assert_equal 'pending', response.params['status']
+ assert_equal 'three_d_secure', response.params['type']
+ assert_equal false, response.params['three_d_secure']['authenticated']
+ end
+
def test_create_webhook_endpoint
response = @gateway.send(:create_webhook_endpoint, @options, ['source.chargeable'])
assert_includes response.params['enabled_events'], 'source.chargeable'
From 3d6cc66ff27d6486fe5189abfc45fe600806c130 Mon Sep 17 00:00:00 2001
From: David Perry
Date: Wed, 1 May 2019 11:40:40 -0400
Subject: [PATCH 0328/2234] Checkout V2: Correct success criteria
Also corrects address field value detection.
Closes #3205
Unit:
22 tests, 99 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/checkout_v2.rb | 14 +++++++-------
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 7fa39359b9a..c59a227f4b8 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -6,6 +6,7 @@
* CardConnect: Add frontendid parameter to requests [gcatlin] #3198
* Adyen: Correct formatting of Billing Address [nfarve] #3200
* Stripe: Stripe: Show payment source [jknipp] #3202
+* Checkout V2: Checkout V2: Correct success criteria [curiousepic] #3205
== Version 1.93.0 (April 18, 2019)
* Stripe: Do not consider a refund unsuccessful if only refunding the fee failed [jasonwebster] #3188
diff --git a/lib/active_merchant/billing/gateways/checkout_v2.rb b/lib/active_merchant/billing/gateways/checkout_v2.rb
index 06538a0a806..248c5bfc477 100644
--- a/lib/active_merchant/billing/gateways/checkout_v2.rb
+++ b/lib/active_merchant/billing/gateways/checkout_v2.rb
@@ -111,12 +111,12 @@ def add_customer_data(post, options)
address = options[:billing_address]
if(address && post[:source])
post[:source][:billing_address] = {}
- post[:source][:billing_address][:address_line1] = address[:address1] if address[:address1]
- post[:source][:billing_address][:address_line2] = address[:address2] if address[:address2]
- post[:source][:billing_address][:city] = address[:city] if address[:city]
- post[:source][:billing_address][:state] = address[:state] if address[:state]
- post[:source][:billing_address][:country] = address[:country] if address[:country]
- post[:source][:billing_address][:zip] = address[:zip] if address[:zip]
+ post[:source][:billing_address][:address_line1] = address[:address1] unless address[:address1].blank?
+ post[:source][:billing_address][:address_line2] = address[:address2] unless address[:address2].blank?
+ post[:source][:billing_address][:city] = address[:city] unless address[:city].blank?
+ post[:source][:billing_address][:state] = address[:state] unless address[:state].blank?
+ post[:source][:billing_address][:country] = address[:country] unless address[:country].blank?
+ post[:source][:billing_address][:zip] = address[:zip] unless address[:zip].blank?
post[:source][:phone] = { number: address[:phone] } unless address[:phone].blank?
end
end
@@ -215,7 +215,7 @@ def parse(body)
end
def success_from(response)
- response['response_summary'] == 'Approved' || response.key?('action_id')
+ response['response_summary'] == 'Approved' || !response.key?('response_summary') && response.key?('action_id')
end
def message_from(succeeded, response)
From 9b80e155d007e4c1b7cf6fc5ab62a826eff59e19 Mon Sep 17 00:00:00 2001
From: David Santoso
Date: Sat, 13 Apr 2019 14:58:56 -0400
Subject: [PATCH 0329/2234] Adyen: Add normalized hash of 3DS 2.0 data fields
from web browsers
In an effort to begin supporting the intiation of 3DS 2.0 transactions,
this introduces another normalized hash for web browser data that can be
mapped to the fields a gateway is expecting. Similarly to stored
credentials, this hash should be used across all gateways in which 3DS
2.0 browser data is meant to be submitted so there is a single interface
for the client/device data.
Eventually I suspect this hash should also support mobile app information
by changing out the "channel" field and doing additional logic around that,
but for now we're starting with web browsers only.
The structure of the hash is as follows:
three_ds_2: {
channel: "browser",
browser_info: {
accept_header: "unknown",
depth: 100,
java: false,
language: "US",
height: 1000,
width: 500,
timezone: "-120",
user_agent: "unknown"
}
}
This should be all of the data gateways are expecting, however as with
all payment gateways I imagine there are some that will accept or
require additional data. In those cases I suspect we can add that data
to this additional hash for a specific gateways needs.
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/adyen.rb | 28 +++++++++++--
test/remote/gateways/remote_adyen_test.rb | 41 +++++++++++++++++--
test/unit/gateways/adyen_test.rb | 40 ++++++++++++++++++
4 files changed, 103 insertions(+), 7 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index c59a227f4b8..a1bb28cb9f8 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -7,6 +7,7 @@
* Adyen: Correct formatting of Billing Address [nfarve] #3200
* Stripe: Stripe: Show payment source [jknipp] #3202
* Checkout V2: Checkout V2: Correct success criteria [curiousepic] #3205
+* Adyen: Add normalized hash of 3DS 2.0 data fields from web browsers [davidsantoso] #3207
== Version 1.93.0 (April 18, 2019)
* Stripe: Do not consider a refund unsuccessful if only refunding the fee failed [jasonwebster] #3188
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index 1e84f35a7b0..6c393ef6082 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -308,9 +308,31 @@ def add_installments(post, options)
end
def add_3ds(post, options)
- return unless options[:execute_threed] || options[:threed_dynamic]
- post[:browserInfo] = { userAgent: options[:user_agent], acceptHeader: options[:accept_header] }
- post[:additionalData] = { executeThreeD: 'true' } if options[:execute_threed]
+ if three_ds_2_options = options[:three_ds_2]
+ if browser_info = three_ds_2_options[:browser_info]
+ post[:browserInfo] = {
+ acceptHeader: browser_info[:accept_header],
+ colorDepth: browser_info[:depth],
+ javaEnabled: browser_info[:java],
+ language: browser_info[:language],
+ screenHeight: browser_info[:height],
+ screenWidth: browser_info[:width],
+ timeZoneOffset: browser_info[:timezone],
+ userAgent: browser_info[:user_agent]
+ }
+
+ if device_channel = three_ds_2_options[:channel]
+ post[:threeDS2RequestData] = {
+ deviceChannel: device_channel,
+ notificationURL: three_ds_2_options[:notification_url] || 'https://example.com/notification'
+ }
+ end
+ end
+ else
+ return unless options[:execute_threed] || options[:threed_dynamic]
+ post[:browserInfo] = { userAgent: options[:user_agent], acceptHeader: options[:accept_header] }
+ post[:additionalData] = { executeThreeD: 'true' } if options[:execute_threed]
+ end
end
def parse(body)
diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb
index f39e7287c2f..c402ceceaaa 100644
--- a/test/remote/gateways/remote_adyen_test.rb
+++ b/test/remote/gateways/remote_adyen_test.rb
@@ -70,7 +70,30 @@ def setup
shopper_reference: 'John Smith',
billing_address: address(),
order_id: '123',
- stored_credential: {reason_type: 'unscheduled'}
+ stored_credential: {reason_type: 'unscheduled'},
+ }
+
+ @normalized_3ds_2_options = {
+ reference: '345123',
+ shopper_email: 'john.smith@test.com',
+ shopper_ip: '77.110.174.153',
+ shopper_reference: 'John Smith',
+ billing_address: address(),
+ order_id: '123',
+ stored_credential: {reason_type: 'unscheduled'},
+ three_ds_2: {
+ channel: 'browser',
+ browser_info: {
+ accept_header: 'unknown',
+ depth: 100,
+ java: false,
+ language: 'US',
+ height: 1000,
+ width: 500,
+ timezone: '-120',
+ user_agent: 'unknown'
+ }
+ }
}
end
@@ -99,7 +122,7 @@ def test_successful_authorize_avs
end
def test_successful_authorize_with_idempotency_key
- options = @options.merge(idempotency_key: 'test123')
+ options = @options.merge(idempotency_key: SecureRandom.hex)
response = @gateway.authorize(@amount, @credit_card, options)
assert_success response
assert_equal 'Authorised', response.message
@@ -130,6 +153,16 @@ def test_successful_authorize_with_3ds_dynamic
refute response.params['paRequest'].blank?
end
+ def test_successful_authorize_with_3ds2_browser_client_data
+ assert response = @gateway.authorize(@amount, @three_ds_enrolled_card, @normalized_3ds_2_options)
+ assert response.test?
+ refute response.authorization.blank?
+ assert_equal response.params['resultCode'], 'IdentifyShopper'
+ refute response.params['additionalData']['threeds2.threeDS2Token'].blank?
+ refute response.params['additionalData']['threeds2.threeDSServerTransID'].blank?
+ refute response.params['additionalData']['threeds2.threeDSMethodURL'].blank?
+ end
+
# with rule set in merchant account to skip 3DS for cards of this brand
def test_successful_authorize_with_3ds_dynamic_rule_broken
mastercard_threed = credit_card('5212345678901234',
@@ -203,7 +236,7 @@ def test_successful_purchase_with_risk_data
end
def test_successful_purchase_with_idempotency_key
- options = @options.merge(idempotency_key: 'testkey45678')
+ options = @options.merge(idempotency_key: SecureRandom.hex)
response = @gateway.purchase(@amount, @credit_card, options)
assert_success response
assert_equal '[capture-received]', response.message
@@ -425,7 +458,7 @@ def test_failed_verify
end
def test_verify_with_idempotency_key
- options = @options.merge(idempotency_key: 'test123')
+ options = @options.merge(idempotency_key: SecureRandom.hex)
response = @gateway.authorize(0, @credit_card, options)
assert_success response
assert_equal 'Authorised', response.message
diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb
index 21e50725d52..8e5e41e4d5f 100644
--- a/test/unit/gateways/adyen_test.rb
+++ b/test/unit/gateways/adyen_test.rb
@@ -61,6 +61,29 @@ def setup
reason_type: 'recurring'
}
}
+
+ @normalized_3ds_2_options = {
+ reference: '345123',
+ shopper_email: 'john.smith@test.com',
+ shopper_ip: '77.110.174.153',
+ shopper_reference: 'John Smith',
+ billing_address: address(),
+ order_id: '123',
+ stored_credential: {reason_type: 'unscheduled'},
+ three_ds_2: {
+ channel: 'browser',
+ browser_info: {
+ accept_header: 'unknown',
+ depth: 100,
+ java: false,
+ language: 'US',
+ height: 1000,
+ width: 500,
+ timezone: '-120',
+ user_agent: 'unknown'
+ }
+ }
+ }
end
# Subdomains are only valid for production gateways, so the test_url check must be manually bypassed for this test to pass.
@@ -163,6 +186,23 @@ def test_successful_maestro_purchase
assert response.test?
end
+ def test_3ds_2_fields_sent
+ stub_comms do
+ @gateway.authorize(@amount, @credit_card, @normalized_3ds_2_options)
+ end.check_request do |endpoint, data, headers|
+ data = JSON.parse(data)
+ assert_equal 'browser', data['threeDS2RequestData']['deviceChannel']
+ assert_equal 'unknown', data['browserInfo']['acceptHeader']
+ assert_equal 100, data['browserInfo']['colorDepth']
+ assert_equal false, data['browserInfo']['javaEnabled']
+ assert_equal 'US', data['browserInfo']['language']
+ assert_equal 1000, data['browserInfo']['screenHeight']
+ assert_equal 500, data['browserInfo']['screenWidth']
+ assert_equal '-120', data['browserInfo']['timeZoneOffset']
+ assert_equal 'unknown', data['browserInfo']['userAgent']
+ end.respond_with(successful_authorize_response)
+ end
+
def test_installments_sent
stub_comms do
@gateway.authorize(@amount, @credit_card, @options)
From e860edecdc8a700925b72b9b3febed7fbfee5c85 Mon Sep 17 00:00:00 2001
From: Jason Webster
Date: Mon, 6 May 2019 11:39:57 -0400
Subject: [PATCH 0330/2234] Do not attempt application fee refund if refund was
not successful (#3206)
This was a regression made in adc5a88c485e8de8cf30c064233fbe7bc927bf86
which was trying to make the App Fee refunds not impact the overall
status of the Refund response. That was achieved, but it also made the
unintentional change of always trying to refund the application fee
regardless of the refund succeeding or not. There was previously no test
coverage of this behaviour.
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/stripe.rb | 2 +-
test/unit/gateways/stripe_test.rb | 9 ++++++++-
3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index a1bb28cb9f8..0fcd70c16d7 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -8,6 +8,7 @@
* Stripe: Stripe: Show payment source [jknipp] #3202
* Checkout V2: Checkout V2: Correct success criteria [curiousepic] #3205
* Adyen: Add normalized hash of 3DS 2.0 data fields from web browsers [davidsantoso] #3207
+* Stripe: Do not attempt application fee refund if refund was not successful [jasonwebster] #3206
== Version 1.93.0 (April 18, 2019)
* Stripe: Do not consider a refund unsuccessful if only refunding the fee failed [jasonwebster] #3188
diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb
index 35950da4764..19587899533 100644
--- a/lib/active_merchant/billing/gateways/stripe.rb
+++ b/lib/active_merchant/billing/gateways/stripe.rb
@@ -152,7 +152,7 @@ def refund(money, identification, options = {})
response = commit(:post, "charges/#{CGI.escape(identification)}/refunds", post, options)
- if options[:refund_fee_amount] && options[:refund_fee_amount].to_s != '0'
+ if response.success? && options[:refund_fee_amount] && options[:refund_fee_amount].to_s != '0'
charge = api_request(:get, "charges/#{CGI.escape(identification)}", nil, options)
if application_fee = charge['application_fee']
diff --git a/test/unit/gateways/stripe_test.rb b/test/unit/gateways/stripe_test.rb
index 9dffa51d540..0fb2d96ff1b 100644
--- a/test/unit/gateways/stripe_test.rb
+++ b/test/unit/gateways/stripe_test.rb
@@ -685,7 +685,6 @@ def test_successful_refund_with_refund_fee_amount
assert_success response
end
- # What is the significance of this??? it's to test that the first response is used as primary. so identical to above with an extra assertion
def test_refund_with_fee_response_responds_with_the_refund_authorization
s = sequence('request')
@gateway.expects(:ssl_request).returns(successful_partially_refunded_response).in_sequence(s)
@@ -716,6 +715,14 @@ def test_successful_refund_with_failed_fee_refund
assert_success response
end
+ def test_unsuccessful_refund_does_not_refund_fee
+ s = sequence('request')
+ @gateway.expects(:ssl_request).returns(generic_error_response).in_sequence(s)
+
+ assert response = @gateway.refund(@refund_amount, 'ch_test_charge', :refund_fee_amount => 100)
+ assert_failure response
+ end
+
def test_successful_verify
response = stub_comms(@gateway, :ssl_request) do
@gateway.verify(@credit_card, @options)
From 9f6e4d409562bc827faf8eddb805a60b28b7a8c1 Mon Sep 17 00:00:00 2001
From: Geoff Catlin
Date: Mon, 29 Apr 2019 19:06:32 -0400
Subject: [PATCH 0331/2234] Elavon: Send ssl_transaction_currency field
Elavon returns an error for any API request that includes a currency
UNLESS the merchant's terminal is setup for multi-currency. Previously
we NEVER sent the currency, so only the default currency worked. Now, we
only send the `ssl_transaction_currency` field if the currency field is
provided.
Elavon Multi-Currency Conversion (MCC) documentation:
https://developer.elavon.com/#/api/eb6e9106-0172-4305-bc5a-b3ebe832f823.rcosoomi/documents?converge-integration-guide/book/processing_options/../../book/processing_options/mcc.html
ECS-272
Unit:
29 tests, 141 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
25 tests, 110 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Closes #3210
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/elavon.rb | 8 ++++++++
test/fixtures.yml | 6 +++---
test/remote/gateways/remote_elavon_test.rb | 9 +++++++++
4 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 0fcd70c16d7..49007de8620 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -9,6 +9,7 @@
* Checkout V2: Checkout V2: Correct success criteria [curiousepic] #3205
* Adyen: Add normalized hash of 3DS 2.0 data fields from web browsers [davidsantoso] #3207
* Stripe: Do not attempt application fee refund if refund was not successful [jasonwebster] #3206
+* Elavon: Send transaction_currency if currency is provided [gcatlin] #3201
== Version 1.93.0 (April 18, 2019)
* Stripe: Do not consider a refund unsuccessful if only refunding the fee failed [jasonwebster] #3188
diff --git a/lib/active_merchant/billing/gateways/elavon.rb b/lib/active_merchant/billing/gateways/elavon.rb
index ab234228e87..3bbe2138c6d 100644
--- a/lib/active_merchant/billing/gateways/elavon.rb
+++ b/lib/active_merchant/billing/gateways/elavon.rb
@@ -42,6 +42,7 @@ def purchase(money, payment_method, options = {})
else
add_creditcard(form, payment_method)
end
+ add_currency(form, money, options)
add_address(form, options)
add_customer_data(form, options)
add_test_mode(form, options)
@@ -54,6 +55,7 @@ def authorize(money, creditcard, options = {})
add_salestax(form, options)
add_invoice(form, options)
add_creditcard(form, creditcard)
+ add_currency(form, money, options)
add_address(form, options)
add_customer_data(form, options)
add_test_mode(form, options)
@@ -69,6 +71,7 @@ def capture(money, authorization, options = {})
add_approval_code(form, authorization)
add_invoice(form, options)
add_creditcard(form, options[:credit_card])
+ add_currency(form, money, options)
add_customer_data(form, options)
add_test_mode(form, options)
else
@@ -102,6 +105,7 @@ def credit(money, creditcard, options = {})
form = {}
add_invoice(form, options)
add_creditcard(form, creditcard)
+ add_currency(form, money, options)
add_address(form, options)
add_customer_data(form, options)
add_test_mode(form, options)
@@ -178,6 +182,10 @@ def add_creditcard(form, creditcard)
form[:last_name] = truncate(creditcard.last_name, 30)
end
+ def add_currency(form, money, options)
+ form[:transaction_currency] = options[:currency] if options[:currency]
+ end
+
def add_token(form, token)
form[:token] = token
end
diff --git a/test/fixtures.yml b/test/fixtures.yml
index e58150b1857..1044a03939d 100644
--- a/test/fixtures.yml
+++ b/test/fixtures.yml
@@ -276,9 +276,9 @@ efsnet:
# Provided for url update test
elavon:
- login: "000127"
- user: ssltest
- password: "IERAOBEE5V0D6Q3Q6R51TG89XAIVGEQ3LGLKMKCKCVQBGGGAU7FN627GPA54P5HR"
+ login: "009006"
+ user: "devportal"
+ password: "XWJS3QTFCH40HW0QGHJKXAYADCTDH0TXXAKXAEZCGCCJ29CFNPCZT4KA9D5KQMDA"
element:
account_id: "1013963"
diff --git a/test/remote/gateways/remote_elavon_test.rb b/test/remote/gateways/remote_elavon_test.rb
index 9c560e7ec77..55769bfdf5a 100644
--- a/test/remote/gateways/remote_elavon_test.rb
+++ b/test/remote/gateways/remote_elavon_test.rb
@@ -205,6 +205,15 @@ def test_successful_purchase_with_custom_fields
assert response.authorization
end
+ def test_successful_purchase_with_currency
+ assert response = @gateway.purchase(@amount, @credit_card, @options.merge(currency: 'JPY'))
+
+ assert_success response
+ assert response.test?
+ assert_equal 'APPROVAL', response.message
+ assert response.authorization
+ end
+
def test_transcript_scrubbing
transcript = capture_transcript(@gateway) do
@gateway.purchase(@amount, @credit_card, @options)
From 8db319a6757011f3924369cc5fc93a90c3fb08e7 Mon Sep 17 00:00:00 2001
From: Jared Knipp
Date: Wed, 8 May 2019 14:34:08 -0500
Subject: [PATCH 0332/2234] Elavon: Multi-currency support
Send the currency in the ssl_transaction_currency field only if the
user has specified they are using multi-currency. The multi-currency
flag can be set with either a gateway or transaction level field.
Using multi-currency depends on the merchant's multi-currency terminal
setting at Elavon.
ECS-272
Unit:
31 tests, 150 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
27 tests, 120 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
closes #3210
---
CHANGELOG | 1 +
.../billing/gateways/elavon.rb | 3 +-
test/fixtures.yml | 7 +++
test/remote/gateways/remote_elavon_test.rb | 24 +++++++++-
test/unit/gateways/elavon_test.rb | 44 +++++++++++++++++++
5 files changed, 76 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 49007de8620..1405ed0854e 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -10,6 +10,7 @@
* Adyen: Add normalized hash of 3DS 2.0 data fields from web browsers [davidsantoso] #3207
* Stripe: Do not attempt application fee refund if refund was not successful [jasonwebster] #3206
* Elavon: Send transaction_currency if currency is provided [gcatlin] #3201
+* Elavon: Multi-currency support [jknipp] #3210
== Version 1.93.0 (April 18, 2019)
* Stripe: Do not consider a refund unsuccessful if only refunding the fee failed [jasonwebster] #3188
diff --git a/lib/active_merchant/billing/gateways/elavon.rb b/lib/active_merchant/billing/gateways/elavon.rb
index 3bbe2138c6d..7abaa0abfd7 100644
--- a/lib/active_merchant/billing/gateways/elavon.rb
+++ b/lib/active_merchant/billing/gateways/elavon.rb
@@ -183,7 +183,8 @@ def add_creditcard(form, creditcard)
end
def add_currency(form, money, options)
- form[:transaction_currency] = options[:currency] if options[:currency]
+ currency = options[:currency] || currency(money)
+ form[:transaction_currency] = currency if currency && (@options[:multi_currency] || options[:multi_currency])
end
def add_token(form, token)
diff --git a/test/fixtures.yml b/test/fixtures.yml
index 1044a03939d..58a9623eca4 100644
--- a/test/fixtures.yml
+++ b/test/fixtures.yml
@@ -275,10 +275,17 @@ efsnet:
password: Y
# Provided for url update test
+
elavon:
+ login: "009005"
+ user: "devportal"
+ password: "BDDZY5KOUDCNPV4L3821K7PETO4Z7TPYOJB06TYBI1CW771IDHXBVBP51HZ6ZANJ"
+
+elavon_multi_currency:
login: "009006"
user: "devportal"
password: "XWJS3QTFCH40HW0QGHJKXAYADCTDH0TXXAKXAEZCGCCJ29CFNPCZT4KA9D5KQMDA"
+ multi_currency: true
element:
account_id: "1013963"
diff --git a/test/remote/gateways/remote_elavon_test.rb b/test/remote/gateways/remote_elavon_test.rb
index 55769bfdf5a..245978a2e80 100644
--- a/test/remote/gateways/remote_elavon_test.rb
+++ b/test/remote/gateways/remote_elavon_test.rb
@@ -3,6 +3,7 @@
class RemoteElavonTest < Test::Unit::TestCase
def setup
@gateway = ElavonGateway.new(fixtures(:elavon))
+ @multi_currency_gateway = ElavonGateway.new(fixtures(:elavon_multi_currency))
@credit_card = credit_card('4124939999999990')
@bad_credit_card = credit_card('invalid')
@@ -205,8 +206,27 @@ def test_successful_purchase_with_custom_fields
assert response.authorization
end
- def test_successful_purchase_with_currency
- assert response = @gateway.purchase(@amount, @credit_card, @options.merge(currency: 'JPY'))
+ def test_failed_purchase_with_multi_currency_terminal_setting_disabled
+ assert response = @gateway.purchase(@amount, @credit_card, @options.merge(currency: 'USD', multi_currency: true))
+
+ assert_failure response
+ assert response.test?
+ assert_equal 'Transaction currency is not allowed for this terminal. Your terminal must be setup with Multi currency', response.message
+ assert response.authorization
+ end
+
+ def test_successful_purchase_with_multi_currency_gateway_setting
+ assert response = @multi_currency_gateway.purchase(@amount, @credit_card, @options.merge(currency: 'JPY'))
+
+ assert_success response
+ assert response.test?
+ assert_equal 'APPROVAL', response.message
+ assert response.authorization
+ end
+
+ def test_successful_purchase_with_multi_currency_transaction_setting
+ @multi_currency_gateway.options.merge!(multi_currency: false)
+ assert response = @multi_currency_gateway.purchase(@amount, @credit_card, @options.merge(currency: 'JPY', multi_currency: true))
assert_success response
assert response.test?
diff --git a/test/unit/gateways/elavon_test.rb b/test/unit/gateways/elavon_test.rb
index cf8557ce0af..038f8200f39 100644
--- a/test/unit/gateways/elavon_test.rb
+++ b/test/unit/gateways/elavon_test.rb
@@ -10,6 +10,13 @@ def setup
:password => 'password'
)
+ @multi_currency_gateway = ElavonGateway.new(
+ :login => 'login',
+ :user => 'user',
+ :password => 'password',
+ :multi_currency => true
+ )
+
@credit_card = credit_card
@amount = 100
@@ -115,6 +122,26 @@ def test_successful_authorization_with_ip
assert_success response
end
+ def test_successful_purchase_with_multi_currency
+ response = stub_comms(@multi_currency_gateway) do
+ @multi_currency_gateway.purchase(@amount, @credit_card, @options.merge(currency: 'EUR'))
+ end.check_request do |endpoint, data, headers|
+ assert_match(/ssl_transaction_currency=EUR/, data)
+ end.respond_with(successful_purchase_with_multi_currency_response)
+
+ assert_success response
+ end
+
+ def test_successful_purchase_without_multi_currency
+ response = stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options.merge(currency: 'EUR', multi_currency: false))
+ end.check_request do |endpoint, data, headers|
+ assert_no_match(/ssl_transaction_currency=EUR/, data)
+ end.respond_with(successful_purchase_response)
+
+ assert_success response
+ end
+
def test_failed_capture
@gateway.expects(:ssl_post).returns(failed_authorization_response)
authorization = '123456INVALID;00000000-0000-0000-0000-00000000000'
@@ -298,6 +325,23 @@ def successful_purchase_response
ssl_txn_time=08/07/2009 09:54:18 PM"
end
+ def successful_purchase_with_multi_currency_response
+ "ssl_card_number=42********4242
+ ssl_exp_date=0910
+ ssl_amount=1.00
+ ssl_invoice_number=
+ ssl_description=Test Transaction
+ ssl_result=0
+ ssl_result_message=APPROVED
+ ssl_txn_id=00000000-0000-0000-0000-00000000000
+ ssl_approval_code=123456
+ ssl_cvv2_response=P
+ ssl_avs_response=X
+ ssl_account_balance=0.00
+ ssl_transaction_currency=EUR
+ ssl_txn_time=08/07/2009 09:54:18 PM"
+ end
+
def successful_refund_response
"ssl_card_number=42*****2222
ssl_exp_date=
From cb89418389a64746fae85f46870d441f78c6253d Mon Sep 17 00:00:00 2001
From: Jared Knipp
Date: Thu, 9 May 2019 10:56:20 -0500
Subject: [PATCH 0333/2234] Fix Rubocop in Elavon remote test
ECS-272
Remote:
27 tests, 120 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
test/remote/gateways/remote_elavon_test.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/remote/gateways/remote_elavon_test.rb b/test/remote/gateways/remote_elavon_test.rb
index 245978a2e80..1f89405e99a 100644
--- a/test/remote/gateways/remote_elavon_test.rb
+++ b/test/remote/gateways/remote_elavon_test.rb
@@ -225,7 +225,7 @@ def test_successful_purchase_with_multi_currency_gateway_setting
end
def test_successful_purchase_with_multi_currency_transaction_setting
- @multi_currency_gateway.options.merge!(multi_currency: false)
+ @multi_currency_gateway.options[:multi_currency] = false
assert response = @multi_currency_gateway.purchase(@amount, @credit_card, @options.merge(currency: 'JPY', multi_currency: true))
assert_success response
From e5084d26c476bce939c2dbf9d20c17b43bc8dd93 Mon Sep 17 00:00:00 2001
From: David Perry
Date: Mon, 6 May 2019 17:06:00 -0400
Subject: [PATCH 0334/2234] Adyen: Support preAuths and Synchronous Adjusts
Allows passing of authorisationType PreAuth to enable Adjusts to be made
on Auths, and allows passing of adjustAuthorisationData from responses
to support Synchronous Adjusts - this requires Adyen to set your account
to Synchronous Adjust mode.
Closes #3212
Remote:
60 tests, 187 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
37 tests, 179 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/adyen.rb | 8 ++-
test/remote/gateways/remote_adyen_test.rb | 57 +++++++++++++++----
test/unit/gateways/adyen_test.rb | 27 ++++++++-
4 files changed, 81 insertions(+), 12 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 1405ed0854e..cf93a6cfda6 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -11,6 +11,7 @@
* Stripe: Do not attempt application fee refund if refund was not successful [jasonwebster] #3206
* Elavon: Send transaction_currency if currency is provided [gcatlin] #3201
* Elavon: Multi-currency support [jknipp] #3210
+* Adyen: Support preAuths and Synchronous Adjusts [curiousepic] #3212
== Version 1.93.0 (April 18, 2019)
* Stripe: Do not consider a refund unsuccessful if only refunding the fee failed [jasonwebster] #3188
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index 6c393ef6082..d01e2f91383 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -80,6 +80,7 @@ def adjust(money, authorization, options={})
post = init_post(options)
add_invoice_for_modification(post, money, options)
add_reference(post, authorization, options)
+ add_extra_data(post, nil, options)
commit('adjustAuthorisation', post, options)
end
@@ -174,6 +175,9 @@ def add_extra_data(post, payment, options)
post[:additionalData][:overwriteBrand] = normalize(options[:overwrite_brand]) if options[:overwrite_brand]
post[:additionalData][:customRoutingFlag] = options[:custom_routing_flag] if options[:custom_routing_flag]
post[:additionalData]['paymentdatasource.type'] = NETWORK_TOKENIZATION_CARD_SOURCE[payment.source.to_s] if payment.is_a?(NetworkTokenizationCreditCard)
+ post[:additionalData][:authorisationType] = options[:authorisation_type] if options[:authorisation_type]
+ post[:additionalData][:adjustAuthorisationData] = options[:adjust_authorisation_data] if options[:adjust_authorisation_data]
+ post[:additionalData][:RequestedTestAcquirerResponseCode] = options[:requested_test_acquirer_response_code] if options[:requested_test_acquirer_response_code] && test?
post[:deviceFingerprint] = options[:device_fingerprint] if options[:device_fingerprint]
add_risk_data(post, options)
end
@@ -396,8 +400,10 @@ def success_from(action, response)
case action.to_s
when 'authorise', 'authorise3d'
['Authorised', 'Received', 'RedirectShopper'].include?(response['resultCode'])
- when 'capture', 'refund', 'cancel', 'adjustAuthorisation'
+ when 'capture', 'refund', 'cancel'
response['response'] == "[#{action}-received]"
+ when 'adjustAuthorisation'
+ response['response'] == 'Authorised' || response['response'] == '[adjustAuthorisation-received]'
else
false
end
diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb
index c402ceceaaa..223af74389d 100644
--- a/test/remote/gateways/remote_adyen_test.rb
+++ b/test/remote/gateways/remote_adyen_test.rb
@@ -365,20 +365,20 @@ def test_failed_void
assert_equal 'Original pspReference required for this operation', response.message
end
- def test_successful_adjust
- authorize = @gateway.authorize(@amount, @credit_card, @options)
+ def test_successful_asynchronous_adjust
+ authorize = @gateway.authorize(@amount, @credit_card, @options.merge(authorisation_type: 'PreAuth'))
assert_success authorize
- assert adjust = @gateway.adjust(200, authorize.authorization)
+ assert adjust = @gateway.adjust(200, authorize.authorization, @options)
assert_success adjust
assert_equal '[adjustAuthorisation-received]', adjust.message
end
- def test_successful_adjust_and_capture
- authorize = @gateway.authorize(@amount, @credit_card, @options)
+ def test_successful_asynchronous_adjust_and_capture
+ authorize = @gateway.authorize(@amount, @credit_card, @options.merge(authorisation_type: 'PreAuth'))
assert_success authorize
- assert adjust = @gateway.adjust(200, authorize.authorization)
+ assert adjust = @gateway.adjust(200, authorize.authorization, @options)
assert_success adjust
assert_equal '[adjustAuthorisation-received]', adjust.message
@@ -386,15 +386,52 @@ def test_successful_adjust_and_capture
assert_success capture
end
- def test_failed_adjust
- auth = @gateway.authorize(@amount, @credit_card, @options)
- assert_success auth
+ def test_failed_asynchronous_adjust
+ authorize = @gateway.authorize(@amount, @credit_card, @options.merge(authorisation_type: 'PreAuth'))
+ assert_success authorize
- assert response = @gateway.adjust(200, '')
+ assert response = @gateway.adjust(200, '', @options)
assert_failure response
assert_equal 'Original pspReference required for this operation', response.message
end
+ # Requires Adyen to set your test account to Synchronous Adjust mode.
+ def test_successful_synchronous_adjust_using_adjust_data
+ authorize = @gateway.authorize(@amount, @credit_card, @options.merge(authorisation_type: 'PreAuth'))
+ assert_success authorize
+
+ options = @options.merge(adjust_authorisation_data: authorize.params['additionalData']['adjustAuthorisationData'])
+ assert adjust = @gateway.adjust(200, authorize.authorization, options)
+ assert_success adjust
+ assert_equal 'Authorised', adjust.message
+ end
+
+ # Requires Adyen to set your test account to Synchronous Adjust mode.
+ def test_successful_synchronous_adjust_and_capture
+ authorize = @gateway.authorize(@amount, @credit_card, @options.merge(authorisation_type: 'PreAuth'))
+ assert_success authorize
+
+ options = @options.merge(adjust_authorisation_data: authorize.params['additionalData']['adjustAuthorisationData'])
+ assert adjust = @gateway.adjust(200, authorize.authorization, options)
+ assert_success adjust
+ assert_equal 'Authorised', adjust.message
+
+ assert capture = @gateway.capture(200, authorize.authorization)
+ assert_success capture
+ end
+
+ # Requires Adyen to set your test account to Synchronous Adjust mode.
+ def test_failed_synchronous_adjust_using_adjust_data
+ authorize = @gateway.authorize(@amount, @credit_card, @options.merge(authorisation_type: 'PreAuth'))
+ assert_success authorize
+
+ options = @options.merge(adjust_authorisation_data: authorize.params['additionalData']['adjustAuthorisationData'],
+ requested_test_acquirer_response_code: '2')
+ assert adjust = @gateway.adjust(200, authorize.authorization, options)
+ assert_failure adjust
+ assert_equal 'Refused', adjust.message
+ end
+
def test_successful_store
assert response = @gateway.store(@credit_card, @options)
diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb
index 8e5e41e4d5f..eb765ce23b7 100644
--- a/test/unit/gateways/adyen_test.rb
+++ b/test/unit/gateways/adyen_test.rb
@@ -315,7 +315,6 @@ def test_successful_adjust
response = @gateway.adjust(200, '8835544088660594')
assert_equal '8835544088660594#8835544088660594#', response.authorization
assert_equal '[adjustAuthorisation-received]', response.message
- assert response.test?
end
def test_failed_adjust
@@ -325,6 +324,20 @@ def test_failed_adjust
assert_failure response
end
+ def test_successful_synchronous_adjust
+ @gateway.expects(:ssl_post).returns(successful_synchronous_adjust_response)
+ response = @gateway.adjust(200, '8835544088660594')
+ assert_equal '8835544088660594#8835574118820108#', response.authorization
+ assert_equal 'Authorised', response.message
+ end
+
+ def test_failed_synchronous_adjust
+ @gateway.expects(:ssl_post).returns(failed_synchronous_adjust_response)
+ response = @gateway.adjust(200, '8835544088660594')
+ assert_equal 'Refused', response.message
+ assert_failure response
+ end
+
def test_successful_store
response = stub_comms do
@gateway.store(@credit_card, @options)
@@ -708,6 +721,18 @@ def failed_adjust_response
RESPONSE
end
+ def successful_synchronous_adjust_response
+ <<-RESPONSE
+ {\"additionalData\":{\"authCode\":\"70125\",\"adjustAuthorisationData\":\"BQABAQA9NtGnJAkLXKqW1C+VUeCNMzDf4WwzLFBiuQ8iaA2Yvflz41t0cYxtA7XVzG2pzlJPMnkSK75k3eByNS0\\/m0\\/N2+NnnKv\\/9rYPn8Pjq1jc7CapczdqZNl8P9FwqtIa4Kdeq7ZBNeGalx9oH4reutlFggzWCr+4eYXMRqMgQNI2Bu5XvwkqBbXwbDL05CuNPjjEwO64YrCpVBLrxk4vlW4fvCLFR0u8O68C+Y4swmsPDvGUxWpRgwNVqXsTmvt9z8hlej21BErL8fPEy+fJP4Zab8oyfcLrv9FJkHZq03cyzJpOzqX458Ctn9sIwBawXzNEFN5bCt6eT1rgp0yuHeMGEGwrjNl8rijez7Rd\\/vy1WUYAAMfmZFuJMQ73l1+Hkr0VlHv6crlyP\\/FVTY\\/XIUiGMqa1yM08Zu\\/Gur5N7lU8qnMi2WO9QPyHmmdlfo7+AGsrKrzV4wY\\/wISg0pcv8PypBWVq\\/hYoCqlHsGUuIiyGLIW7A8LtG6\\/JqAA9t\\/0EdnQVz0k06IEEYnBzkQoY8Qv3cVszgPQukGstBraB47gQdVDp9vmuQjMstt8Te56SDRxtfcu0z4nQIURVSkJJNj8RYfwXH9OUbz3Vd2vwoR3lCJFTCKIeW8sidNVB3xAZnddBVQ3P\\/QxPnrrRdCcnoWSGoEOBBIxgF00XwNxJ4P7Xj1bB7oq3M7k99dgPnSdZIjyvG6BWKnCQcGyVRB0yOaYBaOCmN66EgWfXoJR5BA4Jo6gnWnESWV62iUC8OCzmis1VagfaBn0A9vWNcqKFkUr\\/68s3w8ixLJFy+WdpAS\\/flzC3bJbvy9YR9nESKAP40XiNGz9iBROCfPI2bSOvdFf831RdTxWaE+ewAC3w9GsgEKAXxzWsVeSODWRZQA0TEVOfX8SaNVa5w3EXLDsRVnmKgUH8yQnEJQBGhDJXg1sEbowE07CzzdAY5Mc=\",\"refusalReasonRaw\":\"AUTHORISED\"},\"pspReference\":\"8835574118820108\",\"response\":\"Authorised\"}
+ RESPONSE
+ end
+
+ def failed_synchronous_adjust_response
+ <<-RESPONSE
+ {\"additionalData\":{\"authCode\":\"90745\",\"refusalReasonRaw\":\"2\"},\"pspReference\":\"8835574120337117\",\"response\":\"Refused\"}
+ RESPONSE
+ end
+
def successful_verify_response
<<-RESPONSE
{
From a30594ba8af91246990501637509290c3a78e9a0 Mon Sep 17 00:00:00 2001
From: Tanya Jajodia
Date: Thu, 9 May 2019 14:22:21 -0600
Subject: [PATCH 0335/2234] Worldpay: Support Unknown Card Type
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Adds support for unknown card types for Worldpay which resolves
exception errors. The expected result for such unknown cards is that the
transactions fail with the error message “XML failed validation:
Invalid payment details : Card number not recognised:”
Closes #3213
Remote:
40 tests, 171 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
95% passed
The 2 failures listed above existed prior to this change.
Unit:
49 tests, 268 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/worldpay.rb | 9 ++++-
test/remote/gateways/remote_worldpay_test.rb | 22 +++++++++++
test/unit/gateways/worldpay_test.rb | 39 +++++++++++++++++++
4 files changed, 69 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index cf93a6cfda6..9739c1eb905 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -12,6 +12,7 @@
* Elavon: Send transaction_currency if currency is provided [gcatlin] #3201
* Elavon: Multi-currency support [jknipp] #3210
* Adyen: Support preAuths and Synchronous Adjusts [curiousepic] #3212
+* WorldPay: Support Unknown Card Type [tanyajajodia] #3213
== Version 1.93.0 (April 18, 2019)
* Stripe: Do not consider a refund unsuccessful if only refunding the fee failed [jasonwebster] #3188
diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb
index ca4cf11a316..1ef40b61eeb 100644
--- a/lib/active_merchant/billing/gateways/worldpay.rb
+++ b/lib/active_merchant/billing/gateways/worldpay.rb
@@ -21,7 +21,8 @@ class WorldpayGateway < Gateway
'jcb' => 'JCB-SSL',
'maestro' => 'MAESTRO-SSL',
'diners_club' => 'DINERS-SSL',
- 'elo' => 'ELO-SSL'
+ 'elo' => 'ELO-SSL',
+ 'unknown' => 'CARD-SSL'
}
AVS_CODE_MAP = {
@@ -252,7 +253,7 @@ def add_payment_method(xml, amount, payment_method, options)
end
else
xml.tag! 'paymentDetails', credit_fund_transfer_attribute(options) do
- xml.tag! CARD_CODES[card_brand(payment_method)] do
+ xml.tag! card_code_for(payment_method) do
xml.tag! 'cardNumber', payment_method.number
xml.tag! 'expiryDate' do
xml.tag! 'date', 'month' => format(payment_method.month, :two_digits), 'year' => format(payment_method.year, :four_digits)
@@ -502,6 +503,10 @@ def currency_exponent(currency)
return 3 if three_decimal_currency?(currency)
return 2
end
+
+ def card_code_for(payment_method)
+ CARD_CODES[card_brand(payment_method)] || CARD_CODES['unknown']
+ end
end
end
end
diff --git a/test/remote/gateways/remote_worldpay_test.rb b/test/remote/gateways/remote_worldpay_test.rb
index 03f5c0c4fd4..653cc18234b 100644
--- a/test/remote/gateways/remote_worldpay_test.rb
+++ b/test/remote/gateways/remote_worldpay_test.rb
@@ -16,6 +16,7 @@ def setup
:verification_value => '737',
:brand => 'elo'
)
+ @sodexo_voucher = credit_card('6060704495764400', brand: 'sodexo')
@declined_card = credit_card('4111111111111111', :first_name => nil, :last_name => 'REFUSED')
@threeDS_card = credit_card('4111111111111111', :first_name => nil, :last_name => '3D')
@threeDS_card_external_MPI = credit_card('4444333322221111', :first_name => 'AA', :last_name => 'BD')
@@ -451,6 +452,27 @@ def test_transcript_scrubbing
assert_scrubbed(@credit_card.verification_value.to_s, clean_transcript)
end
+ def test_failed_authorize_with_unknown_card
+ assert auth = @gateway.authorize(@amount, @sodexo_voucher, @options)
+ assert_failure auth
+ assert_equal '5', auth.error_code
+ assert_match %r{XML failed validation: Invalid payment details : Card number not recognised:}, auth.message
+ end
+
+ def test_failed_purchase_with_unknown_card
+ assert response = @gateway.purchase(@amount, @sodexo_voucher, @options)
+ assert_failure response
+ assert_equal '5', response.error_code
+ assert_match %r{XML failed validation: Invalid payment details : Card number not recognised:}, response.message
+ end
+
+ def test_failed_verify_with_unknown_card
+ response = @gateway.verify(@sodexo_voucher, @options)
+ assert_failure response
+ assert_equal '5', response.error_code
+ assert_match %r{XML failed validation: Invalid payment details : Card number not recognised:}, response.message
+ end
+
# Worldpay has a delay between asking for a transaction to be captured and actually marking it as captured
# These 2 tests work if you get authorizations from a purchase, wait some time and then perform the refund/void operation.
#
diff --git a/test/unit/gateways/worldpay_test.rb b/test/unit/gateways/worldpay_test.rb
index 1810f8d22ae..b9351146a85 100644
--- a/test/unit/gateways/worldpay_test.rb
+++ b/test/unit/gateways/worldpay_test.rb
@@ -19,6 +19,7 @@ def setup
:verification_value => '737',
:brand => 'elo'
)
+ @sodexo_voucher = credit_card('6060704495764400', brand: 'sodexo')
@options = {:order_id => 1}
end
@@ -577,6 +578,30 @@ def test_3ds_version_2_request
end.respond_with(successful_authorize_response)
end
+ def test_failed_authorize_with_unknown_card
+ response = stub_comms do
+ @gateway.authorize(@amount, @sodexo_voucher, @options)
+ end.respond_with(failed_with_unknown_card_response)
+ assert_failure response
+ assert_equal '5', response.error_code
+ end
+
+ def test_failed_purchase_with_unknown_card
+ response = stub_comms do
+ @gateway.purchase(@amount, @sodexo_voucher, @options)
+ end.respond_with(failed_with_unknown_card_response)
+ assert_failure response
+ assert_equal '5', response.error_code
+ end
+
+ def test_failed_verify_with_unknown_card
+ @gateway.expects(:ssl_post).returns(failed_with_unknown_card_response)
+
+ response = @gateway.verify(@sodexo_voucher, @options)
+ assert_failure response
+ assert_equal '5', response.error_code
+ end
+
private
def three_d_secure_option(version)
@@ -1071,4 +1096,18 @@ def scrubbed_transcript
TRANSCRIPT
end
+
+ def failed_with_unknown_card_response
+ <<-RESPONSE
+
+
+
+
+
+
+
+
+
+ RESPONSE
+ end
end
From d6e96a54ff6be82b95a0d9d927ce9aa2a64793ad Mon Sep 17 00:00:00 2001
From: David Perry
Date: Tue, 14 May 2019 10:20:38 -0400
Subject: [PATCH 0336/2234] Mundipagg: Make gateway_affiliation_id an option
gateway_affiliation_id was originally implemented as a gateway-level
credential (named gateway_id). However, this field makes more sense as a
transaction-level field. Retains the pointer to @options[:gateway_id] as
a backward compatible fallback.
Closes #3219
Remote:
24 tests, 59 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
18 tests, 78 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/mundipagg.rb | 3 ++-
test/fixtures.yml | 2 ++
test/remote/gateways/remote_mundipagg_test.rb | 11 +++++++++++
test/unit/gateways/mundipagg_test.rb | 15 +++++++++++++++
5 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 9739c1eb905..ba546097a2f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -13,6 +13,7 @@
* Elavon: Multi-currency support [jknipp] #3210
* Adyen: Support preAuths and Synchronous Adjusts [curiousepic] #3212
* WorldPay: Support Unknown Card Type [tanyajajodia] #3213
+* Mundipagg: Make gateway_affiliation_id an option [curiousepic] #3219
== Version 1.93.0 (April 18, 2019)
* Stripe: Do not consider a refund unsuccessful if only refunding the fee failed [jasonwebster] #3188
diff --git a/lib/active_merchant/billing/gateways/mundipagg.rb b/lib/active_merchant/billing/gateways/mundipagg.rb
index 04f39464ab4..24b7b6fa46c 100644
--- a/lib/active_merchant/billing/gateways/mundipagg.rb
+++ b/lib/active_merchant/billing/gateways/mundipagg.rb
@@ -155,7 +155,8 @@ def add_payment(post, payment, options)
post[:customer][:name] = payment.name if post[:customer]
post[:customer_id] = parse_auth(payment)[0] if payment.is_a?(String)
post[:payment] = {}
- post[:payment][:gateway_affiliation_id] = @options[:gateway_id] if @options[:gateway_id]
+ affiliation = options[:gateway_affiliation_id] || @options[:gateway_id]
+ post[:payment][:gateway_affiliation_id] = affiliation if affiliation
post[:payment][:metadata] = { mundipagg_payment_method_code: '1' } if test?
if voucher?(payment)
add_voucher(post, payment, options)
diff --git a/test/fixtures.yml b/test/fixtures.yml
index 58a9623eca4..c366801fbf0 100644
--- a/test/fixtures.yml
+++ b/test/fixtures.yml
@@ -550,6 +550,8 @@ money_movers:
mundipagg:
api_key: api_key
+ gateway_affiliation_id: gateway_affiliation_id
+ # left for backward-compatibility
gateway_id: gateway_id
# Working credentials, no need to replace
diff --git a/test/remote/gateways/remote_mundipagg_test.rb b/test/remote/gateways/remote_mundipagg_test.rb
index bc74b69b5f6..b8b4791caf2 100644
--- a/test/remote/gateways/remote_mundipagg_test.rb
+++ b/test/remote/gateways/remote_mundipagg_test.rb
@@ -13,6 +13,7 @@ def setup
# See https://docs.mundipagg.com/docs/simulador-de-voucher.
@vr_voucher = credit_card('4000000000000010', brand: 'vr')
@options = {
+ gateway_affiliation_id: fixtures(:mundipagg)[:gateway_affiliation_id],
billing_address: address({neighborhood: 'Sesame Street'}),
description: 'Store Purchase'
}
@@ -187,6 +188,16 @@ def test_invalid_login
assert_match %r{Invalid API key; Authorization has been denied for this request.}, response.message
end
+ def test_gateway_id_fallback
+ gateway = MundipaggGateway.new(api_key: fixtures(:mundipagg)[:api_key], gateway_id: fixtures(:mundipagg)[:gateway_id])
+ options = {
+ billing_address: address({neighborhood: 'Sesame Street'}),
+ description: 'Store Purchase'
+ }
+ response = gateway.purchase(@amount, @credit_card, options)
+ assert_success response
+ end
+
def test_transcript_scrubbing
transcript = capture_transcript(@gateway) do
@gateway.purchase(@amount, @credit_card, @options)
diff --git a/test/unit/gateways/mundipagg_test.rb b/test/unit/gateways/mundipagg_test.rb
index 93b023f3f44..c41b1798260 100644
--- a/test/unit/gateways/mundipagg_test.rb
+++ b/test/unit/gateways/mundipagg_test.rb
@@ -8,6 +8,7 @@ def setup
@amount = 100
@options = {
+ gateway_affiliation_id: 'abc123',
order_id: '1',
billing_address: address,
description: 'Store Purchase'
@@ -168,6 +169,20 @@ def test_sucessful_store
assert response.test?
end
+ def test_gateway_id_fallback
+ gateway = MundipaggGateway.new(api_key: 'my_api_key', gateway_id: 'abc123')
+ options = {
+ order_id: '1',
+ billing_address: address,
+ description: 'Store Purchase'
+ }
+ stub_comms do
+ gateway.purchase(@amount, @credit_card, options)
+ end.check_request do |endpoint, data, headers|
+ assert_match(/"gateway_affiliation_id":"abc123"/, data)
+ end.respond_with(successful_purchase_response)
+ end
+
def test_scrub
assert @gateway.supports_scrubbing?
assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed
From 4c63a5b152309c5c39edc6202919072c0c39a037 Mon Sep 17 00:00:00 2001
From: Tanya Jajodia
Date: Mon, 13 May 2019 14:30:44 -0600
Subject: [PATCH 0337/2234] Cybersource: Adds Elo Card Type
Adds Elo card type to list of supported cardtypes.
Closes #3220
Remote:
55 tests, 243 assertions, 5 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
90.9091% passed
The 5 failures listed above are unrelated and pre-existing to this change.
Unit:
57 tests, 277 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/cyber_source.rb | 5 +-
.../gateways/remote_cyber_source_test.rb | 81 +++++++++++++++++++
test/unit/gateways/cyber_source_test.rb | 59 ++++++++++++++
4 files changed, 144 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index ba546097a2f..af04bc0d463 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -14,6 +14,7 @@
* Adyen: Support preAuths and Synchronous Adjusts [curiousepic] #3212
* WorldPay: Support Unknown Card Type [tanyajajodia] #3213
* Mundipagg: Make gateway_affiliation_id an option [curiousepic] #3219
+* CyberSource: Adds Elo Card Type [tanyajajodia] #3220
== Version 1.93.0 (April 18, 2019)
* Stripe: Do not consider a refund unsuccessful if only refunding the fee failed [jasonwebster] #3188
diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb
index 6f8afd7e6a0..1d778a4cc63 100644
--- a/lib/active_merchant/billing/gateways/cyber_source.rb
+++ b/lib/active_merchant/billing/gateways/cyber_source.rb
@@ -26,7 +26,7 @@ class CyberSourceGateway < Gateway
XSD_VERSION = '1.153'
- self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb, :dankort, :maestro]
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb, :dankort, :maestro, :elo]
self.supported_countries = %w(US BR CA CN DK FI FR DE IN JP MX NO SE GB SG LB)
self.default_currency = 'USD'
@@ -43,7 +43,8 @@ class CyberSourceGateway < Gateway
:diners_club => '005',
:jcb => '007',
:dankort => '034',
- :maestro => '042'
+ :maestro => '042',
+ :elo => '054'
}
@@response_codes = {
diff --git a/test/remote/gateways/remote_cyber_source_test.rb b/test/remote/gateways/remote_cyber_source_test.rb
index 2eef0084348..5e969259250 100644
--- a/test/remote/gateways/remote_cyber_source_test.rb
+++ b/test/remote/gateways/remote_cyber_source_test.rb
@@ -9,6 +9,12 @@ def setup
@credit_card = credit_card('4111111111111111', verification_value: '321')
@declined_card = credit_card('801111111111111')
@pinless_debit_card = credit_card('4002269999999999')
+ @elo_credit_card = credit_card('5067310000000010',
+ verification_value: '321',
+ month: '12',
+ year: (Time.now.year + 2).to_s,
+ brand: :elo
+ )
@three_ds_unenrolled_card = credit_card('4000000000000051',
verification_value: '321',
month: '12',
@@ -101,6 +107,14 @@ def test_successful_authorization
assert !response.authorization.blank?
end
+ def test_successful_authorization_with_elo
+ assert response = @gateway.authorize(@amount, @elo_credit_card, @options)
+ assert_equal 'Successful transaction', response.message
+ assert_success response
+ assert response.test?
+ assert !response.authorization.blank?
+ end
+
def test_unsuccessful_authorization
assert response = @gateway.authorize(@amount, @declined_card, @options)
assert response.test?
@@ -128,6 +142,17 @@ def test_capture_and_void
assert void.test?
end
+ def test_capture_and_void_with_elo
+ assert auth = @gateway.authorize(@amount, @elo_credit_card, @options)
+ assert_success auth
+ assert capture = @gateway.capture(@amount, auth.authorization, @options)
+ assert_success capture
+ assert void = @gateway.void(capture.authorization, @options)
+ assert_equal 'Successful transaction', void.message
+ assert_success void
+ assert void.test?
+ end
+
def test_successful_tax_calculation
assert response = @gateway.calculate_tax(@credit_card, @options)
assert_equal 'Successful transaction', response.message
@@ -143,6 +168,14 @@ def test_successful_purchase
assert response.test?
end
+ def test_successful_purchase_with_elo
+ assert response = @gateway.purchase(@amount, @elo_credit_card, @options)
+ assert_success response
+ assert_equal 'Successful transaction', response.message
+ assert_success response
+ assert response.test?
+ end
+
def test_successful_purchase_sans_options
assert response = @gateway.purchase(@amount, @credit_card)
assert_equal 'Successful transaction', response.message
@@ -202,6 +235,15 @@ def test_authorize_and_capture
assert_success capture
end
+ def test_authorize_and_capture_with_elo
+ assert auth = @gateway.authorize(@amount, @elo_credit_card, @options)
+ assert_success auth
+ assert_equal 'Successful transaction', auth.message
+
+ assert capture = @gateway.capture(@amount, auth.authorization)
+ assert_success capture
+ end
+
def test_successful_authorization_and_failed_capture
assert auth = @gateway.authorize(@amount, @credit_card, @options)
assert_success auth
@@ -225,6 +267,10 @@ def test_invalid_login
assert_equal "wsse:FailedCheck: \nSecurity Data : UsernameToken authentication failed.\n", response.message
end
+ # Unable to test refunds for Elo cards, as the test account is setup to have
+ # Elo transactions routed to Comercio Latino which has very specific rules on
+ # refunds (i.e. that you cannot do a "Stand-Alone" refund). This means we need
+ # to go through a Capture cycle at least a day before submitting a refund.
def test_successful_refund
assert response = @gateway.purchase(@amount, @credit_card, @options)
assert_equal 'Successful transaction', response.message
@@ -300,6 +346,18 @@ def test_successful_subscription_purchase
assert response.test?
end
+ def test_successful_subscription_purchase_with_elo
+ assert response = @gateway.store(@elo_credit_card, @subscription_options)
+ assert_equal 'Successful transaction', response.message
+ assert_success response
+ assert response.test?
+
+ assert response = @gateway.purchase(@amount, response.authorization, :order_id => generate_unique_id)
+ assert_equal 'Successful transaction', response.message
+ assert_success response
+ assert response.test?
+ end
+
def test_successful_subscription_credit
assert response = @gateway.store(@credit_card, @subscription_options)
assert_equal 'Successful transaction', response.message
@@ -320,6 +378,13 @@ def test_successful_create_subscription
assert response.test?
end
+ def test_successful_create_subscription_with_elo
+ assert response = @gateway.store(@elo_credit_card, @subscription_options)
+ assert_equal 'Successful transaction', response.message
+ assert_success response
+ assert response.test?
+ end
+
def test_successful_create_subscription_with_setup_fee
assert response = @gateway.store(@credit_card, @subscription_options.merge(:setup_fee => 100))
assert_equal 'Successful transaction', response.message
@@ -370,6 +435,16 @@ def test_successful_delete_subscription
assert response.test?
end
+ def test_successful_delete_subscription_with_elo
+ assert response = @gateway.store(@elo_credit_card, @subscription_options)
+ assert response.success?
+ assert response.test?
+
+ assert response = @gateway.unstore(response.authorization, :order_id => generate_unique_id)
+ assert response.success?
+ assert response.test?
+ end
+
def test_successful_retrieve_subscription
assert response = @gateway.store(@credit_card, @subscription_options)
assert response.success?
@@ -486,6 +561,12 @@ def pares
PARES
end
+ def test_successful_verify_with_elo
+ response = @gateway.verify(@elo_credit_card, @options)
+ assert_equal 'Successful transaction', response.message
+ assert_success response
+ end
+
def test_verify_credentials
assert @gateway.verify_credentials
diff --git a/test/unit/gateways/cyber_source_test.rb b/test/unit/gateways/cyber_source_test.rb
index cbec9080e33..1ed19d716dc 100644
--- a/test/unit/gateways/cyber_source_test.rb
+++ b/test/unit/gateways/cyber_source_test.rb
@@ -15,6 +15,7 @@ def setup
@amount = 100
@customer_ip = '127.0.0.1'
@credit_card = credit_card('4111111111111111', :brand => 'visa')
+ @elo_credit_card = credit_card('5067310000000010', :brand => 'elo')
@declined_card = credit_card('801111111111111', :brand => 'visa')
@check = check()
@@ -63,6 +64,16 @@ def test_successful_credit_card_purchase
assert response.test?
end
+ def test_successful_credit_card_purchase_with_elo
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
+
+ assert response = @gateway.purchase(@amount, @elo_credit_card, @options)
+ assert_equal 'Successful transaction', response.message
+ assert_success response
+ assert_equal "#{@options[:order_id]};#{response.params['requestID']};#{response.params['requestToken']};purchase;100;USD;", response.authorization
+ assert response.test?
+ end
+
def test_purchase_includes_customer_ip
customer_ip_regexp = /#{@customer_ip}<\//
@gateway.expects(:ssl_post).
@@ -198,6 +209,14 @@ def test_successful_auth_request
assert response.test?
end
+ def test_successful_auth_with_elo_request
+ @gateway.stubs(:ssl_post).returns(successful_authorization_response)
+ assert response = @gateway.authorize(@amount, @elo_credit_card, @options)
+ assert_equal Response, response.class
+ assert response.success?
+ assert response.test?
+ end
+
def test_successful_credit_card_tax_request
@gateway.stubs(:ssl_post).returns(successful_tax_response)
assert response = @gateway.calculate_tax(@credit_card, @options)
@@ -216,6 +235,16 @@ def test_successful_credit_card_capture_request
assert response_capture.test?
end
+ def test_successful_credit_card_capture_with_elo_request
+ @gateway.stubs(:ssl_post).returns(successful_authorization_response, successful_capture_response)
+ assert response = @gateway.authorize(@amount, @elo_credit_card, @options)
+ assert response.success?
+ assert response.test?
+ assert response_capture = @gateway.capture(@amount, response.authorization)
+ assert response_capture.success?
+ assert response_capture.test?
+ end
+
def test_successful_credit_card_purchase_request
@gateway.stubs(:ssl_post).returns(successful_capture_response)
assert response = @gateway.purchase(@amount, @credit_card, @options)
@@ -223,6 +252,13 @@ def test_successful_credit_card_purchase_request
assert response.test?
end
+ def test_successful_credit_card_purchase_with_elo_request
+ @gateway.stubs(:ssl_post).returns(successful_capture_response)
+ assert response = @gateway.purchase(@amount, @elo_credit_card, @options)
+ assert response.success?
+ assert response.test?
+ end
+
def test_successful_check_purchase_request
@gateway.stubs(:ssl_post).returns(successful_capture_response)
assert response = @gateway.purchase(@amount, @check, @options)
@@ -296,6 +332,13 @@ def test_successful_refund_request
assert_success(@gateway.refund(@amount, response.authorization))
end
+ def test_successful_refund_with_elo_request
+ @gateway.stubs(:ssl_post).returns(successful_capture_response, successful_refund_response)
+ assert_success(response = @gateway.purchase(@amount, @elo_credit_card, @options))
+
+ assert_success(@gateway.refund(@amount, response.authorization))
+ end
+
def test_successful_credit_request
@gateway.stubs(:ssl_post).returns(successful_create_subscription_response, successful_credit_response)
@@ -323,6 +366,15 @@ def test_successful_void_authorization_request
assert response_void.success?
end
+ def test_successful_void_authorization_with_elo_request
+ @gateway.stubs(:ssl_post).returns(successful_authorization_response, successful_void_response)
+ assert response = @gateway.authorize(@amount, @elo_credit_card, @options)
+ assert response.success?
+ assert response.test?
+ assert response_void = @gateway.void(response.authorization, @options)
+ assert response_void.success?
+ end
+
def test_validate_pinless_debit_card_request
@gateway.stubs(:ssl_post).returns(successful_validate_pinless_debit_card)
assert response = @gateway.validate_pinless_debit_card(@credit_card, @options)
@@ -345,6 +397,13 @@ def test_successful_verify
assert_success response
end
+ def test_successful_verify_with_elo
+ response = stub_comms(@gateway, :ssl_request) do
+ @gateway.verify(@elo_credit_card, @options)
+ end.respond_with(successful_authorization_response)
+ assert_success response
+ end
+
def test_unsuccessful_verify
response = stub_comms(@gateway, :ssl_request) do
@gateway.verify(@credit_card, @options)
From aa0040293c38179f5638b4bed257ddad64ab4672 Mon Sep 17 00:00:00 2001
From: David Perry
Date: Thu, 16 May 2019 16:26:19 -0400
Subject: [PATCH 0338/2234] CyberSource: Support standalone credit for cards
Unit:
58 tests, 279 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote (5 persistent unrelated failures):
56 tests, 247 assertions, 5 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
91.0714% passed
---
CHANGELOG | 1 +
.../billing/gateways/cyber_source.rb | 12 ++++++------
.../gateways/remote_cyber_source_test.rb | 18 +++++++++++++++++-
test/unit/gateways/cyber_source_test.rb | 18 +++++++++++++++---
4 files changed, 39 insertions(+), 10 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index af04bc0d463..498bdab9beb 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -15,6 +15,7 @@
* WorldPay: Support Unknown Card Type [tanyajajodia] #3213
* Mundipagg: Make gateway_affiliation_id an option [curiousepic] #3219
* CyberSource: Adds Elo Card Type [tanyajajodia] #3220
+* CyberSource: Support standalone credit for cards [curiousepic] 3225
== Version 1.93.0 (April 18, 2019)
* Stripe: Do not consider a refund unsuccessful if only refunding the fee failed [jasonwebster] #3188
diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb
index 1d778a4cc63..4228cf1ba66 100644
--- a/lib/active_merchant/billing/gateways/cyber_source.rb
+++ b/lib/active_merchant/billing/gateways/cyber_source.rb
@@ -143,9 +143,10 @@ def verify(payment, options = {})
end
end
- # Adds credit to a subscription (stand alone credit).
- def credit(money, reference, options = {})
- commit(build_credit_request(money, reference, options), :credit, money, options)
+ # Adds credit to a card or subscription (stand alone credit).
+ def credit(money, creditcard_or_reference, options = {})
+ setup_address_hash(options)
+ commit(build_credit_request(money, creditcard_or_reference, options), :credit, money, options)
end
# Stores a customer subscription/profile with type "on-demand".
@@ -328,11 +329,10 @@ def build_refund_request(money, identification, options)
xml.target!
end
- def build_credit_request(money, reference, options)
+ def build_credit_request(money, creditcard_or_reference, options)
xml = Builder::XmlMarkup.new :indent => 2
- add_purchase_data(xml, money, true, options)
- add_subscription(xml, options, reference)
+ add_payment_method_or_subscription(xml, money, creditcard_or_reference, options)
add_credit_service(xml)
xml.target!
diff --git a/test/remote/gateways/remote_cyber_source_test.rb b/test/remote/gateways/remote_cyber_source_test.rb
index 5e969259250..0969ada813a 100644
--- a/test/remote/gateways/remote_cyber_source_test.rb
+++ b/test/remote/gateways/remote_cyber_source_test.rb
@@ -358,7 +358,23 @@ def test_successful_subscription_purchase_with_elo
assert response.test?
end
- def test_successful_subscription_credit
+ def test_successful_standalone_credit_to_card
+ assert response = @gateway.credit(@amount, @credit_card, @options)
+
+ assert_equal 'Successful transaction', response.message
+ assert_success response
+ assert response.test?
+ end
+
+ def test_failed_standalone_credit_to_card
+ assert response = @gateway.credit(@amount, @declined_card, @options)
+
+ assert_equal 'Invalid account number', response.message
+ assert_failed response
+ assert response.test?
+ end
+
+ def test_successful_standalone_credit_to_subscription
assert response = @gateway.store(@credit_card, @subscription_options)
assert_equal 'Successful transaction', response.message
assert_success response
diff --git a/test/unit/gateways/cyber_source_test.rb b/test/unit/gateways/cyber_source_test.rb
index 1ed19d716dc..27a1be0bc20 100644
--- a/test/unit/gateways/cyber_source_test.rb
+++ b/test/unit/gateways/cyber_source_test.rb
@@ -339,8 +339,14 @@ def test_successful_refund_with_elo_request
assert_success(@gateway.refund(@amount, response.authorization))
end
- def test_successful_credit_request
- @gateway.stubs(:ssl_post).returns(successful_create_subscription_response, successful_credit_response)
+ def test_successful_credit_to_card_request
+ @gateway.stubs(:ssl_post).returns(successful_card_credit_response)
+
+ assert_success(@gateway.credit(@amount, @credit_card, @options))
+ end
+
+ def test_successful_credit_to_subscription_request
+ @gateway.stubs(:ssl_post).returns(successful_create_subscription_response, successful_subscription_credit_response)
assert response = @gateway.store(@credit_card, @subscription_options)
assert response.success?
@@ -784,7 +790,13 @@ def successful_refund_response
XML
end
- def successful_credit_response
+ def successful_card_credit_response
+ <<-XML
+\n\n2019-05-16T20:25:05.234Z329b25a4540e05c731a4fb16112e4c725580383051126990804008ACCEPT100Ahj/7wSTLoNfMt0KyZQoGxDdm1ctGjlmo0/RdCA4BUafouhAdpAfJHYQyaSZbpAdvSeAnJl0GvmW6FZMoUAA/SE0USD1002019-05-16T20:25:05Z1.007359449300012345678901201234567
+ XML
+ end
+
+ def successful_subscription_credit_response
<<-XML
From 99b5cf1aa266219b1abf6b3e433988bdded85c30 Mon Sep 17 00:00:00 2001
From: "Jonathan G.V"
Date: Tue, 21 May 2019 15:20:50 -0400
Subject: [PATCH 0339/2234] Release v.1.94.0
---
CHANGELOG | 1 +
lib/active_merchant/version.rb | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 498bdab9beb..f9e11113f09 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
= ActiveMerchant CHANGELOG
== HEAD
+== Version 1.94.0 (May 21, 2019)
* Mundipagg: Fix number lengths for both VR and Sodexo [dtykocki] #3195
* Stripe: Support show and list webhook endpoints [jknipp] #3196
* CardConnect: Add frontendid parameter to requests [gcatlin] #3198
diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb
index a2e7f741aee..2052700c7b1 100644
--- a/lib/active_merchant/version.rb
+++ b/lib/active_merchant/version.rb
@@ -1,3 +1,3 @@
module ActiveMerchant
- VERSION = '1.93.0'
+ VERSION = '1.94.0'
end
From 69f0da17916fde9ba4b7ae2e6ece79bd8a6df1f1 Mon Sep 17 00:00:00 2001
From: David Perry
Date: Tue, 21 May 2019 13:53:39 -0400
Subject: [PATCH 0340/2234] Adyen: Constantize version to fix subdomains
Closes #3228
Remote:
60 tests, 187 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit (subdomain test run and verified independently):
37 tests, 179 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 3 ++-
lib/active_merchant/billing/gateways/adyen.rb | 12 +++++++-----
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index f9e11113f09..0ef1b948f51 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -16,7 +16,8 @@
* WorldPay: Support Unknown Card Type [tanyajajodia] #3213
* Mundipagg: Make gateway_affiliation_id an option [curiousepic] #3219
* CyberSource: Adds Elo Card Type [tanyajajodia] #3220
-* CyberSource: Support standalone credit for cards [curiousepic] 3225
+* CyberSource: Support standalone credit for cards [curiousepic] #3225
+* Adyen: Constantize version to fix subdomains [curiousepic] #3228
== Version 1.93.0 (April 18, 2019)
* Stripe: Do not consider a refund unsuccessful if only refunding the fee failed [jasonwebster] #3188
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index d01e2f91383..42c1cca11e9 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -4,8 +4,8 @@ class AdyenGateway < Gateway
# we recommend setting up merchant-specific endpoints.
# https://docs.adyen.com/developers/api-manual#apiendpoints
- self.test_url = 'https://pal-test.adyen.com/pal/servlet/Payment/v40'
- self.live_url = 'https://pal-live.adyen.com/pal/servlet/Payment/v40'
+ self.test_url = 'https://pal-test.adyen.com/pal/servlet/Payment/'
+ self.live_url = 'https://pal-live.adyen.com/pal/servlet/Payment/'
self.supported_countries = ['AT', 'AU', 'BE', 'BG', 'BR', 'CH', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GB', 'GI', 'GR', 'HK', 'HU', 'IE', 'IS', 'IT', 'LI', 'LT', 'LU', 'LV', 'MC', 'MT', 'MX', 'NL', 'NO', 'PL', 'PT', 'RO', 'SE', 'SG', 'SK', 'SI', 'US']
self.default_currency = 'USD'
@@ -16,6 +16,8 @@ class AdyenGateway < Gateway
self.homepage_url = 'https://www.adyen.com/'
self.display_name = 'Adyen'
+ API_VERSION = 'v40'
+
STANDARD_ERROR_CODE_MAPPING = {
'101' => STANDARD_ERROR_CODE[:incorrect_number],
'103' => STANDARD_ERROR_CODE[:invalid_cvc],
@@ -375,11 +377,11 @@ def cvv_result_from(response)
def url
if test?
- test_url
+ "#{test_url}#{API_VERSION}"
elsif @options[:subdomain]
- "https://#{@options[:subdomain]}-pal-live.adyenpayments.com/pal/servlet/Payment/v18"
+ "https://#{@options[:subdomain]}-pal-live.adyenpayments.com/pal/servlet/Payment/#{API_VERSION}"
else
- live_url
+ "#{live_url}#{API_VERSION}"
end
end
From c0b95f1eb5fb3e125f2f304f897b86cc0931b0e7 Mon Sep 17 00:00:00 2001
From: David Perry
Date: Tue, 21 May 2019 15:34:37 -0400
Subject: [PATCH 0341/2234] Fix Changelog
---
CHANGELOG | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 0ef1b948f51..3831298d95d 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,9 @@
= ActiveMerchant CHANGELOG
== HEAD
+* Adyen: Constantize version to fix subdomains [curiousepic] #3228
+
+
== Version 1.94.0 (May 21, 2019)
* Mundipagg: Fix number lengths for both VR and Sodexo [dtykocki] #3195
* Stripe: Support show and list webhook endpoints [jknipp] #3196
@@ -17,7 +20,6 @@
* Mundipagg: Make gateway_affiliation_id an option [curiousepic] #3219
* CyberSource: Adds Elo Card Type [tanyajajodia] #3220
* CyberSource: Support standalone credit for cards [curiousepic] #3225
-* Adyen: Constantize version to fix subdomains [curiousepic] #3228
== Version 1.93.0 (April 18, 2019)
* Stripe: Do not consider a refund unsuccessful if only refunding the fee failed [jasonwebster] #3188
From 791b762522313161849e9415731741919b390f0f Mon Sep 17 00:00:00 2001
From: molbrown
Date: Tue, 14 May 2019 12:00:33 -0400
Subject: [PATCH 0342/2234] Qvalent: Adds support for standard stored
credential framework
Includes ECI, posEntryMode, storedCredentialUsage, and authTraceID fields,
for Qvalent's requirements for use of stored Visa and Mastercards.
Mastercard will not accept all fields required by Visa.
Unit:
23 tests, 120 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
22 tests, 70 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
ECS-174
---
CHANGELOG | 2 +-
.../billing/gateways/qvalent.rb | 44 ++++++++++++-
test/remote/gateways/remote_qvalent_test.rb | 52 ++++++++++++++-
test/unit/gateways/qvalent_test.rb | 65 +++++++++++++++++++
4 files changed, 160 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 3831298d95d..29dc8ef5954 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,7 +2,7 @@
== HEAD
* Adyen: Constantize version to fix subdomains [curiousepic] #3228
-
+* Qvalent: Adds support for standard stored credential framework [molbrown] #3227
== Version 1.94.0 (May 21, 2019)
* Mundipagg: Fix number lengths for both VR and Sodexo [dtykocki] #3195
diff --git a/lib/active_merchant/billing/gateways/qvalent.rb b/lib/active_merchant/billing/gateways/qvalent.rb
index 10b693cd0c5..420b8cccc96 100644
--- a/lib/active_merchant/billing/gateways/qvalent.rb
+++ b/lib/active_merchant/billing/gateways/qvalent.rb
@@ -27,6 +27,7 @@ def purchase(amount, payment_method, options={})
add_order_number(post, options)
add_payment_method(post, payment_method)
add_verification_value(post, payment_method)
+ add_stored_credential_data(post, payment_method, options)
add_customer_data(post, options)
add_soft_descriptors(post, options)
@@ -39,6 +40,7 @@ def authorize(amount, payment_method, options={})
add_order_number(post, options)
add_payment_method(post, payment_method)
add_verification_value(post, payment_method)
+ add_stored_credential_data(post, payment_method, options)
add_customer_data(post, options)
add_soft_descriptors(post, options)
@@ -61,6 +63,7 @@ def refund(amount, authorization, options={})
add_reference(post, authorization, options)
add_customer_data(post, options)
add_soft_descriptors(post, options)
+ post['order.ECI'] = options[:eci] || 'SSL'
commit('refund', post)
end
@@ -124,7 +127,6 @@ def add_soft_descriptors(post, options)
def add_invoice(post, money, options)
post['order.amount'] = amount(money)
post['card.currency'] = CURRENCY_CODES[options[:currency] || currency(money)]
- post['order.ECI'] = options[:eci] || 'SSL'
end
def add_payment_method(post, payment_method)
@@ -134,6 +136,46 @@ def add_payment_method(post, payment_method)
post['card.expiryMonth'] = format(payment_method.month, :two_digits)
end
+ def add_stored_credential_data(post, payment_method, options)
+ post['order.ECI'] = options[:eci] || eci(options)
+ if (stored_credential = options[:stored_credential]) && %w(visa master).include?(payment_method.brand)
+ post['card.posEntryMode'] = stored_credential[:initial_transaction] ? 'MANUAL' : 'STORED_CREDENTIAL'
+ stored_credential_usage(post, payment_method, options) unless stored_credential[:initiator] && stored_credential[:initiator] == 'cardholder'
+ post['order.authTraceId'] = stored_credential[:network_transaction_id] if stored_credential[:network_transaction_id]
+ end
+ end
+
+ def stored_credential_usage(post, payment_method, options)
+ return unless payment_method.brand == 'visa'
+ stored_credential = options[:stored_credential]
+ if stored_credential[:initial_transaction]
+ post['card.storedCredentialUsage'] = 'INITIAL_STORAGE'
+ elsif stored_credential[:reason_type] == ('recurring' || 'installment')
+ post['card.storedCredentialUsage'] = 'RECURRING'
+ elsif stored_credential[:reason_type] == 'unscheduled'
+ post['card.storedCredentialUsage'] = 'UNSCHEDULED'
+ end
+ end
+
+ def eci(options)
+ if options.dig(:stored_credential, :initial_transaction)
+ 'SSL'
+ elsif options.dig(:stored_credential, :initiator) && options[:stored_credential][:initiator] == 'cardholder'
+ 'MTO'
+ elsif options.dig(:stored_credential, :reason_type)
+ case options[:stored_credential][:reason_type]
+ when 'recurring'
+ 'REC'
+ when 'installment'
+ 'INS'
+ when 'unscheduled'
+ 'MTO'
+ end
+ else
+ 'SSL'
+ end
+ end
+
def add_verification_value(post, payment_method)
post['card.CVN'] = payment_method.verification_value
end
diff --git a/test/remote/gateways/remote_qvalent_test.rb b/test/remote/gateways/remote_qvalent_test.rb
index cc610703d86..95653323048 100644
--- a/test/remote/gateways/remote_qvalent_test.rb
+++ b/test/remote/gateways/remote_qvalent_test.rb
@@ -5,7 +5,8 @@ def setup
@gateway = QvalentGateway.new(fixtures(:qvalent))
@amount = 100
- @credit_card = credit_card('4000100011112224')
+ @credit_card = credit_card('4242424242424242')
+ @mastercard = credit_card('5163200000000008', brand: 'master')
@declined_card = credit_card('4000000000000000')
@expired_card = credit_card('4111111113444494')
@@ -189,4 +190,53 @@ def test_transcript_scrubbing
assert_scrubbed(@credit_card.verification_value, clean_transcript)
assert_scrubbed(@gateway.options[:password], clean_transcript)
end
+
+ def test_successful_purchase_initial
+ stored_credential = {
+ stored_credential: {
+ initial_transaction: true,
+ initiator: 'merchant',
+ reason_type: 'unscheduled'
+ }
+ }
+
+ response = @gateway.purchase(@amount, @credit_card, @options.merge(stored_credential))
+
+ assert_success response
+ assert_equal 'Succeeded', response.message
+ assert_not_nil response.params['response.authTraceId']
+ end
+
+ def test_successful_purchase_cardholder
+ stored_credential = {
+ stored_credential: {
+ initial_transaction: false,
+ initiator: 'cardholder',
+ reason_type: 'unscheduled',
+ network_transaction_id: 'qwerty7890'
+ }
+ }
+
+ response = @gateway.purchase(@amount, @credit_card, @options.merge(stored_credential))
+
+ assert_success response
+ assert_equal 'Succeeded', response.message
+ end
+
+ def test_successful_purchase_mastercard
+ stored_credential = {
+ stored_credential: {
+ initial_transaction: false,
+ initiator: 'merchant',
+ reason_type: 'recurring',
+ network_transaction_id: 'qwerty7890'
+ }
+ }
+
+ response = @gateway.purchase(@amount, @mastercard, @options.merge(stored_credential))
+
+ assert_success response
+ assert_equal 'Succeeded', response.message
+ end
+
end
diff --git a/test/unit/gateways/qvalent_test.rb b/test/unit/gateways/qvalent_test.rb
index 1582e39388c..6bff79ebb82 100644
--- a/test/unit/gateways/qvalent_test.rb
+++ b/test/unit/gateways/qvalent_test.rb
@@ -187,6 +187,71 @@ def test_3d_secure_fields
assert_success response
end
+ def test_stored_credential_fields_initial
+ response = stub_comms(@gateway, :ssl_request) do
+ @gateway.purchase(@amount, @credit_card, {stored_credential: {initial_transaction: true, reason_type: 'unscheduled', initiator: 'merchant'}})
+ end.check_request do |method, endpoint, data, headers|
+ assert_match(/posEntryMode=MANUAL/, data)
+ assert_match(/storedCredentialUsage=INITIAL_STORAGE/, data)
+ assert_match(/ECI=SSL/, data)
+ end.respond_with(successful_purchase_response)
+
+ assert_success response
+ end
+
+ def test_stored_credential_fields_recurring
+ response = stub_comms(@gateway, :ssl_request) do
+ @gateway.purchase(@amount, @credit_card, {stored_credential: {reason_type: 'recurring', initiator: 'merchant', network_transaction_id: '7890'}})
+ end.check_request do |method, endpoint, data, headers|
+ assert_match(/posEntryMode=STORED_CREDENTIAL/, data)
+ assert_match(/storedCredentialUsage=RECURRING/, data)
+ assert_match(/ECI=REC/, data)
+ assert_match(/authTraceId=7890/, data)
+ end.respond_with(successful_purchase_response)
+
+ assert_success response
+ end
+
+ def test_stored_credential_fields_unscheduled
+ response = stub_comms(@gateway, :ssl_request) do
+ @gateway.purchase(@amount, @credit_card, {stored_credential: {reason_type: 'unscheduled', initiator: 'merchant', network_transaction_id: '7890'}})
+ end.check_request do |method, endpoint, data, headers|
+ assert_match(/posEntryMode=STORED_CREDENTIAL/, data)
+ assert_match(/storedCredentialUsage=UNSCHEDULED/, data)
+ assert_match(/ECI=MTO/, data)
+ assert_match(/authTraceId=7890/, data)
+ end.respond_with(successful_purchase_response)
+
+ assert_success response
+ end
+
+ def test_stored_credential_fields_cardholder_initiated
+ response = stub_comms(@gateway, :ssl_request) do
+ @gateway.purchase(@amount, @credit_card, {stored_credential: {reason_type: 'unscheduled', initiator: 'cardholder', network_transaction_id: '7890'}})
+ end.check_request do |method, endpoint, data, headers|
+ assert_match(/posEntryMode=STORED_CREDENTIAL/, data)
+ refute_match(/storedCredentialUsage/, data)
+ assert_match(/ECI=MTO/, data)
+ assert_match(/authTraceId=7890/, data)
+ end.respond_with(successful_purchase_response)
+
+ assert_success response
+ end
+
+ def test_stored_credential_fields_mastercard
+ @credit_card.brand = 'master'
+ response = stub_comms(@gateway, :ssl_request) do
+ @gateway.purchase(@amount, @credit_card, {stored_credential: {reason_type: 'recurring', initiator: 'merchant', network_transaction_id: '7890'}})
+ end.check_request do |method, endpoint, data, headers|
+ assert_match(/posEntryMode=STORED_CREDENTIAL/, data)
+ refute_match(/storedCredentialUsage/, data)
+ assert_match(/ECI=REC/, data)
+ assert_match(/authTraceId=7890/, data)
+ end.respond_with(successful_purchase_response)
+
+ assert_success response
+ end
+
def test_cvv_result
response = stub_comms do
@gateway.purchase(@amount, @credit_card)
From 8a774ddb932fbdffd72389cfbc55daf0ef6010f6 Mon Sep 17 00:00:00 2001
From: Pierre Nespo
Date: Thu, 23 May 2019 10:11:55 -0400
Subject: [PATCH 0343/2234] [Gateways::Cybersource] Send tokenization data when
card is :master (#3230)
Currently it will only send tokenization data for MasterCard when the card
type is :mastercard which is an invalid card type. This commit makes it
so it will send tokenization data when the card type is :master and not
:mastercard
---
lib/active_merchant/billing/gateways/cyber_source.rb | 2 +-
test/unit/gateways/cyber_source_test.rb | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb
index 4228cf1ba66..19fea3bce5d 100644
--- a/lib/active_merchant/billing/gateways/cyber_source.rb
+++ b/lib/active_merchant/billing/gateways/cyber_source.rb
@@ -550,7 +550,7 @@ def add_auth_network_tokenization(xml, payment_method, options)
xml.tag!('commerceIndicator', 'vbv')
xml.tag!('xid', payment_method.payment_cryptogram)
end
- when :mastercard
+ when :master
xml.tag! 'ucaf' do
xml.tag!('authenticationData', payment_method.payment_cryptogram)
xml.tag!('collectionIndicator', '2')
diff --git a/test/unit/gateways/cyber_source_test.rb b/test/unit/gateways/cyber_source_test.rb
index 27a1be0bc20..c1e6f6b334c 100644
--- a/test/unit/gateways/cyber_source_test.rb
+++ b/test/unit/gateways/cyber_source_test.rb
@@ -462,7 +462,7 @@ def test_successful_auth_with_network_tokenization_for_mastercard
end.returns(successful_purchase_response)
credit_card = network_tokenization_credit_card('5555555555554444',
- :brand => 'mastercard',
+ :brand => 'master',
:transaction_id => '123',
:eci => '05',
:payment_cryptogram => '111111111100cryptogram'
From 380108b094bd26f5fe46049bdc5cfab7a768bb2f Mon Sep 17 00:00:00 2001
From: Pierre Nespo
Date: Thu, 23 May 2019 14:21:30 -0400
Subject: [PATCH 0344/2234] Bump to v1.95.0
---
CHANGELOG | 3 +++
lib/active_merchant/version.rb | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 29dc8ef5954..97a0e48d047 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,8 +1,11 @@
= ActiveMerchant CHANGELOG
== HEAD
+
+== Version 1.95.0 (May 23, 2019)
* Adyen: Constantize version to fix subdomains [curiousepic] #3228
* Qvalent: Adds support for standard stored credential framework [molbrown] #3227
+* Cybersource: Send tokenization data when card is :master [pi3r] #3230
== Version 1.94.0 (May 21, 2019)
* Mundipagg: Fix number lengths for both VR and Sodexo [dtykocki] #3195
diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb
index 2052700c7b1..1f632ec56fc 100644
--- a/lib/active_merchant/version.rb
+++ b/lib/active_merchant/version.rb
@@ -1,3 +1,3 @@
module ActiveMerchant
- VERSION = '1.94.0'
+ VERSION = '1.95.0'
end
From ad25f1de80de54ab9c24f54321cee5e7a5c4ea4e Mon Sep 17 00:00:00 2001
From: Ruthan
Date: Tue, 21 May 2019 16:56:23 -0400
Subject: [PATCH 0345/2234] Bluesnap: only send state code for US and Canada
ECS-329
Per Bluesnap, state codes are not supported for countries oter than
the US and Canada.
Unit:
------------------------------------------------------------------------
26 tests, 102 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
------------------------------------------------------------------------
Remote:
------------------------------------------------------------------------
34 tests, 105 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
------------------------------------------------------------------------
0.42 tests/s, 1.31 assertions/s
---
.../billing/gateways/blue_snap.rb | 4 +-
test/remote/gateways/remote_blue_snap_test.rb | 15 +++++
test/unit/gateways/blue_snap_test.rb | 58 +++++++++++++++++++
3 files changed, 76 insertions(+), 1 deletion(-)
diff --git a/lib/active_merchant/billing/gateways/blue_snap.rb b/lib/active_merchant/billing/gateways/blue_snap.rb
index 0b0eabb2c45..c8c29115c08 100644
--- a/lib/active_merchant/billing/gateways/blue_snap.rb
+++ b/lib/active_merchant/billing/gateways/blue_snap.rb
@@ -66,6 +66,8 @@ class BlueSnapGateway < Gateway
'business_savings' => 'CORPORATE_SAVINGS'
}
+ STATE_CODE_COUNTRIES = %w(US CA)
+
def initialize(options={})
requires!(options, :api_username, :api_password)
super
@@ -228,7 +230,7 @@ def add_address(doc, options)
return unless address
doc.country(address[:country]) if address[:country]
- doc.state(address[:state]) if address[:state]
+ doc.state(address[:state]) if address[:state] && STATE_CODE_COUNTRIES.include?(address[:country])
doc.address(address[:address]) if address[:address]
doc.city(address[:city]) if address[:city]
doc.zip(address[:zip]) if address[:zip]
diff --git a/test/remote/gateways/remote_blue_snap_test.rb b/test/remote/gateways/remote_blue_snap_test.rb
index 39511e0940a..3b62fca8d63 100644
--- a/test/remote/gateways/remote_blue_snap_test.rb
+++ b/test/remote/gateways/remote_blue_snap_test.rb
@@ -111,6 +111,21 @@ def test_successful_purchase_with_level3_data
assert_equal '9', response.params['line-item-total']
end
+ def test_successful_purchase_with_unused_state_code
+ unrecognized_state_code_options = {
+ billing_address: {
+ city: "Dresden",
+ state: "Sachsen",
+ country: "DE",
+ zip: "01069"
+ }
+ }
+
+ response = @gateway.purchase(@amount, @credit_card, unrecognized_state_code_options)
+ assert_success response
+ assert_equal 'Success', response.message
+ end
+
def test_successful_echeck_purchase
response = @gateway.purchase(@amount, @check, @options.merge(@valid_check_options))
assert_success response
diff --git a/test/unit/gateways/blue_snap_test.rb b/test/unit/gateways/blue_snap_test.rb
index c3cb84bea00..bfe9fb53b89 100644
--- a/test/unit/gateways/blue_snap_test.rb
+++ b/test/unit/gateways/blue_snap_test.rb
@@ -29,6 +29,24 @@ def test_successful_purchase
assert_equal '1012082839', response.authorization
end
+ def test_successful_purchase_with_unused_state_code
+ unrecognized_state_code_options = {
+ billing_address: {
+ city: 'Dresden',
+ state: 'Sachsen',
+ country: 'DE',
+ zip: '01069'
+ }
+ }
+
+ @gateway.expects(:raw_ssl_request).returns(successful_stateless_purchase_response)
+
+ response = @gateway.purchase(@amount, @credit_card, unrecognized_state_code_options)
+ assert_success response
+ assert_equal '1021645629', response.authorization
+ assert_not_includes(response.params, "state")
+ end
+
def test_successful_echeck_purchase
@gateway.expects(:raw_ssl_request).returns(successful_echeck_purchase_response)
@@ -333,6 +351,46 @@ def successful_echeck_purchase_response
XML
end
+ def successful_stateless_purchase_response
+ MockResponse.succeeded <<-XML
+
+
+ AUTH_CAPTURE
+ 1021645629
+ ECOMMERCE
+ BLS*Spreedly
+ 1.00
+ 1.00
+ USD
+
+ Longbob
+ Longsen
+ DE
+ Dresden
+ 01069
+
+ 24449087
+
+ 9299
+ VISA
+ CREDIT
+ PLATINUM
+ CONSUMER
+ N
+ ALLIED IRISH BANKS PLC
+ ie
+
+
+ success
+ ND
+ U
+ U
+ U
+
+
+ XML
+ end
+
def failed_purchase_response
body = <<-XML
From b0e2907afc2cbd18741510fe6ea15792d5f4b4f1 Mon Sep 17 00:00:00 2001
From: Ruthan
Date: Thu, 23 May 2019 15:33:09 -0400
Subject: [PATCH 0346/2234] Changelog entry for 3229
---
CHANGELOG | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG b/CHANGELOG
index 97a0e48d047..239c43a3518 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -6,6 +6,7 @@
* Adyen: Constantize version to fix subdomains [curiousepic] #3228
* Qvalent: Adds support for standard stored credential framework [molbrown] #3227
* Cybersource: Send tokenization data when card is :master [pi3r] #3230
+* Bluesnap: Omit state codes for unsupported countries [therufs] #3229
== Version 1.94.0 (May 21, 2019)
* Mundipagg: Fix number lengths for both VR and Sodexo [dtykocki] #3195
From ab2a09d44e38827ab47deb0c6bcae83c3c515f30 Mon Sep 17 00:00:00 2001
From: David Perry
Date: Fri, 24 May 2019 15:02:49 -0400
Subject: [PATCH 0347/2234] Adyen: Pass updateShopperStatement, industryUsage
Remote:
60 tests, 187 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
38 tests, 182 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/adyen.rb | 2 ++
test/remote/gateways/remote_adyen_test.rb | 4 ++--
test/remote/gateways/remote_blue_snap_test.rb | 8 ++++----
test/unit/gateways/adyen_test.rb | 9 +++++++++
test/unit/gateways/blue_snap_test.rb | 2 +-
6 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 239c43a3518..04ff67fd002 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -7,6 +7,7 @@
* Qvalent: Adds support for standard stored credential framework [molbrown] #3227
* Cybersource: Send tokenization data when card is :master [pi3r] #3230
* Bluesnap: Omit state codes for unsupported countries [therufs] #3229
+* Adyen: Pass updateShopperStatement, industryUsage [curiousepic] #3233
== Version 1.94.0 (May 21, 2019)
* Mundipagg: Fix number lengths for both VR and Sodexo [dtykocki] #3195
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index 42c1cca11e9..477c4874037 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -179,6 +179,8 @@ def add_extra_data(post, payment, options)
post[:additionalData]['paymentdatasource.type'] = NETWORK_TOKENIZATION_CARD_SOURCE[payment.source.to_s] if payment.is_a?(NetworkTokenizationCreditCard)
post[:additionalData][:authorisationType] = options[:authorisation_type] if options[:authorisation_type]
post[:additionalData][:adjustAuthorisationData] = options[:adjust_authorisation_data] if options[:adjust_authorisation_data]
+ post[:additionalData][:industryUsage] = options[:industry_usage] if options[:industry_usage]
+ post[:additionalData][:updateShopperStatement] = options[:update_shopper_statement] if options[:update_shopper_statement]
post[:additionalData][:RequestedTestAcquirerResponseCode] = options[:requested_test_acquirer_response_code] if options[:requested_test_acquirer_response_code] && test?
post[:deviceFingerprint] = options[:device_fingerprint] if options[:device_fingerprint]
add_risk_data(post, options)
diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb
index 223af74389d..a5f8acd56e4 100644
--- a/test/remote/gateways/remote_adyen_test.rb
+++ b/test/remote/gateways/remote_adyen_test.rb
@@ -397,10 +397,10 @@ def test_failed_asynchronous_adjust
# Requires Adyen to set your test account to Synchronous Adjust mode.
def test_successful_synchronous_adjust_using_adjust_data
- authorize = @gateway.authorize(@amount, @credit_card, @options.merge(authorisation_type: 'PreAuth'))
+ authorize = @gateway.authorize(@amount, @credit_card, @options.merge(authorisation_type: 'PreAuth', shopper_statement: 'statement note'))
assert_success authorize
- options = @options.merge(adjust_authorisation_data: authorize.params['additionalData']['adjustAuthorisationData'])
+ options = @options.merge(adjust_authorisation_data: authorize.params['additionalData']['adjustAuthorisationData'], update_shopper_statement: 'new statement note', industry_usage: 'DelayedCharge')
assert adjust = @gateway.adjust(200, authorize.authorization, options)
assert_success adjust
assert_equal 'Authorised', adjust.message
diff --git a/test/remote/gateways/remote_blue_snap_test.rb b/test/remote/gateways/remote_blue_snap_test.rb
index 3b62fca8d63..bc5d209509a 100644
--- a/test/remote/gateways/remote_blue_snap_test.rb
+++ b/test/remote/gateways/remote_blue_snap_test.rb
@@ -114,10 +114,10 @@ def test_successful_purchase_with_level3_data
def test_successful_purchase_with_unused_state_code
unrecognized_state_code_options = {
billing_address: {
- city: "Dresden",
- state: "Sachsen",
- country: "DE",
- zip: "01069"
+ city: 'Dresden',
+ state: 'Sachsen',
+ country: 'DE',
+ zip: '01069'
}
}
diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb
index eb765ce23b7..c0521889560 100644
--- a/test/unit/gateways/adyen_test.rb
+++ b/test/unit/gateways/adyen_test.rb
@@ -219,6 +219,15 @@ def test_custom_routing_sent
end.respond_with(successful_authorize_response)
end
+ def test_update_shopper_statement_and_industry_usage_sent
+ stub_comms do
+ @gateway.adjust(@amount, '123', @options.merge({update_shopper_statement: 'statement note', industry_usage: 'DelayedCharge'}))
+ end.check_request do |endpoint, data, headers|
+ assert_equal 'statement note', JSON.parse(data)['additionalData']['updateShopperStatement']
+ assert_equal 'DelayedCharge', JSON.parse(data)['additionalData']['industryUsage']
+ end.respond_with(successful_adjust_response)
+ end
+
def test_risk_data_sent
stub_comms do
@gateway.authorize(@amount, @credit_card, @options.merge({risk_data: {'operatingSystem' => 'HAL9000'}}))
diff --git a/test/unit/gateways/blue_snap_test.rb b/test/unit/gateways/blue_snap_test.rb
index bfe9fb53b89..9d923d1a225 100644
--- a/test/unit/gateways/blue_snap_test.rb
+++ b/test/unit/gateways/blue_snap_test.rb
@@ -44,7 +44,7 @@ def test_successful_purchase_with_unused_state_code
response = @gateway.purchase(@amount, @credit_card, unrecognized_state_code_options)
assert_success response
assert_equal '1021645629', response.authorization
- assert_not_includes(response.params, "state")
+ assert_not_includes(response.params, 'state')
end
def test_successful_echeck_purchase
From b69fcadfb84aefe6f172415c2f766862d3a36a73 Mon Sep 17 00:00:00 2001
From: britth
Date: Fri, 24 May 2019 09:41:04 -0400
Subject: [PATCH 0348/2234] TransFirst Express: Fix blank address2 values
If a user passes in an empty string for the address2 field, their
transaction will fail on this gateway. This PR ensures that address2
only gets passed through if it is present and not blank. Additionally
it cleans up some remote test failures. test_successful_verify still
fails in the remote tests, but failure is unrelated to change.
Unit:
21 tests, 103 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
33 tests, 107 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
96.9697% passed
Closes #3231
---
CHANGELOG | 1 +
.../trans_first_transaction_express.rb | 4 ++--
...te_trans_first_transaction_express_test.rb | 22 ++++++++++++++++++-
3 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 04ff67fd002..0d8428bf14e 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -8,6 +8,7 @@
* Cybersource: Send tokenization data when card is :master [pi3r] #3230
* Bluesnap: Omit state codes for unsupported countries [therufs] #3229
* Adyen: Pass updateShopperStatement, industryUsage [curiousepic] #3233
+* TransFirst Transaction Express: Fix blank address2 values [britth] #3231
== Version 1.94.0 (May 21, 2019)
* Mundipagg: Fix number lengths for both VR and Sodexo [dtykocki] #3195
diff --git a/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb b/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb
index fe94ffe357b..f35fe0d9b78 100644
--- a/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb
+++ b/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb
@@ -544,7 +544,7 @@ def add_contact(doc, fullname, options)
end
end
doc['v1'].addrLn1 billing_address[:address1] if billing_address[:address1]
- doc['v1'].addrLn2 billing_address[:address2] if billing_address[:address2]
+ doc['v1'].addrLn2 billing_address[:address2] unless billing_address[:address2].blank?
doc['v1'].city billing_address[:city] if billing_address[:city]
doc['v1'].state billing_address[:state] if billing_address[:state]
doc['v1'].zipCode billing_address[:zip] if billing_address[:zip]
@@ -559,7 +559,7 @@ def add_contact(doc, fullname, options)
doc['v1'].ship do
doc['v1'].fullName fullname unless fullname.blank?
doc['v1'].addrLn1 shipping_address[:address1] if shipping_address[:address1]
- doc['v1'].addrLn2 shipping_address[:address2] if shipping_address[:address2]
+ doc['v1'].addrLn2 shipping_address[:address2] unless shipping_address[:address2].blank?
doc['v1'].city shipping_address[:city] if shipping_address[:city]
doc['v1'].state shipping_address[:state] if shipping_address[:state]
doc['v1'].zipCode shipping_address[:zip] if shipping_address[:zip]
diff --git a/test/remote/gateways/remote_trans_first_transaction_express_test.rb b/test/remote/gateways/remote_trans_first_transaction_express_test.rb
index 9a97eee54f0..3e69c82ecee 100644
--- a/test/remote/gateways/remote_trans_first_transaction_express_test.rb
+++ b/test/remote/gateways/remote_trans_first_transaction_express_test.rb
@@ -7,7 +7,7 @@ def setup
@amount = 100
@declined_amount = 21
- @credit_card = credit_card('4485896261017708')
+ @credit_card = credit_card('4485896261017708', verification_value: 999)
@check = check
billing_address = address({
@@ -76,6 +76,26 @@ def test_successful_purchase_with_only_required
assert_equal 'CVV matches', response.cvv_result['message']
end
+ def test_successful_purchase_without_address2
+ # Test that empty string in `address2` doesn't cause transaction failure
+ options = @options.dup
+ options[:shipping_address] = {
+ address1: '450 Main',
+ address2: '',
+ zip: '85284',
+ }
+
+ options[:billing_address] = {
+ address1: '450 Main',
+ address2: '',
+ zip: '85284',
+ }
+
+ response = @gateway.purchase(@amount, @credit_card, options)
+ assert_success response
+ assert_equal 'Succeeded', response.message
+ end
+
def test_successful_purchase_without_cvv
credit_card_opts = {
:number => 4485896261017708,
From 8c9ff1361156bd25e71f41d55313f08a7cd72eff Mon Sep 17 00:00:00 2001
From: Zeb DeOs
Date: Thu, 30 May 2019 12:21:39 -0400
Subject: [PATCH 0349/2234] Fix CHANGELOG for additions since v1.95.0
---
CHANGELOG | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 0d8428bf14e..ecf1cf1f1ea 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,14 +1,14 @@
= ActiveMerchant CHANGELOG
== HEAD
+* Bluesnap: Omit state codes for unsupported countries [therufs] #3229
+* Adyen: Pass updateShopperStatement, industryUsage [curiousepic] #3233
+* TransFirst Transaction Express: Fix blank address2 values [britth] #3231
== Version 1.95.0 (May 23, 2019)
* Adyen: Constantize version to fix subdomains [curiousepic] #3228
* Qvalent: Adds support for standard stored credential framework [molbrown] #3227
* Cybersource: Send tokenization data when card is :master [pi3r] #3230
-* Bluesnap: Omit state codes for unsupported countries [therufs] #3229
-* Adyen: Pass updateShopperStatement, industryUsage [curiousepic] #3233
-* TransFirst Transaction Express: Fix blank address2 values [britth] #3231
== Version 1.94.0 (May 21, 2019)
* Mundipagg: Fix number lengths for both VR and Sodexo [dtykocki] #3195
From 1243289c2e700e666a634a86611cd6fa8da0ae05 Mon Sep 17 00:00:00 2001
From: Zeb DeOs
Date: Thu, 30 May 2019 12:22:43 -0400
Subject: [PATCH 0350/2234] WorldPay: Add support for store method
We are only supporting shopper-scoped tokens right now, and not
implementing delete/unstore, saving a token along with an authorize or
purchase call, overriding token details on use, or setting the token
lifetime.
The design of the opaque token authorization string we return from
`store` has been intentionally designed to be flexible enough to extend
in a backwards-compatible way should any of the above features need to
be implemented.
Unit:
66 tests, 392 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
50 tests, 219 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
96% passed
The two failing remote tests are concerning 3DS parameter pass through
which the test credentials I'm using does not have permission to use
presently.
ECS-347
Closes #3232
---
CHANGELOG | 1 +
.../billing/gateways/worldpay.rb | 173 ++++++++--
test/remote/gateways/remote_worldpay_test.rb | 91 ++++++
test/unit/gateways/worldpay_test.rb | 307 +++++++++++++++++-
4 files changed, 535 insertions(+), 37 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index ecf1cf1f1ea..0f244190458 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -4,6 +4,7 @@
* Bluesnap: Omit state codes for unsupported countries [therufs] #3229
* Adyen: Pass updateShopperStatement, industryUsage [curiousepic] #3233
* TransFirst Transaction Express: Fix blank address2 values [britth] #3231
+* WorldPay: Add support for store method [bayprogrammer] #3232
== Version 1.95.0 (May 23, 2019)
* Adyen: Constantize version to fix subdomains [curiousepic] #3228
diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb
index 1ef40b61eeb..0472d7e70a0 100644
--- a/lib/active_merchant/billing/gateways/worldpay.rb
+++ b/lib/active_merchant/billing/gateways/worldpay.rb
@@ -59,10 +59,12 @@ def purchase(money, payment_method, options = {})
def authorize(money, payment_method, options = {})
requires!(options, :order_id)
- authorize_request(money, payment_method, options)
+ payment_details = payment_details_from(payment_method)
+ authorize_request(money, payment_method, payment_details.merge(options))
end
def capture(money, authorization, options = {})
+ authorization = order_id_from_authorization(authorization.to_s)
MultiResponse.run do |r|
r.process { inquire_request(authorization, options, 'AUTHORISED') } unless options[:authorization_validated]
if r.params
@@ -74,6 +76,7 @@ def capture(money, authorization, options = {})
end
def void(authorization, options = {})
+ authorization = order_id_from_authorization(authorization.to_s)
MultiResponse.run do |r|
r.process { inquire_request(authorization, options, 'AUTHORISED') } unless options[:authorization_validated]
r.process { cancel_request(authorization, options) }
@@ -81,6 +84,7 @@ def void(authorization, options = {})
end
def refund(money, authorization, options = {})
+ authorization = order_id_from_authorization(authorization.to_s)
response = MultiResponse.run do |r|
r.process { inquire_request(authorization, options, 'CAPTURED', 'SETTLED', 'SETTLED_BY_MERCHANT') }
r.process { refund_request(money, authorization, options) }
@@ -97,16 +101,22 @@ def refund(money, authorization, options = {})
# and other transactions should be performed on a normal eCom-flagged
# merchant ID.
def credit(money, payment_method, options = {})
- credit_request(money, payment_method, options.merge(:credit => true))
+ payment_details = payment_details_from(payment_method)
+ credit_request(money, payment_method, payment_details.merge(:credit => true, **options))
end
- def verify(credit_card, options={})
+ def verify(payment_method, options={})
MultiResponse.run(:use_first_response) do |r|
- r.process { authorize(100, credit_card, options) }
+ r.process { authorize(100, payment_method, options) }
r.process(:ignore_result) { void(r.authorization, options.merge(:authorization_validated => true)) }
end
end
+ def store(credit_card, options={})
+ requires!(options, :customer)
+ store_request(credit_card, options)
+ end
+
def supports_scrubbing
true
end
@@ -144,6 +154,10 @@ def credit_request(money, payment_method, options)
commit('credit', build_authorization_request(money, payment_method, options), :ok, 'SENT_FOR_REFUND', options)
end
+ def store_request(credit_card, options)
+ commit('store', build_store_request(credit_card, options), options)
+ end
+
def build_request
xml = Builder::XmlMarkup.new :indent => 2
xml.instruct! :xml, :encoding => 'UTF-8'
@@ -184,7 +198,7 @@ def build_authorization_request(money, payment_method, options)
end
end
add_payment_method(xml, money, payment_method, options)
- add_email(xml, options)
+ add_shopper(xml, options)
if options[:hcg_additional_data]
add_hcg_additional_data(xml, options)
end
@@ -224,6 +238,22 @@ def build_refund_request(money, authorization, options)
end
end
+ def build_store_request(credit_card, options)
+ build_request do |xml|
+ xml.tag! 'submit' do
+ xml.tag! 'paymentTokenCreate' do
+ add_authenticated_shopper_id(xml, options)
+ xml.tag! 'createToken'
+ xml.tag! 'paymentInstrument' do
+ xml.tag! 'cardDetails' do
+ add_card(xml, credit_card, options)
+ end
+ end
+ end
+ end
+ end
+ end
+
def add_amount(xml, money, options)
currency = options[:currency] || currency(money)
@@ -241,7 +271,7 @@ def add_amount(xml, money, options)
end
def add_payment_method(xml, amount, payment_method, options)
- if payment_method.is_a?(String)
+ if options[:payment_type] == :pay_as_order
if options[:merchant_code]
xml.tag! 'payAsOrder', 'orderCode' => payment_method, 'merchantCode' => options[:merchant_code] do
add_amount(xml, amount, options)
@@ -253,16 +283,14 @@ def add_payment_method(xml, amount, payment_method, options)
end
else
xml.tag! 'paymentDetails', credit_fund_transfer_attribute(options) do
- xml.tag! card_code_for(payment_method) do
- xml.tag! 'cardNumber', payment_method.number
- xml.tag! 'expiryDate' do
- xml.tag! 'date', 'month' => format(payment_method.month, :two_digits), 'year' => format(payment_method.year, :four_digits)
+ if options[:payment_type] == :token
+ xml.tag! 'TOKEN-SSL', 'tokenScope' => options[:token_scope] do
+ xml.tag! 'paymentTokenID', options[:token_id]
+ end
+ else
+ xml.tag! card_code_for(payment_method) do
+ add_card(xml, payment_method, options)
end
-
- xml.tag! 'cardHolderName', options[:execute_threed] ? '3D' : payment_method.name
- xml.tag! 'cvc', payment_method.verification_value
-
- add_address(xml, (options[:billing_address] || options[:address]))
end
add_stored_credential_options(xml, options)
if options[:ip] && options[:session_id]
@@ -285,6 +313,18 @@ def add_payment_method(xml, amount, payment_method, options)
end
end
+ def add_card(xml, payment_method, options)
+ xml.tag! 'cardNumber', payment_method.number
+ xml.tag! 'expiryDate' do
+ xml.tag! 'date', 'month' => format(payment_method.month, :two_digits), 'year' => format(payment_method.year, :four_digits)
+ end
+
+ xml.tag! 'cardHolderName', options[:execute_threed] ? '3D' : payment_method.name
+ xml.tag! 'cvc', payment_method.verification_value
+
+ add_address(xml, (options[:billing_address] || options[:address]))
+ end
+
def add_stored_credential_options(xml, options={})
if options[:stored_credential]
add_stored_credential_using_normalized_fields(xml, options)
@@ -321,10 +361,11 @@ def add_stored_credential_using_gateway_specific_fields(xml, options)
end
end
- def add_email(xml, options)
- return unless options[:execute_threed] || options[:email]
+ def add_shopper(xml, options)
+ return unless options[:execute_threed] || options[:email] || options[:customer]
xml.tag! 'shopper' do
xml.tag! 'shopperEmailAddress', options[:email] if options[:email]
+ add_authenticated_shopper_id(xml, options)
xml.tag! 'browser' do
xml.tag! 'acceptHeader', options[:accept_header]
xml.tag! 'userAgentHeader', options[:user_agent]
@@ -332,6 +373,10 @@ def add_email(xml, options)
end
end
+ def add_authenticated_shopper_id(xml, options)
+ xml.tag!('authenticatedShopperID', options[:customer]) if options[:customer]
+ end
+
def add_address(xml, address)
return unless address
@@ -390,14 +435,17 @@ def parse(action, xml)
end
def parse_element(raw, node)
+ node_name = node.name.underscore
node.attributes.each do |k, v|
- raw["#{node.name.underscore}_#{k.underscore}".to_sym] = v
+ raw["#{node_name}_#{k.underscore}".to_sym] = v
end
if node.has_elements?
- raw[node.name.underscore.to_sym] = true unless node.name.blank?
+ raw[node_name.to_sym] = true unless node.name.blank?
node.elements.each { |e| parse_element(raw, e) }
+ elsif node.children.count > 1
+ raw[node_name.to_sym] = node.children.join(' ').strip
else
- raw[node.name.underscore.to_sym] = node.text unless node.text.nil?
+ raw[node_name.to_sym] = node.text unless node.text.nil?
end
raw
end
@@ -420,13 +468,14 @@ def commit(action, request, *success_criteria, options)
raw[:cookie] = @cookie
raw[:session_id] = options[:session_id]
end
- success, message = success_and_message_from(raw, success_criteria)
+ success = success_from(action, raw, success_criteria)
+ message = message_from(success, raw, success_criteria)
Response.new(
success,
message,
raw,
- :authorization => authorization_from(raw),
+ :authorization => authorization_from(action, raw, options),
:error_code => error_code_from(success, raw),
:test => test?,
:avs_result => AVSResult.new(code: AVS_CODE_MAP[raw[:avs_result_code_description]]),
@@ -456,19 +505,30 @@ def handle_response(response)
end
end
+ def success_from(action, raw, success_criteria)
+ success_criteria_success?(raw, success_criteria) || action_success?(action, raw)
+ end
+
+ def message_from(success, raw, success_criteria)
+ return 'SUCCESS' if success
+ raw[:iso8583_return_code_description] || raw[:error] || required_status_message(raw, success_criteria)
+ end
+
# success_criteria can be:
# - a string or an array of strings (if one of many responses)
# - An array of strings if one of many responses could be considered a
# success.
- def success_and_message_from(raw, success_criteria)
- success = (success_criteria.include?(raw[:last_event]) || raw[:ok].present?)
- if success
- message = 'SUCCESS'
+ def success_criteria_success?(raw, success_criteria)
+ success_criteria.include?(raw[:last_event]) || raw[:ok].present?
+ end
+
+ def action_success?(action, raw)
+ case action
+ when 'store'
+ raw[:token].present?
else
- message = (raw[:iso8583_return_code_description] || raw[:error] || required_status_message(raw, success_criteria))
+ false
end
-
- [ success, message ]
end
def error_code_from(success, raw)
@@ -483,11 +543,64 @@ def required_status_message(raw, success_criteria)
end
end
- def authorization_from(raw)
+ def authorization_from(action, raw, options)
+ order_id = order_id_from(raw)
+
+ case action
+ when 'store'
+ authorization_from_token_details(
+ order_id: order_id,
+ token_id: raw[:payment_token_id],
+ token_scope: 'shopper',
+ customer: options[:customer]
+ )
+ else
+ order_id
+ end
+ end
+
+ def order_id_from(raw)
pair = raw.detect { |k, v| k.to_s =~ /_order_code$/ }
(pair ? pair.last : nil)
end
+ def authorization_from_token_details(options={})
+ [options[:order_id], options[:token_id], options[:token_scope], options[:customer]].join('|')
+ end
+
+ def order_id_from_authorization(authorization)
+ token_details_from_authorization(authorization)[:order_id]
+ end
+
+ def token_details_from_authorization(authorization)
+ order_id, token_id, token_scope, customer = authorization.split('|')
+
+ token_details = {}
+ token_details[:order_id] = order_id if order_id.present?
+ token_details[:token_id] = token_id if token_id.present?
+ token_details[:token_scope] = token_scope if token_scope.present?
+ token_details[:customer] = customer if customer.present?
+
+ token_details
+ end
+
+ def payment_details_from(payment_method)
+ payment_details = {}
+ if payment_method.respond_to?(:number)
+ payment_details[:payment_type] = :credit
+ else
+ token_details = token_details_from_authorization(payment_method)
+ payment_details.merge!(token_details)
+ if token_details.has_key?(:token_id)
+ payment_details[:payment_type] = :token
+ else
+ payment_details[:payment_type] = :pay_as_order
+ end
+ end
+
+ payment_details
+ end
+
def credit_fund_transfer_attribute(options)
return unless options[:credit]
{'action' => 'REFUND'}
diff --git a/test/remote/gateways/remote_worldpay_test.rb b/test/remote/gateways/remote_worldpay_test.rb
index 653cc18234b..c93542ce7bd 100644
--- a/test/remote/gateways/remote_worldpay_test.rb
+++ b/test/remote/gateways/remote_worldpay_test.rb
@@ -25,6 +25,10 @@ def setup
order_id: generate_unique_id,
email: 'wow@example.com'
}
+ @store_options = {
+ customer: generate_unique_id,
+ email: 'wow@example.com'
+ }
end
def test_successful_purchase
@@ -494,4 +498,91 @@ def test_failed_verify_with_unknown_card
# assert_equal 'A transaction status of 'AUTHORISED' is required.', response.message
# end
+ def test_successful_store
+ assert response = @gateway.store(@credit_card, @store_options)
+ assert_success response
+ assert_equal 'SUCCESS', response.message
+ assert_match response.params['payment_token_id'], response.authorization
+ assert_match 'shopper', response.authorization
+ assert_match @store_options[:customer], response.authorization
+ end
+
+ def test_successful_authorize_using_token
+ assert store = @gateway.store(@credit_card, @store_options)
+ assert_success store
+
+ assert response = @gateway.authorize(@amount, store.authorization, @options)
+ assert_success response
+ assert_equal 'SUCCESS', response.message
+ end
+
+ def test_successful_authorize_using_token_and_minimum_options
+ assert store = @gateway.store(@credit_card, @store_options)
+ assert_success store
+
+ assert response = @gateway.authorize(@amount, store.authorization, order_id: generate_unique_id)
+ assert_success response
+ assert_equal 'SUCCESS', response.message
+ end
+
+ def test_successful_purchase_using_token
+ assert store = @gateway.store(@credit_card, @store_options)
+ assert_success store
+
+ assert response = @gateway.authorize(@amount, store.authorization, @options)
+ assert_success response
+ assert_equal 'SUCCESS', response.message
+ end
+
+ def test_successful_verify_using_token
+ assert store = @gateway.store(@credit_card, @store_options)
+ assert_success store
+
+ response = @gateway.verify(store.authorization, @options)
+ assert_success response
+ assert_match %r{SUCCESS}, response.message
+ end
+
+ def test_successful_credit_using_token
+ assert store = @cftgateway.store(@credit_card, @store_options)
+ assert_success store
+
+ credit = @cftgateway.credit(@amount, store.authorization, @options)
+ assert_success credit
+ assert_equal 'SUCCESS', credit.message
+ end
+
+ def test_failed_store
+ assert response = @gateway.store(@credit_card, @store_options.merge(customer: '_invalidId'))
+ assert_failure response
+ assert_equal '2', response.error_code
+ assert_equal 'authenticatedShopperID cannot start with an underscore', response.message
+ end
+
+ def test_failed_authorize_using_token
+ assert store = @gateway.store(@declined_card, @store_options)
+ assert_success store
+
+ assert response = @gateway.authorize(@amount, store.authorization, @options)
+ assert_failure response
+ assert_equal '5', response.error_code
+ assert_equal 'REFUSED', response.message
+ end
+
+ def test_failed_authorize_using_bogus_token
+ assert response = @gateway.authorize(@amount, '|this|is|bogus', @options)
+ assert_failure response
+ assert_equal '2', response.error_code
+ assert_match 'tokenScope', response.message
+ end
+
+ def test_failed_verify_using_token
+ assert store = @gateway.store(@declined_card, @store_options)
+ assert_success store
+
+ response = @gateway.verify(store.authorization, @options)
+ assert_failure response
+ assert_equal '5', response.error_code
+ assert_match %r{REFUSED}, response.message
+ end
end
diff --git a/test/unit/gateways/worldpay_test.rb b/test/unit/gateways/worldpay_test.rb
index b9351146a85..aaaa4302f49 100644
--- a/test/unit/gateways/worldpay_test.rb
+++ b/test/unit/gateways/worldpay_test.rb
@@ -11,6 +11,7 @@ def setup
@amount = 100
@credit_card = credit_card('4242424242424242')
+ @token = '|99411111780163871111|shopper|59424549c291397379f30c5c082dbed8'
@elo_credit_card = credit_card('4514 1600 0000 0008',
:month => 10,
:year => 2020,
@@ -21,6 +22,10 @@ def setup
)
@sodexo_voucher = credit_card('6060704495764400', brand: 'sodexo')
@options = {:order_id => 1}
+ @store_options = {
+ customer: '59424549c291397379f30c5c082dbed8',
+ email: 'wow@example.com'
+ }
end
def test_successful_authorize
@@ -82,6 +87,7 @@ def test_failed_authorize
@gateway.authorize(@amount, @credit_card, @options)
end.respond_with(failed_authorize_response)
assert_equal '7', response.error_code
+ assert_match 'Invalid payment details', response.message
assert_failure response
end
@@ -113,6 +119,8 @@ def test_purchase_authorize_fails
@gateway.purchase(@amount, @credit_card, @options)
end.respond_with(failed_authorize_response)
assert_failure response
+ assert_equal '7', response.error_code
+ assert_match 'Invalid payment details', response.message
assert_equal 1, response.responses.size
end
@@ -157,6 +165,23 @@ def test_void_fails_unless_status_is_authorized
assert_equal "A transaction status of 'AUTHORISED' is required.", response.message
end
+ def test_void_using_order_id_embedded_with_token
+ response = stub_comms do
+ authorization = "#{@options[:order_id]}|99411111780163871111|shopper|59424549c291397379f30c5c082dbed8"
+ @gateway.void(authorization, @options)
+ end.check_request do |endpoint, data, headers|
+ if %r() =~ data
+ assert_tag_with_attributes('orderInquiry', {'orderCode' => @options[:order_id].to_s}, data)
+ end
+ if %r() =~ data
+ assert_tag_with_attributes('orderModification', {'orderCode' => @options[:order_id].to_s}, data)
+ end
+ end.respond_with(successful_void_inquiry_response, successful_void_response)
+ assert_success response
+ assert_equal 'SUCCESS', response.message
+ assert_equal '924e810350efc21a989e0ac7727ce43b', response.params['cancel_received_order_code']
+ end
+
def test_successful_refund_for_captured_payment
response = stub_comms do
@gateway.refund(@amount, @options[:order_id], @options)
@@ -196,6 +221,21 @@ def test_full_refund_for_unsettled_payment_forces_void
assert 'cancel', response.responses.last.params['action']
end
+ def test_refund_using_order_id_embedded_with_token
+ response = stub_comms do
+ authorization = "#{@options[:order_id]}|99411111780163871111|shopper|59424549c291397379f30c5c082dbed8"
+ @gateway.refund(@amount, authorization, @options)
+ end.check_request do |endpoint, data, headers|
+ if %r() =~ data
+ assert_tag_with_attributes('orderInquiry', {'orderCode' => @options[:order_id].to_s}, data)
+ end
+ if %r() =~ data
+ assert_tag_with_attributes('orderModification', {'orderCode' => @options[:order_id].to_s}, data)
+ end
+ end.respond_with(successful_refund_inquiry_response('CAPTURED'), successful_refund_response)
+ assert_success response
+ end
+
def test_capture
response = stub_comms do
response = @gateway.authorize(@amount, @credit_card, @options)
@@ -204,6 +244,19 @@ def test_capture
assert_success response
end
+ def test_capture_using_order_id_embedded_with_token
+ response = stub_comms do
+ response = @gateway.authorize(@amount, @credit_card, @options)
+ authorization = "#{response.authorization}|99411111780163871111|shopper|59424549c291397379f30c5c082dbed8"
+ @gateway.capture(@amount, authorization, @options)
+ end.check_request do |endpoint, data, headers|
+ if %r() =~ data
+ assert_tag_with_attributes('orderModification', {'orderCode' => response.authorization}, data)
+ end
+ end.respond_with(successful_authorize_response, successful_capture_response)
+ assert_success response
+ end
+
def test_successful_visa_credit
response = stub_comms do
@gateway.credit(@amount, @credit_card, @options)
@@ -503,13 +556,6 @@ def test_refund_amount_contains_debit_credit_indicator
assert_success response
end
- def assert_tag_with_attributes(tag, attributes, string)
- assert(m = %r(<#{tag}([^>]+)/>).match(string))
- attributes.each do |attribute, value|
- assert_match %r(#{attribute}="#{value}"), m[1]
- end
- end
-
def test_successful_verify
@gateway.expects(:ssl_post).times(2).returns(successful_authorize_response, successful_void_response)
@@ -602,8 +648,193 @@ def test_failed_verify_with_unknown_card
assert_equal '5', response.error_code
end
+ def test_successful_store
+ response = stub_comms do
+ @gateway.store(@credit_card, @store_options)
+ end.check_request do |endpoint, data, headers|
+ assert_match %r(), data
+ assert_match %r(), data
+ assert_match %r(59424549c291397379f30c5c082dbed8), data
+ assert_match %r(4242424242424242), data
+ assert_no_match %r(), data
+ assert_no_match %r(), data
+ assert_no_match %r(), data
+ end.respond_with(successful_store_response)
+
+ assert_success response
+ assert_equal 'SUCCESS', response.message
+ assert_equal @token, response.authorization
+ end
+
+ def test_successful_authorize_using_token
+ response = stub_comms do
+ @gateway.authorize(@amount, @token, @options)
+ end.check_request do |endpoint, data, headers|
+ assert_tag_with_attributes('order', {'orderCode' => @options[:order_id].to_s}, data)
+ assert_match %r(59424549c291397379f30c5c082dbed8), data
+ assert_tag_with_attributes 'TOKEN-SSL', {'tokenScope' => 'shopper'}, data
+ assert_match %r(99411111780163871111), data
+ end.respond_with(successful_authorize_response)
+
+ assert_success response
+ assert_equal 'SUCCESS', response.message
+ end
+
+ def test_authorize_with_token_includes_shopper_using_minimal_options
+ stub_comms do
+ @gateway.authorize(@amount, @token, @options)
+ end.check_request do |endpoint, data, headers|
+ assert_match %r(59424549c291397379f30c5c082dbed8), data
+ end.respond_with(successful_authorize_response)
+ end
+
+ def test_successful_purchase_using_token
+ response = stub_comms do
+ @gateway.purchase(@amount, @token, @options)
+ end.check_request do |endpoint, data, headers|
+ if %r() =~ data
+ assert_tag_with_attributes('order', {'orderCode' => @options[:order_id].to_s}, data)
+ end
+ end.respond_with(successful_authorize_response, successful_capture_response)
+
+ assert_success response
+ assert_equal 'SUCCESS', response.message
+ end
+
+ def test_successful_verify_using_token
+ response = stub_comms do
+ @gateway.verify(@token, @options)
+ end.check_request do |endpoint, data, headers|
+ if %r() =~ data
+ assert_tag_with_attributes('order', {'orderCode' => @options[:order_id].to_s}, data)
+ end
+ end.respond_with(successful_authorize_response, successful_void_response)
+
+ assert_success response
+ assert_equal 'SUCCESS', response.message
+ end
+
+ def test_successful_credit_using_token
+ response = stub_comms do
+ @gateway.credit(@amount, @token, @options)
+ end.check_request do |endpoint, data, headers|
+ assert_tag_with_attributes('order', {'orderCode' => @options[:order_id].to_s}, data)
+ assert_match(//, data)
+ assert_match %r(59424549c291397379f30c5c082dbed8), data
+ assert_tag_with_attributes 'TOKEN-SSL', {'tokenScope' => 'shopper'}, data
+ assert_match '99411111780163871111', data
+ end.respond_with(successful_visa_credit_response)
+
+ assert_success response
+ assert_equal 'SUCCESS', response.message
+ assert_equal '3d4187536044bd39ad6a289c4339c41c', response.authorization
+ end
+
+ def test_failed_store
+ response = stub_comms do
+ @gateway.store(@credit_card, @store_options.merge(customer: '_invalidId'))
+ end.respond_with(failed_store_response)
+
+ assert_failure response
+ assert_equal '2', response.error_code
+ assert_equal 'authenticatedShopperID cannot start with an underscore', response.message
+ end
+
+ def test_store_should_raise_when_customer_not_present
+ assert_raises(ArgumentError) do
+ @gateway.store(@credit_card)
+ end
+ end
+
+ def test_failed_authorize_using_token
+ response = stub_comms do
+ @gateway.authorize(@amount, @token, @options)
+ end.respond_with(failed_authorize_response_2)
+
+ assert_failure response
+ assert_equal '5', response.error_code
+ assert_match %r{XML failed validation: Invalid payment details : Card number not recognised:}, response.message
+ end
+
+ def test_failed_verify_using_token
+ response = stub_comms do
+ @gateway.verify(@token, @options)
+ end.respond_with(failed_authorize_response_2)
+
+ assert_failure response
+ assert_equal '5', response.error_code
+ assert_match %r{XML failed validation: Invalid payment details : Card number not recognised:}, response.message
+ end
+
+ def test_authorize_order_id_not_overridden_by_order_id_of_token
+ @token = 'wrong_order_id|99411111780163871111|shopper|59424549c291397379f30c5c082dbed8'
+ response = stub_comms do
+ @gateway.authorize(@amount, @token, @options)
+ end.check_request do |endpoint, data, headers|
+ assert_tag_with_attributes('order', {'orderCode' => @options[:order_id].to_s}, data)
+ assert_match %r(59424549c291397379f30c5c082dbed8), data
+ assert_tag_with_attributes 'TOKEN-SSL', {'tokenScope' => 'shopper'}, data
+ assert_match %r(99411111780163871111), data
+ end.respond_with(successful_authorize_response)
+
+ assert_success response
+ assert_equal 'SUCCESS', response.message
+ end
+
+ def test_purchase_order_id_not_overridden_by_order_id_of_token
+ @token = 'wrong_order_id|99411111780163871111|shopper|59424549c291397379f30c5c082dbed8'
+ response = stub_comms do
+ @gateway.purchase(@amount, @token, @options)
+ end.check_request do |endpoint, data, headers|
+ if %r() =~ data
+ assert_tag_with_attributes('order', {'orderCode' => @options[:order_id].to_s}, data)
+ end
+ end.respond_with(successful_authorize_response, successful_capture_response)
+
+ assert_success response
+ assert_equal 'SUCCESS', response.message
+ end
+
+ def test_verify_order_id_not_overridden_by_order_id_of_token
+ @token = 'wrong_order_id|99411111780163871111|shopper|59424549c291397379f30c5c082dbed8'
+ response = stub_comms do
+ @gateway.verify(@token, @options)
+ end.check_request do |endpoint, data, headers|
+ if %r() =~ data
+ assert_tag_with_attributes('order', {'orderCode' => @options[:order_id].to_s}, data)
+ end
+ end.respond_with(successful_authorize_response, successful_void_response)
+
+ assert_success response
+ assert_equal 'SUCCESS', response.message
+ end
+
+ def test_credit_order_id_not_overridden_by_order_if_of_token
+ @token = 'wrong_order_id|99411111780163871111|shopper|59424549c291397379f30c5c082dbed8'
+ response = stub_comms do
+ @gateway.credit(@amount, @token, @options)
+ end.check_request do |endpoint, data, headers|
+ assert_tag_with_attributes('order', {'orderCode' => @options[:order_id].to_s}, data)
+ assert_match(//, data)
+ assert_match %r(59424549c291397379f30c5c082dbed8), data
+ assert_tag_with_attributes 'TOKEN-SSL', {'tokenScope' => 'shopper'}, data
+ assert_match '99411111780163871111', data
+ end.respond_with(successful_visa_credit_response)
+
+ assert_success response
+ assert_equal 'SUCCESS', response.message
+ assert_equal '3d4187536044bd39ad6a289c4339c41c', response.authorization
+ end
+
private
+ def assert_tag_with_attributes(tag, attributes, string)
+ assert(m = %r(<#{tag}([^>]+)/?>).match(string))
+ attributes.each do |attribute, value|
+ assert_match %r(#{attribute}="#{value}"), m[1]
+ end
+ end
+
def three_d_secure_option(version)
{
three_d_secure: {
@@ -658,6 +889,21 @@ def failed_authorize_response
RESPONSE
end
+ # main variation is that CDATA is nested inside w/o newlines; also a
+ # more recent captured response from remote tests where the reply is
+ # contained the error directly (no )
+ def failed_authorize_response_2
+ <<-RESPONSE
+
+
+
+
+
+
+
+ RESPONSE
+ end
+
def successful_capture_response
<<-RESPONSE
@@ -1110,4 +1356,51 @@ def failed_with_unknown_card_response
RESPONSE
end
+
+ def successful_store_response
+ <<-RESPONSE
+
+
+
+
+
+ 59424549c291397379f30c5c082dbed8
+
+ 99411111780163871111
+
+
+
+ Created token without payment on 2019-05-23
+
+
+
+
+
+
+
+
+ VISA
+ VISA_CREDIT
+ N/A
+ 4111********1111
+
+
+
+
+
+
+ RESPONSE
+ end
+
+ def failed_store_response
+ <<-RESPONSE
+
+
+
+
+
+
+
+ RESPONSE
+ end
end
From bdf7fa03b695e161ae6cbe893bc4d27cfbe8fdc3 Mon Sep 17 00:00:00 2001
From: Jared Knipp
Date: Mon, 3 Jun 2019 16:17:15 -0500
Subject: [PATCH 0351/2234] Adyen: Map additional AVS response codes
Map additional Adyen AVS result codes to Active Merchant AVS result
codes.
ECS-301
Unit:
37 tests, 179 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
60 tests, 187 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
closes #3236
---
CHANGELOG | 1 +
lib/active_merchant/billing/avs_result.rb | 7 +++----
lib/active_merchant/billing/gateways/adyen.rb | 6 +++++-
test/unit/gateways/global_transport_test.rb | 2 +-
4 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 0f244190458..002d7591cf2 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -5,6 +5,7 @@
* Adyen: Pass updateShopperStatement, industryUsage [curiousepic] #3233
* TransFirst Transaction Express: Fix blank address2 values [britth] #3231
* WorldPay: Add support for store method [bayprogrammer] #3232
+* Adyen: Support for additional AVS code mapping [jknipp] #3236
== Version 1.95.0 (May 23, 2019)
* Adyen: Constantize version to fix subdomains [curiousepic] #3228
diff --git a/lib/active_merchant/billing/avs_result.rb b/lib/active_merchant/billing/avs_result.rb
index b21017eaa2f..5d63062b59c 100644
--- a/lib/active_merchant/billing/avs_result.rb
+++ b/lib/active_merchant/billing/avs_result.rb
@@ -3,11 +3,10 @@
module ActiveMerchant
module Billing
# Implements the Address Verification System
- # https://www.wellsfargo.com/downloads/pdf/biz/merchant/visa_avs.pdf
+ # https://www.cybersource.com/developers/other_resources/quick_references/avs_results/.
# http://en.wikipedia.org/wiki/Address_Verification_System
- # http://apps.cybersource.com/library/documentation/dev_guides/CC_Svcs_IG/html/app_avs_cvn_codes.htm#app_AVS_CVN_codes_7891_48375
- # http://imgserver.skipjack.com/imgServer/5293710/AVS%20and%20CVV2.pdf
# http://www.emsecommerce.net/avs_cvv2_response_codes.htm
+ # https://www.cardfellow.com/blog/address-verification-service-avs/
class AVSResult
MESSAGES = {
'A' => 'Street address matches, but 5-digit and 9-digit postal code do not match.',
@@ -23,7 +22,7 @@ class AVSResult
'K' => 'Card member\'s name matches but billing address and billing postal code do not match.',
'L' => 'Card member\'s name and billing postal code match, but billing address does not match.',
'M' => 'Street address and postal code match.',
- 'N' => 'Street address and postal code do not match.',
+ 'N' => 'Street address and postal code do not match. For American Express: Card member\'s name, street address and postal code do not match.',
'O' => 'Card member\'s name and billing address match, but billing postal code does not match.',
'P' => 'Postal code matches, but street address not verified.',
'Q' => 'Card member\'s name, billing address, and postal code match. Shipping information verified but chargeback protection not guaranteed.',
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index 477c4874037..16faf16ddee 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -140,10 +140,14 @@ def scrub(transcript)
'16' => 'N', # Postal code doesn't match, address unknown
'17' => 'U', # Postal code doesn't match, address not checked
'18' => 'I', # Neither postal code nor address were checked
+ '19' => 'L', # Name and postal code matches.
'20' => 'V', # Name, address and postal code matches.
+ '21' => 'O', # Name and address matches.
+ '22' => 'K', # Name matches.
'23' => 'F', # Postal code matches, name doesn't match.
'24' => 'H', # Both postal code and address matches, name doesn't match.
- '25' => 'T' # Address matches, name doesn't match.
+ '25' => 'T', # Address matches, name doesn't match.
+ '26' => 'N' # Neither postal code, address nor name matches.
}
CVC_MAPPING = {
diff --git a/test/unit/gateways/global_transport_test.rb b/test/unit/gateways/global_transport_test.rb
index b64fd765323..560c8033025 100644
--- a/test/unit/gateways/global_transport_test.rb
+++ b/test/unit/gateways/global_transport_test.rb
@@ -21,7 +21,7 @@ def test_successful_purchase
assert_equal '3648838', response.authorization
assert response.test?
assert_equal 'CVV matches', response.cvv_result['message']
- assert_equal 'Street address and postal code do not match.', response.avs_result['message']
+ assert_equal 'Street address and postal code do not match. For American Express: Card member\'s name, street address and postal code do not match.', response.avs_result['message']
end
def test_failed_purchase
From 236e0cfdcaaa92b9256b1025fdce30e35e066185 Mon Sep 17 00:00:00 2001
From: Jared Knipp
Date: Tue, 4 Jun 2019 14:36:14 -0500
Subject: [PATCH 0352/2234] Update AVS result message
Update AVS result message for alpha code 'A' to be more generic. The
previous message was causing confusion for merchants processing Canadien
cards with 6 digit postal codes.
ECS-56
Unit:
Authorize.net
96 tests, 565 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Blue Pay
26 tests, 125 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Merchant eSolutions
20 tests, 99 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Metrics Global
22 tests, 93 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Moneris
37 tests, 188 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Moneris US
34 tests, 169 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
Merchant eSolutions
18 tests, 77 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Moneris
31 tests, 123 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Moneris US
30 tests, 118 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
96.6667% passed
- One Unrelated test failure
ECS-56
closes #3237
---
CHANGELOG | 1 +
lib/active_merchant/billing/avs_result.rb | 2 +-
test/remote/gateways/remote_merchant_e_solutions_test.rb | 2 +-
test/remote/gateways/remote_moneris_test.rb | 2 +-
test/remote/gateways/remote_moneris_us_test.rb | 2 +-
test/unit/gateways/authorize_net_test.rb | 2 +-
test/unit/gateways/blue_pay_test.rb | 2 +-
test/unit/gateways/merchant_e_solutions_test.rb | 2 +-
test/unit/gateways/metrics_global_test.rb | 2 +-
test/unit/gateways/moneris_test.rb | 2 +-
test/unit/gateways/moneris_us_test.rb | 2 +-
11 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 002d7591cf2..941f4096580 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -6,6 +6,7 @@
* TransFirst Transaction Express: Fix blank address2 values [britth] #3231
* WorldPay: Add support for store method [bayprogrammer] #3232
* Adyen: Support for additional AVS code mapping [jknipp] #3236
+* Update message for AVS result code 'A' to generically cover postal code mismatches [jknipp] #3237
== Version 1.95.0 (May 23, 2019)
* Adyen: Constantize version to fix subdomains [curiousepic] #3228
diff --git a/lib/active_merchant/billing/avs_result.rb b/lib/active_merchant/billing/avs_result.rb
index 5d63062b59c..77f9ebf3727 100644
--- a/lib/active_merchant/billing/avs_result.rb
+++ b/lib/active_merchant/billing/avs_result.rb
@@ -9,7 +9,7 @@ module Billing
# https://www.cardfellow.com/blog/address-verification-service-avs/
class AVSResult
MESSAGES = {
- 'A' => 'Street address matches, but 5-digit and 9-digit postal code do not match.',
+ 'A' => 'Street address matches, but postal code does not match.',
'B' => 'Street address matches, but postal code not verified.',
'C' => 'Street address and postal code do not match.',
'D' => 'Street address and postal code match.',
diff --git a/test/remote/gateways/remote_merchant_e_solutions_test.rb b/test/remote/gateways/remote_merchant_e_solutions_test.rb
index a9504dac516..7226be98b4d 100644
--- a/test/remote/gateways/remote_merchant_e_solutions_test.rb
+++ b/test/remote/gateways/remote_merchant_e_solutions_test.rb
@@ -149,7 +149,7 @@ def test_unsuccessful_avs_check_with_bad_zip
}
assert response = @gateway.purchase(@amount, @credit_card, options)
assert_equal 'A', response.avs_result['code']
- assert_equal 'Street address matches, but 5-digit and 9-digit postal code do not match.', response.avs_result['message']
+ assert_equal 'Street address matches, but postal code does not match.', response.avs_result['message']
assert_equal 'Y', response.avs_result['street_match']
assert_equal 'N', response.avs_result['postal_match']
end
diff --git a/test/remote/gateways/remote_moneris_test.rb b/test/remote/gateways/remote_moneris_test.rb
index 50a36e13d26..161f17f6807 100644
--- a/test/remote/gateways/remote_moneris_test.rb
+++ b/test/remote/gateways/remote_moneris_test.rb
@@ -262,7 +262,7 @@ def test_avs_result_valid_when_enabled
assert_success response
assert_equal(response.avs_result, {
'code' => 'A',
- 'message' => 'Street address matches, but 5-digit and 9-digit postal code do not match.',
+ 'message' => 'Street address matches, but postal code does not match.',
'street_match' => 'Y',
'postal_match' => 'N'
})
diff --git a/test/remote/gateways/remote_moneris_us_test.rb b/test/remote/gateways/remote_moneris_us_test.rb
index 75bbf7cf52d..dd5c30614f3 100644
--- a/test/remote/gateways/remote_moneris_us_test.rb
+++ b/test/remote/gateways/remote_moneris_us_test.rb
@@ -217,7 +217,7 @@ def test_avs_result_valid_when_enabled
assert_success response
assert_equal(response.avs_result, {
'code' => 'A',
- 'message' => 'Street address matches, but 5-digit and 9-digit postal code do not match.',
+ 'message' => 'Street address matches, but postal code does not match.',
'street_match' => 'Y',
'postal_match' => 'N'
})
diff --git a/test/unit/gateways/authorize_net_test.rb b/test/unit/gateways/authorize_net_test.rb
index 2cdfde5abcd..9c444ad6b3a 100644
--- a/test/unit/gateways/authorize_net_test.rb
+++ b/test/unit/gateways/authorize_net_test.rb
@@ -990,7 +990,7 @@ def test_message
response = stub_comms do
@gateway.purchase(@amount, @credit_card)
end.respond_with(no_match_avs_response)
- assert_equal 'Street address matches, but 5-digit and 9-digit postal code do not match.', response.message
+ assert_equal 'Street address matches, but postal code does not match.', response.message
response = stub_comms do
@gateway.purchase(@amount, @credit_card)
diff --git a/test/unit/gateways/blue_pay_test.rb b/test/unit/gateways/blue_pay_test.rb
index df8f4e62022..bf07a3eac76 100644
--- a/test/unit/gateways/blue_pay_test.rb
+++ b/test/unit/gateways/blue_pay_test.rb
@@ -208,7 +208,7 @@ def test_cvv_result
def test_message_from
assert_equal 'CVV does not match', @gateway.send(:parse, 'STATUS=2&CVV2=N&AVS=A&MESSAGE=FAILURE').message
- assert_equal 'Street address matches, but 5-digit and 9-digit postal code do not match.',
+ assert_equal 'Street address matches, but postal code does not match.',
@gateway.send(:parse, 'STATUS=2&CVV2=M&AVS=A&MESSAGE=FAILURE').message
end
diff --git a/test/unit/gateways/merchant_e_solutions_test.rb b/test/unit/gateways/merchant_e_solutions_test.rb
index 9e073026c41..ca891477a85 100644
--- a/test/unit/gateways/merchant_e_solutions_test.rb
+++ b/test/unit/gateways/merchant_e_solutions_test.rb
@@ -122,7 +122,7 @@ def test_unsuccessful_avs_check_with_bad_zip
@gateway.expects(:ssl_post).returns(successful_purchase_response + '&avs_result=A')
assert response = @gateway.purchase(@amount, @credit_card, @options)
assert_equal response.avs_result['code'], 'A'
- assert_equal response.avs_result['message'], 'Street address matches, but 5-digit and 9-digit postal code do not match.'
+ assert_equal response.avs_result['message'], 'Street address matches, but postal code does not match.'
assert_equal response.avs_result['street_match'], 'Y'
assert_equal response.avs_result['postal_match'], 'N'
end
diff --git a/test/unit/gateways/metrics_global_test.rb b/test/unit/gateways/metrics_global_test.rb
index 0184ddfbeff..e8e3e7da467 100644
--- a/test/unit/gateways/metrics_global_test.rb
+++ b/test/unit/gateways/metrics_global_test.rb
@@ -197,7 +197,7 @@ def test_message_from
assert_equal 'CVV does not match', @gateway.message_from(result)
result[:card_code] = 'M'
- assert_equal 'Street address matches, but 5-digit and 9-digit postal code do not match.', @gateway.message_from(result)
+ assert_equal 'Street address matches, but postal code does not match.', @gateway.message_from(result)
result[:response_reason_code] = '22'
assert_equal 'Failure', @gateway.message_from(result)
diff --git a/test/unit/gateways/moneris_test.rb b/test/unit/gateways/moneris_test.rb
index cf1ece63e0b..f2cd1cd3a77 100644
--- a/test/unit/gateways/moneris_test.rb
+++ b/test/unit/gateways/moneris_test.rb
@@ -349,7 +349,7 @@ def test_avs_result_valid_with_address
assert response = @gateway.purchase(100, @credit_card, @options)
assert_equal(response.avs_result, {
'code' => 'A',
- 'message' => 'Street address matches, but 5-digit and 9-digit postal code do not match.',
+ 'message' => 'Street address matches, but postal code does not match.',
'street_match' => 'Y',
'postal_match' => 'N'
})
diff --git a/test/unit/gateways/moneris_us_test.rb b/test/unit/gateways/moneris_us_test.rb
index b2bff66d3d1..077ad2c8d62 100644
--- a/test/unit/gateways/moneris_us_test.rb
+++ b/test/unit/gateways/moneris_us_test.rb
@@ -300,7 +300,7 @@ def test_avs_result_valid_with_address
assert response = @gateway.purchase(100, @credit_card, @options)
assert_equal(response.avs_result, {
'code' => 'A',
- 'message' => 'Street address matches, but 5-digit and 9-digit postal code do not match.',
+ 'message' => 'Street address matches, but postal code does not match.',
'street_match' => 'Y',
'postal_match' => 'N'
})
From a971becb8ebde766fa70da7cea193dfe40d1bcd6 Mon Sep 17 00:00:00 2001
From: Vincent Smith
Date: Wed, 1 May 2019 11:29:52 -0400
Subject: [PATCH 0353/2234] Update link to Cybersource SOAP Documentation
Unit Tests:
58 tests, 279 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
closes #3204
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/cyber_source.rb | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 941f4096580..d2ad12f7869 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -7,6 +7,7 @@
* WorldPay: Add support for store method [bayprogrammer] #3232
* Adyen: Support for additional AVS code mapping [jknipp] #3236
* Update message for AVS result code 'A' to generically cover postal code mismatches [jknipp] #3237
+* CyberSource: Update CyberSource SOAP documentation link [vince-smith] #3204
== Version 1.95.0 (May 23, 2019)
* Adyen: Constantize version to fix subdomains [curiousepic] #3228
diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb
index 19fea3bce5d..9b65980f240 100644
--- a/lib/active_merchant/billing/gateways/cyber_source.rb
+++ b/lib/active_merchant/billing/gateways/cyber_source.rb
@@ -1,7 +1,7 @@
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
# Initial setup instructions can be found in
- # http://cybersource.com/support_center/implementation/downloads/soap_api/SOAP_toolkits.pdf
+ # http://apps.cybersource.com/library/documentation/dev_guides/SOAP_Toolkits/SOAP_toolkits.pdf
#
# Important Notes
# * For checks you can purchase and store.
From 3216db439aaf03f1ac4199bb5da5a1f4b58bdf6a Mon Sep 17 00:00:00 2001
From: Esty Thomas
Date: Mon, 11 Mar 2019 15:01:35 -0400
Subject: [PATCH 0354/2234] USAePay: Default errors to processing_error
Unit:
3 tests, 3 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
30 tests, 113 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
closes #3167
---
CHANGELOG | 1 +
.../billing/gateways/usa_epay_transaction.rb | 13 ++++++++-----
.../gateways/remote_usa_epay_transaction_test.rb | 7 +++++++
3 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index d2ad12f7869..2bb97a56dbd 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -8,6 +8,7 @@
* Adyen: Support for additional AVS code mapping [jknipp] #3236
* Update message for AVS result code 'A' to generically cover postal code mismatches [jknipp] #3237
* CyberSource: Update CyberSource SOAP documentation link [vince-smith] #3204
+* USAePay: Handle additional error codes and add default error code [estelendur] #3167
== Version 1.95.0 (May 23, 2019)
* Adyen: Constantize version to fix subdomains [curiousepic] #3228
diff --git a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb
index 5b1931fb3a5..e1cade9a52a 100644
--- a/lib/active_merchant/billing/gateways/usa_epay_transaction.rb
+++ b/lib/active_merchant/billing/gateways/usa_epay_transaction.rb
@@ -33,9 +33,9 @@ class UsaEpayTransactionGateway < Gateway
'10110' => STANDARD_ERROR_CODE[:incorrect_address],
'10111' => STANDARD_ERROR_CODE[:incorrect_address],
'10127' => STANDARD_ERROR_CODE[:card_declined],
- '10128' => STANDARD_ERROR_CODE[:processing_error],
- '10132' => STANDARD_ERROR_CODE[:processing_error],
- '00043' => STANDARD_ERROR_CODE[:call_issuer]
+ '00043' => STANDARD_ERROR_CODE[:call_issuer],
+ '10205' => STANDARD_ERROR_CODE[:card_declined],
+ '10204' => STANDARD_ERROR_CODE[:pickup_card]
}
def initialize(options = {})
@@ -318,12 +318,15 @@ def parse(body)
def commit(action, parameters)
url = (test? ? self.test_url : self.live_url)
response = parse(ssl_post(url, post_data(action, parameters)))
- Response.new(response[:status] == 'Approved', message_from(response), response,
+ approved = response[:status] == 'Approved'
+ error_code = nil
+ error_code = (STANDARD_ERROR_CODE_MAPPING[response[:error_code]] || STANDARD_ERROR_CODE[:processing_error]) unless approved
+ Response.new(approved, message_from(response), response,
:test => test?,
:authorization => response[:ref_num],
:cvv_result => response[:cvv2_result_code],
:avs_result => { :code => response[:avs_result_code] },
- :error_code => STANDARD_ERROR_CODE_MAPPING[response[:error_code]]
+ :error_code => error_code
)
end
diff --git a/test/remote/gateways/remote_usa_epay_transaction_test.rb b/test/remote/gateways/remote_usa_epay_transaction_test.rb
index 52c24f212c9..476b2461206 100644
--- a/test/remote/gateways/remote_usa_epay_transaction_test.rb
+++ b/test/remote/gateways/remote_usa_epay_transaction_test.rb
@@ -6,6 +6,7 @@ def setup
@credit_card = credit_card('4000100011112224')
@declined_card = credit_card('4000300011112220')
@credit_card_with_track_data = credit_card_with_track_data('4000100011112224')
+ @invalid_transaction_card = credit_card('4000300511112225')
@check = check
@options = { :billing_address => address(:zip => '27614', :state => 'NC'), :shipping_address => address }
@amount = 100
@@ -253,4 +254,10 @@ def test_transcript_scrubbing
assert_scrubbed(@check.account_number, transcript)
assert_scrubbed(@gateway.options[:login], transcript)
end
+
+ def test_processing_error
+ assert response = @gateway.purchase(@amount, @invalid_transaction_card, @options)
+ assert_equal 'processing_error', response.error_code
+ assert_failure response
+ end
end
From 34f133de98c5fabee8e39467d24f404ecfad1a3a Mon Sep 17 00:00:00 2001
From: leila-alderman
Date: Mon, 10 Jun 2019 10:09:30 -0400
Subject: [PATCH 0355/2234] Braintree: Add skip_avs and skip_cvv fields
Added `skip_avs` and `skip_cvv` gateway specific fields to the
Braintree gateway along with unit and remote tests.
ECS-328
Remote:
73 tests, 415 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
Unit:
61 tests, 162 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
Closes #3241
---
CHANGELOG | 1 +
.../billing/gateways/braintree_blue.rb | 12 +++++++++++-
.../gateways/remote_braintree_blue_test.rb | 14 ++++++++++++++
test/unit/gateways/braintree_blue_test.rb | 18 ++++++++++++++++++
4 files changed, 44 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 2bb97a56dbd..57a1201d025 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -9,6 +9,7 @@
* Update message for AVS result code 'A' to generically cover postal code mismatches [jknipp] #3237
* CyberSource: Update CyberSource SOAP documentation link [vince-smith] #3204
* USAePay: Handle additional error codes and add default error code [estelendur] #3167
+* Braintree: Add `skip_avs` and `skip_cvv` gateway specific fields [leila-alderman] #3241
== Version 1.95.0 (May 23, 2019)
* Adyen: Constantize version to fix subdomains [curiousepic] #3228
diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb
index bff4f0b0e12..e7b48409548 100644
--- a/lib/active_merchant/billing/gateways/braintree_blue.rb
+++ b/lib/active_merchant/billing/gateways/braintree_blue.rb
@@ -419,7 +419,9 @@ def avs_mapping
'street: A, zip: N' => 'C',
'street: A, zip: U' => 'I',
'street: A, zip: I' => 'I',
- 'street: A, zip: A' => 'I'
+ 'street: A, zip: A' => 'I',
+
+ 'street: B, zip: B' => 'B'
}
end
@@ -590,6 +592,14 @@ def create_transaction_parameters(money, credit_card_or_vault_id, options)
parameters[:options][:skip_advanced_fraud_checking] = options[:skip_advanced_fraud_checking]
end
+ if options[:skip_avs]
+ parameters[:options][:skip_avs] = options[:skip_avs]
+ end
+
+ if options[:skip_cvv]
+ parameters[:options][:skip_cvv] = options[:skip_cvv]
+ end
+
parameters[:custom_fields] = options[:custom_fields]
parameters[:device_data] = options[:device_data] if options[:device_data]
parameters[:service_fee_amount] = options[:service_fee_amount] if options[:service_fee_amount]
diff --git a/test/remote/gateways/remote_braintree_blue_test.rb b/test/remote/gateways/remote_braintree_blue_test.rb
index dc32dd9611e..4cc9e7f16a3 100644
--- a/test/remote/gateways/remote_braintree_blue_test.rb
+++ b/test/remote/gateways/remote_braintree_blue_test.rb
@@ -417,6 +417,20 @@ def test_successful_purchase_with_skip_advanced_fraud_checking_option
assert_equal 'submitted_for_settlement', response.params['braintree_transaction']['status']
end
+ def test_successful_purchase_with_skip_avs
+ assert response = @gateway.purchase(@amount, @credit_card, @options.merge(skip_avs: true))
+ assert_success response
+ assert_equal '1000 Approved', response.message
+ assert_equal 'B', response.avs_result['code']
+ end
+
+ def test_successful_purchase_with_skip_cvv
+ assert response = @gateway.purchase(@amount, @credit_card, @options.merge(skip_cvv: true))
+ assert_success response
+ assert_equal '1000 Approved', response.message
+ assert_equal 'B', response.cvv_result['code']
+ end
+
def test_successful_purchase_with_device_data
# Requires Advanced Fraud Tools to be enabled
assert response = @gateway.purchase(@amount, @credit_card, @options.merge(device_data: 'device data for purchase'))
diff --git a/test/unit/gateways/braintree_blue_test.rb b/test/unit/gateways/braintree_blue_test.rb
index ad3a1f1a848..83b8e566089 100644
--- a/test/unit/gateways/braintree_blue_test.rb
+++ b/test/unit/gateways/braintree_blue_test.rb
@@ -686,6 +686,24 @@ def test_passes_transaction_source
@gateway.purchase(100, credit_card('41111111111111111111'), :transaction_source => 'recurring', :recurring => true)
end
+ def test_passes_skip_avs
+ Braintree::TransactionGateway.any_instance.expects(:sale).with do |params|
+ (params[:options][:skip_avs] == true)
+ end.returns(braintree_result(:avs_postal_code_response_code => 'B', :avs_street_address_response_code => 'B'))
+
+ response = @gateway.purchase(100, credit_card('41111111111111111111'), :skip_avs => true)
+ assert_equal 'B', response.avs_result['code']
+ end
+
+ def test_passes_skip_cvv
+ Braintree::TransactionGateway.any_instance.expects(:sale).with do |params|
+ (params[:options][:skip_cvv] == true)
+ end.returns(braintree_result(:cvv_response_code => 'B'))
+
+ response = @gateway.purchase(100, credit_card('41111111111111111111'), :skip_cvv => true)
+ assert_equal 'B', response.cvv_result['code']
+ end
+
def test_configured_logger_has_a_default
# The default is actually provided by the Braintree gem, but we
# assert its presence in order to show ActiveMerchant need not
From bb34f6061e71e7ed903417a124644fc94dae9562 Mon Sep 17 00:00:00 2001
From: Jimmy Zhang
Date: Tue, 19 Mar 2019 11:54:24 +1100
Subject: [PATCH 0356/2234] NAB Transact: Updated periodic test url
Updates the periodic test url and fixes 6 remote test failures.
Unit:
18 tests, 75 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
22 tests, 84 assertions, 3 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
86.3636% passed
closes #3177
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/nab_transact.rb | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 57a1201d025..066f28b0baa 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -10,6 +10,7 @@
* CyberSource: Update CyberSource SOAP documentation link [vince-smith] #3204
* USAePay: Handle additional error codes and add default error code [estelendur] #3167
* Braintree: Add `skip_avs` and `skip_cvv` gateway specific fields [leila-alderman] #3241
+* NAB Transact: Update periodic test url [mengqing] #3177
== Version 1.95.0 (May 23, 2019)
* Adyen: Constantize version to fix subdomains [curiousepic] #3228
diff --git a/lib/active_merchant/billing/gateways/nab_transact.rb b/lib/active_merchant/billing/gateways/nab_transact.rb
index f7df53da09b..6715c0e1afb 100644
--- a/lib/active_merchant/billing/gateways/nab_transact.rb
+++ b/lib/active_merchant/billing/gateways/nab_transact.rb
@@ -12,7 +12,7 @@ class NabTransactGateway < Gateway
self.test_url = 'https://demo.transact.nab.com.au/xmlapi/payment'
self.live_url = 'https://transact.nab.com.au/live/xmlapi/payment'
- self.test_periodic_url = 'https://transact.nab.com.au/xmlapidemo/periodic'
+ self.test_periodic_url = 'https://demo.transact.nab.com.au/xmlapi/periodic'
self.live_periodic_url = 'https://transact.nab.com.au/xmlapi/periodic'
self.supported_countries = ['AU']
From a1845c3e85febebb972c88f754f63a0bd0b6d071 Mon Sep 17 00:00:00 2001
From: Jason Nappier
Date: Thu, 6 Jun 2019 09:27:23 -0400
Subject: [PATCH 0357/2234] NMI: Add level 3 fields tax, shipping, and
ponumber.
All unit tests and remote NMI tests passed.
Closes #3239
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateway.rb | 10 ++
lib/active_merchant/billing/gateways/nmi.rb | 8 ++
test/remote/gateways/remote_nmi_test.rb | 19 +++-
test/unit/gateways/gateway_test.rb | 26 +++++
test/unit/gateways/nmi_test.rb | 101 +++++++++++++++-----
6 files changed, 137 insertions(+), 28 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 066f28b0baa..066cfb578e8 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -11,6 +11,7 @@
* USAePay: Handle additional error codes and add default error code [estelendur] #3167
* Braintree: Add `skip_avs` and `skip_cvv` gateway specific fields [leila-alderman] #3241
* NAB Transact: Update periodic test url [mengqing] #3177
+* NMI: Add level 3 gateway-specific fields tax, shipping, and ponumber [jasonxp] #3239
== Version 1.95.0 (May 23, 2019)
* Adyen: Constantize version to fix subdomains [curiousepic] #3228
diff --git a/lib/active_merchant/billing/gateway.rb b/lib/active_merchant/billing/gateway.rb
index 29fcc6bbaf8..c90e56e28c7 100644
--- a/lib/active_merchant/billing/gateway.rb
+++ b/lib/active_merchant/billing/gateway.rb
@@ -200,6 +200,16 @@ def supports_network_tokenization?
false
end
+ def add_fields_to_post_if_present(post, options, fields)
+ fields.each do |field|
+ add_field_to_post_if_present(post, options, field)
+ end
+ end
+
+ def add_field_to_post_if_present(post, options, field)
+ post[field] = options[field] if options[field]
+ end
+
protected # :nodoc: all
def normalize(field)
diff --git a/lib/active_merchant/billing/gateways/nmi.rb b/lib/active_merchant/billing/gateways/nmi.rb
index 5b3c452e39f..f4d793fa91c 100644
--- a/lib/active_merchant/billing/gateways/nmi.rb
+++ b/lib/active_merchant/billing/gateways/nmi.rb
@@ -34,6 +34,7 @@ def purchase(amount, payment_method, options={})
add_customer_data(post, options)
add_vendor_data(post, options)
add_merchant_defined_fields(post, options)
+ add_level3_fields(post, options)
commit('sale', post)
end
@@ -45,6 +46,7 @@ def authorize(amount, payment_method, options={})
add_customer_data(post, options)
add_vendor_data(post, options)
add_merchant_defined_fields(post, options)
+ add_level3_fields(post, options)
commit('auth', post)
end
@@ -81,6 +83,7 @@ def credit(amount, payment_method, options={})
add_payment_method(post, payment_method, options)
add_customer_data(post, options)
add_vendor_data(post, options)
+ add_level3_fields(post, options)
commit('credit', post)
end
@@ -91,6 +94,7 @@ def verify(payment_method, options={})
add_customer_data(post, options)
add_vendor_data(post, options)
add_merchant_defined_fields(post, options)
+ add_level3_fields(post, options)
commit('validate', post)
end
@@ -131,6 +135,10 @@ def supports_network_tokenization?
private
+ def add_level3_fields(post, options)
+ add_fields_to_post_if_present(post, options, [:tax, :shipping, :ponumber])
+ end
+
def add_invoice(post, money, options)
post[:amount] = amount(money)
post[:orderid] = options[:order_id]
diff --git a/test/remote/gateways/remote_nmi_test.rb b/test/remote/gateways/remote_nmi_test.rb
index b4fbc9ff01a..48f8f7e788c 100644
--- a/test/remote/gateways/remote_nmi_test.rb
+++ b/test/remote/gateways/remote_nmi_test.rb
@@ -22,6 +22,9 @@ def setup
:billing_address => address,
:description => 'Store purchase'
}
+ @level3_options = {
+ tax: 5.25, shipping: 10.51, ponumber: 1002
+ }
end
def test_invalid_login
@@ -32,7 +35,9 @@ def test_invalid_login
end
def test_successful_purchase
- assert response = @gateway.purchase(@amount, @credit_card, @options)
+ options = @options.merge(@level3_options)
+
+ assert response = @gateway.purchase(@amount, @credit_card, options)
assert_success response
assert response.test?
assert_equal 'Succeeded', response.message
@@ -100,7 +105,9 @@ def test_successful_purchase_with_additional_options
end
def test_successful_authorization
- assert response = @gateway.authorize(@amount, @credit_card, @options)
+ options = @options.merge(@level3_options)
+
+ assert response = @gateway.authorize(@amount, @credit_card, options)
assert_success response
assert_equal 'Succeeded', response.message
assert response.authorization
@@ -174,7 +181,9 @@ def test_successful_refund_with_echeck
end
def test_successful_credit
- response = @gateway.credit(@amount, @credit_card, @options)
+ options = @options.merge(@level3_options)
+
+ response = @gateway.credit(@amount, @credit_card, options)
assert_success response
assert_equal 'Succeeded', response.message
end
@@ -186,7 +195,9 @@ def test_failed_credit
end
def test_successful_verify
- response = @gateway.verify(@credit_card, @options)
+ options = @options.merge(@level3_options)
+
+ response = @gateway.verify(@credit_card, options)
assert_success response
assert_match 'Succeeded', response.message
end
diff --git a/test/unit/gateways/gateway_test.rb b/test/unit/gateways/gateway_test.rb
index 3372ee5de13..1be0dd4931c 100644
--- a/test/unit/gateways/gateway_test.rb
+++ b/test/unit/gateways/gateway_test.rb
@@ -143,4 +143,30 @@ def test_strip_invalid_xml_chars
REXML::Document.new(xml)
end
end
+
+ def test_add_field_to_post_if_present
+ order_id = 'abc123'
+
+ post = { }
+ options = { order_id: order_id, do_not_add: 24 }
+
+ @gateway.add_field_to_post_if_present(post, options, :order_id)
+
+ assert_equal post[:order_id], order_id
+ assert_false post.key?(:do_not_add)
+ end
+
+ def test_add_fields_to_post_if_present
+ order_id = 'abc123'
+ transaction_number = 500
+
+ post = { }
+ options = { order_id: order_id, transaction_number: transaction_number, do_not_add: 24 }
+
+ @gateway.add_fields_to_post_if_present(post, options, [:order_id, :transaction_number])
+
+ assert_equal post[:order_id], order_id
+ assert_equal post[:transaction_number], transaction_number
+ assert_false post.key?(:do_not_add)
+ end
end
diff --git a/test/unit/gateways/nmi_test.rb b/test/unit/gateways/nmi_test.rb
index 5c0ee07d25c..945e2ed7b73 100644
--- a/test/unit/gateways/nmi_test.rb
+++ b/test/unit/gateways/nmi_test.rb
@@ -9,7 +9,13 @@ def setup
@amount = 100
@credit_card = credit_card
@check = check
- @options = {}
+
+ @merchant_defined_fields = { merchant_defined_field_8: 'value8' }
+
+ @transaction_options = {
+ recurring: true, order_id: '#1001', description: 'AM test', currency: 'GBP', dup_seconds: 15,
+ customer: '123', tax: 5.25, shipping: 10.51, ponumber: 1002
+ }
end
def test_successful_purchase
@@ -33,18 +39,13 @@ def test_successful_purchase
end
def test_purchase_with_options
+ options = @transaction_options.merge(@merchant_defined_fields)
+
response = stub_comms do
- @gateway.purchase(@amount, @credit_card,
- recurring: true, order_id: '#1001', description: 'AM test',
- currency: 'GBP', dup_seconds: 15, customer: '123',
- merchant_defined_field_8: 'value8')
+ @gateway.purchase(@amount, @credit_card, options)
end.check_request do |endpoint, data, headers|
- assert_match(/billing_method=recurring/, data)
- assert_match(/orderid=#{CGI.escape("#1001")}/, data)
- assert_match(/orderdescription=AM\+test/, data)
- assert_match(/currency=GBP/, data)
- assert_match(/dup_seconds=15/, data)
- assert_match(/customer_id=123/, data)
+ test_transaction_options(data)
+
assert_match(/merchant_defined_field_8=value8/, data)
end.respond_with(successful_purchase_response)
@@ -95,6 +96,20 @@ def test_failed_purchase_with_echeck
assert_equal 'FAILED', response.message
end
+ def test_authorize_with_options
+ options = @transaction_options.merge(@merchant_defined_fields)
+
+ response = stub_comms do
+ @gateway.authorize(@amount, @credit_card, options)
+ end.check_request do |endpoint, data, headers|
+ test_transaction_options(data)
+
+ assert_match(/merchant_defined_field_8=value8/, data)
+ end.respond_with(successful_purchase_response)
+
+ assert_success response
+ end
+
def test_successful_authorize_and_capture
response = stub_comms do
@gateway.authorize(@amount, @credit_card)
@@ -219,6 +234,16 @@ def test_successful_credit
assert response.test?
end
+ def test_credit_with_options
+ response = stub_comms do
+ @gateway.credit(@amount, @credit_card, @transaction_options)
+ end.check_request do |endpoint, data, headers|
+ test_transaction_options(data)
+ end.respond_with(successful_credit_response)
+
+ assert_success response
+ end
+
def test_failed_credit
response = stub_comms do
@gateway.credit(@amount, @credit_card)
@@ -230,20 +255,11 @@ def test_failed_credit
end
def test_successful_verify
- response = stub_comms do
- @gateway.verify(@credit_card)
- end.check_request do |endpoint, data, headers|
- assert_match(/username=#{@gateway.options[:login]}/, data)
- assert_match(/password=#{@gateway.options[:password]}/, data)
- assert_match(/type=validate/, data)
- assert_match(/payment=creditcard/, data)
- assert_match(/ccnumber=#{@credit_card.number}/, data)
- assert_match(/cvv=#{@credit_card.verification_value}/, data)
- assert_match(/ccexp=#{sprintf("%.2i", @credit_card.month)}#{@credit_card.year.to_s[-2..-1]}/, data)
- end.respond_with(successful_validate_response)
+ test_verify
+ end
- assert_success response
- assert_equal 'Succeeded', response.message
+ def test_verify_with_options
+ test_verify(@transaction_options)
end
def test_failed_verify
@@ -368,6 +384,43 @@ def test_duplicate_window_deprecation
private
+ def test_verify(options = {})
+ response = stub_comms do
+ @gateway.verify(@credit_card, options)
+ end.check_request do |endpoint, data, headers|
+ assert_match(/username=#{@gateway.options[:login]}/, data)
+ assert_match(/password=#{@gateway.options[:password]}/, data)
+ assert_match(/type=validate/, data)
+ assert_match(/payment=creditcard/, data)
+ assert_match(/ccnumber=#{@credit_card.number}/, data)
+ assert_match(/cvv=#{@credit_card.verification_value}/, data)
+ assert_match(/ccexp=#{sprintf("%.2i", @credit_card.month)}#{@credit_card.year.to_s[-2..-1]}/,
+ data)
+
+ test_level3_options(data) if options.any?
+ end.respond_with(successful_validate_response)
+
+ assert_success response
+ assert_equal 'Succeeded', response.message
+ end
+
+ def test_level3_options(data)
+ assert_match(/tax=5.25/, data)
+ assert_match(/shipping=10.51/, data)
+ assert_match(/ponumber=1002/, data)
+ end
+
+ def test_transaction_options(data)
+ assert_match(/billing_method=recurring/, data)
+ assert_match(/orderid=#{CGI.escape("#1001")}/, data)
+ assert_match(/orderdescription=AM\+test/, data)
+ assert_match(/currency=GBP/, data)
+ assert_match(/dup_seconds=15/, data)
+ assert_match(/customer_id=123/, data)
+
+ test_level3_options(data)
+ end
+
def successful_purchase_response
'response=1&responsetext=SUCCESS&authcode=123456&transactionid=2762757839&avsresponse=N&cvvresponse=N&orderid=b6c1c57f709cfaa65a5cf5b8532ad181&type=&response_code=100'
end
From 8d506686c09734a398dbd85cd264c2f181b8c622 Mon Sep 17 00:00:00 2001
From: David Perry
Date: Fri, 14 Jun 2019 15:17:23 -0400
Subject: [PATCH 0358/2234] Checkout V2: Update stored card flag
The manner of flagging stored card credentials is different for v2, and
was not caught when updating.
Closes #3247
Remote:
28 tests, 67 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
22 tests, 99 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/checkout_v2.rb | 6 +++---
test/unit/gateways/checkout_v2_test.rb | 2 +-
3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 066cfb578e8..d8ded7a81c0 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -12,6 +12,7 @@
* Braintree: Add `skip_avs` and `skip_cvv` gateway specific fields [leila-alderman] #3241
* NAB Transact: Update periodic test url [mengqing] #3177
* NMI: Add level 3 gateway-specific fields tax, shipping, and ponumber [jasonxp] #3239
+* Checkout V2: Update stored card flag [curiousepic] #3247
== Version 1.95.0 (May 23, 2019)
* Adyen: Constantize version to fix subdomains [curiousepic] #3228
diff --git a/lib/active_merchant/billing/gateways/checkout_v2.rb b/lib/active_merchant/billing/gateways/checkout_v2.rb
index 248c5bfc477..c170598262a 100644
--- a/lib/active_merchant/billing/gateways/checkout_v2.rb
+++ b/lib/active_merchant/billing/gateways/checkout_v2.rb
@@ -32,7 +32,7 @@ def authorize(amount, payment_method, options={})
post = {}
post[:capture] = false
add_invoice(post, amount, options)
- add_payment_method(post, payment_method)
+ add_payment_method(post, payment_method, options)
add_customer_data(post, options)
add_transaction_data(post, options)
add_3ds(post, options)
@@ -94,7 +94,7 @@ def add_invoice(post, money, options)
post[:metadata][:udf5] = application_id || 'ActiveMerchant'
end
- def add_payment_method(post, payment_method)
+ def add_payment_method(post, payment_method, options)
post[:source] = {}
post[:source][:type] = 'card'
post[:source][:name] = payment_method.name
@@ -102,6 +102,7 @@ def add_payment_method(post, payment_method)
post[:source][:cvv] = payment_method.verification_value
post[:source][:expiry_year] = format(payment_method.year, :four_digits)
post[:source][:expiry_month] = format(payment_method.month, :two_digits)
+ post[:source][:stored] = 'true' if options[:card_on_file] == true
end
def add_customer_data(post, options)
@@ -122,7 +123,6 @@ def add_customer_data(post, options)
end
def add_transaction_data(post, options={})
- post[:card_on_file] = true if options[:card_on_file] == true
post[:payment_type] = 'Regular' if options[:transaction_indicator] == 1
post[:payment_type] = 'Recurring' if options[:transaction_indicator] == 2
post[:previous_payment_id] = options[:previous_charge_id] if options[:previous_charge_id]
diff --git a/test/unit/gateways/checkout_v2_test.rb b/test/unit/gateways/checkout_v2_test.rb
index 0c9701ac164..83cca231ecb 100644
--- a/test/unit/gateways/checkout_v2_test.rb
+++ b/test/unit/gateways/checkout_v2_test.rb
@@ -102,7 +102,7 @@ def test_successful_authorize_and_capture_with_additional_options
}
@gateway.authorize(@amount, @credit_card, options)
end.check_request do |endpoint, data, headers|
- assert_match(%r{"card_on_file":true}, data)
+ assert_match(%r{"stored":"true"}, data)
assert_match(%r{"payment_type":"Recurring"}, data)
assert_match(%r{"previous_payment_id":"pay_123"}, data)
end.respond_with(successful_authorize_response)
From 6b8d81cdb8d2d886ad97ef890221ad6530642507 Mon Sep 17 00:00:00 2001
From: Zeb DeOs
Date: Tue, 18 Jun 2019 14:22:26 -0400
Subject: [PATCH 0359/2234] NMI: Add support for stored credentials
Unit:
45 tests, 342 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
41 tests, 151 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
ECS-258
Closes #3243
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/nmi.rb | 30 +++
test/remote/gateways/remote_nmi_test.rb | 117 +++++++++-
test/test_helper.rb | 20 ++
test/unit/gateways/nmi_test.rb | 224 ++++++++++++++++++++
5 files changed, 383 insertions(+), 9 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index d8ded7a81c0..bb4360f4096 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -13,6 +13,7 @@
* NAB Transact: Update periodic test url [mengqing] #3177
* NMI: Add level 3 gateway-specific fields tax, shipping, and ponumber [jasonxp] #3239
* Checkout V2: Update stored card flag [curiousepic] #3247
+* NMI: Add support for stored credentials [bayprogrammer] #3243
== Version 1.95.0 (May 23, 2019)
* Adyen: Constantize version to fix subdomains [curiousepic] #3228
diff --git a/lib/active_merchant/billing/gateways/nmi.rb b/lib/active_merchant/billing/gateways/nmi.rb
index f4d793fa91c..f170a653fa6 100644
--- a/lib/active_merchant/billing/gateways/nmi.rb
+++ b/lib/active_merchant/billing/gateways/nmi.rb
@@ -31,6 +31,7 @@ def purchase(amount, payment_method, options={})
post = {}
add_invoice(post, amount, options)
add_payment_method(post, payment_method, options)
+ add_stored_credential(post, options)
add_customer_data(post, options)
add_vendor_data(post, options)
add_merchant_defined_fields(post, options)
@@ -43,6 +44,7 @@ def authorize(amount, payment_method, options={})
post = {}
add_invoice(post, amount, options)
add_payment_method(post, payment_method, options)
+ add_stored_credential(post, options)
add_customer_data(post, options)
add_vendor_data(post, options)
add_merchant_defined_fields(post, options)
@@ -178,6 +180,34 @@ def add_payment_method(post, payment_method, options)
end
end
+ def add_stored_credential(post, options)
+ return unless (stored_credential = options[:stored_credential])
+
+ if stored_credential[:initiator] == 'cardholder'
+ post[:initiated_by] = 'customer'
+ else
+ post[:initiated_by] = 'merchant'
+ end
+
+ # :reason_type, when provided, overrides anything previously set in
+ # post[:billing_method] (see `add_invoice` and the :recurring) option
+ case stored_credential[:reason_type]
+ when 'recurring'
+ post[:billing_method] = 'recurring'
+ when 'installment'
+ post[:billing_method] = 'installment'
+ when 'unscheduled'
+ post.delete(:billing_method)
+ end
+
+ if stored_credential[:initial_transaction]
+ post[:stored_credential_indicator] = 'stored'
+ else
+ post[:stored_credential_indicator] = 'used'
+ post[:initial_transaction_id] = stored_credential[:network_transaction_id]
+ end
+ end
+
def add_customer_data(post, options)
post[:email] = options[:email]
post[:ipaddress] = options[:ip]
diff --git a/test/remote/gateways/remote_nmi_test.rb b/test/remote/gateways/remote_nmi_test.rb
index 48f8f7e788c..4c4784b216a 100644
--- a/test/remote/gateways/remote_nmi_test.rb
+++ b/test/remote/gateways/remote_nmi_test.rb
@@ -264,6 +264,87 @@ def test_verify_credentials
assert !gateway.verify_credentials
end
+ def test_purchase_using_stored_credential_recurring_cit
+ initial_options = stored_credential_options(:cardholder, :recurring, :initial)
+ assert purchase = @gateway.purchase(@amount, @credit_card, initial_options)
+ assert_success purchase
+ assert network_transaction_id = purchase.params['transactionid']
+
+ used_options = stored_credential_options(:recurring, :cardholder, id: network_transaction_id)
+ assert purchase = @gateway.purchase(@amount, @credit_card, used_options)
+ assert_success purchase
+ end
+
+ def test_purchase_using_stored_credential_recurring_mit
+ initial_options = stored_credential_options(:merchant, :recurring, :initial)
+ assert purchase = @gateway.purchase(@amount, @credit_card, initial_options)
+ assert_success purchase
+ assert network_transaction_id = purchase.params['transactionid']
+
+ used_options = stored_credential_options(:merchant, :recurring, id: network_transaction_id)
+ assert purchase = @gateway.purchase(@amount, @credit_card, used_options)
+ assert_success purchase
+ end
+
+ def test_purchase_using_stored_credential_installment_cit
+ initial_options = stored_credential_options(:cardholder, :installment, :initial)
+ assert purchase = @gateway.purchase(@amount, @credit_card, initial_options)
+ assert_success purchase
+ assert network_transaction_id = purchase.params['transactionid']
+
+ used_options = stored_credential_options(:cardholder, :installment, id: network_transaction_id)
+ assert purchase = @gateway.purchase(@amount, @credit_card, used_options)
+ assert_success purchase
+ end
+
+ def test_purchase_using_stored_credential_installment_mit
+ initial_options = stored_credential_options(:merchant, :installment, :initial)
+ assert purchase = @gateway.purchase(@amount, @credit_card, initial_options)
+ assert_success purchase
+ assert network_transaction_id = purchase.params['transactionid']
+
+ used_options = stored_credential_options(:merchant, :installment, id: network_transaction_id)
+ assert purchase = @gateway.purchase(@amount, @credit_card, used_options)
+ assert_success purchase
+ end
+
+ def test_purchase_using_stored_credential_unscheduled_cit
+ initial_options = stored_credential_options(:cardholder, :unscheduled, :initial)
+ assert purchase = @gateway.purchase(@amount, @credit_card, initial_options)
+ assert_success purchase
+ assert network_transaction_id = purchase.params['transactionid']
+
+ used_options = stored_credential_options(:cardholder, :unscheduled, id: network_transaction_id)
+ assert purchase = @gateway.purchase(@amount, @credit_card, used_options)
+ assert_success purchase
+ end
+
+ def test_purchase_using_stored_credential_unscheduled_mit
+ initial_options = stored_credential_options(:merchant, :unscheduled, :initial)
+ assert purchase = @gateway.purchase(@amount, @credit_card, initial_options)
+ assert_success purchase
+ assert network_transaction_id = purchase.params['transactionid']
+
+ used_options = stored_credential_options(:merchant, :unscheduled, id: network_transaction_id)
+ assert purchase = @gateway.purchase(@amount, @credit_card, used_options)
+ assert_success purchase
+ end
+
+ def test_authorize_and_capture_with_stored_credential
+ initial_options = stored_credential_options(:cardholder, :recurring, :initial)
+ assert authorization = @gateway.authorize(@amount, @credit_card, initial_options)
+ assert_success authorization
+ assert network_transaction_id = authorization.params['transactionid']
+
+ assert capture = @gateway.capture(@amount, authorization.authorization)
+ assert_success capture
+
+ used_options = stored_credential_options(:cardholder, :recurring, id: network_transaction_id)
+ assert authorization = @gateway.authorize(@amount, @credit_card, used_options)
+ assert_success authorization
+ assert @gateway.capture(@amount, authorization.authorization)
+ end
+
def test_card_transcript_scrubbing
transcript = capture_transcript(@gateway) do
@gateway.purchase(@amount, @credit_card, @options)
@@ -271,10 +352,8 @@ def test_card_transcript_scrubbing
clean_transcript = @gateway.scrub(transcript)
assert_scrubbed(@credit_card.number, clean_transcript)
- assert_scrubbed(@credit_card.verification_value.to_s, clean_transcript)
-
- # "password=password is filtered, but can't be tested b/c of key match"
- # assert_scrubbed(@gateway.options[:password], clean_transcript)
+ assert_cvv_scrubbed(clean_transcript)
+ assert_password_scrubbed(clean_transcript)
end
def test_check_transcript_scrubbing
@@ -285,9 +364,7 @@ def test_check_transcript_scrubbing
assert_scrubbed(@check.account_number, clean_transcript)
assert_scrubbed(@check.routing_number, clean_transcript)
-
- # "password=password is filtered, but can't be tested b/c of key match"
- # assert_scrubbed(@gateway.options[:password], clean_transcript)
+ assert_password_scrubbed(clean_transcript)
end
def test_network_tokenization_transcript_scrubbing
@@ -298,8 +375,30 @@ def test_network_tokenization_transcript_scrubbing
assert_scrubbed(@apple_pay_card.number, clean_transcript)
assert_scrubbed(@apple_pay_card.payment_cryptogram, clean_transcript)
+ assert_password_scrubbed(clean_transcript)
+ end
+
+ private
+
+ # "password=password is filtered, but can't be tested via normal
+ # `assert_scrubbed` b/c of key match"
+ def assert_password_scrubbed(transcript)
+ assert_match(/password=\[FILTERED\]/, transcript)
+ end
+
+ # Because the cvv is a simple three digit number, sometimes there are random
+ # failures using `assert_scrubbed` because of natural collisions with a
+ # substring within orderid in transcript; e.g.
+ #
+ # Expected the value to be scrubbed out of the transcript.
+ # 917/> was expected to not match
+ # <"opening connection to secure.nmi.com:443...\nopened\nstarting SSL for secure.nmi.com:443...\nSSL established\n<- \"POST /api/transact.php HTTP/1.1\\r\\nContent-Type: application/x-www-form-urlencoded;charset=UTF-8\\r\\nConnection: close\\r\\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\\r\\nAccept: */*\\r\\nUser-Agent: Ruby\\r\\nHost: secure.nmi.com\\r\\nContent-Length: 394\\r\\n\\r\\n\"\n<- \"amount=7.96&orderid=9bb4c3bf6fbb26b91796ae9442cb1941&orderdescription=Store+purchase¤cy=USD&payment=creditcard&firstname=Longbob&lastname=Longsen&ccnumber=[FILTERED]&cvv=[FILTERED]&ccexp=0920&email=&ipaddress=&customer_id=&company=Widgets+Inc&address1=456+My+Street&address2=Apt+1&city=Ottawa&state=ON&country=CA&zip=K1C2N6&phone=%28555%29555-5555&type=sale&username=demo&password=[FILTERED]\"\n-> \"HTTP/1.1 200 OK\\r\\n\"\n-> \"Date: Wed, 12 Jun 2019 21:10:29 GMT\\r\\n\"\n-> \"Server: Apache\\r\\n\"\n-> \"Content-Length: 169\\r\\n\"\n-> \"Connection: close\\r\\n\"\n-> \"Content-Type: text/html; charset=UTF-8\\r\\n\"\n-> \"\\r\\n\"\nreading 169 bytes...\n-> \"response=1&responsetext=SUCCESS&authcode=123456&transactionid=4743046890&avsresponse=N&cvvresponse=N&orderid=9bb4c3bf6fbb26b91796ae9442cb1941&type=sale&response_code=100\"\nread 169 bytes\nConn close\n">.
+ def assert_cvv_scrubbed(transcript)
+ assert_match(/cvv=\[FILTERED\]/, transcript)
+ end
- # "password=password is filtered, but can't be tested b/c of key match"
- # assert_scrubbed(@gateway.options[:password], clean_transcript)
+ def stored_credential_options(*args, id: nil)
+ @options.merge(order_id: generate_unique_id,
+ stored_credential: stored_credential(*args, id: id))
end
end
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 9666234fea9..361857a3afb 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -245,6 +245,26 @@ def statement_address(options = {})
}.update(options)
end
+ def stored_credential(*args, **options)
+ id = options.delete(:id) || options.delete(:network_transaction_id)
+
+ stored_credential = {
+ network_transaction_id: id,
+ initial_transaction: false
+ }
+
+ stored_credential[:initial_transaction] = true if args.include?(:initial)
+
+ stored_credential[:reason_type] = 'recurring' if args.include?(:recurring)
+ stored_credential[:reason_type] = 'unscheduled' if args.include?(:unscheduled)
+ stored_credential[:reason_type] = 'installment' if args.include?(:installment)
+
+ stored_credential[:initiator] = 'cardholder' if args.include?(:cardholder)
+ stored_credential[:initiator] = 'merchant' if args.include?(:merchant)
+
+ stored_credential
+ end
+
def generate_unique_id
SecureRandom.hex(16)
end
diff --git a/test/unit/gateways/nmi_test.rb b/test/unit/gateways/nmi_test.rb
index 945e2ed7b73..a3586414a25 100644
--- a/test/unit/gateways/nmi_test.rb
+++ b/test/unit/gateways/nmi_test.rb
@@ -382,6 +382,216 @@ def test_duplicate_window_deprecation
end
end
+ def test_stored_credential_recurring_cit_initial
+ options = stored_credential_options(:cardholder, :recurring, :initial)
+ response = stub_comms do
+ @gateway.authorize(@amount, @credit_card, options)
+ end.check_request do |endpoint, data, headers|
+ assert_match(/initiated_by=customer/, data)
+ assert_match(/stored_credential_indicator=stored/, data)
+ assert_match(/billing_method=recurring/, data)
+ refute_match(/initial_transaction_id/, data)
+ end.respond_with(successful_authorization_response)
+
+ assert_success response
+ end
+
+ def test_stored_credential_recurring_cit_used
+ options = stored_credential_options(:cardholder, :recurring, id: 'abc123')
+ response = stub_comms do
+ @gateway.authorize(@amount, @credit_card, options)
+ end.check_request do |endpoint, data, headers|
+ assert_match(/initiated_by=customer/, data)
+ assert_match(/stored_credential_indicator=used/, data)
+ assert_match(/billing_method=recurring/, data)
+ assert_match(/initial_transaction_id=abc123/, data)
+ end.respond_with(successful_authorization_response)
+
+ assert_success response
+ end
+
+ def test_stored_credential_recurring_mit_initial
+ options = stored_credential_options(:merchant, :recurring, :initial)
+ response = stub_comms do
+ @gateway.authorize(@amount, @credit_card, options)
+ end.check_request do |endpoint, data, headers|
+ assert_match(/initiated_by=merchant/, data)
+ assert_match(/stored_credential_indicator=stored/, data)
+ assert_match(/billing_method=recurring/, data)
+ refute_match(/initial_transaction_id/, data)
+ end.respond_with(successful_authorization_response)
+
+ assert_success response
+ end
+
+ def test_stored_credential_recurring_mit_used
+ options = stored_credential_options(:merchant, :recurring, id: 'abc123')
+ response = stub_comms do
+ @gateway.authorize(@amount, @credit_card, options)
+ end.check_request do |endpoint, data, headers|
+ assert_match(/initiated_by=merchant/, data)
+ assert_match(/stored_credential_indicator=used/, data)
+ assert_match(/billing_method=recurring/, data)
+ assert_match(/initial_transaction_id=abc123/, data)
+ end.respond_with(successful_authorization_response)
+
+ assert_success response
+ end
+
+ def test_stored_credential_installment_cit_initial
+ options = stored_credential_options(:cardholder, :installment, :initial)
+ response = stub_comms do
+ @gateway.authorize(@amount, @credit_card, options)
+ end.check_request do |endpoint, data, headers|
+ assert_match(/initiated_by=customer/, data)
+ assert_match(/stored_credential_indicator=stored/, data)
+ assert_match(/billing_method=installment/, data)
+ refute_match(/initial_transaction_id/, data)
+ end.respond_with(successful_authorization_response)
+
+ assert_success response
+ end
+
+ def test_stored_credential_installment_cit_used
+ options = stored_credential_options(:cardholder, :installment, id: 'abc123')
+ response = stub_comms do
+ @gateway.authorize(@amount, @credit_card, options)
+ end.check_request do |endpoint, data, headers|
+ assert_match(/initiated_by=customer/, data)
+ assert_match(/stored_credential_indicator=used/, data)
+ assert_match(/billing_method=installment/, data)
+ assert_match(/initial_transaction_id=abc123/, data)
+ end.respond_with(successful_authorization_response)
+
+ assert_success response
+ end
+
+ def test_stored_credential_installment_mit_initial
+ options = stored_credential_options(:merchant, :installment, :initial)
+ response = stub_comms do
+ @gateway.authorize(@amount, @credit_card, options)
+ end.check_request do |endpoint, data, headers|
+ assert_match(/initiated_by=merchant/, data)
+ assert_match(/stored_credential_indicator=stored/, data)
+ assert_match(/billing_method=installment/, data)
+ refute_match(/initial_transaction_id/, data)
+ end.respond_with(successful_authorization_response)
+
+ assert_success response
+ end
+
+ def test_stored_credential_installment_mit_used
+ options = stored_credential_options(:merchant, :installment, id: 'abc123')
+ response = stub_comms do
+ @gateway.authorize(@amount, @credit_card, options)
+ end.check_request do |endpoint, data, headers|
+ assert_match(/initiated_by=merchant/, data)
+ assert_match(/stored_credential_indicator=used/, data)
+ assert_match(/billing_method=installment/, data)
+ assert_match(/initial_transaction_id=abc123/, data)
+ end.respond_with(successful_authorization_response)
+
+ assert_success response
+ end
+
+ def test_stored_credential_unscheduled_cit_initial
+ options = stored_credential_options(:cardholder, :unscheduled, :initial)
+ response = stub_comms do
+ @gateway.authorize(@amount, @credit_card, options)
+ end.check_request do |endpoint, data, headers|
+ assert_match(/initiated_by=customer/, data)
+ assert_match(/stored_credential_indicator=stored/, data)
+ refute_match(/billing_method/, data)
+ refute_match(/initial_transaction_id/, data)
+ end.respond_with(successful_authorization_response)
+
+ assert_success response
+ end
+
+ def test_stored_credential_unscheduled_cit_used
+ options = stored_credential_options(:cardholder, :unscheduled, id: 'abc123')
+ response = stub_comms do
+ @gateway.authorize(@amount, @credit_card, options)
+ end.check_request do |endpoint, data, headers|
+ assert_match(/initiated_by=customer/, data)
+ assert_match(/stored_credential_indicator=used/, data)
+ refute_match(/billing_method/, data)
+ assert_match(/initial_transaction_id=abc123/, data)
+ end.respond_with(successful_authorization_response)
+
+ assert_success response
+ end
+
+ def test_stored_credential_unscheduled_mit_initial
+ options = stored_credential_options(:merchant, :unscheduled, :initial)
+ response = stub_comms do
+ @gateway.authorize(@amount, @credit_card, options)
+ end.check_request do |endpoint, data, headers|
+ assert_match(/initiated_by=merchant/, data)
+ assert_match(/stored_credential_indicator=stored/, data)
+ refute_match(/billing_method/, data)
+ refute_match(/initial_transaction_id/, data)
+ end.respond_with(successful_authorization_response)
+
+ assert_success response
+ end
+
+ def test_stored_credential_unscheduled_mit_used
+ options = stored_credential_options(:merchant, :unscheduled, id: 'abc123')
+ response = stub_comms do
+ @gateway.authorize(@amount, @credit_card, options)
+ end.check_request do |endpoint, data, headers|
+ assert_match(/initiated_by=merchant/, data)
+ assert_match(/stored_credential_indicator=used/, data)
+ refute_match(/billing_method/, data)
+ assert_match(/initial_transaction_id=abc123/, data)
+ end.respond_with(successful_authorization_response)
+
+ assert_success response
+ end
+
+ def test_purchase_with_stored_credential
+ options = stored_credential_options(:merchant, :installment, id: 'abc123')
+ response = stub_comms do
+ @gateway.purchase(@amount, @credit_card, options)
+ end.check_request do |endpoint, data, headers|
+ assert_match(/initiated_by=merchant/, data)
+ assert_match(/stored_credential_indicator=used/, data)
+ assert_match(/billing_method=installment/, data)
+ assert_match(/initial_transaction_id=abc123/, data)
+ end.respond_with(successful_authorization_response)
+
+ assert_success response
+ end
+
+ def test_stored_credential_installment_takes_precedence_over_recurring_option
+ options = stored_credential_options(:merchant, :installment, id: 'abc123').merge(recurring: true)
+ response = stub_comms do
+ @gateway.authorize(@amount, @credit_card, options)
+ end.check_request do |endpoint, data, headers|
+ assert_match(/initiated_by=merchant/, data)
+ assert_match(/stored_credential_indicator=used/, data)
+ assert_match(/billing_method=installment/, data)
+ assert_match(/initial_transaction_id=abc123/, data)
+ end.respond_with(successful_authorization_response)
+
+ assert_success response
+ end
+
+ def test_stored_credential_unscheduled_takes_precedence_over_recurring_option
+ options = stored_credential_options(:merchant, :unscheduled, id: 'abc123').merge(recurring: true)
+ response = stub_comms do
+ @gateway.authorize(@amount, @credit_card, options)
+ end.check_request do |endpoint, data, headers|
+ assert_match(/initiated_by=merchant/, data)
+ assert_match(/stored_credential_indicator=used/, data)
+ refute_match(/billing_method/, data)
+ assert_match(/initial_transaction_id=abc123/, data)
+ end.respond_with(successful_authorization_response)
+
+ assert_success response
+ end
+
private
def test_verify(options = {})
@@ -421,6 +631,20 @@ def test_transaction_options(data)
test_level3_options(data)
end
+ def stored_credential_options(*args, id: nil)
+ {
+ order_id: '#1001',
+ description: 'AM test',
+ currency: 'GBP',
+ dup_seconds: 15,
+ customer: '123',
+ tax: 5.25,
+ shipping: 10.51,
+ ponumber: 1002,
+ stored_credential: stored_credential(*args, id: id)
+ }
+ end
+
def successful_purchase_response
'response=1&responsetext=SUCCESS&authcode=123456&transactionid=2762757839&avsresponse=N&cvvresponse=N&orderid=b6c1c57f709cfaa65a5cf5b8532ad181&type=&response_code=100'
end
From 1ab94da134d64396e2f1d9737a13154e79949ce0 Mon Sep 17 00:00:00 2001
From: Lancelot Carlson
Date: Fri, 4 Jan 2019 18:18:39 -0500
Subject: [PATCH 0360/2234] Spreedly: Consolidate API requests and support bank
accounts
- Consolidate payment method storage and auth/purchase/verify API
requests into a single request.
- Support bank account payment methods.
Unit Tests:
26 tests, 144 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote Tests:
34 tests, 160 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
ECS-372
closes #3105
closes #3078
---
CHANGELOG | 1 +
.../billing/gateways/spreedly_core.rb | 64 +++++-----
.../gateways/remote_spreedly_core_test.rb | 19 ++-
test/unit/gateways/spreedly_core_test.rb | 115 +++++++++++++++++-
4 files changed, 162 insertions(+), 37 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index bb4360f4096..4149ce4dec7 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -14,6 +14,7 @@
* NMI: Add level 3 gateway-specific fields tax, shipping, and ponumber [jasonxp] #3239
* Checkout V2: Update stored card flag [curiousepic] #3247
* NMI: Add support for stored credentials [bayprogrammer] #3243
+* Spreedly: Consolidate API requests and support bank accounts [lancecarlson] #3105
== Version 1.95.0 (May 23, 2019)
* Adyen: Constantize version to fix subdomains [curiousepic] #3228
diff --git a/lib/active_merchant/billing/gateways/spreedly_core.rb b/lib/active_merchant/billing/gateways/spreedly_core.rb
index d3d3e91af87..47175cc2194 100644
--- a/lib/active_merchant/billing/gateways/spreedly_core.rb
+++ b/lib/active_merchant/billing/gateways/spreedly_core.rb
@@ -35,19 +35,13 @@ def initialize(options = {})
# Public: Run a purchase transaction.
#
# money - The monetary amount of the transaction in cents.
- # payment_method - The CreditCard or the Spreedly payment method token.
+ # payment_method - The CreditCard or Check or the Spreedly payment method token.
# options - A hash of options:
# :store - Retain the payment method if the purchase
# succeeds. Defaults to false. (optional)
def purchase(money, payment_method, options = {})
- if payment_method.is_a?(String)
- purchase_with_token(money, payment_method, options)
- else
- MultiResponse.run do |r|
- r.process { save_card(options[:store], payment_method, options) }
- r.process { purchase_with_token(money, r.authorization, options) }
- end
- end
+ request = build_transaction_request(money, payment_method, options)
+ commit("gateways/#{options[:gateway_token] || @options[:gateway_token]}/purchase.xml", request)
end
# Public: Run an authorize transaction.
@@ -58,14 +52,8 @@ def purchase(money, payment_method, options = {})
# :store - Retain the payment method if the authorize
# succeeds. Defaults to false. (optional)
def authorize(money, payment_method, options = {})
- if payment_method.is_a?(String)
- authorize_with_token(money, payment_method, options)
- else
- MultiResponse.run do |r|
- r.process { save_card(options[:store], payment_method, options) }
- r.process { authorize_with_token(money, r.authorization, options) }
- end
- end
+ request = build_transaction_request(money, payment_method, options)
+ commit("gateways/#{@options[:gateway_token]}/authorize.xml", request)
end
def capture(money, authorization, options={})
@@ -155,32 +143,25 @@ def save_card(retain, credit_card, options)
end
def purchase_with_token(money, payment_method_token, options)
- request = auth_purchase_request(money, payment_method_token, options)
+ request = build_transaction_request(money, payment_method_token, options)
commit("gateways/#{options[:gateway_token] || @options[:gateway_token]}/purchase.xml", request)
end
def authorize_with_token(money, payment_method_token, options)
- request = auth_purchase_request(money, payment_method_token, options)
+ request = build_transaction_request(money, payment_method_token, options)
commit("gateways/#{@options[:gateway_token]}/authorize.xml", request)
end
def verify_with_token(payment_method_token, options)
- request = build_xml_request('transaction') do |doc|
- add_invoice(doc, nil, options)
- doc.payment_method_token(payment_method_token)
- doc.retain_on_success(true) if options[:store]
- add_extra_options(:gateway_specific_fields, doc, options)
- end
-
+ request = build_transaction_request(nil, payment_method_token, options)
commit("gateways/#{@options[:gateway_token]}/verify.xml", request)
end
- def auth_purchase_request(money, payment_method_token, options)
+ def build_transaction_request(money, payment_method, options)
build_xml_request('transaction') do |doc|
add_invoice(doc, money, options)
+ add_payment_method(doc, payment_method, options)
add_extra_options(:gateway_specific_fields, doc, options)
- doc.payment_method_token(payment_method_token)
- doc.retain_on_success(true) if options[:store]
end
end
@@ -192,6 +173,20 @@ def add_invoice(doc, money, options)
doc.description(options[:description]) if options[:description]
end
+ def add_payment_method(doc, payment_method, options)
+ doc.retain_on_success(true) if options[:store]
+
+ if payment_method.is_a?(String)
+ doc.payment_method_token(payment_method)
+ elsif payment_method.is_a?(CreditCard)
+ add_credit_card(doc, payment_method, options)
+ elsif payment_method.is_a?(Check)
+ add_bank_account(doc, payment_method, options)
+ else
+ raise TypeError, 'Payment method not supported'
+ end
+ end
+
def add_credit_card(doc, credit_card, options)
doc.credit_card do
doc.number(credit_card.number)
@@ -210,6 +205,17 @@ def add_credit_card(doc, credit_card, options)
end
end
+ def add_bank_account(doc, bank_account, options)
+ doc.bank_account do
+ doc.first_name(bank_account.first_name)
+ doc.last_name(bank_account.last_name)
+ doc.bank_routing_number(bank_account.routing_number)
+ doc.bank_account_number(bank_account.account_number)
+ doc.bank_account_type(bank_account.account_type)
+ doc.bank_account_holder_type(bank_account.account_holder_type)
+ end
+ end
+
def add_extra_options(type, doc, options)
doc.send(type) do
extra_options_to_doc(doc, options[type])
diff --git a/test/remote/gateways/remote_spreedly_core_test.rb b/test/remote/gateways/remote_spreedly_core_test.rb
index c9ea36a7d2c..a162d35a6fc 100644
--- a/test/remote/gateways/remote_spreedly_core_test.rb
+++ b/test/remote/gateways/remote_spreedly_core_test.rb
@@ -8,6 +8,7 @@ def setup
@amount = 100
@credit_card = credit_card('5555555555554444')
@declined_card = credit_card('4012888888881881')
+ @check = check({routing_number: '021000021', account_number: '9876543210'})
@existing_payment_method = '3rEkRlZur2hXKbwwRBidHJAIUTO'
@declined_payment_method = 'UPfh3J3JbekLeYC88BP741JWnS5'
@existing_transaction = 'PJ5ICgM6h7v9pBNxDCJjRHDDxBC'
@@ -60,6 +61,14 @@ def test_successful_purchase_with_credit_card
assert_equal 'cached', response.params['payment_method_storage_state']
end
+ def test_successful_purchase_with_check
+ assert response = @gateway.purchase(@amount, @check)
+ assert_success response
+ assert_equal 'Succeeded!', response.message
+ assert_equal 'Purchase', response.params['transaction_type']
+ assert_equal 'cached', response.params['payment_method_storage_state']
+ end
+
def test_successful_purchase_with_card_and_address
options = {
:email => 'joebob@example.com',
@@ -88,7 +97,8 @@ def test_failed_purchase_with_invalid_credit_card
@credit_card.first_name = ' '
assert response = @gateway.purchase(@amount, @credit_card)
assert_failure response
- assert_equal "First name can't be blank", response.message
+ assert_equal 'The payment method is invalid.', response.message
+ assert_equal "First name can't be blank", response.params['payment_method_errors'].strip
end
def test_successful_purchase_with_store
@@ -96,7 +106,7 @@ def test_successful_purchase_with_store
assert_success response
assert_equal 'Succeeded!', response.message
assert_equal 'Purchase', response.params['transaction_type']
- assert_equal 'retained', response.params['payment_method_storage_state']
+ assert %w(retained cached).include?(response.params['payment_method_storage_state'])
assert !response.params['payment_method_token'].blank?
end
@@ -141,7 +151,8 @@ def test_failed_authrorize_with_invalid_credit_card
@credit_card.first_name = ' '
assert response = @gateway.authorize(@amount, @credit_card)
assert_failure response
- assert_equal "First name can't be blank", response.message
+ assert_equal 'The payment method is invalid.', response.message
+ assert_equal "First name can't be blank", response.params['payment_method_errors'].strip
end
def test_successful_authorize_with_store
@@ -149,7 +160,7 @@ def test_successful_authorize_with_store
assert_success response
assert_equal 'Succeeded!', response.message
assert_equal 'Authorization', response.params['transaction_type']
- assert_equal 'retained', response.params['payment_method_storage_state']
+ assert %w(retained cached).include?(response.params['payment_method_storage_state'])
assert !response.params['payment_method_token'].blank?
end
diff --git a/test/unit/gateways/spreedly_core_test.rb b/test/unit/gateways/spreedly_core_test.rb
index afc5d4dd961..89e86fb2e28 100644
--- a/test/unit/gateways/spreedly_core_test.rb
+++ b/test/unit/gateways/spreedly_core_test.rb
@@ -7,6 +7,7 @@ def setup
@payment_method_token = 'E3eQGR3E0xiosj7FOJRtIKbF8Ch'
@credit_card = credit_card
+ @check = check
@amount = 103
@existing_transaction = 'LKA3RchoqYO0njAfhHVw60ohjrC'
@not_found_transaction = 'AdyQXaG0SVpSoMPdmFlvd3aA3uz'
@@ -41,7 +42,7 @@ def test_failed_purchase_with_payment_method_token
end
def test_successful_purchase_with_credit_card
- @gateway.stubs(:raw_ssl_request).returns(successful_store_response, successful_purchase_response)
+ @gateway.stubs(:raw_ssl_request).returns(successful_purchase_response)
response = @gateway.purchase(@amount, @credit_card)
assert_success response
@@ -57,6 +58,21 @@ def test_successful_purchase_with_credit_card
assert_equal 'used', response.params['payment_method_storage_state']
end
+ def test_successful_purchase_with_check
+ @gateway.stubs(:raw_ssl_request).returns(successful_check_purchase_response)
+ response = @gateway.purchase(@amount, @check)
+
+ assert_success response
+ assert !response.test?
+
+ assert_equal 'ZwnfZs3Qy4gRDPWXHopamNuarCJ', response.authorization
+ assert_equal 'Succeeded!', response.message
+ assert_equal 'Purchase', response.params['transaction_type']
+ assert_equal 'HtCrYfW17wEzWWfrMbwDX4TwPVW', response.params['payment_method_token']
+ assert_equal '021*', response.params['payment_method_routing_number']
+ assert_equal '*3210', response.params['payment_method_account_number']
+ end
+
def test_failed_purchase_with_invalid_credit_card
@gateway.expects(:raw_ssl_request).returns(failed_store_response)
response = @gateway.purchase(@amount, @credit_card)
@@ -65,7 +81,7 @@ def test_failed_purchase_with_invalid_credit_card
end
def test_failed_purchase_with_credit_card
- @gateway.stubs(:raw_ssl_request).returns(successful_store_response, failed_purchase_response)
+ @gateway.stubs(:raw_ssl_request).returns(failed_purchase_response)
response = @gateway.purchase(@amount, @credit_card)
assert_failure response
@@ -121,7 +137,7 @@ def test_failed_authorize_with_token
end
def test_successful_authorize_with_credit_card_and_capture
- @gateway.stubs(:raw_ssl_request).returns(successful_store_response, successful_authorize_response)
+ @gateway.stubs(:raw_ssl_request).returns(successful_authorize_response)
response = @gateway.authorize(@amount, @credit_card)
assert_success response
@@ -144,7 +160,7 @@ def test_successful_authorize_with_credit_card_and_capture
end
def test_failed_authorize_with_credit_card
- @gateway.stubs(:raw_ssl_request).returns(successful_store_response, failed_authorize_response)
+ @gateway.stubs(:raw_ssl_request).returns(failed_authorize_response)
response = @gateway.authorize(@amount, @credit_card)
assert_failure response
assert_equal 'This transaction cannot be processed.', response.message
@@ -351,6 +367,97 @@ def successful_purchase_response
XML
end
+ def successful_check_purchase_response
+ MockResponse.succeeded <<-XML
+
+ false
+ 2019-01-06T18:24:33Z
+ 2019-01-06T18:24:33Z
+ true
+ succeeded
+ ZwnfZs3Qy4gRDPWXHopamNuarCJ
+ Purchase
+
+
+
+
+
+
+
+
+
+ 49
+ 0
+ 100
+ USD
+ false
+ true
+ Succeeded!
+ 3gLeg4726V5P0HK7cq7QzHsL0a6
+ test
+
+
+
+
+
+
+
+
+
+
+
+ true
+ Successful purchase
+
+
+
+
+ false
+ false
+
+
+ false
+
+ 2019-01-06T18:24:33Z
+ 2019-01-06T18:24:33Z
+
+
+
+
+ HtCrYfW17wEzWWfrMbwDX4TwPVW
+ 2019-01-06T18:24:33Z
+ 2019-01-06T18:24:33Z
+
+
+ cached
+ true
+
+ Jim Smith
+
+ checking
+ personal
+ 021
+ 3210
+ Jim
+ Smith
+
+
+
+
+
+
+
+
+ bank_account
+
+
+ 021*
+ *3210
+
+
+ XML
+ end
+
def failed_purchase_response
MockResponse.failed <<-XML
From 1c06389e8d4989f01459112a29c5e284ae23a735 Mon Sep 17 00:00:00 2001
From: David Perry
Date: Wed, 19 Jun 2019 14:22:02 -0400
Subject: [PATCH 0361/2234] BPoint: Hook up merchant_reference and CRN fields
These fields were already implemented in the request structure but did
not actually get anything passed to them from options.
Closes #3249
Unit:
18 tests, 59 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote: No current test credentials, fairly confident the changes are
safe given that the fields are already present in requests, just without
a value.
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/bpoint.rb | 8 ++++----
test/remote/gateways/remote_bpoint_test.rb | 6 ++++++
test/unit/gateways/bpoint_test.rb | 9 +++++++++
4 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 4149ce4dec7..67375bdc8e2 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -15,6 +15,7 @@
* Checkout V2: Update stored card flag [curiousepic] #3247
* NMI: Add support for stored credentials [bayprogrammer] #3243
* Spreedly: Consolidate API requests and support bank accounts [lancecarlson] #3105
+* BPoint: Hook up merchant_reference and CRN fields [curiousepic] #3249
== Version 1.95.0 (May 23, 2019)
* Adyen: Constantize version to fix subdomains [curiousepic] #3228
diff --git a/lib/active_merchant/billing/gateways/bpoint.rb b/lib/active_merchant/billing/gateways/bpoint.rb
index dc48ffa47a1..320e024a03b 100644
--- a/lib/active_merchant/billing/gateways/bpoint.rb
+++ b/lib/active_merchant/billing/gateways/bpoint.rb
@@ -163,10 +163,10 @@ def payment_xml(xml, payment_type, amount, options)
xml.send('PaymentType', payment_type)
xml.send('TxnType', 'WEB_SHOP')
xml.send('BillerCode', options.fetch(:biller_code, ''))
- xml.send('MerchantReference', '')
- xml.send('CRN1', '')
- xml.send('CRN2', '')
- xml.send('CRN3', '')
+ xml.send('MerchantReference', options[:order_id]) if options[:order_id]
+ xml.send('CRN1', options[:crn1]) if options[:crn1]
+ xml.send('CRN2', options[:crn2]) if options[:crn2]
+ xml.send('CRN3', options[:crn3]) if options[:crn3]
xml.send('Amount', amount)
end
diff --git a/test/remote/gateways/remote_bpoint_test.rb b/test/remote/gateways/remote_bpoint_test.rb
index 32f0124e787..c2ba913c86c 100644
--- a/test/remote/gateways/remote_bpoint_test.rb
+++ b/test/remote/gateways/remote_bpoint_test.rb
@@ -40,6 +40,12 @@ def test_successful_purchase
assert_equal 'Approved', response.message
end
+ def test_successful_purchase_with_more_options
+ response = @gateway.purchase(@amount, @credit_card, @options.merge({ crn1: 'ref'}))
+ assert_success response
+ assert_equal 'Approved', response.message
+ end
+
def test_failed_purchase
response = @gateway.purchase(@amount, @declined_card, @options)
assert_failure response
diff --git a/test/unit/gateways/bpoint_test.rb b/test/unit/gateways/bpoint_test.rb
index 384862ab576..3ee09b8c0e1 100644
--- a/test/unit/gateways/bpoint_test.rb
+++ b/test/unit/gateways/bpoint_test.rb
@@ -130,6 +130,15 @@ def test_passing_biller_code
end.respond_with(successful_authorize_response)
end
+ def test_passing_reference_and_crn
+ stub_comms do
+ @gateway.authorize(@amount, @credit_card, @options.merge({ crn1: 'ref' }))
+ end.check_request do |endpoint, data, headers|
+ assert_match(%r(1)m, data)
+ assert_match(%r(ref)m, data)
+ end.respond_with(successful_authorize_response)
+ end
+
private
def pre_scrubbed
From 9c7663b8041791eded8f35666cd11a2a5c83466e Mon Sep 17 00:00:00 2001
From: Filipe Costa
Date: Sat, 22 Jun 2019 14:50:13 -0400
Subject: [PATCH 0362/2234] Fixes checkout v2 integration (#3248)
* Fixing phone number unwanted chars and COF feature
- Phone number: Checkout.com only accepts digits for phone numbers
- COF feature: the param was being sent on the wrong place
* Stop sending phone number to Checkout V2 integration
---
.../billing/gateways/checkout_v2.rb | 47 +++++++++----------
test/unit/gateways/checkout_v2_test.rb | 2 +-
2 files changed, 24 insertions(+), 25 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/checkout_v2.rb b/lib/active_merchant/billing/gateways/checkout_v2.rb
index c170598262a..4f6ec1eb7e2 100644
--- a/lib/active_merchant/billing/gateways/checkout_v2.rb
+++ b/lib/active_merchant/billing/gateways/checkout_v2.rb
@@ -9,14 +9,14 @@ class CheckoutV2Gateway < Gateway
self.supported_countries = ['AD', 'AE', 'AT', 'BE', 'BG', 'CH', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FO', 'FI', 'FR', 'GB', 'GI', 'GL', 'GR', 'HR', 'HU', 'IE', 'IS', 'IL', 'IT', 'LI', 'LT', 'LU', 'LV', 'MC', 'MT', 'NL', 'NO', 'PL', 'PT', 'RO', 'SE', 'SI', 'SM', 'SK', 'SJ', 'TR', 'VA']
self.default_currency = 'USD'
self.money_format = :cents
- self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :maestro, :discover]
+ self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :maestro, :discover]
- def initialize(options={})
+ def initialize(options = {})
requires!(options, :secret_key)
super
end
- def purchase(amount, payment_method, options={})
+ def purchase(amount, payment_method, options = {})
multi = MultiResponse.run do |r|
r.process { authorize(amount, payment_method, options) }
r.process { capture(amount, r.authorization, options) }
@@ -28,11 +28,11 @@ def purchase(amount, payment_method, options={})
response(:purchase, succeeded, merged_params)
end
- def authorize(amount, payment_method, options={})
+ def authorize(amount, payment_method, options = {})
post = {}
post[:capture] = false
add_invoice(post, amount, options)
- add_payment_method(post, payment_method, options)
+ add_payment_method(post, payment_method)
add_customer_data(post, options)
add_transaction_data(post, options)
add_3ds(post, options)
@@ -40,7 +40,7 @@ def authorize(amount, payment_method, options={})
commit(:authorize, post)
end
- def capture(amount, authorization, options={})
+ def capture(amount, authorization, options = {})
post = {}
add_invoice(post, amount, options)
add_customer_data(post, options)
@@ -48,12 +48,12 @@ def capture(amount, authorization, options={})
commit(:capture, post, authorization)
end
- def void(authorization, options={})
+ def void(authorization, _options = {})
post = {}
commit(:void, post, authorization)
end
- def refund(amount, authorization, options={})
+ def refund(amount, authorization, options = {})
post = {}
add_invoice(post, amount, options)
add_customer_data(post, options)
@@ -61,7 +61,7 @@ def refund(amount, authorization, options={})
commit(:refund, post, authorization)
end
- def verify(credit_card, options={})
+ def verify(credit_card, options = {})
MultiResponse.run(:use_first_response) do |r|
r.process { authorize(100, credit_card, options) }
r.process(:ignore_result) { void(r.authorization, options) }
@@ -74,9 +74,9 @@ def supports_scrubbing?
def scrub(transcript)
transcript.
- gsub(%r((Authorization: )[^\\]*)i, '\1[FILTERED]').
- gsub(%r(("number\\":\\")\d+), '\1[FILTERED]').
- gsub(%r(("cvv\\":\\")\d+), '\1[FILTERED]')
+ gsub(/(Authorization: )[^\\]*/i, '\1[FILTERED]').
+ gsub(/("number\\":\\")\d+/, '\1[FILTERED]').
+ gsub(/("cvv\\":\\")\d+/, '\1[FILTERED]')
end
private
@@ -94,7 +94,7 @@ def add_invoice(post, money, options)
post[:metadata][:udf5] = application_id || 'ActiveMerchant'
end
- def add_payment_method(post, payment_method, options)
+ def add_payment_method(post, payment_method)
post[:source] = {}
post[:source][:type] = 'card'
post[:source][:name] = payment_method.name
@@ -102,7 +102,6 @@ def add_payment_method(post, payment_method, options)
post[:source][:cvv] = payment_method.verification_value
post[:source][:expiry_year] = format(payment_method.year, :four_digits)
post[:source][:expiry_month] = format(payment_method.month, :two_digits)
- post[:source][:stored] = 'true' if options[:card_on_file] == true
end
def add_customer_data(post, options)
@@ -110,7 +109,7 @@ def add_customer_data(post, options)
post[:customer][:email] = options[:email] || nil
post[:payment_ip] = options[:ip] if options[:ip]
address = options[:billing_address]
- if(address && post[:source])
+ if address && post[:source]
post[:source][:billing_address] = {}
post[:source][:billing_address][:address_line1] = address[:address1] unless address[:address1].blank?
post[:source][:billing_address][:address_line2] = address[:address2] unless address[:address2].blank?
@@ -118,11 +117,11 @@ def add_customer_data(post, options)
post[:source][:billing_address][:state] = address[:state] unless address[:state].blank?
post[:source][:billing_address][:country] = address[:country] unless address[:country].blank?
post[:source][:billing_address][:zip] = address[:zip] unless address[:zip].blank?
- post[:source][:phone] = { number: address[:phone] } unless address[:phone].blank?
end
end
- def add_transaction_data(post, options={})
+ def add_transaction_data(post, options = {})
+ post[:card_on_file] = true if options[:card_on_file] == true
post[:payment_type] = 'Regular' if options[:transaction_indicator] == 1
post[:payment_type] = 'Recurring' if options[:transaction_indicator] == 2
post[:previous_payment_id] = options[:previous_charge_id] if options[:previous_charge_id]
@@ -132,9 +131,9 @@ def add_3ds(post, options)
if options[:three_d_secure]
post[:'3ds'] = {}
post[:'3ds'][:enabled] = true
- post[:'3ds'][:eci] = options[:eci] if options[:eci]
- post[:'3ds'][:cryptogram] = options[:cavv] if options[:cavv]
- post[:'3ds'][:xid] = options[:xid] if options[:xid]
+ post[:'3ds'][:eci] = options[:eci] if options[:eci]
+ post[:'3ds'][:cryptogram] = options[:cavv] if options[:cavv]
+ post[:'3ds'][:xid] = options[:xid] if options[:xid]
end
end
@@ -146,7 +145,7 @@ def commit(action, post, authorization = nil)
response['id'] = response['_links']['payment']['href'].split('/')[-1]
end
rescue ResponseError => e
- raise unless(e.response.code.to_s =~ /4\d\d/)
+ raise unless e.response.code.to_s =~ /4\d\d/
response = parse(e.response.body)
end
@@ -175,11 +174,11 @@ def response(action, succeeded, response)
def headers
{
'Authorization' => @options[:secret_key],
- 'Content-Type' => 'application/json;charset=UTF-8'
+ 'Content-Type' => 'application/json;charset=UTF-8',
}
end
- def url(post, action, authorization)
+ def url(_post, action, authorization)
if action == :authorize
"#{base_url}/payments"
elsif action == :capture
@@ -248,7 +247,7 @@ def authorization_from(raw)
def error_code_from(succeeded, response)
return if succeeded
if response['error_type'] && response['error_codes']
- "#{response["error_type"]}: #{response["error_codes"].join(", ")}"
+ "#{response['error_type']}: #{response['error_codes'].join(', ')}"
elsif response['error_type']
response['error_type']
else
diff --git a/test/unit/gateways/checkout_v2_test.rb b/test/unit/gateways/checkout_v2_test.rb
index 83cca231ecb..0c9701ac164 100644
--- a/test/unit/gateways/checkout_v2_test.rb
+++ b/test/unit/gateways/checkout_v2_test.rb
@@ -102,7 +102,7 @@ def test_successful_authorize_and_capture_with_additional_options
}
@gateway.authorize(@amount, @credit_card, options)
end.check_request do |endpoint, data, headers|
- assert_match(%r{"stored":"true"}, data)
+ assert_match(%r{"card_on_file":true}, data)
assert_match(%r{"payment_type":"Recurring"}, data)
assert_match(%r{"previous_payment_id":"pay_123"}, data)
end.respond_with(successful_authorize_response)
From 0bf63dd1b1e3a0db4e8ccada1cd34975dd596a02 Mon Sep 17 00:00:00 2001
From: britth
Date: Tue, 25 Jun 2019 12:43:11 -0400
Subject: [PATCH 0363/2234] Barclaycard Smartpay: 3DS2 Support
This preps Barclaycard Smartpay for 3DS2 integration. The api version
is bumped up to 40 to get relevant 3DS2 functionality, and additional
browser_info is captured. The parse method is also updated so that it
can return a nested hash with an additionalData field for 3DS2.
Unit:
28 tests, 142 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
34 tests, 76 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
97.0588% passed
(failed `test_successful_third_party_payout` - unrelated invalid credentials error)
Closes #3251
---
CHANGELOG | 1 +
.../billing/gateways/barclaycard_smartpay.rb | 49 +++++++++++++++----
.../remote_barclaycard_smartpay_test.rb | 34 +++++++++++++
.../gateways/barclaycard_smartpay_test.rb | 40 +++++++++++++++
4 files changed, 114 insertions(+), 10 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 67375bdc8e2..75430dfff80 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -16,6 +16,7 @@
* NMI: Add support for stored credentials [bayprogrammer] #3243
* Spreedly: Consolidate API requests and support bank accounts [lancecarlson] #3105
* BPoint: Hook up merchant_reference and CRN fields [curiousepic] #3249
+* Barclaycard Smartpay: Add support for 3DS2 [britth] #3251
== Version 1.95.0 (May 23, 2019)
* Adyen: Constantize version to fix subdomains [curiousepic] #3228
diff --git a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb
index 84a59f82081..6daa08d98ce 100644
--- a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb
+++ b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb
@@ -13,7 +13,7 @@ class BarclaycardSmartpayGateway < Gateway
self.homepage_url = 'https://www.barclaycardsmartpay.com/'
self.display_name = 'Barclaycard Smartpay'
- API_VERSION = 'v30'
+ API_VERSION = 'v40'
def initialize(options = {})
requires!(options, :company, :merchant, :password)
@@ -37,7 +37,7 @@ def authorize(money, creditcard, options = {})
post[:card] = credit_card_hash(creditcard)
post[:billingAddress] = billing_address_hash(options) if options[:billing_address]
post[:deliveryAddress] = shipping_address_hash(options) if options[:shipping_address]
- add_3ds(post, options) if options[:execute_threed]
+ add_3ds(post, options)
commit('authorise', post)
end
@@ -186,7 +186,7 @@ def authorization_from(parameters, response)
end
def parse_avs_code(response)
- AVS_MAPPING[response['avsResult'][0..1].strip] if response['avsResult']
+ AVS_MAPPING[response['additionalData']['avsResult'][0..1].strip] if response.dig('additionalData', 'avsResult')
end
def flatten_hash(hash, prefix = nil)
@@ -210,12 +210,18 @@ def headers(account, password)
end
def parse(response)
- Hash[
- response.split('&').map do |x|
- key, val = x.split('=', 2)
- [key.split('.').last, CGI.unescape(val)]
+ parsed_response = {}
+ params = CGI.parse(response)
+ params.each do |key, value|
+ parsed_key = key.split('.', 2)
+ if parsed_key.size > 1
+ parsed_response[parsed_key[0]] ||= {}
+ parsed_response[parsed_key[0]][parsed_key[1]] = value[0]
+ else
+ parsed_response[parsed_key[0]] = value[0]
end
- ]
+ end
+ parsed_response
end
def post_data(data)
@@ -343,8 +349,31 @@ def store_request(options)
end
def add_3ds(post, options)
- post[:additionalData] = { executeThreeD: 'true' }
- post[:browserInfo] = { userAgent: options[:user_agent], acceptHeader: options[:accept_header] }
+ if three_ds_2_options = options[:three_ds_2]
+ if browser_info = three_ds_2_options[:browser_info]
+ post[:browserInfo] = {
+ acceptHeader: browser_info[:accept_header],
+ colorDepth: browser_info[:depth],
+ javaEnabled: browser_info[:java],
+ language: browser_info[:language],
+ screenHeight: browser_info[:height],
+ screenWidth: browser_info[:width],
+ timeZoneOffset: browser_info[:timezone],
+ userAgent: browser_info[:user_agent]
+ }
+
+ if device_channel = three_ds_2_options[:channel]
+ post[:threeDS2RequestData] = {
+ deviceChannel: device_channel,
+ notificationURL: three_ds_2_options[:notification_url]
+ }
+ end
+ end
+ else
+ return unless options[:execute_threed] || options[:threed_dynamic]
+ post[:browserInfo] = { userAgent: options[:user_agent], acceptHeader: options[:accept_header] }
+ post[:additionalData] = { executeThreeD: 'true' } if options[:execute_threed]
+ end
end
end
end
diff --git a/test/remote/gateways/remote_barclaycard_smartpay_test.rb b/test/remote/gateways/remote_barclaycard_smartpay_test.rb
index 1f0444d6a08..76339217d63 100644
--- a/test/remote/gateways/remote_barclaycard_smartpay_test.rb
+++ b/test/remote/gateways/remote_barclaycard_smartpay_test.rb
@@ -112,6 +112,30 @@ def setup
zip: '95014',
country: 'US'
})
+
+ @normalized_3ds_2_options = {
+ reference: '345123',
+ shopper_email: 'john.smith@test.com',
+ shopper_ip: '77.110.174.153',
+ shopper_reference: 'John Smith',
+ billing_address: address(),
+ order_id: '123',
+ stored_credential: {reason_type: 'unscheduled'},
+ three_ds_2: {
+ channel: 'browser',
+ browser_info: {
+ accept_header: 'unknown',
+ depth: 100,
+ java: false,
+ language: 'US',
+ height: 1000,
+ width: 500,
+ timezone: '-120',
+ user_agent: 'unknown'
+ },
+ notification_url: 'https://example.com/notification'
+ }
+ }
end
def teardown
@@ -176,6 +200,16 @@ def test_successful_authorize_with_3ds
refute response.params['paRequest'].blank?
end
+ def test_successful_authorize_with_3ds2_browser_client_data
+ assert response = @gateway.authorize(@amount, @three_ds_enrolled_card, @normalized_3ds_2_options)
+ assert response.test?
+ refute response.authorization.blank?
+ assert_equal response.params['resultCode'], 'IdentifyShopper'
+ refute response.params['additionalData']['threeds2.threeDS2Token'].blank?
+ refute response.params['additionalData']['threeds2.threeDSServerTransID'].blank?
+ refute response.params['additionalData']['threeds2.threeDSMethodURL'].blank?
+ end
+
def test_successful_authorize_and_capture
auth = @gateway.authorize(@amount, @credit_card, @options)
assert_success auth
diff --git a/test/unit/gateways/barclaycard_smartpay_test.rb b/test/unit/gateways/barclaycard_smartpay_test.rb
index 2bb8443b85d..ae38e80bd92 100644
--- a/test/unit/gateways/barclaycard_smartpay_test.rb
+++ b/test/unit/gateways/barclaycard_smartpay_test.rb
@@ -100,6 +100,30 @@ def setup
zip: '95014',
country: 'US'
})
+
+ @normalized_3ds_2_options = {
+ reference: '345123',
+ shopper_email: 'john.smith@test.com',
+ shopper_ip: '77.110.174.153',
+ shopper_reference: 'John Smith',
+ billing_address: address(),
+ order_id: '123',
+ stored_credential: {reason_type: 'unscheduled'},
+ three_ds_2: {
+ channel: 'browser',
+ browser_info: {
+ accept_header: 'unknown',
+ depth: 100,
+ java: false,
+ language: 'US',
+ height: 1000,
+ width: 500,
+ timezone: '-120',
+ user_agent: 'unknown'
+ },
+ notification_url: 'https://example.com/notification'
+ }
+ }
end
def test_successful_purchase
@@ -189,6 +213,18 @@ def test_successful_authorize_with_3ds
assert response.test?
end
+ def test_successful_authorize_with_3ds2_browser_client_data
+ @gateway.stubs(:ssl_post).returns(successful_authorize_with_3ds2_response)
+
+ assert response = @gateway.authorize(@amount, @three_ds_enrolled_card, @normalized_3ds_2_options)
+ assert response.test?
+ assert_equal '8815609737078177', response.authorization
+ assert_equal response.params['resultCode'], 'IdentifyShopper'
+ refute response.params['additionalData']['threeds2.threeDS2Token'].blank?
+ refute response.params['additionalData']['threeds2.threeDSServerTransID'].blank?
+ refute response.params['additionalData']['threeds2.threeDSMethodURL'].blank?
+ end
+
def test_failed_authorize
@gateway.stubs(:ssl_post).returns(failed_authorize_response)
@@ -395,6 +431,10 @@ def successful_authorize_with_3ds_response
'pspReference=8815161318854998&resultCode=RedirectShopper&issuerUrl=https%3A%2F%2Ftest.adyen.com%2Fhpp%2F3d%2Fvalidate.shtml&md=WIFa2sF3CuPyN53Txjt3U%2F%2BDuCsddzywiY5NLgEAdUAXPksHUzXL5E%2BsfvdpolkGWR8b1oh%2FNA3jNaUP9UCgfjhXqRslGFy9OGqcZ1ITMz54HHm%2FlsCKN9bTftKnYA4F7GqvOgcIIrinUZjbMvW9doGifwzSqYLo6ASOm6bARL5n7cIFV8IWtA2yPlO%2FztKSTRJt1glN4s8sMcpE57z4soWKMuycbdXdpp6d4ZRSa%2F1TPF0MnJF0zNaSAAkw9JpXqGMOz5sFF2Smpc38HXJzM%2FV%2B1mmoDhhWmXXOb5YQ0QSCS7DXKIcr8ZtuGuGmFp0QOfZiO41%2B2I2N7VhONVx8xSn%2BLu4m6vaDIg5qsnd9saxaWwbJpl9okKm6pB2MJap9ScuBCcvI496BPCrjQ2LHxvDWhk6M3Exemtv942NQIGlsiPaW0KXoC2dQvBsxWh0K&paRequest=eNpVUtuOgjAQ%2FRXj%2B1KKoIWMTVgxWR%2B8RNkPaMpEycrFUlb8%2B20B190%2BnXPm0pnTQnpRiMkJZauQwxabRpxxkmfLacQYDeiczihjgR%2BGbMrhEB%2FxxuEbVZNXJaeO63hAntSUK3kRpeYg5O19s%2BPUm%2FnBHMhIoUC1SXiKjT4URSxvba5QARlkKEWB%2FFSbgbLr41QIpXFVFUB6HWTVllo9OPNMwyeBVl35Reu6iQi53%2B9OM5Y7sipMVqmF1G9tA8QmAnlNeGgtakzjLs%2F4Pjl3u3TtbdNtZzDdJV%2FBPu7PEojNgExo5J5LmUvpfELDyPcjPwDS6yAKOxFffx4nxhXXrDwIUNt74oFQG%2FgrgLFdYSkfPFwws9WTAXZ1VaLJMPb%2BYiCvoVcf1mSpjW%2B%2BN9i8YKFr0MLa3Qdsl9yYREM37NtYAsSWkvElyfjiBv37CT9ySbE1'
end
+ def successful_authorize_with_3ds2_response
+ 'additionalData.threeds2.threeDS2Token=BQABAQB9sBAzFS%2BrvT1fuY78N4P5BA5DO6s9Y6jCIzvMcH%2Bk5%2B0ms8dRPEZZhO8CYx%2Fa5NCl8r4vyJj0nI0HZ9CBl%2FQLxtGLYfVu6sNxZc9xZry%2Bm24pBGTtHsd4vunorPNPAGlYWHBXtf4h0Sj9Qy0bzlau7a%2Feayi1cpjbfV%2B8Eqw%2FAod1B80heU8sX2DKm5SHlR4o0qTu0WQUSJfKRxjdJ1AntgAxjYo3uFUlU%2FyhNpdRiAxgauLImbllfQTGVTcYBQXsY9FSakfAZRW1kT7bNMraCvRUpp4o1Z5ZezJxPcksfCEzFVPyJYcTvcV4odQK4tT6imRLRvG1OgUVNzNAuDBnEJtFOC%2BE5YwAwfKuloCqB9oAAOzL5ZHXOXPASY2ehJ3RaCZjqj5vmAX8L9GY35FV8q49skYZpzIvlMICWjErI2ayKMCiXHFDE54f2GJEhVRKpY9s506740UGQc0%2FMgbKyLyqtU%2BRG30BwA9bSt3NQKchm9xoOL7U%2Bzm6OIeikmw94TBq%2BmBN7SdQi%2BK2W4yfMkqFsl7hc7HHBa%2BOc6At7wxxdxCLg6wksQmDxElXeQfFkWvoBuR96fIHaXILnVHKjWcTbeulXBhVPA5Y47MLEtZL3G8k%2BzKTFUCW7O0MN2WxUoMBT8foan1%2B9QhZejEqiamreIs56PLQkJvhigyRQmiqwnVjXiFOv%2FEcWn0Z6IM2TnAfw3Kd2KwZ9JaePLtZ2Ck7%2FUEsdt1Kj2HYeE86WM4PESystER5oBT12xWXvbp8CEA7Mulmpd3bkiMl5IVRoSBL5pl4qZd1CrnG%2FeuvtXYTsN%2FdA%2BIcWwiLiXpmSwqaRB8DfChwouuNMAAkfKhQ6b3vLAToc3o%2B3Xa1QetsK8GI1pmjkoZRvLd2xfGhVe%2FmCl23wzQsAicwB9ZXXMgWbaS2OwdwsISQGOmsWrajzp7%2FvR0T4aHqJlrFvKnc9BrWEWbDi8g%2BDFZ2E2ifhFYSYhrHVA7yOIIDdTQnH3CIzaevxUAnbIyFsxrhy8USdP6R6CdJZ%2Bg0rIJ5%2FeZ5P8JjDiYJWi5FDJwy%2BNP9PQIFFim6psbELCtnAaW1m7pU1FeNwjYUGIdVD2f%2BVYJe4cWHPCaWAAsARNXTzjrfUEq%2BpEYDcs%2FLyTB8f69qSrmTSDGsCETsNNy27LY%2BtodGDKsxtW35jIqoV8l2Dra3wucman8nIZp3VTNtNvZDCqWetLXxBbFVZN6ecuoMPwhER5MBFUrkkXCSSFBK%2FNGp%2FXaEDP6A2hmUKvXikL3F9S7MIKQCUYC%2FI7K4DFYFBjTBzN4%3D&additionalData.threeds2.threeDSServerTransID=efbf9d05-5e6b-4659-a64e-f1dfa5d846c4&additionalData.threeds2.threeDSMethodURL=https%3A%2F%2Fpal-test.adyen.com%2Fthreeds2simulator%2Facs%2FstartMethod.shtml&pspReference=8815609737078177&resultCode=IdentifyShopper'
+ end
+
def failed_authorize_response
'pspReference=7914002630895750&refusalReason=Refused&resultCode=Refused'
end
From bcd95f14ede74d4c2d3a948ec7216a85f8eb6859 Mon Sep 17 00:00:00 2001
From: molbrown
Date: Tue, 25 Jun 2019 12:06:58 -0400
Subject: [PATCH 0364/2234] Adyen: Add support for non-fractional currencies
Adds localized_amount to determine amount, to allow correct handling of
non-fractional currencies.
Includes a what_amount method which will protect customers already transacting on
Adyen from a sudden change in their transaction amounts. what_amount
will be removed after coordinating.
ECS-420
Unit:
40 tests, 191 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
60 tests, 187 assertions, 4 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
93.3333% passed
Failures due to error message change, unrelated
Closes #3257
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/adyen.rb | 25 ++++++++++++++++---
test/unit/gateways/adyen_test.rb | 22 ++++++++++++++++
3 files changed, 44 insertions(+), 4 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 75430dfff80..2a29fa46415 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -17,6 +17,7 @@
* Spreedly: Consolidate API requests and support bank accounts [lancecarlson] #3105
* BPoint: Hook up merchant_reference and CRN fields [curiousepic] #3249
* Barclaycard Smartpay: Add support for 3DS2 [britth] #3251
+* Adyen: Add support for non-fractional currencies [molbrown] #3257
== Version 1.95.0 (May 23, 2019)
* Adyen: Constantize version to fix subdomains [curiousepic] #3228
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index 16faf16ddee..93f4560ceaa 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -9,6 +9,7 @@ class AdyenGateway < Gateway
self.supported_countries = ['AT', 'AU', 'BE', 'BG', 'BR', 'CH', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GB', 'GI', 'GR', 'HK', 'HU', 'IE', 'IS', 'IT', 'LI', 'LT', 'LU', 'LV', 'MC', 'MT', 'MX', 'NL', 'NO', 'PL', 'PT', 'RO', 'SE', 'SG', 'SK', 'SI', 'US']
self.default_currency = 'USD'
+ self.currencies_without_fractions = %w(CVE DJF GNF IDR JPY KMF KRW PYG RWF UGX VND VUV XAF XOF XPF)
self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :jcb, :dankort, :maestro, :discover, :elo]
self.money_format = :cents
@@ -237,21 +238,37 @@ def add_address(post, options)
end
def add_invoice(post, money, options)
+ currency = options[:currency] || currency(money)
+ money = calculate_amount(money, options)
amount = {
- value: amount(money),
- currency: options[:currency] || currency(money)
+ value: localized_amount(money, currency),
+ currency: currency
}
post[:amount] = amount
end
def add_invoice_for_modification(post, money, options)
+ currency = options[:currency] || currency(money)
+ money = calculate_amount(money, options)
amount = {
- value: amount(money),
- currency: options[:currency] || currency(money)
+ value: localized_amount(money, currency),
+ currency: currency
}
post[:modificationAmount] = amount
end
+ # temporary method in place to support Spreedly customers switching
+ # over to sending multiplied amounts for non-fractional currency transactions,
+ # as now required for localized_amount. To avoid amount manipulation, send
+ # opt_out_multiply_amount with any non-fractional currency transaction.
+ def calculate_amount(money, options)
+ currency = options[:currency] || currency(money)
+ if non_fractional_currency?(currency)
+ money *=100 unless options[:opt_out_multiply_amount]
+ end
+ money
+ end
+
def add_payment(post, payment)
if payment.is_a?(String)
_, _, recurring_detail_reference = payment.split('#')
diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb
index c0521889560..664a7e88edb 100644
--- a/test/unit/gateways/adyen_test.rb
+++ b/test/unit/gateways/adyen_test.rb
@@ -271,6 +271,28 @@ def test_successful_initial_authorize_with_normalized_stored_credentials
end.respond_with(successful_authorize_response)
end
+ def test_nonfractional_currency_handling_with_amount_modification
+ stub_comms do
+ @gateway.authorize(1, @credit_card, @options.merge(currency: 'JPY'))
+ end.check_request do |endpoint, data, headers|
+ assert_match(/"amount\":{\"value\":\"1\",\"currency\":\"JPY\"}/, data)
+ end.respond_with(successful_authorize_response)
+ end
+
+ def test_nonfractional_currency_handling_without_amount_modification
+ stub_comms do
+ @gateway.authorize(200, @credit_card, @options.merge(currency: 'JPY', opt_out_multiply_amount: true))
+ end.check_request do |endpoint, data, headers|
+ assert_match(/"amount\":{\"value\":\"2\",\"currency\":\"JPY\"}/, data)
+ end.respond_with(successful_authorize_response)
+
+ stub_comms do
+ @gateway.authorize(200, @credit_card, @options.merge(currency: 'CLP'))
+ end.check_request do |endpoint, data, headers|
+ assert_match(/"amount\":{\"value\":\"200\",\"currency\":\"CLP\"}/, data)
+ end.respond_with(successful_authorize_response)
+ end
+
def test_failed_purchase
@gateway.expects(:ssl_post).returns(failed_purchase_response)
From fc2f9478187388952893b70f07d635641b3398d1 Mon Sep 17 00:00:00 2001
From: Jared Knipp
Date: Fri, 7 Jun 2019 11:59:15 -0500
Subject: [PATCH 0365/2234] Decidir: Add new gateway
Add support for the Decidir gateway. This implementation sends card data
inline with purchase and authorize requests rather than creating payment
method tokens.
ECS-374
Unit:
22 tests, 112 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
17 tests, 60 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
closes #3254
---
CHANGELOG | 1 +
.../billing/gateways/decidir.rb | 232 +++++++++++
test/fixtures.yml | 8 +
test/remote/gateways/remote_decidir_test.rb | 168 ++++++++
test/unit/gateways/decidir_test.rb | 371 ++++++++++++++++++
5 files changed, 780 insertions(+)
create mode 100644 lib/active_merchant/billing/gateways/decidir.rb
create mode 100644 test/remote/gateways/remote_decidir_test.rb
create mode 100644 test/unit/gateways/decidir_test.rb
diff --git a/CHANGELOG b/CHANGELOG
index 2a29fa46415..7a492fae371 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -18,6 +18,7 @@
* BPoint: Hook up merchant_reference and CRN fields [curiousepic] #3249
* Barclaycard Smartpay: Add support for 3DS2 [britth] #3251
* Adyen: Add support for non-fractional currencies [molbrown] #3257
+* Decidir: Add new gateway [jknipp] #3254
== Version 1.95.0 (May 23, 2019)
* Adyen: Constantize version to fix subdomains [curiousepic] #3228
diff --git a/lib/active_merchant/billing/gateways/decidir.rb b/lib/active_merchant/billing/gateways/decidir.rb
new file mode 100644
index 00000000000..2b7eed33e89
--- /dev/null
+++ b/lib/active_merchant/billing/gateways/decidir.rb
@@ -0,0 +1,232 @@
+module ActiveMerchant #:nodoc:
+ module Billing #:nodoc:
+ class DecidirGateway < Gateway
+ self.test_url = 'https://developers.decidir.com/api/v2'
+ self.live_url = 'https://live.decidir.com/api/v2'
+
+ self.supported_countries = ['AR']
+ self.money_format = :cents
+ self.default_currency = 'ARS'
+ self.supported_cardtypes = [:visa, :master, :american_express, :diners_club]
+
+ self.homepage_url = 'http://www.decidir.com'
+ self.display_name = 'Decidir'
+
+ STANDARD_ERROR_CODE_MAPPING = {
+ 1 => STANDARD_ERROR_CODE[:call_issuer],
+ 2 => STANDARD_ERROR_CODE[:call_issuer],
+ 3 => STANDARD_ERROR_CODE[:config_error],
+ 4 => STANDARD_ERROR_CODE[:pickup_card],
+ 5 => STANDARD_ERROR_CODE[:card_declined],
+ 7 => STANDARD_ERROR_CODE[:pickup_card],
+ 12 => STANDARD_ERROR_CODE[:processing_error],
+ 14 => STANDARD_ERROR_CODE[:invalid_number],
+ 28 => STANDARD_ERROR_CODE[:processing_error],
+ 38 => STANDARD_ERROR_CODE[:incorrect_pin],
+ 39 => STANDARD_ERROR_CODE[:invalid_number],
+ 43 => STANDARD_ERROR_CODE[:pickup_card],
+ 45 => STANDARD_ERROR_CODE[:card_declined],
+ 46 => STANDARD_ERROR_CODE[:invalid_number],
+ 47 => STANDARD_ERROR_CODE[:card_declined],
+ 48 => STANDARD_ERROR_CODE[:card_declined],
+ 49 => STANDARD_ERROR_CODE[:invalid_expiry_date],
+ 51 => STANDARD_ERROR_CODE[:card_declined],
+ 53 => STANDARD_ERROR_CODE[:card_declined],
+ 54 => STANDARD_ERROR_CODE[:expired_card],
+ 55 => STANDARD_ERROR_CODE[:incorrect_pin],
+ 56 => STANDARD_ERROR_CODE[:card_declined],
+ 57 => STANDARD_ERROR_CODE[:card_declined],
+ 76 => STANDARD_ERROR_CODE[:call_issuer],
+ 96 => STANDARD_ERROR_CODE[:processing_error],
+ 97 => STANDARD_ERROR_CODE[:processing_error],
+ }
+
+ def initialize(options={})
+ requires!(options, :api_key)
+ super
+ @options[:preauth_mode] ||= false
+ end
+
+ def purchase(money, payment, options={})
+ raise ArgumentError, 'Purchase is not supported on Decidir gateways configured with the preauth_mode option' if @options[:preauth_mode]
+
+ post = {}
+ add_auth_purchase_params(post, money, payment, options)
+ commit(:post, 'payments', post)
+ end
+
+ def authorize(money, payment, options={})
+ raise ArgumentError, 'Authorize is not supported on Decidir gateways unless the preauth_mode option is enabled' unless @options[:preauth_mode]
+
+ post = {}
+ add_auth_purchase_params(post, money, payment, options)
+ commit(:post, 'payments', post)
+ end
+
+ def capture(money, authorization, options={})
+ raise ArgumentError, 'Capture is not supported on Decidir gateways unless the preauth_mode option is enabled' unless @options[:preauth_mode]
+
+ post = {}
+ add_amount(post, money, options)
+ commit(:put, "payments/#{authorization}", post)
+ end
+
+ def refund(money, authorization, options={})
+ post = {}
+ add_amount(post, money, options)
+ commit(:post, "payments/#{authorization}/refunds", post)
+ end
+
+ def void(authorization, options={})
+ post = {}
+ commit(:post, "payments/#{authorization}/refunds", post)
+ end
+
+ def verify(credit_card, options={})
+ raise ArgumentError, 'Verify is not supported on Decidir gateways unless the preauth_mode option is enabled' unless @options[:preauth_mode]
+
+ MultiResponse.run(:use_first_response) do |r|
+ r.process { authorize(100, credit_card, options) }
+ r.process(:ignore_result) { void(r.authorization, options) }
+ end
+ end
+
+ def supports_scrubbing?
+ true
+ end
+
+ def scrub(transcript)
+ transcript.
+ gsub(%r((apikey: )\w+)i, '\1[FILTERED]').
+ gsub(%r((\"card_number\\\":\\\")\d+), '\1[FILTERED]').
+ gsub(%r((\"security_code\\\":\\\")\d+), '\1[FILTERED]')
+ end
+
+ private
+
+ def add_auth_purchase_params(post, money, credit_card, options)
+ post[:payment_method_id] = options[:payment_method_id] ? options[:payment_method_id].to_i : 1
+ post[:site_transaction_id] = options[:order_id]
+ post[:bin] = credit_card.number[0..5]
+ post[:payment_type] = options[:payment_type] || 'single'
+ post[:installments] = options[:installments] ? options[:installments].to_i : 1
+ post[:description] = options[:description] if options[:description]
+ post[:email] = options[:email] if options[:email]
+ post[:sub_payments] = []
+
+ add_invoice(post, money, options)
+ add_payment(post, credit_card, options)
+ end
+
+ def add_invoice(post, money, options)
+ add_amount(post, money, options)
+ post[:currency] = (options[:currency] || currency(money))
+ end
+
+ def add_amount(post, money, options)
+ currency = (options[:currency] || currency(money))
+ post[:amount] = localized_amount(money, currency).to_i
+ end
+
+ def add_payment(post, credit_card, options)
+ card_data = {}
+ card_data[:card_number] = credit_card.number
+ card_data[:card_expiration_month] = format(credit_card.month, :two_digits)
+ card_data[:card_expiration_year] = format(credit_card.year, :two_digits)
+ card_data[:security_code] = credit_card.verification_value if credit_card.verification_value?
+ card_data[:card_holder_name] = credit_card.name if credit_card.name
+
+ # additional data used for Visa transactions
+ card_data[:card_holder_door_number] = options[:card_holder_door_number].to_i if options[:card_holder_door_number]
+ card_data[:card_holder_birthday] = options[:card_holder_birthday] if options[:card_holder_birthday]
+
+ card_data[:card_holder_identification] = {}
+ card_data[:card_holder_identification][:type] = options[:card_holder_identification_type] if options[:card_holder_identification_type]
+ card_data[:card_holder_identification][:number] = options[:card_holder_identification_number] if options[:card_holder_identification_number]
+
+ post[:card_data] = card_data
+ end
+
+ def headers(options = {})
+ {
+ 'apikey' => @options[:api_key],
+ 'Content-type' => 'application/json',
+ 'Cache-Control' => 'no-cache'
+ }
+ end
+
+ def commit(method, endpoint, parameters, options={})
+ url = "#{(test? ? test_url : live_url)}/#{endpoint}"
+
+ begin
+ raw_response = ssl_request(method, url, post_data(parameters), headers(options))
+ response = parse(raw_response)
+ rescue ResponseError => e
+ raw_response = e.response.body
+ response = parse(raw_response)
+ end
+
+ success = success_from(response)
+ Response.new(
+ success,
+ message_from(success, response),
+ response,
+ authorization: authorization_from(response),
+ test: test?,
+ error_code: success ? nil : error_code_from(response)
+ )
+ end
+
+ def post_data(parameters = {})
+ parameters.to_json
+ end
+
+ def parse(body)
+ JSON.parse(body)
+ rescue JSON::ParserError
+ {
+ 'message' => "A non-JSON response was received from Decidir where one was expected. The raw response was:\n\n#{body}"
+ }
+ end
+
+ def message_from(success, response)
+ return response['status'] if success
+ return response['message'] if response['message']
+
+ message = nil
+
+ if error = response.dig('status_details', 'error')
+ message = error.dig('reason', 'description')
+ elsif response['error_type']
+ if response['validation_errors']
+ message = response['validation_errors'].map { |errors| "#{errors['code']}: #{errors['param']}" }.join(', ')
+ end
+ message ||= response['error_type']
+ end
+
+ message
+ end
+
+ def success_from(response)
+ response['status'] == 'approved' || response['status'] == 'pre_approved'
+ end
+
+ def authorization_from(response)
+ response['id']
+ end
+
+ def error_code_from(response)
+ error_code = nil
+ if error = response.dig('status_details', 'error')
+ code = error.dig('reason', 'id')
+ error_code = STANDARD_ERROR_CODE_MAPPING[code]
+ error_code ||= error['type']
+ elsif response['error_type']
+ error_code = response['error_type'] if response['validation_errors']
+ end
+
+ error_code || STANDARD_ERROR_CODE[:processing_error]
+ end
+ end
+ end
+end
diff --git a/test/fixtures.yml b/test/fixtures.yml
index c366801fbf0..bc3375fe903 100644
--- a/test/fixtures.yml
+++ b/test/fixtures.yml
@@ -253,6 +253,14 @@ data_cash:
login: X
password: Y
+# Working credentials, no need to replace
+decidir_authorize:
+ api_key: 5a15fbc227224edabdb6f2e8219e8b28
+ preauth_mode: true
+
+decidir_purchase:
+ api_key: 5df6b5764c3f4822aecdc82d56f26b9d
+
# No working test credentials
dibs:
merchant_id: SOMECREDENTIAL
diff --git a/test/remote/gateways/remote_decidir_test.rb b/test/remote/gateways/remote_decidir_test.rb
new file mode 100644
index 00000000000..e5f76ce1686
--- /dev/null
+++ b/test/remote/gateways/remote_decidir_test.rb
@@ -0,0 +1,168 @@
+require 'test_helper'
+
+class RemoteDecidirTest < Test::Unit::TestCase
+ def setup
+ @gateway_for_purchase = DecidirGateway.new(fixtures(:decidir_purchase))
+ @gateway_for_auth = DecidirGateway.new(fixtures(:decidir_authorize))
+
+ @amount = 100
+ @credit_card = credit_card('4507990000004905')
+ @declined_card = credit_card('4000300011112220')
+ @options = {
+ order_id: SecureRandom.uuid,
+ billing_address: address,
+ description: 'Store Purchase'
+ }
+ end
+
+ def test_successful_purchase
+ response = @gateway_for_purchase.purchase(@amount, @credit_card, @options)
+ assert_success response
+ assert_equal 'approved', response.message
+ assert response.authorization
+ end
+
+ def test_successful_purchase_with_more_options
+ options = {
+ ip: '127.0.0.1',
+ email: 'joe@example.com',
+ card_holder_door_number: '1234',
+ card_holder_birthday: '01011980',
+ card_holder_identification_type: 'dni',
+ card_holder_identification_number: '123456',
+ installments: '12'
+ }
+
+ response = @gateway_for_purchase.purchase(@amount, credit_card('4509790112684851'), @options.merge(options))
+ assert_success response
+ assert_equal 'approved', response.message
+ assert response.authorization
+ end
+
+ def test_failed_purchase
+ response = @gateway_for_purchase.purchase(@amount, @declined_card, @options)
+ assert_failure response
+ assert_equal 'TARJETA INVALIDA', response.message
+ assert_match Gateway::STANDARD_ERROR_CODE[:invalid_number], response.error_code
+ end
+
+ def test_failed_purchase_with_invalid_field
+ response = @gateway_for_purchase.purchase(@amount, @declined_card, @options.merge(installments: -1))
+ assert_failure response
+ assert_equal 'invalid_param: installments', response.message
+ assert_match 'invalid_request_error', response.error_code
+ end
+
+ def test_successful_authorize_and_capture
+ auth = @gateway_for_auth.authorize(@amount, @credit_card, @options)
+ assert_success auth
+ assert_equal 'pre_approved', auth.message
+ assert auth.authorization
+
+ assert capture = @gateway_for_auth.capture(@amount, auth.authorization)
+ assert_success capture
+ assert_equal 'approved', capture.message
+ assert capture.authorization
+ end
+
+ def test_failed_authorize
+ response = @gateway_for_auth.authorize(@amount, @declined_card, @options)
+ assert_failure response
+ assert_equal 'TARJETA INVALIDA', response.message
+ assert_match Gateway::STANDARD_ERROR_CODE[:invalid_number], response.error_code
+ end
+
+ def test_failed_partial_capture
+ auth = @gateway_for_auth.authorize(@amount, @credit_card, @options)
+ assert_success auth
+
+ assert capture = @gateway_for_auth.capture(1, auth.authorization)
+ assert_failure capture
+ assert_equal 'amount: Amount out of ranges: 100 - 100', capture.message
+ assert_equal 'invalid_request_error', capture.error_code
+ assert_nil capture.authorization
+ end
+
+ def test_failed_capture
+ response = @gateway_for_auth.capture(@amount, '')
+
+ assert_equal 'not_found_error', response.message
+ assert_match Gateway::STANDARD_ERROR_CODE[:processing_error], response.error_code
+ end
+
+ def test_successful_refund
+ purchase = @gateway_for_purchase.purchase(@amount, @credit_card, @options)
+ assert_success purchase
+
+ assert refund = @gateway_for_purchase.refund(@amount, purchase.authorization)
+ assert_success refund
+ assert_equal 'approved', refund.message
+ assert refund.authorization
+ end
+
+ def test_partial_refund
+ purchase = @gateway_for_purchase.purchase(@amount, @credit_card, @options)
+ assert_success purchase
+
+ assert refund = @gateway_for_purchase.refund(@amount-1, purchase.authorization)
+ assert_success refund
+ assert_equal 'approved', refund.message
+ assert refund.authorization
+ end
+
+ def test_failed_refund
+ response = @gateway_for_purchase.refund(@amount, '')
+ assert_failure response
+ assert_equal 'not_found_error', response.message
+ assert_match Gateway::STANDARD_ERROR_CODE[:processing_error], response.error_code
+ end
+
+ def test_successful_void
+ auth = @gateway_for_auth.authorize(@amount, @credit_card, @options)
+ assert_success auth
+
+ assert void = @gateway_for_auth.void(auth.authorization)
+ assert_success void
+ assert_equal 'approved', void.message
+ assert void.authorization
+ end
+
+ def test_failed_void
+ response = @gateway_for_auth.void('')
+ assert_failure response
+ assert_equal 'not_found_error', response.message
+ assert_match Gateway::STANDARD_ERROR_CODE[:processing_error], response.error_code
+ end
+
+ def test_successful_verify
+ response = @gateway_for_auth.verify(@credit_card, @options)
+ assert_success response
+ assert_match %r{pre_approved}, response.message
+ end
+
+ def test_failed_verify
+ response = @gateway_for_auth.verify(@declined_card, @options)
+ assert_failure response
+ assert_match %r{TARJETA INVALIDA}, response.message
+ end
+
+ def test_invalid_login
+ gateway = DecidirGateway.new(api_key: '')
+
+ response = gateway.purchase(@amount, @credit_card, @options)
+ assert_failure response
+ assert_match %r{Invalid authentication credentials}, response.message
+ end
+
+ def test_transcript_scrubbing
+ transcript = capture_transcript(@gateway_for_purchase) do
+ @gateway_for_purchase.purchase(@amount, @credit_card, @options)
+ end
+ transcript = @gateway_for_purchase.scrub(transcript)
+
+ assert_scrubbed(@credit_card.number, transcript)
+ assert_scrubbed(@credit_card.verification_value, transcript)
+ assert_scrubbed(@gateway_for_purchase.options[:api_key], transcript)
+ end
+
+end
diff --git a/test/unit/gateways/decidir_test.rb b/test/unit/gateways/decidir_test.rb
new file mode 100644
index 00000000000..f9aebae75f5
--- /dev/null
+++ b/test/unit/gateways/decidir_test.rb
@@ -0,0 +1,371 @@
+require 'test_helper'
+
+class DecidirTest < Test::Unit::TestCase
+ include CommStub
+
+ def setup
+ @gateway_for_purchase = DecidirGateway.new(api_key: 'api_key')
+ @gateway_for_auth = DecidirGateway.new(api_key: 'api_key', preauth_mode: true)
+ @credit_card = credit_card
+ @amount = 100
+
+ @options = {
+ order_id: '1',
+ billing_address: address,
+ description: 'Store Purchase'
+ }
+ end
+
+ def test_successful_purchase
+ @gateway_for_purchase.expects(:ssl_request).returns(successful_purchase_response)
+
+ response = @gateway_for_purchase.purchase(@amount, @credit_card, @options)
+ assert_success response
+
+ assert_equal 7719132, response.authorization
+ assert_equal 'approved', response.message
+ assert response.test?
+ end
+
+ def test_successful_purchase_with_options
+ options = {
+ ip: '127.0.0.1',
+ email: 'joe@example.com',
+ card_holder_door_number: '1234',
+ card_holder_birthday: '01011980',
+ card_holder_identification_type: 'dni',
+ card_holder_identification_number: '123456',
+ installments: 12
+ }
+
+ response = stub_comms(@gateway_for_purchase, :ssl_request) do
+ @gateway_for_purchase.purchase(@amount, @credit_card, @options.merge(options))
+ end.check_request do |method, endpoint, data, headers|
+ assert data =~ /card_holder_door_number/, '1234'
+ assert data =~ /card_holder_birthday/, '01011980'
+ assert data =~ /type/, 'dni'
+ assert data =~ /number/, '123456'
+ end.respond_with(successful_purchase_response)
+
+ assert_equal 7719132, response.authorization
+ assert_equal 'approved', response.message
+ assert response.test?
+ end
+
+ def test_failed_purchase
+ @gateway_for_purchase.expects(:ssl_request).returns(failed_purchase_response)
+
+ response = @gateway_for_purchase.purchase(@amount, @credit_card, @options)
+ assert_failure response
+ assert_equal 'TARJETA INVALIDA', response.message
+ assert_match Gateway::STANDARD_ERROR_CODE[:invalid_number], response.error_code
+ end
+
+ def test_failed_purchase_with_invalid_field
+ @gateway_for_purchase.expects(:ssl_request).returns(failed_purchase_with_invalid_field_response)
+
+ response = @gateway_for_purchase.purchase(@amount, @credit_card, @options.merge(installments: -1))
+ assert_failure response
+ assert_equal 'invalid_param: installments', response.message
+ assert_match 'invalid_request_error', response.error_code
+ end
+
+ def test_failed_purchase_with_preauth_mode
+ assert_raise(ArgumentError) do
+ @gateway_for_auth.purchase(@amount, @credit_card, @options)
+ end
+ end
+
+ def test_successful_authorize
+ @gateway_for_auth.expects(:ssl_request).returns(successful_authorize_response)
+
+ response = @gateway_for_auth.authorize(@amount, @credit_card, @options)
+ assert_success response
+
+ assert_equal 7720214, response.authorization
+ assert_equal 'pre_approved', response.message
+ assert response.test?
+ end
+
+ def test_failed_authorize
+ @gateway_for_auth.expects(:ssl_request).returns(failed_authorize_response)
+
+ response = @gateway_for_auth.authorize(@amount, @credit_card, @options)
+ assert_failure response
+
+ assert_equal 7719358, response.authorization
+ assert_equal 'TARJETA INVALIDA', response.message
+ assert response.test?
+ end
+
+ def test_failed_authorize_without_preauth_mode
+ assert_raise(ArgumentError) do
+ @gateway_for_purchase.authorize(@amount, @credit_card, @options)
+ end
+ end
+
+ def test_successful_capture
+ @gateway_for_auth.expects(:ssl_request).returns(successful_capture_response)
+
+ response = @gateway_for_auth.capture(@amount, 7720214)
+ assert_success response
+
+ assert_equal 7720214, response.authorization
+ assert_equal 'approved', response.message
+ assert response.test?
+ end
+
+ def test_failed_partial_capture
+ @gateway_for_auth.expects(:ssl_request).returns(failed_partial_capture_response)
+
+ response = @gateway_for_auth.capture(@amount, '')
+ assert_failure response
+
+ assert_nil response.authorization
+ assert_equal 'amount: Amount out of ranges: 100 - 100', response.message
+ assert_equal 'invalid_request_error', response.error_code
+ assert response.test?
+ end
+
+ def test_failed_capture
+ @gateway_for_auth.expects(:ssl_request).returns(failed_capture_response)
+
+ response = @gateway_for_auth.capture(@amount, '')
+ assert_failure response
+
+ assert_equal '', response.authorization
+ assert_equal 'not_found_error', response.message
+ assert response.test?
+ end
+
+ def test_failed_capture_without_preauth_mode
+ assert_raise(ArgumentError) do
+ @gateway_for_purchase.capture(@amount, @credit_card, @options)
+ end
+ end
+
+ def test_successful_refund
+ @gateway_for_purchase.expects(:ssl_request).returns(successful_refund_response)
+
+ response = @gateway_for_purchase.refund(@amount, 81931, @options)
+ assert_success response
+
+ assert_equal 81931, response.authorization
+ assert_equal 'approved', response.message
+ assert response.test?
+ end
+
+ def test_partial_refund
+ @gateway_for_purchase.expects(:ssl_request).returns(partial_refund_response)
+
+ response = @gateway_for_purchase.refund(@amount-1, 81932, @options)
+ assert_success response
+
+ assert_equal 81932, response.authorization
+ assert_equal 'approved', response.message
+ assert response.test?
+ end
+
+ def test_failed_refund
+ @gateway_for_purchase.expects(:ssl_request).returns(failed_refund_response)
+
+ response = @gateway_for_purchase.refund(@amount, '')
+ assert_failure response
+
+ assert_equal '', response.authorization
+ assert_equal 'not_found_error', response.message
+ assert response.test?
+ end
+
+ def test_successful_void
+ @gateway_for_auth.expects(:ssl_request).returns(successful_void_response)
+
+ response = @gateway_for_auth.void(@amount, '')
+ assert_success response
+
+ assert_equal 82814, response.authorization
+ assert_equal 'approved', response.message
+ assert response.test?
+ end
+
+ def test_failed_void
+ @gateway_for_auth.expects(:ssl_request).returns(failed_void_response)
+
+ response = @gateway_for_auth.void('')
+ assert_failure response
+
+ assert_equal '', response.authorization
+ assert_equal 'not_found_error', response.message
+ assert response.test?
+ end
+
+ def test_successful_verify
+ @gateway_for_auth.expects(:ssl_request).at_most(3).returns(successful_void_response)
+
+ response = @gateway_for_auth.verify(@credit_card, @options)
+ assert_success response
+
+ assert_equal 'approved', response.message
+ assert response.test?
+ end
+
+ def test_successful_verify_with_failed_void
+ @gateway_for_auth.expects(:ssl_request).at_most(3).returns(failed_void_response)
+
+ response = @gateway_for_auth.verify(@credit_card, @options)
+ assert_failure response
+
+ assert_equal 'not_found_error', response.message
+ assert response.test?
+ end
+
+ def test_failed_verify
+ @gateway_for_auth.expects(:ssl_request).at_most(2).returns(failed_authorize_response)
+
+ response = @gateway_for_auth.verify(@credit_card, @options)
+ assert_failure response
+
+ assert_equal 'TARJETA INVALIDA', response.message
+ assert response.test?
+ end
+
+ def test_failed_verify_for_without_preauth_mode
+ assert_raise(ArgumentError) do
+ @gateway_for_purchase.verify(@amount, @credit_card, @options)
+ end
+ end
+
+ def test_scrub
+ assert @gateway_for_purchase.supports_scrubbing?
+ assert_equal @gateway_for_purchase.scrub(pre_scrubbed), post_scrubbed
+ end
+
+ private
+
+ def pre_scrubbed
+ %q(
+ opening connection to developers.decidir.com:443...
+ opened
+ starting SSL for developers.decidir.com:443...
+ SSL established
+ <- "POST /api/v2/payments HTTP/1.1\r\nContent-Type: application/json\r\nApikey: 5df6b5764c3f4822aecdc82d56f26b9d\r\nCache-Control: no-cache\r\nConnection: close\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nHost: developers.decidir.com\r\nContent-Length: 414\r\n\r\n"
+ <- "{\"site_transaction_id\":\"d5972b68-87d5-46fd-8d3d-b2512902b9af\",\"payment_method_id\":1,\"bin\":\"450799\",\"payment_type\":\"single\",\"installments\":1,\"description\":\"Store Purchase\",\"sub_payments\":[],\"amount\":100,\"currency\":\"ARS\",\"card_data\":{\"card_number\":\"4507990000004905\",\"card_expiration_month\":\"09\",\"card_expiration_year\":\"20\",\"security_code\":\"123\",\"card_holder_name\":\"Longbob Longsen\",\"card_holder_identification\":{}}}"
+ -> "HTTP/1.1 201 Created\r\n"
+ -> "Date: Mon, 24 Jun 2019 18:38:42 GMT\r\n"
+ -> "Content-Type: application/json\r\n"
+ -> "Content-Length: 659\r\n"
+ -> "Connection: close\r\n"
+ -> "Access-Control-Allow-Origin: *\r\n"
+ -> "X-Kong-Upstream-Latency: 159\r\n"
+ -> "X-Kong-Proxy-Latency: 0\r\n"
+ -> "Via: kong/0.8.3\r\n"
+ -> "\r\n"
+ reading 659 bytes...
+ -> "{\"id\":7721017,\"site_transaction_id\":\"d5972b68-87d5-46fd-8d3d-b2512902b9af\",\"payment_method_id\":1,\"card_brand\":\"Visa\",\"amount\":100,\"currency\":\"ars\",\"status\":\"approved\",\"status_details\":{\"ticket\":\"7297\",\"card_authorization_code\":\"153842\",\"address_validation_code\":\"VTE0011\",\"error\":null},\"date\":\"2019-06-24T15:38Z\",\"customer\":null,\"bin\":\"450799\",\"installments\":1,\"first_installment_expiration_date\":null,\"payment_type\":\"single\",\"sub_payments\":[],\"site_id\":\"99999999\",\"fraud_detection\":null,\"aggregate_data\":null,\"establishment_name\":null,\"spv\":null,\"confirmed\":null,\"pan\":\"345425f15b2c7c4584e0044357b6394d7e\",\"customer_token\":null,\"card_data\":\"/tokens/7721017\"}"
+ read 659 bytes
+ Conn close
+ )
+ end
+
+ def post_scrubbed
+ %q(
+ opening connection to developers.decidir.com:443...
+ opened
+ starting SSL for developers.decidir.com:443...
+ SSL established
+ <- "POST /api/v2/payments HTTP/1.1\r\nContent-Type: application/json\r\nApikey: [FILTERED]\r\nCache-Control: no-cache\r\nConnection: close\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nHost: developers.decidir.com\r\nContent-Length: 414\r\n\r\n"
+ <- "{\"site_transaction_id\":\"d5972b68-87d5-46fd-8d3d-b2512902b9af\",\"payment_method_id\":1,\"bin\":\"450799\",\"payment_type\":\"single\",\"installments\":1,\"description\":\"Store Purchase\",\"sub_payments\":[],\"amount\":100,\"currency\":\"ARS\",\"card_data\":{\"card_number\":\"[FILTERED]\",\"card_expiration_month\":\"09\",\"card_expiration_year\":\"20\",\"security_code\":\"[FILTERED]\",\"card_holder_name\":\"Longbob Longsen\",\"card_holder_identification\":{}}}"
+ -> "HTTP/1.1 201 Created\r\n"
+ -> "Date: Mon, 24 Jun 2019 18:38:42 GMT\r\n"
+ -> "Content-Type: application/json\r\n"
+ -> "Content-Length: 659\r\n"
+ -> "Connection: close\r\n"
+ -> "Access-Control-Allow-Origin: *\r\n"
+ -> "X-Kong-Upstream-Latency: 159\r\n"
+ -> "X-Kong-Proxy-Latency: 0\r\n"
+ -> "Via: kong/0.8.3\r\n"
+ -> "\r\n"
+ reading 659 bytes...
+ -> "{\"id\":7721017,\"site_transaction_id\":\"d5972b68-87d5-46fd-8d3d-b2512902b9af\",\"payment_method_id\":1,\"card_brand\":\"Visa\",\"amount\":100,\"currency\":\"ars\",\"status\":\"approved\",\"status_details\":{\"ticket\":\"7297\",\"card_authorization_code\":\"153842\",\"address_validation_code\":\"VTE0011\",\"error\":null},\"date\":\"2019-06-24T15:38Z\",\"customer\":null,\"bin\":\"450799\",\"installments\":1,\"first_installment_expiration_date\":null,\"payment_type\":\"single\",\"sub_payments\":[],\"site_id\":\"99999999\",\"fraud_detection\":null,\"aggregate_data\":null,\"establishment_name\":null,\"spv\":null,\"confirmed\":null,\"pan\":\"345425f15b2c7c4584e0044357b6394d7e\",\"customer_token\":null,\"card_data\":\"/tokens/7721017\"}"
+ read 659 bytes
+ Conn close
+ )
+ end
+
+ def successful_purchase_response
+ %(
+ {"id":7719132,"site_transaction_id":"ebcb2db7-7aab-4f33-a7d1-6617a5749fce","payment_method_id":1,"card_brand":"Visa","amount":100,"currency":"ars","status":"approved","status_details":{"ticket":"7156","card_authorization_code":"174838","address_validation_code":"VTE0011","error":null},"date":"2019-06-21T17:48Z","customer":null,"bin":"450799","installments":1,"first_installment_expiration_date":null,"payment_type":"single","sub_payments":[],"site_id":"99999999","fraud_detection":null,"aggregate_data":null,"establishment_name":null,"spv":null,"confirmed":null,"pan":"345425f15b2c7c4584e0044357b6394d7e","customer_token":null,"card_data":"/tokens/7719132"}
+ )
+ end
+
+ def failed_purchase_response
+ %(
+ {"id":7719351,"site_transaction_id":"73e3ed66-37b1-4c97-8f69-f9cb96422383","payment_method_id":1,"card_brand":"Visa","amount":100,"currency":"ars","status":"rejected","status_details":{"ticket":"7162","card_authorization_code":"","address_validation_code":null,"error":{"type":"invalid_number","reason":{"id":14,"description":"TARJETA INVALIDA","additional_description":""}}},"date":"2019-06-21T17:57Z","customer":null,"bin":"400030","installments":1,"first_installment_expiration_date":null,"payment_type":"single","sub_payments":[],"site_id":"99999999","fraud_detection":null,"aggregate_data":null,"establishment_name":null,"spv":null,"confirmed":null,"pan":"11b076fbc8fa6a55783b2f5d03f6938d8a","customer_token":null,"card_data":"/tokens/7719351"}
+ )
+ end
+
+ def failed_purchase_with_invalid_field_response
+ %(
+ {\"error_type\":\"invalid_request_error\",\"validation_errors\":[{\"code\":\"invalid_param\",\"param\":\"installments\"}]} )
+ end
+
+ def successful_authorize_response
+ %(
+ {"id":7720214,"site_transaction_id":"0fcedc95-4fbc-4299-80dc-f77e9dd7f525","payment_method_id":1,"card_brand":"Visa","amount":100,"currency":"ars","status":"pre_approved","status_details":{"ticket":"8187","card_authorization_code":"180548","address_validation_code":"VTE0011","error":null},"date":"2019-06-21T18:05Z","customer":null,"bin":"450799","installments":1,"first_installment_expiration_date":null,"payment_type":"single","sub_payments":[],"site_id":"99999997","fraud_detection":null,"aggregate_data":null,"establishment_name":null,"spv":null,"confirmed":null,"pan":"345425f15b2c7c4584e0044357b6394d7e","customer_token":null,"card_data":"/tokens/7720214"}
+ )
+ end
+
+ def failed_authorize_response
+ %(
+ {"id":7719358,"site_transaction_id":"ff1c12c1-fb6d-4c1a-bc20-2e77d4322c61","payment_method_id":1,"card_brand":"Visa","amount":100,"currency":"ars","status":"rejected","status_details":{"ticket":"8189","card_authorization_code":"","address_validation_code":null,"error":{"type":"invalid_number","reason":{"id":14,"description":"TARJETA INVALIDA","additional_description":""}}},"date":"2019-06-21T18:07Z","customer":null,"bin":"400030","installments":1,"first_installment_expiration_date":null,"payment_type":"single","sub_payments":[],"site_id":"99999997","fraud_detection":null,"aggregate_data":null,"establishment_name":null,"spv":null,"confirmed":null,"pan":"11b076fbc8fa6a55783b2f5d03f6938d8a","customer_token":null,"card_data":"/tokens/7719358"}
+ )
+ end
+
+ def successful_capture_response
+ %(
+ {"id":7720214,"site_transaction_id":"0fcedc95-4fbc-4299-80dc-f77e9dd7f525","payment_method_id":1,"card_brand":"Visa","amount":100,"currency":"ars","status":"approved","status_details":{"ticket":"8187","card_authorization_code":"180548","address_validation_code":"VTE0011","error":null},"date":"2019-06-21T18:05Z","customer":null,"bin":"450799","installments":1,"first_installment_expiration_date":null,"payment_type":"single","sub_payments":[],"site_id":"99999997","fraud_detection":null,"aggregate_data":null,"establishment_name":null,"spv":null,"confirmed":{"id":78436,"origin_amount":100,"date":"2019-06-21T03:00Z"},"pan":"345425f15b2c7c4584e0044357b6394d7e","customer_token":null,"card_data":"/tokens/7720214"}
+ )
+ end
+
+ def failed_partial_capture_response
+ %(
+ {"error_type":"invalid_request_error","validation_errors":[{"code":"amount","param":"Amount out of ranges: 100 - 100"}]}
+ )
+ end
+
+ def failed_capture_response
+ %(
+ {"error_type":"not_found_error","entity_name":"","id":""}
+ )
+ end
+
+ def successful_refund_response
+ %(
+ {"id":81931,"amount":100,"sub_payments":null,"error":null,"status":"approved"}
+ )
+ end
+
+ def partial_refund_response
+ %(
+ {"id":81932,"amount":99,"sub_payments":null,"error":null,"status":"approved"}
+ )
+ end
+
+ def failed_refund_response
+ %(
+ {"error_type":"not_found_error","entity_name":"","id":""}
+ )
+ end
+
+ def successful_void_response
+ %(
+ {"id":82814,"amount":100,"sub_payments":null,"error":null,"status":"approved"}
+ )
+ end
+
+ def failed_void_response
+ %(
+ {"error_type":"not_found_error","entity_name":"","id":""}
+ )
+ end
+end
From 34481c3d3e1873e0cea1d32561e8169560084ff1 Mon Sep 17 00:00:00 2001
From: David Perry
Date: Fri, 14 Jun 2019 15:17:23 -0400
Subject: [PATCH 0366/2234] Checkout V2: Re-apply Update stored card flag
Reapplying this after the change in 9c7663b
Remote:
28 tests, 67 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
22 tests, 99 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/checkout_v2.rb | 6 +++---
test/unit/gateways/checkout_v2_test.rb | 2 +-
3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 7a492fae371..01eea23d831 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -19,6 +19,7 @@
* Barclaycard Smartpay: Add support for 3DS2 [britth] #3251
* Adyen: Add support for non-fractional currencies [molbrown] #3257
* Decidir: Add new gateway [jknipp] #3254
+* Checkout V2: Reapply Update stored card flag [curiousepic]
== Version 1.95.0 (May 23, 2019)
* Adyen: Constantize version to fix subdomains [curiousepic] #3228
diff --git a/lib/active_merchant/billing/gateways/checkout_v2.rb b/lib/active_merchant/billing/gateways/checkout_v2.rb
index 4f6ec1eb7e2..f75348965c2 100644
--- a/lib/active_merchant/billing/gateways/checkout_v2.rb
+++ b/lib/active_merchant/billing/gateways/checkout_v2.rb
@@ -32,7 +32,7 @@ def authorize(amount, payment_method, options = {})
post = {}
post[:capture] = false
add_invoice(post, amount, options)
- add_payment_method(post, payment_method)
+ add_payment_method(post, payment_method, options)
add_customer_data(post, options)
add_transaction_data(post, options)
add_3ds(post, options)
@@ -94,7 +94,7 @@ def add_invoice(post, money, options)
post[:metadata][:udf5] = application_id || 'ActiveMerchant'
end
- def add_payment_method(post, payment_method)
+ def add_payment_method(post, payment_method, options)
post[:source] = {}
post[:source][:type] = 'card'
post[:source][:name] = payment_method.name
@@ -102,6 +102,7 @@ def add_payment_method(post, payment_method)
post[:source][:cvv] = payment_method.verification_value
post[:source][:expiry_year] = format(payment_method.year, :four_digits)
post[:source][:expiry_month] = format(payment_method.month, :two_digits)
+ post[:source][:stored] = 'true' if options[:card_on_file] == true
end
def add_customer_data(post, options)
@@ -121,7 +122,6 @@ def add_customer_data(post, options)
end
def add_transaction_data(post, options = {})
- post[:card_on_file] = true if options[:card_on_file] == true
post[:payment_type] = 'Regular' if options[:transaction_indicator] == 1
post[:payment_type] = 'Recurring' if options[:transaction_indicator] == 2
post[:previous_payment_id] = options[:previous_charge_id] if options[:previous_charge_id]
diff --git a/test/unit/gateways/checkout_v2_test.rb b/test/unit/gateways/checkout_v2_test.rb
index 0c9701ac164..83cca231ecb 100644
--- a/test/unit/gateways/checkout_v2_test.rb
+++ b/test/unit/gateways/checkout_v2_test.rb
@@ -102,7 +102,7 @@ def test_successful_authorize_and_capture_with_additional_options
}
@gateway.authorize(@amount, @credit_card, options)
end.check_request do |endpoint, data, headers|
- assert_match(%r{"card_on_file":true}, data)
+ assert_match(%r{"stored":"true"}, data)
assert_match(%r{"payment_type":"Recurring"}, data)
assert_match(%r{"previous_payment_id":"pay_123"}, data)
end.respond_with(successful_authorize_response)
From 02de05459be52fe7223ead418807469d10abcba5 Mon Sep 17 00:00:00 2001
From: molbrown
Date: Tue, 25 Jun 2019 10:32:07 -0400
Subject: [PATCH 0367/2234] CyberSource: Update supported countries
ECS-408
---
lib/active_merchant/billing/gateways/cyber_source.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb
index 9b65980f240..7d5357c94e0 100644
--- a/lib/active_merchant/billing/gateways/cyber_source.rb
+++ b/lib/active_merchant/billing/gateways/cyber_source.rb
@@ -27,7 +27,7 @@ class CyberSourceGateway < Gateway
XSD_VERSION = '1.153'
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb, :dankort, :maestro, :elo]
- self.supported_countries = %w(US BR CA CN DK FI FR DE IN JP MX NO SE GB SG LB)
+ self.supported_countries = %w(US BR CA CN DK FI FR DE IN JP MX NO SE GB SG LB PK)
self.default_currency = 'USD'
self.currencies_without_fractions = %w(JPY)
From 0ae966796085be0a6073ed3adba98441c1309b21 Mon Sep 17 00:00:00 2001
From: molbrown
Date: Tue, 25 Jun 2019 11:04:53 -0400
Subject: [PATCH 0368/2234] Credorax: Update supported countries
ECS-389
---
lib/active_merchant/billing/gateways/credorax.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/active_merchant/billing/gateways/credorax.rb b/lib/active_merchant/billing/gateways/credorax.rb
index ccc42a508ed..6ecc5ccc644 100644
--- a/lib/active_merchant/billing/gateways/credorax.rb
+++ b/lib/active_merchant/billing/gateways/credorax.rb
@@ -15,7 +15,7 @@ class CredoraxGateway < Gateway
# ActiveMerchant::Billing::CredoraxGateway.live_url = "https://assigned-subdomain.credorax.net/crax_gate/service/gateway"
self.live_url = 'https://assigned-subdomain.credorax.net/crax_gate/service/gateway'
- self.supported_countries = %w(DE GB FR IT ES PL NL BE GR CZ PT SE HU RS AT CH BG DK FI SK NO IE HR BA AL LT MK SI LV EE ME LU MT IS AD MC LI SM)
+ self.supported_countries = %w(AD AT BE BG HR CY CZ DK EE FR DE GI GR GG HU IS IE IM IT JE LV LI LT LU MT MC NO PL PT RO SM SK ES SE CH GB)
self.default_currency = 'EUR'
self.currencies_without_fractions = %w(CLP JPY KRW PYG VND)
self.currencies_with_three_decimal_places = %w(BHD JOD KWD OMR RSD TND)
From fa84bd602e4aaaf06cc37904e4df75afbf50a71e Mon Sep 17 00:00:00 2001
From: molbrown
Date: Thu, 27 Jun 2019 15:40:14 -0400
Subject: [PATCH 0369/2234] Kushki: Update supported countries
ECS-408
---
lib/active_merchant/billing/gateways/kushki.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/active_merchant/billing/gateways/kushki.rb b/lib/active_merchant/billing/gateways/kushki.rb
index c97bd2e6f38..646df52166a 100644
--- a/lib/active_merchant/billing/gateways/kushki.rb
+++ b/lib/active_merchant/billing/gateways/kushki.rb
@@ -7,7 +7,7 @@ class KushkiGateway < Gateway
self.test_url = 'https://api-uat.kushkipagos.com/v1/'
self.live_url = 'https://api.kushkipagos.com/v1/'
- self.supported_countries = ['CO', 'EC']
+ self.supported_countries = ['CL', 'CO', 'EC', 'MX', 'PE']
self.default_currency = 'USD'
self.money_format = :dollars
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club]
From 5bb4e0c94c4f338290e5159a616398d2fed7d488 Mon Sep 17 00:00:00 2001
From: molbrown
Date: Thu, 27 Jun 2019 15:45:09 -0400
Subject: [PATCH 0370/2234] Paypal: Update supported countries
ECS-408
---
lib/active_merchant/billing/gateways/paypal.rb | 2 +-
test/unit/gateways/paypal_test.rb | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/paypal.rb b/lib/active_merchant/billing/gateways/paypal.rb
index 465a0dd2b24..0972125cb7e 100644
--- a/lib/active_merchant/billing/gateways/paypal.rb
+++ b/lib/active_merchant/billing/gateways/paypal.rb
@@ -9,7 +9,7 @@ class PaypalGateway < Gateway
include PaypalRecurringApi
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
- self.supported_countries = ['US']
+ self.supported_countries = ['CA', 'NZ', 'GB', 'US']
self.homepage_url = 'https://www.paypal.com/us/webapps/mpp/paypal-payments-pro'
self.display_name = 'PayPal Payments Pro (US)'
diff --git a/test/unit/gateways/paypal_test.rb b/test/unit/gateways/paypal_test.rb
index a9ae07cbfc4..d63e8797c9c 100644
--- a/test/unit/gateways/paypal_test.rb
+++ b/test/unit/gateways/paypal_test.rb
@@ -219,7 +219,7 @@ def test_ensure_options_are_transferred_to_express_instance
end
def test_supported_countries
- assert_equal ['US'], PaypalGateway.supported_countries
+ assert_equal ['CA', 'NZ', 'GB', 'US'], PaypalGateway.supported_countries
end
def test_supported_card_types
From 8c85f7602dac737ab62245f420767343b930a5ff Mon Sep 17 00:00:00 2001
From: molbrown
Date: Thu, 27 Jun 2019 17:05:04 -0400
Subject: [PATCH 0371/2234] Changelog update for supported countries change.
---
CHANGELOG | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index 01eea23d831..e88d3b53674 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -20,6 +20,10 @@
* Adyen: Add support for non-fractional currencies [molbrown] #3257
* Decidir: Add new gateway [jknipp] #3254
* Checkout V2: Reapply Update stored card flag [curiousepic]
+* CyberSource: Update supported countries [molbrown] #3260
+* Credorax: Update supported countries [molbrown] #3260
+* Kushki: Update supported countries [molbrown] #3260
+* Paypal: Update supported countries [molbrown] #3260
== Version 1.95.0 (May 23, 2019)
* Adyen: Constantize version to fix subdomains [curiousepic] #3228
From a40eb1f0ff390b3f2999fa3eae9a592a4678c623 Mon Sep 17 00:00:00 2001
From: Jared Knipp
Date: Thu, 27 Jun 2019 16:23:24 -0500
Subject: [PATCH 0372/2234] BlueSnap: Send amount in capture requests
ECS-430
Unit:
26 tests, 106 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
35 tests, 109 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
closes #3262
---
CHANGELOG | 2 ++
lib/active_merchant/billing/gateways/blue_snap.rb | 1 +
test/remote/gateways/remote_blue_snap_test.rb | 9 +++++++++
test/unit/gateways/blue_snap_test.rb | 8 ++++++--
4 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index e88d3b53674..cde1f2371eb 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -24,6 +24,8 @@
* Credorax: Update supported countries [molbrown] #3260
* Kushki: Update supported countries [molbrown] #3260
* Paypal: Update supported countries [molbrown] #3260
+* BlueSnap: Send amount in capture requests [jknipp] #3262
+
== Version 1.95.0 (May 23, 2019)
* Adyen: Constantize version to fix subdomains [curiousepic] #3228
diff --git a/lib/active_merchant/billing/gateways/blue_snap.rb b/lib/active_merchant/billing/gateways/blue_snap.rb
index c8c29115c08..e4c2f5b6ea6 100644
--- a/lib/active_merchant/billing/gateways/blue_snap.rb
+++ b/lib/active_merchant/billing/gateways/blue_snap.rb
@@ -95,6 +95,7 @@ def capture(money, authorization, options={})
commit(:capture, :put) do |doc|
add_authorization(doc, authorization)
add_order(doc, options)
+ add_amount(doc, money, options)
end
end
diff --git a/test/remote/gateways/remote_blue_snap_test.rb b/test/remote/gateways/remote_blue_snap_test.rb
index bc5d209509a..e36b3e699cd 100644
--- a/test/remote/gateways/remote_blue_snap_test.rb
+++ b/test/remote/gateways/remote_blue_snap_test.rb
@@ -176,6 +176,15 @@ def test_successful_authorize_and_capture
assert_equal 'Success', capture.message
end
+ def test_successful_authorize_and_partial_capture
+ auth = @gateway.authorize(@amount, @credit_card, @options)
+ assert_success auth
+
+ assert capture = @gateway.capture(@amount - 1, auth.authorization)
+ assert_success capture
+ assert_equal 'Success', capture.message
+ end
+
def test_failed_authorize
response = @gateway.authorize(@amount, @declined_card, @options)
assert_failure response
diff --git a/test/unit/gateways/blue_snap_test.rb b/test/unit/gateways/blue_snap_test.rb
index 9d923d1a225..737c45d11e2 100644
--- a/test/unit/gateways/blue_snap_test.rb
+++ b/test/unit/gateways/blue_snap_test.rb
@@ -91,9 +91,13 @@ def test_failed_authorize
end
def test_successful_capture
- @gateway.expects(:raw_ssl_request).returns(successful_capture_response)
+ response = stub_comms(@gateway, :raw_ssl_request) do
+ @gateway.capture(@amount, @credit_card, @options)
+ end.check_request do |method, url, data|
+ assert_match(/1.00<\/amount>/, data)
+ assert_match(/USD<\/currency>/, data)
+ end.respond_with(successful_capture_response)
- response = @gateway.capture(@amount, 'Authorization')
assert_success response
assert_equal '1012082881', response.authorization
end
From 0a4fe4eff75b8223032a8d7ef5c116db502e213b Mon Sep 17 00:00:00 2001
From: Jason Nappier
Date: Mon, 17 Jun 2019 19:13:26 -0400
Subject: [PATCH 0373/2234] Mundipagg: Add Alelo card support
CE-16
---
CHANGELOG | 2 +-
lib/active_merchant/billing/credit_card.rb | 2 +
.../billing/credit_card_methods.rb | 14 ++
.../billing/gateways/mundipagg.rb | 2 +-
test/remote/gateways/remote_mundipagg_test.rb | 164 +++++++++++++-----
test/unit/credit_card_methods_test.rb | 17 ++
test/unit/gateways/mundipagg_test.rb | 49 +++++-
7 files changed, 203 insertions(+), 47 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index cde1f2371eb..cb942fcc8f5 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -25,7 +25,7 @@
* Kushki: Update supported countries [molbrown] #3260
* Paypal: Update supported countries [molbrown] #3260
* BlueSnap: Send amount in capture requests [jknipp] #3262
-
+* Adds Elo card type in general, and specifically to Mundipagg [jasonxp] #3255
== Version 1.95.0 (May 23, 2019)
* Adyen: Constantize version to fix subdomains [curiousepic] #3228
diff --git a/lib/active_merchant/billing/credit_card.rb b/lib/active_merchant/billing/credit_card.rb
index a14bc726c6a..1a0c097636e 100644
--- a/lib/active_merchant/billing/credit_card.rb
+++ b/lib/active_merchant/billing/credit_card.rb
@@ -19,6 +19,7 @@ module Billing #:nodoc:
# * Maestro
# * Forbrugsforeningen
# * Elo
+ # * Alelo
#
# For testing purposes, use the 'bogus' credit card brand. This skips the vast majority of
# validations, allowing you to focus on your core concerns until you're ready to be more concerned
@@ -90,6 +91,7 @@ def number=(value)
# * +'maestro'+
# * +'forbrugsforeningen'+
# * +'elo'+
+ # * +'alelo'+
#
# Or, if you wish to test your implementation, +'bogus'+.
#
diff --git a/lib/active_merchant/billing/credit_card_methods.rb b/lib/active_merchant/billing/credit_card_methods.rb
index 2e18135062b..355e039fc6c 100644
--- a/lib/active_merchant/billing/credit_card_methods.rb
+++ b/lib/active_merchant/billing/credit_card_methods.rb
@@ -6,6 +6,7 @@ module CreditCardMethods
'visa' => ->(num) { num =~ /^4\d{12}(\d{3})?(\d{3})?$/ },
'master' => ->(num) { num&.size == 16 && in_bin_range?(num.slice(0, 6), MASTERCARD_RANGES) },
'elo' => ->(num) { num&.size == 16 && in_bin_range?(num.slice(0, 6), ELO_RANGES) },
+ 'alelo' => ->(num) { num&.size == 16 && in_bin_range?(num.slice(0, 6), ALELO_RANGES) },
'discover' => ->(num) { num =~ /^(6011|65\d{2}|64[4-9]\d)\d{12,15}|(62\d{14,17})$/ },
'american_express' => ->(num) { num =~ /^3[47]\d{13}$/ },
'diners_club' => ->(num) { num =~ /^3(0[0-5]|[68]\d)\d{11}$/ },
@@ -79,6 +80,19 @@ module CreditCardMethods
651652..651667, 651675..651678, 655000..655010, 655012..655015, 655051..655052, 655056..655057
]
+ # Alelo provides BIN ranges by e-mailing them out periodically.
+ # The BINs beginning with the digit 4 overlap with Visa's range of valid card numbers.
+ # By placing the 'alelo' entry in CARD_COMPANY_DETECTORS below the 'visa' entry, we
+ # identify these cards as Visa. This works because transactions with such cards will
+ # run on Visa rails.
+ ALELO_RANGES = [
+ 402588..402588, 404347..404347, 405876..405876, 405882..405882, 405884..405884,
+ 405886..405886, 430471..430471, 438061..438061, 438064..438064, 470063..470066,
+ 496067..496067, 506699..506704, 506706..506706, 506713..506714, 506716..506716,
+ 506749..506750, 506752..506752, 506754..506756, 506758..506762, 506764..506767,
+ 506770..506771, 509015..509019, 509880..509882, 509884..509885, 509987..509988
+ ]
+
def self.included(base)
base.extend(ClassMethods)
end
diff --git a/lib/active_merchant/billing/gateways/mundipagg.rb b/lib/active_merchant/billing/gateways/mundipagg.rb
index 24b7b6fa46c..e66a6b94680 100644
--- a/lib/active_merchant/billing/gateways/mundipagg.rb
+++ b/lib/active_merchant/billing/gateways/mundipagg.rb
@@ -5,7 +5,7 @@ class MundipaggGateway < Gateway
self.supported_countries = ['US']
self.default_currency = 'USD'
- self.supported_cardtypes = [:visa, :master, :american_express, :discover]
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :alelo]
self.homepage_url = 'https://www.mundipagg.com/'
self.display_name = 'Mundipagg'
diff --git a/test/remote/gateways/remote_mundipagg_test.rb b/test/remote/gateways/remote_mundipagg_test.rb
index b8b4791caf2..e1c16f2cc67 100644
--- a/test/remote/gateways/remote_mundipagg_test.rb
+++ b/test/remote/gateways/remote_mundipagg_test.rb
@@ -8,10 +8,14 @@ def setup
@credit_card = credit_card('4000100011112224')
@declined_card = credit_card('4000300011112220')
@sodexo_voucher = credit_card('6060704495764400', brand: 'sodexo')
+
# Mundipagg only allows certain card numbers for success and failure scenarios.
- # As such, we cannot use a card number with a BIN belonging to VR.
+ # As such, we cannot use card numbers with BINs belonging to VR or Alelo.
# See https://docs.mundipagg.com/docs/simulador-de-voucher.
@vr_voucher = credit_card('4000000000000010', brand: 'vr')
+ @alelo_voucher = credit_card('4000000000000010', brand: 'alelo')
+ @declined_alelo_voucher = credit_card('4000000000000028', brand: 'alelo')
+
@options = {
gateway_affiliation_id: fixtures(:mundipagg)[:gateway_affiliation_id],
billing_address: address({neighborhood: 'Sesame Street'}),
@@ -20,9 +24,11 @@ def setup
end
def test_successful_purchase
- response = @gateway.purchase(@amount, @credit_card, @options)
- assert_success response
- assert_equal 'Simulator|Transação de simulação autorizada com sucesso', response.message
+ test_successful_purchase_with(@credit_card)
+ end
+
+ def test_successful_purchase_with_alelo_card
+ test_successful_purchase_with(@alelo_voucher)
end
def test_successful_purchase_no_address
@@ -59,32 +65,35 @@ def test_successful_purchase_with_vr_voucher
end
def test_failed_purchase
- response = @gateway.purchase(105200, @declined_card, @options)
- assert_failure response
- assert_equal 'Simulator|Transação de simulada negada por falta de crédito, utilizado para realizar simulação de autorização parcial.', response.message
+ test_failed_purchase_with(@declined_card)
+ end
+
+ def test_failed_purchase_with_alelo_card
+ test_failed_purchase_with(@declined_alelo_voucher)
end
def test_successful_authorize_and_capture
- auth = @gateway.authorize(@amount, @credit_card, @options)
- assert_success auth
+ test_successful_authorize_and_capture_with(@credit_card)
+ end
- assert capture = @gateway.capture(@amount, auth.authorization)
- assert_success capture
- assert_equal 'Simulator|Transação de simulação capturada com sucesso', capture.message
+ def test_successful_authorize_and_capture_with_alelo_card
+ test_successful_authorize_and_capture_with(@alelo_voucher)
end
def test_failed_authorize
- response = @gateway.authorize(105200, @declined_card, @options)
- assert_failure response
- assert_equal 'Simulator|Transação de simulada negada por falta de crédito, utilizado para realizar simulação de autorização parcial.', response.message
+ test_failed_authorize_with(@declined_card)
+ end
+
+ def test_failed_authorize_with_alelo_card
+ test_failed_authorize_with(@declined_alelo_voucher)
end
def test_partial_capture
- auth = @gateway.authorize(@amount, @credit_card, @options)
- assert_success auth
+ test_partial_capture_with(@credit_card)
+ end
- assert capture = @gateway.capture(@amount-1, auth.authorization)
- assert_success capture
+ def test_partial_capture_with_alelo_card
+ test_partial_capture_with(@alelo_voucher)
end
def test_failed_capture
@@ -94,19 +103,19 @@ def test_failed_capture
end
def test_successful_refund
- purchase = @gateway.purchase(@amount, @credit_card, @options)
- assert_success purchase
+ test_successful_refund_with(@credit_card)
+ end
- assert refund = @gateway.refund(@amount, purchase.authorization)
- assert_success refund
+ def test_successful_refund_with_alelo_card
+ test_successful_refund_with(@alelo_voucher)
end
def test_partial_refund
- purchase = @gateway.purchase(@amount, @credit_card, @options)
- assert_success purchase
+ test_partial_refund_with(@credit_card)
+ end
- assert refund = @gateway.refund(@amount - 1, purchase.authorization)
- assert_success refund
+ def test_partial_refund_with_alelo_card
+ test_partial_refund_with(@alelo_voucher)
end
def test_failed_refund
@@ -116,11 +125,11 @@ def test_failed_refund
end
def test_successful_void
- auth = @gateway.authorize(@amount, @credit_card, @options)
- assert_success auth
+ test_successful_void_with(@credit_card)
+ end
- assert void = @gateway.void(auth.authorization)
- assert_success void
+ def test_successful_void_with_alelo_card
+ test_successful_void_with(@alelo_voucher)
end
def test_successful_void_with_sodexo_voucher
@@ -166,18 +175,19 @@ def test_failed_void
end
def test_successful_verify
- response = @gateway.verify(@credit_card, @options)
- assert_success response
- assert_match %r{Simulator|Transação de simulação autorizada com sucesso}, response.message
+ test_successful_verify_with(@credit_card)
+ end
+
+ def test_successful_verify_with_alelo_card
+ test_successful_verify_with(@alelo_voucher)
end
def test_successful_store_and_purchase
- store = @gateway.store(@credit_card, @options)
- assert_success store
+ test_successful_store_and_purchase_with(@credit_card)
+ end
- assert purchase = @gateway.purchase(@amount, store.authorization, @options)
- assert_success purchase
- assert_equal 'Simulator|Transação de simulação autorizada com sucesso', purchase.message
+ def test_successful_store_and_purchase_with_alelo_card
+ test_successful_store_and_purchase_with(@alelo_voucher)
end
def test_invalid_login
@@ -208,4 +218,80 @@ def test_transcript_scrubbing
assert_scrubbed(@credit_card.verification_value, transcript)
assert_scrubbed(@gateway.options[:api_key], transcript)
end
+
+ private
+
+ def test_successful_purchase_with(card)
+ response = @gateway.purchase(@amount, card, @options)
+ assert_success response
+ assert_equal 'Simulator|Transação de simulação autorizada com sucesso', response.message
+ end
+
+ def test_failed_purchase_with(card)
+ response = @gateway.purchase(105200, card, @options)
+ assert_failure response
+ assert_equal 'Simulator|Transação de simulada negada por falta de crédito, utilizado para realizar simulação de autorização parcial.', response.message
+ end
+
+ def test_successful_authorize_and_capture_with(card)
+ auth = @gateway.authorize(@amount, card, @options)
+ assert_success auth
+
+ assert capture = @gateway.capture(@amount, auth.authorization)
+ assert_success capture
+ assert_equal 'Simulator|Transação de simulação capturada com sucesso', capture.message
+ end
+
+ def test_failed_authorize_with(card)
+ response = @gateway.authorize(105200, card, @options)
+ assert_failure response
+ assert_equal 'Simulator|Transação de simulada negada por falta de crédito, utilizado para realizar simulação de autorização parcial.', response.message
+ end
+
+ def test_partial_capture_with(card)
+ auth = @gateway.authorize(@amount, card, @options)
+ assert_success auth
+
+ assert capture = @gateway.capture(@amount-1, auth.authorization)
+ assert_success capture
+ end
+
+ def test_successful_refund_with(card)
+ purchase = @gateway.purchase(@amount, card, @options)
+ assert_success purchase
+
+ assert refund = @gateway.refund(@amount, purchase.authorization)
+ assert_success refund
+ end
+
+ def test_partial_refund_with(card)
+ purchase = @gateway.purchase(@amount, card, @options)
+ assert_success purchase
+
+ assert refund = @gateway.refund(@amount - 1, purchase.authorization)
+ assert_success refund
+ end
+
+ def test_successful_void_with(card)
+ auth = @gateway.authorize(@amount, card, @options)
+ assert_success auth
+
+ assert void = @gateway.void(auth.authorization)
+ assert_success void
+ end
+
+ def test_successful_verify_with(card)
+ response = @gateway.verify(card, @options)
+ assert_success response
+ assert_match %r{Simulator|Transação de simulação autorizada com sucesso}, response.message
+ end
+
+ def test_successful_store_and_purchase_with(card)
+ store = @gateway.store(card, @options)
+ assert_success store
+
+ assert purchase = @gateway.purchase(@amount, store.authorization, @options)
+ assert_success purchase
+ assert_equal 'Simulator|Transação de simulação autorizada com sucesso', purchase.message
+ end
end
diff --git a/test/unit/credit_card_methods_test.rb b/test/unit/credit_card_methods_test.rb
index 1eab03bb838..fed753f9fc0 100644
--- a/test/unit/credit_card_methods_test.rb
+++ b/test/unit/credit_card_methods_test.rb
@@ -138,6 +138,23 @@ def test_should_detect_elo_card
assert_equal 'elo', CreditCard.brand?('6509550000000000')
end
+ def test_should_detect_alelo_card
+ assert_equal 'alelo', CreditCard.brand?('5067490000000010')
+ assert_equal 'alelo', CreditCard.brand?('5067700000000028')
+ assert_equal 'alelo', CreditCard.brand?('5067600000000036')
+ assert_equal 'alelo', CreditCard.brand?('5067600000000044')
+ end
+
+ # Alelo BINs beginning with the digit 4 overlap with Visa's range of valid card numbers.
+ # We intentionally misidentify these cards as Visa, which works because transactions with
+ # such cards will run on Visa rails.
+ def test_should_detect_alelo_number_beginning_with_4_as_visa
+ assert_equal 'visa', CreditCard.brand?('4025880000000010')
+ assert_equal 'visa', CreditCard.brand?('4025880000000028')
+ assert_equal 'visa', CreditCard.brand?('4025880000000036')
+ assert_equal 'visa', CreditCard.brand?('4025880000000044')
+ end
+
def test_should_detect_when_an_argument_brand_does_not_match_calculated_brand
assert CreditCard.matching_brand?('4175001000000000', 'visa')
assert_false CreditCard.matching_brand?('4175001000000000', 'master')
diff --git a/test/unit/gateways/mundipagg_test.rb b/test/unit/gateways/mundipagg_test.rb
index c41b1798260..b6806224f3a 100644
--- a/test/unit/gateways/mundipagg_test.rb
+++ b/test/unit/gateways/mundipagg_test.rb
@@ -3,8 +3,33 @@
class MundipaggTest < Test::Unit::TestCase
include CommStub
def setup
- @gateway = MundipaggGateway.new(api_key: 'my_api_key')
@credit_card = credit_card
+
+ @alelo_card = credit_card(
+ '5067700000000028',
+ {
+ month: 10,
+ year: 2032,
+ first_name: 'John',
+ last_name: 'Smith',
+ verification_value: '737',
+ brand: 'alelo'
+ }
+ )
+
+ @alelo_visa_card = credit_card(
+ '4025880000000010',
+ {
+ month: 10,
+ year: 2032,
+ first_name: 'John',
+ last_name: 'Smith',
+ verification_value: '737',
+ brand: 'alelo'
+ }
+ )
+
+ @gateway = MundipaggGateway.new(api_key: 'my_api_key')
@amount = 100
@options = {
@@ -16,13 +41,15 @@ def setup
end
def test_successful_purchase
- @gateway.expects(:ssl_post).returns(successful_purchase_response)
+ test_successful_purchase_with(@credit_card)
+ end
- response = @gateway.purchase(@amount, @credit_card, @options)
- assert_success response
+ def test_successful_purchase_with_alelo_card
+ test_successful_purchase_with(@alelo_card)
+ end
- assert_equal 'ch_90Vjq8TrwfP74XJO', response.authorization
- assert response.test?
+ def test_successful_purchase_with_alelo_number_beginning_with_4
+ test_successful_purchase_with(@alelo_visa_card)
end
def test_successful_purchase_with_holder_document
@@ -190,6 +217,16 @@ def test_scrub
private
+ def test_successful_purchase_with(card)
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
+
+ response = @gateway.purchase(@amount, card, @options)
+ assert_success response
+
+ assert_equal 'ch_90Vjq8TrwfP74XJO', response.authorization
+ assert response.test?
+ end
+
def pre_scrubbed
%q(
opening connection to api.mundipagg.com:443...
From 4509244b13754cfedfba7b9db69a7110e1ae7026 Mon Sep 17 00:00:00 2001
From: molbrown
Date: Thu, 27 Jun 2019 09:26:46 -0400
Subject: [PATCH 0374/2234] Adyen: Remove temporary amount modification for
non-fractional currencies
After safe switchover is coordinated with customer who needed
transition step during update of Adyen to use localized_amount.
Unit:
39 tests, 188 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
60 tests, 187 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Continues ECS-420
closes #3263
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/adyen.rb | 14 --------------
test/remote/gateways/remote_adyen_test.rb | 8 ++++----
test/unit/gateways/adyen_test.rb | 12 ++----------
4 files changed, 7 insertions(+), 28 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index cb942fcc8f5..b820f83ec6b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -26,6 +26,7 @@
* Paypal: Update supported countries [molbrown] #3260
* BlueSnap: Send amount in capture requests [jknipp] #3262
* Adds Elo card type in general, and specifically to Mundipagg [jasonxp] #3255
+* Adyen: Remove temporary amount modification for non-fractional currencies [molbrown] #3263
== Version 1.95.0 (May 23, 2019)
* Adyen: Constantize version to fix subdomains [curiousepic] #3228
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index 93f4560ceaa..ed8e43fc583 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -239,7 +239,6 @@ def add_address(post, options)
def add_invoice(post, money, options)
currency = options[:currency] || currency(money)
- money = calculate_amount(money, options)
amount = {
value: localized_amount(money, currency),
currency: currency
@@ -249,7 +248,6 @@ def add_invoice(post, money, options)
def add_invoice_for_modification(post, money, options)
currency = options[:currency] || currency(money)
- money = calculate_amount(money, options)
amount = {
value: localized_amount(money, currency),
currency: currency
@@ -257,18 +255,6 @@ def add_invoice_for_modification(post, money, options)
post[:modificationAmount] = amount
end
- # temporary method in place to support Spreedly customers switching
- # over to sending multiplied amounts for non-fractional currency transactions,
- # as now required for localized_amount. To avoid amount manipulation, send
- # opt_out_multiply_amount with any non-fractional currency transaction.
- def calculate_amount(money, options)
- currency = options[:currency] || currency(money)
- if non_fractional_currency?(currency)
- money *=100 unless options[:opt_out_multiply_amount]
- end
- money
- end
-
def add_payment(post, payment)
if payment.is_a?(String)
_, _, recurring_detail_reference = payment.split('#')
diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb
index a5f8acd56e4..3f28e882966 100644
--- a/test/remote/gateways/remote_adyen_test.rb
+++ b/test/remote/gateways/remote_adyen_test.rb
@@ -196,7 +196,7 @@ def test_successful_authorize_with_no_address
def test_failed_authorize
response = @gateway.authorize(@amount, @declined_card, @options)
assert_failure response
- assert_equal 'Refused', response.message
+ assert_equal 'CVC Declined', response.message
end
def test_successful_purchase
@@ -274,7 +274,7 @@ def test_successful_purchase_with_elo_card
def test_failed_purchase
response = @gateway.purchase(@amount, @declined_card, @options)
assert_failure response
- assert_equal 'Refused', response.message
+ assert_equal 'CVC Declined', response.message
end
def test_successful_authorize_and_capture
@@ -452,7 +452,7 @@ def test_failed_store
assert response = @gateway.store(@declined_card, @options)
assert_failure response
- assert_equal 'Refused', response.message
+ assert_equal 'CVC Declined', response.message
end
def test_successful_purchase_using_stored_card
@@ -491,7 +491,7 @@ def test_successful_verify
def test_failed_verify
response = @gateway.verify(@declined_card, @options)
assert_failure response
- assert_match 'Refused', response.message
+ assert_match 'CVC Declined', response.message
end
def test_verify_with_idempotency_key
diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb
index 664a7e88edb..d38e33fafc0 100644
--- a/test/unit/gateways/adyen_test.rb
+++ b/test/unit/gateways/adyen_test.rb
@@ -271,17 +271,9 @@ def test_successful_initial_authorize_with_normalized_stored_credentials
end.respond_with(successful_authorize_response)
end
- def test_nonfractional_currency_handling_with_amount_modification
+ def test_nonfractional_currency_handling
stub_comms do
- @gateway.authorize(1, @credit_card, @options.merge(currency: 'JPY'))
- end.check_request do |endpoint, data, headers|
- assert_match(/"amount\":{\"value\":\"1\",\"currency\":\"JPY\"}/, data)
- end.respond_with(successful_authorize_response)
- end
-
- def test_nonfractional_currency_handling_without_amount_modification
- stub_comms do
- @gateway.authorize(200, @credit_card, @options.merge(currency: 'JPY', opt_out_multiply_amount: true))
+ @gateway.authorize(200, @credit_card, @options.merge(currency: 'JPY'))
end.check_request do |endpoint, data, headers|
assert_match(/"amount\":{\"value\":\"2\",\"currency\":\"JPY\"}/, data)
end.respond_with(successful_authorize_response)
From 38327b3c29e9ef4855dc0473a0e63529fdccec0d Mon Sep 17 00:00:00 2001
From: Ruthan
Date: Wed, 19 Jun 2019 14:24:26 -0400
Subject: [PATCH 0375/2234] Adyen: Replace empty state string with N/A
---
lib/active_merchant/billing/gateways/adyen.rb | 6 +++++-
test/remote/gateways/remote_adyen_test.rb | 9 +++++++--
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index ed8e43fc583..a641cf095b0 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -232,11 +232,15 @@ def add_address(post, options)
post[:billingAddress][:houseNumberOrName] = address[:address2] || 'N/A'
post[:billingAddress][:postalCode] = address[:zip] if address[:zip]
post[:billingAddress][:city] = address[:city] || 'N/A'
- post[:billingAddress][:stateOrProvince] = address[:state] || 'N/A'
+ post[:billingAddress][:stateOrProvince] = get_state(address)
post[:billingAddress][:country] = address[:country] if address[:country]
end
end
+ def get_state(address)
+ address[:state] && !address[:state].blank? ? address[:state] : 'N/A'
+ end
+
def add_invoice(post, money, options)
currency = options[:currency] || currency(money)
amount = {
diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb
index 3f28e882966..ffe0e03d7df 100644
--- a/test/remote/gateways/remote_adyen_test.rb
+++ b/test/remote/gateways/remote_adyen_test.rb
@@ -605,11 +605,16 @@ def test_blank_country_for_purchase
assert_match Gateway::STANDARD_ERROR_CODE[:incorrect_address], response.error_code
end
+ def test_nil_state_for_purchase
+ @options[:billing_address][:state] = nil
+ response = @gateway.authorize(@amount, @credit_card, @options)
+ assert_success response
+ end
+
def test_blank_state_for_purchase
@options[:billing_address][:state] = ''
response = @gateway.authorize(@amount, @credit_card, @options)
- assert_failure response
- assert_match Gateway::STANDARD_ERROR_CODE[:incorrect_address], response.error_code
+ assert_success response
end
def test_missing_phone_for_purchase
From bdd05715b2c913732fd434dc53571b297f7676e0 Mon Sep 17 00:00:00 2001
From: Ruthan
Date: Wed, 3 Jul 2019 10:39:10 -0400
Subject: [PATCH 0376/2234] Update changelog for 3252
---
CHANGELOG | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG b/CHANGELOG
index b820f83ec6b..c6d1b471ecb 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -27,6 +27,7 @@
* BlueSnap: Send amount in capture requests [jknipp] #3262
* Adds Elo card type in general, and specifically to Mundipagg [jasonxp] #3255
* Adyen: Remove temporary amount modification for non-fractional currencies [molbrown] #3263
+* Adyen: Set blank state to N/A [therufs] #3252
== Version 1.95.0 (May 23, 2019)
* Adyen: Constantize version to fix subdomains [curiousepic] #3228
From 4493b55b5bf49f854bcd43e08cae1b9e30b62eb2 Mon Sep 17 00:00:00 2001
From: leila-alderman
Date: Mon, 1 Jul 2019 10:22:42 -0400
Subject: [PATCH 0377/2234] MiGS: Add tx_source gateway specific field
Added the `tx_source` gateway specific field to the MiGS gateway along
with remote and unit tests.
Based on feedback, the `add_tx_source` method wasn't added to the
`purchase_offsite_url` action since Spreedly is not in control of this
action and since there is not a way to run a remote test for it as the
`test_server_purchase_url` is the remote test that is still resulting
in an error.
No remote test was added for the `refund` action passing the `tx_source`
parameter because the main remote test for the `refund` action is
currently commented out and not working.
For consistency, all of the hash rockets in the unit tests were changed
to use the modern hash syntax, i.e., `key: value`.
CE-34 / CE-44
Unit:
9 tests, 21 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
Remote:
16 tests, 59 assertions, 0 failures, 1 errors, 0 pendings, 0 omissions,
0 notifications
93.75% passed
Undefined method `request_uri` error in `test_server_purchase_url`;
error unrelated to change
---
lib/active_merchant/billing/gateways/migs.rb | 8 +++
test/remote/gateways/remote_migs_test.rb | 45 ++++++++++++++++
test/unit/gateways/migs_test.rb | 55 +++++++++++++++-----
3 files changed, 94 insertions(+), 14 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/migs.rb b/lib/active_merchant/billing/gateways/migs.rb
index f689a41fc4f..e1ae2922682 100644
--- a/lib/active_merchant/billing/gateways/migs.rb
+++ b/lib/active_merchant/billing/gateways/migs.rb
@@ -63,6 +63,7 @@ def purchase(money, creditcard, options = {})
add_creditcard(post, creditcard)
add_standard_parameters('pay', post, options[:unique_id])
add_3ds(post, options)
+ add_tx_source(post, options)
commit(post)
end
@@ -83,6 +84,7 @@ def capture(money, authorization, options = {})
add_amount(post, money, options)
add_advanced_user(post)
add_standard_parameters('capture', post, options[:unique_id])
+ add_tx_source(post, options)
commit(post)
end
@@ -99,6 +101,7 @@ def refund(money, authorization, options = {})
add_amount(post, money, options)
add_advanced_user(post)
add_standard_parameters('refund', post, options[:unique_id])
+ add_tx_source(post, options)
commit(post)
end
@@ -110,6 +113,7 @@ def void(authorization, options = {})
add_advanced_user(post)
add_standard_parameters('voidAuthorisation', post, options[:unique_id])
+ add_tx_source(post, options)
commit(post)
end
@@ -241,6 +245,10 @@ def add_3ds(post, options)
post['3DSstatus'] = options[:three_ds_status] if options[:three_ds_status]
end
+ def add_tx_source(post, options)
+ post[:TxSource] = options[:tx_source] if options[:tx_source]
+ end
+
def add_creditcard(post, creditcard)
post[:CardNum] = creditcard.number
post[:CardSecurityCode] = creditcard.verification_value if creditcard.verification_value?
diff --git a/test/remote/gateways/remote_migs_test.rb b/test/remote/gateways/remote_migs_test.rb
index 077762dc30b..69ea544201c 100644
--- a/test/remote/gateways/remote_migs_test.rb
+++ b/test/remote/gateways/remote_migs_test.rb
@@ -16,6 +16,9 @@ def setup
@diners = credit_card('30123456789019', :month => 5, :year => 2021, :brand => 'diners_club')
@credit_card = @visa
+ @valid_tx_source = 'MOTO'
+ @invalid_tx_source = 'penguin'
+
@options = {
:order_id => '1',
:currency => 'SAR'
@@ -104,6 +107,48 @@ def test_refund
# assert_equal 'Approved', response.message
end
+ def test_purchase_passes_tx_source
+ # returns a successful response when a valid tx_source parameter is sent
+ assert good_response = @gateway.purchase(@amount, @credit_card, @options.merge(tx_source: @valid_tx_source))
+ assert_success good_response
+ assert_equal 'Approved', good_response.message
+
+ # returns a failed response when an invalid tx_source parameter is sent
+ assert bad_response = @gateway.purchase(@amount, @credit_card, @options.merge(tx_source: @invalid_tx_source))
+ assert_failure bad_response
+ end
+
+ def test_capture_passes_tx_source
+ # authorize the credit card in order to then run capture
+ assert auth = @gateway.authorize(@amount, @credit_card, @options)
+ assert_success auth
+ assert_equal 'Approved', auth.message
+
+ # returns a successful response when a valid tx_source paramater is sent
+ assert good_response = @gateway.capture(@amount, auth.authorization, @options.merge(tx_source: @valid_tx_source))
+ assert_success good_response
+
+ # returns a failed response when an invalid tx_source parameter is sent
+ assert bad_response = @gateway.capture(@amount, auth.authorization, @options.merge(tx_source: @invalid_tx_source))
+ assert_failure bad_response
+ end
+
+ def test_void_passes_tx_source
+ # authorize the credit card in order to then run capture
+ assert auth = @gateway.authorize(@amount, @credit_card, @options)
+ assert_success auth
+ assert_equal 'Approved', auth.message
+
+ # returns a successful response when a valid tx_source paramater is sent
+ assert good_response = @gateway.void(auth.authorization, @options.merge(tx_source: @valid_tx_source))
+ assert_success good_response
+ assert_equal 'Approved', good_response.message
+
+ # returns a failed response when an invalid tx_source parameter is sent
+ assert bad_response = @gateway.void(auth.authorization, @options.merge(tx_source: @invalid_tx_source))
+ assert_failure bad_response
+ end
+
def test_status
purchase_response = @gateway.purchase(@declined_amount, @credit_card, @options)
assert response = @gateway.status(purchase_response.params['MerchTxnRef'])
diff --git a/test/unit/gateways/migs_test.rb b/test/unit/gateways/migs_test.rb
index f6ba3282202..73ef494ff7b 100644
--- a/test/unit/gateways/migs_test.rb
+++ b/test/unit/gateways/migs_test.rb
@@ -3,18 +3,21 @@
class MigsTest < Test::Unit::TestCase
def setup
@gateway = MigsGateway.new(
- :login => 'login',
- :password => 'password',
- :secure_hash => '76AF3392002D202A60D0AB5F9D81653C'
+ login: 'login',
+ password: 'password',
+ secure_hash: '76AF3392002D202A60D0AB5F9D81653C',
+ advanced_login: 'advlogin',
+ advanced_password: 'advpass'
)
-
@credit_card = credit_card
@amount = 100
+ @authorization = '2070000742'
+ @tx_source = 'MOTO'
@options = {
- :order_id => '1',
- :billing_address => address,
- :description => 'Store Purchase'
+ order_id: '1',
+ billing_address: address,
+ description: 'Store Purchase'
}
end
@@ -41,9 +44,9 @@ def test_unsuccessful_request
def test_secure_hash
params = {
- :MerchantId => 'MER123',
- :OrderInfo => 'A48cvE28',
- :Amount => 2995
+ MerchantId: 'MER123',
+ OrderInfo: 'A48cvE28',
+ Amount: 2995
}
ordered_values = 'vpc_Amount=2995&vpc_MerchantId=MER123&vpc_OrderInfo=A48cvE28'
@gateway.send(:add_secure_hash, params)
@@ -74,21 +77,41 @@ def test_scrub
assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed
end
+ def test_purchase_passes_tx_source
+ expect_commit_with_tx_source
+ @gateway.purchase(@amount, @credit_card, @options.merge(tx_source: @tx_source))
+ end
+
+ def test_capture_passes_tx_source
+ expect_commit_with_tx_source
+ @gateway.capture(@amount, @authorization, @options.merge(tx_source: @tx_source))
+ end
+
+ def test_refund_passes_tx_source
+ expect_commit_with_tx_source
+ @gateway.refund(@amount, @authorization, @options.merge(tx_source: @tx_source))
+ end
+
+ def test_void_passes_tx_source
+ expect_commit_with_tx_source
+ @gateway.void(@authorization, @options.merge(tx_source: @tx_source))
+ end
+
private
# Place raw successful response from gateway here
def successful_purchase_response
build_response(
- :TxnResponseCode => '0',
- :TransactionNo => '123456'
+ TxnResponseCode: '0',
+ TransactionNo: '123456'
)
end
# Place raw failed response from gateway here
def failed_purchase_response
build_response(
- :TxnResponseCode => '3',
- :TransactionNo => '654321'
+ TxnResponseCode: '3',
+ TransactionNo: '654321'
)
end
@@ -96,6 +119,10 @@ def build_response(options)
options.collect { |key, value| "vpc_#{key}=#{CGI.escape(value.to_s)}" }.join('&')
end
+ def expect_commit_with_tx_source
+ @gateway.expects(:commit).with(has_entries(TxSource: @tx_source))
+ end
+
def pre_scrubbed
<<-EOS
opening connection to migs.mastercard.com.au:443...
From 24b99e8a57305d3ca826251b427930df9b3800a9 Mon Sep 17 00:00:00 2001
From: leila-alderman
Date: Fri, 5 Jul 2019 13:41:34 -0400
Subject: [PATCH 0378/2234] Update CHANGELOG
Updates the CHANGELOG for the changes made in PR #3264, `MiGS: Add
tx_source gateway specific field`.
CE-34 / CE-44
---
CHANGELOG | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG b/CHANGELOG
index c6d1b471ecb..80d52c12716 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -28,6 +28,7 @@
* Adds Elo card type in general, and specifically to Mundipagg [jasonxp] #3255
* Adyen: Remove temporary amount modification for non-fractional currencies [molbrown] #3263
* Adyen: Set blank state to N/A [therufs] #3252
+* MiGS: Add tx_source gateway specific field [leila-alderman] #3264
== Version 1.95.0 (May 23, 2019)
* Adyen: Constantize version to fix subdomains [curiousepic] #3228
From 4c718139ef38d8a466ad87f12f0478e3c774a96b Mon Sep 17 00:00:00 2001
From: Hannah Deters
Date: Mon, 8 Jul 2019 16:04:31 -0400
Subject: [PATCH 0379/2234] NMI: Scrub symbols from passwords
Accounts for the possibility of symbols in passwords rather than just
letters/digits and scrubs accordingly
ECS-317
Closes #3267
Unit:
45 tests, 342 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
Remote:
41 tests, 151 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/nmi.rb | 2 +-
test/unit/gateways/nmi_test.rb | 4 ++--
3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 80d52c12716..f61b0a2bb55 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -29,6 +29,7 @@
* Adyen: Remove temporary amount modification for non-fractional currencies [molbrown] #3263
* Adyen: Set blank state to N/A [therufs] #3252
* MiGS: Add tx_source gateway specific field [leila-alderman] #3264
+* NMI: Correct password scrubber to scrub symbols [hdeters] #3267
== Version 1.95.0 (May 23, 2019)
* Adyen: Constantize version to fix subdomains [curiousepic] #3228
diff --git a/lib/active_merchant/billing/gateways/nmi.rb b/lib/active_merchant/billing/gateways/nmi.rb
index f170a653fa6..7d5339d6d70 100644
--- a/lib/active_merchant/billing/gateways/nmi.rb
+++ b/lib/active_merchant/billing/gateways/nmi.rb
@@ -123,7 +123,7 @@ def supports_scrubbing?
def scrub(transcript)
transcript.
- gsub(%r((password=)\w+), '\1[FILTERED]').
+ gsub(%r((password=)[^&\n]*), '\1[FILTERED]').
gsub(%r((ccnumber=)\d+), '\1[FILTERED]').
gsub(%r((cvv=)\d+), '\1[FILTERED]').
gsub(%r((checkaba=)\d+), '\1[FILTERED]').
diff --git a/test/unit/gateways/nmi_test.rb b/test/unit/gateways/nmi_test.rb
index a3586414a25..72b90edaa32 100644
--- a/test/unit/gateways/nmi_test.rb
+++ b/test/unit/gateways/nmi_test.rb
@@ -723,9 +723,9 @@ def successful_echeck_store_response
def transcript
'
- amount=1.00&orderid=c9f2fb356d2a839d315aa6e8d7ed2404&orderdescription=Store+purchase¤cy=USD&payment=creditcard&firstname=Longbob&lastname=Longsen&ccnumber=4111111111111111&cvv=917&ccexp=0916&email=&ipaddress=&company=Widgets+Inc&address1=456+My+Street&address2=Apt+1&city=Ottawa&state=ON&country=CA&zip=K1C2N6&phone=%28555%29555-5555&type=sale&username=demo&password=password
+ amount=1.00&orderid=c9f2fb356d2a839d315aa6e8d7ed2404&orderdescription=Store+purchase¤cy=USD&payment=creditcard&firstname=Longbob&lastname=Longsen&ccnumber=4111111111111111&cvv=917&ccexp=0916&email=&ipaddress=&company=Widgets+Inc&address1=456+My+Street&address2=Apt+1&city=Ottawa&state=ON&country=CA&zip=K1C2N6&phone=%28555%29555-5555&type=sale&username=demo&password=passwordw$thsym%ols
response=1&responsetext=SUCCESS&authcode=123456&transactionid=2767466670&avsresponse=N&cvvresponse=N&orderid=c9f2fb356d2a839d315aa6e8d7ed2404&type=sale&response_code=100
- amount=1.00&orderid=e88df316d8ba3c8c6b98aa93b78facc0&orderdescription=Store+purchase¤cy=USD&payment=check&checkname=Jim+Smith&checkaba=123123123&checkaccount=123123123&account_holder_type=personal&account_type=checking&sec_code=WEB&email=&ipaddress=&company=Widgets+Inc&address1=456+My+Street&address2=Apt+1&city=Ottawa&state=ON&country=CA&zip=K1C2N6&phone=%28555%29555-5555&type=sale&username=demo&password=password
+ amount=1.00&orderid=e88df316d8ba3c8c6b98aa93b78facc0&orderdescription=Store+purchase¤cy=USD&payment=check&checkname=Jim+Smith&checkaba=123123123&checkaccount=123123123&account_holder_type=personal&account_type=checking&sec_code=WEB&email=&ipaddress=&company=Widgets+Inc&address1=456+My+Street&address2=Apt+1&city=Ottawa&state=ON&country=CA&zip=K1C2N6&phone=%28555%29555-5555&type=sale&username=demo&password=passwordw$thsym%ols
response=1&responsetext=SUCCESS&authcode=123456&transactionid=2767467157&avsresponse=&cvvresponse=&orderid=e88df316d8ba3c8c6b98aa93b78facc0&type=sale&response_code=100
'
end
From 70235b422173701d76dbedebab21fc942e0318ca Mon Sep 17 00:00:00 2001
From: David Perry
Date: Tue, 9 Jul 2019 15:30:08 -0400
Subject: [PATCH 0380/2234] Global Collect: Only add name if present
Closes #3268
Remote:
17 tests, 40 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
20 tests, 88 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/global_collect.rb | 8 ++------
test/remote/gateways/remote_global_collect_test.rb | 10 +++++++++-
test/unit/gateways/global_collect_test.rb | 10 ++++++++++
4 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index f61b0a2bb55..2e86a9dceb5 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -30,6 +30,7 @@
* Adyen: Set blank state to N/A [therufs] #3252
* MiGS: Add tx_source gateway specific field [leila-alderman] #3264
* NMI: Correct password scrubber to scrub symbols [hdeters] #3267
+* Global Collect: Only add name if present [curiousepic] #3268
== Version 1.95.0 (May 23, 2019)
* Adyen: Constantize version to fix subdomains [curiousepic] #3228
diff --git a/lib/active_merchant/billing/gateways/global_collect.rb b/lib/active_merchant/billing/gateways/global_collect.rb
index 370780d14f1..f9ef0aa4e96 100644
--- a/lib/active_merchant/billing/gateways/global_collect.rb
+++ b/lib/active_merchant/billing/gateways/global_collect.rb
@@ -142,12 +142,8 @@ def add_payment(post, payment, options)
def add_customer_data(post, options, payment = nil)
if payment
- post['order']['customer']['personalInformation'] = {
- 'name' => {
- 'firstName' => payment.first_name[0..14],
- 'surname' => payment.last_name[0..69]
- }
- }
+ post['order']['customer']['personalInformation']['name']['firstName'] = payment.first_name[0..14] if payment.first_name
+ post['order']['customer']['personalInformation']['name']['surname'] = payment.last_name[0..69] if payment.last_name
end
post['order']['customer']['merchantCustomerId'] = options[:customer] if options[:customer]
post['order']['customer']['companyInformation']['name'] = options[:company] if options[:company]
diff --git a/test/remote/gateways/remote_global_collect_test.rb b/test/remote/gateways/remote_global_collect_test.rb
index b7497b13f00..19eab0296fa 100644
--- a/test/remote/gateways/remote_global_collect_test.rb
+++ b/test/remote/gateways/remote_global_collect_test.rb
@@ -63,6 +63,14 @@ def test_successful_purchase_with_very_long_name
assert_equal 'Succeeded', response.message
end
+ def test_successful_purchase_with_blank_name
+ credit_card = credit_card('4567350000427977', { first_name: nil, last_name: nil})
+
+ response = @gateway.purchase(@amount, credit_card, @options)
+ assert_success response
+ assert_equal 'Succeeded', response.message
+ end
+
def test_failed_purchase
response = @gateway.purchase(@rejected_amount, @declined_card, @options)
assert_failure response
@@ -155,7 +163,7 @@ def test_invalid_login
response = gateway.purchase(@amount, @credit_card, @options)
assert_failure response
- assert_match %r{UNKNOWN_SERVER_ERROR}, response.message
+ assert_match %r{MISSING_OR_INVALID_AUTHORIZATION}, response.message
end
def test_transcript_scrubbing
diff --git a/test/unit/gateways/global_collect_test.rb b/test/unit/gateways/global_collect_test.rb
index 318f4ea8e38..fd1d5bff1fc 100644
--- a/test/unit/gateways/global_collect_test.rb
+++ b/test/unit/gateways/global_collect_test.rb
@@ -104,6 +104,16 @@ def test_trucates_first_name_to_15_chars
assert_equal '000000142800000000920000100001', response.authorization
end
+ def test_handles_blank_names
+ credit_card = credit_card('4567350000427977', { first_name: nil, last_name: nil})
+
+ response = stub_comms do
+ @gateway.authorize(@accepted_amount, credit_card, @options)
+ end.respond_with(successful_authorize_response)
+
+ assert_success response
+ end
+
def test_failed_authorize
response = stub_comms do
@gateway.authorize(@rejected_amount, @declined_card, @options)
From c387d6f2259763aab539ed19ef3b3599ed91b76c Mon Sep 17 00:00:00 2001
From: Shane Logsdon
Date: Mon, 6 May 2019 15:35:45 -0400
Subject: [PATCH 0381/2234] HPS: Add Apple Pay raw cryptogram support
Unit:
34 tests, 171 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
40 tests, 102 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Closes #3209
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/hps.rb | 47 ++-
test/remote/gateways/remote_hps_test.rb | 148 +++++++++
test/unit/gateways/hps_test.rb | 317 +++++++++++++++++++-
4 files changed, 510 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 2e86a9dceb5..a01d10b8bf8 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -31,6 +31,7 @@
* MiGS: Add tx_source gateway specific field [leila-alderman] #3264
* NMI: Correct password scrubber to scrub symbols [hdeters] #3267
* Global Collect: Only add name if present [curiousepic] #3268
+* HPS: Add Apple Pay raw cryptogram support [slogsdon] #3209
== Version 1.95.0 (May 23, 2019)
* Adyen: Constantize version to fix subdomains [curiousepic] #3228
diff --git a/lib/active_merchant/billing/gateways/hps.rb b/lib/active_merchant/billing/gateways/hps.rb
index dbc7997370b..6069040003c 100644
--- a/lib/active_merchant/billing/gateways/hps.rb
+++ b/lib/active_merchant/billing/gateways/hps.rb
@@ -15,6 +15,14 @@ class HpsGateway < Gateway
self.money_format = :dollars
+ PAYMENT_DATA_SOURCE_MAPPING = {
+ apple_pay: 'ApplePay',
+ master: 'MasterCard 3DSecure',
+ visa: 'Visa 3DSecure',
+ american_express: 'AMEX 3DSecure',
+ discover: 'Discover 3DSecure',
+ }
+
def initialize(options={})
requires!(options, :secret_api_key)
super
@@ -28,6 +36,7 @@ def authorize(money, card_or_token, options={})
add_details(xml, options)
add_descriptor_name(xml, options)
add_payment(xml, card_or_token, options)
+ add_three_d_secure(xml, card_or_token, options)
end
end
@@ -46,6 +55,7 @@ def purchase(money, card_or_token, options={})
add_details(xml, options)
add_descriptor_name(xml, options)
add_payment(xml, card_or_token, options)
+ add_three_d_secure(xml, card_or_token, options)
end
end
@@ -81,7 +91,8 @@ def scrub(transcript)
transcript.
gsub(%r(()[^<]*(<\/hps:CardNbr>))i, '\1[FILTERED]\2').
gsub(%r(()[^<]*(<\/hps:CVV2>))i, '\1[FILTERED]\2').
- gsub(%r(()[^<]*(<\/hps:SecretAPIKey>))i, '\1[FILTERED]\2')
+ gsub(%r(()[^<]*(<\/hps:SecretAPIKey>))i, '\1[FILTERED]\2').
+ gsub(%r(()[^<]*(<\/hps:PaymentData>))i, '\1[FILTERED]\2')
end
private
@@ -164,6 +175,40 @@ def add_descriptor_name(xml, options)
xml.hps :TxnDescriptor, options[:descriptor_name] if options[:descriptor_name]
end
+ def add_three_d_secure(xml, card_or_token, options)
+ if card_or_token.is_a?(NetworkTokenizationCreditCard)
+ build_three_d_secure(xml, {
+ source: card_or_token.source,
+ cavv: card_or_token.payment_cryptogram,
+ eci: card_or_token.eci,
+ xid: card_or_token.transaction_id,
+ })
+ elsif options[:three_d_secure]
+ options[:three_d_secure][:source] ||= card_brand(card_or_token)
+ build_three_d_secure(xml, options[:three_d_secure])
+ end
+ end
+
+ def build_three_d_secure(xml, three_d_secure)
+ # PaymentDataSource is required when supplying the SecureECommerce data group,
+ # and the gateway currently only allows the values within the mapping
+ return unless PAYMENT_DATA_SOURCE_MAPPING[three_d_secure[:source].to_sym]
+
+ xml.hps :SecureECommerce do
+ xml.hps :PaymentDataSource, PAYMENT_DATA_SOURCE_MAPPING[three_d_secure[:source].to_sym]
+ xml.hps :TypeOfPaymentData, '3DSecure' # Only type currently supported
+ xml.hps :PaymentData, three_d_secure[:cavv] if three_d_secure[:cavv]
+ # the gateway only allows a single character for the ECI
+ xml.hps :ECommerceIndicator, strip_leading_zero(three_d_secure[:eci]) if three_d_secure[:eci]
+ xml.hps :XID, three_d_secure[:xid] if three_d_secure[:xid]
+ end
+ end
+
+ def strip_leading_zero(value)
+ return value unless value[0] == '0'
+ value[1, 1]
+ end
+
def build_request(action)
xml = Builder::XmlMarkup.new(encoding: 'UTF-8')
xml.instruct!(:xml, encoding: 'UTF-8')
diff --git a/test/remote/gateways/remote_hps_test.rb b/test/remote/gateways/remote_hps_test.rb
index 2650965ecc5..832d73703a9 100644
--- a/test/remote/gateways/remote_hps_test.rb
+++ b/test/remote/gateways/remote_hps_test.rb
@@ -261,4 +261,152 @@ def test_transcript_scrubbing
assert_scrubbed(@credit_card.verification_value, transcript)
assert_scrubbed(@gateway.options[:secret_api_key], transcript)
end
+
+ def test_transcript_scrubbing_with_cryptogram
+ credit_card = network_tokenization_credit_card('4242424242424242',
+ payment_cryptogram: 'EHuWW9PiBkWvqE5juRwDzAUFBAk=',
+ verification_value: nil,
+ eci: '05',
+ source: :apple_pay
+ )
+ transcript = capture_transcript(@gateway) do
+ @gateway.purchase(@amount, credit_card, @options)
+ end
+ transcript = @gateway.scrub(transcript)
+
+ assert_scrubbed(credit_card.number, transcript)
+ assert_scrubbed(@gateway.options[:secret_api_key], transcript)
+ assert_scrubbed(credit_card.payment_cryptogram, transcript)
+ end
+
+ def test_successful_purchase_with_apple_pay_raw_cryptogram_with_eci
+ credit_card = network_tokenization_credit_card('4242424242424242',
+ payment_cryptogram: 'EHuWW9PiBkWvqE5juRwDzAUFBAk=',
+ verification_value: nil,
+ eci: '05',
+ source: :apple_pay
+ )
+ assert response = @gateway.purchase(@amount, credit_card, @options)
+ assert_success response
+ assert_equal 'Success', response.message
+ end
+
+ def test_successful_purchase_with_apple_pay_raw_cryptogram_without_eci
+ credit_card = network_tokenization_credit_card('4242424242424242',
+ payment_cryptogram: 'EHuWW9PiBkWvqE5juRwDzAUFBAk=',
+ verification_value: nil,
+ source: :apple_pay
+ )
+ assert response = @gateway.purchase(@amount, credit_card, @options)
+ assert_success response
+ assert_equal 'Success', response.message
+ end
+
+ def test_successful_auth_with_apple_pay_raw_cryptogram_with_eci
+ credit_card = network_tokenization_credit_card('4242424242424242',
+ payment_cryptogram: 'EHuWW9PiBkWvqE5juRwDzAUFBAk=',
+ verification_value: nil,
+ eci: '05',
+ source: :apple_pay
+ )
+ assert response = @gateway.authorize(@amount, credit_card, @options)
+ assert_success response
+ assert_equal 'Success', response.message
+ end
+
+ def test_successful_auth_with_apple_pay_raw_cryptogram_without_eci
+ credit_card = network_tokenization_credit_card('4242424242424242',
+ payment_cryptogram: 'EHuWW9PiBkWvqE5juRwDzAUFBAk=',
+ verification_value: nil,
+ source: :apple_pay
+ )
+ assert response = @gateway.authorize(@amount, credit_card, @options)
+ assert_success response
+ assert_equal 'Success', response.message
+ end
+
+ def test_three_d_secure_visa
+ @credit_card.number = '4012002000060016'
+ @credit_card.brand = 'visa'
+
+ options = {
+ :three_d_secure => {
+ :cavv => 'EHuWW9PiBkWvqE5juRwDzAUFBAk=',
+ :eci => '05',
+ :xid => 'TTBCSkVTa1ZpbDI1bjRxbGk5ODE='
+ }
+ }
+
+ response = @gateway.purchase(@amount, @credit_card, options)
+ assert_success response
+ assert_equal 'Success', response.message
+ end
+
+ def test_three_d_secure_mastercard
+ @credit_card.number = '5473500000000014'
+ @credit_card.brand = 'master'
+
+ options = {
+ :three_d_secure => {
+ :cavv => 'EHuWW9PiBkWvqE5juRwDzAUFBAk=',
+ :eci => '05',
+ :xid => 'TTBCSkVTa1ZpbDI1bjRxbGk5ODE='
+ }
+ }
+
+ response = @gateway.purchase(@amount, @credit_card, options)
+ assert_success response
+ assert_equal 'Success', response.message
+ end
+
+ def test_three_d_secure_discover
+ @credit_card.number = '6011000990156527'
+ @credit_card.brand = 'discover'
+
+ options = {
+ :three_d_secure => {
+ :cavv => 'EHuWW9PiBkWvqE5juRwDzAUFBAk=',
+ :eci => '05',
+ :xid => 'TTBCSkVTa1ZpbDI1bjRxbGk5ODE='
+ }
+ }
+
+ response = @gateway.purchase(@amount, @credit_card, options)
+ assert_success response
+ assert_equal 'Success', response.message
+ end
+
+ def test_three_d_secure_amex
+ @credit_card.number = '372700699251018'
+ @credit_card.brand = 'american_express'
+
+ options = {
+ :three_d_secure => {
+ :cavv => 'EHuWW9PiBkWvqE5juRwDzAUFBAk=',
+ :eci => '05',
+ :xid => 'TTBCSkVTa1ZpbDI1bjRxbGk5ODE='
+ }
+ }
+
+ response = @gateway.purchase(@amount, @credit_card, options)
+ assert_success response
+ assert_equal 'Success', response.message
+ end
+
+ def test_three_d_secure_jcb
+ @credit_card.number = '372700699251018'
+ @credit_card.brand = 'jcb'
+
+ options = {
+ :three_d_secure => {
+ :cavv => 'EHuWW9PiBkWvqE5juRwDzAUFBAk=',
+ :eci => '05',
+ :xid => 'TTBCSkVTa1ZpbDI1bjRxbGk5ODE='
+ }
+ }
+
+ response = @gateway.purchase(@amount, @credit_card, options)
+ assert_success response
+ assert_equal 'Success', response.message
+ end
end
diff --git a/test/unit/gateways/hps_test.rb b/test/unit/gateways/hps_test.rb
index 0f85bf5a2cb..ef046791860 100644
--- a/test/unit/gateways/hps_test.rb
+++ b/test/unit/gateways/hps_test.rb
@@ -1,6 +1,8 @@
require 'test_helper'
class HpsTest < Test::Unit::TestCase
+ include CommStub
+
def setup
@gateway = HpsGateway.new({:secret_api_key => '12'})
@@ -195,6 +197,249 @@ def test_transcript_scrubbing
assert_equal @gateway.scrub(pre_scrub), post_scrub
end
+ def test_successful_purchase_with_apple_pay_raw_cryptogram_with_eci
+ @gateway.expects(:ssl_post).returns(successful_charge_response)
+
+ credit_card = network_tokenization_credit_card('4242424242424242',
+ payment_cryptogram: 'EHuWW9PiBkWvqE5juRwDzAUFBAk=',
+ verification_value: nil,
+ eci: '05',
+ source: :apple_pay
+ )
+ assert response = @gateway.purchase(@amount, credit_card, @options)
+ assert_success response
+ assert_equal 'Success', response.message
+ end
+
+ def test_failed_purchase_with_apple_pay_raw_cryptogram_with_eci
+ @gateway.expects(:ssl_post).returns(failed_charge_response_decline)
+
+ credit_card = network_tokenization_credit_card('4242424242424242',
+ payment_cryptogram: 'EHuWW9PiBkWvqE5juRwDzAUFBAk=',
+ verification_value: nil,
+ eci: '05',
+ source: :apple_pay
+ )
+ assert response = @gateway.purchase(@amount, credit_card, @options)
+ assert_failure response
+ assert_equal 'The card was declined.', response.message
+ end
+
+ def test_successful_purchase_with_apple_pay_raw_cryptogram_without_eci
+ @gateway.expects(:ssl_post).returns(successful_charge_response)
+
+ credit_card = network_tokenization_credit_card('4242424242424242',
+ payment_cryptogram: 'EHuWW9PiBkWvqE5juRwDzAUFBAk=',
+ verification_value: nil,
+ source: :apple_pay
+ )
+ assert response = @gateway.purchase(@amount, credit_card, @options)
+ assert_success response
+ assert_equal 'Success', response.message
+ end
+
+ def test_failed_purchase_with_apple_pay_raw_cryptogram_without_eci
+ @gateway.expects(:ssl_post).returns(failed_charge_response_decline)
+
+ credit_card = network_tokenization_credit_card('4242424242424242',
+ payment_cryptogram: 'EHuWW9PiBkWvqE5juRwDzAUFBAk=',
+ verification_value: nil,
+ source: :apple_pay
+ )
+ assert response = @gateway.purchase(@amount, credit_card, @options)
+ assert_failure response
+ assert_equal 'The card was declined.', response.message
+ end
+
+ def test_successful_auth_with_apple_pay_raw_cryptogram_with_eci
+ @gateway.expects(:ssl_post).returns(successful_authorize_response)
+
+ credit_card = network_tokenization_credit_card('4242424242424242',
+ payment_cryptogram: 'EHuWW9PiBkWvqE5juRwDzAUFBAk=',
+ verification_value: nil,
+ eci: '05',
+ source: :apple_pay
+ )
+ assert response = @gateway.authorize(@amount, credit_card, @options)
+ assert_success response
+ assert_equal 'Success', response.message
+ end
+
+ def test_failed_auth_with_apple_pay_raw_cryptogram_with_eci
+ @gateway.expects(:ssl_post).returns(failed_authorize_response_decline)
+
+ credit_card = network_tokenization_credit_card('4242424242424242',
+ payment_cryptogram: 'EHuWW9PiBkWvqE5juRwDzAUFBAk=',
+ verification_value: nil,
+ eci: '05',
+ source: :apple_pay
+ )
+ assert response = @gateway.authorize(@amount, credit_card, @options)
+ assert_failure response
+ assert_equal 'The card was declined.', response.message
+ end
+
+ def test_successful_auth_with_apple_pay_raw_cryptogram_without_eci
+ @gateway.expects(:ssl_post).returns(successful_authorize_response)
+
+ credit_card = network_tokenization_credit_card('4242424242424242',
+ payment_cryptogram: 'EHuWW9PiBkWvqE5juRwDzAUFBAk=',
+ verification_value: nil,
+ source: :apple_pay
+ )
+ assert response = @gateway.authorize(@amount, credit_card, @options)
+ assert_success response
+ assert_equal 'Success', response.message
+ end
+
+ def test_failed_auth_with_apple_pay_raw_cryptogram_without_eci
+ @gateway.expects(:ssl_post).returns(failed_authorize_response_decline)
+
+ credit_card = network_tokenization_credit_card('4242424242424242',
+ payment_cryptogram: 'EHuWW9PiBkWvqE5juRwDzAUFBAk=',
+ verification_value: nil,
+ source: :apple_pay
+ )
+ assert response = @gateway.authorize(@amount, credit_card, @options)
+ assert_failure response
+ assert_equal 'The card was declined.', response.message
+ end
+
+ def test_three_d_secure_visa
+ @credit_card.number = '4012002000060016'
+ @credit_card.brand = 'visa'
+
+ options = {
+ :three_d_secure => {
+ :cavv => 'EHuWW9PiBkWvqE5juRwDzAUFBAk=',
+ :eci => '05',
+ :xid => 'TTBCSkVTa1ZpbDI1bjRxbGk5ODE='
+ }
+ }
+
+ response = stub_comms(@gateway, :ssl_request) do
+ @gateway.purchase(@amount, @credit_card, options)
+ end.check_request do |method, endpoint, data, headers|
+ assert_match(/(.*)<\/hps:SecureECommerce>/, data)
+ assert_match(/Visa 3DSecure<\/hps:PaymentDataSource>/, data)
+ assert_match(/3DSecure<\/hps:TypeOfPaymentData>/, data)
+ assert_match(/#{options[:three_d_secure][:cavv]}<\/hps:PaymentData>/, data)
+ assert_match(/5<\/hps:ECommerceIndicator>/, data)
+ assert_match(/#{options[:three_d_secure][:xid]}<\/hps:XID>/, data)
+ end.respond_with(successful_charge_response)
+
+ assert_success response
+ assert_equal 'Success', response.message
+ end
+
+ def test_three_d_secure_mastercard
+ @credit_card.number = '5473500000000014'
+ @credit_card.brand = 'master'
+
+ options = {
+ :three_d_secure => {
+ :cavv => 'EHuWW9PiBkWvqE5juRwDzAUFBAk=',
+ :eci => '05',
+ :xid => 'TTBCSkVTa1ZpbDI1bjRxbGk5ODE='
+ }
+ }
+
+ response = stub_comms(@gateway, :ssl_request) do
+ @gateway.purchase(@amount, @credit_card, options)
+ end.check_request do |method, endpoint, data, headers|
+ assert_match(/(.*)<\/hps:SecureECommerce>/, data)
+ assert_match(/MasterCard 3DSecure<\/hps:PaymentDataSource>/, data)
+ assert_match(/3DSecure<\/hps:TypeOfPaymentData>/, data)
+ assert_match(/#{options[:three_d_secure][:cavv]}<\/hps:PaymentData>/, data)
+ assert_match(/5<\/hps:ECommerceIndicator>/, data)
+ assert_match(/#{options[:three_d_secure][:xid]}<\/hps:XID>/, data)
+ end.respond_with(successful_charge_response)
+
+ assert_success response
+ assert_equal 'Success', response.message
+ end
+
+ def test_three_d_secure_discover
+ @credit_card.number = '6011000990156527'
+ @credit_card.brand = 'discover'
+
+ options = {
+ :three_d_secure => {
+ :cavv => 'EHuWW9PiBkWvqE5juRwDzAUFBAk=',
+ :eci => '5',
+ :xid => 'TTBCSkVTa1ZpbDI1bjRxbGk5ODE='
+ }
+ }
+
+ response = stub_comms(@gateway, :ssl_request) do
+ @gateway.purchase(@amount, @credit_card, options)
+ end.check_request do |method, endpoint, data, headers|
+ assert_match(/(.*)<\/hps:SecureECommerce>/, data)
+ assert_match(/Discover 3DSecure<\/hps:PaymentDataSource>/, data)
+ assert_match(/3DSecure<\/hps:TypeOfPaymentData>/, data)
+ assert_match(/#{options[:three_d_secure][:cavv]}<\/hps:PaymentData>/, data)
+ assert_match(/5<\/hps:ECommerceIndicator>/, data)
+ assert_match(/#{options[:three_d_secure][:xid]}<\/hps:XID>/, data)
+ end.respond_with(successful_charge_response)
+
+ assert_success response
+ assert_equal 'Success', response.message
+ end
+
+ def test_three_d_secure_amex
+ @credit_card.number = '372700699251018'
+ @credit_card.brand = 'american_express'
+
+ options = {
+ :three_d_secure => {
+ :cavv => 'EHuWW9PiBkWvqE5juRwDzAUFBAk=',
+ :eci => '05',
+ :xid => 'TTBCSkVTa1ZpbDI1bjRxbGk5ODE='
+ }
+ }
+
+ response = stub_comms(@gateway, :ssl_request) do
+ @gateway.purchase(@amount, @credit_card, options)
+ end.check_request do |method, endpoint, data, headers|
+ assert_match(/(.*)<\/hps:SecureECommerce>/, data)
+ assert_match(/AMEX 3DSecure<\/hps:PaymentDataSource>/, data)
+ assert_match(/3DSecure<\/hps:TypeOfPaymentData>/, data)
+ assert_match(/#{options[:three_d_secure][:cavv]}<\/hps:PaymentData>/, data)
+ assert_match(/5<\/hps:ECommerceIndicator>/, data)
+ assert_match(/#{options[:three_d_secure][:xid]}<\/hps:XID>/, data)
+ end.respond_with(successful_charge_response)
+
+ assert_success response
+ assert_equal 'Success', response.message
+ end
+
+ def test_three_d_secure_jcb
+ @credit_card.number = '372700699251018'
+ @credit_card.brand = 'jcb'
+
+ options = {
+ :three_d_secure => {
+ :cavv => 'EHuWW9PiBkWvqE5juRwDzAUFBAk=',
+ :eci => '5',
+ :xid => 'TTBCSkVTa1ZpbDI1bjRxbGk5ODE='
+ }
+ }
+
+ response = stub_comms(@gateway, :ssl_request) do
+ @gateway.purchase(@amount, @credit_card, options)
+ end.check_request do |method, endpoint, data, headers|
+ refute_match(/(.*)<\/hps:SecureECommerce>/, data)
+ refute_match(/(.*)<\/hps:PaymentDataSource>/, data)
+ refute_match(/3DSecure<\/hps:TypeOfPaymentData>/, data)
+ refute_match(/#{options[:three_d_secure][:cavv]}<\/hps:PaymentData>/, data)
+ refute_match(/5<\/hps:ECommerceIndicator>/, data)
+ refute_match(/#{options[:three_d_secure][:xid]}<\/hps:XID>/, data)
+ end.respond_with(successful_charge_response)
+
+ assert_success response
+ assert_equal 'Success', response.message
+ end
+
private
def successful_charge_response
@@ -269,6 +514,40 @@ def failed_charge_response
RESPONSE
end
+ def failed_charge_response_decline
+ <<-RESPONSE
+
+
+
+
+
+
+ 21229
+ 21232
+ 1525997
+ 16099851
+ 0
+ Success
+ 2014-03-17T13:01:55.851307
+
+
+
+ 05
+ DECLINE
+
+ 0
+ 407613674802
+ Visa
+ AVS Not Requested.
+
+
+
+
+
+
+ RESPONSE
+ end
+
def successful_authorize_response
<<-RESPONSE
@@ -341,6 +620,40 @@ def failed_authorize_response
RESPONSE
end
+ def failed_authorize_response_decline
+ <<-RESPONSE
+
+
+
+
+
+
+ 21229
+ 21232
+ 1525997
+ 16088893
+ 0
+ Success
+ 2014-03-17T13:06:45.449707
+
+
+
+ 05
+ DECLINE
+
+ 0
+ 407613674811
+ Visa
+ AVS Not Requested.
+
+
+
+
+
+
+ RESPONSE
+ end
+
def successful_capture_response
<<-RESPONSE
@@ -616,7 +929,7 @@ def pre_scrub
starting SSL for posgateway.cert.secureexchange.net:443...
SSL established
<- "POST /Hps.Exchange.PosGateway/PosGatewayService.asmx?wsdl HTTP/1.1\r\nContent-Type: text/xml\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: posgateway.cert.secureexchange.net\r\nContent-Length: 1295\r\n\r\n"
-<- "skapi_cert_MYl2AQAowiQAbLp5JesGKh7QFkcizOP2jcX9BrEMqQ1.00YLongbobLongsen456 My StreetOttawaONK1C2N6Store Purchase1400010001111222492019123NNN"
+<- "skapi_cert_MYl2AQAowiQAbLp5JesGKh7QFkcizOP2jcX9BrEMqQ1.00YLongbobLongsen456 My StreetOttawaONK1C2N6Store Purchase1400010001111222492019123NNNApplePay3DSecureEHuWW9PiBkWvqE5juRwDzAUFBAk5abc123"
-> "HTTP/1.1 200 OK\r\n"
-> "Cache-Control: private, max-age=0\r\n"
-> "Content-Type: text/xml; charset=utf-8\r\n"
@@ -646,7 +959,7 @@ def post_scrub
starting SSL for posgateway.cert.secureexchange.net:443...
SSL established
<- "POST /Hps.Exchange.PosGateway/PosGatewayService.asmx?wsdl HTTP/1.1\r\nContent-Type: text/xml\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: posgateway.cert.secureexchange.net\r\nContent-Length: 1295\r\n\r\n"
-<- "[FILTERED]1.00YLongbobLongsen456 My StreetOttawaONK1C2N6Store Purchase1[FILTERED]92019[FILTERED]NNN"
+<- "[FILTERED]1.00YLongbobLongsen456 My StreetOttawaONK1C2N6Store Purchase1[FILTERED]92019[FILTERED]NNNApplePay3DSecure[FILTERED]5abc123"
-> "HTTP/1.1 200 OK\r\n"
-> "Cache-Control: private, max-age=0\r\n"
-> "Content-Type: text/xml; charset=utf-8\r\n"
From 1d63f42b022aa79fc3e7b723237834b02b6d09f1 Mon Sep 17 00:00:00 2001
From: Hannah Deters
Date: Thu, 11 Jul 2019 15:08:15 -0400
Subject: [PATCH 0382/2234] CardConnect: Fix level 3 field parse
Remove underscores from level 3 gateway specific fields
ECS-397
Unit:
22 tests, 92 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
Remote:
23 tests, 55 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
Closes #3273
---
CHANGELOG | 1 +
.../billing/gateways/card_connect.rb | 1 +
.../gateways/remote_card_connect_test.rb | 20 +++++++++----------
3 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index a01d10b8bf8..2811722b46b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -32,6 +32,7 @@
* NMI: Correct password scrubber to scrub symbols [hdeters] #3267
* Global Collect: Only add name if present [curiousepic] #3268
* HPS: Add Apple Pay raw cryptogram support [slogsdon] #3209
+* CardConnect: Fix parsing of level 3 fields [hdeters] #3273
== Version 1.95.0 (May 23, 2019)
* Adyen: Constantize version to fix subdomains [curiousepic] #3228
diff --git a/lib/active_merchant/billing/gateways/card_connect.rb b/lib/active_merchant/billing/gateways/card_connect.rb
index e467d8dbf55..eb4a74daae0 100644
--- a/lib/active_merchant/billing/gateways/card_connect.rb
+++ b/lib/active_merchant/billing/gateways/card_connect.rb
@@ -233,6 +233,7 @@ def add_additional_data(post, options)
item.each_pair do |k, v|
updated.merge!(k.to_s.gsub(/_/, '') => v)
end
+ updated
end
end
end
diff --git a/test/remote/gateways/remote_card_connect_test.rb b/test/remote/gateways/remote_card_connect_test.rb
index 61f587cd168..4ec9496c19d 100644
--- a/test/remote/gateways/remote_card_connect_test.rb
+++ b/test/remote/gateways/remote_card_connect_test.rb
@@ -34,28 +34,28 @@ def test_successful_purchase_with_more_options
ship_from_date: '20877',
items: [
{
- line_no: '1',
+ lineno: '1',
material: 'MATERIAL-1',
description: 'DESCRIPTION-1',
upc: 'UPC-1',
quantity: '1000',
uom: 'CS',
- unit_cost: '900',
- net_amnt: '150',
- tax_amnt: '117',
- disc_amnt: '0'
+ unitcost: '900',
+ netamnt: '150',
+ taxamnt: '117',
+ discamnt: '0'
},
{
- line_no: '2',
+ lineno: '2',
material: 'MATERIAL-2',
description: 'DESCRIPTION-2',
upc: 'UPC-1',
quantity: '2000',
uom: 'CS',
- unit_cost: '450',
- net_amnt: '300',
- tax_amnt: '117',
- disc_amnt: '0'
+ unitcost: '450',
+ netamnt: '300',
+ taxamnt: '117',
+ discamnt: '0'
}
]
}
From ac192a1a2f9caff3f7ead62abd1bf2e47ffd5822 Mon Sep 17 00:00:00 2001
From: Jared Knipp
Date: Mon, 1 Jul 2019 12:55:19 -0500
Subject: [PATCH 0383/2234] Trust Commerce: Support void after purchase
Trust Commerce allows voids on purchases, refunds and captures, and
preauths. Preauth uses the 'reversal' function, while purchase, refund,
and capture use the Trust Commerce 'void' function'.
Expand void support for additional transaction types by tracking the
original action associated with the authorization transaction
id. The action take at Trust Commerce (reversal or void) is based on the
original action.
ECS-356
Unit:
12 tests, 41 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
17 tests, 64 assertions, 3 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
82.3529% passed
closes #3265
---
CHANGELOG | 1 +
.../billing/gateways/trust_commerce.rb | 29 +++++++++++++++----
.../gateways/remote_trust_commerce_test.rb | 12 ++++++++
test/unit/gateways/trust_commerce_test.rb | 25 +++++++++++++++-
4 files changed, 61 insertions(+), 6 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 2811722b46b..aef31d0274f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -33,6 +33,7 @@
* Global Collect: Only add name if present [curiousepic] #3268
* HPS: Add Apple Pay raw cryptogram support [slogsdon] #3209
* CardConnect: Fix parsing of level 3 fields [hdeters] #3273
+* TrustCommerce: Support void after purchase [jknipp] #3265
== Version 1.95.0 (May 23, 2019)
* Adyen: Constantize version to fix subdomains [curiousepic] #3228
diff --git a/lib/active_merchant/billing/gateways/trust_commerce.rb b/lib/active_merchant/billing/gateways/trust_commerce.rb
index 767fe06ccb9..d0e2e546039 100644
--- a/lib/active_merchant/billing/gateways/trust_commerce.rb
+++ b/lib/active_merchant/billing/gateways/trust_commerce.rb
@@ -104,6 +104,8 @@ class TrustCommerceGateway < Gateway
TEST_LOGIN = 'TestMerchant'
TEST_PASSWORD = 'password'
+ VOIDABLE_ACTIONS = %w(preauth sale postauth credit)
+
self.money_format = :cents
self.supported_cardtypes = [:visa, :master, :discover, :american_express, :diners_club, :jcb]
self.supported_countries = ['US']
@@ -179,9 +181,10 @@ def purchase(money, creditcard_or_billing_id, options = {})
# postauth, we preserve active_merchant's nomenclature of capture() for consistency with the rest of the library. To process
# a postauthorization with TC, you need an amount in cents or a money object, and a TC transid.
def capture(money, authorization, options = {})
+ transaction_id, _ = split_authorization(authorization)
parameters = {
:amount => amount(money),
- :transid => authorization,
+ :transid => transaction_id,
}
add_aggregator(parameters, options)
@@ -191,9 +194,10 @@ def capture(money, authorization, options = {})
# refund() allows you to return money to a card that was previously billed. You need to supply the amount, in cents or a money object,
# that you want to refund, and a TC transid for the transaction that you are refunding.
def refund(money, identification, options = {})
+ transaction_id, _ = split_authorization(identification)
parameters = {
:amount => amount(money),
- :transid => identification
+ :transid => transaction_id
}
add_aggregator(parameters, options)
@@ -214,18 +218,24 @@ def credit(money, identification, options = {})
# TrustCommerce to allow for reversal transactions before you can use this
# method.
#
+ # void() is also used to to cancel a capture (postauth), purchase (sale),
+ # or refund (credit) or a before it is sent for settlement.
+ #
# NOTE: AMEX preauth's cannot be reversed. If you want to clear it more
# quickly than the automatic expiration (7-10 days), you will have to
# capture it and then immediately issue a credit for the same amount
# which should clear the customers credit card with 48 hours according to
# TC.
def void(authorization, options = {})
+ transaction_id, original_action = split_authorization(authorization)
+ action = (VOIDABLE_ACTIONS - ['preauth']).include?(original_action) ? 'void' : 'reversal'
+
parameters = {
- :transid => authorization,
+ :transid => transaction_id,
}
add_aggregator(parameters, options)
- commit('reversal', parameters)
+ commit(action, parameters)
end
# recurring() a TrustCommerce account that is activated for Citadel, TrustCommerce's
@@ -416,7 +426,7 @@ def commit(action, parameters)
message = message_from(data)
Response.new(success, message, data,
:test => test?,
- :authorization => data['transid'],
+ :authorization => authorization_from(action, data),
:cvv_result => data['cvv'],
:avs_result => { :code => data['avs'] }
)
@@ -446,6 +456,15 @@ def message_from(data)
end
end
+ def authorization_from(action, data)
+ authorization = data['transid']
+ authorization = "#{authorization}|#{action}" if authorization && VOIDABLE_ACTIONS.include?(action)
+ authorization
+ end
+
+ def split_authorization(authorization)
+ authorization.split('|')
+ end
end
end
end
diff --git a/test/remote/gateways/remote_trust_commerce_test.rb b/test/remote/gateways/remote_trust_commerce_test.rb
index 196ffe26c7f..04d419b0a56 100644
--- a/test/remote/gateways/remote_trust_commerce_test.rb
+++ b/test/remote/gateways/remote_trust_commerce_test.rb
@@ -84,6 +84,18 @@ def test_purchase_with_avs_for_invalid_address
assert_success response
end
+ # Requires enabling the setting: 'Allow voids to process or settle on processing node' in the Trust Commerce vault UI
+ def test_purchase_and_void
+ purchase = @gateway.purchase(@amount, @credit_card, @options)
+ assert_success purchase
+
+ void = @gateway.void(purchase.authorization)
+ assert_success void
+ assert_equal 'The transaction was successful', void.message
+ assert_equal 'accepted', void.params['status']
+ assert void.params['transid']
+ end
+
def test_successful_authorize_with_avs
assert response = @gateway.authorize(@amount, @credit_card, :billing_address => @valid_address)
diff --git a/test/unit/gateways/trust_commerce_test.rb b/test/unit/gateways/trust_commerce_test.rb
index 9221ae96d46..b201a585786 100644
--- a/test/unit/gateways/trust_commerce_test.rb
+++ b/test/unit/gateways/trust_commerce_test.rb
@@ -21,7 +21,7 @@ def test_successful_purchase
assert response = @gateway.purchase(@amount, @credit_card)
assert_instance_of Response, response
assert_success response
- assert_equal '025-0007423614', response.authorization
+ assert_equal '025-0007423614|sale', response.authorization
end
def test_unsuccessful_purchase
@@ -41,6 +41,22 @@ def test_succesful_purchase_with_check
end.respond_with(successful_purchase_response)
end
+ def test_successful_void_from_purchase
+ stub_comms do
+ @gateway.void('1235|sale')
+ end.check_request do |endpoint, data, headers|
+ assert_match(%r{action=void}, data)
+ end.respond_with(successful_void_response)
+ end
+
+ def test_successful_void_from_authorize
+ stub_comms do
+ @gateway.void('1235|preauth')
+ end.check_request do |endpoint, data, headers|
+ assert_match(%r{action=reversal}, data)
+ end.respond_with(successful_void_response)
+ end
+
def test_amount_style
assert_equal '1034', @gateway.send(:amount, 1034)
@@ -105,6 +121,13 @@ def unsuccessful_purchase_response
RESPONSE
end
+ def successful_void_response
+ <<-RESPONSE
+transid=025-0007423828
+status=accpeted
+ RESPONSE
+ end
+
def transcript
<<-TRANSCRIPT
action=sale&demo=y&password=password&custid=TestMerchant&shipto_zip=90001&shipto_state=CA&shipto_city=Somewhere&shipto_address1=123+Test+St.&avs=n&zip=90001&state=CA&city=Somewhere&address1=123+Test+St.&cvv=1234&exp=0916&cc=4111111111111111&name=Longbob+Longsen&media=cc&ip=10.10.10.10&email=cody%40example.com&ticket=%231000.1&amount=100
From d8ec68d7eaf8be45de462250450548d0e70b7a81 Mon Sep 17 00:00:00 2001
From: Ruthan
Date: Thu, 11 Jul 2019 15:08:38 -0400
Subject: [PATCH 0384/2234] Payflow: Support arbitrary L2/L3 fields
---
.../billing/gateways/payflow.rb | 42 +++++-
test/remote/gateways/remote_payflow_test.rb | 51 ++++++++
test/unit/gateways/payflow_test.rb | 120 ++++++++++++++++++
3 files changed, 211 insertions(+), 2 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/payflow.rb b/lib/active_merchant/billing/gateways/payflow.rb
index 3123693a84d..709cd19ef45 100644
--- a/lib/active_merchant/billing/gateways/payflow.rb
+++ b/lib/active_merchant/billing/gateways/payflow.rb
@@ -1,3 +1,4 @@
+require 'nokogiri'
require 'active_merchant/billing/gateways/payflow/payflow_common_api'
require 'active_merchant/billing/gateways/payflow/payflow_response'
require 'active_merchant/billing/gateways/payflow_express'
@@ -187,7 +188,44 @@ def build_credit_card_request(action, money, credit_card, options)
end
end
end
- xml.target!
+ add_level_two_three_fields(xml.target!, options)
+ end
+
+ def add_level_two_three_fields(xml_string, options)
+ if options[:level_two_fields] || options[:level_three_fields]
+ xml_doc = Nokogiri::XML.parse(xml_string)
+ %i[level_two_fields level_three_fields].each do |fields|
+ xml_string = add_fields(xml_doc, options[fields]) if options[fields]
+ end
+ end
+ xml_string
+ end
+
+ def check_fields(parent, fields, xml_doc)
+ fields.each do |k, v|
+ if v.is_a? String
+ new_node = Nokogiri::XML::Node.new(k, xml_doc)
+ new_node.add_child(v)
+ xml_doc.at_css(parent).add_child(new_node)
+ else
+ check_subparent_before_continuing(parent, k, xml_doc)
+ check_fields(k, v, xml_doc)
+ end
+ end
+ xml_doc
+ end
+
+ def check_subparent_before_continuing(parent, subparent, xml_doc)
+ unless xml_doc.at_css(subparent)
+ subparent_node = Nokogiri::XML::Node.new(subparent, xml_doc)
+ xml_doc.at_css(parent).add_child(subparent_node)
+ end
+ end
+
+ def add_fields(xml_doc, options_fields)
+ fields_to_add = JSON.parse(options_fields)
+ check_fields('Invoice', fields_to_add, xml_doc)
+ xml_doc.root.to_s
end
def build_check_request(action, money, check, options)
@@ -213,7 +251,7 @@ def build_check_request(action, money, check, options)
end
end
end
- xml.target!
+ add_level_two_three_fields(xml.target!, options)
end
def add_credit_card(xml, credit_card, options = {})
diff --git a/test/remote/gateways/remote_payflow_test.rb b/test/remote/gateways/remote_payflow_test.rb
index 6104f8e45bd..e1370e4d4ce 100644
--- a/test/remote/gateways/remote_payflow_test.rb
+++ b/test/remote/gateways/remote_payflow_test.rb
@@ -29,6 +29,27 @@ def setup
:routing_number => '111111118',
:account_number => '1111111111'
)
+
+ @l2_json = '{
+ "Tender": {
+ "ACH": {
+ "AcctType": "C",
+ "AcctNum": "6355059797",
+ "ABA": "021000021"
+ }
+ }
+ }'
+
+ @l3_json = '{
+ "Invoice": {
+ "Date": "20190104",
+ "Level3Invoice": {
+ "CountyTax": {"Amount": "3.23"}
+ },
+ "Items":
+ "- 11119999Widget2INQ49.999.983.008.00101.00 500 Main St.AnytownNY67890US2003063024680ABC01232003071454.10.15.05
- 22228888Gizmo5INQ9.992.503.002.5052.95 500 Main St.AnytownNY67890US2003062813579XYZ78902003071154.10.16.05
"
+ }
+ }'
end
def test_successful_purchase
@@ -68,6 +89,36 @@ def test_successful_purchase_with_fraud_review
assert response.fraud_review?
end
+ def test_successful_purchase_with_l2_fields
+ options = @options.merge(level_two_fields: @l2_json)
+
+ assert response = @gateway.purchase(100000, @credit_card, options)
+ assert_equal 'Approved', response.message
+ assert_success response
+ assert response.test?
+ assert_not_nil response.authorization
+ end
+
+ def test_successful_purchase_with_l3_fields
+ options = @options.merge(level_three_fields: @l3_json)
+
+ assert response = @gateway.purchase(100000, @credit_card, options)
+ assert_equal 'Approved', response.message
+ assert_success response
+ assert response.test?
+ assert_not_nil response.authorization
+ end
+
+ def test_successful_purchase_with_l2_l3_fields
+ options = @options.merge(level_two_fields: @l2_json).merge(level_three_fields: @l3_json)
+
+ assert response = @gateway.purchase(100000, @credit_card, options)
+ assert_equal 'Approved', response.message
+ assert_success response
+ assert response.test?
+ assert_not_nil response.authorization
+ end
+
def test_declined_purchase
assert response = @gateway.purchase(210000, @credit_card, @options)
assert_equal 'Declined', response.message
diff --git a/test/unit/gateways/payflow_test.rb b/test/unit/gateways/payflow_test.rb
index 01a4ed9cb0b..6c03e4c18e9 100644
--- a/test/unit/gateways/payflow_test.rb
+++ b/test/unit/gateways/payflow_test.rb
@@ -15,6 +15,24 @@ def setup
@credit_card = credit_card('4242424242424242')
@options = { :billing_address => address.merge(:first_name => 'Longbob', :last_name => 'Longsen') }
@check = check(:name => 'Jim Smith')
+ @l2_json = '{
+ "Tender": {
+ "ACH": {
+ "AcctType": "C",
+ "AcctNum": "6355059797",
+ "ABA": "021000021"
+ }
+ }
+ }'
+
+ @l3_json = '{
+ "Invoice": {
+ "Date": "20190104",
+ "Level3Invoice": {
+ "CountyTax": {"Amount": "3.23"}
+ }
+ }
+ }'
end
def test_successful_authorization
@@ -97,6 +115,55 @@ def test_successful_purchase_with_three_d_secure_option
assert response.fraud_review?
end
+ def test_successful_purchase_with_level_2_fields
+ options = @options.merge(level_two_fields: @l2_json)
+
+ response = stub_comms do
+ @gateway.purchase(@amount, @credit_card, options)
+ end.check_request do |endpoint, data, headers|
+ assert_match %r(6355059797), data
+ assert_match %r(), data.tr("\n ", '')
+ end.respond_with(successful_l2_response)
+ assert_equal 'Approved', response.message
+ assert_success response
+ assert_equal 'A1ADADCE9B12', response.authorization
+ refute response.fraud_review?
+ end
+
+ def test_successful_purchase_with_level_3_fields
+ options = @options.merge(level_three_fields: @l3_json)
+
+ response = stub_comms do
+ @gateway.purchase(@amount, @credit_card, options)
+ end.check_request do |endpoint, data, headers|
+ assert_match %r(20190104), data
+ assert_match %r(3.23), data
+ assert_match %r(), data.tr("\n ", '')
+ end.respond_with(successful_l3_response)
+ assert_equal 'Approved', response.message
+ assert_success response
+ assert_equal 'A71AAC3B60A1', response.authorization
+ refute response.fraud_review?
+ end
+
+ def test_successful_purchase_with_level_2_3_fields
+ options = @options.merge(level_two_fields: @l2_json).merge(level_three_fields: @l3_json)
+
+ response = stub_comms do
+ @gateway.purchase(@amount, @credit_card, options)
+ end.check_request do |endpoint, data, headers|
+ assert_match %r(20190104), data
+ assert_match %r(3.23), data
+ assert_match %r(6355059797), data
+ assert_match %r(), data.tr("\n ", '')
+ assert_match %r(), data.tr("\n ", '')
+ end.respond_with(successful_l2_response)
+ assert_equal 'Approved', response.message
+ assert_success response
+ assert_equal 'A1ADADCE9B12', response.authorization
+ refute response.fraud_review?
+ end
+
def test_credit
@gateway.expects(:ssl_post).with(anything, regexp_matches(/#{@credit_card.number}<\//), anything).returns('')
@gateway.expects(:parse).returns({})
@@ -606,6 +673,59 @@ def successful_authorization_response
XML
end
+ def successful_l3_response
+ <<-XML
+
+ spreedlyIntegrations
+ paypal
+
+
+ 0
+
+ Z
+ M
+ A
+
+
+ No Rules Triggered
+
+
+ No Rules Triggered
+
+ N
+
+ No Match
+ Match
+
+ Match
+ Approved
+ A71AAC3B60A1
+ 240PNI
+
+
+
+ XML
+ end
+
+ def successful_l2_response
+ <<-XML
+
+ spreedlyIntegrations
+ paypal
+
+
+ 0
+
+ A
+
+ Approved
+ A1ADADCE9B12
+
+
+
+ XML
+ end
+
def failed_authorization_response
<<-XML
From e15d4d8914c797b604e8be32dd9ea5ae075305ff Mon Sep 17 00:00:00 2001
From: Ruthan
Date: Mon, 15 Jul 2019 13:30:13 -0400
Subject: [PATCH 0385/2234] Update Changelog for 3272
---
CHANGELOG | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG b/CHANGELOG
index aef31d0274f..1e96375e60a 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -34,6 +34,7 @@
* HPS: Add Apple Pay raw cryptogram support [slogsdon] #3209
* CardConnect: Fix parsing of level 3 fields [hdeters] #3273
* TrustCommerce: Support void after purchase [jknipp] #3265
+* Payflow: Support arbitrary level 2 + level 3 fields [therufs] #3272
== Version 1.95.0 (May 23, 2019)
* Adyen: Constantize version to fix subdomains [curiousepic] #3228
From c120007d5778413d38f72b0661ddfc283683c1e0 Mon Sep 17 00:00:00 2001
From: molbrown
Date: Tue, 9 Jul 2019 15:35:46 -0400
Subject: [PATCH 0386/2234] BlueSnap: Default to not send amount on capture
Including an amount on capture can cause an issue if attempting to
capture full amount authorized and there are slight differences in
amount requested and amount actually authorized due to currency
exchange. BlueSnap will capture full amount authorized if no amount is
included in the capture request. Adds a flag for including the amount
only in the case of partial capture.
Continues ECS-454
Relates to ECS-430
Unit:
27 tests, 110 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
35 tests, 109 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/blue_snap.rb | 2 +-
test/unit/gateways/blue_snap_test.rb | 12 ++++++++++++
3 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 1e96375e60a..401d266d4f4 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -35,6 +35,7 @@
* CardConnect: Fix parsing of level 3 fields [hdeters] #3273
* TrustCommerce: Support void after purchase [jknipp] #3265
* Payflow: Support arbitrary level 2 + level 3 fields [therufs] #3272
+* BlueSnap: Default to not send amount on capture [molbrown] #3270
== Version 1.95.0 (May 23, 2019)
* Adyen: Constantize version to fix subdomains [curiousepic] #3228
diff --git a/lib/active_merchant/billing/gateways/blue_snap.rb b/lib/active_merchant/billing/gateways/blue_snap.rb
index e4c2f5b6ea6..97aa8fae10c 100644
--- a/lib/active_merchant/billing/gateways/blue_snap.rb
+++ b/lib/active_merchant/billing/gateways/blue_snap.rb
@@ -95,7 +95,7 @@ def capture(money, authorization, options={})
commit(:capture, :put) do |doc|
add_authorization(doc, authorization)
add_order(doc, options)
- add_amount(doc, money, options)
+ add_amount(doc, money, options) if options[:include_capture_amount] == true
end
end
diff --git a/test/unit/gateways/blue_snap_test.rb b/test/unit/gateways/blue_snap_test.rb
index 737c45d11e2..3a67d86da8a 100644
--- a/test/unit/gateways/blue_snap_test.rb
+++ b/test/unit/gateways/blue_snap_test.rb
@@ -93,6 +93,18 @@ def test_failed_authorize
def test_successful_capture
response = stub_comms(@gateway, :raw_ssl_request) do
@gateway.capture(@amount, @credit_card, @options)
+ end.check_request do |method, url, data|
+ assert_not_match(/1.00<\/amount>/, data)
+ assert_not_match(/USD<\/currency>/, data)
+ end.respond_with(successful_capture_response)
+
+ assert_success response
+ assert_equal '1012082881', response.authorization
+ end
+
+ def test_successful_partial_capture
+ response = stub_comms(@gateway, :raw_ssl_request) do
+ @gateway.capture(@amount, @credit_card, @options.merge(include_capture_amount: true))
end.check_request do |method, url, data|
assert_match(/1.00<\/amount>/, data)
assert_match(/USD<\/currency>/, data)
From a45b7157039f4f7a013482998c3e178bdd2c6906 Mon Sep 17 00:00:00 2001
From: Nathan Verni
Date: Tue, 16 Jul 2019 14:39:36 -0400
Subject: [PATCH 0387/2234] OPP: Adds support for store (#3253)
---
lib/active_merchant/billing/gateways/opp.rb | 21 +++-
test/unit/gateways/opp_test.rb | 107 ++++++++++++++++++--
2 files changed, 120 insertions(+), 8 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/opp.rb b/lib/active_merchant/billing/gateways/opp.rb
index 8c82574a670..cdd4900e729 100644
--- a/lib/active_merchant/billing/gateways/opp.rb
+++ b/lib/active_merchant/billing/gateways/opp.rb
@@ -125,6 +125,9 @@ def initialize(options={})
def purchase(money, payment, options={})
# debit
+ if payment.is_a?(String)
+ options[:registrationId] = payment
+ end
execute_dbpa(options[:risk_workflow] ? 'PA.CP': 'DB',
money, payment, options)
end
@@ -156,6 +159,10 @@ def verify(credit_card, options={})
end
end
+ def store(credit_card, options = {})
+ execute_store(credit_card, options.merge(store: true))
+ end
+
def supports_scrubbing?
true
end
@@ -169,6 +176,15 @@ def scrub(transcript)
private
+ def execute_store(payment, options)
+ post = {}
+ add_payment_method(post, payment, options)
+ add_address(post, options)
+ add_options(post, options)
+ add_3d_secure(post, options)
+ commit(post, nil, options)
+ end
+
def execute_dbpa(txtype, money, payment, options)
post = {}
post[:paymentType] = txtype
@@ -243,6 +259,7 @@ def add_invoice(post, money, options)
end
def add_payment_method(post, payment, options)
+ return if payment.is_a?(String)
if options[:registrationId]
post[:card] = {
cvv: payment.verification_value,
@@ -278,7 +295,9 @@ def add_options(post, options)
end
def build_url(url, authorization, options)
- if options[:registrationId]
+ if options[:store]
+ url.gsub(/payments/, 'registrations')
+ elsif options[:registrationId]
"#{url.gsub(/payments/, 'registrations')}/#{options[:registrationId]}/payments"
elsif authorization
"#{url}/#{authorization}"
diff --git a/test/unit/gateways/opp_test.rb b/test/unit/gateways/opp_test.rb
index a59885917d5..28efb3e2d72 100644
--- a/test/unit/gateways/opp_test.rb
+++ b/test/unit/gateways/opp_test.rb
@@ -121,6 +121,14 @@ def test_successful_void
assert void.test?
end
+ def test_successful_store
+ @gateway.expects(:raw_ssl_request).returns(successful_store_response(@test_success_id))
+ store = @gateway.store(@valid_card)
+ assert_success store
+ assert_equal "Request successfully processed in 'Merchant in Integrator Test Mode'", store.message
+ assert_equal @test_success_id, store.authorization
+ end
+
# ****************************************** FAILURE TESTS ******************************************
def test_failed_purchase
@gateway.expects(:raw_ssl_request).returns(failed_response('DB', @test_failure_id))
@@ -157,6 +165,13 @@ def test_failed_void
assert_equal '100.100.101', response.error_code
end
+ def test_failed_store
+ @gateway.expects(:raw_ssl_request).returns(failed_store_response(@test_failure_id))
+ store = @gateway.store(@invalid_card)
+ assert_failure store
+ assert_equal '100.100.101', store.error_code
+ end
+
def test_passes_3d_secure_fields
options = @complete_request_options.merge({eci: 'eci', cavv: 'cavv', xid: 'xid'})
@@ -188,18 +203,96 @@ def post_scrubbed
def successful_response(type, id)
OppMockResponse.new(200,
- JSON.generate({'id' => id, 'paymentType' => type, 'paymentBrand' => 'VISA', 'amount' => '1.00', 'currency' => 'EUR', "des
- criptor" => '5410.9959.0306 OPP_Channel ', 'result' => {'code' => '000.100.110', 'description' => "Request successfully processed in 'Merchant in Integrator Test Mode'"}, 'card' => {"bin
- " => '420000', 'last4Digits' => '0000', 'holder' => 'Longbob Longsen', 'expiryMonth' => '05', 'expiryYear' => '2018'}, 'buildNumber' => '20150618-111601.r185004.opp-tags-20150618_stage', "time
- stamp" => '2015-06-20 19:31:01+0000', 'ndc' => '8a8294174b7ecb28014b9699220015ca_4453edbc001f405da557c05cb3c3add9'})
+ JSON.generate({
+ 'id' => id,
+ 'paymentType' => type,
+ 'paymentBrand' => 'VISA',
+ 'amount' => '1.00',
+ 'currency' => 'EUR',
+ 'descriptor' => '5410.9959.0306 OPP_Channel',
+ 'result' => {
+ 'code' => '000.100.110',
+ 'description' => "Request successfully processed in 'Merchant in Integrator Test Mode'"
+ },
+ 'card' => {
+ 'bin' => '420000',
+ 'last4Digits' => '0000',
+ 'holder' => 'Longbob Longsen',
+ 'expiryMonth' => '05',
+ 'expiryYear' => '2018'
+ },
+ 'buildNumber' => '20150618-111601.r185004.opp-tags-20150618_stage',
+ 'timestamp' => '2015-06-20 19:31:01+0000',
+ 'ndc' => '8a8294174b7ecb28014b9699220015ca_4453edbc001f405da557c05cb3c3add9'
+ })
+ )
+ end
+
+ def successful_store_response(id)
+ OppMockResponse.new(200,
+ JSON.generate({
+ 'id' => id,
+ 'result' => {
+ 'code' => '000.100.110',
+ 'description' => "Request successfully processed in 'Merchant in Integrator Test Mode'"
+ },
+ 'card' => {
+ 'bin' => '420000',
+ 'last4Digits' => '0000',
+ 'holder' => 'Longbob Longsen',
+ 'expiryMonth' => '05',
+ 'expiryYear' => '2018'
+ },
+ 'buildNumber' => '20150618-111601.r185004.opp-tags-20150618_stage',
+ 'timestamp' => '2015-06-20 19:31:01+0000',
+ 'ndc' => '8a8294174b7ecb28014b9699220015ca_4453edbc001f405da557c05cb3c3add9'
+ })
)
end
def failed_response(type, id, code='100.100.101')
OppMockResponse.new(400,
- JSON.generate({'id' => id, 'paymentType' => type, 'paymentBrand' => 'VISA', 'result' => {'code' => code, "des
- cription" => 'invalid creditcard, bank account number or bank name'}, 'card' => {'bin' => '444444', 'last4Digits' => '4444', 'holder' => 'Longbob Longsen', 'expiryMonth' => '05', 'expiryYear' => '2018'},
- 'buildNumber' => '20150618-111601.r185004.opp-tags-20150618_stage', 'timestamp' => '2015-06-20 20:40:26+0000', 'ndc' => '8a8294174b7ecb28014b9699220015ca_5200332e7d664412a84ed5f4777b3c7d'})
+ JSON.generate({
+ 'id' => id,
+ 'paymentType' => type,
+ 'paymentBrand' => 'VISA',
+ 'result' => {
+ 'code' => code,
+ 'description' => 'invalid creditcard, bank account number or bank name'
+ },
+ 'card' => {
+ 'bin' => '444444',
+ 'last4Digits' => '4444',
+ 'holder' => 'Longbob Longsen',
+ 'expiryMonth' => '05',
+ 'expiryYear' => '2018'
+ },
+ 'buildNumber' => '20150618-111601.r185004.opp-tags-20150618_stage',
+ 'timestamp' => '2015-06-20 20:40:26+0000',
+ 'ndc' => '8a8294174b7ecb28014b9699220015ca_5200332e7d664412a84ed5f4777b3c7d'
+ })
+ )
+ end
+
+ def failed_store_response(id, code='100.100.101')
+ OppMockResponse.new(400,
+ JSON.generate({
+ 'id' => id,
+ 'result' => {
+ 'code' => code,
+ 'description' => 'invalid creditcard, bank account number or bank name'
+ },
+ 'card' => {
+ 'bin' => '444444',
+ 'last4Digits' => '4444',
+ 'holder' => 'Longbob Longsen',
+ 'expiryMonth' => '05',
+ 'expiryYear' => '2018'
+ },
+ 'buildNumber' => '20150618-111601.r185004.opp-tags-20150618_stage',
+ 'timestamp' => '2015-06-20 20:40:26+0000',
+ 'ndc' => '8a8294174b7ecb28014b9699220015ca_5200332e7d664412a84ed5f4777b3c7d'
+ })
)
end
From 86182b1189ec0818c0892e9429b47a7af7b74ff2 Mon Sep 17 00:00:00 2001
From: Chris Kruger
Date: Wed, 17 Jul 2019 16:50:01 -0400
Subject: [PATCH 0388/2234] Spreedly: extra fields, remove extraneous check
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/spreedly_core.rb | 8 ++++++++
2 files changed, 9 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index 401d266d4f4..bc391dab081 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -36,6 +36,7 @@
* TrustCommerce: Support void after purchase [jknipp] #3265
* Payflow: Support arbitrary level 2 + level 3 fields [therufs] #3272
* BlueSnap: Default to not send amount on capture [molbrown] #3270
+* Spreedly: extra fields, remove extraneous check [montdidier] #3102 #3281
== Version 1.95.0 (May 23, 2019)
* Adyen: Constantize version to fix subdomains [curiousepic] #3228
diff --git a/lib/active_merchant/billing/gateways/spreedly_core.rb b/lib/active_merchant/billing/gateways/spreedly_core.rb
index 47175cc2194..92e3f5ccbcc 100644
--- a/lib/active_merchant/billing/gateways/spreedly_core.rb
+++ b/lib/active_merchant/billing/gateways/spreedly_core.rb
@@ -67,6 +67,7 @@ def capture(money, authorization, options={})
def refund(money, authorization, options={})
request = build_xml_request('transaction') do |doc|
add_invoice(doc, money, options)
+ add_extra_options(:gateway_specific_fields, doc, options)
end
commit("transactions/#{authorization}/credit.xml", request)
@@ -171,6 +172,13 @@ def add_invoice(doc, money, options)
doc.order_id(options[:order_id])
doc.ip(options[:ip]) if options[:ip]
doc.description(options[:description]) if options[:description]
+
+ if options[:merchant_name_descriptor]
+ doc.merchant_name_descriptor(options[:merchant_name_descriptor])
+ end
+ if options[:merchant_location_descriptor]
+ doc.merchant_location_descriptor(options[:merchant_location_descriptor])
+ end
end
def add_payment_method(doc, payment_method, options)
From 374a82c53844670dd557763285993a2a4886607c Mon Sep 17 00:00:00 2001
From: leila-alderman
Date: Tue, 16 Jul 2019 15:35:35 -0400
Subject: [PATCH 0389/2234] CECAbank: Update encryption to SHA2
Updated the encryption method for the CECAbank gateway from SHA1 to
SHA2. This change also included updating the URLs for the gateway and
revising the remote tests to work with the new URL.
CE-23
Unit:
7 tests, 36 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
Remote:
5 tests, 17 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/cecabank.rb | 14 +++++++-------
test/remote/gateways/remote_cecabank_test.rb | 19 +++++++++----------
3 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index bc391dab081..70683aaf1fd 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -37,6 +37,7 @@
* Payflow: Support arbitrary level 2 + level 3 fields [therufs] #3272
* BlueSnap: Default to not send amount on capture [molbrown] #3270
* Spreedly: extra fields, remove extraneous check [montdidier] #3102 #3281
+* Cecabank: Update encryption to SHA2 [leila-alderman] #3278
== Version 1.95.0 (May 23, 2019)
* Adyen: Constantize version to fix subdomains [curiousepic] #3228
diff --git a/lib/active_merchant/billing/gateways/cecabank.rb b/lib/active_merchant/billing/gateways/cecabank.rb
index ba73965d48a..b09ed92c37a 100644
--- a/lib/active_merchant/billing/gateways/cecabank.rb
+++ b/lib/active_merchant/billing/gateways/cecabank.rb
@@ -1,7 +1,7 @@
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
class CecabankGateway < Gateway
- self.test_url = 'http://tpv.ceca.es:8000'
+ self.test_url = 'https://tpv.ceca.es'
self.live_url = 'https://pgw.ceca.es'
self.supported_countries = ['ES']
@@ -13,14 +13,14 @@ class CecabankGateway < Gateway
#### CECA's MAGIC NUMBERS
CECA_NOTIFICATIONS_URL = 'NONE'
- CECA_ENCRIPTION = 'SHA1'
+ CECA_ENCRIPTION = 'SHA2'
CECA_DECIMALS = '2'
CECA_MODE = 'SSL'
CECA_UI_LESS_LANGUAGE = 'XML'
CECA_UI_LESS_LANGUAGE_REFUND = '1'
CECA_UI_LESS_REFUND_PAGE = 'anulacion_xml'
- CECA_ACTION_REFUND = 'tpvanularparcialmente' # use partial refund's URL to avoid time frame limitations and decision logic on client side
- CECA_ACTION_PURCHASE = 'tpv'
+ CECA_ACTION_REFUND = 'anulaciones/anularParcial' # use partial refund's URL to avoid time frame limitations and decision logic on client side
+ CECA_ACTION_PURCHASE = 'tpv/compra'
CECA_CURRENCIES_DICTIONARY = {'EUR' => 978, 'USD' => 840, 'GBP' => 826}
# Creates a new CecabankGateway
@@ -168,8 +168,8 @@ def commit(action, parameters)
'AcquirerBIN' => options[:acquirer_bin],
'TerminalID' => options[:terminal_id]
)
- url = (test? ? self.test_url : self.live_url) + "/cgi-bin/#{action}"
- xml = ssl_post(url, post_data(parameters))
+ url = (test? ? self.test_url : self.live_url) + "/tpvweb/#{action}.action"
+ xml = ssl_post("#{url}?", post_data(parameters))
response = parse(xml)
Response.new(
response[:success],
@@ -242,7 +242,7 @@ def generate_signature(action, parameters)
CECA_NOTIFICATIONS_URL +
CECA_NOTIFICATIONS_URL
end
- Digest::SHA1.hexdigest(signature_fields)
+ Digest::SHA2.hexdigest(signature_fields)
end
end
end
diff --git a/test/remote/gateways/remote_cecabank_test.rb b/test/remote/gateways/remote_cecabank_test.rb
index 108fb3ea106..b44ff568ead 100644
--- a/test/remote/gateways/remote_cecabank_test.rb
+++ b/test/remote/gateways/remote_cecabank_test.rb
@@ -23,7 +23,7 @@ def test_successful_purchase
def test_unsuccessful_purchase
assert response = @gateway.purchase(@amount, @declined_card, @options)
assert_failure response
- assert_equal 'ERROR', response.message
+ assert_match 'ERROR', response.message
end
def test_successful_refund
@@ -36,20 +36,19 @@ def test_successful_refund
end
def test_unsuccessful_refund
- assert response = @gateway.refund(@amount, 'wrongreference', @options)
+ purchase = @gateway.purchase(@amount, @credit_card, @options)
+ assert_success purchase
+
+ assert response = @gateway.refund(@amount, purchase.authorization, @options.merge(currency: 'USD'))
assert_failure response
- assert_equal 'ERROR', response.message
+ assert_match 'ERROR', response.message
end
def test_invalid_login
- gateway = CecabankGateway.new(
- :merchant_id => '',
- :acquirer_bin => '',
- :terminal_id => '',
- :key => ''
- )
+ gateway = CecabankGateway.new(fixtures(:cecabank).merge(key: 'invalid'))
+
assert response = gateway.purchase(@amount, @credit_card, @options)
assert_failure response
- assert_equal 'ERROR', response.message
+ assert_match 'ERROR', response.message
end
end
From 95f412b9a74a6430b8bd8a7cb11d9ba44626b352 Mon Sep 17 00:00:00 2001
From: Nicolas Maalouf
Date: Thu, 18 Jul 2019 20:31:36 +0100
Subject: [PATCH 0390/2234] Update Checkout.com integration for 3DS (#3240)
* Fix Checkout.com V2 Sandbox URL
* Fix success response code validation
* Fix success response code validation v2
* Improve success response validation logic
* Add list of currencies without fractions
* Add localized_amount support to add_invoice function
* Remove redefinition of currencies_without_fractions
* Add test for Void Authorize with AVS rule
* Align with main repo
* Migrate to unified payments API
* Add 3rd party MPI 3DS support
* Migrate tests to Unified Payments API
* Add third party MPI tests
* Fix 3DS test syntax error
* Syntax fixes
* Fix metadata array initialisation
* Test fixes
* Update response success validation. Fix test
* Fix billing_descriptor conditional inclusion
* Improve payment source identification
* Refund payment ID fix
* Fix setting response ID for capture actions
* Fix remote tests
* Retrieve payment ID from capture responses
* Fix 3DS payload handling
* Fix 3DS syntax error
* Move capture conditional payment ID to successful responses only
* Fix condition to parse payment ID from href link
* Remove trailing whitespaces
* Empty line removed
* Fix metadata
* Block empty strings from being submitted in billing address
* Fix success_from handling for declined payments
* Fix phone number formatting
* Align checkout_v2 to master
* Add version field in 3rd party MPI 3DS support along with ds_transaction_id for supporting 3ds2 results
* Fix 3ds implementation. Update tests
---
.../billing/gateways/checkout_v2.rb | 7 ++--
.../gateways/remote_checkout_v2_test.rb | 26 +++++++++++++--
test/unit/gateways/checkout_v2_test.rb | 33 +++++++++++++++++--
3 files changed, 57 insertions(+), 9 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/checkout_v2.rb b/lib/active_merchant/billing/gateways/checkout_v2.rb
index f75348965c2..9c5c1a190a0 100644
--- a/lib/active_merchant/billing/gateways/checkout_v2.rb
+++ b/lib/active_merchant/billing/gateways/checkout_v2.rb
@@ -131,9 +131,10 @@ def add_3ds(post, options)
if options[:three_d_secure]
post[:'3ds'] = {}
post[:'3ds'][:enabled] = true
- post[:'3ds'][:eci] = options[:eci] if options[:eci]
- post[:'3ds'][:cryptogram] = options[:cavv] if options[:cavv]
- post[:'3ds'][:xid] = options[:xid] if options[:xid]
+ post[:'3ds'][:eci] = options[:three_d_secure][:eci] if options[:three_d_secure][:eci]
+ post[:'3ds'][:cryptogram] = options[:three_d_secure][:cavv] if options[:three_d_secure][:cavv]
+ post[:'3ds'][:version] = options[:three_d_secure][:version] if options[:three_d_secure][:version]
+ post[:'3ds'][:xid] = options[:three_d_secure][:ds_transaction_id] || options[:three_d_secure][:xid]
end
end
diff --git a/test/remote/gateways/remote_checkout_v2_test.rb b/test/remote/gateways/remote_checkout_v2_test.rb
index 94e3762ce20..c8b40ca569e 100644
--- a/test/remote/gateways/remote_checkout_v2_test.rb
+++ b/test/remote/gateways/remote_checkout_v2_test.rb
@@ -22,9 +22,21 @@ def setup
)
@additional_options_3ds = @options.merge(
execute_threed: true,
- eci: '05',
- cryptogram: '1234',
- xid: '1234'
+ three_d_secure: {
+ version: '1.0.2',
+ eci: '06',
+ cavv: 'AgAAAAAAAIR8CQrXcIhbQAAAAAA',
+ xid: 'MDAwMDAwMDAwMDAwMDAwMzIyNzY='
+ }
+ )
+ @additional_options_3ds2 = @options.merge(
+ execute_threed: true,
+ three_d_secure: {
+ version: '2.0.0',
+ eci: '06',
+ cavv: 'AgAAAAAAAIR8CQrXcIhbQAAAAAA',
+ ds_transaction_id: 'MDAwMDAwMDAwMDAwMDAwMzIyNzY='
+ }
)
end
@@ -148,6 +160,14 @@ def test_successful_authorize_and_capture_with_3ds
assert_success capture
end
+ def test_successful_authorize_and_capture_with_3ds2
+ auth = @gateway.authorize(@amount, @credit_card, @additional_options_3ds2)
+ assert_success auth
+
+ assert capture = @gateway.capture(nil, auth.authorization)
+ assert_success capture
+ end
+
def test_failed_authorize
response = @gateway.authorize(@amount, @declined_card, @options)
assert_failure response
diff --git a/test/unit/gateways/checkout_v2_test.rb b/test/unit/gateways/checkout_v2_test.rb
index 83cca231ecb..c5839c0a494 100644
--- a/test/unit/gateways/checkout_v2_test.rb
+++ b/test/unit/gateways/checkout_v2_test.rb
@@ -121,9 +121,36 @@ def test_successful_authorize_and_capture_with_3ds
response = stub_comms do
options = {
execute_threed: true,
- eci: '05',
- cryptogram: '1234',
- xid: '1234'
+ three_d_secure: {
+ version: '1.0.2',
+ eci: '05',
+ cryptogram: '1234',
+ xid: '1234'
+ }
+ }
+ @gateway.authorize(@amount, @credit_card, options)
+ end.respond_with(successful_authorize_response)
+
+ assert_success response
+ assert_equal 'pay_fj3xswqe3emuxckocjx6td73ni', response.authorization
+
+ capture = stub_comms do
+ @gateway.capture(@amount, response.authorization)
+ end.respond_with(successful_capture_response)
+
+ assert_success capture
+ end
+
+ def test_successful_authorize_and_capture_with_3ds2
+ response = stub_comms do
+ options = {
+ execute_threed: true,
+ three_d_secure: {
+ version: '2.0.0',
+ eci: '05',
+ cryptogram: '1234',
+ ds_transaction_id: '1234'
+ }
}
@gateway.authorize(@amount, @credit_card, options)
end.respond_with(successful_authorize_response)
From 74f2859e0fc458ef99784ec64ba9e315d3dce215 Mon Sep 17 00:00:00 2001
From: Bertrand Braschi
Date: Fri, 19 Jul 2019 09:48:47 -0400
Subject: [PATCH 0391/2234] WorldPay - use ds_transaction_id for 3DS 2.x
(#3277)
---
.../billing/gateways/worldpay.rb | 21 ++++++++++++-------
test/unit/gateways/worldpay_test.rb | 13 ++++++------
2 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb
index 0472d7e70a0..c145c0587c8 100644
--- a/lib/active_merchant/billing/gateways/worldpay.rb
+++ b/lib/active_merchant/billing/gateways/worldpay.rb
@@ -301,18 +301,25 @@ def add_payment_method(xml, amount, payment_method, options)
end
if three_d_secure = options[:three_d_secure]
- xml.tag! 'info3DSecure' do
- xml.tag! 'threeDSVersion', three_d_secure[:version]
- xid_tag = three_d_secure[:version] =~ /^2/ ? 'dsTransactionId' : 'xid'
- xml.tag! xid_tag, three_d_secure[:xid]
- xml.tag! 'cavv', three_d_secure[:cavv]
- xml.tag! 'eci', three_d_secure[:eci]
- end
+ add_three_d_secure(three_d_secure, xml)
end
end
end
end
+ def add_three_d_secure(three_d_secure, xml)
+ xml.tag! 'info3DSecure' do
+ xml.tag! 'threeDSVersion', three_d_secure[:version]
+ if three_d_secure[:version] =~ /^2/
+ xml.tag! 'dsTransactionId', three_d_secure[:ds_transaction_id]
+ else
+ xml.tag! 'xid', three_d_secure[:xid]
+ end
+ xml.tag! 'cavv', three_d_secure[:cavv]
+ xml.tag! 'eci', three_d_secure[:eci]
+ end
+ end
+
def add_card(xml, payment_method, options)
xml.tag! 'cardNumber', payment_method.number
xml.tag! 'expiryDate' do
diff --git a/test/unit/gateways/worldpay_test.rb b/test/unit/gateways/worldpay_test.rb
index aaaa4302f49..531ef493450 100644
--- a/test/unit/gateways/worldpay_test.rb
+++ b/test/unit/gateways/worldpay_test.rb
@@ -602,7 +602,7 @@ def test_transcript_scrubbing
def test_3ds_version_1_request
stub_comms do
- @gateway.authorize(@amount, @credit_card, @options.merge(three_d_secure_option('1.0.2')))
+ @gateway.authorize(@amount, @credit_card, @options.merge(three_d_secure_option(version: '1.0.2', xid: 'xid')))
end.check_request do |endpoint, data, headers|
assert_match %r{}, data
assert_match %r{eci}, data
@@ -614,12 +614,12 @@ def test_3ds_version_1_request
def test_3ds_version_2_request
stub_comms do
- @gateway.authorize(@amount, @credit_card, @options.merge(three_d_secure_option('2.1.0')))
+ @gateway.authorize(@amount, @credit_card, @options.merge(three_d_secure_option(version: '2.1.0', ds_transaction_id: 'ds_transaction_id')))
end.check_request do |endpoint, data, headers|
assert_match %r{}, data
assert_match %r{eci}, data
assert_match %r{cavv}, data
- assert_match %r{xid}, data
+ assert_match %r{ds_transaction_id}, data
assert_match %r{2.1.0}, data
end.respond_with(successful_authorize_response)
end
@@ -835,13 +835,14 @@ def assert_tag_with_attributes(tag, attributes, string)
end
end
- def three_d_secure_option(version)
+ def three_d_secure_option(version:, xid: nil, ds_transaction_id: nil)
{
three_d_secure: {
eci: 'eci',
cavv: 'cavv',
- xid: 'xid',
- version: version
+ xid: xid,
+ ds_transaction_id: ds_transaction_id,
+ version: version,
}
}
end
From 8d288721a3a658df12ae62e800eb5764fb2bfd63 Mon Sep 17 00:00:00 2001
From: Zeb DeOs
Date: Mon, 15 Jul 2019 12:31:59 -0400
Subject: [PATCH 0392/2234] Credorax: add 3DS2 MPI auth data support
Unit:
22 tests, 102 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
25 tests, 45 assertions, 10 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
60% passed
NOTE: Failing tests also failing in current master as of time of this
run (and these same 10 were passing only a couple hours ago). The
Credorax test infrastructure with respect to the test Visa credentials
seems very unstable (and possibly depenedent on the time of day the
transactions are attempted), see:
https://github.com/activemerchant/active_merchant/pull/3040#issuecomment-437146298
Today, it seemed like they passed before 17:00 London time, and started
failing with "Transaction has been declined." at or around 17:00 London
time. Shuffling card numbers is futile, just leaving these failures in
place since there is no predictable and reliable way to ensure they
always pass.
ECS-382
Closes #3274
---
CHANGELOG | 1 +
README.md | 3 +
.../billing/gateways/credorax.rb | 30 ++++-
test/fixtures.yml | 3 +
test/remote/gateways/remote_credorax_test.rb | 108 +++++++++++++++++-
test/unit/gateways/credorax_test.rb | 44 +++++++
6 files changed, 186 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 70683aaf1fd..d6b23dead48 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -38,6 +38,7 @@
* BlueSnap: Default to not send amount on capture [molbrown] #3270
* Spreedly: extra fields, remove extraneous check [montdidier] #3102 #3281
* Cecabank: Update encryption to SHA2 [leila-alderman] #3278
+* Credorax: add 3DS2 MPI auth data support [bayprogrammer] #3274
== Version 1.95.0 (May 23, 2019)
* Adyen: Constantize version to fix subdomains [curiousepic] #3228
diff --git a/README.md b/README.md
index c026e93ae86..0c478dcb687 100644
--- a/README.md
+++ b/README.md
@@ -84,6 +84,9 @@ end
For more in-depth documentation and tutorials, see [GettingStarted.md](GettingStarted.md) and the
[API documentation](http://www.rubydoc.info/github/activemerchant/active_merchant/).
+Emerging ActiveMerchant 3DS conventions are documented in the [Contributing](https://github.com/activemerchant/active_merchant/wiki/Contributing#3ds-options)
+guide and [Standardized 3DS Fields](https://github.com/activemerchant/active_merchant/wiki/Standardized-3DS-Fields) guide of the wiki.
+
## Supported Payment Gateways
The [ActiveMerchant Wiki](https://github.com/activemerchant/active_merchant/wikis) contains a [table of features supported by each gateway](https://github.com/activemerchant/active_merchant/wiki/Gateway-Feature-Matrix).
diff --git a/lib/active_merchant/billing/gateways/credorax.rb b/lib/active_merchant/billing/gateways/credorax.rb
index 6ecc5ccc644..6f28d82f259 100644
--- a/lib/active_merchant/billing/gateways/credorax.rb
+++ b/lib/active_merchant/billing/gateways/credorax.rb
@@ -6,6 +6,10 @@ class CredoraxGateway < Gateway
self.display_name = 'Credorax Gateway'
self.homepage_url = 'https://www.credorax.com/'
+ # NOTE: the IP address you run the remote tests from will need to be
+ # whitelisted by Credorax; contact support@credorax.com as necessary to
+ # request your IP address be added to the whitelist for your test
+ # account.
self.test_url = 'https://intconsole.credorax.com/intenv/service/gateway'
# The live URL is assigned on a per merchant basis once certification has passed
@@ -264,8 +268,30 @@ def add_email(post, options)
end
def add_3d_secure(post, options)
- return unless options[:eci] && options[:xid]
- post[:i8] = "#{options[:eci]}:#{(options[:cavv] || "none")}:#{options[:xid]}"
+ if options[:eci] && options[:xid]
+ add_3d_secure_1_data(post, options)
+ elsif options[:three_d_secure]
+ add_normalized_3d_secure_2_data(post, options)
+ end
+ end
+
+ def add_3d_secure_1_data(post, options)
+ post[:i8] = build_i8(options[:eci], options[:cavv], options[:xid])
+ end
+
+ def add_normalized_3d_secure_2_data(post, options)
+ three_d_secure_options = options[:three_d_secure]
+
+ post[:i8] = build_i8(
+ three_d_secure_options[:eci],
+ three_d_secure_options[:cavv]
+ )
+ post[:'3ds_version'] = three_d_secure_options[:version]
+ post[:'3ds_dstrxid'] = three_d_secure_options[:ds_transaction_id]
+ end
+
+ def build_i8(eci, cavv=nil, xid=nil)
+ "#{eci}:#{cavv || 'none'}:#{xid || 'none'}"
end
def add_echo(post, options)
diff --git a/test/fixtures.yml b/test/fixtures.yml
index bc3375fe903..9cb35a7ec25 100644
--- a/test/fixtures.yml
+++ b/test/fixtures.yml
@@ -220,6 +220,9 @@ creditcall:
terminal_id: '99961426'
transaction_key: '9drdRU9wJ65SNRw3'
+# NOTE: the IP address you run the remote tests from will need to be
+# whitelisted by Credorax; contact support@credorax.com as necessary to request
+# your IP address be added to the whitelist for your test account.
credorax:
merchant_id: 'merchant_id'
cipher_key: 'cipher_key'
diff --git a/test/remote/gateways/remote_credorax_test.rb b/test/remote/gateways/remote_credorax_test.rb
index 52f611fa200..f826f157987 100644
--- a/test/remote/gateways/remote_credorax_test.rb
+++ b/test/remote/gateways/remote_credorax_test.rb
@@ -6,6 +6,7 @@ def setup
@amount = 100
@credit_card = credit_card('4176661000001015', verification_value: '281', month: '12', year: '2022')
+ @fully_auth_card = credit_card('5223450000000007', brand: 'mastercard', verification_value: '090', month: '12', year: '2025')
@declined_card = credit_card('4176661000001111', verification_value: '681', month: '12', year: '2022')
@options = {
order_id: '1',
@@ -35,12 +36,78 @@ def test_successful_purchase_with_extra_options
assert_equal 'Succeeded', response.message
end
+ def test_successful_purchase_with_auth_data_via_3ds1_fields
+ options = @options.merge(
+ eci: '02',
+ cavv: 'jJ81HADVRtXfCBATEp01CJUAAAA=',
+ xid: '00000000000000000501'
+ )
+
+ response = @gateway.purchase(@amount, @fully_auth_card, options)
+ assert_success response
+ assert_equal '1', response.params['H9']
+ assert_equal 'Succeeded', response.message
+ end
+
+ def test_successful_purchase_with_auth_data_via_normalized_3ds2_options
+ version = '2.0'
+ eci = '02'
+ cavv = 'jJ81HADVRtXfCBATEp01CJUAAAA='
+ ds_transaction_id = '97267598-FAE6-48F2-8083-C23433990FBC'
+ options = @options.merge(
+ three_d_secure: {
+ version: version,
+ eci: eci,
+ cavv: cavv,
+ ds_transaction_id: ds_transaction_id
+ }
+ )
+
+ response = @gateway.purchase(@amount, @fully_auth_card, options)
+ assert_success response
+ assert_equal '1', response.params['H9']
+ assert_equal 'Succeeded', response.message
+ end
+
def test_failed_purchase
response = @gateway.purchase(@amount, @declined_card, @options)
assert_failure response
assert_equal 'Transaction not allowed for cardholder', response.message
end
+ def test_failed_purchase_invalid_auth_data_via_3ds1_fields
+ options = @options.merge(
+ eci: '02',
+ cavv: 'jJ81HADVRtXfCBATEp01CJUAAAA=',
+ xid: 'this is not a valid xid, it will be rejected'
+ )
+
+ response = @gateway.purchase(@amount, @fully_auth_card, options)
+ assert_failure response
+ assert_equal '-9', response.params['Z2']
+ assert_match 'Parameter i8 is invalid', response.message
+ end
+
+ def test_failed_purchase_invalid_auth_data_via_normalized_3ds2_options
+ version = '2.0'
+ eci = '02'
+ cavv = 'BOGUS'
+ ds_transaction_id = '97267598-FAE6-48F2-8083-C23433990FBC'
+ options = @options.merge(
+ three_d_secure: {
+ version: version,
+ eci: eci,
+ cavv: cavv,
+ ds_transaction_id: ds_transaction_id
+ }
+ )
+
+ response = @gateway.purchase(@amount, @fully_auth_card, options)
+ assert_failure response
+ assert_equal '-9', response.params['Z2']
+ assert_match 'malformed', response.message
+ end
+
def test_successful_authorize_and_capture
response = @gateway.authorize(@amount, @credit_card, @options)
assert_success response
@@ -52,6 +119,39 @@ def test_successful_authorize_and_capture
assert_equal 'Succeeded', capture.message
end
+ def test_successful_authorize_with_auth_data_via_3ds1_fields
+ options = @options.merge(
+ eci: '02',
+ cavv: 'jJ81HADVRtXfCBATEp01CJUAAAA=',
+ xid: '00000000000000000501'
+ )
+
+ response = @gateway.authorize(@amount, @fully_auth_card, options)
+ assert_success response
+ assert_equal 'Succeeded', response.message
+ assert response.authorization
+ end
+
+ def test_successful_authorize_with_auth_data_via_normalized_3ds2_options
+ version = '2.0'
+ eci = '02'
+ cavv = 'jJ81HADVRtXfCBATEp01CJUAAAA='
+ ds_transaction_id = '97267598-FAE6-48F2-8083-C23433990FBC'
+ options = @options.merge(
+ three_d_secure: {
+ version: version,
+ eci: eci,
+ cavv: cavv,
+ ds_transaction_id: ds_transaction_id
+ }
+ )
+
+ response = @gateway.authorize(@amount, @fully_auth_card, options)
+ assert_success response
+ assert_equal 'Succeeded', response.message
+ assert response.authorization
+ end
+
def test_failed_authorize
response = @gateway.authorize(@amount, @declined_card, @options)
assert_failure response
@@ -165,7 +265,7 @@ def test_transcript_scrubbing
clean_transcript = @gateway.scrub(transcript)
assert_scrubbed(@credit_card.number, clean_transcript)
- assert_scrubbed(@credit_card.verification_value.to_s, clean_transcript)
+ assert_cvv_scrubbed(clean_transcript)
end
# #########################################################################
@@ -478,4 +578,10 @@ def test_transcript_scrubbing
# assert_success void
# assert_equal "Succeeded", void.message
# end
+
+ private
+
+ def assert_cvv_scrubbed(transcript)
+ assert_match(/b5=\[FILTERED\]/, transcript)
+ end
end
diff --git a/test/unit/gateways/credorax_test.rb b/test/unit/gateways/credorax_test.rb
index c93b3987470..f353c0297fb 100644
--- a/test/unit/gateways/credorax_test.rb
+++ b/test/unit/gateways/credorax_test.rb
@@ -204,6 +204,50 @@ def test_defaults_3d_secure_cavv_field_to_none_if_not_present
assert response.test?
end
+ def test_adds_3ds2_fields_via_normalized_hash
+ version = '2.0'
+ eci = '05'
+ cavv = '637574652070757070792026206b697474656e73'
+ ds_transaction_id = '97267598-FAE6-48F2-8083-C23433990FBC'
+ options_with_normalized_3ds = @options.merge(
+ three_d_secure: {
+ version: version,
+ eci: eci,
+ cavv: cavv,
+ ds_transaction_id: ds_transaction_id
+ }
+ )
+
+ stub_comms do
+ @gateway.purchase(@amount, @credit_card, options_with_normalized_3ds)
+ end.check_request do |endpoint, data, headers|
+ assert_match(/i8=#{eci}%3A#{cavv}%3Anone/, data)
+ assert_match(/3ds_version=#{version}/, data)
+ assert_match(/3ds_dstrxid=#{ds_transaction_id}/, data)
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_adds_default_cavv_when_omitted_from_normalized_hash
+ version = '2.0'
+ eci = '05'
+ ds_transaction_id = '97267598-FAE6-48F2-8083-C23433990FBC'
+ options_with_normalized_3ds = @options.merge(
+ three_d_secure: {
+ version: version,
+ eci: eci,
+ ds_transaction_id: ds_transaction_id
+ }
+ )
+
+ stub_comms do
+ @gateway.purchase(@amount, @credit_card, options_with_normalized_3ds)
+ end.check_request do |endpoint, data, headers|
+ assert_match(/i8=#{eci}%3Anone%3Anone/, data)
+ assert_match(/3ds_version=#{version}/, data)
+ assert_match(/3ds_dstrxid=#{ds_transaction_id}/, data)
+ end.respond_with(successful_purchase_response)
+ end
+
def test_adds_a9_field
options_with_3ds = @options.merge({transaction_type: '8'})
From d810c75143208145335bf898ef31a50342ca0f84 Mon Sep 17 00:00:00 2001
From: Jonathan Smith
Date: Wed, 24 Jul 2019 10:14:00 -0400
Subject: [PATCH 0393/2234] Add Kosovo to the list of countries (#3226)
Although these codes are not officially in the ISO standard, they are
used by the European Commission, and we're seeing some buyers use them.
The numeric code, which is almost never used by the provider, is one of
the reserved codes that will never be assigned to an actual country. If
Kosovo is added to the ISO standard, we can correct it at that time.
---
CHANGELOG | 1 +
lib/active_merchant/country.rb | 1 +
2 files changed, 2 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index d6b23dead48..04e093e3d32 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -39,6 +39,7 @@
* Spreedly: extra fields, remove extraneous check [montdidier] #3102 #3281
* Cecabank: Update encryption to SHA2 [leila-alderman] #3278
* Credorax: add 3DS2 MPI auth data support [bayprogrammer] #3274
+* Add Kosovo to the list of countries [AnotherJoSmith] #3226
== Version 1.95.0 (May 23, 2019)
* Adyen: Constantize version to fix subdomains [curiousepic] #3228
diff --git a/lib/active_merchant/country.rb b/lib/active_merchant/country.rb
index e6db5cb3e28..eb18ba69665 100644
--- a/lib/active_merchant/country.rb
+++ b/lib/active_merchant/country.rb
@@ -183,6 +183,7 @@ def to_s
{ alpha2: 'KI', name: 'Kiribati', alpha3: 'KIR', numeric: '296' },
{ alpha2: 'KP', name: 'Korea, Democratic People\'s Republic of', alpha3: 'PRK', numeric: '408' },
{ alpha2: 'KR', name: 'Korea, Republic of', alpha3: 'KOR', numeric: '410' },
+ { alpha2: 'XK', name: 'Kosovo', alpha3: 'XKX', numeric: '900' },
{ alpha2: 'KW', name: 'Kuwait', alpha3: 'KWT', numeric: '414' },
{ alpha2: 'KG', name: 'Kyrgyzstan', alpha3: 'KGZ', numeric: '417' },
{ alpha2: 'LA', name: 'Lao People\'s Democratic Republic', alpha3: 'LAO', numeric: '418' },
From c0c0e8edfc9c257ebd161488a3620f61f56978d1 Mon Sep 17 00:00:00 2001
From: Filipe Costa
Date: Wed, 24 Jul 2019 11:48:04 -0400
Subject: [PATCH 0394/2234] [Realex] Add 3DS support through external MPI
(#3284)
* [Realex] Add 3DS support through external MPI
A few sample request we got from Realex contacts
```
AAACBllleHchZTBWIGV4AAAAAAA=
crqAeMwkEL9r4POdxpByWJ1/wYg=
5
1
```
And
```
5
c272b04f-6e7b-43a2-bb78-90f4fb94aa25
ODQzNjgwNjU0ZjM3N2JmYTg0NTM=
2.1.0
```
* Prefer single quotes
* Adding fixtures for 3DS
---
.../billing/gateways/realex.rb | 16 ++--
test/fixtures.yml | 6 ++
test/remote/gateways/remote_realex_test.rb | 41 ++++++++---
test/unit/gateways/realex_test.rb | 73 +++++++++++++++----
4 files changed, 108 insertions(+), 28 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/realex.rb b/lib/active_merchant/billing/gateways/realex.rb
index 9b8798b2cc4..3a45955c810 100644
--- a/lib/active_merchant/billing/gateways/realex.rb
+++ b/lib/active_merchant/billing/gateways/realex.rb
@@ -289,12 +289,18 @@ def add_network_tokenization_card(xml, payment)
end
def add_three_d_secure(xml, options)
- if options[:three_d_secure]
- xml.tag! 'mpi' do
- xml.tag! 'cavv', options[:three_d_secure][:cavv]
- xml.tag! 'eci', options[:three_d_secure][:eci]
- xml.tag! 'xid', options[:three_d_secure][:xid]
+ return unless three_d_secure = options[:three_d_secure]
+ version = three_d_secure.fetch(:version, '')
+ xml.tag! 'mpi' do
+ if version =~ /^2/
+ xml.tag! 'authentication_value', three_d_secure[:cavv]
+ xml.tag! 'ds_trans_id', three_d_secure[:ds_transaction_id]
+ else
+ xml.tag! 'cavv', three_d_secure[:cavv]
+ xml.tag! 'xid', three_d_secure[:xid]
end
+ xml.tag! 'eci', three_d_secure[:eci]
+ xml.tag! 'message_version', version
end
end
diff --git a/test/fixtures.yml b/test/fixtures.yml
index 9cb35a7ec25..7f8439a76eb 100644
--- a/test/fixtures.yml
+++ b/test/fixtures.yml
@@ -1051,6 +1051,12 @@ realex_visa:
year: '2020'
verification_value: '123'
+realex_visa_3ds_enrolled:
+ number: '4012001037141112'
+ month: '9'
+ year: '2021'
+ verification_value: '123'
+
realex_visa_coms_error:
number: '4009830000001985'
month: '6'
diff --git a/test/remote/gateways/remote_realex_test.rb b/test/remote/gateways/remote_realex_test.rb
index ec80321697b..ddac90806c5 100644
--- a/test/remote/gateways/remote_realex_test.rb
+++ b/test/remote/gateways/remote_realex_test.rb
@@ -3,14 +3,15 @@
class RemoteRealexTest < Test::Unit::TestCase
def setup
- @gateway = RealexGateway.new(fixtures(:realex))
+ @gateway = RealexGateway.new(fixtures(:realex_with_account))
# Replace the card numbers with the test account numbers from Realex
- @visa = card_fixtures(:realex_visa)
- @visa_declined = card_fixtures(:realex_visa_declined)
- @visa_referral_b = card_fixtures(:realex_visa_referral_b)
- @visa_referral_a = card_fixtures(:realex_visa_referral_a)
- @visa_coms_error = card_fixtures(:realex_visa_coms_error)
+ @visa = card_fixtures(:realex_visa)
+ @visa_declined = card_fixtures(:realex_visa_declined)
+ @visa_referral_b = card_fixtures(:realex_visa_referral_b)
+ @visa_referral_a = card_fixtures(:realex_visa_referral_a)
+ @visa_coms_error = card_fixtures(:realex_visa_coms_error)
+ @visa_3ds_enrolled = card_fixtures(:realex_visa_3ds_enrolled)
@mastercard = card_fixtures(:realex_mastercard)
@mastercard_declined = card_fixtures(:realex_mastercard_declined)
@@ -115,12 +116,33 @@ def test_realex_purchase_with_apple_pay_declined
assert_match %r{DECLINED}i, response.message
end
- def test_realex_purchase_with_three_d_secure
+ def test_realex_purchase_with_three_d_secure_1
response = @gateway.purchase(
1000,
- @visa,
+ @visa_3ds_enrolled,
three_d_secure: {
- eci: '05', xid: '05', cavv: '05'
+ eci: '05',
+ cavv: 'AgAAAAAAAIR8CQrXcIhbQAAAAAA',
+ xid: 'MDAwMDAwMDAwMDAwMDAwMzIyNzY=',
+ version: '1.0.2',
+ },
+ :order_id => generate_unique_id,
+ :description => 'Test Realex with 3DS'
+ )
+ assert_success response
+ assert response.test?
+ assert_equal 'Successful', response.message
+ end
+
+ def test_realex_purchase_with_three_d_secure_2
+ response = @gateway.purchase(
+ 1000,
+ @visa_3ds_enrolled,
+ three_d_secure: {
+ eci: '05',
+ cavv: 'AgAAAAAAAIR8CQrXcIhbQAAAAAA',
+ ds_transaction_id: 'bDE9Aa1A-C5Ac-AD3a-4bBC-aC918ab1de3E',
+ version: '2.1.0',
},
:order_id => generate_unique_id,
:description => 'Test Realex with 3DS'
@@ -163,7 +185,6 @@ def test_realex_purchase_coms_error
:order_id => generate_unique_id,
:description => 'Test Realex coms error'
)
-
assert_not_nil response
assert_failure response
diff --git a/test/unit/gateways/realex_test.rb b/test/unit/gateways/realex_test.rb
index 2223ffd06fe..1516f4b19ab 100644
--- a/test/unit/gateways/realex_test.rb
+++ b/test/unit/gateways/realex_test.rb
@@ -339,15 +339,16 @@ def test_transcript_scrubbing
assert_equal scrubbed_transcript, @gateway.scrub(transcript)
end
- def test_three_d_secure
+ def test_three_d_secure_1
@gateway.expects(:ssl_post).returns(successful_purchase_response)
options = {
- :order_id => '1',
- :three_d_secure => {
- :cavv => '1234',
- :eci => '1234',
- :xid => '1234'
+ order_id: '1',
+ three_d_secure: {
+ cavv: '1234',
+ eci: '1234',
+ xid: '1234',
+ version: '1.0.2',
}
}
@@ -355,13 +356,14 @@ def test_three_d_secure
assert_equal 'M', response.cvv_result['code']
end
- def test_auth_xml_with_three_d_secure
+ def test_auth_xml_with_three_d_secure_1
options = {
- :order_id => '1',
- :three_d_secure => {
- :cavv => '1234',
- :eci => '1234',
- :xid => '1234'
+ order_id: '1',
+ three_d_secure: {
+ cavv: '1234',
+ eci: '1234',
+ xid: '1234',
+ version: '1.0.2',
}
}
@@ -388,8 +390,53 @@ def test_auth_xml_with_three_d_secure
3499d7bc8dbacdcfba2286bd74916d026bae630f
1234
- 1234
1234
+ 1234
+ 1.0.2
+
+
+SRC
+
+ assert_xml_equal valid_auth_request_xml, @gateway.build_purchase_or_authorization_request(:authorization, @amount, @credit_card, options)
+ end
+
+ def test_auth_xml_with_three_d_secure_2
+ options = {
+ order_id: '1',
+ three_d_secure: {
+ cavv: '1234',
+ eci: '1234',
+ ds_transaction_id: '1234',
+ version: '2.1.0',
+ }
+ }
+
+ @gateway.expects(:new_timestamp).returns('20090824160201')
+
+ valid_auth_request_xml = <<-SRC
+
+ your_merchant_id
+ your_account
+ 1
+ 100
+
+ 4263971921001307
+ 0808
+ Longbob Longsen
+ VISA
+
+
+
+
+
+
+
+ 3499d7bc8dbacdcfba2286bd74916d026bae630f
+
+ 1234
+ 1234
+ 1234
+ 2.1.0
SRC
From 25413633c87edf5756e6542ed29d52778dd7e0d4 Mon Sep 17 00:00:00 2001
From: Dilan Nebioglu
Date: Wed, 24 Jul 2019 14:58:26 -0400
Subject: [PATCH 0395/2234] Add 3DS 1.0 values to paypal (#3279)
---
.../billing/gateways/paypal.rb | 13 +++++++++++
test/remote/gateways/remote_paypal_test.rb | 13 +++++++++++
test/unit/gateways/paypal_test.rb | 23 +++++++++++++++++++
3 files changed, 49 insertions(+)
diff --git a/lib/active_merchant/billing/gateways/paypal.rb b/lib/active_merchant/billing/gateways/paypal.rb
index 0972125cb7e..3563a40410d 100644
--- a/lib/active_merchant/billing/gateways/paypal.rb
+++ b/lib/active_merchant/billing/gateways/paypal.rb
@@ -90,6 +90,8 @@ def add_credit_card(xml, credit_card, address, options)
xml.tag! 'n2:Payer', options[:email]
add_address(xml, 'n2:Address', address)
end
+
+ add_three_d_secure(xml, options) if options[:three_d_secure]
end
end
@@ -98,6 +100,17 @@ def add_descriptors(xml, options)
xml.tag! 'n2:SoftDescriptorCity', options[:soft_descriptor_city] unless options[:soft_descriptor_city].blank?
end
+ def add_three_d_secure(xml, options)
+ three_d_secure = options[:three_d_secure]
+ xml.tag! 'ThreeDSecureRequest' do
+ xml.tag! 'MpiVendor3ds', 'Y'
+ xml.tag! 'AuthStatus3ds', three_d_secure[:trans_status] unless three_d_secure[:trans_status].blank?
+ xml.tag! 'Cavv', three_d_secure[:cavv] unless three_d_secure[:cavv].blank?
+ xml.tag! 'Eci3ds', three_d_secure[:eci] unless three_d_secure[:eci].blank?
+ xml.tag! 'Xid', three_d_secure[:xid] unless three_d_secure[:xid].blank?
+ end
+ end
+
def credit_card_type(type)
case type
when 'visa' then 'Visa'
diff --git a/test/remote/gateways/remote_paypal_test.rb b/test/remote/gateways/remote_paypal_test.rb
index 7465a369da7..220337bb2d9 100644
--- a/test/remote/gateways/remote_paypal_test.rb
+++ b/test/remote/gateways/remote_paypal_test.rb
@@ -256,4 +256,17 @@ def test_successful_referenced_id_purchase
assert_success response2
end
+ def test_successful_purchase_with_3ds_version_1
+ params = @params.merge!({
+ three_d_secure: {
+ trans_status: 'Y',
+ eci: '05',
+ cavv: 'AgAAAAAAAIR8CQrXcIhbQAAAAAA',
+ xid: 'MDAwMDAwMDAwMDAwMDAwMzIyNzY='
+ }
+ })
+ response = @gateway.purchase(@amount, @credit_card, params)
+ assert_success response
+ assert response.params['transaction_id']
+ end
end
diff --git a/test/unit/gateways/paypal_test.rb b/test/unit/gateways/paypal_test.rb
index d63e8797c9c..306e4bf5dd9 100644
--- a/test/unit/gateways/paypal_test.rb
+++ b/test/unit/gateways/paypal_test.rb
@@ -611,6 +611,18 @@ def test_error_code_with_no_mapping_returns_standardized_processing_error
assert_equal(:processing_error, response.error_code)
end
+ def test_3ds_version_1_request
+ stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options.merge(three_d_secure_option))
+ end.check_request do |endpoint, data, headers|
+ assert_match %r{124}, data
+ assert_match %r{Y}, data
+ assert_match %r{cavv}, data
+ assert_match %r{eci}, data
+ assert_match %r{xid}, data
+ end.respond_with(successful_purchase_response)
+ end
+
private
def pre_scrubbed
@@ -1416,4 +1428,15 @@ def successful_get_recurring_payments_profile_response
2012-03-19T21:34:40ZSuccess6f24b53c49232722649250I-M1L3RX91DPDDCancelledProfileA descriptionNoAutoBill0Ryan BatesPayPalUnconfirmed2012-03-19T11:00:00ZMonth101.230.000.001-11.231Visa357612013unverifiedRyanBatesPayPalUnconfirmed00Month101.230.000.000.000.000.000.001970-01-01T00:00:00Z
RESPONSE
end
+
+ def three_d_secure_option
+ {
+ three_d_secure: {
+ trans_status: 'Y',
+ eci: 'eci',
+ cavv: 'cavv',
+ xid: 'xid'
+ }
+ }
+ end
end
From 51978a2e37546a04f70fe6f1f35d643d6e9b30bd Mon Sep 17 00:00:00 2001
From: Filipe Costa
Date: Fri, 26 Jul 2019 09:39:13 -0400
Subject: [PATCH 0396/2234] Release v1.96.0
---
CHANGELOG | 10 ++++++++--
lib/active_merchant/version.rb | 2 +-
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 04e093e3d32..163206e3739 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,12 +1,14 @@
= ActiveMerchant CHANGELOG
== HEAD
+
+== Version 1.96.0 (Jul 26, 2019)
* Bluesnap: Omit state codes for unsupported countries [therufs] #3229
* Adyen: Pass updateShopperStatement, industryUsage [curiousepic] #3233
* TransFirst Transaction Express: Fix blank address2 values [britth] #3231
* WorldPay: Add support for store method [bayprogrammer] #3232
* Adyen: Support for additional AVS code mapping [jknipp] #3236
-* Update message for AVS result code 'A' to generically cover postal code mismatches [jknipp] #3237
+* Adyen: Update message for AVS result code 'A' to generically cover postal code mismatches [jknipp] #3237
* CyberSource: Update CyberSource SOAP documentation link [vince-smith] #3204
* USAePay: Handle additional error codes and add default error code [estelendur] #3167
* Braintree: Add `skip_avs` and `skip_cvv` gateway specific fields [leila-alderman] #3241
@@ -16,6 +18,7 @@
* NMI: Add support for stored credentials [bayprogrammer] #3243
* Spreedly: Consolidate API requests and support bank accounts [lancecarlson] #3105
* BPoint: Hook up merchant_reference and CRN fields [curiousepic] #3249
+* Checkout V2: Stop sending phone number to Checkout V2 integration [filipebarcos] #3248
* Barclaycard Smartpay: Add support for 3DS2 [britth] #3251
* Adyen: Add support for non-fractional currencies [molbrown] #3257
* Decidir: Add new gateway [jknipp] #3254
@@ -25,7 +28,7 @@
* Kushki: Update supported countries [molbrown] #3260
* Paypal: Update supported countries [molbrown] #3260
* BlueSnap: Send amount in capture requests [jknipp] #3262
-* Adds Elo card type in general, and specifically to Mundipagg [jasonxp] #3255
+* Mundipagg: Add Alelo card support [jasonxp] #3255
* Adyen: Remove temporary amount modification for non-fractional currencies [molbrown] #3263
* Adyen: Set blank state to N/A [therufs] #3252
* MiGS: Add tx_source gateway specific field [leila-alderman] #3264
@@ -38,8 +41,11 @@
* BlueSnap: Default to not send amount on capture [molbrown] #3270
* Spreedly: extra fields, remove extraneous check [montdidier] #3102 #3281
* Cecabank: Update encryption to SHA2 [leila-alderman] #3278
+* Checkout V2: Fix 3DS 1&2 integration [nicolas-maalouf-cko] #3240
* Credorax: add 3DS2 MPI auth data support [bayprogrammer] #3274
* Add Kosovo to the list of countries [AnotherJoSmith] #3226
+* Realex: Adds 3DS 1&2 support through external MPI [filipebarcos] #3284
+* PayPal: Adds 3DS 1 support through external MPI [nebdil] #3279
== Version 1.95.0 (May 23, 2019)
* Adyen: Constantize version to fix subdomains [curiousepic] #3228
diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb
index 1f632ec56fc..08670fbdad1 100644
--- a/lib/active_merchant/version.rb
+++ b/lib/active_merchant/version.rb
@@ -1,3 +1,3 @@
module ActiveMerchant
- VERSION = '1.95.0'
+ VERSION = '1.96.0'
end
From 789beab00f792f51ade2c246806052d7f3786fa7 Mon Sep 17 00:00:00 2001
From: Hannah Deters
Date: Thu, 18 Jul 2019 16:16:02 -0400
Subject: [PATCH 0397/2234] CardConnect: fix domain GSF
Keep domain as top level gateway field, domain option will always
be passed but can be nil, in which case the default live_url will
be used.
ECS-448
Unit:
22 tests, 92 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
Remote:
23 tests, 55 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
Closes #3283
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/card_connect.rb | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 163206e3739..e0a3b6b8974 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
= ActiveMerchant CHANGELOG
== HEAD
+* CardConnect: Move domain from gateway spefici to gateway field
== Version 1.96.0 (Jul 26, 2019)
* Bluesnap: Omit state codes for unsupported countries [therufs] #3229
diff --git a/lib/active_merchant/billing/gateways/card_connect.rb b/lib/active_merchant/billing/gateways/card_connect.rb
index eb4a74daae0..4d953f0a6dd 100644
--- a/lib/active_merchant/billing/gateways/card_connect.rb
+++ b/lib/active_merchant/billing/gateways/card_connect.rb
@@ -68,7 +68,7 @@ def initialize(options = {})
end
def require_valid_domain!(options, param)
- if options.key?(param)
+ if options[param]
raise ArgumentError.new('not a valid cardconnect domain') unless /\Dcardconnect.com:\d{1,}\D/ =~ options[param]
end
end
From 43e84e48408d7e87f4c84faa0a108301cd4cde7c Mon Sep 17 00:00:00 2001
From: Hannah Deters
Date: Thu, 18 Jul 2019 15:42:08 -0400
Subject: [PATCH 0398/2234] ECS-217_braintree_stored_credentials
Unit:
73 tests, 174 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
Remote:
79 tests, 435 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
Closes #3286
---
CHANGELOG | 3 +-
.../billing/gateways/braintree_blue.rb | 23 ++-
.../gateways/remote_braintree_blue_test.rb | 55 ++++++
test/unit/gateways/braintree_blue_test.rb | 181 ++++++++++++++++++
4 files changed, 260 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index e0a3b6b8974..2382479dc94 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,7 +1,8 @@
= ActiveMerchant CHANGELOG
== HEAD
-* CardConnect: Move domain from gateway spefici to gateway field
+* CardConnect: Move domain from gateway specific to gateway field [hdeters] #3283
+* Braintree Blue: Support for stored credentials [hdeters] #3286
== Version 1.96.0 (Jul 26, 2019)
* Bluesnap: Omit state codes for unsupported countries [therufs] #3229
diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb
index e7b48409548..eabf8b12557 100644
--- a/lib/active_merchant/billing/gateways/braintree_blue.rb
+++ b/lib/active_merchant/billing/gateways/braintree_blue.rb
@@ -447,7 +447,6 @@ def response_code_from_result(result)
def create_transaction(transaction_type, money, credit_card_or_vault_id, options)
transaction_params = create_transaction_parameters(money, credit_card_or_vault_id, options)
-
commit do
result = @braintree_gateway.transaction.send(transaction_type, transaction_params)
response = Response.new(result.success?, message_from_transaction_result(result), response_params(result), response_options(result))
@@ -567,6 +566,7 @@ def transaction_hash(result)
'vault_customer' => vault_customer,
'merchant_account_id' => transaction.merchant_account_id,
'risk_data' => risk_data,
+ 'network_transaction_id' => transaction.network_transaction_id || nil,
'processor_response_code' => response_code_from_result(result)
}
end
@@ -614,6 +614,7 @@ def create_transaction_parameters(money, credit_card_or_vault_id, options)
end
add_payment_method(parameters, credit_card_or_vault_id, options)
+ add_stored_credential_data(parameters, credit_card_or_vault_id, options)
parameters[:billing] = map_address(options[:billing_address]) if options[:billing_address]
parameters[:shipping] = map_address(options[:shipping_address]) if options[:shipping_address]
@@ -650,6 +651,26 @@ def create_transaction_parameters(money, credit_card_or_vault_id, options)
parameters
end
+ def add_stored_credential_data(parameters, credit_card_or_vault_id, options)
+ return unless (stored_credential = options[:stored_credential])
+ parameters[:external_vault] = {}
+ if stored_credential[:initial_transaction]
+ parameters[:external_vault][:status] = 'will_vault'
+ else
+ parameters[:external_vault][:status] = 'vaulted'
+ parameters[:external_vault][:previous_network_transaction_id] = stored_credential[:network_transaction_id]
+ end
+ if stored_credential[:initiator] == 'merchant'
+ if stored_credential[:reason_type] == 'installment'
+ parameters[:transaction_source] = 'recurring'
+ else
+ parameters[:transaction_source] = stored_credential[:reason_type]
+ end
+ else
+ parameters[:transaction_source] = ''
+ end
+ end
+
def add_payment_method(parameters, credit_card_or_vault_id, options)
if credit_card_or_vault_id.is_a?(String) || credit_card_or_vault_id.is_a?(Integer)
if options[:payment_method_token]
diff --git a/test/remote/gateways/remote_braintree_blue_test.rb b/test/remote/gateways/remote_braintree_blue_test.rb
index 4cc9e7f16a3..5ff491fa024 100644
--- a/test/remote/gateways/remote_braintree_blue_test.rb
+++ b/test/remote/gateways/remote_braintree_blue_test.rb
@@ -874,8 +874,63 @@ def test_verify_credentials
assert !gateway.verify_credentials
end
+ def test_successful_merchant_purchase_initial
+ creds_options = stored_credential_options(:merchant, :recurring, :initial)
+ response = @gateway.purchase(@amount, credit_card('4111111111111111'), @options.merge(stored_credential: creds_options))
+
+ assert_success response
+ assert_equal '1000 Approved', response.message
+ assert_equal 'submitted_for_settlement', response.params['braintree_transaction']['status']
+ assert_not_nil response.params['braintree_transaction']['network_transaction_id']
+ end
+
+ def test_successful_subsequent_merchant_unscheduled_transaction
+ creds_options = stored_credential_options(:merchant, :unscheduled, id: '020190722142652')
+ response = @gateway.purchase(@amount, credit_card('4111111111111111'), @options.merge(stored_credential: creds_options))
+ assert_success response
+ assert_equal '1000 Approved', response.message
+ assert_equal 'submitted_for_settlement', response.params['braintree_transaction']['status']
+ end
+
+ def test_successful_subsequent_merchant_recurring_transaction
+ creds_options = stored_credential_options(:cardholder, :recurring, id: '020190722142652')
+ response = @gateway.purchase(@amount, credit_card('4111111111111111'), @options.merge(stored_credential: creds_options))
+ assert_success response
+ assert_equal '1000 Approved', response.message
+ assert_equal 'submitted_for_settlement', response.params['braintree_transaction']['status']
+ end
+
+ def test_successful_cardholder_purchase_initial
+ creds_options = stored_credential_options(:cardholder, :recurring, :initial)
+ response = @gateway.purchase(@amount, credit_card('4111111111111111'), @options.merge(stored_credential: creds_options))
+ assert_success response
+ assert_equal '1000 Approved', response.message
+ assert_not_nil response.params['braintree_transaction']['network_transaction_id']
+ assert_equal 'submitted_for_settlement', response.params['braintree_transaction']['status']
+ end
+
+ def test_successful_cardholder_purchase_recurring
+ creds_options = stored_credential_options(:cardholder, :recurring, id: '020190722142652')
+ response = @gateway.purchase(@amount, credit_card('4111111111111111'), @options.merge(stored_credential: creds_options))
+ assert_success response
+ assert_equal '1000 Approved', response.message
+ assert_equal 'submitted_for_settlement', response.params['braintree_transaction']['status']
+ end
+
+ def test_successful_cardholder_purchase_unscheduled
+ creds_options = stored_credential_options(:cardholder, :unscheduled, id: '020190722142652')
+ response = @gateway.purchase(@amount, credit_card('4111111111111111'), @options.merge(stored_credential: creds_options))
+ assert_success response
+ assert_equal '1000 Approved', response.message
+ assert_equal 'submitted_for_settlement', response.params['braintree_transaction']['status']
+ end
+
private
+ def stored_credential_options(*args, id: nil)
+ stored_credential(*args, id: id)
+ end
+
def assert_avs(address1, zip, expected_avs_code)
response = @gateway.purchase(@amount, @credit_card, billing_address: {address1: address1, zip: zip})
diff --git a/test/unit/gateways/braintree_blue_test.rb b/test/unit/gateways/braintree_blue_test.rb
index 83b8e566089..f8d50ad9086 100644
--- a/test/unit/gateways/braintree_blue_test.rb
+++ b/test/unit/gateways/braintree_blue_test.rb
@@ -932,6 +932,169 @@ def test_refund_unsettled_payment_forces_void_on_full_refund
assert response.success?
end
+ def test_stored_credential_recurring_cit_initial
+ Braintree::TransactionGateway.any_instance.expects(:sale).with(
+ standard_purchase_params.merge(
+ {
+ :external_vault => {
+ :status => 'will_vault'},
+ :transaction_source => ''
+ })
+ ).returns(braintree_result)
+
+ @gateway.purchase(100, credit_card('41111111111111111111'), {test: true, order_id: '1', stored_credential: stored_credential(:cardholder, :recurring, :initial)})
+ end
+
+ def test_stored_credential_recurring_cit_used
+ Braintree::TransactionGateway.any_instance.expects(:sale).with(
+ standard_purchase_params.merge(
+ {
+ :external_vault => {
+ :status => 'vaulted',
+ :previous_network_transaction_id => '123ABC'},
+ :transaction_source => ''
+ })
+ ).returns(braintree_result)
+
+ @gateway.purchase(100, credit_card('41111111111111111111'), {test: true, order_id: '1', stored_credential: stored_credential(:cardholder, :recurring, id: '123ABC')})
+ end
+
+ def test_stored_credential_recurring_mit_initial
+ Braintree::TransactionGateway.any_instance.expects(:sale).with(
+ standard_purchase_params.merge(
+ {
+ :external_vault => {
+ :status => 'will_vault'},
+ :transaction_source => 'recurring'
+ })
+ ).returns(braintree_result)
+
+ @gateway.purchase(100, credit_card('41111111111111111111'), {test: true, order_id: '1', stored_credential: stored_credential(:merchant, :recurring, :initial)})
+ end
+
+ def test_stored_credential_recurring_mit_used
+ Braintree::TransactionGateway.any_instance.expects(:sale).with(
+ standard_purchase_params.merge(
+ {
+ :external_vault => {
+ :status => 'vaulted',
+ :previous_network_transaction_id => '123ABC'},
+ :transaction_source => 'recurring'
+ })
+ ).returns(braintree_result)
+
+ @gateway.purchase(100, credit_card('41111111111111111111'), {test: true, order_id: '1', stored_credential: stored_credential(:merchant, :recurring, id: '123ABC')})
+ end
+
+ def test_stored_credential_installment_cit_initial
+ Braintree::TransactionGateway.any_instance.expects(:sale).with(
+ standard_purchase_params.merge(
+ {
+ :external_vault => {
+ :status => 'will_vault'},
+ :transaction_source => ''
+ })
+ ).returns(braintree_result)
+
+ @gateway.purchase(100, credit_card('41111111111111111111'), {test: true, order_id: '1', stored_credential: stored_credential(:cardholder, :installment, :initial)})
+ end
+
+ def test_stored_credential_installment_cit_used
+ Braintree::TransactionGateway.any_instance.expects(:sale).with(
+ standard_purchase_params.merge(
+ {
+ :external_vault => {
+ :status => 'vaulted',
+ :previous_network_transaction_id => '123ABC'},
+ :transaction_source => ''
+ })
+ ).returns(braintree_result)
+
+ @gateway.purchase(100, credit_card('41111111111111111111'), {test: true, order_id: '1', stored_credential: stored_credential(:cardholder, :installment, id: '123ABC')})
+ end
+
+ def test_stored_credential_installment_mit_initial
+ Braintree::TransactionGateway.any_instance.expects(:sale).with(
+ standard_purchase_params.merge(
+ {
+ :external_vault => {
+ :status => 'will_vault'},
+ :transaction_source => 'recurring'
+ })
+ ).returns(braintree_result)
+
+ @gateway.purchase(100, credit_card('41111111111111111111'), {test: true, order_id: '1', stored_credential: stored_credential(:merchant, :installment, :initial)})
+ end
+
+ def test_stored_credential_installment_mit_used
+ Braintree::TransactionGateway.any_instance.expects(:sale).with(
+ standard_purchase_params.merge(
+ {
+ :external_vault => {
+ :status => 'vaulted',
+ :previous_network_transaction_id => '123ABC'},
+ :transaction_source => 'recurring'
+ })
+ ).returns(braintree_result)
+
+ @gateway.purchase(100, credit_card('41111111111111111111'), {test: true, order_id: '1', stored_credential: stored_credential(:merchant, :installment, id: '123ABC')})
+ end
+
+ def test_stored_credential_unscheduled_cit_initial
+ Braintree::TransactionGateway.any_instance.expects(:sale).with(
+ standard_purchase_params.merge(
+ {
+ :external_vault => {
+ :status => 'will_vault'},
+ :transaction_source => ''
+ })
+ ).returns(braintree_result)
+
+ @gateway.purchase(100, credit_card('41111111111111111111'), {test: true, order_id: '1', stored_credential: stored_credential(:cardholder, :unscheduled, :initial)})
+ end
+
+ def test_stored_credential_unscheduled_cit_used
+ Braintree::TransactionGateway.any_instance.expects(:sale).with(
+ standard_purchase_params.merge(
+ {
+ :external_vault => {
+ :status => 'vaulted',
+ :previous_network_transaction_id => '123ABC'},
+ :transaction_source => ''
+ })
+ ).returns(braintree_result)
+
+ @gateway.purchase(100, credit_card('41111111111111111111'), {test: true, order_id: '1', stored_credential: stored_credential(:cardholder, :unscheduled, id: '123ABC')})
+ end
+
+ def test_stored_credential_unscheduled_mit_initial
+ Braintree::TransactionGateway.any_instance.expects(:sale).with(
+ standard_purchase_params.merge(
+ {
+ :external_vault => {
+ :status => 'will_vault'},
+ :transaction_source => 'unscheduled'
+ })
+ ).returns(braintree_result)
+
+ @gateway.purchase(100, credit_card('41111111111111111111'), {test: true, order_id: '1', stored_credential: stored_credential(:merchant, :unscheduled, :initial)})
+ end
+
+ def test_stored_credential_unscheduled_mit_used
+ Braintree::TransactionGateway.any_instance.expects(:sale).with(
+ standard_purchase_params.merge(
+ {
+ :external_vault => {
+ :status => 'vaulted',
+ :previous_network_transaction_id => '123ABC'
+ },
+ :transaction_source => 'unscheduled'
+ })
+ ).returns(braintree_result)
+
+ @gateway.purchase(100, credit_card('41111111111111111111'), {test: true, order_id: '1', stored_credential: stored_credential(:merchant, :unscheduled, id: '123ABC')})
+ end
+
private
def braintree_result(options = {})
@@ -954,4 +1117,22 @@ def with_braintree_configuration_restoration(&block)
# Reset the Braintree logger
Braintree::Configuration.logger = nil
end
+
+ def standard_purchase_params
+ {
+ :amount => '1.00',
+ :order_id => '1',
+ :customer => {:id => nil, :email => nil, :phone => nil,
+ :first_name => 'Longbob', :last_name => 'Longsen'},
+ :options => {:store_in_vault => false, :submit_for_settlement => true, :hold_in_escrow => nil},
+ :custom_fields => nil,
+ :credit_card => {
+ :number => '41111111111111111111',
+ :cvv => '123',
+ :expiration_month => '09',
+ :expiration_year => '2020',
+ :cardholder_name => 'Longbob Longsen',
+ }
+ }
+ end
end
From 072e072af311b68dfde892eda3bbfa2cffb381bc Mon Sep 17 00:00:00 2001
From: leila-alderman
Date: Wed, 17 Jul 2019 16:28:33 -0400
Subject: [PATCH 0399/2234] Realex: Re-implement credit as general credit
Re-implemented the `credit` action (known as `general_credit` in
Spreedly parlance) for the Realex gateway from its deprecated
implementation of re-using the `refund` action to performing an actual
`credit` (non-reference credit) transaction.
CE-52 / CE-58
Unit:
28 tests, 975 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
Remote:
27 tests, 138 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/realex.rb | 23 +++-
test/remote/gateways/remote_realex_test.rb | 40 +++++-
test/unit/gateways/realex_test.rb | 116 +++++++++++++++++-
4 files changed, 168 insertions(+), 12 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 2382479dc94..86327168624 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -3,6 +3,7 @@
== HEAD
* CardConnect: Move domain from gateway specific to gateway field [hdeters] #3283
* Braintree Blue: Support for stored credentials [hdeters] #3286
+* Realex: Re-implement credit as general credit [leila-alderman] #3280
== Version 1.96.0 (Jul 26, 2019)
* Bluesnap: Omit state codes for unsupported countries [therufs] #3229
diff --git a/lib/active_merchant/billing/gateways/realex.rb b/lib/active_merchant/billing/gateways/realex.rb
index 3a45955c810..137eae395b3 100644
--- a/lib/active_merchant/billing/gateways/realex.rb
+++ b/lib/active_merchant/billing/gateways/realex.rb
@@ -43,6 +43,7 @@ class RealexGateway < Gateway
def initialize(options = {})
requires!(options, :login, :password)
options[:refund_hash] = Digest::SHA1.hexdigest(options[:rebate_secret]) if options.has_key?(:rebate_secret)
+ options[:credit_hash] = Digest::SHA1.hexdigest(options[:refund_secret]) if options.has_key?(:refund_secret)
super
end
@@ -70,9 +71,9 @@ def refund(money, authorization, options = {})
commit(request)
end
- def credit(money, authorization, options = {})
- ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE
- refund(money, authorization, options)
+ def credit(money, creditcard, options = {})
+ request = build_credit_request(money, creditcard, options)
+ commit(request)
end
def void(authorization, options = {})
@@ -184,6 +185,22 @@ def build_refund_request(money, authorization, options)
xml.target!
end
+ def build_credit_request(money, credit_card, options)
+ timestamp = new_timestamp
+ xml = Builder::XmlMarkup.new :indent => 2
+ xml.tag! 'request', 'timestamp' => timestamp, 'type' => 'credit' do
+ add_merchant_details(xml, options)
+ xml.tag! 'orderid', sanitize_order_id(options[:order_id])
+ add_amount(xml, money, options)
+ add_card(xml, credit_card)
+ xml.tag! 'refundhash', @options[:credit_hash] if @options[:credit_hash]
+ xml.tag! 'autosettle', 'flag' => 1
+ add_comments(xml, options)
+ add_signed_digest(xml, timestamp, @options[:login], sanitize_order_id(options[:order_id]), amount(money), (options[:currency] || currency(money)), credit_card.number)
+ end
+ xml.target!
+ end
+
def build_void_request(authorization, options)
timestamp = new_timestamp
xml = Builder::XmlMarkup.new :indent => 2
diff --git a/test/remote/gateways/remote_realex_test.rb b/test/remote/gateways/remote_realex_test.rb
index ddac90806c5..92b415ec0c2 100644
--- a/test/remote/gateways/remote_realex_test.rb
+++ b/test/remote/gateways/remote_realex_test.rb
@@ -75,15 +75,15 @@ def test_realex_purchase_with_invalid_login
end
def test_realex_purchase_with_invalid_account
- response = RealexGateway.new(fixtures(:realex_with_account)).purchase(@amount, @visa,
+ response = RealexGateway.new(fixtures(:realex_with_account).merge(account: 'invalid')).purchase(@amount, @visa,
:order_id => generate_unique_id,
- :description => 'Test Realex purchase with invalid acocunt'
+ :description => 'Test Realex purchase with invalid account'
)
assert_not_nil response
assert_failure response
- assert_equal '504', response.params['result']
+ assert_equal '506', response.params['result']
assert_match %r{no such}i, response.message
end
@@ -390,6 +390,40 @@ def test_realex_verify_declined
assert_match %r{DECLINED}i, response.message
end
+ def test_successful_credit
+ gateway_with_refund_password = RealexGateway.new(fixtures(:realex).merge(:refund_secret => 'refund'))
+
+ credit_response = gateway_with_refund_password.credit(@amount, @visa,
+ :order_id => generate_unique_id,
+ :description => 'Test Realex Credit',
+ :billing_address => {
+ :zip => '90210',
+ :country => 'US'
+ }
+ )
+
+ assert_not_nil credit_response
+ assert_success credit_response
+ assert credit_response.authorization.length > 0
+ assert_equal 'Successful', credit_response.message
+ end
+
+ def test_failed_credit
+ credit_response = @gateway.credit(@amount, @visa,
+ :order_id => generate_unique_id,
+ :description => 'Test Realex Credit',
+ :billing_address => {
+ :zip => '90210',
+ :country => 'US'
+ }
+ )
+
+ assert_not_nil credit_response
+ assert_failure credit_response
+ assert credit_response.authorization.length > 0
+ assert_equal 'Refund Hash not present.', credit_response.message
+ end
+
def test_maps_avs_and_cvv_response_codes
[ @visa, @mastercard ].each do |card|
response = @gateway.purchase(@amount, card,
diff --git a/test/unit/gateways/realex_test.rb b/test/unit/gateways/realex_test.rb
index 1516f4b19ab..c3d5b3deeca 100644
--- a/test/unit/gateways/realex_test.rb
+++ b/test/unit/gateways/realex_test.rb
@@ -4,7 +4,7 @@ class RealexTest < Test::Unit::TestCase
class ActiveMerchant::Billing::RealexGateway
# For the purposes of testing, lets redefine some protected methods as public.
public :build_purchase_or_authorization_request, :build_refund_request, :build_void_request,
- :build_capture_request, :build_verify_request
+ :build_capture_request, :build_verify_request, :build_credit_request
end
def setup
@@ -12,6 +12,7 @@ def setup
@password = 'your_secret'
@account = 'your_account'
@rebate_secret = 'your_rebate_secret'
+ @refund_secret = 'your_refund_secret'
@gateway = RealexGateway.new(
:login => @login,
@@ -88,11 +89,14 @@ def test_unsuccessful_refund
assert_failure @gateway.refund(@amount, '1234;1234;1234')
end
- def test_deprecated_credit
- @gateway.expects(:ssl_post).returns(successful_refund_response)
- assert_deprecation_warning(Gateway::CREDIT_DEPRECATION_MESSAGE) do
- assert_success @gateway.credit(@amount, '1234;1234;1234')
- end
+ def test_successful_credit
+ @gateway.expects(:ssl_post).returns(successful_credit_response)
+ assert_success @gateway.credit(@amount, @credit_card, @options)
+ end
+
+ def test_unsuccessful_credit
+ @gateway.expects(:ssl_post).returns(unsuccessful_credit_response)
+ assert_failure @gateway.credit(@amount, @credit_card, @options)
end
def test_supported_countries
@@ -296,6 +300,69 @@ def test_refund_with_rebate_secret_xml
assert_xml_equal valid_refund_request_xml, gateway.build_refund_request(@amount, '1;4321;1234', {})
end
+ def test_credit_xml
+ options = {
+ :order_id => '1'
+ }
+
+ @gateway.expects(:new_timestamp).returns('20190717161006')
+
+ valid_credit_request_xml = <<-SRC
+
+ your_merchant_id
+ your_account
+ 1
+ 100
+
+ 4263971921001307
+ 0808
+ Longbob Longsen
+ VISA
+
+
+
+
+
+
+
+ 73ff566dcfc3a73bebf1a2d387316162111f030e
+
+SRC
+
+ assert_xml_equal valid_credit_request_xml, @gateway.build_credit_request(@amount, @credit_card, options)
+ end
+
+ def test_credit_with_refund_secret_xml
+ gateway = RealexGateway.new(:login => @login, :password => @password, :account => @account, :refund_secret => @refund_secret)
+
+ gateway.expects(:new_timestamp).returns('20190717161006')
+
+ valid_credit_request_xml = <<-SRC
+
+ your_merchant_id
+ your_account
+ 1
+ 100
+
+ 4263971921001307
+ 0808
+ Longbob Longsen
+ VISA
+
+
+
+
+
+
+ bbc192c6eac0132a039c23eae8550a22907c6796
+
+ 73ff566dcfc3a73bebf1a2d387316162111f030e
+
+SRC
+
+ assert_xml_equal valid_credit_request_xml, gateway.build_credit_request(@amount, @credit_card, @options)
+ end
+
def test_auth_with_address
@gateway.expects(:ssl_post).returns(successful_purchase_response)
@@ -569,6 +636,43 @@ def unsuccessful_refund_response
RESPONSE
end
+ def successful_credit_response
+ <<-RESPONSE
+
+ spreedly
+ internet
+ 57a861e97273371e6f1b1737a9bc5710
+ 005030
+ 00
+ U
+ U
+ U
+ 674655
+ AUTH CODE: 005030
+ 15633930303644971
+ 0
+ 0
+
+ AIB BANK
+ IRELAND
+ IE
+ EUR
+
+ 6d2fc...67814
+ "
+ RESPONSE
+ end
+
+ def unsuccessful_credit_response
+ <<-RESPONSE
+
+ 502
+ Refund Hash not present.
+ _refund_fd4ea2d10b339011bdba89f580c5b207
+ "
+ RESPONSE
+ end
+
def transcript
<<-REQUEST
From a2059bbee0438a2a191e485988492e59ec748cae Mon Sep 17 00:00:00 2001
From: Jason Nappier
Date: Wed, 31 Jul 2019 01:11:26 -0400
Subject: [PATCH 0400/2234] Paymill: Add currency and amount to store requests.
Paymill now requires a currency and amount to be specified for tokenization. These are used for an authorization. We now set this to $1 USD, which is the minimum required.
Suite test/remote/gateways/remote_paymill_test
18 tests, 74 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
All unit tests
4188 tests, 70111 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications
100% passed
Rename store_endpoint -> store_endpoint_url
Combine tests for store currency and amount
Tweak comment
Update Changelog for Paymill store change
---
CHANGELOG | 1 +
.../billing/gateways/paymill.rb | 5 +++++
test/unit/gateways/paymill_test.rb | 18 ++++++++++++++++++
3 files changed, 24 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index 86327168624..3826344f07c 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -4,6 +4,7 @@
* CardConnect: Move domain from gateway specific to gateway field [hdeters] #3283
* Braintree Blue: Support for stored credentials [hdeters] #3286
* Realex: Re-implement credit as general credit [leila-alderman] #3280
+* Paymill: Add currency and amount to store requests [jasonxp] #3289
== Version 1.96.0 (Jul 26, 2019)
* Bluesnap: Omit state codes for unsupported countries [therufs] #3229
diff --git a/lib/active_merchant/billing/gateways/paymill.rb b/lib/active_merchant/billing/gateways/paymill.rb
index caf64486d8b..ba4dbeb8f9d 100644
--- a/lib/active_merchant/billing/gateways/paymill.rb
+++ b/lib/active_merchant/billing/gateways/paymill.rb
@@ -48,6 +48,11 @@ def void(authorization, options={})
end
def store(credit_card, options={})
+ # The store request requires a currency and amount of at least $1 USD.
+ # This is used for an authorization that is handled internally by Paymill.
+ options[:currency] = 'USD'
+ options[:money] = 100
+
save_card(credit_card, options)
end
diff --git a/test/unit/gateways/paymill_test.rb b/test/unit/gateways/paymill_test.rb
index 546a98b9125..f44e8b07c30 100644
--- a/test/unit/gateways/paymill_test.rb
+++ b/test/unit/gateways/paymill_test.rb
@@ -181,6 +181,20 @@ def test_successful_store
assert response.test?
end
+ def test_store_includes_currency_and_amount
+ expected_currency = 'USD'
+ expected_amount = 100
+
+ @gateway.expects(:raw_ssl_request).with(
+ :get,
+ store_endpoint_url(@credit_card, expected_currency, expected_amount),
+ nil,
+ {}
+ ).returns(successful_store_response, successful_purchase_response)
+
+ @gateway.store(@credit_card)
+ end
+
def test_failed_store_with_invalid_credit_card
@gateway.expects(:raw_ssl_request).returns(failed_store_response)
response = @gateway.store(@credit_card)
@@ -225,6 +239,10 @@ def test_transcript_scrubbing
private
+ def store_endpoint_url(credit_card, currency, amount)
+ "https://test-token.paymill.com?account.holder=#{credit_card.first_name}+#{credit_card.last_name}&account.number=#{credit_card.number}&account.expiry.month=#{'%02d' % credit_card.month}&account.expiry.year=#{credit_card.year}&account.verification=#{credit_card.verification_value}&presentation.amount3D=#{amount}&presentation.currency3D=#{currency}&channel.id=PUBLIC&jsonPFunction=jsonPFunction&transaction.mode=CONNECTOR_TEST"
+ end
+
def successful_store_response
MockResponse.new 200, %[jsonPFunction({"transaction":{"mode":"CONNECTOR_TEST","channel":"57313835619696ac361dc591bc973626","response":"SYNC","payment":{"code":"CC.DB"},"processing":{"code":"CC.DB.90.00","reason":{"code":"00","message":"Successful Processing"},"result":"ACK","return":{"code":"000.100.112","message":"Request successfully processed in 'Merchant in Connector Test Mode'"},"timestamp":"2013-02-12 21:33:43"},"identification":{"shortId":"1998.1832.1612","uniqueId":"tok_4f9a571b39bd8d0b4db5"}}})]
end
From 7aa0477b35d6f7e34f47d34f5a2dd1befbddea52 Mon Sep 17 00:00:00 2001
From: Pierre Nespo
Date: Fri, 2 Aug 2019 13:34:10 -0400
Subject: [PATCH 0401/2234] [Orbital] Add support for 3DS (#3261)
This adds values for 3DS transactions. You can validate that those xml keys are valid by looking at the xsd.
---
.../billing/gateways/orbital.rb | 70 +++++++++++--
test/remote/gateways/remote_orbital_test.rb | 97 +++++++++++++++++++
test/unit/gateways/orbital_test.rb | 65 +++++++++++++
3 files changed, 222 insertions(+), 10 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/orbital.rb b/lib/active_merchant/billing/gateways/orbital.rb
index 93246833526..aad16855ea2 100644
--- a/lib/active_merchant/billing/gateways/orbital.rb
+++ b/lib/active_merchant/billing/gateways/orbital.rb
@@ -465,16 +465,62 @@ def add_creditcard(xml, creditcard, currency=nil)
end
end
- def add_cdpt_eci_and_xid(xml, creditcard)
- xml.tag! :AuthenticationECIInd, creditcard.eci
- xml.tag! :XID, creditcard.transaction_id if creditcard.transaction_id
+ def add_eci(xml, creditcard, three_d_secure)
+ eci = if three_d_secure
+ three_d_secure[:eci]
+ elsif creditcard.is_a?(NetworkTokenizationCreditCard)
+ creditcard.eci
+ end
+
+ xml.tag!(:AuthenticationECIInd, eci) if eci
+ end
+
+ def add_xid(xml, creditcard, three_d_secure)
+ xid = if three_d_secure && creditcard.brand == 'visa'
+ three_d_secure[:xid]
+ elsif creditcard.is_a?(NetworkTokenizationCreditCard)
+ creditcard.transaction_id
+ end
+
+ xml.tag!(:XID, xid) if xid
+ end
+
+ def add_cavv(xml, creditcard, three_d_secure)
+ return unless three_d_secure && creditcard.brand == 'visa'
+
+ xml.tag!(:CAVV, three_d_secure[:cavv])
+ end
+
+ def add_aav(xml, creditcard, three_d_secure)
+ return unless three_d_secure && creditcard.brand == 'master'
+
+ xml.tag!(:AAV, three_d_secure[:cavv])
end
- def add_cdpt_payment_cryptogram(xml, creditcard)
+ def add_dpanind(xml, creditcard)
+ return unless creditcard.is_a?(NetworkTokenizationCreditCard)
+
xml.tag! :DPANInd, 'Y'
+ end
+
+ def add_digital_token_cryptogram(xml, creditcard)
+ return unless creditcard.is_a?(NetworkTokenizationCreditCard)
+
xml.tag! :DigitalTokenCryptogram, creditcard.payment_cryptogram
end
+ def add_aevv(xml, creditcard, three_d_secure)
+ return unless three_d_secure && creditcard.brand == 'american_express'
+
+ xml.tag!(:AEVV, three_d_secure[:cavv])
+ end
+
+ def add_pymt_brand_program_code(xml, creditcard, three_d_secure)
+ return unless three_d_secure && creditcard.brand == 'american_express'
+
+ xml.tag!(:PymtBrandProgramCode, 'ASK')
+ end
+
def add_refund(xml, currency=nil)
xml.tag! :AccountNum, nil
@@ -633,9 +679,11 @@ def build_new_order_xml(action, money, creditcard, parameters = {})
yield xml if block_given?
- if creditcard.is_a?(NetworkTokenizationCreditCard)
- add_cdpt_eci_and_xid(xml, creditcard)
- end
+ three_d_secure = parameters[:three_d_secure]
+
+ add_eci(xml, creditcard, three_d_secure)
+ add_cavv(xml, creditcard, three_d_secure)
+ add_xid(xml, creditcard, three_d_secure)
xml.tag! :OrderID, format_order_id(parameters[:order_id])
xml.tag! :Amount, amount(money)
@@ -644,11 +692,12 @@ def build_new_order_xml(action, money, creditcard, parameters = {})
add_level_2_tax(xml, parameters)
add_level_2_advice_addendum(xml, parameters)
+ add_aav(xml, creditcard, three_d_secure)
# CustomerAni, AVSPhoneType and AVSDestPhoneType could be added here.
- if creditcard.is_a?(NetworkTokenizationCreditCard)
- add_cdpt_payment_cryptogram(xml, creditcard)
- end
+ add_dpanind(xml, creditcard)
+ add_aevv(xml, creditcard, three_d_secure)
+ add_digital_token_cryptogram(xml, creditcard)
if parameters[:soft_descriptors].is_a?(OrbitalSoftDescriptors)
add_soft_descriptors(xml, parameters[:soft_descriptors])
@@ -666,6 +715,7 @@ def build_new_order_xml(action, money, creditcard, parameters = {})
add_level_2_purchase(xml, parameters)
add_stored_credentials(xml, parameters)
+ add_pymt_brand_program_code(xml, creditcard, three_d_secure)
end
end
xml.target!
diff --git a/test/remote/gateways/remote_orbital_test.rb b/test/remote/gateways/remote_orbital_test.rb
index f85e53c28d3..92e7c3a7d9b 100644
--- a/test/remote/gateways/remote_orbital_test.rb
+++ b/test/remote/gateways/remote_orbital_test.rb
@@ -132,6 +132,103 @@ def test_successful_purchase_with_discover_network_tokenization_credit_card
assert_false response.authorization.blank?
end
+ [
+ {
+ card: {
+ number: '4112344112344113',
+ verification_value: '411',
+ brand: 'visa',
+ },
+ three_d_secure: {
+ eci: '5',
+ cavv: 'AAABAIcJIoQDIzAgVAkiAAAAAAA=',
+ xid: 'AAABAIcJIoQDIzAgVAkiAAAAAAA=',
+ },
+ address: {
+ address1: '55 Forever Ave',
+ address2: '',
+ city: 'Concord',
+ state: 'NH',
+ zip: '03301',
+ country: 'US',
+ },
+ },
+ {
+ card: {
+ number: '5112345112345114',
+ verification_value: '823',
+ brand: 'master',
+ },
+ three_d_secure: {
+ eci: '6',
+ cavv: 'Asju1ljfl86bAAAAAACm9zU6aqY=',
+ xid: 'Asju1ljfl86bAAAAAACm9zU6aqY=',
+ },
+ address: {
+ address1: 'Byway Street',
+ address2: '',
+ city: 'Portsmouth',
+ state: 'MA',
+ zip: '',
+ country: 'US',
+ },
+ },
+ {
+ card: {
+ number: '371144371144376',
+ verification_value: '1234',
+ brand: 'american_express',
+ },
+ three_d_secure: {
+ eci: '5',
+ cavv: 'AAABBWcSNIdjeUZThmNHAAAAAAA=',
+ xid: 'AAABBWcSNIdjeUZThmNHAAAAAAA=',
+ },
+ address: {
+ address1: '4 Northeastern Blvd',
+ address2: '',
+ city: 'Salem',
+ state: 'NH',
+ zip: '03105',
+ country: 'US',
+ },
+ }
+ ].each do |fixture|
+ define_method("test_successful_#{fixture[:card][:brand]}_authorization_with_3ds") do
+ cc = credit_card(fixture[:card][:number], {
+ verification_value: fixture[:card][:verification_value],
+ brand: fixture[:card][:brand]
+ })
+ assert response = @gateway.authorize(100, cc, @options.merge(
+ order_id: '2',
+ currency: 'USD',
+ three_d_secure: fixture[:three_d_secure],
+ address: fixture[:address]
+ ))
+
+ assert_success response
+ assert_equal 'Approved', response.message
+ assert_false response.authorization.blank?
+ end
+
+ define_method("test_successful_#{fixture[:card][:brand]}_purchase_with_3ds") do
+ cc = credit_card(fixture[:card][:number], {
+ verification_value: fixture[:card][:verification_value],
+ brand: fixture[:card][:brand]
+ })
+ assert response = @gateway.purchase(100, cc, @options.merge(
+ order_id: '2',
+ currency: 'USD',
+ three_d_secure: fixture[:three_d_secure],
+ address: fixture[:address]
+ ))
+
+ assert_success response
+ assert_equal 'Approved', response.message
+ assert_false response.authorization.blank?
+ end
+ end
+
def test_successful_purchase_with_mit_stored_credentials
mit_stored_credentials = {
mit_msg_type: 'MUSE',
diff --git a/test/unit/gateways/orbital_test.rb b/test/unit/gateways/orbital_test.rb
index 1ef99beb2db..6f594600095 100644
--- a/test/unit/gateways/orbital_test.rb
+++ b/test/unit/gateways/orbital_test.rb
@@ -50,6 +50,13 @@ def setup
initiator: 'customer'
}
}
+ @three_d_secure_options = {
+ three_d_secure: {
+ eci: '5',
+ xid: 'TESTXID',
+ cavv: 'TESTCAVV',
+ }
+ }
end
def test_successful_purchase
@@ -92,6 +99,64 @@ def test_network_tokenization_credit_card_data
end.respond_with(successful_purchase_response)
end
+ def test_three_d_secure_data_on_visa_purchase
+ stub_comms do
+ @gateway.purchase(50, credit_card, @options.merge(@three_d_secure_options))
+ end.check_request do |endpoint, data, headers|
+ assert_match %{5}, data
+ assert_match %{TESTCAVV}, data
+ assert_match %{TESTXID}, data
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_three_d_secure_data_on_visa_authorization
+ stub_comms do
+ @gateway.authorize(50, credit_card, @options.merge(@three_d_secure_options))
+ end.check_request do |endpoint, data, headers|
+ assert_match %{5}, data
+ assert_match %{TESTCAVV}, data
+ assert_match %{TESTXID}, data
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_three_d_secure_data_on_master_purchase
+ stub_comms do
+ @gateway.purchase(50, credit_card(nil, brand: 'master'), @options.merge(@three_d_secure_options))
+ end.check_request do |endpoint, data, headers|
+ assert_match %{5}, data
+ assert_match %{TESTCAVV}, data
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_three_d_secure_data_on_master_authorization
+ stub_comms do
+ @gateway.authorize(50, credit_card(nil, brand: 'master'), @options.merge(@three_d_secure_options))
+ end.check_request do |endpoint, data, headers|
+ assert_match %{5}, data
+ assert_match %{TESTCAVV}, data
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_three_d_secure_data_on_american_express_purchase
+ stub_comms do
+ @gateway.purchase(50, credit_card(nil, brand: 'american_express'), @options.merge(@three_d_secure_options))
+ end.check_request do |endpoint, data, headers|
+ assert_match %{5}, data
+ assert_match %{TESTCAVV}, data
+ assert_match %{ASK}, data
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_three_d_secure_data_on_american_express_authorization
+ stub_comms do
+ @gateway.authorize(50, credit_card(nil, brand: 'american_express'), @options.merge(@three_d_secure_options))
+ end.check_request do |endpoint, data, headers|
+ assert_match %{5}, data
+ assert_match %{TESTCAVV}, data
+ assert_match %{ASK}, data
+ end.respond_with(successful_purchase_response)
+ end
+
def test_currency_exponents
stub_comms do
@gateway.purchase(50, credit_card, :order_id => '1')
From 0077a594e4699a3bdf2950ed3d90b72fec0282a7 Mon Sep 17 00:00:00 2001
From: Jason Nappier
Date: Thu, 1 Aug 2019 01:37:16 -0400
Subject: [PATCH 0402/2234] Realex: Fix a runtime error that occurs when the
rebate_secret or refund_secret option is set to nil. In that case, the Realex
gateway initializer attempted to calculate the refund hash or credit hash,
passing nil to Digest::SHA1.hexdigest,which caused the error. The fix is to
only compute each hash if a secret has actually been provided.
All unit tests
4189 tests, 70115 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications
100% passed
Loaded suite test/remote/gateways/remote_realex_test
27 tests, 138 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
CE-52
Closes #3291
---
CHANGELOG | 1 +
.../billing/gateways/realex.rb | 4 +-
test/unit/gateways/realex_test.rb | 37 +++++++++++++++++++
3 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 3826344f07c..530817a8161 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -5,6 +5,7 @@
* Braintree Blue: Support for stored credentials [hdeters] #3286
* Realex: Re-implement credit as general credit [leila-alderman] #3280
* Paymill: Add currency and amount to store requests [jasonxp] #3289
+* Realex: Prevent error calculating `refund_hash` or `credit_hash` when the secret is nil [jasonxp] #3291
== Version 1.96.0 (Jul 26, 2019)
* Bluesnap: Omit state codes for unsupported countries [therufs] #3229
diff --git a/lib/active_merchant/billing/gateways/realex.rb b/lib/active_merchant/billing/gateways/realex.rb
index 137eae395b3..ca402a5ca97 100644
--- a/lib/active_merchant/billing/gateways/realex.rb
+++ b/lib/active_merchant/billing/gateways/realex.rb
@@ -42,8 +42,8 @@ class RealexGateway < Gateway
def initialize(options = {})
requires!(options, :login, :password)
- options[:refund_hash] = Digest::SHA1.hexdigest(options[:rebate_secret]) if options.has_key?(:rebate_secret)
- options[:credit_hash] = Digest::SHA1.hexdigest(options[:refund_secret]) if options.has_key?(:refund_secret)
+ options[:refund_hash] = Digest::SHA1.hexdigest(options[:rebate_secret]) if options[:rebate_secret].present?
+ options[:credit_hash] = Digest::SHA1.hexdigest(options[:refund_secret]) if options[:refund_secret].present?
super
end
diff --git a/test/unit/gateways/realex_test.rb b/test/unit/gateways/realex_test.rb
index c3d5b3deeca..a672d03ec73 100644
--- a/test/unit/gateways/realex_test.rb
+++ b/test/unit/gateways/realex_test.rb
@@ -51,6 +51,43 @@ def setup
@amount = 100
end
+ def test_initialize_sets_refund_and_credit_hashes
+ refund_secret = 'refund'
+ rebate_secret = 'rebate'
+
+ gateway = RealexGateway.new(
+ login: @login,
+ password: @password,
+ rebate_secret: rebate_secret,
+ refund_secret: refund_secret
+ )
+
+ assert gateway.options[:refund_hash] == Digest::SHA1.hexdigest(rebate_secret)
+ assert gateway.options[:credit_hash] == Digest::SHA1.hexdigest(refund_secret)
+ end
+
+ def test_initialize_with_nil_refund_and_rebate_secrets
+ gateway = RealexGateway.new(
+ login: @login,
+ password: @password,
+ rebate_secret: nil,
+ refund_secret: nil
+ )
+
+ assert_false gateway.options.key?(:refund_hash)
+ assert_false gateway.options.key?(:credit_hash)
+ end
+
+ def test_initialize_without_refund_and_rebate_secrets
+ gateway = RealexGateway.new(
+ login: @login,
+ password: @password
+ )
+
+ assert_false gateway.options.key?(:refund_hash)
+ assert_false gateway.options.key?(:credit_hash)
+ end
+
def test_hash
gateway = RealexGateway.new(
:login => 'thestore',
From d18ab772b0337c8ec210a558817f67b9e0154b17 Mon Sep 17 00:00:00 2001
From: Alex Dunae
Date: Wed, 7 Aug 2019 12:59:34 -0700
Subject: [PATCH 0403/2234] Beanstream: Pass card owner when storing tokenized
cards (#3007)
---
CHANGELOG | 2 +-
lib/active_merchant/billing/gateways/beanstream.rb | 2 ++
.../billing/gateways/beanstream/beanstream_core.rb | 3 +++
3 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 530817a8161..70da953ffcc 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
= ActiveMerchant CHANGELOG
== HEAD
+* Bambora formerly Beanstream: Pass card owner when storing tokenized cards [#3006]
* CardConnect: Move domain from gateway specific to gateway field [hdeters] #3283
* Braintree Blue: Support for stored credentials [hdeters] #3286
* Realex: Re-implement credit as general credit [leila-alderman] #3280
@@ -197,7 +198,6 @@
* Forte: Allow void on capture [nfarve] #3059
== Version 1.86.0 (October 26, 2018)
-* UsaEpayTransaction: Support UMcheckformat option for echecks [dtykocki] #3002
* Global Collect: handle internal server errors [molbrown] #3005
* Barclaycard Smartpay: allow third-party payouts for credits [bpollack] #3009
* RuboCop: AlignHash [nfarve] #3004
diff --git a/lib/active_merchant/billing/gateways/beanstream.rb b/lib/active_merchant/billing/gateways/beanstream.rb
index aedcac80462..de03c2a1afa 100644
--- a/lib/active_merchant/billing/gateways/beanstream.rb
+++ b/lib/active_merchant/billing/gateways/beanstream.rb
@@ -153,6 +153,8 @@ def interac
# To match the other stored-value gateways, like TrustCommerce,
# store and unstore need to be defined
+ #
+ # When passing a single-use token the :name option is required
def store(payment_method, options = {})
post = {}
add_address(post, options)
diff --git a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb
index 5d0640262fe..e34e6daed12 100644
--- a/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb
+++ b/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb
@@ -315,6 +315,9 @@ def add_secure_profile_variables(post, options = {})
post[:operationType] = options[:operationType] || options[:operation] || secure_profile_action(:new)
post[:customerCode] = options[:billing_id] || options[:vault_id] || false
post[:status] = options[:status]
+
+ billing_address = options[:billing_address] || options[:address]
+ post[:trnCardOwner] = billing_address[:name]
end
def add_recurring_amount(post, money)
From 6e936e8df8ab101d76ec115d2f0c865c2c254bb0 Mon Sep 17 00:00:00 2001
From: Dmitriy Nevzorov
Date: Fri, 9 Aug 2019 21:09:40 +0300
Subject: [PATCH 0404/2234] add MONEI 3d secure support (#3292)
* add MONEI 3d secure support
* remove trailing whitespaces
* add more unit and remote tests for MONEI gateway
---
lib/active_merchant/billing/gateways/monei.rb | 31 +++++++++++++++++++
test/remote/gateways/remote_monei_test.rb | 27 ++++++++++++++++
test/unit/gateways/monei_test.rb | 25 ++++++++++++---
3 files changed, 79 insertions(+), 4 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/monei.rb b/lib/active_merchant/billing/gateways/monei.rb
index a5fce7eb0f0..37247721a6a 100755
--- a/lib/active_merchant/billing/gateways/monei.rb
+++ b/lib/active_merchant/billing/gateways/monei.rb
@@ -133,6 +133,7 @@ def execute_new_order(action, money, credit_card, options)
add_payment(xml, action, money, options)
add_account(xml, credit_card)
add_customer(xml, credit_card, options)
+ add_three_d_secure(xml, options)
end
commit(request)
@@ -225,6 +226,36 @@ def add_customer(xml, credit_card, options)
end
end
+ # Private : Convert ECI to ResultIndicator
+ # Possible ECI values:
+ # 02 or 05 - Fully Authenticated Transaction
+ # 00 or 07 - Non 3D Secure Transaction
+ # Possible ResultIndicator values:
+ # 01 = MASTER_3D_ATTEMPT
+ # 02 = MASTER_3D_SUCCESS
+ # 05 = VISA_3D_SUCCESS
+ # 06 = VISA_3D_ATTEMPT
+ # 07 = DEFAULT_E_COMMERCE
+ def eci_to_result_indicator(eci)
+ case eci
+ when '02', '05'
+ return eci
+ else
+ return '07'
+ end
+ end
+
+ # Private : Add the 3DSecure infos to XML
+ def add_three_d_secure(xml, options)
+ if options[:three_d_secure]
+ xml.Authentication(:type => '3DSecure') do
+ xml.ResultIndicator eci_to_result_indicator options[:three_d_secure][:eci]
+ xml.Parameter(:name => 'VERIFICATION_ID') { xml.text options[:three_d_secure][:cavv] }
+ xml.Parameter(:name => 'XID') { xml.text options[:three_d_secure][:xid] }
+ end
+ end
+ end
+
# Private: Parse XML response from Monei servers
def parse(body)
xml = Nokogiri::XML(body)
diff --git a/test/remote/gateways/remote_monei_test.rb b/test/remote/gateways/remote_monei_test.rb
index 474f317c76a..984187d4dee 100755
--- a/test/remote/gateways/remote_monei_test.rb
+++ b/test/remote/gateways/remote_monei_test.rb
@@ -24,12 +24,39 @@ def test_successful_purchase
assert_equal 'Request successfully processed in \'Merchant in Connector Test Mode\'', response.message
end
+ def test_successful_purchase_with_3ds
+ options = @options.merge!({
+ three_d_secure: {
+ eci: '05',
+ cavv: 'AAACAgSRBklmQCFgMpEGAAAAAAA=',
+ xid: 'CAACCVVUlwCXUyhQNlSXAAAAAAA='
+ }
+ })
+ response = @gateway.purchase(@amount, @credit_card, options)
+
+ assert_success response
+ assert_equal 'Request successfully processed in \'Merchant in Connector Test Mode\'', response.message
+ end
+
def test_failed_purchase
response = @gateway.purchase(@amount, @declined_card, @options)
assert_failure response
assert_equal 'invalid cc number/brand combination', response.message
end
+ def test_failed_purchase_with_3ds
+ options = @options.merge!({
+ three_d_secure: {
+ eci: '05',
+ cavv: 'INVALID_Verification_ID',
+ xid: 'CAACCVVUlwCXUyhQNlSXAAAAAAA='
+ }
+ })
+ response = @gateway.purchase(@amount, @credit_card, options)
+ assert_failure response
+ assert_equal 'Invalid 3DSecure Verification_ID. Must have Base64 encoding a Length of 28 digits', response.message
+ end
+
def test_successful_authorize_and_capture
auth = @gateway.authorize(@amount, @credit_card, @options)
assert_success auth
diff --git a/test/unit/gateways/monei_test.rb b/test/unit/gateways/monei_test.rb
index 27b70aff1bd..79d9a2c2365 100755
--- a/test/unit/gateways/monei_test.rb
+++ b/test/unit/gateways/monei_test.rb
@@ -5,10 +5,7 @@ class MoneiTest < Test::Unit::TestCase
def setup
@gateway = MoneiGateway.new(
- :sender_id => 'mother',
- :channel_id => 'there is no other',
- :login => 'like mother',
- :pwd => 'so treat Her right'
+ fixtures(:monei)
)
@credit_card = credit_card
@@ -130,6 +127,26 @@ def test_failed_verify
assert_failure response
end
+ def test_3ds_request
+ three_d_secure_options = {
+ eci: '05',
+ cavv: 'AAACAgSRBklmQCFgMpEGAAAAAAA=',
+ xid: 'CAACCVVUlwCXUyhQNlSXAAAAAAA='
+ }
+ options = @options.merge!({
+ three_d_secure: three_d_secure_options
+ })
+ stub_comms do
+ @gateway.purchase(@amount, @credit_card, options)
+ end.check_request do |endpoint, data, headers|
+ body = CGI.unescape data
+ assert_match %r{}, body
+ assert_match %r{05}, body
+ assert_match %r{#{three_d_secure_options[:cavv]}}, body
+ assert_match %r{#{three_d_secure_options[:xid]}}, body
+ end.respond_with(successful_purchase_response)
+ end
+
private
def successful_purchase_response
From d3bbd1bd70387f7f01e98f72605657214e9aca31 Mon Sep 17 00:00:00 2001
From: leila-alderman
Date: Tue, 6 Aug 2019 16:06:08 -0400
Subject: [PATCH 0405/2234] MercadoPago: Add Cabal card type
Added the Cabal card type to Active Merchant and to the MercadoPago
gateway.
CE-64
Unit:
25 tests, 129 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
Remote:
26 tests, 76 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
92.3077% passed
The `test_partial_capture` and
`test_successful_purchase_with_processing_mode_gateway` remote tests are
currently failing and were failing prior to making any of these changes.
---
CHANGELOG | 1 +
lib/active_merchant/billing/credit_card.rb | 2 +
.../billing/credit_card_methods.rb | 7 +++
.../billing/gateways/mercado_pago.rb | 2 +-
.../gateways/remote_mercado_pago_test.rb | 42 ++++++++++++++
test/unit/credit_card_methods_test.rb | 6 ++
test/unit/gateways/mercado_pago_test.rb | 58 +++++++++++++++++++
7 files changed, 117 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 70da953ffcc..151a7567392 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -7,6 +7,7 @@
* Realex: Re-implement credit as general credit [leila-alderman] #3280
* Paymill: Add currency and amount to store requests [jasonxp] #3289
* Realex: Prevent error calculating `refund_hash` or `credit_hash` when the secret is nil [jasonxp] #3291
+* MercadoPago: Add Cabal card type [leila-alderman] #3295
== Version 1.96.0 (Jul 26, 2019)
* Bluesnap: Omit state codes for unsupported countries [therufs] #3229
diff --git a/lib/active_merchant/billing/credit_card.rb b/lib/active_merchant/billing/credit_card.rb
index 1a0c097636e..7dad6011089 100644
--- a/lib/active_merchant/billing/credit_card.rb
+++ b/lib/active_merchant/billing/credit_card.rb
@@ -20,6 +20,7 @@ module Billing #:nodoc:
# * Forbrugsforeningen
# * Elo
# * Alelo
+ # * Cabal
#
# For testing purposes, use the 'bogus' credit card brand. This skips the vast majority of
# validations, allowing you to focus on your core concerns until you're ready to be more concerned
@@ -92,6 +93,7 @@ def number=(value)
# * +'forbrugsforeningen'+
# * +'elo'+
# * +'alelo'+
+ # * +'cabal'+
#
# Or, if you wish to test your implementation, +'bogus'+.
#
diff --git a/lib/active_merchant/billing/credit_card_methods.rb b/lib/active_merchant/billing/credit_card_methods.rb
index 355e039fc6c..5b030c9eb8f 100644
--- a/lib/active_merchant/billing/credit_card_methods.rb
+++ b/lib/active_merchant/billing/credit_card_methods.rb
@@ -16,6 +16,7 @@ module CreditCardMethods
'forbrugsforeningen' => ->(num) { num =~ /^600722\d{10}$/ },
'sodexo' => ->(num) { num =~ /^(606071|603389|606070|606069|606068|600818)\d{10}$/ },
'vr' => ->(num) { num =~ /^(627416|637036)\d{10}$/ },
+ 'cabal' => ->(num) { num&.size == 16 && in_bin_range?(num.slice(0, 8), CABAL_RANGES) },
'carnet' => lambda { |num|
num&.size == 16 && (
in_bin_range?(num.slice(0, 6), CARNET_RANGES) ||
@@ -93,6 +94,12 @@ module CreditCardMethods
506770..506771, 509015..509019, 509880..509882, 509884..509885, 509987..509988
]
+ CABAL_RANGES = [
+ 60420100..60440099,
+ 58965700..58965799,
+ 60352200..60352299
+ ]
+
def self.included(base)
base.extend(ClassMethods)
end
diff --git a/lib/active_merchant/billing/gateways/mercado_pago.rb b/lib/active_merchant/billing/gateways/mercado_pago.rb
index f8bcc688fb7..165cd138f38 100644
--- a/lib/active_merchant/billing/gateways/mercado_pago.rb
+++ b/lib/active_merchant/billing/gateways/mercado_pago.rb
@@ -4,7 +4,7 @@ class MercadoPagoGateway < Gateway
self.live_url = self.test_url = 'https://api.mercadopago.com/v1'
self.supported_countries = ['AR', 'BR', 'CL', 'CO', 'MX', 'PE', 'UY']
- self.supported_cardtypes = [:visa, :master, :american_express, :elo]
+ self.supported_cardtypes = [:visa, :master, :american_express, :elo, :cabal]
self.homepage_url = 'https://www.mercadopago.com/'
self.display_name = 'Mercado Pago'
diff --git a/test/remote/gateways/remote_mercado_pago_test.rb b/test/remote/gateways/remote_mercado_pago_test.rb
index d715d49d04d..f6a9e0fc0bb 100644
--- a/test/remote/gateways/remote_mercado_pago_test.rb
+++ b/test/remote/gateways/remote_mercado_pago_test.rb
@@ -3,6 +3,7 @@
class RemoteMercadoPagoTest < Test::Unit::TestCase
def setup
@gateway = MercadoPagoGateway.new(fixtures(:mercado_pago))
+ @argentina_gateway = MercadoPagoGateway.new(fixtures(:mercado_pago_argentina))
@amount = 500
@credit_card = credit_card('4509953566233704')
@@ -13,6 +14,13 @@ def setup
:last_name => 'Smith',
:verification_value => '737'
)
+ @cabal_credit_card = credit_card('6035227716427021',
+ :month => 10,
+ :year => 2020,
+ :first_name => 'John',
+ :last_name => 'Smith',
+ :verification_value => '737'
+ )
@declined_card = credit_card('4000300011112220')
@options = {
billing_address: address,
@@ -41,6 +49,12 @@ def test_successful_purchase_with_elo
assert_equal 'accredited', response.message
end
+ def test_successful_purchase_with_cabal
+ response = @argentina_gateway.purchase(@amount, @cabal_credit_card, @options)
+ assert_success response
+ assert_equal 'accredited', response.message
+ end
+
def test_successful_purchase_with_binary_false
@options.update(binary_mode: false)
response = @gateway.authorize(@amount, @credit_card, @options)
@@ -90,6 +104,16 @@ def test_successful_authorize_and_capture_with_elo
assert_equal 'accredited', capture.message
end
+ def test_successful_authorize_and_capture_with_cabal
+ auth = @argentina_gateway.authorize(@amount, @cabal_credit_card, @options)
+ assert_success auth
+ assert_equal 'pending_capture', auth.message
+
+ assert capture = @argentina_gateway.capture(@amount, auth.authorization)
+ assert_success capture
+ assert_equal 'accredited', capture.message
+ end
+
def test_failed_authorize
response = @gateway.authorize(@amount, @declined_card, @options)
assert_failure response
@@ -129,6 +153,15 @@ def test_successful_refund_with_elo
assert_equal nil, refund.message
end
+ def test_successful_refund_with_cabal
+ purchase = @argentina_gateway.purchase(@amount, @cabal_credit_card, @options)
+ assert_success purchase
+
+ assert refund = @argentina_gateway.refund(@amount, purchase.authorization)
+ assert_success refund
+ assert_equal nil, refund.message
+ end
+
def test_partial_refund
purchase = @gateway.purchase(@amount, @credit_card, @options)
assert_success purchase
@@ -161,6 +194,15 @@ def test_successful_void_with_elo
assert_equal 'by_collector', void.message
end
+ def test_successful_void_with_cabal
+ auth = @argentina_gateway.authorize(@amount, @cabal_credit_card, @options)
+ assert_success auth
+
+ assert void = @argentina_gateway.void(auth.authorization)
+ assert_success void
+ assert_equal 'by_collector', void.message
+ end
+
def test_failed_void
response = @gateway.void('')
assert_failure response
diff --git a/test/unit/credit_card_methods_test.rb b/test/unit/credit_card_methods_test.rb
index fed753f9fc0..1b141a19af3 100644
--- a/test/unit/credit_card_methods_test.rb
+++ b/test/unit/credit_card_methods_test.rb
@@ -155,6 +155,12 @@ def test_should_detect_alelo_number_beginning_with_4_as_visa
assert_equal 'visa', CreditCard.brand?('4025880000000044')
end
+ def test_should_detect_cabal_card
+ assert_equal 'cabal', CreditCard.brand?('6044009000000000')
+ assert_equal 'cabal', CreditCard.brand?('5896575500000000')
+ assert_equal 'cabal', CreditCard.brand?('6035224400000000')
+ end
+
def test_should_detect_when_an_argument_brand_does_not_match_calculated_brand
assert CreditCard.matching_brand?('4175001000000000', 'visa')
assert_false CreditCard.matching_brand?('4175001000000000', 'master')
diff --git a/test/unit/gateways/mercado_pago_test.rb b/test/unit/gateways/mercado_pago_test.rb
index 3690b766f46..a0a9a0c3429 100644
--- a/test/unit/gateways/mercado_pago_test.rb
+++ b/test/unit/gateways/mercado_pago_test.rb
@@ -13,6 +13,13 @@ def setup
:last_name => 'Smith',
:verification_value => '737'
)
+ @cabal_credit_card = credit_card('6035227716427021',
+ :month => 10,
+ :year => 2020,
+ :first_name => 'John',
+ :last_name => 'Smith',
+ :verification_value => '737'
+ )
@amount = 100
@options = {
@@ -44,6 +51,17 @@ def test_successful_purchase_with_elo
assert response.test?
end
+ def test_successful_purchase_with_cabal
+ @gateway.expects(:ssl_post).at_most(2).returns(successful_purchase_with_cabal_response)
+
+ response = @gateway.purchase(@amount, @cabal_credit_card, @options)
+ assert_success response
+
+ assert_equal '20728968|1.0', response.authorization
+ assert_equal 'accredited', response.message
+ assert response.test?
+ end
+
def test_failed_purchase
@gateway.expects(:ssl_post).at_most(2).returns(failed_purchase_response)
@@ -75,6 +93,17 @@ def test_successful_authorize_with_elo
assert response.test?
end
+ def test_successful_authorize_with_cabal
+ @gateway.expects(:ssl_post).at_most(2).returns(successful_authorize_with_cabal_response)
+
+ response = @gateway.authorize(@amount, @cabal_credit_card, @options)
+ assert_success response
+
+ assert_equal '20729288|1.0', response.authorization
+ assert_equal 'pending_capture', response.message
+ assert response.test?
+ end
+
def test_failed_authorize
@gateway.expects(:ssl_post).at_most(2).returns(failed_authorize_response)
@@ -106,6 +135,17 @@ def test_successful_capture_with_elo
assert response.test?
end
+ def test_successful_capture_with_cabal
+ @gateway.expects(:ssl_request).returns(successful_capture_with_cabal_response)
+
+ response = @gateway.capture(@amount, 'authorization|amount')
+ assert_success response
+
+ assert_equal '20729288|1.0', response.authorization
+ assert_equal 'accredited', response.message
+ assert response.test?
+ end
+
def test_failed_capture
@gateway.expects(:ssl_request).returns(failed_capture_response)
@@ -379,6 +419,12 @@ def successful_purchase_with_elo_response
)
end
+ def successful_purchase_with_cabal_response
+ %(
+ {"id":20728968,"date_created":"2019-08-06T15:38:12.000-04:00","date_approved":"2019-08-06T15:38:12.000-04:00","date_last_updated":"2019-08-06T15:38:12.000-04:00","date_of_expiration":null,"money_release_date":"2019-08-20T15:38:12.000-04:00","operation_type":"regular_payment","issuer_id":"688","payment_method_id":"cabal","payment_type_id":"credit_card","status":"approved","status_detail":"accredited","currency_id":"ARS","description":"Store Purchase","live_mode":false,"sponsor_id":null,"authorization_code":null,"money_release_schema":null,"taxes_amount":0,"counter_currency":null,"shipping_amount":0,"pos_id":null,"store_id":null,"collector_id":388534608,"payer":{"first_name":"Test","last_name":"Test","email":"test_user_80507629@testuser.com","identification":{"number":"32659430","type":"DNI"},"phone":{"area_code":"01","number":"1111-1111","extension":""},"type":"registered","entity_type":null,"id":"388571255"},"metadata":{},"additional_info":{"payer":{"address":{"zip_code":"K1C2N6","street_name":"456 My Street Apt 1"}},"shipments":{"receiver_address":{"zip_code":"K1C2N6","street_name":"456 My Street Apt 1"}}},"order":{},"external_reference":"ab86ce493d1cc1e447877720843812e9","transaction_amount":5,"transaction_amount_refunded":0,"coupon_amount":0,"differential_pricing_id":null,"deduction_schema":null,"transaction_details":{"payment_method_reference_id":null,"net_received_amount":4.79,"total_paid_amount":5,"overpaid_amount":0,"external_resource_url":null,"installment_amount":5,"financial_institution":null,"payable_deferral_period":null,"acquirer_reference":null},"fee_details":[{"type":"mercadopago_fee","amount":0.21,"fee_payer":"collector"}],"captured":true,"binary_mode":true,"call_for_authorize_id":null,"statement_descriptor":"SPREEDLYMLA","installments":1,"card":{"id":null,"first_six_digits":"603522","last_four_digits":"7021","expiration_month":10,"expiration_year":2020,"date_created":"2019-08-06T15:38:12.000-04:00","date_last_updated":"2019-08-06T15:38:12.000-04:00","cardholder":{"name":"John Smith","identification":{"number":null,"type":null}}},"notification_url":null,"refunds":[],"processing_mode":"aggregator","merchant_account_id":null,"acquirer":null,"merchant_number":null,"acquirer_reconciliation":[]}
+ )
+ end
+
def failed_purchase_response
%(
{"id":4142297,"date_created":"2017-07-06T10:13:32.000-04:00","date_approved":null,"date_last_updated":"2017-07-06T10:13:32.000-04:00","date_of_expiration":null,"money_release_date":null,"operation_type":"regular_payment","issuer_id":"166","payment_method_id":"visa","payment_type_id":"credit_card","status":"rejected","status_detail":"cc_rejected_other_reason","currency_id":"MXN","description":"Store Purchase","live_mode":false,"sponsor_id":null,"authorization_code":null,"related_exchange_rate":null,"collector_id":261735089,"payer":{"type":"guest","id":null,"email":"user@example.com","identification":{"type":null,"number":null},"phone":{"area_code":null,"number":null,"extension":""},"first_name":"First User","last_name":"User","entity_type":null},"metadata":{},"additional_info":{"payer":{"address":{"zip_code":"K1C2N6","street_name":"My Street","street_number":"456"}}},"order":{"type":"mercadopago","id":"830943860538524456"},"external_reference":null,"transaction_amount":5,"transaction_amount_refunded":0,"coupon_amount":0,"differential_pricing_id":null,"deduction_schema":null,"transaction_details":{"net_received_amount":0,"total_paid_amount":5,"overpaid_amount":0,"external_resource_url":null,"installment_amount":5,"financial_institution":null,"payment_method_reference_id":null,"payable_deferral_period":null,"acquirer_reference":null},"fee_details":[],"captured":true,"binary_mode":false,"call_for_authorize_id":null,"statement_descriptor":"WWW.MERCADOPAGO.COM","installments":1,"card":{"id":null,"first_six_digits":"400030","last_four_digits":"2220","expiration_month":9,"expiration_year":2018,"date_created":"2017-07-06T10:13:32.000-04:00","date_last_updated":"2017-07-06T10:13:32.000-04:00","cardholder":{"name":"Longbob Longsen","identification":{"number":null,"type":null}}},"notification_url":null,"refunds":[],"processing_mode":null,"merchant_account_id":null,"acquirer":null,"merchant_number":null}
@@ -397,6 +443,12 @@ def successful_authorize_with_elo_response
)
end
+ def successful_authorize_with_cabal_response
+ %(
+ {"id":20729288,"date_created":"2019-08-06T15:57:47.000-04:00","date_approved":null,"date_last_updated":"2019-08-06T15:57:49.000-04:00","date_of_expiration":null,"money_release_date":null,"operation_type":"regular_payment","issuer_id":"688","payment_method_id":"cabal","payment_type_id":"credit_card","status":"authorized","status_detail":"pending_capture","currency_id":"ARS","description":"Store Purchase","live_mode":false,"sponsor_id":null,"authorization_code":null,"money_release_schema":null,"taxes_amount":0,"counter_currency":null,"shipping_amount":0,"pos_id":null,"store_id":null,"collector_id":388534608,"payer":{"first_name":"Test","last_name":"Test","email":"test_user_80507629@testuser.com","identification":{"number":"32659430","type":"DNI"},"phone":{"area_code":"01","number":"1111-1111","extension":""},"type":"registered","entity_type":null,"id":"388571255"},"metadata":{},"additional_info":{"payer":{"address":{"zip_code":"K1C2N6","street_name":"456 My Street Apt 1"}},"shipments":{"receiver_address":{"zip_code":"K1C2N6","street_name":"456 My Street Apt 1"}}},"order":{},"external_reference":"f70cb796271176441a5077012ff2af2a","transaction_amount":5,"transaction_amount_refunded":0,"coupon_amount":0,"differential_pricing_id":null,"deduction_schema":null,"transaction_details":{"payment_method_reference_id":null,"net_received_amount":0,"total_paid_amount":5,"overpaid_amount":0,"external_resource_url":null,"installment_amount":5,"financial_institution":null,"payable_deferral_period":null,"acquirer_reference":null},"fee_details":[],"captured":false,"binary_mode":true,"call_for_authorize_id":null,"statement_descriptor":"SPREEDLYMLA","installments":1,"card":{"id":null,"first_six_digits":"603522","last_four_digits":"7021","expiration_month":10,"expiration_year":2020,"date_created":"2019-08-06T15:57:47.000-04:00","date_last_updated":"2019-08-06T15:57:47.000-04:00","cardholder":{"name":"John Smith","identification":{"number":null,"type":null}}},"notification_url":null,"refunds":[],"processing_mode":"aggregator","merchant_account_id":null,"acquirer":null,"merchant_number":null,"acquirer_reconciliation":[]}
+ )
+ end
+
def failed_authorize_response
%(
{"id":4261953,"date_created":"2017-07-13T14:25:33.000-04:00","date_approved":null,"date_last_updated":"2017-07-13T14:25:33.000-04:00","date_of_expiration":null,"money_release_date":null,"operation_type":"regular_payment","issuer_id":"25","payment_method_id":"visa","payment_type_id":"credit_card","status":"rejected","status_detail":"cc_rejected_other_reason","currency_id":"BRL","description":"Store Purchase","live_mode":false,"sponsor_id":null,"authorization_code":null,"related_exchange_rate":null,"collector_id":263489584,"payer":{"type":"guest","id":null,"email":"user+br@example.com","identification":{"type":null,"number":null},"phone":{"area_code":null,"number":null,"extension":null},"first_name":null,"last_name":null,"entity_type":null},"metadata":{},"additional_info":{"payer":{"address":{"zip_code":"K1C2N6","street_name":"My Street","street_number":"456"}}},"order":{"type":"mercadopago","id":"7528376941458928221"},"external_reference":null,"transaction_amount":5,"transaction_amount_refunded":0,"coupon_amount":0,"differential_pricing_id":null,"deduction_schema":null,"transaction_details":{"net_received_amount":0,"total_paid_amount":5,"overpaid_amount":0,"external_resource_url":null,"installment_amount":5,"financial_institution":null,"payment_method_reference_id":null,"payable_deferral_period":null,"acquirer_reference":null},"fee_details":[],"captured":false,"binary_mode":false,"call_for_authorize_id":null,"statement_descriptor":"WWW.MERCADOPAGO.COM","installments":1,"card":{"id":null,"first_six_digits":"400030","last_four_digits":"2220","expiration_month":9,"expiration_year":2018,"date_created":"2017-07-13T14:25:33.000-04:00","date_last_updated":"2017-07-13T14:25:33.000-04:00","cardholder":{"name":"Longbob Longsen","identification":{"number":null,"type":null}}},"notification_url":null,"refunds":[],"processing_mode":"aggregator","merchant_account_id":null,"acquirer":null,"merchant_number":null}
@@ -415,6 +467,12 @@ def successful_capture_with_elo_response
)
end
+ def successful_capture_with_cabal_response
+ %(
+ {"id":20729288,"date_created":"2019-08-06T15:57:47.000-04:00","date_approved":"2019-08-06T15:57:49.000-04:00","date_last_updated":"2019-08-06T15:57:49.000-04:00","date_of_expiration":null,"money_release_date":"2019-08-20T15:57:49.000-04:00","operation_type":"regular_payment","issuer_id":"688","payment_method_id":"cabal","payment_type_id":"credit_card","status":"approved","status_detail":"accredited","currency_id":"ARS","description":"Store Purchase","live_mode":false,"sponsor_id":null,"authorization_code":null,"money_release_schema":null,"taxes_amount":0,"counter_currency":null,"shipping_amount":0,"pos_id":null,"store_id":null,"collector_id":388534608,"payer":{"first_name":"Test","last_name":"Test","email":"test_user_80507629@testuser.com","identification":{"number":"32659430","type":"DNI"},"phone":{"area_code":"01","number":"1111-1111","extension":""},"type":"registered","entity_type":null,"id":"388571255"},"metadata":{},"additional_info":{"payer":{"address":{"zip_code":"K1C2N6","street_name":"456 My Street Apt 1"}},"shipments":{"receiver_address":{"zip_code":"K1C2N6","street_name":"456 My Street Apt 1"}}},"order":{},"external_reference":"f70cb796271176441a5077012ff2af2a","transaction_amount":5,"transaction_amount_refunded":0,"coupon_amount":0,"differential_pricing_id":null,"deduction_schema":null,"transaction_details":{"payment_method_reference_id":null,"net_received_amount":4.79,"total_paid_amount":5,"overpaid_amount":0,"external_resource_url":null,"installment_amount":5,"financial_institution":null,"payable_deferral_period":null,"acquirer_reference":null},"fee_details":[{"type":"mercadopago_fee","amount":0.21,"fee_payer":"collector"}],"captured":true,"binary_mode":true,"call_for_authorize_id":null,"statement_descriptor":"SPREEDLYMLA","installments":1,"card":{"id":null,"first_six_digits":"603522","last_four_digits":"7021","expiration_month":10,"expiration_year":2020,"date_created":"2019-08-06T15:57:47.000-04:00","date_last_updated":"2019-08-06T15:57:47.000-04:00","cardholder":{"name":"John Smith","identification":{"number":null,"type":null}}},"notification_url":null,"refunds":[],"processing_mode":"aggregator","merchant_account_id":null,"acquirer":null,"merchant_number":null,"acquirer_reconciliation":[]}
+ )
+ end
+
def failed_capture_response
%(
{"message":"Method not allowed","error":"method_not_allowed","status":405,"cause":[{"code":"Method not allowed","description":"Method not allowed","data":null}]}
From 1f2133156f6e98e9b165d6f89253c6e1291b7851 Mon Sep 17 00:00:00 2001
From: "Jeremy W. Rowe"
Date: Tue, 13 Aug 2019 09:18:39 -0400
Subject: [PATCH 0406/2234] Add app based 3DS auth and purchase to Adyen
(#3298)
To create app based auth and purchases requests two things need to happen:
1) Send channel as "app"
2) Don't send notificationURL
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/adyen.rb | 38 ++++++++++---------
test/remote/gateways/remote_adyen_test.rb | 29 +++++++++++++-
3 files changed, 49 insertions(+), 19 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 151a7567392..af9930843cf 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -8,6 +8,7 @@
* Paymill: Add currency and amount to store requests [jasonxp] #3289
* Realex: Prevent error calculating `refund_hash` or `credit_hash` when the secret is nil [jasonxp] #3291
* MercadoPago: Add Cabal card type [leila-alderman] #3295
+* Adyen: Add app based 3DS requests for auth and purchase [jeremywrowe] #3298
== Version 1.96.0 (Jul 26, 2019)
* Bluesnap: Omit state codes for unsupported countries [therufs] #3229
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index a641cf095b0..6f083ab4732 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -328,24 +328,12 @@ def add_installments(post, options)
def add_3ds(post, options)
if three_ds_2_options = options[:three_ds_2]
- if browser_info = three_ds_2_options[:browser_info]
- post[:browserInfo] = {
- acceptHeader: browser_info[:accept_header],
- colorDepth: browser_info[:depth],
- javaEnabled: browser_info[:java],
- language: browser_info[:language],
- screenHeight: browser_info[:height],
- screenWidth: browser_info[:width],
- timeZoneOffset: browser_info[:timezone],
- userAgent: browser_info[:user_agent]
- }
-
- if device_channel = three_ds_2_options[:channel]
- post[:threeDS2RequestData] = {
- deviceChannel: device_channel,
- notificationURL: three_ds_2_options[:notification_url] || 'https://example.com/notification'
- }
- end
+ device_channel = three_ds_2_options[:channel]
+ if device_channel == 'app'
+ post[:threeDS2RequestData] = { deviceChannel: device_channel }
+ else
+ add_browser_info(three_ds_2_options[:browser_info], post)
+ post[:threeDS2RequestData] = { deviceChannel: device_channel, notificationURL: three_ds_2_options[:notification_url] }
end
else
return unless options[:execute_threed] || options[:threed_dynamic]
@@ -457,6 +445,20 @@ def post_data(action, parameters = {})
def error_code_from(response)
STANDARD_ERROR_CODE_MAPPING[response['errorCode']]
end
+
+ def add_browser_info(browser_info, post)
+ return unless browser_info
+ post[:browserInfo] = {
+ acceptHeader: browser_info[:accept_header],
+ colorDepth: browser_info[:depth],
+ javaEnabled: browser_info[:java],
+ language: browser_info[:language],
+ screenHeight: browser_info[:height],
+ screenWidth: browser_info[:width],
+ timeZoneOffset: browser_info[:timezone],
+ userAgent: browser_info[:user_agent]
+ }
+ end
end
end
end
diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb
index ffe0e03d7df..5cfc7ecb22f 100644
--- a/test/remote/gateways/remote_adyen_test.rb
+++ b/test/remote/gateways/remote_adyen_test.rb
@@ -33,7 +33,7 @@ def setup
:brand => 'elo'
)
- @three_ds_enrolled_card = credit_card('4212345678901237', brand: :visa)
+ @three_ds_enrolled_card = credit_card('4917610000000000', brand: :visa)
@declined_card = credit_card('4000300011112220')
@@ -83,6 +83,7 @@ def setup
stored_credential: {reason_type: 'unscheduled'},
three_ds_2: {
channel: 'browser',
+ notification_url: 'https://example.com/notification',
browser_info: {
accept_header: 'unknown',
depth: 100,
@@ -157,12 +158,38 @@ def test_successful_authorize_with_3ds2_browser_client_data
assert response = @gateway.authorize(@amount, @three_ds_enrolled_card, @normalized_3ds_2_options)
assert response.test?
refute response.authorization.blank?
+
assert_equal response.params['resultCode'], 'IdentifyShopper'
refute response.params['additionalData']['threeds2.threeDS2Token'].blank?
refute response.params['additionalData']['threeds2.threeDSServerTransID'].blank?
refute response.params['additionalData']['threeds2.threeDSMethodURL'].blank?
end
+ def test_successful_authorize_with_3ds2_app_based_request
+ three_ds_app_based_options = {
+ reference: '345123',
+ shopper_email: 'john.smith@test.com',
+ shopper_ip: '77.110.174.153',
+ shopper_reference: 'John Smith',
+ billing_address: address(),
+ order_id: '123',
+ stored_credential: {reason_type: 'unscheduled'},
+ three_ds_2: {
+ channel: 'app',
+ }
+ }
+
+ assert response = @gateway.authorize(@amount, @three_ds_enrolled_card, three_ds_app_based_options)
+ assert response.test?
+ refute response.authorization.blank?
+ assert_equal response.params['resultCode'], 'IdentifyShopper'
+ refute response.params['additionalData']['threeds2.threeDS2Token'].blank?
+ refute response.params['additionalData']['threeds2.threeDSServerTransID'].blank?
+ refute response.params['additionalData']['threeds2.threeDS2DirectoryServerInformation.algorithm'].blank?
+ refute response.params['additionalData']['threeds2.threeDS2DirectoryServerInformation.directoryServerId'].blank?
+ refute response.params['additionalData']['threeds2.threeDS2DirectoryServerInformation.publicKey'].blank?
+ end
+
# with rule set in merchant account to skip 3DS for cards of this brand
def test_successful_authorize_with_3ds_dynamic_rule_broken
mastercard_threed = credit_card('5212345678901234',
From 61a9caa1ab1509110949c01e690100d4a94ace23 Mon Sep 17 00:00:00 2001
From: Hannah Deters
Date: Tue, 13 Aug 2019 14:35:35 -0400
Subject: [PATCH 0407/2234] Adds Naranja card type
This adds support for the Naranja card type along with the custom
card number validation logic they use. Naranja is added as a card
type to the following gateways: Bluesnap, dLocal, PayU Latam, Ingenico
ePayments, Mercado Pago, Worldpay, Adyen
There is a single BIN number for Naranja (589562) -- it is co-branded
with Visa, Mastercard, and Amex and will be identified as the co-brand
in those cases.
Added remote gateway test for dLocal and PayU Latam -- remaining
gateways either didn't have a Naranja test card available or needed
additional configuration for Naranja cards (card type or region enabled)
Removed two tests from PayU Latam because capture and void methods are
now supported in the sandbox.
Remote dLocal tests
Remote
22 tests, 61 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
Remote PayU Latam tests
30 tests, 72 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
Card method unit tests
35 tests, 231 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
EVS-171
Closes #3299
---
CHANGELOG | 1 +
lib/active_merchant/billing/credit_card.rb | 2 +
.../billing/credit_card_methods.rb | 28 +++++++++++-
lib/active_merchant/billing/gateways/adyen.rb | 2 +-
.../billing/gateways/blue_snap.rb | 2 +-
.../billing/gateways/d_local.rb | 2 +-
.../billing/gateways/global_collect.rb | 2 +-
.../billing/gateways/mercado_pago.rb | 2 +-
.../billing/gateways/payu_latam.rb | 5 ++-
.../billing/gateways/worldpay.rb | 3 +-
test/remote/gateways/remote_d_local_test.rb | 9 +++-
.../remote/gateways/remote_payu_latam_test.rb | 43 ++++++++-----------
test/unit/credit_card_methods_test.rb | 12 ++++++
13 files changed, 78 insertions(+), 35 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index af9930843cf..2a9565e1444 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -9,6 +9,7 @@
* Realex: Prevent error calculating `refund_hash` or `credit_hash` when the secret is nil [jasonxp] #3291
* MercadoPago: Add Cabal card type [leila-alderman] #3295
* Adyen: Add app based 3DS requests for auth and purchase [jeremywrowe] #3298
+* PayU Latam: Add Naranja card type [hdeters] #3299
== Version 1.96.0 (Jul 26, 2019)
* Bluesnap: Omit state codes for unsupported countries [therufs] #3229
diff --git a/lib/active_merchant/billing/credit_card.rb b/lib/active_merchant/billing/credit_card.rb
index 7dad6011089..983e3edc384 100644
--- a/lib/active_merchant/billing/credit_card.rb
+++ b/lib/active_merchant/billing/credit_card.rb
@@ -21,6 +21,7 @@ module Billing #:nodoc:
# * Elo
# * Alelo
# * Cabal
+ # * Naranja
#
# For testing purposes, use the 'bogus' credit card brand. This skips the vast majority of
# validations, allowing you to focus on your core concerns until you're ready to be more concerned
@@ -94,6 +95,7 @@ def number=(value)
# * +'elo'+
# * +'alelo'+
# * +'cabal'+
+ # * +'naranja'+
#
# Or, if you wish to test your implementation, +'bogus'+.
#
diff --git a/lib/active_merchant/billing/credit_card_methods.rb b/lib/active_merchant/billing/credit_card_methods.rb
index 5b030c9eb8f..3077be86989 100644
--- a/lib/active_merchant/billing/credit_card_methods.rb
+++ b/lib/active_merchant/billing/credit_card_methods.rb
@@ -9,6 +9,7 @@ module CreditCardMethods
'alelo' => ->(num) { num&.size == 16 && in_bin_range?(num.slice(0, 6), ALELO_RANGES) },
'discover' => ->(num) { num =~ /^(6011|65\d{2}|64[4-9]\d)\d{12,15}|(62\d{14,17})$/ },
'american_express' => ->(num) { num =~ /^3[47]\d{13}$/ },
+ 'naranja' => ->(num) { num&.size == 16 && in_bin_range?(num.slice(0, 6), NARANJA_RANGES) },
'diners_club' => ->(num) { num =~ /^3(0[0-5]|[68]\d)\d{11}$/ },
'jcb' => ->(num) { num =~ /^35(28|29|[3-8]\d)\d{12}$/ },
'dankort' => ->(num) { num =~ /^5019\d{12}$/ },
@@ -100,6 +101,10 @@ module CreditCardMethods
60352200..60352299
]
+ NARANJA_RANGES = [
+ 589562..589562
+ ]
+
def self.included(base)
base.extend(ClassMethods)
end
@@ -175,7 +180,7 @@ def valid_number?(number)
valid_test_mode_card_number?(number) ||
valid_card_number_length?(number) &&
valid_card_number_characters?(number) &&
- valid_checksum?(number)
+ valid_by_algorithm?(brand?(number), number)
end
def card_companies
@@ -249,6 +254,15 @@ def valid_test_mode_card_number?(number) #:nodoc:
%w[1 2 3 success failure error].include?(number)
end
+ def valid_by_algorithm?(brand, numbers) #:nodoc:
+ case brand
+ when 'naranja'
+ valid_naranja_algo?(numbers)
+ else
+ valid_luhn?(numbers)
+ end
+ end
+
ODD_LUHN_VALUE = {
48 => 0,
49 => 1,
@@ -279,7 +293,7 @@ def valid_test_mode_card_number?(number) #:nodoc:
# Checks the validity of a card number by use of the Luhn Algorithm.
# Please see http://en.wikipedia.org/wiki/Luhn_algorithm for details.
# This implementation is from the luhn_checksum gem, https://github.com/zendesk/luhn_checksum.
- def valid_checksum?(numbers) #:nodoc:
+ def valid_luhn?(numbers) #:nodoc:
sum = 0
odd = true
@@ -295,6 +309,16 @@ def valid_checksum?(numbers) #:nodoc:
sum % 10 == 0
end
+
+ # Checks the validity of a card number by use of Naranja's specific algorithm.
+ def valid_naranja_algo?(numbers) #:nodoc:
+ num_array = numbers.to_s.chars.map(&:to_i)
+ multipliers = [4, 3, 2, 7, 6, 5, 4, 3, 2, 7, 6, 5, 4, 3, 2]
+ num_sum = num_array[0..14].zip(multipliers).map { |a, b| a*b }.reduce(:+)
+ intermediate = 11 - (num_sum % 11)
+ final_num = intermediate > 9 ? 0 : intermediate
+ final_num == num_array[15]
+ end
end
end
end
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index 6f083ab4732..75253e6fd6f 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -10,7 +10,7 @@ class AdyenGateway < Gateway
self.supported_countries = ['AT', 'AU', 'BE', 'BG', 'BR', 'CH', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GB', 'GI', 'GR', 'HK', 'HU', 'IE', 'IS', 'IT', 'LI', 'LT', 'LU', 'LV', 'MC', 'MT', 'MX', 'NL', 'NO', 'PL', 'PT', 'RO', 'SE', 'SG', 'SK', 'SI', 'US']
self.default_currency = 'USD'
self.currencies_without_fractions = %w(CVE DJF GNF IDR JPY KMF KRW PYG RWF UGX VND VUV XAF XOF XPF)
- self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :jcb, :dankort, :maestro, :discover, :elo]
+ self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :jcb, :dankort, :maestro, :discover, :elo, :naranja]
self.money_format = :cents
diff --git a/lib/active_merchant/billing/gateways/blue_snap.rb b/lib/active_merchant/billing/gateways/blue_snap.rb
index 97aa8fae10c..dffe8c85f83 100644
--- a/lib/active_merchant/billing/gateways/blue_snap.rb
+++ b/lib/active_merchant/billing/gateways/blue_snap.rb
@@ -8,7 +8,7 @@ class BlueSnapGateway < Gateway
self.supported_countries = %w(US CA GB AT BE BG HR CY CZ DK EE FI FR DE GR HU IE IT LV LT LU MT NL PL PT RO SK SI ES SE AR BO BR BZ CL CO CR DO EC GF GP GT HN HT MF MQ MX NI PA PE PR PY SV UY VE)
self.default_currency = 'USD'
- self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners_club, :maestro]
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners_club, :maestro, :naranja]
self.homepage_url = 'https://home.bluesnap.com/'
self.display_name = 'BlueSnap'
diff --git a/lib/active_merchant/billing/gateways/d_local.rb b/lib/active_merchant/billing/gateways/d_local.rb
index 781e29cfe3c..8f639449404 100644
--- a/lib/active_merchant/billing/gateways/d_local.rb
+++ b/lib/active_merchant/billing/gateways/d_local.rb
@@ -6,7 +6,7 @@ class DLocalGateway < Gateway
self.supported_countries = ['AR', 'BR', 'CL', 'CO', 'MX', 'PE', 'UY', 'TR']
self.default_currency = 'USD'
- self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners_club, :maestro]
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners_club, :maestro, :naranja]
self.homepage_url = 'https://dlocal.com/'
self.display_name = 'dLocal'
diff --git a/lib/active_merchant/billing/gateways/global_collect.rb b/lib/active_merchant/billing/gateways/global_collect.rb
index f9ef0aa4e96..9395d0985ff 100644
--- a/lib/active_merchant/billing/gateways/global_collect.rb
+++ b/lib/active_merchant/billing/gateways/global_collect.rb
@@ -10,7 +10,7 @@ class GlobalCollectGateway < Gateway
self.supported_countries = ['AD', 'AE', 'AG', 'AI', 'AL', 'AM', 'AO', 'AR', 'AS', 'AT', 'AU', 'AW', 'AX', 'AZ', 'BA', 'BB', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BL', 'BM', 'BN', 'BO', 'BQ', 'BR', 'BS', 'BT', 'BW', 'BY', 'BZ', 'CA', 'CC', 'CD', 'CF', 'CH', 'CI', 'CK', 'CL', 'CM', 'CN', 'CO', 'CR', 'CU', 'CV', 'CW', 'CX', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM', 'DO', 'DZ', 'EC', 'EE', 'EG', 'ER', 'ES', 'ET', 'FI', 'FJ', 'FK', 'FM', 'FO', 'FR', 'GA', 'GB', 'GD', 'GE', 'GF', 'GH', 'GI', 'GL', 'GM', 'GN', 'GP', 'GQ', 'GR', 'GS', 'GT', 'GU', 'GW', 'GY', 'HK', 'HN', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IM', 'IN', 'IS', 'IT', 'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI', 'KM', 'KN', 'KR', 'KW', 'KY', 'KZ', 'LA', 'LB', 'LC', 'LI', 'LK', 'LR', 'LS', 'LT', 'LU', 'LV', 'MA', 'MC', 'MD', 'ME', 'MF', 'MG', 'MH', 'MK', 'MM', 'MN', 'MO', 'MP', 'MQ', 'MR', 'MS', 'MT', 'MU', 'MV', 'MW', 'MX', 'MY', 'MZ', 'NA', 'NC', 'NE', 'NG', 'NI', 'NL', 'NO', 'NP', 'NR', 'NU', 'NZ', 'OM', 'PA', 'PE', 'PF', 'PG', 'PH', 'PL', 'PN', 'PS', 'PT', 'PW', 'QA', 'RE', 'RO', 'RS', 'RU', 'RW', 'SA', 'SB', 'SC', 'SE', 'SG', 'SH', 'SI', 'SJ', 'SK', 'SL', 'SM', 'SN', 'SR', 'ST', 'SV', 'SZ', 'TC', 'TD', 'TG', 'TH', 'TJ', 'TL', 'TM', 'TN', 'TO', 'TR', 'TT', 'TV', 'TW', 'TZ', 'UA', 'UG', 'US', 'UY', 'UZ', 'VC', 'VE', 'VG', 'VI', 'VN', 'WF', 'WS', 'ZA', 'ZM', 'ZW']
self.default_currency = 'USD'
self.money_format = :cents
- self.supported_cardtypes = [:visa, :master, :american_express, :discover]
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :naranja]
def initialize(options={})
requires!(options, :merchant_id, :api_key_id, :secret_api_key)
diff --git a/lib/active_merchant/billing/gateways/mercado_pago.rb b/lib/active_merchant/billing/gateways/mercado_pago.rb
index 165cd138f38..98cc40bb374 100644
--- a/lib/active_merchant/billing/gateways/mercado_pago.rb
+++ b/lib/active_merchant/billing/gateways/mercado_pago.rb
@@ -4,7 +4,7 @@ class MercadoPagoGateway < Gateway
self.live_url = self.test_url = 'https://api.mercadopago.com/v1'
self.supported_countries = ['AR', 'BR', 'CL', 'CO', 'MX', 'PE', 'UY']
- self.supported_cardtypes = [:visa, :master, :american_express, :elo, :cabal]
+ self.supported_cardtypes = [:visa, :master, :american_express, :elo, :cabal, :naranja]
self.homepage_url = 'https://www.mercadopago.com/'
self.display_name = 'Mercado Pago'
diff --git a/lib/active_merchant/billing/gateways/payu_latam.rb b/lib/active_merchant/billing/gateways/payu_latam.rb
index 1d2b995b083..c4f00bc1822 100644
--- a/lib/active_merchant/billing/gateways/payu_latam.rb
+++ b/lib/active_merchant/billing/gateways/payu_latam.rb
@@ -12,13 +12,14 @@ class PayuLatamGateway < Gateway
self.supported_countries = ['AR', 'BR', 'CL', 'CO', 'MX', 'PA', 'PE']
self.default_currency = 'USD'
self.money_format = :dollars
- self.supported_cardtypes = [:visa, :master, :american_express, :diners_club]
+ self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :naranja]
BRAND_MAP = {
'visa' => 'VISA',
'master' => 'MASTERCARD',
'american_express' => 'AMEX',
- 'diners_club' => 'DINERS'
+ 'diners_club' => 'DINERS',
+ 'naranja' => 'NARANJA'
}
MINIMUMS = {
diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb
index c145c0587c8..e020e2d0b64 100644
--- a/lib/active_merchant/billing/gateways/worldpay.rb
+++ b/lib/active_merchant/billing/gateways/worldpay.rb
@@ -7,7 +7,7 @@ class WorldpayGateway < Gateway
self.default_currency = 'GBP'
self.money_format = :cents
self.supported_countries = %w(HK GB AU AD AR BE BR CA CH CN CO CR CY CZ DE DK ES FI FR GI GR HU IE IN IT JP LI LU MC MT MY MX NL NO NZ PA PE PL PT SE SG SI SM TR UM VA)
- self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :maestro, :elo]
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :maestro, :elo, :naranja]
self.currencies_without_fractions = %w(HUF IDR ISK JPY KRW)
self.currencies_with_three_decimal_places = %w(BHD KWD OMR RSD TND)
self.homepage_url = 'http://www.worldpay.com/'
@@ -22,6 +22,7 @@ class WorldpayGateway < Gateway
'maestro' => 'MAESTRO-SSL',
'diners_club' => 'DINERS-SSL',
'elo' => 'ELO-SSL',
+ 'naranja' => 'NARANJA-SSL',
'unknown' => 'CARD-SSL'
}
diff --git a/test/remote/gateways/remote_d_local_test.rb b/test/remote/gateways/remote_d_local_test.rb
index f704e54e5d4..865257401fa 100644
--- a/test/remote/gateways/remote_d_local_test.rb
+++ b/test/remote/gateways/remote_d_local_test.rb
@@ -4,8 +4,9 @@ class RemoteDLocalTest < Test::Unit::TestCase
def setup
@gateway = DLocalGateway.new(fixtures(:d_local))
- @amount = 100
+ @amount = 200
@credit_card = credit_card('4111111111111111')
+ @credit_card_naranja = credit_card('5895627823453005')
# No test card numbers, all txns are approved by default,
# but errors can be invoked directly with the `description` field
@options = {
@@ -41,6 +42,12 @@ def test_successful_purchase
assert_match 'The payment was paid', response.message
end
+ def test_successful_purchase_naranja
+ response = @gateway.purchase(@amount, @credit_card_naranja, @options)
+ assert_success response
+ assert_match 'The payment was paid', response.message
+ end
+
def test_successful_purchase_with_more_options
options = @options.merge(
order_id: '1',
diff --git a/test/remote/gateways/remote_payu_latam_test.rb b/test/remote/gateways/remote_payu_latam_test.rb
index 8f6518fc4b1..9dff1810ba6 100644
--- a/test/remote/gateways/remote_payu_latam_test.rb
+++ b/test/remote/gateways/remote_payu_latam_test.rb
@@ -8,6 +8,7 @@ def setup
@credit_card = credit_card('4097440000000004', verification_value: '444', first_name: 'APPROVED', last_name: '')
@declined_card = credit_card('4097440000000004', verification_value: '444', first_name: 'REJECTED', last_name: '')
@pending_card = credit_card('4097440000000004', verification_value: '444', first_name: 'PENDING', last_name: '')
+ @naranja_credit_card = credit_card('5895620000000002', :verification_value => '123', :first_name => 'APPROVED', :last_name => '', :brand => 'naranja')
@options = {
dni_number: '5415668464654',
@@ -49,6 +50,13 @@ def test_successful_purchase
assert response.test?
end
+ def test_successful_purchase_with_naranja_card
+ response = @gateway.purchase(@amount, @naranja_credit_card, @options)
+ assert_success response
+ assert_equal 'APPROVED', response.message
+ assert response.test?
+ end
+
def test_successful_purchase_with_specified_language
response = @gateway.purchase(@amount, @credit_card, @options.merge(language: 'es'))
assert_success response
@@ -231,6 +239,13 @@ def test_successful_authorize
assert_match %r(^\d+\|(\w|-)+$), response.authorization
end
+ def test_successful_authorize_with_naranja_card
+ response = @gateway.authorize(@amount, @naranja_credit_card, @options)
+ assert_success response
+ assert_equal 'APPROVED', response.message
+ assert_match %r(^\d+\|(\w|-)+$), response.authorization
+ end
+
def test_successful_authorize_with_specified_language
response = @gateway.authorize(@amount, @credit_card, @options.merge(language: 'es'))
assert_success response
@@ -299,16 +314,6 @@ def test_failed_refund_with_specified_language
assert_match(/property: parentTransactionId, message: No puede ser vacio/, response.message)
end
- # If this test fails, support for void may have been added to the sandbox
- def test_unsupported_test_void_fails_as_expected
- auth = @gateway.authorize(@amount, @credit_card, @options)
- assert_success auth
-
- assert void = @gateway.void(auth.authorization)
- assert_failure void
- assert_equal 'Internal payment provider error. ', void.message
- end
-
def test_failed_void
response = @gateway.void('')
assert_failure response
@@ -321,16 +326,6 @@ def test_failed_void_with_specified_language
assert_match(/property: parentTransactionId, message: No puede ser vacio/, response.message)
end
- # If this test fails, support for captures may have been added to the sandbox
- def test_unsupported_test_capture_fails_as_expected
- auth = @gateway.authorize(@amount, @credit_card, @options)
- assert_success auth
-
- assert capture = @gateway.capture(@amount, auth.authorization, @options)
- assert_failure capture
- assert_equal 'Internal payment provider error. ', capture.message
- end
-
def test_failed_capture
response = @gateway.capture(@amount, '')
assert_failure response
@@ -366,17 +361,17 @@ def test_successful_verify_with_specified_language
end
def test_failed_verify_with_specified_amount
- verify = @gateway.verify(@credit_card, @options.merge(verify_amount: 1699))
+ verify = @gateway.verify(@credit_card, @options.merge(verify_amount: 499))
assert_failure verify
- assert_equal 'The order value is less than minimum allowed. Minimum value allowed 17 ARS', verify.message
+ assert_equal 'The order value is less than minimum allowed. Minimum value allowed 5 ARS', verify.message
end
def test_failed_verify_with_specified_language
- verify = @gateway.verify(@credit_card, @options.merge(verify_amount: 1699, language: 'es'))
+ verify = @gateway.verify(@credit_card, @options.merge(verify_amount: 499, language: 'es'))
assert_failure verify
- assert_equal 'The order value is less than minimum allowed. Minimum value allowed 17 ARS', verify.message
+ assert_equal 'The order value is less than minimum allowed. Minimum value allowed 5 ARS', verify.message
end
def test_transcript_scrubbing
diff --git a/test/unit/credit_card_methods_test.rb b/test/unit/credit_card_methods_test.rb
index 1b141a19af3..1400b603f5d 100644
--- a/test/unit/credit_card_methods_test.rb
+++ b/test/unit/credit_card_methods_test.rb
@@ -145,6 +145,12 @@ def test_should_detect_alelo_card
assert_equal 'alelo', CreditCard.brand?('5067600000000044')
end
+ def test_should_detect_naranja_card
+ assert_equal 'naranja', CreditCard.brand?('5895627823453005')
+ assert_equal 'naranja', CreditCard.brand?('5895620000000002')
+ assert_equal 'naranja', CreditCard.brand?('5895626746595650')
+ end
+
# Alelo BINs beginning with the digit 4 overlap with Visa's range of valid card numbers.
# We intentionally misidentify these cards as Visa, which works because transactions with
# such cards will run on Visa rails.
@@ -199,6 +205,12 @@ def test_matching_invalid_card
assert_false CreditCard.valid_number?(nil)
end
+ def test_matching_valid_naranja
+ number = '5895627823453005'
+ assert_equal 'naranja', CreditCard.brand?(number)
+ assert CreditCard.valid_number?(number)
+ end
+
def test_16_digit_maestro_uk
number = '6759000000000000'
assert_equal 16, number.length
From 7e5a1c98fa5ed3b6333cdd657567689ac47976d9 Mon Sep 17 00:00:00 2001
From: Jason Nappier
Date: Thu, 8 Aug 2019 17:11:56 -0400
Subject: [PATCH 0408/2234] CyberSource: Add support for issuer additionalData
gateway-specific field
Added support for the issuer additionalData CyberSource-specific field. The CyberSource XML schema has also been updated. Per the gateway's instructions, we are now using version 1.156 in the test environment,
and version 1.155 in production.
CE-56
Unit tests:
4195 tests, 70144 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications
100% passed
test/remote/gateways/remote_cyber_source_test.rb contains 5 pre-existing, unrelated test failures:
- test_successful_3ds_validate_authorize_request
- test_successful_3ds_validate_purchase_request
- test_successful_pinless_debit_card_puchase
- test_successful_tax_calculation
- test_successful_validate_pinless_debit_card
59 tests, 260 assertions, 5 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
---
CHANGELOG | 1 +
.../billing/gateways/cyber_source.rb | 20 +-
.../gateways/remote_cyber_source_test.rb | 125 +-
.../CyberSourceTransaction_1.155.xsd | 4857 ++++++++++++++++
.../CyberSourceTransaction_1.156.xsd | 4894 +++++++++++++++++
test/unit/gateways/cyber_source_test.rb | 21 +-
6 files changed, 9842 insertions(+), 76 deletions(-)
create mode 100644 test/schema/cyber_source/CyberSourceTransaction_1.155.xsd
create mode 100644 test/schema/cyber_source/CyberSourceTransaction_1.156.xsd
diff --git a/CHANGELOG b/CHANGELOG
index 2a9565e1444..6ebafd5b536 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -10,6 +10,7 @@
* MercadoPago: Add Cabal card type [leila-alderman] #3295
* Adyen: Add app based 3DS requests for auth and purchase [jeremywrowe] #3298
* PayU Latam: Add Naranja card type [hdeters] #3299
+* CyberSource: Add issuer `additionalData` gateway-specific field [jasonxp] #3296
== Version 1.96.0 (Jul 26, 2019)
* Bluesnap: Omit state codes for unsupported countries [therufs] #3229
diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb
index 7d5357c94e0..ba4cb8438f9 100644
--- a/lib/active_merchant/billing/gateways/cyber_source.rb
+++ b/lib/active_merchant/billing/gateways/cyber_source.rb
@@ -24,7 +24,9 @@ class CyberSourceGateway < Gateway
self.test_url = 'https://ics2wstesta.ic3.com/commerce/1.x/transactionProcessor'
self.live_url = 'https://ics2wsa.ic3.com/commerce/1.x/transactionProcessor'
- XSD_VERSION = '1.153'
+ # Schema files can be found here: https://ics2ws.ic3.com/commerce/1.x/transactionProcessor/
+ TEST_XSD_VERSION = '1.156'
+ PRODUCTION_XSD_VERSION = '1.155'
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb, :dankort, :maestro, :elo]
self.supported_countries = %w(US BR CA CN DK FI FR DE IN JP MX NO SE GB SG LB PK)
@@ -263,6 +265,8 @@ def build_auth_request(money, creditcard_or_reference, options)
add_payment_network_token(xml) if network_tokenization?(creditcard_or_reference)
add_business_rules_data(xml, creditcard_or_reference, options)
add_stored_credential_options(xml, options)
+ add_issuer_additional_data(xml, options)
+
xml.target!
end
@@ -301,6 +305,8 @@ def build_purchase_request(money, payment_method_or_reference, options)
add_payment_network_token(xml) if network_tokenization?(payment_method_or_reference)
add_business_rules_data(xml, payment_method_or_reference, options) unless options[:pinless_debit_card]
end
+ add_issuer_additional_data(xml, options)
+
xml.target!
end
@@ -485,6 +491,14 @@ def add_decision_manager_fields(xml, options)
end
end
+ def add_issuer_additional_data(xml, options)
+ return unless options[:issuer_additional_data]
+
+ xml.tag! 'issuer' do
+ xml.tag! 'additionalData', options[:issuer_additional_data]
+ end
+ end
+
def add_mdd_fields(xml, options)
return unless options.keys.any? { |key| key.to_s.start_with?('mdd_field') }
@@ -713,6 +727,8 @@ def add_stored_credential_options(xml, options={})
# Where we actually build the full SOAP request using builder
def build_request(body, options)
+ xsd_version = test? ? TEST_XSD_VERSION : PRODUCTION_XSD_VERSION
+
xml = Builder::XmlMarkup.new :indent => 2
xml.instruct!
xml.tag! 's:Envelope', {'xmlns:s' => 'http://schemas.xmlsoap.org/soap/envelope/'} do
@@ -725,7 +741,7 @@ def build_request(body, options)
end
end
xml.tag! 's:Body', {'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema'} do
- xml.tag! 'requestMessage', {'xmlns' => "urn:schemas-cybersource-com:transaction-data-#{XSD_VERSION}"} do
+ xml.tag! 'requestMessage', {'xmlns' => "urn:schemas-cybersource-com:transaction-data-#{xsd_version}"} do
add_merchant_data(xml, options)
xml << body
end
diff --git a/test/remote/gateways/remote_cyber_source_test.rb b/test/remote/gateways/remote_cyber_source_test.rb
index 0969ada813a..c295737a0a6 100644
--- a/test/remote/gateways/remote_cyber_source_test.rb
+++ b/test/remote/gateways/remote_cyber_source_test.rb
@@ -69,6 +69,9 @@ def setup
:amount => 100
}
}
+
+ @issuer_additional_data = 'PR25000000000011111111111112222222sk111111111111111111111111111'
+ + '1111111115555555222233101abcdefghijkl7777777777777777777777777promotionCde'
end
def test_transcript_scrubbing
@@ -101,17 +104,21 @@ def test_network_tokenization_transcript_scrubbing
def test_successful_authorization
assert response = @gateway.authorize(@amount, @credit_card, @options)
- assert_equal 'Successful transaction', response.message
- assert_success response
- assert response.test?
+ assert_successful_response(response)
+ assert !response.authorization.blank?
+ end
+
+ def test_successful_authorization_with_issuer_additional_data
+ @options[:issuer_additional_data] = @issuer_additional_data
+
+ assert response = @gateway.authorize(@amount, @credit_card, @options)
+ assert_successful_response(response)
assert !response.authorization.blank?
end
def test_successful_authorization_with_elo
assert response = @gateway.authorize(@amount, @elo_credit_card, @options)
- assert_equal 'Successful transaction', response.message
- assert_success response
- assert response.test?
+ assert_successful_response(response)
assert !response.authorization.blank?
end
@@ -163,17 +170,19 @@ def test_successful_tax_calculation
def test_successful_purchase
assert response = @gateway.purchase(@amount, @credit_card, @options)
- assert_equal 'Successful transaction', response.message
- assert_success response
- assert response.test?
+ assert_successful_response(response)
+ end
+
+ def test_successful_purchase_with_issuer_additional_data
+ @options[:issuer_additional_data] = @issuer_additional_data
+
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
+ assert_successful_response(response)
end
def test_successful_purchase_with_elo
assert response = @gateway.purchase(@amount, @elo_credit_card, @options)
- assert_success response
- assert_equal 'Successful transaction', response.message
- assert_success response
- assert response.test?
+ assert_successful_response(response)
end
def test_successful_purchase_sans_options
@@ -200,18 +209,14 @@ def test_successful_purchase_with_long_country_name
def test_successful_purchase_without_decision_manager
@options[:decision_manager_enabled] = 'false'
assert response = @gateway.purchase(@amount, @credit_card, @options)
- assert_equal 'Successful transaction', response.message
- assert_success response
- assert response.test?
+ assert_successful_response(response)
end
def test_successful_purchase_with_decision_manager_profile
@options[:decision_manager_enabled] = 'true'
@options[:decision_manager_profile] = 'Regular'
assert response = @gateway.purchase(@amount, @credit_card, @options)
- assert_equal 'Successful transaction', response.message
- assert_success response
- assert response.test?
+ assert_successful_response(response)
end
def test_successful_pinless_debit_card_puchase
@@ -273,9 +278,8 @@ def test_invalid_login
# to go through a Capture cycle at least a day before submitting a refund.
def test_successful_refund
assert response = @gateway.purchase(@amount, @credit_card, @options)
- assert_equal 'Successful transaction', response.message
- assert_success response
- assert response.test?
+ assert_successful_response(response)
+
assert response = @gateway.refund(@amount, response.authorization)
assert_equal 'Successful transaction', response.message
assert_success response
@@ -305,6 +309,7 @@ def test_network_tokenization_authorize_and_capture
def test_successful_authorize_with_mdd_fields
(1..20).each { |e| @options["mdd_field_#{e}".to_sym] = "value #{e}" }
+
assert response = @gateway.authorize(@amount, @credit_card, @options)
assert_success response
end
@@ -323,89 +328,63 @@ def test_successful_authorize_with_nonfractional_currency
def test_successful_subscription_authorization
assert response = @gateway.store(@credit_card, @subscription_options)
- assert_equal 'Successful transaction', response.message
- assert_success response
- assert response.test?
+ assert_successful_response(response)
assert response = @gateway.authorize(@amount, response.authorization, :order_id => generate_unique_id)
- assert_equal 'Successful transaction', response.message
- assert_success response
- assert response.test?
+ assert_successful_response(response)
assert !response.authorization.blank?
end
def test_successful_subscription_purchase
assert response = @gateway.store(@credit_card, @subscription_options)
- assert_equal 'Successful transaction', response.message
- assert_success response
- assert response.test?
+ assert_successful_response(response)
assert response = @gateway.purchase(@amount, response.authorization, :order_id => generate_unique_id)
- assert_equal 'Successful transaction', response.message
- assert_success response
- assert response.test?
+ assert_successful_response(response)
end
def test_successful_subscription_purchase_with_elo
assert response = @gateway.store(@elo_credit_card, @subscription_options)
- assert_equal 'Successful transaction', response.message
- assert_success response
- assert response.test?
+ assert_successful_response(response)
assert response = @gateway.purchase(@amount, response.authorization, :order_id => generate_unique_id)
- assert_equal 'Successful transaction', response.message
- assert_success response
- assert response.test?
+ assert_successful_response(response)
end
def test_successful_standalone_credit_to_card
assert response = @gateway.credit(@amount, @credit_card, @options)
-
- assert_equal 'Successful transaction', response.message
- assert_success response
- assert response.test?
+ assert_successful_response(response)
end
def test_failed_standalone_credit_to_card
assert response = @gateway.credit(@amount, @declined_card, @options)
assert_equal 'Invalid account number', response.message
- assert_failed response
+ assert_failure response
assert response.test?
end
def test_successful_standalone_credit_to_subscription
assert response = @gateway.store(@credit_card, @subscription_options)
- assert_equal 'Successful transaction', response.message
- assert_success response
- assert response.test?
+ assert_successful_response(response)
assert response = @gateway.credit(@amount, response.authorization, :order_id => generate_unique_id)
-
- assert_equal 'Successful transaction', response.message
- assert_success response
- assert response.test?
+ assert_successful_response(response)
end
def test_successful_create_subscription
assert response = @gateway.store(@credit_card, @subscription_options)
- assert_equal 'Successful transaction', response.message
- assert_success response
- assert response.test?
+ assert_successful_response(response)
end
def test_successful_create_subscription_with_elo
assert response = @gateway.store(@elo_credit_card, @subscription_options)
- assert_equal 'Successful transaction', response.message
- assert_success response
- assert response.test?
+ assert_successful_response(response)
end
def test_successful_create_subscription_with_setup_fee
assert response = @gateway.store(@credit_card, @subscription_options.merge(:setup_fee => 100))
- assert_equal 'Successful transaction', response.message
- assert_success response
- assert response.test?
+ assert_successful_response(response)
end
def test_successful_create_subscription_with_monthly_options
@@ -418,27 +397,20 @@ def test_successful_create_subscription_with_monthly_options
def test_successful_update_subscription_creditcard
assert response = @gateway.store(@credit_card, @subscription_options)
- assert_equal 'Successful transaction', response.message
- assert_success response
- assert response.test?
+ assert_successful_response(response)
assert response = @gateway.update(response.authorization, @credit_card, {:order_id => generate_unique_id, :setup_fee => 100})
- assert_equal 'Successful transaction', response.message
- assert_success response
- assert response.test?
+ assert_successful_response(response)
end
def test_successful_update_subscription_billing_address
assert response = @gateway.store(@credit_card, @subscription_options)
- assert_equal 'Successful transaction', response.message
- assert_success response
- assert response.test?
+ assert_successful_response(response)
assert response = @gateway.update(response.authorization, nil,
{:order_id => generate_unique_id, :setup_fee => 100, billing_address: address, email: 'someguy1232@fakeemail.net'})
- assert_equal 'Successful transaction', response.message
- assert_success response
- assert response.test?
+
+ assert_successful_response(response)
end
def test_successful_delete_subscription
@@ -590,4 +562,11 @@ def test_verify_credentials
assert !gateway.verify_credentials
end
+ private
+
+ def assert_successful_response(response)
+ assert_equal 'Successful transaction', response.message
+ assert_success response
+ assert response.test?
+ end
end
diff --git a/test/schema/cyber_source/CyberSourceTransaction_1.155.xsd b/test/schema/cyber_source/CyberSourceTransaction_1.155.xsd
new file mode 100644
index 00000000000..577ae9fc8a6
--- /dev/null
+++ b/test/schema/cyber_source/CyberSourceTransaction_1.155.xsd
@@ -0,0 +1,4857 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/schema/cyber_source/CyberSourceTransaction_1.156.xsd b/test/schema/cyber_source/CyberSourceTransaction_1.156.xsd
new file mode 100644
index 00000000000..74dc2e7b7a5
--- /dev/null
+++ b/test/schema/cyber_source/CyberSourceTransaction_1.156.xsd
@@ -0,0 +1,4894 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/unit/gateways/cyber_source_test.rb b/test/unit/gateways/cyber_source_test.rb
index c1e6f6b334c..c71a31aed9b 100644
--- a/test/unit/gateways/cyber_source_test.rb
+++ b/test/unit/gateways/cyber_source_test.rb
@@ -52,6 +52,9 @@ def setup
:amount => 100
}
}
+
+ @issuer_additional_data = 'PR25000000000011111111111112222222sk111111111111111111111111111'
+ + '1111111115555555222233101abcdefghijkl7777777777777777777777777promotionCde'
end
def test_successful_credit_card_purchase
@@ -83,6 +86,14 @@ def test_purchase_includes_customer_ip
@gateway.purchase(@amount, @credit_card, @options)
end
+ def test_purchase_includes_issuer_additional_data
+ stub_comms do
+ @gateway.purchase(100, @credit_card, order_id: '1', issuer_additional_data: @issuer_additional_data)
+ end.check_request do |endpoint, data, headers|
+ assert_match(/\s+#{@issuer_additional_data}<\/additionalData>\s+<\/issuer>/m, data)
+ end.respond_with(successful_purchase_response)
+ end
+
def test_purchase_includes_mdd_fields
stub_comms do
@gateway.purchase(100, @credit_card, order_id: '1', mdd_field_2: 'CustomValue2', mdd_field_3: 'CustomValue3')
@@ -91,6 +102,14 @@ def test_purchase_includes_mdd_fields
end.respond_with(successful_purchase_response)
end
+ def test_authorize_includes_issuer_additional_data
+ stub_comms do
+ @gateway.authorize(100, @credit_card, order_id: '1', issuer_additional_data: @issuer_additional_data)
+ end.check_request do |endpoint, data, headers|
+ assert_match(/\s+#{@issuer_additional_data}<\/additionalData>\s+<\/issuer>/m, data)
+ end.respond_with(successful_authorization_response)
+ end
+
def test_authorize_includes_mdd_fields
stub_comms do
@gateway.authorize(100, @credit_card, order_id: '1', mdd_field_2: 'CustomValue2', mdd_field_3: 'CustomValue3')
@@ -873,7 +892,7 @@ def invalid_xml_response
end
def assert_xml_valid_to_xsd(data, root_element = '//s:Body/*')
- schema_file = File.open("#{File.dirname(__FILE__)}/../../schema/cyber_source/CyberSourceTransaction_#{CyberSourceGateway::XSD_VERSION}.xsd")
+ schema_file = File.open("#{File.dirname(__FILE__)}/../../schema/cyber_source/CyberSourceTransaction_#{CyberSourceGateway::TEST_XSD_VERSION}.xsd")
doc = Nokogiri::XML(data)
root = Nokogiri::XML(doc.xpath(root_element).to_s)
xsd = Nokogiri::XML::Schema(schema_file)
From 1086c4e446a72a5fcc9dac95540ec80df835879a Mon Sep 17 00:00:00 2001
From: Filipe Costa
Date: Thu, 15 Aug 2019 11:14:22 -0400
Subject: [PATCH 0409/2234] Release v1.97.0
---
CHANGELOG | 22 +++++++++++++---------
lib/active_merchant/version.rb | 2 +-
2 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 6ebafd5b536..9584ff21386 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,16 +1,20 @@
= ActiveMerchant CHANGELOG
== HEAD
-* Bambora formerly Beanstream: Pass card owner when storing tokenized cards [#3006]
-* CardConnect: Move domain from gateway specific to gateway field [hdeters] #3283
-* Braintree Blue: Support for stored credentials [hdeters] #3286
-* Realex: Re-implement credit as general credit [leila-alderman] #3280
-* Paymill: Add currency and amount to store requests [jasonxp] #3289
-* Realex: Prevent error calculating `refund_hash` or `credit_hash` when the secret is nil [jasonxp] #3291
-* MercadoPago: Add Cabal card type [leila-alderman] #3295
-* Adyen: Add app based 3DS requests for auth and purchase [jeremywrowe] #3298
-* PayU Latam: Add Naranja card type [hdeters] #3299
+
+== Version 1.97.0 (Aug 15, 2019)
* CyberSource: Add issuer `additionalData` gateway-specific field [jasonxp] #3296
+* PayU Latam: Add Naranja card type [hdeters] #3299
+* Adyen: Add app based 3DS requests for auth and purchase [jeremywrowe] #3298
+* MercadoPago: Add Cabal card type [leila-alderman] #3295
+* MONEI: Add external MPI 3DS 1 support [jimmyn] #3292
+* Bambora formerly Beanstream: Pass card owner when storing tokenized cards [alexdunae] #3006
+* Realex: Prevent error calculating `refund_hash` or `credit_hash` when the secret is nil [jasonxp] #3291
+* Orbital: Add external MPI support for 3DS1 [pi3r] #3261
+* Paymill: Add currency and amount to store requests [jasonxp] #3289
+* Realex: Re-implement credit as general credit [leila-alderman] #3280
+* Braintree Blue: Support for stored credentials [hdeters] #3286
+* CardConnect: Move domain from gateway specific to gateway field [hdeters] #3283
== Version 1.96.0 (Jul 26, 2019)
* Bluesnap: Omit state codes for unsupported countries [therufs] #3229
diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb
index 08670fbdad1..f01a6db39d8 100644
--- a/lib/active_merchant/version.rb
+++ b/lib/active_merchant/version.rb
@@ -1,3 +1,3 @@
module ActiveMerchant
- VERSION = '1.96.0'
+ VERSION = '1.97.0'
end
From 823faaeab0d6d3bd75ee037ec894ab7c9d95d3a9 Mon Sep 17 00:00:00 2001
From: britth
Date: Thu, 15 Aug 2019 19:10:23 -0400
Subject: [PATCH 0410/2234] Stripe Payment Intents - Add new gateway
In preparation for Stripe 3DS2 support, this PR adds support for Stripe
Payment Intents. Stripe Payment Intents is added as a gateway, with
functionality to create new PaymentIntents and Stripe PaymentMethods.
PaymentIntents can also be confirmed, captured, cancelled, shown, and
updated. This gateway is implemented as a subclass of the Stripe gateway.
To take advantage of the latest features, the API for this gateway is
bumped up to the latest version, `2019-05-16`.
Remote:
24 tests, 103 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
6 tests, 42 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Closes #3290
---
CHANGELOG | 1 +
activemerchant.gemspec | 1 +
.../billing/gateways/stripe.rb | 10 +-
.../gateways/stripe_payment_intents.rb | 239 +++++++++++
.../remote_stripe_payment_intents_test.rb | 389 ++++++++++++++++++
.../gateways/stripe_payment_intents_test.rb | 266 ++++++++++++
6 files changed, 903 insertions(+), 3 deletions(-)
create mode 100644 lib/active_merchant/billing/gateways/stripe_payment_intents.rb
create mode 100644 test/remote/gateways/remote_stripe_payment_intents_test.rb
create mode 100644 test/unit/gateways/stripe_payment_intents_test.rb
diff --git a/CHANGELOG b/CHANGELOG
index 9584ff21386..b33b34e41a5 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
= ActiveMerchant CHANGELOG
== HEAD
+* Stripe Payment Intents: Add new gateway [britth] #3290
== Version 1.97.0 (Aug 15, 2019)
* CyberSource: Add issuer `additionalData` gateway-specific field [jasonxp] #3296
diff --git a/activemerchant.gemspec b/activemerchant.gemspec
index bb9ea4e14f8..505bcfecd42 100644
--- a/activemerchant.gemspec
+++ b/activemerchant.gemspec
@@ -30,4 +30,5 @@ Gem::Specification.new do |s|
s.add_development_dependency('test-unit', '~> 3')
s.add_development_dependency('mocha', '~> 1')
s.add_development_dependency('thor')
+ s.add_development_dependency('pry')
end
diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb
index 19587899533..e8f9b0de5e7 100644
--- a/lib/active_merchant/billing/gateways/stripe.rb
+++ b/lib/active_merchant/billing/gateways/stripe.rb
@@ -2,6 +2,8 @@
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
+ # This gateway uses an older version of the Stripe API.
+ # To utilize the updated {Payment Intents API}[https://stripe.com/docs/api/payment_intents], integrate with the StripePaymentIntents gateway
class StripeGateway < Gateway
self.live_url = 'https://api.stripe.com/v1/'
@@ -21,6 +23,8 @@ class StripeGateway < Gateway
'unchecked' => 'P'
}
+ DEFAULT_API_VERSION = '2015-04-07'
+
self.supported_countries = %w(AT AU BE BR CA CH DE DK ES FI FR GB HK IE IT JP LU MX NL NO NZ PT SE SG US)
self.default_currency = 'USD'
self.money_format = :cents
@@ -589,7 +593,7 @@ def stripe_client_user_agent(options)
end
def api_version(options)
- options[:version] || @options[:version] || '2015-04-07'
+ options[:version] || @options[:version] || self.class::DEFAULT_API_VERSION
end
def api_request(method, endpoint, parameters = nil, options = {})
@@ -632,8 +636,8 @@ def authorization_from(success, url, method, response)
return response.fetch('error', {})['charge'] unless success
if url == 'customers'
- [response['id'], response['sources']['data'].first['id']].join('|')
- elsif method == :post && url.match(/customers\/.*\/cards/)
+ [response['id'], response.dig('sources', 'data').first&.dig('id')].join('|')
+ elsif method == :post && (url.match(/customers\/.*\/cards/) || url.match(/payment_methods\/.*\/attach/))
[response['customer'], response['id']].join('|')
else
response['id']
diff --git a/lib/active_merchant/billing/gateways/stripe_payment_intents.rb b/lib/active_merchant/billing/gateways/stripe_payment_intents.rb
new file mode 100644
index 00000000000..90d3d0b9b30
--- /dev/null
+++ b/lib/active_merchant/billing/gateways/stripe_payment_intents.rb
@@ -0,0 +1,239 @@
+require 'active_support/core_ext/hash/slice'
+
+module ActiveMerchant #:nodoc:
+ module Billing #:nodoc:
+ # This gateway uses the current Stripe {Payment Intents API}[https://stripe.com/docs/api/payment_intents].
+ # For the legacy API, see the Stripe gateway
+ class StripePaymentIntentsGateway < StripeGateway
+ ALLOWED_METHOD_STATES = %w[automatic manual].freeze
+ ALLOWED_CANCELLATION_REASONS = %w[duplicate fraudulent requested_by_customer abandoned].freeze
+ CREATE_INTENT_ATTRIBUTES = %i[description statement_descriptor receipt_email save_payment_method]
+ CONFIRM_INTENT_ATTRIBUTES = %i[receipt_email return_url save_payment_method setup_future_usage off_session]
+ UPDATE_INTENT_ATTRIBUTES = %i[description statement_descriptor receipt_email setup_future_usage]
+ DEFAULT_API_VERSION = '2019-05-16'
+
+ def create_intent(money, payment_method, options = {})
+ post = {}
+ add_amount(post, money, options, true)
+ add_capture_method(post, options)
+ add_confirmation_method(post, options)
+ add_customer(post, options)
+ add_payment_method_token(post, payment_method, options)
+ add_metadata(post, options)
+ add_return_url(post, options)
+ add_connected_account(post, options)
+ add_shipping_address(post, options)
+ setup_future_usage(post, options)
+
+ CREATE_INTENT_ATTRIBUTES.each do |attribute|
+ add_whitelisted_attribute(post, options, attribute)
+ end
+
+ commit(:post, 'payment_intents', post, options)
+ end
+
+ def show_intent(intent_id, options)
+ commit(:get, "payment_intents/#{intent_id}", nil, options)
+ end
+
+ def confirm_intent(intent_id, payment_method, options = {})
+ post = {}
+ add_payment_method_token(post, payment_method, options)
+ CONFIRM_INTENT_ATTRIBUTES.each do |attribute|
+ add_whitelisted_attribute(post, options, attribute)
+ end
+
+ commit(:post, "payment_intents/#{intent_id}/confirm", post, options)
+ end
+
+ def create_payment_method(payment_method, options = {})
+ post = {}
+ post[:type] = 'card'
+ post[:card] = {}
+ post[:card][:number] = payment_method.number
+ post[:card][:exp_month] = payment_method.month
+ post[:card][:exp_year] = payment_method.year
+ post[:card][:cvc] = payment_method.verification_value if payment_method.verification_value
+
+ commit(:post, 'payment_methods', post, options)
+ end
+
+ def update_intent(money, intent_id, payment_method, options = {})
+ post = {}
+ post[:amount] = money if money
+
+ add_payment_method_token(post, payment_method, options)
+ add_payment_method_types(post, options)
+ add_customer(post, options)
+ add_metadata(post, options)
+ add_shipping_address(post, options)
+ add_connected_account(post, options)
+
+ UPDATE_INTENT_ATTRIBUTES.each do |attribute|
+ add_whitelisted_attribute(post, options, attribute)
+ end
+
+ commit(:post, "payment_intents/#{intent_id}", post, options)
+ end
+
+ def authorize(money, payment_method, options = {})
+ create_intent(money, payment_method, options.merge!(confirm: true, capture_method: 'manual'))
+ end
+
+ def purchase(money, payment_method, options = {})
+ create_intent(money, payment_method, options.merge!(confirm: true, capture_method: 'automatic'))
+ end
+
+ def capture(money, intent_id, options = {})
+ post = {}
+ post[:amount_to_capture] = money
+ add_connected_account(post, options)
+ commit(:post, "payment_intents/#{intent_id}/capture", post, options)
+ end
+
+ def void(intent_id, options = {})
+ post = {}
+ post[:cancellation_reason] = options[:cancellation_reason] if ALLOWED_CANCELLATION_REASONS.include?(options[:cancellation_reason])
+ commit(:post, "payment_intents/#{intent_id}/cancel", post, options)
+ end
+
+ def refund(money, intent_id, options = {})
+ intent = commit(:get, "payment_intents/#{intent_id}", nil, options)
+ charge_id = intent.params.dig('charges', 'data')[0].dig('id')
+ super(money, charge_id, options)
+ end
+
+ # Note: Not all payment methods are currently supported by the {Payment Methods API}[https://stripe.com/docs/payments/payment-methods]
+ # Current implementation will create a PaymentMethod object if the method is a token or credit card
+ # All other types will default to legacy Stripe store
+ def store(payment_method, options = {})
+ params = {}
+ post = {}
+
+ # If customer option is provided, create a payment method and attach to customer id
+ # Otherwise, create a customer, then attach
+ if payment_method.is_a?(StripePaymentToken) || payment_method.is_a?(ActiveMerchant::Billing::CreditCard)
+ add_payment_method_token(params, payment_method, options)
+ if options[:customer]
+ customer_id = options[:customer]
+ else
+ post[:validate] = options[:validate] unless options[:validate].nil?
+ post[:description] = options[:description] if options[:description]
+ post[:email] = options[:email] if options[:email]
+ customer = commit(:post, 'customers', post, options)
+ customer_id = customer.params['id']
+ end
+ commit(:post, "payment_methods/#{params[:payment_method]}/attach", { customer: customer_id }, options)
+ else
+ super(payment, options)
+ end
+ end
+
+ def unstore(identification, options = {}, deprecated_options = {})
+ if identification.include?('pm_')
+ _, payment_method = identification.split('|')
+ commit(:post, "payment_methods/#{payment_method}/detach", nil, options)
+ else
+ super(identification, options, deprecated_options)
+ end
+ end
+
+ private
+
+ def add_whitelisted_attribute(post, options, attribute)
+ post[attribute] = options[attribute] if options[attribute]
+ post
+ end
+
+ def add_capture_method(post, options)
+ capture_method = options[:capture_method].to_s
+ post[:capture_method] = capture_method if ALLOWED_METHOD_STATES.include?(capture_method)
+ post
+ end
+
+ def add_confirmation_method(post, options)
+ confirmation_method = options[:confirmation_method].to_s
+ post[:confirmation_method] = confirmation_method if ALLOWED_METHOD_STATES.include?(confirmation_method)
+ post
+ end
+
+ def add_customer(post, options)
+ customer = options[:customer].to_s
+ post[:customer] = customer if customer.start_with?('cus_')
+ post
+ end
+
+ def add_return_url(post, options)
+ return unless options[:confirm]
+ post[:confirm] = options[:confirm]
+ post[:return_url] = options[:return_url] if options[:return_url]
+ post
+ end
+
+ def add_payment_method_token(post, payment_method, options)
+ return if payment_method.nil?
+
+ if payment_method.is_a?(ActiveMerchant::Billing::CreditCard)
+ p = create_payment_method(payment_method, options)
+ payment_method = p.params['id']
+ end
+
+ if payment_method.is_a?(StripePaymentToken)
+ post[:payment_method] = payment_method.payment_data['id']
+ elsif payment_method.is_a?(String)
+ if payment_method.include?('|')
+ customer_id, payment_method_id = payment_method.split('|')
+ token = payment_method_id
+ post[:customer] = customer_id
+ else
+ token = payment_method
+ end
+ post[:payment_method] = token
+ end
+ end
+
+ def add_payment_method_types(post, options)
+ payment_method_types = options[:payment_method_types] if options[:payment_method_types]
+ return if payment_method_types.nil?
+
+ post[:payment_method_types] = Array(payment_method_types)
+ post
+ end
+
+ def setup_future_usage(post, options = {})
+ post[:setup_future_usage] = options[:setup_future_usage] if %w( on_session off_session ).include?(options[:setup_future_usage])
+ post[:off_session] = options[:off_session] if options[:off_session] && options[:confirm] == true
+ post
+ end
+
+ def add_connected_account(post, options = {})
+ return unless transfer_data = options[:transfer_data]
+ post[:transfer_data] = {}
+ post[:transfer_data][:destination] = transfer_data[:destination] if transfer_data[:destination]
+ post[:transfer_data][:amount] = transfer_data[:amount] if transfer_data[:amount]
+ post[:on_behalf_of] = options[:on_behalf_of] if options[:on_behalf_of]
+ post[:transfer_group] = options[:transfer_group] if options[:transfer_group]
+ post[:application_fee_amount] = options[:application_fee] if options[:application_fee]
+ post
+ end
+
+ def add_shipping_address(post, options = {})
+ return unless shipping = options[:shipping]
+ post[:shipping] = {}
+ post[:shipping][:address] = {}
+ post[:shipping][:address][:line1] = shipping[:address][:line1]
+ post[:shipping][:address][:city] = shipping[:address][:city] if shipping[:address][:city]
+ post[:shipping][:address][:country] = shipping[:address][:country] if shipping[:address][:country]
+ post[:shipping][:address][:line2] = shipping[:address][:line2] if shipping[:address][:line2]
+ post[:shipping][:address][:postal_code] = shipping[:address][:postal_code] if shipping[:address][:postal_code]
+ post[:shipping][:address][:state] = shipping[:address][:state] if shipping[:address][:state]
+
+ post[:shipping][:name] = shipping[:name]
+ post[:shipping][:carrier] = shipping[:carrier] if shipping[:carrier]
+ post[:shipping][:phone] = shipping[:phone] if shipping[:phone]
+ post[:shipping][:tracking_number] = shipping[:tracking_number] if shipping[:tracking_number]
+ post
+ end
+ end
+ end
+end
diff --git a/test/remote/gateways/remote_stripe_payment_intents_test.rb b/test/remote/gateways/remote_stripe_payment_intents_test.rb
new file mode 100644
index 00000000000..59272687255
--- /dev/null
+++ b/test/remote/gateways/remote_stripe_payment_intents_test.rb
@@ -0,0 +1,389 @@
+require 'test_helper'
+
+class RemoteStripeIntentsTest < Test::Unit::TestCase
+ def setup
+ @gateway = StripePaymentIntentsGateway.new(fixtures(:stripe))
+ @customer = fixtures(:stripe)[:customer_id]
+ @amount = 2000
+ @three_ds_payment_method = 'pm_card_threeDSecure2Required'
+ @visa_payment_method = 'pm_card_visa'
+ @declined_payment_method = 'pm_card_chargeDeclined'
+ @three_ds_credit_card = credit_card('4000000000003220',
+ verification_value: '737',
+ month: 10,
+ year: 2020
+ )
+ @visa_card = credit_card('4242424242424242',
+ verification_value: '737',
+ month: 10,
+ year: 2020
+ )
+ @destination_account = fixtures(:stripe_destination)[:stripe_user_id]
+ end
+
+ def test_authorization_and_void
+ options = {
+ currency: 'GBP',
+ customer: @customer,
+ }
+ assert authorization = @gateway.authorize(@amount, @visa_payment_method, options)
+
+ assert_equal 'requires_capture', authorization.params['status']
+ refute authorization.params.dig('charges', 'data')[0]['captured']
+
+ assert void = @gateway.void(authorization.authorization)
+ assert_success void
+ end
+
+ def test_successful_purchase
+ options = {
+ currency: 'GBP',
+ customer: @customer,
+ }
+ assert purchase = @gateway.purchase(@amount, @visa_payment_method, options)
+
+ assert_equal 'succeeded', purchase.params['status']
+ assert purchase.params.dig('charges', 'data')[0]['captured']
+ end
+
+ def test_unsuccessful_purchase
+ options = {
+ currency: 'GBP',
+ customer: @customer,
+ }
+ assert purchase = @gateway.purchase(@amount, @declined_payment_method, options)
+
+ assert_equal 'Your card was declined.', purchase.message
+ refute purchase.params.dig('error', 'payment_intent', 'charges', 'data')[0]['captured']
+ end
+
+ def test_create_payment_intent_manual_capture_method
+ options = {
+ currency: 'USD',
+ capture_method: 'manual'
+ }
+
+ assert response = @gateway.create_intent(@amount, nil, options)
+
+ assert_success response
+ assert_equal 'payment_intent', response.params['object']
+ assert_equal 'manual', response.params['capture_method']
+ end
+
+ def test_create_payment_intent_manual_confimation_method
+ options = {
+ currency: 'USD',
+ description: 'ActiveMerchant Test Purchase',
+ confirmation_method: 'manual'
+ }
+
+ assert response = @gateway.create_intent(@amount, nil, options)
+
+ assert_success response
+ assert_equal 'payment_intent', response.params['object']
+ assert_equal 'manual', response.params['confirmation_method']
+ end
+
+ def test_create_payment_intent_with_customer
+ options = {
+ currency: 'USD',
+ customer: @customer || 'set customer in fixtures'
+ }
+
+ assert response = @gateway.create_intent(@amount, nil, options)
+
+ assert_success response
+ assert_equal 'payment_intent', response.params['object']
+ assert_equal @customer, response.params['customer']
+ end
+
+ def test_create_payment_intent_with_credit_card
+ options = {
+ currency: 'USD',
+ customer: @customer,
+ }
+
+ assert response = @gateway.create_intent(@amount, @three_ds_credit_card, options)
+
+ assert_success response
+ assert_equal 'payment_intent', response.params['object']
+ end
+
+ def test_create_payment_intent_with_return_url
+ options = {
+ currency: 'USD',
+ customer: @customer,
+ confirm: true,
+ return_url: 'https://www.example.com'
+ }
+
+ assert response = @gateway.create_intent(@amount, @three_ds_credit_card, options)
+
+ assert_success response
+ assert_equal 'https://www.example.com', response.params['next_action']['redirect_to_url']['return_url']
+ end
+
+ def test_create_payment_intent_with_metadata
+ options = {
+ currency: 'USD',
+ customer: @customer,
+ description: 'ActiveMerchant Test Purchase',
+ receipt_email: 'test@example.com',
+ statement_descriptor: 'Statement Descriptor',
+ metadata: { key_1: 'value_1', key_2: 'value_2' }
+ }
+
+ assert response = @gateway.create_intent(@amount, nil, options)
+
+ assert_success response
+ assert_equal 'value_1', response.params['metadata']['key_1']
+ assert_equal 'ActiveMerchant Test Purchase', response.params['description']
+ assert_equal 'test@example.com', response.params['receipt_email']
+ assert_equal 'Statement Descriptor', response.params['statement_descriptor']
+ end
+
+ def test_create_payment_intent_that_saves_payment_method
+ options = {
+ currency: 'USD',
+ customer: @customer,
+ save_payment_method: true
+ }
+
+ assert response = @gateway.create_intent(@amount, @three_ds_credit_card, options)
+ assert_success response
+
+ assert response = @gateway.create_intent(@amount, nil, options)
+ assert_failure response
+ assert_equal 'A payment method must be provided or already '\
+ 'attached to the PaymentIntent when `save_payment_method=true`.', response.message
+
+ options.delete(:customer)
+ assert response = @gateway.create_intent(@amount, @three_ds_credit_card, options)
+ assert_failure response
+ assert_equal 'A valid `customer` must be provided when `save_payment_method=true`.', response.message
+ end
+
+ def test_create_payment_intent_with_setup_future_usage
+ options = {
+ currency: 'USD',
+ customer: @customer,
+ setup_future_usage: 'on_session'
+ }
+
+ assert response = @gateway.create_intent(@amount, @three_ds_credit_card, options)
+ assert_success response
+ assert_equal 'on_session', response.params['setup_future_usage']
+ end
+
+ def test_3ds_unauthenticated_authorize_with_off_session
+ options = {
+ currency: 'USD',
+ customer: @customer,
+ off_session: true,
+ }
+
+ assert response = @gateway.authorize(@amount, @three_ds_credit_card, options)
+ assert_failure response
+ end
+
+ def test_create_payment_intent_with_shipping_address
+ options = {
+ currency: 'USD',
+ customer: @customer,
+ shipping: {
+ address: {
+ line1: '1 Test Ln',
+ city: 'Durham'
+ },
+ name: 'John Doe',
+ tracking_number: '123456789'
+ }
+ }
+
+ assert response = @gateway.create_intent(@amount, nil, options)
+ assert_success response
+ assert response.params['shipping']['address']
+ assert_equal 'John Doe', response.params['shipping']['name']
+ end
+
+ def test_create_payment_intent_with_connected_account
+ options = {
+ currency: 'USD',
+ customer: @customer,
+ application_fee: 100,
+ transfer_data: {destination: @destination_account}
+ }
+
+ assert response = @gateway.create_intent(@amount, nil, options)
+
+ assert_success response
+ assert_equal 100, response.params['application_fee_amount']
+ assert_equal @destination_account, response.params.dig('transfer_data', 'destination')
+ end
+
+ def test_create_a_payment_intent_and_confirm
+ options = {
+ currency: 'GBP',
+ customer: @customer,
+ return_url: 'https://www.example.com',
+ confirmation_method: 'manual',
+ capture_method: 'manual',
+ }
+ assert create_response = @gateway.create_intent(@amount, @three_ds_payment_method, options)
+ assert_equal 'requires_confirmation', create_response.params['status']
+ intent_id = create_response.params['id']
+
+ assert get_response = @gateway.show_intent(intent_id, options)
+ assert_equal 'requires_confirmation', get_response.params['status']
+
+ assert confirm_response = @gateway.confirm_intent(intent_id, nil, return_url: 'https://example.com/return-to-me')
+ assert_equal 'redirect_to_url', confirm_response.params.dig('next_action', 'type')
+ end
+
+ def test_create_a_payment_intent_and_manually_capture
+ options = {
+ currency: 'GBP',
+ customer: @customer,
+ confirmation_method: 'manual',
+ capture_method: 'manual',
+ confirm: true
+ }
+ assert create_response = @gateway.create_intent(@amount, @visa_payment_method, options)
+ intent_id = create_response.params['id']
+ assert_equal 'requires_capture', create_response.params['status']
+
+ assert capture_response = @gateway.capture(@amount, intent_id, options)
+ assert_equal 'succeeded', capture_response.params['status']
+ assert_equal 'Payment complete.', capture_response.params.dig('charges', 'data')[0].dig('outcome', 'seller_message')
+ end
+
+ def test_create_a_payment_intent_and_automatically_capture
+ options = {
+ currency: 'GBP',
+ customer: @customer,
+ confirmation_method: 'manual',
+ confirm: true
+ }
+ assert create_response = @gateway.create_intent(@amount, @visa_payment_method, options)
+ assert_nil create_response.params['next_action']
+ assert_equal 'succeeded', create_response.params['status']
+ assert_equal 'Payment complete.', create_response.params.dig('charges', 'data')[0].dig('outcome', 'seller_message')
+ end
+
+ def test_failed_capture_after_creation
+ options = {
+ currency: 'GBP',
+ customer: @customer,
+ confirmation_method: 'manual',
+ confirm: true
+ }
+ assert create_response = @gateway.create_intent(@amount, 'pm_card_chargeDeclined', options)
+ assert_equal 'requires_payment_method', create_response.params.dig('error', 'payment_intent', 'status')
+ assert_equal false, create_response.params.dig('error', 'payment_intent', 'charges', 'data')[0].dig('captured')
+ end
+
+ def test_create_a_payment_intent_and_update
+ update_amount = 2050
+ options = {
+ currency: 'GBP',
+ customer: @customer,
+ confirmation_method: 'manual',
+ capture_method: 'manual',
+ }
+ assert create_response = @gateway.create_intent(@amount, @visa_payment_method, options)
+ intent_id = create_response.params['id']
+ assert_equal @amount, create_response.params['amount']
+
+ assert update_response = @gateway.update_intent(update_amount, intent_id, nil, options.merge(payment_method_types: 'card'))
+ assert_equal update_amount, update_response.params['amount']
+ assert_equal 'requires_confirmation', update_response.params['status']
+ end
+
+ def test_create_a_payment_intent_and_void
+ options = {
+ currency: 'GBP',
+ customer: @customer,
+ confirmation_method: 'manual',
+ capture_method: 'manual',
+ confirm: true
+ }
+ assert create_response = @gateway.create_intent(@amount, @visa_payment_method, options)
+ intent_id = create_response.params['id']
+
+ assert cancel_response = @gateway.void(intent_id, cancellation_reason: 'requested_by_customer')
+ assert_equal @amount, cancel_response.params.dig('charges', 'data')[0].dig('amount_refunded')
+ assert_equal 'canceled', cancel_response.params['status']
+ assert_equal 'requested_by_customer', cancel_response.params['cancellation_reason']
+ end
+
+ def test_failed_void_after_capture
+ options = {
+ currency: 'GBP',
+ customer: @customer,
+ confirmation_method: 'manual',
+ confirm: true
+ }
+ assert create_response = @gateway.create_intent(@amount, @visa_payment_method, options)
+ assert_equal 'succeeded', create_response.params['status']
+ intent_id = create_response.params['id']
+
+ assert cancel_response = @gateway.void(intent_id, cancellation_reason: 'requested_by_customer')
+ assert_equal 'You cannot cancel this PaymentIntent because ' \
+ 'it has a status of succeeded. Only a PaymentIntent with ' \
+ 'one of the following statuses may be canceled: ' \
+ 'requires_payment_method, requires_capture, requires_confirmation, requires_action.', cancel_response.message
+ end
+
+ def test_refund_a_payment_intent
+ options = {
+ currency: 'GBP',
+ customer: @customer,
+ confirmation_method: 'manual',
+ capture_method: 'manual',
+ confirm: true
+ }
+ assert create_response = @gateway.create_intent(@amount, @visa_payment_method, options)
+ intent_id = create_response.params['id']
+
+ assert @gateway.capture(@amount, intent_id, options)
+
+ assert refund = @gateway.refund(@amount - 20, intent_id)
+ assert_equal @amount - 20, refund.params['charge']['amount_refunded']
+ assert_equal true, refund.params['charge']['captured']
+ refund_id = refund.params['id']
+ assert_equal refund.authorization, refund_id
+ end
+
+ def test_successful_store_purchase_and_unstore
+ options = {
+ currency: 'GBP',
+ }
+ assert store = @gateway.store(@visa_card, options)
+ assert store.params['customer'].start_with?('cus_')
+
+ assert purchase = @gateway.purchase(@amount, store.authorization, options)
+ assert 'succeeded', purchase.params['status']
+
+ assert unstore = @gateway.unstore(store.authorization)
+ assert_nil unstore.params['customer']
+ end
+
+ def test_transcript_scrubbing
+ options = {
+ currency: 'GBP',
+ customer: @customer,
+ confirmation_method: 'manual',
+ capture_method: 'manual',
+ return_url: 'https://www.example.com/return',
+ confirm: true
+ }
+ transcript = capture_transcript(@gateway) do
+ @gateway.create_intent(@amount, @three_ds_credit_card, options)
+ end
+ transcript = @gateway.scrub(transcript)
+
+ assert_scrubbed(@three_ds_credit_card.number, transcript)
+ assert_scrubbed(@three_ds_credit_card.verification_value, transcript)
+ assert_scrubbed(@gateway.options[:login], transcript)
+ end
+end
diff --git a/test/unit/gateways/stripe_payment_intents_test.rb b/test/unit/gateways/stripe_payment_intents_test.rb
new file mode 100644
index 00000000000..6245e7b494a
--- /dev/null
+++ b/test/unit/gateways/stripe_payment_intents_test.rb
@@ -0,0 +1,266 @@
+require 'test_helper'
+
+class StripePaymentIntentsTest < Test::Unit::TestCase
+ include CommStub
+
+ def setup
+ @gateway = StripePaymentIntentsGateway.new(:login => 'login')
+
+ @credit_card = credit_card()
+ @threeds_2_card = credit_card('4000000000003220')
+ @visa_token = 'pm_card_visa'
+ @amount = 2020
+ @update_amount = 2050
+
+ @options = {
+ currency: 'GBP',
+ confirmation_method: 'manual',
+ }
+ end
+
+ def test_successful_create_and_confirm_intent
+ @gateway.expects(:ssl_request).times(3).returns(successful_create_3ds2_payment_method, successful_create_3ds2_intent_response, successful_confirm_3ds2_intent_response)
+
+ assert create = @gateway.create_intent(@amount, @threeds_2_card, @options.merge(return_url: 'https://www.example.com', capture_method: 'manual'))
+ assert_instance_of Response, create
+ assert_success create
+
+ assert_equal 'pi_1F1wpFAWOtgoysog8nTulYGk', create.authorization
+ assert_equal 'requires_confirmation', create.params['status']
+ assert create.test?
+
+ assert confirm = @gateway.confirm_intent(create.params['id'], nil, return_url: 'https://example.com/return-to-me')
+ assert_equal 'redirect_to_url', confirm.params.dig('next_action', 'type')
+ end
+
+ def test_successful_create_and_capture_intent
+ options = @options.merge(capture_method: 'manual', confirm: true)
+ @gateway.expects(:ssl_request).twice.returns(successful_create_intent_response, successful_capture_response)
+ assert create = @gateway.create_intent(@amount, @visa_token, options)
+ assert_success create
+ assert_equal 'requires_capture', create.params['status']
+
+ assert capture = @gateway.capture(@amount, create.params['id'], options)
+ assert_success capture
+ assert_equal 'succeeded', capture.params['status']
+ assert_equal 'Payment complete.', capture.params.dig('charges', 'data')[0].dig('outcome', 'seller_message')
+ end
+
+ def test_successful_create_and_update_intent
+ @gateway.expects(:ssl_request).twice.returns(successful_create_intent_response, successful_update_intent_response)
+ assert create = @gateway.create_intent(@amount, @visa_token, @options.merge(capture_method: 'manual'))
+
+ assert update = @gateway.update_intent(@update_amount, create.params['id'], nil, @options.merge(capture_method: 'manual'))
+ assert_equal @update_amount, update.params['amount']
+ assert_equal 'requires_confirmation', update.params['status']
+ end
+
+ def test_successful_create_and_void_intent
+ @gateway.expects(:ssl_request).twice.returns(successful_create_intent_response, successful_void_response)
+ assert create = @gateway.create_intent(@amount, @visa_token, @options.merge(capture_method: 'manual', confirm: true))
+
+ assert cancel = @gateway.void(create.params['id'])
+ assert_equal @amount, cancel.params.dig('charges', 'data')[0].dig('amount_refunded')
+ assert_equal 'canceled', cancel.params['status']
+ end
+
+ def test_failed_capture_after_creation
+ @gateway.expects(:ssl_request).returns(failed_capture_response)
+
+ assert create = @gateway.create_intent(@amount, 'pm_card_chargeDeclined', @options.merge(confirm: true))
+ assert_equal 'requires_payment_method', create.params.dig('error', 'payment_intent', 'status')
+ assert_equal false, create.params.dig('error', 'payment_intent', 'charges', 'data')[0].dig('captured')
+ end
+
+ def test_failed_void_after_capture
+ @gateway.expects(:ssl_request).twice.returns(successful_capture_response, failed_cancel_response)
+ assert create = @gateway.create_intent(@amount, @visa_token, @options.merge(confirm: true))
+ assert_equal 'succeeded', create.params['status']
+ intent_id = create.params['id']
+
+ assert cancel = @gateway.void(intent_id, cancellation_reason: 'requested_by_customer')
+ assert_equal 'You cannot cancel this PaymentIntent because ' \
+ 'it has a status of succeeded. Only a PaymentIntent with ' \
+ 'one of the following statuses may be canceled: ' \
+ 'requires_payment_method, requires_capture, requires_confirmation, requires_action.', cancel.message
+ end
+
+ private
+
+ def successful_create_intent_response
+ <<-RESPONSE
+ {"id":"pi_1F1xauAWOtgoysogIfHO8jGi","object":"payment_intent","amount":2020,"amount_capturable":2020,"amount_received":0,"application":null,"application_fee_amount":null,"canceled_at":null,"cancellation_reason":null,"capture_method":"manual","charges":{"object":"list","data":[{"id":"ch_1F1xavAWOtgoysogxrtSiCu4","object":"charge","amount":2020,"amount_refunded":0,"application":null,"application_fee":null,"application_fee_amount":null,"balance_transaction":null,"billing_details":{"address":{"city":null,"country":null,"line1":null,"line2":null,"postal_code":null,"state":null},"email":null,"name":null,"phone":null},"captured":false,"created":1564501833,"currency":"gbp","customer":"cus_7s22nNueP2Hjj6","description":null,"destination":null,"dispute":null,"failure_code":null,"failure_message":null,"fraud_details":{},"invoice":null,"livemode":false,"metadata":{},"on_behalf_of":null,"order":null,"outcome":{"network_status":"approved_by_network","reason":null,"risk_level":"normal","risk_score":58,"seller_message":"Payment complete.","type":"authorized"},"paid":true,"payment_intent":"pi_1F1xauAWOtgoysogIfHO8jGi","payment_method":"pm_1F1xauAWOtgoysog00COoKIU","payment_method_details":{"card":{"brand":"visa","checks":{"address_line1_check":null,"address_postal_code_check":null,"cvc_check":null},"country":"US","exp_month":7,"exp_year":2020,"fingerprint":"hfaVNMiXc0dYSiC5","funding":"credit","last4":"4242","three_d_secure":null,"wallet":null},"type":"card"},"receipt_email":null,"receipt_number":null,"receipt_url":"https://pay.stripe.com/receipts/acct_160DX6AWOtgoysog/ch_1F1xavAWOtgoysogxrtSiCu4/rcpt_FX1eGdFRi8ssOY8Fqk4X6nEjNeGV5PG","refunded":false,"refunds":{"object":"list","data":[],"has_more":false,"total_count":0,"url":"/v1/charges/ch_1F1xavAWOtgoysogxrtSiCu4/refunds"},"review":null,"shipping":null,"source":null,"source_transfer":null,"statement_descriptor":null,"status":"succeeded","transfer_data":null,"transfer_group":null}],"has_more":false,"total_count":1,"url":"/v1/charges?payment_intent=pi_1F1xauAWOtgoysogIfHO8jGi"},"client_secret":"pi_1F1xauAWOtgoysogIfHO8jGi_secret_ZrXvfydFv0BelaMQJgHxjts5b","confirmation_method":"manual","created":1564501832,"currency":"gbp","customer":"cus_7s22nNueP2Hjj6","description":null,"invoice":null,"last_payment_error":null,"livemode":false,"metadata":{},"next_action":null,"on_behalf_of":null,"payment_method":"pm_1F1xauAWOtgoysog00COoKIU","payment_method_options":{"card":{"request_three_d_secure":"automatic"}},"payment_method_types":["card"],"receipt_email":null,"review":null,"setup_future_usage":null,"shipping":null,"source":null,"statement_descriptor":null,"status":"requires_capture","transfer_data":null,"transfer_group":null}
+ RESPONSE
+ end
+
+ def successful_capture_response
+ <<-RESPONSE
+ {"id":"pi_1F1xauAWOtgoysogIfHO8jGi","object":"payment_intent","amount":2020,"amount_capturable":0,"amount_received":2020,"application":null,"application_fee_amount":null,"canceled_at":null,"cancellation_reason":null,"capture_method":"manual","charges":{"object":"list","data":[{"id":"ch_1F1xavAWOtgoysogxrtSiCu4","object":"charge","amount":2020,"amount_refunded":0,"application":null,"application_fee":null,"application_fee_amount":null,"balance_transaction":"txn_1F1xawAWOtgoysog27xGBjM6","billing_details":{"address":{"city":null,"country":null,"line1":null,"line2":null,"postal_code":null,"state":null},"email":null,"name":null,"phone":null},"captured":true,"created":1564501833,"currency":"gbp","customer":"cus_7s22nNueP2Hjj6","description":null,"destination":null,"dispute":null,"failure_code":null,"failure_message":null,"fraud_details":{},"invoice":null,"livemode":false,"metadata":{},"on_behalf_of":null,"order":null,"outcome":{"network_status":"approved_by_network","reason":null,"risk_level":"normal","risk_score":58,"seller_message":"Payment complete.","type":"authorized"},"paid":true,"payment_intent":"pi_1F1xauAWOtgoysogIfHO8jGi","payment_method":"pm_1F1xauAWOtgoysog00COoKIU","payment_method_details":{"card":{"brand":"visa","checks":{"address_line1_check":null,"address_postal_code_check":null,"cvc_check":null},"country":"US","exp_month":7,"exp_year":2020,"fingerprint":"hfaVNMiXc0dYSiC5","funding":"credit","last4":"4242","three_d_secure":null,"wallet":null},"type":"card"},"receipt_email":null,"receipt_number":null,"receipt_url":"https://pay.stripe.com/receipts/acct_160DX6AWOtgoysog/ch_1F1xavAWOtgoysogxrtSiCu4/rcpt_FX1eGdFRi8ssOY8Fqk4X6nEjNeGV5PG","refunded":false,"refunds":{"object":"list","data":[],"has_more":false,"total_count":0,"url":"/v1/charges/ch_1F1xavAWOtgoysogxrtSiCu4/refunds"},"review":null,"shipping":null,"source":null,"source_transfer":null,"statement_descriptor":null,"status":"succeeded","transfer_data":null,"transfer_group":null}],"has_more":false,"total_count":1,"url":"/v1/charges?payment_intent=pi_1F1xauAWOtgoysogIfHO8jGi"},"client_secret":"pi_1F1xauAWOtgoysogIfHO8jGi_secret_ZrXvfydFv0BelaMQJgHxjts5b","confirmation_method":"manual","created":1564501832,"currency":"gbp","customer":"cus_7s22nNueP2Hjj6","description":null,"invoice":null,"last_payment_error":null,"livemode":false,"metadata":{},"next_action":null,"on_behalf_of":null,"payment_method":"pm_1F1xauAWOtgoysog00COoKIU","payment_method_options":{"card":{"request_three_d_secure":"automatic"}},"payment_method_types":["card"],"receipt_email":null,"review":null,"setup_future_usage":null,"shipping":null,"source":null,"statement_descriptor":null,"status":"succeeded","transfer_data":null,"transfer_group":null}
+ RESPONSE
+ end
+
+ def successful_void_response
+ <<-RESPONSE
+ {"id":"pi_1F1yBVAWOtgoysogearamRvl","object":"payment_intent","amount":2020,"amount_capturable":0,"amount_received":0,"application":null,"application_fee_amount":null,"canceled_at":1564504103,"cancellation_reason":"requested_by_customer","capture_method":"manual","charges":{"object":"list","data":[{"id":"ch_1F1yBWAWOtgoysog1MQfDpJH","object":"charge","amount":2020,"amount_refunded":2020,"application":null,"application_fee":null,"application_fee_amount":null,"balance_transaction":null,"billing_details":{"address":{"city":null,"country":null,"line1":null,"line2":null,"postal_code":null,"state":null},"email":null,"name":null,"phone":null},"captured":false,"created":1564504102,"currency":"gbp","customer":"cus_7s22nNueP2Hjj6","description":null,"destination":null,"dispute":null,"failure_code":null,"failure_message":null,"fraud_details":{},"invoice":null,"livemode":false,"metadata":{},"on_behalf_of":null,"order":null,"outcome":{"network_status":"approved_by_network","reason":null,"risk_level":"normal","risk_score":46,"seller_message":"Payment complete.","type":"authorized"},"paid":true,"payment_intent":"pi_1F1yBVAWOtgoysogearamRvl","payment_method":"pm_1F1yBVAWOtgoysogddy4E3hL","payment_method_details":{"card":{"brand":"visa","checks":{"address_line1_check":null,"address_postal_code_check":null,"cvc_check":null},"country":"US","exp_month":7,"exp_year":2020,"fingerprint":"hfaVNMiXc0dYSiC5","funding":"credit","last4":"4242","three_d_secure":null,"wallet":null},"type":"card"},"receipt_email":null,"receipt_number":null,"receipt_url":"https://pay.stripe.com/receipts/acct_160DX6AWOtgoysog/ch_1F1yBWAWOtgoysog1MQfDpJH/rcpt_FX2Go3YHBqAYQPJuKGMeab3nyCU0Kks","refunded":true,"refunds":{"object":"list","data":[{"id":"re_1F1yBXAWOtgoysog0PU371Yz","object":"refund","amount":2020,"balance_transaction":null,"charge":"ch_1F1yBWAWOtgoysog1MQfDpJH","created":1564504103,"currency":"gbp","metadata":{},"reason":"requested_by_customer","receipt_number":null,"source_transfer_reversal":null,"status":"succeeded","transfer_reversal":null}],"has_more":false,"total_count":1,"url":"/v1/charges/ch_1F1yBWAWOtgoysog1MQfDpJH/refunds"},"review":null,"shipping":null,"source":null,"source_transfer":null,"statement_descriptor":null,"status":"succeeded","transfer_data":null,"transfer_group":null}],"has_more":false,"total_count":1,"url":"/v1/charges?payment_intent=pi_1F1yBVAWOtgoysogearamRvl"},"client_secret":"pi_1F1yBVAWOtgoysogearamRvl_secret_oCnlR2t0GPclqACgHt2rst4gM","confirmation_method":"manual","created":1564504101,"currency":"gbp","customer":"cus_7s22nNueP2Hjj6","description":null,"invoice":null,"last_payment_error":null,"livemode":false,"metadata":{},"next_action":null,"on_behalf_of":null,"payment_method":"pm_1F1yBVAWOtgoysogddy4E3hL","payment_method_options":{"card":{"request_three_d_secure":"automatic"}},"payment_method_types":["card"],"receipt_email":null,"review":null,"setup_future_usage":null,"shipping":null,"source":null,"statement_descriptor":null,"status":"canceled","transfer_data":null,"transfer_group":null}
+ RESPONSE
+ end
+
+ def successful_update_intent_response
+ <<-RESPONSE
+ {"id":"pi_1F1yBbAWOtgoysog52J88BuO","object":"payment_intent","amount":2050,"amount_capturable":0,"amount_received":0,"application":null,"application_fee_amount":null,"canceled_at":null,"cancellation_reason":null,"capture_method":"manual","charges":{"object":"list","data":[],"has_more":false,"total_count":0,"url":"/v1/charges?payment_intent=pi_1F1yBbAWOtgoysog52J88BuO"},"client_secret":"pi_1F1yBbAWOtgoysog52J88BuO_secret_olw5rmbtm7cd72S9JfbKjTJJv","confirmation_method":"manual","created":1564504107,"currency":"gbp","customer":"cus_7s22nNueP2Hjj6","description":null,"invoice":null,"last_payment_error":null,"livemode":false,"metadata":{},"next_action":null,"on_behalf_of":null,"payment_method":"pm_1F1yBbAWOtgoysoguJQsDdYj","payment_method_options":{"card":{"request_three_d_secure":"automatic"}},"payment_method_types":["card"],"receipt_email":null,"review":null,"setup_future_usage":null,"shipping":null,"source":null,"statement_descriptor":null,"status":"requires_confirmation","transfer_data":null,"transfer_group":null}
+ RESPONSE
+ end
+
+ def successful_create_3ds2_payment_method
+ <<-RESPONSE
+ {
+ "id": "pm_1F1xK0AWOtgoysogfPuRKN1d",
+ "object": "payment_method",
+ "billing_details": {
+ "address": {"city": null,
+ "country": null,
+ "line1": null,
+ "line2": null,
+ "postal_code": null,
+ "state": null},
+ "email": null,
+ "name": null,
+ "phone": null},
+ "card": {
+ "brand": "visa",
+ "checks": {"address_line1_check": null,
+ "address_postal_code_check": null,
+ "cvc_check": "unchecked"},
+ "country": null,
+ "exp_month": 10,
+ "exp_year": 2020,
+ "fingerprint": "l3J0NJaGgv0jAGLV",
+ "funding": "credit",
+ "generated_from": null,
+ "last4": "3220",
+ "three_d_secure_usage": {"supported": true},
+ "wallet": null},
+ "created": 1564500784,
+ "customer": null,
+ "livemode": false,
+ "metadata": {},
+ "type": "card"
+ }
+ RESPONSE
+ end
+
+ def successful_create_3ds2_intent_response
+ <<-RESPONSE
+ {
+ "id": "pi_1F1wpFAWOtgoysog8nTulYGk",
+ "object": "payment_intent",
+ "amount": 2020,
+ "amount_capturable": 0,
+ "amount_received": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "canceled_at": null,
+ "cancellation_reason": null,
+ "capture_method": "manual",
+ "charges": {
+ "object": "list",
+ "data": [],
+ "has_more": false,
+ "total_count": 0,
+ "url": "/v1/charges?payment_intent=pi_1F1wpFAWOtgoysog8nTulYGk"
+ },
+ "client_secret": "pi_1F1wpFAWOtgoysog8nTulYGk_secret_75qf7rjBDsTTz279LfS1feXUj",
+ "confirmation_method": "manual",
+ "created": 1564498877,
+ "currency": "gbp",
+ "customer": "cus_7s22nNueP2Hjj6",
+ "description": null,
+ "invoice": null,
+ "last_payment_error": null,
+ "livemode": false,
+ "metadata": {},
+ "next_action": null,
+ "on_behalf_of": null,
+ "payment_method": "pm_1F1wpFAWOtgoysogJ8zQ8K07",
+ "payment_method_options": {
+ "card": {"request_three_d_secure": "automatic"}
+ },
+ "payment_method_types": ["card"],
+ "receipt_email": null,
+ "review": null,
+ "setup_future_usage": null,
+ "shipping": null,
+ "source": null,
+ "statement_descriptor": null,
+ "status": "requires_confirmation",
+ "transfer_data": null,
+ "transfer_group": null
+ }
+ RESPONSE
+ end
+
+ def successful_confirm_3ds2_intent_response
+ <<-RESPONSE
+ {
+ "id": "pi_1F1wpFAWOtgoysog8nTulYGk",
+ "object": "payment_intent",
+ "amount": 2020,
+ "amount_capturable": 0,
+ "amount_received": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "canceled_at": null,
+ "cancellation_reason": null,
+ "capture_method": "manual",
+ "charges": {
+ "object": "list",
+ "data": [],
+ "has_more": false,
+ "total_count": 0,
+ "url": "/v1/charges?payment_intent=pi_1F1wpFAWOtgoysog8nTulYGk"},
+ "client_secret": "pi_1F1wpFAWOtgoysog8nTulYGk_secret_75qf7rjBDsTTz279LfS1feXUj",
+ "confirmation_method": "manual",
+ "created": 1564498877,
+ "currency": "gbp",
+ "customer": "cus_7s22nNueP2Hjj6",
+ "description": null,
+ "invoice": null,
+ "last_payment_error": null,
+ "livemode": false,
+ "metadata": {},
+ "next_action": {
+ "redirect_to_url": {
+ "return_url": "https://example.com/return-to-me",
+ "url": "https://hooks.stripe.com/3d_secure_2_eap/begin_test/src_1F1wpGAWOtgoysog4f00umCp/src_client_secret_FX0qk3uQ04woFWgdJbN3pnHD"},
+ "type": "redirect_to_url"},
+ "on_behalf_of": null,
+ "payment_method": "pm_1F1wpFAWOtgoysogJ8zQ8K07",
+ "payment_method_options": {
+ "card": {"request_three_d_secure": "automatic"}
+ },
+ "payment_method_types": ["card"],
+ "receipt_email": null,
+ "review": null,
+ "setup_future_usage": null,
+ "shipping": null,
+ "source": null,
+ "statement_descriptor": null,
+ "status": "requires_action",
+ "transfer_data": null,
+ "transfer_group": null
+ }
+ RESPONSE
+ end
+
+ def failed_capture_response
+ <<-RESPONSE
+ {"error":{"charge":"ch_1F2MB6AWOtgoysogAIvNV32Z","code":"card_declined","decline_code":"generic_decline","doc_url":"https://stripe.com/docs/error-codes/card-declined","message":"Your card was declined.","payment_intent":{"id":"pi_1F2MB5AWOtgoysogCMt8BaxR","object":"payment_intent","amount":2020,"amount_capturable":0,"amount_received":0,"application":null,"application_fee_amount":null,"canceled_at":null,"cancellation_reason":null,"capture_method":"automatic","charges":{"object":"list","data":[{"id":"ch_1F2MB6AWOtgoysogAIvNV32Z","object":"charge","amount":2020,"amount_refunded":0,"application":null,"application_fee":null,"application_fee_amount":null,"balance_transaction":null,"billing_details":{"address":{"city":null,"country":null,"line1":null,"line2":null,"postal_code":null,"state":null},"email":null,"name":null,"phone":null},"captured":false,"created":1564596332,"currency":"gbp","customer":"cus_7s22nNueP2Hjj6","description":null,"destination":null,"dispute":null,"failure_code":"card_declined","failure_message":"Your card was declined.","fraud_details":{},"invoice":null,"livemode":false,"metadata":{},"on_behalf_of":null,"order":null,"outcome":{"network_status":"declined_by_network","reason":"generic_decline","risk_level":"normal","risk_score":41,"seller_message":"The bank did not return any further details with this decline.","type":"issuer_declined"},"paid":false,"payment_intent":"pi_1F2MB5AWOtgoysogCMt8BaxR","payment_method":"pm_1F2MB5AWOtgoysogq3yXZ98h","payment_method_details":{"card":{"brand":"visa","checks":{"address_line1_check":null,"address_postal_code_check":null,"cvc_check":null},"country":"US","exp_month":7,"exp_year":2020,"fingerprint":"1VUoWMvHnqtngyrD","funding":"credit","last4":"0002","three_d_secure":null,"wallet":null},"type":"card"},"receipt_email":null,"receipt_number":null,"receipt_url":"https://pay.stripe.com/receipts/acct_160DX6AWOtgoysog/ch_1F2MB6AWOtgoysogAIvNV32Z/rcpt_FXR3PjBGluHmHsnLmp0S2KQiHl3yg6W","refunded":false,"refunds":{"object":"list","data":[],"has_more":false,"total_count":0,"url":"/v1/charges/ch_1F2MB6AWOtgoysogAIvNV32Z/refunds"},"review":null,"shipping":null,"source":null,"source_transfer":null,"statement_descriptor":null,"status":"failed","transfer_data":null,"transfer_group":null}],"has_more":false,"total_count":1,"url":"/v1/charges?payment_intent=pi_1F2MB5AWOtgoysogCMt8BaxR"},"client_secret":"pi_1F2MB5AWOtgoysogCMt8BaxR_secret_fOHryjtjBE4gACiHTcREraXSQ","confirmation_method":"manual","created":1564596331,"currency":"gbp","customer":"cus_7s22nNueP2Hjj6","description":null,"invoice":null,"last_payment_error":{"charge":"ch_1F2MB6AWOtgoysogAIvNV32Z","code":"card_declined","decline_code":"generic_decline","doc_url":"https://stripe.com/docs/error-codes/card-declined","message":"Your card was declined.","payment_method":{"id":"pm_1F2MB5AWOtgoysogq3yXZ98h","object":"payment_method","billing_details":{"address":{"city":null,"country":null,"line1":null,"line2":null,"postal_code":null,"state":null},"email":null,"name":null,"phone":null},"card":{"brand":"visa","checks":{"address_line1_check":null,"address_postal_code_check":null,"cvc_check":null},"country":"US","exp_month":7,"exp_year":2020,"fingerprint":"1VUoWMvHnqtngyrD","funding":"credit","generated_from":null,"last4":"0002","three_d_secure_usage":{"supported":true},"wallet":null},"created":1564596331,"customer":null,"livemode":false,"metadata":{},"type":"card"},"type":"card_error"},"livemode":false,"metadata":{},"next_action":null,"on_behalf_of":null,"payment_method":null,"payment_method_options":{"card":{"request_three_d_secure":"automatic"}},"payment_method_types":["card"],"receipt_email":null,"review":null,"setup_future_usage":null,"shipping":null,"source":null,"statement_descriptor":null,"status":"requires_payment_method","transfer_data":null,"transfer_group":null},"payment_method":{"id":"pm_1F2MB5AWOtgoysogq3yXZ98h","object":"payment_method","billing_details":{"address":{"city":null,"country":null,"line1":null,"line2":null,"postal_code":null,"state":null},"email":null,"name":null,"phone":null},"card":{"brand":"visa","checks":{"address_line1_check":null,"address_postal_code_check":null,"cvc_check":null},"country":"US","exp_month":7,"exp_year":2020,"fingerprint":"1VUoWMvHnqtngyrD","funding":"credit","generated_from":null,"last4":"0002","three_d_secure_usage":{"supported":true},"wallet":null},"created":1564596331,"customer":null,"livemode":false,"metadata":{},"type":"card"},"type":"card_error"}}
+ RESPONSE
+ end
+
+ def failed_cancel_response
+ <<-RESPONSE
+ {"error":{"code":"payment_intent_unexpected_state","doc_url":"https://stripe.com/docs/error-codes/payment-intent-unexpected-state","message":"You cannot cancel this PaymentIntent because it has a status of succeeded. Only a PaymentIntent with one of the following statuses may be canceled: requires_payment_method, requires_capture, requires_confirmation, requires_action.","payment_intent":{"id":"pi_1F2McmAWOtgoysoglFLDRWab","object":"payment_intent","amount":2020,"amount_capturable":0,"amount_received":2020,"application":null,"application_fee_amount":null,"canceled_at":null,"cancellation_reason":null,"capture_method":"automatic","charges":{"object":"list","data":[{"id":"ch_1F2McmAWOtgoysogQgUS1YtH","object":"charge","amount":2020,"amount_refunded":0,"application":null,"application_fee":null,"application_fee_amount":null,"balance_transaction":"txn_1F2McmAWOtgoysog8uxBEJ30","billing_details":{"address":{"city":null,"country":null,"line1":null,"line2":null,"postal_code":null,"state":null},"email":null,"name":null,"phone":null},"captured":true,"created":1564598048,"currency":"gbp","customer":"cus_7s22nNueP2Hjj6","description":null,"destination":null,"dispute":null,"failure_code":null,"failure_message":null,"fraud_details":{},"invoice":null,"livemode":false,"metadata":{},"on_behalf_of":null,"order":null,"outcome":{"network_status":"approved_by_network","reason":null,"risk_level":"normal","risk_score":53,"seller_message":"Payment complete.","type":"authorized"},"paid":true,"payment_intent":"pi_1F2McmAWOtgoysoglFLDRWab","payment_method":"pm_1F2MclAWOtgoysogq80GBBMO","payment_method_details":{"card":{"brand":"visa","checks":{"address_line1_check":null,"address_postal_code_check":null,"cvc_check":null},"country":"US","exp_month":7,"exp_year":2020,"fingerprint":"hfaVNMiXc0dYSiC5","funding":"credit","last4":"4242","three_d_secure":null,"wallet":null},"type":"card"},"receipt_email":null,"receipt_number":null,"receipt_url":"https://pay.stripe.com/receipts/acct_160DX6AWOtgoysog/ch_1F2McmAWOtgoysogQgUS1YtH/rcpt_FXRVzyFnf7aCS1r13N3uym1u8AaboOJ","refunded":false,"refunds":{"object":"list","data":[],"has_more":false,"total_count":0,"url":"/v1/charges/ch_1F2McmAWOtgoysogQgUS1YtH/refunds"},"review":null,"shipping":null,"source":null,"source_transfer":null,"statement_descriptor":null,"status":"succeeded","transfer_data":null,"transfer_group":null}],"has_more":false,"total_count":1,"url":"/v1/charges?payment_intent=pi_1F2McmAWOtgoysoglFLDRWab"},"client_secret":"pi_1F2McmAWOtgoysoglFLDRWab_secret_z4faDF0Cv0JZJ6pxK3bdIodkD","confirmation_method":"manual","created":1564598048,"currency":"gbp","customer":"cus_7s22nNueP2Hjj6","description":null,"invoice":null,"last_payment_error":null,"livemode":false,"metadata":{},"next_action":null,"on_behalf_of":null,"payment_method":"pm_1F2MclAWOtgoysogq80GBBMO","payment_method_options":{"card":{"request_three_d_secure":"automatic"}},"payment_method_types":["card"],"receipt_email":null,"review":null,"setup_future_usage":null,"shipping":null,"source":null,"statement_descriptor":null,"status":"succeeded","transfer_data":null,"transfer_group":null},"type":"invalid_request_error"}}
+ RESPONSE
+ end
+end
From 3ffed0fd40045ea240f5963e6effc852886cfbb6 Mon Sep 17 00:00:00 2001
From: Jared Knipp
Date: Tue, 13 Aug 2019 17:06:28 -0500
Subject: [PATCH 0411/2234] Stripe: Send cardholder name and address with 3DS
1.0
Add the cardholder name, address, email and phone to the card source
created for 3DS 1.0 transactions.
ECS-455
Unit:
135 tests, 722 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
67 tests, 313 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote 3DS:
12 tests, 88 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
closes #3300
---
CHANGELOG | 1 +
Gemfile | 1 +
.../billing/gateways/stripe.rb | 35 ++++++--
.../remote/gateways/remote_stripe_3ds_test.rb | 88 +++++++++++++++----
4 files changed, 101 insertions(+), 24 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index b33b34e41a5..b3105484d5e 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,7 @@
== HEAD
* Stripe Payment Intents: Add new gateway [britth] #3290
+* Stripe: Send cardholder name and address when creating sources for 3DS 1.0 [jknipp] #3300
== Version 1.97.0 (Aug 15, 2019)
* CyberSource: Add issuer `additionalData` gateway-specific field [jasonxp] #3296
diff --git a/Gemfile b/Gemfile
index 3c766be75de..19c64a756b1 100644
--- a/Gemfile
+++ b/Gemfile
@@ -7,4 +7,5 @@ gem 'rubocop', '~> 0.60.0', require: false
group :test, :remote_test do
# gateway-specific dependencies, keeping these gems out of the gemspec
gem 'braintree', '>= 2.93.0'
+ gem 'mechanize'
end
diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb
index e8f9b0de5e7..ffa022c58d7 100644
--- a/lib/active_merchant/billing/gateways/stripe.rb
+++ b/lib/active_merchant/billing/gateways/stripe.rb
@@ -304,8 +304,8 @@ def create_source(money, payment, type, options = {})
add_amount(post, money, options, true)
post[:type] = type
if type == 'card'
- add_creditcard(post, payment, options)
- post[:card].delete(:name)
+ add_creditcard(post, payment, options, true)
+ add_source_owner(post, payment, options)
elsif type == 'three_d_secure'
post[:three_d_secure] = {card: payment}
post[:redirect] = {return_url: options[:redirect_url]}
@@ -351,6 +351,12 @@ def create_post_for_auth_or_purchase(money, payment, options)
add_creditcard(post, payment, options)
end
+ add_charge_details(post, money, payment, options)
+ post
+ end
+
+ # Used internally by Spreedly to populate the charge object for 3DS 1.0 transactions
+ def add_charge_details(post, money, payment, options)
if emv_payment?(payment)
add_statement_address(post, options)
add_emv_metadata(post, payment)
@@ -453,7 +459,7 @@ def add_statement_address(post, options)
post[:statement_address][:state] = statement_address[:state]
end
- def add_creditcard(post, creditcard, options)
+ def add_creditcard(post, creditcard, options, use_sources = false)
card = {}
if emv_payment?(creditcard)
add_emv_creditcard(post, creditcard.icc_data)
@@ -476,7 +482,7 @@ def add_creditcard(post, creditcard, options)
card[:exp_month] = creditcard.month
card[:exp_year] = creditcard.year
card[:cvc] = creditcard.verification_value if creditcard.verification_value?
- card[:name] = creditcard.name if creditcard.name
+ card[:name] = creditcard.name if creditcard.name && !use_sources
end
if creditcard.is_a?(NetworkTokenizationCreditCard)
@@ -486,7 +492,7 @@ def add_creditcard(post, creditcard, options)
end
post[:card] = card
- add_address(post, options)
+ add_address(post, options) unless use_sources
elsif creditcard.kind_of?(String)
if options[:track_data]
card[:swipe_data] = options[:track_data]
@@ -534,6 +540,25 @@ def add_emv_metadata(post, creditcard)
post[:metadata][:card_read_method] = creditcard.read_method if creditcard.respond_to?(:read_method)
end
+ def add_source_owner(post, creditcard, options)
+ post[:owner] = {}
+ post[:owner][:name] = creditcard.name if creditcard.name
+ post[:owner][:email] = options[:email] if options[:email]
+
+ if address = options[:billing_address] || options[:address]
+ owner_address = {}
+ owner_address[:line1] = address[:address1] if address[:address1]
+ owner_address[:line2] = address[:address2] if address[:address2]
+ owner_address[:country] = address[:country] if address[:country]
+ owner_address[:postal_code] = address[:zip] if address[:zip]
+ owner_address[:state] = address[:state] if address[:state]
+ owner_address[:city] = address[:city] if address[:city]
+
+ post[:owner][:phone] = address[:phone] if address[:phone]
+ post[:owner][:address] = owner_address
+ end
+ end
+
def parse(body)
JSON.parse(body)
end
diff --git a/test/remote/gateways/remote_stripe_3ds_test.rb b/test/remote/gateways/remote_stripe_3ds_test.rb
index 3231ce99993..fb596dc05ae 100644
--- a/test/remote/gateways/remote_stripe_3ds_test.rb
+++ b/test/remote/gateways/remote_stripe_3ds_test.rb
@@ -1,4 +1,5 @@
require 'test_helper'
+require 'mechanize'
class RemoteStripe3DSTest < Test::Unit::TestCase
CHARGE_ID_REGEX = /ch_[a-zA-Z\d]{24}/
@@ -6,6 +7,7 @@ class RemoteStripe3DSTest < Test::Unit::TestCase
def setup
@gateway = StripeGateway.new(fixtures(:stripe))
@amount = 100
+ @billing_details = address()
@options = {
:currency => 'USD',
@@ -13,7 +15,8 @@ def setup
:email => 'wow@example.com',
:execute_threed => true,
:redirect_url => 'http://www.example.com/redirect',
- :callback_url => 'http://www.example.com/callback'
+ :callback_url => 'http://www.example.com/callback',
+ :billing_address => @billing_details
}
@credit_card = credit_card('4000000000003063')
@non_3ds_card = credit_card('378282246310005')
@@ -23,42 +26,29 @@ def setup
def test_create_3ds_card_source
assert response = @gateway.send(:create_source, @amount, @credit_card, 'card', @options)
- assert_success response
- assert_equal 'source', response.params['object']
- assert_equal 'chargeable', response.params['status']
- assert_equal 'required', response.params['card']['three_d_secure']
- assert_equal 'card', response.params['type']
+ assert_card_source(response)
end
def test_create_non3ds_card_source
assert response = @gateway.send(:create_source, @amount, @non_3ds_card, 'card', @options)
- assert_success response
- assert_equal 'source', response.params['object']
- assert_equal 'chargeable', response.params['status']
- assert_equal 'not_supported', response.params['card']['three_d_secure']
- assert_equal 'card', response.params['type']
+ assert_card_source(response, 'not_supported')
end
def test_create_3ds_source
card_source = @gateway.send(:create_source, @amount, @credit_card, 'card', @options)
assert response = @gateway.send(:create_source, @amount, card_source.params['id'], 'three_d_secure', @options)
assert_success response
- assert_equal 'source', response.params['object']
- assert_equal 'pending', response.params['status']
- assert_equal 'three_d_secure', response.params['type']
- assert_equal false, response.params['three_d_secure']['authenticated']
+ assert_three_ds_source(response)
end
def test_show_3ds_source
card_source = @gateway.send(:create_source, @amount, @credit_card, 'card', @options)
assert three_d_secure_source = @gateway.send(:create_source, @amount, card_source.params['id'], 'three_d_secure', @options)
assert_success three_d_secure_source
+ assert_three_ds_source(three_d_secure_source)
assert response = @gateway.send(:show_source, three_d_secure_source.params['id'], @options)
- assert_equal 'source', response.params['object']
- assert_equal 'pending', response.params['status']
- assert_equal 'three_d_secure', response.params['type']
- assert_equal false, response.params['three_d_secure']['authenticated']
+ assert_three_ds_source(response)
end
def test_create_webhook_endpoint
@@ -141,4 +131,64 @@ def test_list_webhook_endpoints
assert_equal true, deleted_response2.params['deleted']
end
+ def test_3ds_purchase
+ card_source_response = @gateway.send(:create_source, @amount, @credit_card, 'card', @options)
+ assert_card_source(card_source_response)
+
+ assert three_ds_source_response = @gateway.send(:create_source, @amount, card_source_response.params['id'], 'three_d_secure', @options)
+ assert_success three_ds_source_response
+ assert_three_ds_source(three_ds_source_response)
+
+ # Simulate 3DS 1.0 authentication in the test environment
+ authentication_url = three_ds_source_response.params['redirect']['url']
+ agent = Mechanize.new
+ page = agent.get(authentication_url)
+
+ form = page.forms.first
+ form.submit.tap do |result_page|
+ assert_equal '200', result_page.code
+ end
+
+ # Test charging of the 3DS source
+ threeds_params = {}
+ threeds_params[:source] = three_ds_source_response.params['id']
+ threeds_params[:capture] = 'true'
+
+ @gateway.send(:add_charge_details, threeds_params, @amount, @credit_card, @options)
+
+ assert response = @gateway.send(:commit, :post, 'charges', threeds_params, @options)
+ assert_equal 'charge', response.params['object']
+ assert_equal 'succeeded', response.params['status']
+ assert_equal true, response.params['captured']
+ assert_equal 'three_d_secure', response.params.dig('source', 'type')
+ assert_equal true, response.params.dig('payment_method_details', 'card', 'three_d_secure', 'authenticated')
+
+ # Check that billing details have been propagated from the card source to the charge
+ billing_details = response.params['billing_details']
+ assert_equal @options[:email], billing_details['email']
+ assert_equal @credit_card.name, billing_details['name']
+ assert_equal @billing_details[:phone], billing_details['phone']
+ assert_equal @billing_details[:address1], billing_details['address']['line1']
+ assert_equal @billing_details[:address2], billing_details['address']['line2']
+ assert_equal @billing_details[:city], billing_details['address']['city']
+ assert_equal @billing_details[:state], billing_details['address']['state']
+ assert_equal @billing_details[:zip], billing_details['address']['postal_code']
+ assert_equal @billing_details[:country], billing_details['address']['country']
+ end
+
+ def assert_card_source(response, three_d_secure_status = 'required')
+ assert_success response
+ assert_equal 'source', response.params['object']
+ assert_equal 'chargeable', response.params['status']
+ assert_equal three_d_secure_status, response.params['card']['three_d_secure']
+ assert_equal 'card', response.params['type']
+ end
+
+ def assert_three_ds_source(response)
+ assert_equal 'source', response.params['object']
+ assert_equal 'pending', response.params['status']
+ assert_equal 'three_d_secure', response.params['type']
+ assert_equal false, response.params['three_d_secure']['authenticated']
+ end
+
end
From aeeeccc5aa0f952efc9481f5542d8eb25018df9d Mon Sep 17 00:00:00 2001
From: Niaja
Date: Wed, 14 Aug 2019 14:52:09 -0400
Subject: [PATCH 0412/2234] Checkout_v2: Support for native 3DS2.0
Adds a method to verify a payment after its gone through 3DS
authentication.
Loaded suite test/unit/gateways/checkout_v2_test
..........................
26 tests, 116 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Loaded suite test/remote/gateways/remote_checkout_v2_test
29 tests, 70 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/checkout_v2.rb | 15 +++++--
test/unit/gateways/checkout_v2_test.rb | 43 +++++++++++++++++++
3 files changed, 56 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index b3105484d5e..4b5d86eb330 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -3,6 +3,7 @@
== HEAD
* Stripe Payment Intents: Add new gateway [britth] #3290
* Stripe: Send cardholder name and address when creating sources for 3DS 1.0 [jknipp] #3300
+* Checkout_v2: Support for native 3DS2.0 [nfarve] #3303
== Version 1.97.0 (Aug 15, 2019)
* CyberSource: Add issuer `additionalData` gateway-specific field [jasonxp] #3296
diff --git a/lib/active_merchant/billing/gateways/checkout_v2.rb b/lib/active_merchant/billing/gateways/checkout_v2.rb
index 9c5c1a190a0..e16fe5049ba 100644
--- a/lib/active_merchant/billing/gateways/checkout_v2.rb
+++ b/lib/active_merchant/billing/gateways/checkout_v2.rb
@@ -68,6 +68,10 @@ def verify(credit_card, options = {})
end
end
+ def verify_payment(authorization, option={})
+ commit(:verify_payment, authorization)
+ end
+
def supports_scrubbing?
true
end
@@ -128,9 +132,14 @@ def add_transaction_data(post, options = {})
end
def add_3ds(post, options)
- if options[:three_d_secure]
+ if options[:three_d_secure] || options[:execute_threed]
post[:'3ds'] = {}
post[:'3ds'][:enabled] = true
+ post[:success_url] = options[:callback_url] if options[:callback_url]
+ post[:failure_url] = options[:callback_url] if options[:callback_url]
+ end
+
+ if options[:three_d_secure]
post[:'3ds'][:eci] = options[:three_d_secure][:eci] if options[:three_d_secure][:eci]
post[:'3ds'][:cryptogram] = options[:three_d_secure][:cavv] if options[:three_d_secure][:cavv]
post[:'3ds'][:version] = options[:three_d_secure][:version] if options[:three_d_secure][:version]
@@ -140,7 +149,7 @@ def add_3ds(post, options)
def commit(action, post, authorization = nil)
begin
- raw_response = ssl_post(url(post, action, authorization), post.to_json, headers)
+ raw_response = (action == :verify_payment ? ssl_get("#{base_url}/payments/#{post}", headers) : ssl_post(url(post, action, authorization), post.to_json, headers))
response = parse(raw_response)
if action == :capture && response.key?('_links')
response['id'] = response['_links']['payment']['href'].split('/')[-1]
@@ -215,7 +224,7 @@ def parse(body)
end
def success_from(response)
- response['response_summary'] == 'Approved' || !response.key?('response_summary') && response.key?('action_id')
+ response['response_summary'] == 'Approved' || response['approved'] == true || !response.key?('response_summary') && response.key?('action_id')
end
def message_from(succeeded, response)
diff --git a/test/unit/gateways/checkout_v2_test.rb b/test/unit/gateways/checkout_v2_test.rb
index c5839c0a494..0855d53da5b 100644
--- a/test/unit/gateways/checkout_v2_test.rb
+++ b/test/unit/gateways/checkout_v2_test.rb
@@ -117,6 +117,37 @@ def test_successful_authorize_and_capture_with_additional_options
assert_success capture
end
+ def test_3ds_passed
+ response = stub_comms do
+ options = {
+ execute_threed: true,
+ callback_url: 'https://www.example.com'
+ }
+ @gateway.authorize(@amount, @credit_card, options)
+ end.check_request do |endpoint, data, headers|
+ assert_match(%r{"success_url"}, data)
+ assert_match(%r{"failure_url"}, data)
+ end.respond_with(successful_authorize_response)
+
+ assert_success response
+ end
+
+ def test_successful_verify_payment
+ response = stub_comms(@gateway, :ssl_request) do
+ @gateway.verify_payment('testValue')
+ end.respond_with(successful_verify_payment_response)
+
+ assert_success response
+ end
+
+ def test_failed_verify_payment
+ response = stub_comms(@gateway, :ssl_request) do
+ @gateway.verify_payment('testValue')
+ end.respond_with(failed_verify_payment_response)
+
+ assert_failure response
+ end
+
def test_successful_authorize_and_capture_with_3ds
response = stub_comms do
options = {
@@ -466,4 +497,16 @@ def error_code_response
}
)
end
+
+ def successful_verify_payment_response
+ %(
+ {"id":"pay_tkvif5mf54eerhd3ysuawfcnt4","requested_on":"2019-08-14T18:13:54Z","source":{"id":"src_lot2ch4ygk3ehi4fugxmk7r2di","type":"card","expiry_month":12,"expiry_year":2020,"name":"Jane Doe","scheme":"Visa","last4":"0907","fingerprint":"E4048195442B0059D73FD47F6E1961A02CD085B0B34B7703CE4A93750DB5A0A1","bin":"457382","avs_check":"S","cvv_check":"Y"},"amount":100,"currency":"USD","payment_type":"Regular","reference":"Dvy8EMaEphrMWolKsLVHcUqPsyx","status":"Authorized","approved":true,"3ds":{"downgraded":false,"enrolled":"Y","authentication_response":"Y","cryptogram":"ce49b5c1-5d3c-4864-bd16-2a8c","xid":"95202312-f034-48b4-b9b2-54254a2b49fb","version":"2.1.0"},"risk":{"flagged":false},"customer":{"id":"cus_zt5pspdtkypuvifj7g6roy7p6y","name":"Jane Doe"},"billing_descriptor":{"name":"","city":"London"},"payment_ip":"127.0.0.1","metadata":{"Udf5":"ActiveMerchant"},"eci":"05","scheme_id":"638284745624527","actions":[{"id":"act_tkvif5mf54eerhd3ysuawfcnt4","type":"Authorization","response_code":"10000","response_summary":"Approved"}],"_links":{"self":{"href":"https://api.sandbox.checkout.com/payments/pay_tkvif5mf54eerhd3ysuawfcnt4"},"actions":{"href":"https://api.sandbox.checkout.com/payments/pay_tkvif5mf54eerhd3ysuawfcnt4/actions"},"capture":{"href":"https://api.sandbox.checkout.com/payments/pay_tkvif5mf54eerhd3ysuawfcnt4/captures"},"void":{"href":"https://api.sandbox.checkout.com/payments/pay_tkvif5mf54eerhd3ysuawfcnt4/voids"}}}
+ )
+ end
+
+ def failed_verify_payment_response
+ %(
+ {"id":"pay_xrwmaqlar73uhjtyoghc7bspa4","requested_on":"2019-08-14T18:32:50Z","source":{"type":"card","expiry_month":12,"expiry_year":2020,"name":"Jane Doe","scheme":"Visa","last4":"7863","fingerprint":"DC20145B78E242C561A892B83CB64471729D7A5063E5A5B341035713B8FDEC92","bin":"453962"},"amount":100,"currency":"USD","payment_type":"Regular","reference":"EuyOZtgt8KI4tolEH8lqxCclWqz","status":"Declined","approved":false,"3ds":{"downgraded":false,"enrolled":"Y","version":"2.1.0"},"risk":{"flagged":false},"customer":{"id":"cus_bb4b7eu35sde7o33fq2xchv7oq","name":"Jane Doe"},"payment_ip":"127.0.0.1","metadata":{"Udf5":"ActiveMerchant"},"_links":{"self":{"href":"https://api.sandbox.checkout.com/payments/pay_xrwmaqlar73uhjtyoghc7bspa4"},"actions":{"href":"https://api.sandbox.checkout.com/payments/pay_xrwmaqlar73uhjtyoghc7bspa4/actions"}}}
+ )
+ end
end
From 0ec7b2f143d734acb61fa69920dc022366ce2381 Mon Sep 17 00:00:00 2001
From: Tanya Jajodia
Date: Mon, 19 Aug 2019 10:08:57 -0600
Subject: [PATCH 0413/2234] Adds new Maestro BINs
Adds additional BINs for Maestro to ensure valid payment methods
pass validation and avoid card errors.
BIN lists from the Binbase and BINDB subscriptions are used as the
reference for the largest, contiguous, non-overlapping range of Maestro
BINs possible from these lists. There are some additional Maestro BINs
in the list that have not been added with this change. Effort to ensure
an up-to-date match for all valid card BINs will be done as part of
EVS-178.
Unit:
4205 tests, 70188 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications
100% passed
Closes #3305
---
CHANGELOG | 1 +
.../billing/credit_card_methods.rb | 18 ++++++++++++++++++
test/unit/credit_card_methods_test.rb | 4 +++-
3 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 4b5d86eb330..6c10a3fbf83 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -18,6 +18,7 @@
* Realex: Re-implement credit as general credit [leila-alderman] #3280
* Braintree Blue: Support for stored credentials [hdeters] #3286
* CardConnect: Move domain from gateway specific to gateway field [hdeters] #3283
+* Adds new Maestro BINs [tanyajajodia] #3305
== Version 1.96.0 (Jul 26, 2019)
* Bluesnap: Omit state codes for unsupported countries [therufs] #3229
diff --git a/lib/active_merchant/billing/credit_card_methods.rb b/lib/active_merchant/billing/credit_card_methods.rb
index 3077be86989..8cf91c5297c 100644
--- a/lib/active_merchant/billing/credit_card_methods.rb
+++ b/lib/active_merchant/billing/credit_card_methods.rb
@@ -66,6 +66,24 @@ module CreditCardMethods
# https://www.mastercard.us/content/dam/mccom/global/documents/mastercard-rules.pdf, page 73
MAESTRO_RANGES = [
+ (561200..561269),
+ (561271..561299),
+ (561320..561356),
+ (581700..581751),
+ (581753..581800),
+ (589998..591259),
+ (591261..596770),
+ (596772..598744),
+ (598746..599999),
+ (600297..600314),
+ (600316..600335),
+ (600337..600362),
+ (600364..600382),
+ (601232..601254),
+ (601256..601276),
+ (601640..601652),
+ (601689..601700),
+ (602011..602050),
(639000..639099),
(670000..679999),
]
diff --git a/test/unit/credit_card_methods_test.rb b/test/unit/credit_card_methods_test.rb
index 1400b603f5d..400dc07c3a7 100644
--- a/test/unit/credit_card_methods_test.rb
+++ b/test/unit/credit_card_methods_test.rb
@@ -9,6 +9,7 @@ class CreditCard
def maestro_card_numbers
%w[
+ 5612590000000000 5817500000000000 5818000000000000
6390000000000000 6390700000000000 6390990000000000
6761999999999999 6763000000000000 6799999999999999
]
@@ -17,7 +18,8 @@ def maestro_card_numbers
def non_maestro_card_numbers
%w[
4999999999999999 5100000000000000 5599999999999999
- 5900000000000000 5999999999999999 7000000000000000
+ 5612709999999999 5817520000000000 5818019999999999
+ 5912600000000000 6000009999999999 7000000000000000
]
end
From 9899f4d52d7cd8ca1cd2c6933359d0b04acedd5b Mon Sep 17 00:00:00 2001
From: Filipe Costa
Date: Thu, 22 Aug 2019 11:26:35 -0400
Subject: [PATCH 0414/2234] Re-add removed changelog entry (#3304)
---
CHANGELOG | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG b/CHANGELOG
index 6c10a3fbf83..1474aeecce3 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -210,6 +210,7 @@
* Forte: Allow void on capture [nfarve] #3059
== Version 1.86.0 (October 26, 2018)
+* UsaEpayTransaction: Support UMcheckformat option for echecks [dtykocki] #3002
* Global Collect: handle internal server errors [molbrown] #3005
* Barclaycard Smartpay: allow third-party payouts for credits [bpollack] #3009
* RuboCop: AlignHash [nfarve] #3004
From 6a666eded7a8327748b8a888e96537c34c9fe30a Mon Sep 17 00:00:00 2001
From: Jason Nappier
Date: Tue, 20 Aug 2019 14:31:47 -0400
Subject: [PATCH 0415/2234] eWAY Rapid: Rework logic for setting the customer
and shipping address fields for the purchase, authorize, store, and update
operations.
- When no address has been provided, default to the name associated with the payment method.
- Fixed a bug in which the email was not set if no address was provided.
- Fixed a bug in which the shipping address phone number was not set.
In addition, some existing failing/erroring tests were updated to pass correctly, and test coverage for the customer and shipping address data logic has been added.
Unit tests:
4228 tests, 70411 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications
100% passed
test/remote/gateways/remote_eway_rapid_test.rb:
28 tests, 155 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
2 pre-existing remote tests have been known to fail at times (perhaps depending on the time of day).
CE-73
---
CHANGELOG | 3 +
.../billing/gateways/eway_rapid.rb | 54 +++-
.../remote/gateways/remote_eway_rapid_test.rb | 212 ++++++++++++++-
test/unit/gateways/eway_rapid_test.rb | 244 +++++++++++++++++-
4 files changed, 493 insertions(+), 20 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 1474aeecce3..eed25bb1b9e 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -4,6 +4,9 @@
* Stripe Payment Intents: Add new gateway [britth] #3290
* Stripe: Send cardholder name and address when creating sources for 3DS 1.0 [jknipp] #3300
* Checkout_v2: Support for native 3DS2.0 [nfarve] #3303
+* eWAY Rapid: If no address is available, default to the name associated with the payment method when setting the Customer fields [jasonxp] #3306
+* eWAY Rapid: Fix a bug in which the email was not set in Customer fields if no address was provided [jasonxp] #3306
+* eWAY Rapid: Support both `phone` and `phone_number` fields under the `shipping_address` option [jasonxp] #3306
== Version 1.97.0 (Aug 15, 2019)
* CyberSource: Add issuer `additionalData` gateway-specific field [jasonxp] #3296
diff --git a/lib/active_merchant/billing/gateways/eway_rapid.rb b/lib/active_merchant/billing/gateways/eway_rapid.rb
index 29d06a837b4..34470c07183 100644
--- a/lib/active_merchant/billing/gateways/eway_rapid.rb
+++ b/lib/active_merchant/billing/gateways/eway_rapid.rb
@@ -51,7 +51,7 @@ def purchase(amount, payment_method, options={})
params = {}
add_metadata(params, options)
add_invoice(params, amount, options)
- add_customer_data(params, options)
+ add_customer_data(params, options, payment_method)
add_credit_card(params, payment_method, options)
params['Method'] = payment_method.respond_to?(:number) ? 'ProcessPayment' : 'TokenPayment'
commit(url_for('Transaction'), params)
@@ -61,7 +61,7 @@ def authorize(amount, payment_method, options={})
params = {}
add_metadata(params, options)
add_invoice(params, amount, options)
- add_customer_data(params, options)
+ add_customer_data(params, options, payment_method)
add_credit_card(params, payment_method, options)
params['Method'] = 'Authorise'
commit(url_for('Authorisation'), params)
@@ -137,7 +137,7 @@ def store(payment_method, options = {})
params = {}
add_metadata(params, options)
add_invoice(params, 0, options)
- add_customer_data(params, options)
+ add_customer_data(params, options, payment_method)
add_credit_card(params, payment_method, options)
params['Method'] = 'CreateTokenCustomer'
commit(url_for('Transaction'), params)
@@ -166,7 +166,7 @@ def update(customer_token, payment_method, options = {})
params = {}
add_metadata(params, options)
add_invoice(params, 0, options)
- add_customer_data(params, options)
+ add_customer_data(params, options, payment_method)
add_credit_card(params, payment_method, options)
add_customer_token(params, customer_token)
params['Method'] = 'UpdateTokenCustomer'
@@ -212,17 +212,48 @@ def add_reference(params, reference)
params['TransactionID'] = reference
end
- def add_customer_data(params, options)
- params['Customer'] ||= {}
- add_address(params['Customer'], (options[:billing_address] || options[:address]), {:email => options[:email]})
- params['ShippingAddress'] = {}
- add_address(params['ShippingAddress'], options[:shipping_address], {:skip_company => true})
+ def add_customer_data(params, options, payment_method = nil)
+ add_customer_fields(params, options, payment_method)
+ add_shipping_fields(params, options)
+ end
+
+ def add_customer_fields(params, options, payment_method)
+ key = 'Customer'
+ params[key] ||= {}
+
+ customer_address = options[:billing_address] || options[:address]
+
+ add_name_and_email(params[key], customer_address, options[:email], payment_method)
+ add_address(params[key], customer_address)
+ end
+
+ def add_shipping_fields(params, options)
+ key = 'ShippingAddress'
+ params[key] = {}
+
+ add_name_and_email(params[key], options[:shipping_address], options[:email])
+ add_address(params[key], options[:shipping_address], {:skip_company => true})
+ end
+
+ def add_name_and_email(params, address, email, payment_method = nil)
+ if address.present?
+ params['FirstName'], params['LastName'] = split_names(address[:name])
+ elsif payment_method_name_available?(payment_method)
+ params['FirstName'] = payment_method.first_name
+ params['LastName'] = payment_method.last_name
+ end
+
+ params['Email'] = email
+ end
+
+ def payment_method_name_available?(payment_method)
+ payment_method.respond_to?(:first_name) && payment_method.respond_to?(:last_name) &&
+ payment_method.first_name.present? && payment_method.last_name.present?
end
def add_address(params, address, options={})
return unless address
- params['FirstName'], params['LastName'] = split_names(address[:name])
params['Title'] = address[:title]
params['CompanyName'] = address[:company] unless options[:skip_company]
params['Street1'] = truncate(address[:address1], 50)
@@ -231,9 +262,8 @@ def add_address(params, address, options={})
params['State'] = address[:state]
params['PostalCode'] = address[:zip]
params['Country'] = address[:country].to_s.downcase
- params['Phone'] = address[:phone]
+ params['Phone'] = address[:phone] || address[:phone_number]
params['Fax'] = address[:fax]
- params['Email'] = options[:email]
end
def add_credit_card(params, credit_card, options)
diff --git a/test/remote/gateways/remote_eway_rapid_test.rb b/test/remote/gateways/remote_eway_rapid_test.rb
index f0c33ba61e8..4feec8d4e6b 100644
--- a/test/remote/gateways/remote_eway_rapid_test.rb
+++ b/test/remote/gateways/remote_eway_rapid_test.rb
@@ -17,10 +17,59 @@ def setup
}
end
- def test_successful_purchase
+ def test_successful_purchase_with_billing_address
response = @gateway.purchase(@amount, @credit_card, @options)
+
+ assert_success response
+ assert_equal 'Transaction Approved Successful', response.message
+
+ customer = response.params['Customer']
+
+ assert_address_match(customer, @options[:billing_address])
+ end
+
+ def test_successful_purchase_with_address
+ @options[:billing_address] = nil
+ @options[:address] = address
+
+ response = @gateway.purchase(@amount, @credit_card, @options)
+
+ assert_success response
+ assert_equal 'Transaction Approved Successful', response.message
+
+ customer = response.params['Customer']
+
+ assert_address_match(customer, @options[:address])
+ end
+
+ def test_successful_purchase_without_address
+ email = 'test@example.com'
+
+ @options[:billing_address] = nil
+ @options[:email] = email
+
+ response = @gateway.purchase(@amount, @credit_card, @options)
+
assert_success response
assert_equal 'Transaction Approved Successful', response.message
+
+ customer = response.params['Customer']
+
+ assert_equal customer['FirstName'], @credit_card.first_name
+ assert_equal customer['LastName'], @credit_card.last_name
+ assert_equal customer['Email'], email
+ end
+
+ def test_successful_purchase_with_shipping_address
+ @options[:shipping_address] = address
+
+ response = @gateway.purchase(@amount, @credit_card, @options)
+
+ assert_success response
+ assert_equal 'Transaction Approved Successful', response.message
+
+ # eWAY Rapid does not include the shipping address in the request response,
+ # so we can only test that the transaction is successful.
end
def test_fully_loaded_purchase
@@ -95,6 +144,61 @@ def test_failed_purchase
assert_equal 'Invalid Payment TotalAmount', response.message
end
+ def test_successful_authorize_with_billing_address
+ response = @gateway.authorize(@amount, @credit_card, @options)
+
+ assert_success response
+ assert_equal 'Transaction Approved Successful', response.message
+
+ customer = response.params['Customer']
+
+ assert_address_match(customer, @options[:billing_address])
+ end
+
+ def test_successful_authorize_with_address
+ @options[:billing_address] = nil
+ @options[:address] = address
+
+ response = @gateway.authorize(@amount, @credit_card, @options)
+
+ assert_success response
+ assert_equal 'Transaction Approved Successful', response.message
+
+ customer = response.params['Customer']
+
+ assert_address_match(customer, @options[:address])
+ end
+
+ def test_successful_authorize_without_address
+ email = 'test@example.com'
+
+ @options[:billing_address] = nil
+ @options[:email] = email
+
+ response = @gateway.authorize(@amount, @credit_card, @options)
+
+ assert_success response
+ assert_equal 'Transaction Approved Successful', response.message
+
+ customer = response.params['Customer']
+
+ assert_equal customer['FirstName'], @credit_card.first_name
+ assert_equal customer['LastName'], @credit_card.last_name
+ assert_equal customer['Email'], email
+ end
+
+ def test_successful_authorize_with_shipping_address
+ @options[:shipping_address] = address
+
+ response = @gateway.authorize(@amount, @credit_card, @options)
+
+ assert_success response
+ assert_equal 'Transaction Approved Successful', response.message
+
+ # eWAY Rapid does not include the shipping address in the request response,
+ # so we can only test that the transaction is successful.
+ end
+
def test_successful_authorize_and_capture
authorize = @gateway.authorize(@amount, @credit_card, @options)
assert_success authorize
@@ -107,7 +211,7 @@ def test_successful_authorize_and_capture
def test_failed_authorize
response = @gateway.authorize(@failed_amount, @credit_card, @options)
assert_failure response
- assert_equal 'Error Failed', response.message
+ assert_equal '', response.message
end
def test_failed_capture
@@ -127,7 +231,7 @@ def test_successful_void
def test_failed_void
response = @gateway.void('bogus')
assert_failure response
- assert_equal 'Invalid Auth Transaction ID for Capture/Void', response.message
+ assert_equal 'Failed', response.message
end
def test_successful_refund
@@ -150,6 +254,22 @@ def test_successful_store
response = @gateway.store(@credit_card, @options)
assert_success response
assert_equal 'Transaction Approved Successful', response.message
+
+ customer = response.params['Customer']
+
+ assert_address_match(customer, @options[:billing_address])
+ end
+
+ def test_successful_store_with_shipping_address
+ @options[:shipping_address] = address
+
+ response = @gateway.store(@credit_card, @options)
+
+ assert_success response
+ assert_equal 'Transaction Approved Successful', response.message
+
+ # eWAY Rapid does not include the shipping address in the request response,
+ # so we can only test that the transaction is successful.
end
def test_failed_store
@@ -160,13 +280,72 @@ def test_failed_store
assert_equal 'Customer CountryCode Required', response.message
end
- def test_successful_update
+ def test_successful_update_with_billing_address
+ response = @gateway.store(@credit_card, @options)
+ assert_success response
+ assert_equal 'Transaction Approved Successful', response.message
+ response = @gateway.update(response.authorization, @credit_card, @options)
+ assert_success response
+ assert_equal 'Transaction Approved Successful', response.message
+
+ customer = response.params['Customer']
+ assert_address_match(customer, @options[:billing_address])
+ end
+
+ def test_successful_update_with_address
+ @options[:billing_address] = nil
+ @options[:address] = address
+
+ response = @gateway.store(@credit_card, @options)
+ assert_success response
+ assert_equal 'Transaction Approved Successful', response.message
+
+ response = @gateway.update(response.authorization, @credit_card, @options)
+
+ assert_success response
+ assert_equal 'Transaction Approved Successful', response.message
+
+ customer = response.params['Customer']
+
+ assert_address_match(customer, @options[:address])
+ end
+
+ def test_successful_update_without_address
+ email = 'test@example.com'
+ @options[:email] = email
+
response = @gateway.store(@credit_card, @options)
assert_success response
assert_equal 'Transaction Approved Successful', response.message
+
+ @options[:billing_address] = nil
+
response = @gateway.update(response.authorization, @credit_card, @options)
+
assert_success response
assert_equal 'Transaction Approved Successful', response.message
+
+ customer = response.params['Customer']
+
+ assert_equal customer['FirstName'], @credit_card.first_name
+ assert_equal customer['LastName'], @credit_card.last_name
+ assert_equal customer['Email'], email
+ end
+
+ def test_successful_update_with_shipping_address
+ @options[:shipping_address] = address
+
+ response = @gateway.store(@credit_card, @options)
+ assert_success response
+ assert_equal 'Transaction Approved Successful', response.message
+
+ response = @gateway.update(response.authorization, @credit_card, @options)
+
+ assert_success response
+ assert_equal 'Transaction Approved Successful', response.message
+
+ # eWAY Rapid does not include the shipping address in the request response,
+ # so we can only test that the transaction is successful.
end
def test_successful_store_purchase
@@ -190,12 +369,31 @@ def test_invalid_login
end
def test_transcript_scrubbing
+ credit_card_success = credit_card('4444333322221111', verification_value: 976225)
+
transcript = capture_transcript(@gateway) do
- @gateway.purchase(100, @credit_card_success, @params)
+ @gateway.purchase(100, credit_card_success, {})
end
+
clean_transcript = @gateway.scrub(transcript)
- assert_scrubbed(@credit_card_success.number, clean_transcript)
- assert_scrubbed(@credit_card_success.verification_value.to_s, clean_transcript)
+ assert_scrubbed(credit_card_success.number, clean_transcript)
+ assert_scrubbed(credit_card_success.verification_value.to_s, clean_transcript)
+ end
+
+ private
+
+ def assert_address_match(customer, address)
+ assert_equal customer['FirstName'], address[:name].split[0]
+ assert_equal customer['LastName'], address[:name].split[1]
+ assert_equal customer['CompanyName'], address[:company]
+ assert_equal customer['Street1'], address[:address1]
+ assert_equal customer['Street2'], address[:address2]
+ assert_equal customer['City'], address[:city]
+ assert_equal customer['State'], address[:state]
+ assert_equal customer['PostalCode'], address[:zip]
+ assert_equal customer['Country'], address[:country].to_s.downcase
+ assert_equal customer['Phone'], address[:phone]
+ assert_equal customer['Fax'], address[:fax]
end
end
diff --git a/test/unit/gateways/eway_rapid_test.rb b/test/unit/gateways/eway_rapid_test.rb
index 15788011e99..790b839228e 100644
--- a/test/unit/gateways/eway_rapid_test.rb
+++ b/test/unit/gateways/eway_rapid_test.rb
@@ -12,6 +12,36 @@ def setup
@credit_card = credit_card
@amount = 100
+
+ @address = {
+ name: 'John Smith',
+ title: 'Test Title',
+ company: 'Test Company, Inc.',
+ address1: '14701 Test Road',
+ address2: 'Test Unit 100',
+ city: 'TestCity',
+ state: 'NC',
+ zip: '27517',
+ country: 'USA',
+ phone: '555-555-1000',
+ fax: '555-555-2000'
+ }
+
+ @shipping_address = {
+ name: 'John Smith',
+ title: 'Test Title',
+ company: 'Test Company, Inc.',
+ address1: '14701 Test Road',
+ address2: 'Test Unit 100',
+ city: 'TestCity',
+ state: 'NC',
+ zip: '27517',
+ country: 'USA',
+ phone_number: '555-555-1000',
+ fax: '555-555-2000'
+ }
+
+ @email = 'john.smith@example.com'
end
def test_successful_purchase
@@ -25,6 +55,55 @@ def test_successful_purchase
assert response.test?
end
+ def test_purchase_passes_customer_data_from_payment_method_when_no_address_is_provided
+ stub_comms do
+ @gateway.purchase(@amount, @credit_card, { email: @email })
+ end.check_request do |endpoint, data, headers|
+ assert_customer_data_passed(
+ data,
+ @credit_card.first_name,
+ @credit_card.last_name,
+ @email
+ )
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_purchase_passes_customer_data_from_billing_address
+ stub_comms do
+ @gateway.purchase(@amount, @credit_card, { billing_address: @address, email: @email })
+ end.check_request do |endpoint, data, headers|
+ assert_customer_data_passed(
+ data,
+ @address[:name].split[0],
+ @address[:name].split[1],
+ @email,
+ @address
+ )
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_purchase_passes_customer_data_from_address
+ stub_comms do
+ @gateway.purchase(@amount, @credit_card, { address: @address, email: @email })
+ end.check_request do |endpoint, data, headers|
+ assert_customer_data_passed(
+ data,
+ @address[:name].split[0],
+ @address[:name].split[1],
+ @email,
+ @address
+ )
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_purchase_passes_shipping_data
+ stub_comms do
+ @gateway.purchase(@amount, @credit_card, { shipping_address: @shipping_address, email: @email })
+ end.check_request do |endpoint, data, headers|
+ assert_shipping_data_passed(data, @shipping_address, @email)
+ end.respond_with(successful_purchase_response)
+ end
+
def test_localized_currency
stub_comms do
@gateway.purchase(100, @credit_card, :currency => 'CAD')
@@ -150,7 +229,7 @@ def test_purchase_with_all_options
assert_match(%r{"Country":"us"}, data)
assert_match(%r{"Phone":"1115555555"}, data)
assert_match(%r{"Fax":"1115556666"}, data)
- assert_match(%r{"Email":null}, data)
+ assert_match(%r{"Email":"jim@example\.com"}, data)
end.respond_with(successful_purchase_response)
assert_success response
@@ -203,6 +282,55 @@ def test_successful_authorize
assert_equal 10774952, response.authorization
end
+ def test_authorize_passes_customer_data_from_payment_method_when_no_address_is_provided
+ stub_comms do
+ @gateway.authorize(@amount, @credit_card, { email: @email })
+ end.check_request do |endpoint, data, headers|
+ assert_customer_data_passed(
+ data,
+ @credit_card.first_name,
+ @credit_card.last_name,
+ @email
+ )
+ end.respond_with(successful_authorize_response)
+ end
+
+ def test_authorize_passes_customer_data_from_billing_address
+ stub_comms do
+ @gateway.authorize(@amount, @credit_card, { billing_address: @address, email: @email })
+ end.check_request do |endpoint, data, headers|
+ assert_customer_data_passed(
+ data,
+ @address[:name].split[0],
+ @address[:name].split[1],
+ @email,
+ @address
+ )
+ end.respond_with(successful_authorize_response)
+ end
+
+ def test_authorize_passes_customer_data_from_address
+ stub_comms do
+ @gateway.authorize(@amount, @credit_card, { address: @address, email: @email })
+ end.check_request do |endpoint, data, headers|
+ assert_customer_data_passed(
+ data,
+ @address[:name].split[0],
+ @address[:name].split[1],
+ @email,
+ @address
+ )
+ end.respond_with(successful_authorize_response)
+ end
+
+ def test_authorize_passes_shipping_data
+ stub_comms do
+ @gateway.authorize(@amount, @credit_card, { shipping_address: @shipping_address, email: @email })
+ end.check_request do |endpoint, data, headers|
+ assert_shipping_data_passed(data, @shipping_address, @email)
+ end.respond_with(successful_authorize_response)
+ end
+
def test_successful_capture
response = stub_comms do
@gateway.capture(nil, 'auth')
@@ -278,6 +406,31 @@ def test_successful_store
assert response.test?
end
+ def test_store_passes_customer_data_from_billing_address
+ stub_comms do
+ @gateway.store(@credit_card, { billing_address: @address, email: @email })
+ end.check_request do |endpoint, data, headers|
+ assert_customer_data_passed(
+ data,
+ @address[:name].split[0],
+ @address[:name].split[1],
+ @email,
+ @address
+ )
+ end.respond_with(successful_store_response)
+ end
+
+ def test_store_passes_shipping_data
+ stub_comms do
+ @gateway.store(
+ @credit_card,
+ { shipping_address: @shipping_address, billing_address: @address, email: @email }
+ )
+ end.check_request do |endpoint, data, headers|
+ assert_shipping_data_passed(data, @shipping_address, @email)
+ end.respond_with(successful_store_response)
+ end
+
def test_failed_store
response = stub_comms do
@gateway.store(@credit_card, :billing_address => {})
@@ -302,6 +455,55 @@ def test_successful_update
assert response.test?
end
+ def test_update_passes_customer_data_from_payment_method_when_no_address_is_provided
+ stub_comms do
+ @gateway.update('token', @credit_card, { email: @email })
+ end.check_request do |endpoint, data, headers|
+ assert_customer_data_passed(
+ data,
+ @credit_card.first_name,
+ @credit_card.last_name,
+ @email
+ )
+ end.respond_with(successful_update_response)
+ end
+
+ def test_update_passes_customer_data_from_billing_address
+ stub_comms do
+ @gateway.update('token', @credit_card, { billing_address: @address, email: @email })
+ end.check_request do |endpoint, data, headers|
+ assert_customer_data_passed(
+ data,
+ @address[:name].split[0],
+ @address[:name].split[1],
+ @email,
+ @address
+ )
+ end.respond_with(successful_update_response)
+ end
+
+ def test_update_passes_customer_data_from_address
+ stub_comms do
+ @gateway.update('token', @credit_card, { address: @address, email: @email })
+ end.check_request do |endpoint, data, headers|
+ assert_customer_data_passed(
+ data,
+ @address[:name].split[0],
+ @address[:name].split[1],
+ @email,
+ @address
+ )
+ end.respond_with(successful_update_response)
+ end
+
+ def test_update_passes_shipping_data
+ stub_comms do
+ @gateway.update('token', @credit_card, { shipping_address: @shipping_address, email: @email })
+ end.check_request do |endpoint, data, headers|
+ assert_shipping_data_passed(data, @shipping_address, @email)
+ end.respond_with(successful_update_response)
+ end
+
def test_successful_refund
response = stub_comms do
@gateway.refund(@amount, '1234567')
@@ -375,6 +577,46 @@ def test_transcript_scrubbing
private
+ def assert_customer_data_passed(data, first_name, last_name, email, address = nil)
+ parsed_data = JSON.parse(data)
+ customer = parsed_data['Customer']
+
+ assert_equal customer['FirstName'], first_name
+ assert_equal customer['LastName'], last_name
+ assert_equal customer['Email'], email
+
+ if address
+ assert_equal customer['Title'], address[:title]
+ assert_equal customer['CompanyName'], address[:company]
+ assert_equal customer['Street1'], address[:address1]
+ assert_equal customer['Street2'], address[:address2]
+ assert_equal customer['City'], address[:city]
+ assert_equal customer['State'], address[:state]
+ assert_equal customer['PostalCode'], address[:zip]
+ assert_equal customer['Country'], address[:country].downcase
+ assert_equal customer['Phone'], address[:phone]
+ assert_equal customer['Fax'], address[:fax]
+ end
+ end
+
+ def assert_shipping_data_passed(data, address, email)
+ parsed_data = JSON.parse(data)
+ shipping = parsed_data['ShippingAddress']
+
+ assert_equal shipping['FirstName'], address[:name].split[0]
+ assert_equal shipping['LastName'], address[:name].split[1]
+ assert_equal shipping['Title'], address[:title]
+ assert_equal shipping['Street1'], address[:address1]
+ assert_equal shipping['Street2'], address[:address2]
+ assert_equal shipping['City'], address[:city]
+ assert_equal shipping['State'], address[:state]
+ assert_equal shipping['PostalCode'], address[:zip]
+ assert_equal shipping['Country'], address[:country].downcase
+ assert_equal shipping['Phone'], address[:phone_number]
+ assert_equal shipping['Fax'], address[:fax]
+ assert_equal shipping['Email'], email
+ end
+
def successful_purchase_response(options = {})
verification_status = options[:verification_status] || 0
verification_status = %Q{"#{verification_status}"} if verification_status.is_a? String
From f9e7abfeb4ce4ba0158a87bd577f2cf426ba381b Mon Sep 17 00:00:00 2001
From: Jason Nappier
Date: Thu, 22 Aug 2019 17:07:02 -0400
Subject: [PATCH 0416/2234] PayU Latam: Add support for merchantBuyerId
Unit tests:
4229 tests, 70420 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications
100% passed
test/remote/gateways/remote_payu_latam_test.rb:
30 tests, 72 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
CE-95
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/payu_latam.rb | 2 ++
test/remote/gateways/remote_payu_latam_test.rb | 4 +++-
test/unit/gateways/payu_latam_test.rb | 14 ++++++++++++--
4 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index eed25bb1b9e..d523da46455 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -7,6 +7,7 @@
* eWAY Rapid: If no address is available, default to the name associated with the payment method when setting the Customer fields [jasonxp] #3306
* eWAY Rapid: Fix a bug in which the email was not set in Customer fields if no address was provided [jasonxp] #3306
* eWAY Rapid: Support both `phone` and `phone_number` fields under the `shipping_address` option [jasonxp] #3306
+* PayU Latam: Add support for the `merchant_buyer_id` field in the `options` and `buyer` hashes [jasonxp] #3308
== Version 1.97.0 (Aug 15, 2019)
* CyberSource: Add issuer `additionalData` gateway-specific field [jasonxp] #3296
diff --git a/lib/active_merchant/billing/gateways/payu_latam.rb b/lib/active_merchant/billing/gateways/payu_latam.rb
index c4f00bc1822..56c7e64f0d4 100644
--- a/lib/active_merchant/billing/gateways/payu_latam.rb
+++ b/lib/active_merchant/billing/gateways/payu_latam.rb
@@ -196,6 +196,7 @@ def add_buyer(post, payment_method, options)
buyer[:fullName] = buyer_hash[:name]
buyer[:dniNumber] = buyer_hash[:dni_number]
buyer[:dniType] = buyer_hash[:dni_type]
+ buyer[:merchantBuyerId] = buyer_hash[:merchant_buyer_id]
buyer[:cnpj] = buyer_hash[:cnpj] if @options[:payment_country] == 'BR'
buyer[:emailAddress] = buyer_hash[:email]
buyer[:contactPhone] = (options[:billing_address][:phone] if options[:billing_address]) || (options[:shipping_address][:phone] if options[:shipping_address]) || ''
@@ -204,6 +205,7 @@ def add_buyer(post, payment_method, options)
buyer[:fullName] = payment_method.name.strip
buyer[:dniNumber] = options[:dni_number]
buyer[:dniType] = options[:dni_type]
+ buyer[:merchantBuyerId] = options[:merchant_buyer_id]
buyer[:cnpj] = options[:cnpj] if @options[:payment_country] == 'BR'
buyer[:emailAddress] = options[:email]
buyer[:contactPhone] = (options[:billing_address][:phone] if options[:billing_address]) || (options[:shipping_address][:phone] if options[:shipping_address]) || ''
diff --git a/test/remote/gateways/remote_payu_latam_test.rb b/test/remote/gateways/remote_payu_latam_test.rb
index 9dff1810ba6..e9f02d78ddc 100644
--- a/test/remote/gateways/remote_payu_latam_test.rb
+++ b/test/remote/gateways/remote_payu_latam_test.rb
@@ -12,6 +12,7 @@ def setup
@options = {
dni_number: '5415668464654',
+ merchant_buyer_id: '1',
currency: 'ARS',
order_id: generate_unique_id,
description: 'Active Merchant Transaction',
@@ -64,7 +65,7 @@ def test_successful_purchase_with_specified_language
assert response.test?
end
- def test_successul_purchase_with_buyer
+ def test_successful_purchase_with_buyer
gateway = PayuLatamGateway.new(fixtures(:payu_latam).update(:account_id => '512327', payment_country: 'BR'))
options_buyer = {
@@ -91,6 +92,7 @@ def test_successul_purchase_with_buyer
name: 'Jorge Borges',
dni_number: '5415668464123',
dni_type: 'TI',
+ merchant_buyer_id: '2',
cnpj: '32593371000110',
email: 'axaxaxas@mlo.org'
}
diff --git a/test/unit/gateways/payu_latam_test.rb b/test/unit/gateways/payu_latam_test.rb
index 68e76b9ef2e..d2c0dbf28c5 100644
--- a/test/unit/gateways/payu_latam_test.rb
+++ b/test/unit/gateways/payu_latam_test.rb
@@ -16,6 +16,7 @@ def setup
@options = {
dni_number: '5415668464654',
dni_type: 'TI',
+ merchant_buyer_id: '1',
currency: 'ARS',
order_id: generate_unique_id,
description: 'Active Merchant Transaction',
@@ -147,6 +148,14 @@ def test_successful_purchase_with_dni_number
end.respond_with(successful_purchase_response)
end
+ def test_successful_purchase_with_merchant_buyer_id
+ stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options)
+ end.check_request do |endpoint, data, headers|
+ assert_match(/"merchantBuyerId":"1"/, data)
+ end.respond_with(successful_purchase_response)
+ end
+
def test_verify_good_credentials
@gateway.expects(:ssl_post).returns(credentials_are_legit_response)
assert @gateway.verify_credentials
@@ -237,6 +246,7 @@ def test_partial_buyer_hash_info
buyer: {
name: 'Jorge Borges',
dni_number: '5415668464456',
+ merchant_buyer_id: '1',
email: 'axaxaxas@mlo.org'
}
}
@@ -244,7 +254,7 @@ def test_partial_buyer_hash_info
stub_comms do
@gateway.purchase(@amount, @credit_card, @options.update(options_buyer))
end.check_request do |endpoint, data, headers|
- assert_match(/\"buyer\":{\"fullName\":\"Jorge Borges\",\"dniNumber\":\"5415668464456\",\"dniType\":null,\"emailAddress\":\"axaxaxas@mlo.org\",\"contactPhone\":\"7563126\",\"shippingAddress\":{\"street1\":\"Calle 200\",\"street2\":\"N107\",\"city\":\"Sao Paulo\",\"state\":\"SP\",\"country\":\"BR\",\"postalCode\":\"01019-030\",\"phone\":\"\(11\)756312345\"}}/, data)
+ assert_match(/\"buyer\":{\"fullName\":\"Jorge Borges\",\"dniNumber\":\"5415668464456\",\"dniType\":null,\"merchantBuyerId\":\"1\",\"emailAddress\":\"axaxaxas@mlo.org\",\"contactPhone\":\"7563126\",\"shippingAddress\":{\"street1\":\"Calle 200\",\"street2\":\"N107\",\"city\":\"Sao Paulo\",\"state\":\"SP\",\"country\":\"BR\",\"postalCode\":\"01019-030\",\"phone\":\"\(11\)756312345\"}}/, data)
end.respond_with(successful_purchase_response)
end
@@ -252,7 +262,7 @@ def test_buyer_fields_default_to_payer
stub_comms do
@gateway.purchase(@amount, @credit_card, @options)
end.check_request do |endpoint, data, headers|
- assert_match(/\"buyer\":{\"fullName\":\"APPROVED\",\"dniNumber\":\"5415668464654\",\"dniType\":\"TI\",\"emailAddress\":\"username@domain.com\",\"contactPhone\":\"7563126\"/, data)
+ assert_match(/\"buyer\":{\"fullName\":\"APPROVED\",\"dniNumber\":\"5415668464654\",\"dniType\":\"TI\",\"merchantBuyerId\":\"1\",\"emailAddress\":\"username@domain.com\",\"contactPhone\":\"7563126\"/, data)
end.respond_with(successful_purchase_response)
end
From 45d0c37280626e8805a6514174a168f5cf1f3f0c Mon Sep 17 00:00:00 2001
From: David Perry
Date: Mon, 26 Aug 2019 16:14:14 -0400
Subject: [PATCH 0417/2234] Update Braintree Gem
Update to latest gem version to support 3DS2 fields.
https://github.com/braintree/braintree_ruby/blob/master/CHANGELOG.md
Closes #3311
Unit:
6 tests, 6 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Blue Remote:
79 tests, 435 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Blue Unit:
73 tests, 174 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Orange Remote:
21 tests, 91 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Orange Unit:
18 tests, 69 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
Gemfile | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index d523da46455..d92a08d1b13 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -186,6 +186,7 @@
* Payeezy: Add `stored_credentials` [nfarve] #3083
* Fix CVC validation for 0 length CVC [filipebarcos] #3082
* NMI: Supports vendor_id and processor_id fields [molbrown] #3085
+* Update Braintree Gem [curiousepic] #3311
== Version 1.88.0 (November 30, 2018)
* Added ActiveSupport/Rails master support [Edouard-chin] #3065
diff --git a/Gemfile b/Gemfile
index 19c64a756b1..fc9791f2719 100644
--- a/Gemfile
+++ b/Gemfile
@@ -6,6 +6,6 @@ gem 'rubocop', '~> 0.60.0', require: false
group :test, :remote_test do
# gateway-specific dependencies, keeping these gems out of the gemspec
- gem 'braintree', '>= 2.93.0'
+ gem 'braintree', '>= 2.98.0'
gem 'mechanize'
end
From 2eae870afb9f397d0af6595b48e6002e19730d6b Mon Sep 17 00:00:00 2001
From: Chris Kruger
Date: Thu, 29 Aug 2019 10:37:24 +0800
Subject: [PATCH 0418/2234] Fat Zebra: Send metadata for purchase and authorize
Include metadata with purchase and authorize requests.
Unit:
18 tests, 95 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote: (1 unrelated failure)
23 tests, 82 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
95.6522% passed
closes #3101
---
CHANGELOG | 1 +
.../billing/gateways/fat_zebra.rb | 6 ++
test/remote/gateways/remote_fat_zebra_test.rb | 7 ++
test/unit/gateways/fat_zebra_test.rb | 94 +++++++++++++++++--
4 files changed, 100 insertions(+), 8 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index d92a08d1b13..f9433f26018 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -8,6 +8,7 @@
* eWAY Rapid: Fix a bug in which the email was not set in Customer fields if no address was provided [jasonxp] #3306
* eWAY Rapid: Support both `phone` and `phone_number` fields under the `shipping_address` option [jasonxp] #3306
* PayU Latam: Add support for the `merchant_buyer_id` field in the `options` and `buyer` hashes [jasonxp] #3308
+* Fat Zebra: Send metadata for purchase and authorize [montdidier] #3101
== Version 1.97.0 (Aug 15, 2019)
* CyberSource: Add issuer `additionalData` gateway-specific field [jasonxp] #3296
diff --git a/lib/active_merchant/billing/gateways/fat_zebra.rb b/lib/active_merchant/billing/gateways/fat_zebra.rb
index 7a37c767304..9903e010a99 100644
--- a/lib/active_merchant/billing/gateways/fat_zebra.rb
+++ b/lib/active_merchant/billing/gateways/fat_zebra.rb
@@ -27,6 +27,7 @@ def purchase(money, creditcard, options = {})
add_extra_options(post, options)
add_order_id(post, options)
add_ip(post, options)
+ add_metadata(post, options)
commit(:post, 'purchases', post)
end
@@ -39,6 +40,7 @@ def authorize(money, creditcard, options = {})
add_extra_options(post, options)
add_order_id(post, options)
add_ip(post, options)
+ add_metadata(post, options)
post[:capture] = false
@@ -138,6 +140,10 @@ def add_ip(post, options)
post[:customer_ip] = options[:ip] || '127.0.0.1'
end
+ def add_metadata(post, options)
+ post[:metadata] = options.fetch(:metadata, {})
+ end
+
def commit(method, uri, parameters=nil)
response = begin
parse(ssl_request(method, get_url(uri), parameters.to_json, headers))
diff --git a/test/remote/gateways/remote_fat_zebra_test.rb b/test/remote/gateways/remote_fat_zebra_test.rb
index fa0ad80219b..28943103a33 100644
--- a/test/remote/gateways/remote_fat_zebra_test.rb
+++ b/test/remote/gateways/remote_fat_zebra_test.rb
@@ -151,6 +151,13 @@ def test_successful_purchase_with_descriptor
assert_equal 'Approved', response.message
end
+ def test_successful_purchase_with_metadata
+ assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:metadata => { :description => 'Invoice #1234356' }))
+ assert_success response
+ assert_equal 'Approved', response.message
+ assert_equal 'Invoice #1234356', response.params['response']['metadata']['description']
+ end
+
def test_successful_purchase_with_3DS_information
assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:cavv => 'MDRjN2MxZTAxYjllNTBkNmM2MTA=', :xid => 'MGVmMmNlMzI4NjAyOWU2ZDgwNTQ=', :sli => '05'))
assert_success response
diff --git a/test/unit/gateways/fat_zebra_test.rb b/test/unit/gateways/fat_zebra_test.rb
index 4b319c1ce18..2bd96c1c19f 100644
--- a/test/unit/gateways/fat_zebra_test.rb
+++ b/test/unit/gateways/fat_zebra_test.rb
@@ -29,6 +29,18 @@ def test_successful_purchase
assert response.test?
end
+ def test_successful_purchase_with_metadata
+ @gateway.expects(:ssl_request).with { |method, url, body, headers|
+ body.match '"metadata":{"foo":"bar"}'
+ }.returns(successful_purchase_response_with_metadata)
+
+ assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:metadata => { 'foo' => 'bar' }))
+ assert_success response
+
+ assert_equal '001-P-12345AA|purchases', response.authorization
+ assert response.test?
+ end
+
def test_successful_purchase_with_token
@gateway.expects(:ssl_request).with { |method, url, body, headers|
body.match '"card_token":"e1q7dbj2"'
@@ -242,16 +254,61 @@ def successful_purchase_response
{
:successful => true,
:response => {
- :authorization => '55355',
+ :authorization => 55355,
:id => '001-P-12345AA',
:card_number => 'XXXXXXXXXXXX1111',
:card_holder => 'John Smith',
:card_expiry => '10/2011',
:card_token => 'a1bhj98j',
:amount => 349,
+ :decimal_amount => 3.49,
:successful => true,
+ :message => 'Approved',
:reference => 'ABC123',
+ :currency => 'AUD',
+ :transaction_id => '001-P-12345AA',
+ :settlement_date => '2011-07-01',
+ :transaction_date => '2011-07-01T12:00:00+11:00',
+ :response_code => '08',
+ :captured => true,
+ :captured_amount => 349,
+ :rrn => '000000000000',
+ :cvv_match => 'U',
+ :metadata => {
+ },
+ },
+ :test => true,
+ :errors => []
+ }.to_json
+ end
+
+ def successful_purchase_response_with_metadata
+ {
+ :successful => true,
+ :response => {
+ :authorization => 55355,
+ :id => '001-P-12345AA',
+ :card_number => 'XXXXXXXXXXXX1111',
+ :card_holder => 'John Smith',
+ :card_expiry => '2011-10-31',
+ :card_token => 'a1bhj98j',
+ :amount => 349,
+ :decimal_amount => 3.49,
+ :successful => true,
:message => 'Approved',
+ :reference => 'ABC123',
+ :currency => 'AUD',
+ :transaction_id => '001-P-12345AA',
+ :settlement_date => '2011-07-01',
+ :transaction_date => '2011-07-01T12:00:00+11:00',
+ :response_code => '08',
+ :captured => true,
+ :captured_amount => 349,
+ :rrn => '000000000000',
+ :cvv_match => 'U',
+ :metadata => {
+ 'foo' => 'bar',
+ },
},
:test => true,
:errors => []
@@ -262,15 +319,28 @@ def declined_purchase_response
{
:successful => true,
:response => {
- :authorization_id => nil,
- :id => nil,
+ :authorization => 0,
+ :id => '001-P-12345AB',
:card_number => 'XXXXXXXXXXXX1111',
:card_holder => 'John Smith',
:card_expiry => '10/2011',
:amount => 100,
:authorized => false,
:reference => 'ABC123',
+ :decimal_amount => 1.0,
+ :successful => false,
:message => 'Card Declined - check with issuer',
+ :currency => 'AUD',
+ :transaction_id => '001-P-12345AB',
+ :settlement_date => nil,
+ :transaction_date => '2011-07-01T12:00:00+11:00',
+ :response_code => '01',
+ :captured => false,
+ :captured_amount => 0,
+ :rrn => '000000000001',
+ :cvv_match => 'U',
+ :metadata => {
+ }
},
:test => true,
:errors => []
@@ -281,20 +351,28 @@ def successful_refund_response
{
:successful => true,
:response => {
- :authorization => '1339973263',
+ :authorization => 1339973263,
:id => '003-R-7MNIUMY6',
- :amount => -10,
+ :amount => 10,
:refunded => 'Approved',
- :message => '08 Approved',
+ :message => 'Approved',
:card_holder => 'Harry Smith',
:card_number => 'XXXXXXXXXXXX4444',
:card_expiry => '2013-05-31',
:card_type => 'MasterCard',
:transaction_id => '003-R-7MNIUMY6',
- :successful => true
+ :reference => '18280',
+ :currency => 'USD',
+ :successful => true,
+ :transaction_date => '2013-07-01T12:00:00+11:00',
+ :response_code => '08',
+ :settlement_date => '2013-07-01',
+ :metadata => {
+ },
+ :standalone => false,
+ :rrn => '000000000002',
},
:errors => [
-
],
:test => true
}.to_json
From faa6ed68901def236a338cad48a5d0a34468e776 Mon Sep 17 00:00:00 2001
From: Jason Nappier
Date: Mon, 26 Aug 2019 21:04:40 -0400
Subject: [PATCH 0419/2234] Support custom fields for TrustCommerce
Also fix some tests that previously failed.
Unit:
4236 tests, 70441 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications
100% passed
Remote:
17 tests, 67 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
CE-96
---
CHANGELOG | 1 +
.../billing/gateways/trust_commerce.rb | 24 +++-
.../gateways/remote_trust_commerce_test.rb | 48 ++++++--
test/unit/gateways/trust_commerce_test.rb | 103 ++++++++++++++++++
4 files changed, 165 insertions(+), 11 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index f9433f26018..408aed728f0 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -9,6 +9,7 @@
* eWAY Rapid: Support both `phone` and `phone_number` fields under the `shipping_address` option [jasonxp] #3306
* PayU Latam: Add support for the `merchant_buyer_id` field in the `options` and `buyer` hashes [jasonxp] #3308
* Fat Zebra: Send metadata for purchase and authorize [montdidier] #3101
+* TrustCommerce: Add support for custom fields [jasonxp] #3313
== Version 1.97.0 (Aug 15, 2019)
* CyberSource: Add issuer `additionalData` gateway-specific field [jasonxp] #3296
diff --git a/lib/active_merchant/billing/gateways/trust_commerce.rb b/lib/active_merchant/billing/gateways/trust_commerce.rb
index d0e2e546039..3018d9d1690 100644
--- a/lib/active_merchant/billing/gateways/trust_commerce.rb
+++ b/lib/active_merchant/billing/gateways/trust_commerce.rb
@@ -159,6 +159,8 @@ def authorize(money, creditcard_or_billing_id, options = {})
add_customer_data(parameters, options)
add_payment_source(parameters, creditcard_or_billing_id)
add_addresses(parameters, options)
+ add_custom_fields(parameters, options)
+
commit('preauth', parameters)
end
@@ -174,6 +176,8 @@ def purchase(money, creditcard_or_billing_id, options = {})
add_customer_data(parameters, options)
add_payment_source(parameters, creditcard_or_billing_id)
add_addresses(parameters, options)
+ add_custom_fields(parameters, options)
+
commit('sale', parameters)
end
@@ -187,6 +191,7 @@ def capture(money, authorization, options = {})
:transid => transaction_id,
}
add_aggregator(parameters, options)
+ add_custom_fields(parameters, options)
commit('postauth', parameters)
end
@@ -195,11 +200,14 @@ def capture(money, authorization, options = {})
# that you want to refund, and a TC transid for the transaction that you are refunding.
def refund(money, identification, options = {})
transaction_id, _ = split_authorization(identification)
+
parameters = {
:amount => amount(money),
:transid => transaction_id
}
+
add_aggregator(parameters, options)
+ add_custom_fields(parameters, options)
commit('credit', parameters)
end
@@ -233,7 +241,9 @@ def void(authorization, options = {})
parameters = {
:transid => transaction_id,
}
+
add_aggregator(parameters, options)
+ add_custom_fields(parameters, options)
commit(action, parameters)
end
@@ -294,6 +304,8 @@ def store(creditcard, options = {})
add_creditcard(parameters, creditcard)
add_addresses(parameters, options)
+ add_custom_fields(parameters, options)
+
commit('store', parameters)
end
@@ -304,6 +316,8 @@ def unstore(identification, options = {})
:billingid => identification,
}
+ add_custom_fields(parameters, options)
+
commit('unstore', parameters)
end
@@ -321,6 +335,12 @@ def scrub(transcript)
private
+ def add_custom_fields(params, options)
+ options[:custom_fields]&.each do |key, value|
+ params[key.to_sym] = value
+ end
+ end
+
def add_aggregator(params, options)
if @options[:aggregator_id] || application_id != Gateway.application_id
params[:aggregators] = 1
@@ -419,7 +439,7 @@ def commit(action, parameters)
TCLink.send(parameters)
else
parse(ssl_post(self.live_url, post_data(parameters)))
- end
+ end
# to be considered successful, transaction status must be either "approved" or "accepted"
success = SUCCESS_TYPES.include?(data['status'])
@@ -463,7 +483,7 @@ def authorization_from(action, data)
end
def split_authorization(authorization)
- authorization.split('|')
+ authorization&.split('|')
end
end
end
diff --git a/test/remote/gateways/remote_trust_commerce_test.rb b/test/remote/gateways/remote_trust_commerce_test.rb
index 04d419b0a56..9625597ffc1 100644
--- a/test/remote/gateways/remote_trust_commerce_test.rb
+++ b/test/remote/gateways/remote_trust_commerce_test.rb
@@ -5,6 +5,7 @@ def setup
@gateway = TrustCommerceGateway.new(fixtures(:trust_commerce))
@credit_card = credit_card('4111111111111111')
+ @declined_credit_card = credit_card('4111111111111112')
@check = check({account_number: 55544433221, routing_number: 789456124})
@amount = 100
@@ -28,12 +29,21 @@ def setup
:zip => '94062'
}
+ # The Trust Commerce API does not return anything different when custom fields are present.
+ # To confirm that the field values are being stored with the transactions, add a custom
+ # field in your account in the Vault UI, then examine the transactions after running the
+ # test suite.
+ custom_fields = {
+ 'customfield1' => 'test1'
+ }
+
@options = {
:ip => '10.10.10.10',
:order_id => '#1000.1',
:email => 'cody@example.com',
:billing_address => @valid_address,
- :shipping_address => @valid_address
+ :shipping_address => @valid_address,
+ :custom_fields => custom_fields
}
end
@@ -158,26 +168,38 @@ def test_successful_check_refund
assert_success response
end
- def test_store_failure
+ def test_successful_store
assert response = @gateway.store(@credit_card)
assert_equal Response, response.class
- assert_match %r{The merchant can't accept data passed in this field}, response.message
- assert_failure response
+ assert_equal 'approved', response.params['status']
+ assert_match %r{The transaction was successful}, response.message
+ end
+
+ def test_failed_store
+ assert response = @gateway.store(@declined_credit_card)
+
+ assert_bad_data_response(response)
end
def test_unstore_failure
- assert response = @gateway.unstore('testme')
+ assert response = @gateway.unstore('does-not-exist')
- assert_match %r{The merchant can't accept data passed in this field}, response.message
+ assert_match %r{A field was longer or shorter than the server allows}, response.message
assert_failure response
end
- def test_recurring_failure
+ def test_successful_recurring
assert response = @gateway.recurring(@amount, @credit_card, :periodicity => :weekly)
- assert_match %r{The merchant can't accept data passed in this field}, response.message
- assert_failure response
+ assert_match %r{The transaction was successful}, response.message
+ assert_success response
+ end
+
+ def test_failed_recurring
+ assert response = @gateway.recurring(@amount, @declined_credit_card, :periodicity => :weekly)
+
+ assert_bad_data_response(response)
end
def test_transcript_scrubbing
@@ -190,4 +212,12 @@ def test_transcript_scrubbing
assert_scrubbed(@credit_card.number, clean_transcript)
assert_scrubbed(@credit_card.verification_value.to_s, clean_transcript)
end
+
+ private
+
+ def assert_bad_data_response(response)
+ assert_equal Response, response.class
+ assert_equal 'A field was improperly formatted, such as non-digit characters in a number field', response.message
+ assert_equal 'baddata', response.params['status']
+ end
end
diff --git a/test/unit/gateways/trust_commerce_test.rb b/test/unit/gateways/trust_commerce_test.rb
index b201a585786..84d14090b66 100644
--- a/test/unit/gateways/trust_commerce_test.rb
+++ b/test/unit/gateways/trust_commerce_test.rb
@@ -14,6 +14,12 @@ def setup
@amount = 100
@check = check
@credit_card = credit_card('4111111111111111')
+
+ @options_with_custom_fields = {
+ custom_fields: {
+ 'customfield1' => 'test1'
+ }
+ }
end
def test_successful_purchase
@@ -41,6 +47,22 @@ def test_succesful_purchase_with_check
end.respond_with(successful_purchase_response)
end
+ def test_succesful_purchase_with_custom_fields
+ stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options_with_custom_fields)
+ end.check_request do |endpoint, data, headers|
+ assert_match(%r{customfield1=test1}, data)
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_succesful_authorize_with_custom_fields
+ stub_comms do
+ @gateway.authorize(@amount, @check, @options_with_custom_fields)
+ end.check_request do |endpoint, data, headers|
+ assert_match(%r{customfield1=test1}, data)
+ end.respond_with(successful_authorize_response)
+ end
+
def test_successful_void_from_purchase
stub_comms do
@gateway.void('1235|sale')
@@ -57,6 +79,46 @@ def test_successful_void_from_authorize
end.respond_with(successful_void_response)
end
+ def test_succesful_capture_with_custom_fields
+ stub_comms do
+ @gateway.capture(@amount, 'auth', @options_with_custom_fields)
+ end.check_request do |endpoint, data, headers|
+ assert_match(%r{customfield1=test1}, data)
+ end.respond_with(successful_capture_response)
+ end
+
+ def test_succesful_refund_with_custom_fields
+ stub_comms do
+ @gateway.refund(@amount, 'auth|100', @options_with_custom_fields)
+ end.check_request do |endpoint, data, headers|
+ assert_match(%r{customfield1=test1}, data)
+ end.respond_with(successful_refund_response)
+ end
+
+ def test_succesful_void_with_custom_fields
+ stub_comms do
+ @gateway.void('1235|sale', @options_with_custom_fields)
+ end.check_request do |endpoint, data, headers|
+ assert_match(%r{customfield1=test1}, data)
+ end.respond_with(successful_void_response)
+ end
+
+ def test_succesful_store_with_custom_fields
+ stub_comms do
+ @gateway.store(@credit_card, @options_with_custom_fields)
+ end.check_request do |endpoint, data, headers|
+ assert_match(%r{customfield1=test1}, data)
+ end.respond_with(successful_store_response)
+ end
+
+ def test_succesful_unstore_with_custom_fields
+ stub_comms do
+ @gateway.unstore('test', @options_with_custom_fields)
+ end.check_request do |endpoint, data, headers|
+ assert_match(%r{customfield1=test1}, data)
+ end.respond_with(successful_unstore_response)
+ end
+
def test_amount_style
assert_equal '1034', @gateway.send(:amount, 1034)
@@ -103,6 +165,16 @@ def test_transcript_scrubbing
private
+ def successful_authorize_response
+ <<-RESPONSE
+authcode=123456
+transid=026-0193338367,
+status=approved
+avs=Y
+cvv=M
+ RESPONSE
+ end
+
def successful_purchase_response
<<-RESPONSE
transid=025-0007423614
@@ -112,6 +184,13 @@ def successful_purchase_response
RESPONSE
end
+ def successful_capture_response
+ <<-RESPONSE
+transid=026-0193338993
+status=accepted
+ RESPONSE
+ end
+
def unsuccessful_purchase_response
<<-RESPONSE
transid=025-0007423827
@@ -128,6 +207,30 @@ def successful_void_response
RESPONSE
end
+ def successful_refund_response
+ <<-RESPONSE
+transid=026-0193345407
+status=accepted
+ RESPONSE
+ end
+
+ def successful_store_response
+ <<-RESPONSE
+transid=026-0193346109
+status=approved,
+cvv=M,
+avs=0
+billingid=Q5T7PT
+ RESPONSE
+ end
+
+ def successful_unstore_response
+ <<-RESPONSE
+transid=026-0193346231
+status=rejected
+ RESPONSE
+ end
+
def transcript
<<-TRANSCRIPT
action=sale&demo=y&password=password&custid=TestMerchant&shipto_zip=90001&shipto_state=CA&shipto_city=Somewhere&shipto_address1=123+Test+St.&avs=n&zip=90001&state=CA&city=Somewhere&address1=123+Test+St.&cvv=1234&exp=0916&cc=4111111111111111&name=Longbob+Longsen&media=cc&ip=10.10.10.10&email=cody%40example.com&ticket=%231000.1&amount=100
From b80e7d9fc84f81ad49f6d5e975fc3d2cd20f7499 Mon Sep 17 00:00:00 2001
From: Hannah Deters
Date: Wed, 21 Aug 2019 16:32:06 -0400
Subject: [PATCH 0420/2234] Decidir: Add Naranja Card EVS-181
Adds Naranha card to Decidir gateway
Updated two tests to correspond to changed Decidir responses
Unit:
22 tests, 112 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
Remote:
17 tests, 60 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
---
lib/active_merchant/billing/gateways/decidir.rb | 5 +++--
test/remote/gateways/remote_decidir_test.rb | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/decidir.rb b/lib/active_merchant/billing/gateways/decidir.rb
index 2b7eed33e89..56233db4e43 100644
--- a/lib/active_merchant/billing/gateways/decidir.rb
+++ b/lib/active_merchant/billing/gateways/decidir.rb
@@ -7,7 +7,7 @@ class DecidirGateway < Gateway
self.supported_countries = ['AR']
self.money_format = :cents
self.default_currency = 'ARS'
- self.supported_cardtypes = [:visa, :master, :american_express, :diners_club]
+ self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :naranja]
self.homepage_url = 'http://www.decidir.com'
self.display_name = 'Decidir'
@@ -99,7 +99,8 @@ def scrub(transcript)
transcript.
gsub(%r((apikey: )\w+)i, '\1[FILTERED]').
gsub(%r((\"card_number\\\":\\\")\d+), '\1[FILTERED]').
- gsub(%r((\"security_code\\\":\\\")\d+), '\1[FILTERED]')
+ gsub(%r((\"security_code\\\":\\\")\d+), '\1[FILTERED]').
+ gsub(%r((\"emv_issuer_data\\\":\\\")\d+), '\1[FILTERED]')
end
private
diff --git a/test/remote/gateways/remote_decidir_test.rb b/test/remote/gateways/remote_decidir_test.rb
index e5f76ce1686..d8555619fe0 100644
--- a/test/remote/gateways/remote_decidir_test.rb
+++ b/test/remote/gateways/remote_decidir_test.rb
@@ -78,7 +78,7 @@ def test_failed_partial_capture
assert capture = @gateway_for_auth.capture(1, auth.authorization)
assert_failure capture
- assert_equal 'amount: Amount out of ranges: 100 - 100', capture.message
+ assert_equal 'amount: Amount out of ranges: 80 - 105', capture.message
assert_equal 'invalid_request_error', capture.error_code
assert_nil capture.authorization
end
From 210fcfee9fa40dbef9d301c8d0eac95e170e5dad Mon Sep 17 00:00:00 2001
From: britth
Date: Fri, 30 Aug 2019 12:34:03 -0400
Subject: [PATCH 0421/2234] Stripe Payment Intents - Update transfer_data
option
Rather than requiring a user to send in a hash with transfer data, this PR changes
to use individual `transfer_destination` and `transfer_amount` fields instead.
Remote:
24 tests, 103 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
6 tests, 42 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/stripe_payment_intents.rb | 6 +++---
test/remote/gateways/remote_stripe_payment_intents_test.rb | 2 +-
3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 408aed728f0..963c6944ea0 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -10,6 +10,7 @@
* PayU Latam: Add support for the `merchant_buyer_id` field in the `options` and `buyer` hashes [jasonxp] #3308
* Fat Zebra: Send metadata for purchase and authorize [montdidier] #3101
* TrustCommerce: Add support for custom fields [jasonxp] #3313
+* Stripe Payment Intents: Support option fields `transfer_destination` and `transfer_amount` and remove `transfer_data` hash [britth] #3317
== Version 1.97.0 (Aug 15, 2019)
* CyberSource: Add issuer `additionalData` gateway-specific field [jasonxp] #3296
diff --git a/lib/active_merchant/billing/gateways/stripe_payment_intents.rb b/lib/active_merchant/billing/gateways/stripe_payment_intents.rb
index 90d3d0b9b30..16ab7d1eeb1 100644
--- a/lib/active_merchant/billing/gateways/stripe_payment_intents.rb
+++ b/lib/active_merchant/billing/gateways/stripe_payment_intents.rb
@@ -207,10 +207,10 @@ def setup_future_usage(post, options = {})
end
def add_connected_account(post, options = {})
- return unless transfer_data = options[:transfer_data]
+ return unless options[:transfer_destination]
post[:transfer_data] = {}
- post[:transfer_data][:destination] = transfer_data[:destination] if transfer_data[:destination]
- post[:transfer_data][:amount] = transfer_data[:amount] if transfer_data[:amount]
+ post[:transfer_data][:destination] = options[:transfer_destination]
+ post[:transfer_data][:amount] = options[:transfer_amount] if options[:transfer_amount]
post[:on_behalf_of] = options[:on_behalf_of] if options[:on_behalf_of]
post[:transfer_group] = options[:transfer_group] if options[:transfer_group]
post[:application_fee_amount] = options[:application_fee] if options[:application_fee]
diff --git a/test/remote/gateways/remote_stripe_payment_intents_test.rb b/test/remote/gateways/remote_stripe_payment_intents_test.rb
index 59272687255..8625c210d57 100644
--- a/test/remote/gateways/remote_stripe_payment_intents_test.rb
+++ b/test/remote/gateways/remote_stripe_payment_intents_test.rb
@@ -211,7 +211,7 @@ def test_create_payment_intent_with_connected_account
currency: 'USD',
customer: @customer,
application_fee: 100,
- transfer_data: {destination: @destination_account}
+ transfer_destination: @destination_account
}
assert response = @gateway.create_intent(@amount, nil, options)
From e086fbeb211896b97f6feb2bc832eaacd3c51a54 Mon Sep 17 00:00:00 2001
From: Jason Nappier
Date: Thu, 29 Aug 2019 20:21:00 -0400
Subject: [PATCH 0422/2234] Barclaycard SmartPay: Add support for
shopper_statement gateway-specific field
Unit:
4237 tests, 70448 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications
100% passed
Remote:
35 tests, 75 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
94.2857% passed
Unrelated pre-existing remote test failures:
- test_successful_authorize_with_3ds2_browser_client_data (IdentifyShopper expected, RedirectShopper returned)
- test_successful_third_party_payout (invalid credentials)
CE-105
---
CHANGELOG | 1 +
.../billing/gateways/barclaycard_smartpay.rb | 2 ++
.../remote_barclaycard_smartpay_test.rb | 11 +++++++++++
.../gateways/barclaycard_smartpay_test.rb | 19 ++++++++++++++++---
4 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 963c6944ea0..912b9cfdeba 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -11,6 +11,7 @@
* Fat Zebra: Send metadata for purchase and authorize [montdidier] #3101
* TrustCommerce: Add support for custom fields [jasonxp] #3313
* Stripe Payment Intents: Support option fields `transfer_destination` and `transfer_amount` and remove `transfer_data` hash [britth] #3317
+* Barclaycard Smartpay: Add support for `shopperStatement` gateway-specific field [jasonxp] #3319
== Version 1.97.0 (Aug 15, 2019)
* CyberSource: Add issuer `additionalData` gateway-specific field [jasonxp] #3296
diff --git a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb
index 6daa08d98ce..503990127b9 100644
--- a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb
+++ b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb
@@ -37,6 +37,8 @@ def authorize(money, creditcard, options = {})
post[:card] = credit_card_hash(creditcard)
post[:billingAddress] = billing_address_hash(options) if options[:billing_address]
post[:deliveryAddress] = shipping_address_hash(options) if options[:shipping_address]
+ post[:shopperStatement] = options[:shopper_statement] if options[:shopper_statement]
+
add_3ds(post, options)
commit('authorise', post)
end
diff --git a/test/remote/gateways/remote_barclaycard_smartpay_test.rb b/test/remote/gateways/remote_barclaycard_smartpay_test.rb
index 76339217d63..bc72278b926 100644
--- a/test/remote/gateways/remote_barclaycard_smartpay_test.rb
+++ b/test/remote/gateways/remote_barclaycard_smartpay_test.rb
@@ -190,6 +190,17 @@ def test_successful_purchase_with_device_fingerprint
assert_equal '[capture-received]', response.message
end
+ def test_successful_purchase_with_shopper_statement
+ response = @gateway.purchase(
+ @amount,
+ @credit_card,
+ @options.merge(shopper_statement: 'One-year premium subscription')
+ )
+
+ assert_success response
+ assert_equal '[capture-received]', response.message
+ end
+
def test_successful_authorize_with_3ds
assert response = @gateway.authorize(@amount, @three_ds_enrolled_card, @options.merge(execute_threed: true))
assert_equal 'RedirectShopper', response.message
diff --git a/test/unit/gateways/barclaycard_smartpay_test.rb b/test/unit/gateways/barclaycard_smartpay_test.rb
index ae38e80bd92..87ad0da5c0b 100644
--- a/test/unit/gateways/barclaycard_smartpay_test.rb
+++ b/test/unit/gateways/barclaycard_smartpay_test.rb
@@ -182,11 +182,24 @@ def test_successful_authorize_with_shipping_house_number_and_street
end
def test_successful_authorize_with_extra_options
+ shopper_interaction = 'ContAuth'
+ shopper_statement = 'One-year premium subscription'
+ device_fingerprint = 'abcde123'
+
response = stub_comms do
- @gateway.authorize(@amount, @credit_card, @options.merge(shopper_interaction: 'ContAuth', device_fingerprint: 'abcde123'))
+ @gateway.authorize(
+ @amount,
+ @credit_card,
+ @options.merge(
+ shopper_interaction: shopper_interaction,
+ device_fingerprint: device_fingerprint,
+ shopper_statement: shopper_statement
+ )
+ )
end.check_request do |endpoint, data, headers|
- assert_match(/shopperInteraction=ContAuth/, data)
- assert_match(/deviceFingerprint=abcde123/, data)
+ assert_match(/shopperInteraction=#{shopper_interaction}/, data)
+ assert_match(/shopperStatement=#{Regexp.quote(CGI.escape(shopper_statement))}/, data)
+ assert_match(/deviceFingerprint=#{device_fingerprint}/, data)
end.respond_with(successful_authorize_response)
assert_success response
From d306cd42248947041dacb75c9d9f4562a1191dd5 Mon Sep 17 00:00:00 2001
From: britth
Date: Fri, 30 Aug 2019 15:40:03 -0400
Subject: [PATCH 0423/2234] Stripe Payment Intents: Add billing_details to
payments
Saves billing details (address, name, email, phone) to payment methods.
Remote:
25 tests, 107 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
6 tests, 42 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/stripe_payment_intents.rb | 17 +++++++++++++++++
.../remote_stripe_payment_intents_test.rb | 14 ++++++++++++++
3 files changed, 32 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index 912b9cfdeba..da3b5a77173 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -12,6 +12,7 @@
* TrustCommerce: Add support for custom fields [jasonxp] #3313
* Stripe Payment Intents: Support option fields `transfer_destination` and `transfer_amount` and remove `transfer_data` hash [britth] #3317
* Barclaycard Smartpay: Add support for `shopperStatement` gateway-specific field [jasonxp] #3319
+* Stripe Payment Intents: Add support for billing_details on payment methods [britth] #3320
== Version 1.97.0 (Aug 15, 2019)
* CyberSource: Add issuer `additionalData` gateway-specific field [jasonxp] #3296
diff --git a/lib/active_merchant/billing/gateways/stripe_payment_intents.rb b/lib/active_merchant/billing/gateways/stripe_payment_intents.rb
index 16ab7d1eeb1..3d1b94cf7a5 100644
--- a/lib/active_merchant/billing/gateways/stripe_payment_intents.rb
+++ b/lib/active_merchant/billing/gateways/stripe_payment_intents.rb
@@ -54,6 +54,7 @@ def create_payment_method(payment_method, options = {})
post[:card][:exp_month] = payment_method.month
post[:card][:exp_year] = payment_method.year
post[:card][:cvc] = payment_method.verification_value if payment_method.verification_value
+ add_billing_address(post, options)
commit(:post, 'payment_methods', post, options)
end
@@ -217,6 +218,22 @@ def add_connected_account(post, options = {})
post
end
+ def add_billing_address(post, options = {})
+ return unless billing = options[:billing_address] || options[:address]
+ post[:billing_details] = {}
+ post[:billing_details][:address] = {}
+ post[:billing_details][:address][:city] = billing[:city] if billing[:city]
+ post[:billing_details][:address][:country] = billing[:country] if billing[:country]
+ post[:billing_details][:address][:line1] = billing[:address1] if billing[:address1]
+ post[:billing_details][:address][:line2] = billing[:address2] if billing[:address2]
+ post[:billing_details][:address][:postal_code] = billing[:zip] if billing[:zip]
+ post[:billing_details][:address][:state] = billing[:state] if billing[:state]
+ post[:billing_details][:email] = billing[:email] if billing[:email]
+ post[:billing_details][:name] = billing[:name] if billing[:name]
+ post[:billing_details][:phone] = billing[:phone] if billing[:phone]
+ post
+ end
+
def add_shipping_address(post, options = {})
return unless shipping = options[:shipping]
post[:shipping] = {}
diff --git a/test/remote/gateways/remote_stripe_payment_intents_test.rb b/test/remote/gateways/remote_stripe_payment_intents_test.rb
index 8625c210d57..89059655301 100644
--- a/test/remote/gateways/remote_stripe_payment_intents_test.rb
+++ b/test/remote/gateways/remote_stripe_payment_intents_test.rb
@@ -206,6 +206,20 @@ def test_create_payment_intent_with_shipping_address
assert_equal 'John Doe', response.params['shipping']['name']
end
+ def test_create_payment_intent_with_billing_address
+ options = {
+ currency: 'USD',
+ customer: @customer,
+ billing_address: address,
+ confirm: true
+ }
+
+ assert response = @gateway.create_intent(@amount, @visa_card, options)
+ assert_success response
+ assert billing = response.params.dig('charges', 'data')[0].dig('billing_details', 'address')
+ assert_equal 'Ottawa', billing['city']
+ end
+
def test_create_payment_intent_with_connected_account
options = {
currency: 'USD',
From 9b585ff8dd1a5396a6c5b5512da1d825b072b076 Mon Sep 17 00:00:00 2001
From: Zeb DeOs
Date: Thu, 29 Aug 2019 16:58:51 -0400
Subject: [PATCH 0424/2234] BlueSnap: add standardized 3DS 2 auth fields
Unit:
30 tests, 142 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
37 tests, 115 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
ECS-552
Closes #3318
---
.../billing/gateways/blue_snap.rb | 17 ++
test/remote/gateways/remote_blue_snap_test.rb | 27 ++++
test/unit/gateways/blue_snap_test.rb | 152 ++++++++++++++++++
3 files changed, 196 insertions(+)
diff --git a/lib/active_merchant/billing/gateways/blue_snap.rb b/lib/active_merchant/billing/gateways/blue_snap.rb
index dffe8c85f83..b710e55b891 100644
--- a/lib/active_merchant/billing/gateways/blue_snap.rb
+++ b/lib/active_merchant/billing/gateways/blue_snap.rb
@@ -223,6 +223,7 @@ def add_order(doc, options)
doc.send('merchant-transaction-id', truncate(options[:order_id], 50)) if options[:order_id]
doc.send('soft-descriptor', options[:soft_descriptor]) if options[:soft_descriptor]
add_description(doc, options[:description]) if options[:description]
+ add_3ds(doc, options[:three_d_secure]) if options[:three_d_secure]
add_level_3_data(doc, options)
end
@@ -237,6 +238,22 @@ def add_address(doc, options)
doc.zip(address[:zip]) if address[:zip]
end
+ def add_3ds(doc, three_d_secure_options)
+ eci = three_d_secure_options[:eci]
+ cavv = three_d_secure_options[:cavv]
+ xid = three_d_secure_options[:xid]
+ ds_transaction_id = three_d_secure_options[:ds_transaction_id]
+ version = three_d_secure_options[:version]
+
+ doc.send('three-d-secure') do
+ doc.eci(eci) if eci
+ doc.cavv(cavv) if cavv
+ doc.xid(xid) if xid
+ doc.send('three-d-secure-version', version) if version
+ doc.send('ds-transaction-id', ds_transaction_id) if ds_transaction_id
+ end
+ end
+
def add_level_3_data(doc, options)
return unless options[:customer_reference_number]
doc.send('level-3-data') do
diff --git a/test/remote/gateways/remote_blue_snap_test.rb b/test/remote/gateways/remote_blue_snap_test.rb
index e36b3e699cd..bdbf9fba078 100644
--- a/test/remote/gateways/remote_blue_snap_test.rb
+++ b/test/remote/gateways/remote_blue_snap_test.rb
@@ -8,7 +8,19 @@ def setup
@credit_card = credit_card('4263982640269299')
@declined_card = credit_card('4917484589897107', month: 1, year: 2023)
@invalid_card = credit_card('4917484589897106', month: 1, year: 2023)
+ @three_ds_visa_card = credit_card('4000000000001091', month: 1)
+ @three_ds_master_card = credit_card('5200000000001096', month: 1)
+
@options = { billing_address: address }
+ @options_3ds2 = @options.merge(
+ three_d_secure: {
+ eci: '05',
+ cavv: 'AAABAWFlmQAAAABjRWWZEEFgFz+A',
+ xid: 'MGpHWm5ZWVpKclo0aUk0VmltVDA=',
+ ds_transaction_id: 'jhg34-sdgds87-sdg87-sdfg7',
+ version: '2.2.0'
+ }
+ )
@check = check
@invalid_check = check(:routing_number => '123456', :account_number => '123456789')
@@ -51,6 +63,12 @@ def test_successful_purchase_with_more_options
assert_equal 'Success', response.message
end
+ def test_successful_purchase_with_3ds2_auth
+ response = @gateway.purchase(@amount, @three_ds_visa_card, @options_3ds2)
+ assert_success response
+ assert_equal 'Success', response.message
+ end
+
def test_successful_purchase_with_currency
response = @gateway.purchase(@amount, @credit_card, @options.merge(currency: 'CAD'))
assert_success response
@@ -185,6 +203,15 @@ def test_successful_authorize_and_partial_capture
assert_equal 'Success', capture.message
end
+ def test_successful_authorize_and_capture_with_3ds2_auth
+ auth = @gateway.authorize(@amount, @three_ds_master_card, @options_3ds2)
+ assert_success auth
+
+ assert capture = @gateway.capture(@amount, auth.authorization)
+ assert_success capture
+ assert_equal 'Success', capture.message
+ end
+
def test_failed_authorize
response = @gateway.authorize(@amount, @declined_card, @options)
assert_failure response
diff --git a/test/unit/gateways/blue_snap_test.rb b/test/unit/gateways/blue_snap_test.rb
index 3a67d86da8a..541cc05a65d 100644
--- a/test/unit/gateways/blue_snap_test.rb
+++ b/test/unit/gateways/blue_snap_test.rb
@@ -1,3 +1,5 @@
+# coding: utf-8
+
require 'test_helper'
class BlueSnapTest < Test::Unit::TestCase
@@ -9,6 +11,15 @@ def setup
@check = check
@amount = 100
@options = { order_id: '1', personal_identification_number: 'CNPJ' }
+ @options_3ds2 = @options.merge(
+ three_d_secure: {
+ eci: '05',
+ cavv: 'AAABAWFlmQAAAABjRWWZEEFgFz+A',
+ xid: 'MGpHWm5ZWVpKclo0aUk0VmltVDA=',
+ ds_transaction_id: 'jhg34-sdgds87-sdg87-sdfg7',
+ version: '2.2.0'
+ }
+ )
@valid_check_options = {
billing_address: {
address1: '123 Street',
@@ -55,6 +66,37 @@ def test_successful_echeck_purchase
assert_equal '1019803029', response.authorization
end
+ def test_successful_purchase_with_3ds_auth
+ response = stub_comms(@gateway, :raw_ssl_request) do
+ @gateway.purchase(@amount, @credit_card, @options_3ds2)
+ end.check_request do |method, url, data|
+ assert_match(//, data)
+ assert_match(/#{Regexp.quote(@options_3ds2[:three_d_secure][:eci])}<\/eci>/, data)
+ assert_match(/#{Regexp.quote(@options_3ds2[:three_d_secure][:cavv])}<\/cavv>/, data)
+ assert_match(/#{Regexp.quote(@options_3ds2[:three_d_secure][:xid])}<\/xid>/, data)
+ assert_match(/#{Regexp.quote(@options_3ds2[:three_d_secure][:version])}<\/three-d-secure-version>/, data)
+ assert_match(/#{Regexp.quote(@options_3ds2[:three_d_secure][:ds_transaction_id])}<\/ds-transaction-id>/, data)
+ end.respond_with(successful_purchase_with_3ds_auth_response)
+
+ assert_success response
+ assert_equal '1024951831', response.authorization
+ assert_equal '019082915501456', response.params['original-network-transaction-id']
+ assert_equal '019082915501456', response.params['network-transaction-id']
+ end
+
+ def test_does_not_send_3ds_auth_when_empty
+ stub_comms(@gateway, :raw_ssl_request) do
+ @gateway.purchase(@amount, @credit_card, @options)
+ end.check_request do |method, url, data|
+ assert_not_match(//, data)
+ assert_not_match(//, data)
+ assert_not_match(//, data)
+ assert_not_match(//, data)
+ assert_not_match(//, data)
+ assert_not_match(//, data)
+ end.respond_with(successful_purchase_response)
+ end
+
def test_failed_purchase
@gateway.expects(:raw_ssl_request).returns(failed_purchase_response)
@@ -82,6 +124,24 @@ def test_successful_authorize
assert_equal '1012082893', response.authorization
end
+ def test_successful_authorize_with_3ds_auth
+ response = stub_comms(@gateway, :raw_ssl_request) do
+ @gateway.authorize(@amount, @credit_card, @options_3ds2)
+ end.check_request do |type, endpoint, data, headers|
+ assert_match(//, data)
+ assert_match(/#{Regexp.quote(@options_3ds2[:three_d_secure][:eci])}<\/eci>/, data)
+ assert_match(/#{Regexp.quote(@options_3ds2[:three_d_secure][:cavv])}<\/cavv>/, data)
+ assert_match(/#{Regexp.quote(@options_3ds2[:three_d_secure][:xid])}<\/xid>/, data)
+ assert_match(/#{Regexp.quote(@options_3ds2[:three_d_secure][:version])}<\/three-d-secure-version>/, data)
+ assert_match(/#{Regexp.quote(@options_3ds2[:three_d_secure][:ds_transaction_id])}<\/ds-transaction-id>/, data)
+ end.respond_with(successful_authorize_with_3ds_auth_response)
+
+ assert_success response
+ assert_equal '1024951833', response.authorization
+ assert_equal 'MCC8929120829', response.params['original-network-transaction-id']
+ assert_equal 'MCC8929120829', response.params['network-transaction-id']
+ end
+
def test_failed_authorize
@gateway.expects(:raw_ssl_request).returns(failed_authorize_response)
@@ -340,6 +400,51 @@ def successful_purchase_response
XML
end
+ def successful_purchase_with_3ds_auth_response
+ MockResponse.succeeded <<-XML
+
+
+ AUTH_CAPTURE
+ 1024951831
+ ECOMMERCE
+ BLS*Spreedly
+ 1.00
+ 1.00
+ USD
+ N
+
+ Longbob
+ Longsen
+ CA
+ ON
+ Ottawa
+ K1C2N6
+
+ 25105083
+
+ 1091
+ VISA
+ CREDIT
+ CONSUMER
+ N
+ us
+
+
+ 019082915501456
+ 019082915501456
+
+
+ success
+ NR
+ N
+ N
+ U
+ 019082915501456
+
+
+ XML
+ end
+
def successful_echeck_purchase_response
MockResponse.succeeded <<-XML
@@ -472,6 +577,53 @@ def successful_authorize_response
XML
end
+ def successful_authorize_with_3ds_auth_response
+ MockResponse.succeeded <<-XML
+
+
+ AUTH_ONLY
+ 1024951833
+ ECOMMERCE
+ BLS*Spreedly
+ 1.00
+ 1.00
+ USD
+ S
+
+ Longbob
+ Longsen
+ CA
+ ON
+ Ottawa
+ K1C2N6
+
+ 25105085
+
+ 1096
+ MASTERCARD
+ CREDIT
+ STANDARD
+ CONSUMER
+ N
+ PUBLIC BANK BERHAD
+ my
+
+
+ MCC8929120829
+ MCC8929120829
+
+
+ success
+ NC
+ U
+ U
+ U
+ MCC8929120829
+
+
+ XML
+ end
+
def failed_authorize_response
body = <<-XML
From 1e14379e2d2c257f4fbaf6b32bacf113550a3e0e Mon Sep 17 00:00:00 2001
From: Zeb DeOs
Date: Tue, 3 Sep 2019 16:25:56 -0400
Subject: [PATCH 0425/2234] Add entry to CHANGELOG for #3318
---
CHANGELOG | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG b/CHANGELOG
index da3b5a77173..cd0934662ae 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -13,6 +13,7 @@
* Stripe Payment Intents: Support option fields `transfer_destination` and `transfer_amount` and remove `transfer_data` hash [britth] #3317
* Barclaycard Smartpay: Add support for `shopperStatement` gateway-specific field [jasonxp] #3319
* Stripe Payment Intents: Add support for billing_details on payment methods [britth] #3320
+* BlueSnap: add standardized 3DS 2 auth fields [bayprogrammer] #3318
== Version 1.97.0 (Aug 15, 2019)
* CyberSource: Add issuer `additionalData` gateway-specific field [jasonxp] #3296
From 19872bf2a5c4f1b11faf909a8b8a49f0f36c404b Mon Sep 17 00:00:00 2001
From: britth
Date: Wed, 4 Sep 2019 09:32:29 -0400
Subject: [PATCH 0426/2234] Barclaycard Smartpay: Add app based 3ds auth and
purchase
Like Adyen (#3298), we need to be able to create app based auth
and purchase requests, setting device_channel appropriately and
only sending notificationURL for browser based requests.
Remote:
36 tests, 87 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
97.2222% passed
Unit:
28 tests, 143 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unrelated pre-existing remote test failures:
- test_successful_third_party_payout (invalid credentials)
---
CHANGELOG | 1 +
.../billing/gateways/barclaycard_smartpay.rb | 38 ++++++++++---------
.../remote_barclaycard_smartpay_test.rb | 28 +++++++++++++-
3 files changed, 48 insertions(+), 19 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index cd0934662ae..74567a6da22 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -14,6 +14,7 @@
* Barclaycard Smartpay: Add support for `shopperStatement` gateway-specific field [jasonxp] #3319
* Stripe Payment Intents: Add support for billing_details on payment methods [britth] #3320
* BlueSnap: add standardized 3DS 2 auth fields [bayprogrammer] #3318
+* Barclaycard Smartpay: Add app based 3DS requests for auth and purchase [britth] #3327
== Version 1.97.0 (Aug 15, 2019)
* CyberSource: Add issuer `additionalData` gateway-specific field [jasonxp] #3296
diff --git a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb
index 503990127b9..1788954da3b 100644
--- a/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb
+++ b/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb
@@ -352,24 +352,12 @@ def store_request(options)
def add_3ds(post, options)
if three_ds_2_options = options[:three_ds_2]
- if browser_info = three_ds_2_options[:browser_info]
- post[:browserInfo] = {
- acceptHeader: browser_info[:accept_header],
- colorDepth: browser_info[:depth],
- javaEnabled: browser_info[:java],
- language: browser_info[:language],
- screenHeight: browser_info[:height],
- screenWidth: browser_info[:width],
- timeZoneOffset: browser_info[:timezone],
- userAgent: browser_info[:user_agent]
- }
-
- if device_channel = three_ds_2_options[:channel]
- post[:threeDS2RequestData] = {
- deviceChannel: device_channel,
- notificationURL: three_ds_2_options[:notification_url]
- }
- end
+ device_channel = three_ds_2_options[:channel]
+ if device_channel == 'app'
+ post[:threeDS2RequestData] = { deviceChannel: device_channel }
+ else
+ add_browser_info(three_ds_2_options[:browser_info], post)
+ post[:threeDS2RequestData] = { deviceChannel: device_channel, notificationURL: three_ds_2_options[:notification_url] }
end
else
return unless options[:execute_threed] || options[:threed_dynamic]
@@ -377,6 +365,20 @@ def add_3ds(post, options)
post[:additionalData] = { executeThreeD: 'true' } if options[:execute_threed]
end
end
+
+ def add_browser_info(browser_info, post)
+ return unless browser_info
+ post[:browserInfo] = {
+ acceptHeader: browser_info[:accept_header],
+ colorDepth: browser_info[:depth],
+ javaEnabled: browser_info[:java],
+ language: browser_info[:language],
+ screenHeight: browser_info[:height],
+ screenWidth: browser_info[:width],
+ timeZoneOffset: browser_info[:timezone],
+ userAgent: browser_info[:user_agent]
+ }
+ end
end
end
end
diff --git a/test/remote/gateways/remote_barclaycard_smartpay_test.rb b/test/remote/gateways/remote_barclaycard_smartpay_test.rb
index bc72278b926..0cd7a6ab001 100644
--- a/test/remote/gateways/remote_barclaycard_smartpay_test.rb
+++ b/test/remote/gateways/remote_barclaycard_smartpay_test.rb
@@ -10,6 +10,7 @@ def setup
@credit_card = credit_card('4111111111111111', :month => 10, :year => 2020, :verification_value => 737)
@declined_card = credit_card('4000300011112220', :month => 3, :year => 2030, :verification_value => 737)
@three_ds_enrolled_card = credit_card('4212345678901237', brand: :visa)
+ @three_ds_2_enrolled_card = credit_card('4917610000000000', brand: :visa)
@options = {
order_id: '1',
@@ -212,7 +213,7 @@ def test_successful_authorize_with_3ds
end
def test_successful_authorize_with_3ds2_browser_client_data
- assert response = @gateway.authorize(@amount, @three_ds_enrolled_card, @normalized_3ds_2_options)
+ assert response = @gateway.authorize(@amount, @three_ds_2_enrolled_card, @normalized_3ds_2_options)
assert response.test?
refute response.authorization.blank?
assert_equal response.params['resultCode'], 'IdentifyShopper'
@@ -221,6 +222,31 @@ def test_successful_authorize_with_3ds2_browser_client_data
refute response.params['additionalData']['threeds2.threeDSMethodURL'].blank?
end
+ def test_successful_authorize_with_3ds2_app_based_request
+ three_ds_app_based_options = {
+ reference: '345123',
+ shopper_email: 'john.smith@test.com',
+ shopper_ip: '77.110.174.153',
+ shopper_reference: 'John Smith',
+ billing_address: address(),
+ order_id: '123',
+ stored_credential: {reason_type: 'unscheduled'},
+ three_ds_2: {
+ channel: 'app',
+ }
+ }
+
+ assert response = @gateway.authorize(@amount, @three_ds_2_enrolled_card, three_ds_app_based_options)
+ assert response.test?
+ refute response.authorization.blank?
+ assert_equal response.params['resultCode'], 'IdentifyShopper'
+ refute response.params['additionalData']['threeds2.threeDS2Token'].blank?
+ refute response.params['additionalData']['threeds2.threeDSServerTransID'].blank?
+ refute response.params['additionalData']['threeds2.threeDS2DirectoryServerInformation.algorithm'].blank?
+ refute response.params['additionalData']['threeds2.threeDS2DirectoryServerInformation.directoryServerId'].blank?
+ refute response.params['additionalData']['threeds2.threeDS2DirectoryServerInformation.publicKey'].blank?
+ end
+
def test_successful_authorize_and_capture
auth = @gateway.authorize(@amount, @credit_card, @options)
assert_success auth
From e3f59c1d3f409e43cb958720aab6817ebfea01ac Mon Sep 17 00:00:00 2001
From: britth
Date: Wed, 4 Sep 2019 11:28:58 -0400
Subject: [PATCH 0427/2234] Stripe Payment Intents, Checkout V2: MOTO flag
This PR enables marking a transaction as MOTO on the Stripe Payment
Intents and Checkout V2 gateways. Note: For Stripe, accounts must
be configured to allow setting the MOTO flag (https://stripe.com/guides/strong-customer-authentication#phone-sales).
This PR also adds the list of supported countries for Stripe.
Stripe Payment Intents -
Remote:
28 tests, 115 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
6 tests, 42 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Checkout V2 -
Remote:
30 tests, 72 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
26 tests, 116 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/checkout_v2.rb | 1 +
.../gateways/stripe_payment_intents.rb | 11 ++++++
.../gateways/remote_checkout_v2_test.rb | 7 ++++
.../remote_stripe_payment_intents_test.rb | 36 +++++++++++++++++++
5 files changed, 56 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index 74567a6da22..6df67f62f32 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -15,6 +15,7 @@
* Stripe Payment Intents: Add support for billing_details on payment methods [britth] #3320
* BlueSnap: add standardized 3DS 2 auth fields [bayprogrammer] #3318
* Barclaycard Smartpay: Add app based 3DS requests for auth and purchase [britth] #3327
+* Stripe Payment Intents, Checkout V2: Add support for `MOTO` flagging [britth] #3323
== Version 1.97.0 (Aug 15, 2019)
* CyberSource: Add issuer `additionalData` gateway-specific field [jasonxp] #3296
diff --git a/lib/active_merchant/billing/gateways/checkout_v2.rb b/lib/active_merchant/billing/gateways/checkout_v2.rb
index e16fe5049ba..0f916158a22 100644
--- a/lib/active_merchant/billing/gateways/checkout_v2.rb
+++ b/lib/active_merchant/billing/gateways/checkout_v2.rb
@@ -128,6 +128,7 @@ def add_customer_data(post, options)
def add_transaction_data(post, options = {})
post[:payment_type] = 'Regular' if options[:transaction_indicator] == 1
post[:payment_type] = 'Recurring' if options[:transaction_indicator] == 2
+ post[:payment_type] = 'MOTO' if options[:transaction_indicator] == 3
post[:previous_payment_id] = options[:previous_charge_id] if options[:previous_charge_id]
end
diff --git a/lib/active_merchant/billing/gateways/stripe_payment_intents.rb b/lib/active_merchant/billing/gateways/stripe_payment_intents.rb
index 3d1b94cf7a5..6469e671113 100644
--- a/lib/active_merchant/billing/gateways/stripe_payment_intents.rb
+++ b/lib/active_merchant/billing/gateways/stripe_payment_intents.rb
@@ -5,6 +5,9 @@ module Billing #:nodoc:
# This gateway uses the current Stripe {Payment Intents API}[https://stripe.com/docs/api/payment_intents].
# For the legacy API, see the Stripe gateway
class StripePaymentIntentsGateway < StripeGateway
+
+ self.supported_countries = %w(AT AU BE BR CA CH DE DK ES FI FR GB HK IE IT JP LU MX NL NO NZ PT SE SG US)
+
ALLOWED_METHOD_STATES = %w[automatic manual].freeze
ALLOWED_CANCELLATION_REASONS = %w[duplicate fraudulent requested_by_customer abandoned].freeze
CREATE_INTENT_ATTRIBUTES = %i[description statement_descriptor receipt_email save_payment_method]
@@ -24,6 +27,7 @@ def create_intent(money, payment_method, options = {})
add_connected_account(post, options)
add_shipping_address(post, options)
setup_future_usage(post, options)
+ add_exemption(post, options)
CREATE_INTENT_ATTRIBUTES.each do |attribute|
add_whitelisted_attribute(post, options, attribute)
@@ -201,6 +205,13 @@ def add_payment_method_types(post, options)
post
end
+ def add_exemption(post, options = {})
+ return unless options[:confirm]
+ post[:payment_method_options] ||= {}
+ post[:payment_method_options][:card] ||= {}
+ post[:payment_method_options][:card][:moto] = true if options[:moto]
+ end
+
def setup_future_usage(post, options = {})
post[:setup_future_usage] = options[:setup_future_usage] if %w( on_session off_session ).include?(options[:setup_future_usage])
post[:off_session] = options[:off_session] if options[:off_session] && options[:confirm] == true
diff --git a/test/remote/gateways/remote_checkout_v2_test.rb b/test/remote/gateways/remote_checkout_v2_test.rb
index c8b40ca569e..bec80aba153 100644
--- a/test/remote/gateways/remote_checkout_v2_test.rb
+++ b/test/remote/gateways/remote_checkout_v2_test.rb
@@ -63,6 +63,13 @@ def test_successful_purchase_with_additional_options
assert_equal 'Succeeded', response.message
end
+ def test_successful_purchase_with_moto_flag
+ response = @gateway.authorize(@amount, @credit_card, @options.merge(transaction_indicator: 3))
+
+ assert_success response
+ assert_equal 'Succeeded', response.message
+ end
+
def test_successful_purchase_includes_avs_result
response = @gateway.purchase(@amount, @credit_card, @options)
assert_success response
diff --git a/test/remote/gateways/remote_stripe_payment_intents_test.rb b/test/remote/gateways/remote_stripe_payment_intents_test.rb
index 89059655301..a8928f5cf3e 100644
--- a/test/remote/gateways/remote_stripe_payment_intents_test.rb
+++ b/test/remote/gateways/remote_stripe_payment_intents_test.rb
@@ -8,6 +8,8 @@ def setup
@three_ds_payment_method = 'pm_card_threeDSecure2Required'
@visa_payment_method = 'pm_card_visa'
@declined_payment_method = 'pm_card_chargeDeclined'
+ @three_ds_moto_enabled = 'pm_card_authenticationRequiredOnSetup'
+ @three_ds_authentication_required = 'pm_card_authenticationRequired'
@three_ds_credit_card = credit_card('4000000000003220',
verification_value: '737',
month: 10,
@@ -382,6 +384,40 @@ def test_successful_store_purchase_and_unstore
assert_nil unstore.params['customer']
end
+ def test_moto_enabled_card_requires_action_when_not_marked
+ options = {
+ currency: 'GBP',
+ confirm: true,
+ }
+ assert purchase = @gateway.purchase(@amount, @three_ds_moto_enabled, options)
+
+ assert_equal 'requires_action', purchase.params['status']
+ end
+
+ def test_moto_enabled_card_succeeds_when_marked
+ options = {
+ currency: 'GBP',
+ confirm: true,
+ moto: true,
+ }
+ assert purchase = @gateway.purchase(@amount, @three_ds_moto_enabled, options)
+
+ assert_equal 'succeeded', purchase.params['status']
+ assert purchase.params.dig('charges', 'data')[0]['captured']
+ end
+
+ def test_certain_cards_require_action_even_when_marked_as_moto
+ options = {
+ currency: 'GBP',
+ confirm: true,
+ moto: true,
+ }
+ assert purchase = @gateway.purchase(@amount, @three_ds_authentication_required, options)
+
+ assert_failure purchase
+ assert_equal 'Your card was declined. This transaction requires authentication.', purchase.message
+ end
+
def test_transcript_scrubbing
options = {
currency: 'GBP',
From fd93abd018ba6dc07ffef3c15c993eb2e2bc9abb Mon Sep 17 00:00:00 2001
From: Molly Brown <37967379+molbrown@users.noreply.github.com>
Date: Wed, 4 Sep 2019 15:25:46 -0400
Subject: [PATCH 0428/2234] Braintree Blue: Adding 3DS2 passthru support
(#3328)
* Adding 3DS2 passthru support to Braintree Blue
* Finish 3DS2 passthru support to Braintree Blue
Unit:
75 tests, 176 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
80 tests, 435 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
ECS-499
---
.../billing/gateways/braintree_blue.rb | 30 ++++++++++++----
.../gateways/remote_braintree_blue_test.rb | 13 +++++--
test/unit/gateways/braintree_blue_test.rb | 35 ++++++++++++++++++-
3 files changed, 67 insertions(+), 11 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/braintree_blue.rb b/lib/active_merchant/billing/gateways/braintree_blue.rb
index eabf8b12557..463c7ac2b5f 100644
--- a/lib/active_merchant/billing/gateways/braintree_blue.rb
+++ b/lib/active_merchant/billing/gateways/braintree_blue.rb
@@ -630,13 +630,7 @@ def create_transaction_parameters(money, credit_card_or_vault_id, options)
}
end
- if options[:three_d_secure]
- parameters[:three_d_secure_pass_thru] = {
- cavv: options[:three_d_secure][:cavv],
- eci_flag: options[:three_d_secure][:eci],
- xid: options[:three_d_secure][:xid],
- }
- end
+ add_3ds_info(parameters, options[:three_d_secure])
parameters[:tax_amount] = options[:tax_amount] if options[:tax_amount]
parameters[:tax_exempt] = options[:tax_exempt] if options[:tax_exempt]
@@ -651,6 +645,28 @@ def create_transaction_parameters(money, credit_card_or_vault_id, options)
parameters
end
+ def add_3ds_info(parameters, three_d_secure_opts)
+ return if empty?(three_d_secure_opts)
+ pass_thru = {}
+
+ pass_thru[:three_d_secure_version] = three_d_secure_opts[:version] if three_d_secure_opts[:version]
+ pass_thru[:eci_flag] = three_d_secure_opts[:eci] if three_d_secure_opts[:eci]
+ pass_thru[:cavv_algorithm] = three_d_secure_opts[:cavv_algorithm] if three_d_secure_opts[:cavv_algorithm]
+ pass_thru[:cavv] = three_d_secure_opts[:cavv] if three_d_secure_opts[:cavv]
+ pass_thru[:directory_response] = three_d_secure_opts[:directory_response_status] if three_d_secure_opts[:directory_response_status]
+ pass_thru[:authentication_response] = three_d_secure_opts[:authentication_response_status] if three_d_secure_opts[:authentication_response_status]
+
+ parameters[:three_d_secure_pass_thru] = pass_thru.merge(xid_or_ds_trans_id(three_d_secure_opts))
+ end
+
+ def xid_or_ds_trans_id(three_d_secure_opts)
+ if three_d_secure_opts[:version].to_f >= 2
+ { ds_transaction_id: three_d_secure_opts[:ds_transaction_id] }
+ else
+ { xid: three_d_secure_opts[:xid] }
+ end
+ end
+
def add_stored_credential_data(parameters, credit_card_or_vault_id, options)
return unless (stored_credential = options[:stored_credential])
parameters[:external_vault] = {}
diff --git a/test/remote/gateways/remote_braintree_blue_test.rb b/test/remote/gateways/remote_braintree_blue_test.rb
index 5ff491fa024..d1031516fab 100644
--- a/test/remote/gateways/remote_braintree_blue_test.rb
+++ b/test/remote/gateways/remote_braintree_blue_test.rb
@@ -538,8 +538,16 @@ def test_successful_purchase_with_addresses
end
def test_successful_purchase_with_three_d_secure_pass_thru
- three_d_secure_params = { eci: '05', cavv: 'cavv', xid: 'xid' }
- assert response = @gateway.purchase(@amount, @credit_card,
+ three_d_secure_params = { version: '2.0', cavv: 'cavv', eci: '02', ds_transaction_id: 'trans_id', cavv_algorithm: 'algorithm', directory_response_status: 'directory', authentication_response_status: 'auth' }
+ response = @gateway.purchase(@amount, @credit_card,
+ three_d_secure: three_d_secure_params
+ )
+ assert_success response
+ end
+
+ def test_successful_purchase_with_some_three_d_secure_pass_thru_fields
+ three_d_secure_params = { version: '2.0', cavv: 'cavv', eci: '02', ds_transaction_id: 'trans_id' }
+ response = @gateway.purchase(@amount, @credit_card,
three_d_secure: three_d_secure_params
)
assert_success response
@@ -937,5 +945,4 @@ def assert_avs(address1, zip, expected_avs_code)
assert_success response
assert_equal expected_avs_code, response.avs_result['code']
end
-
end
diff --git a/test/unit/gateways/braintree_blue_test.rb b/test/unit/gateways/braintree_blue_test.rb
index f8d50ad9086..727fbd054d8 100644
--- a/test/unit/gateways/braintree_blue_test.rb
+++ b/test/unit/gateways/braintree_blue_test.rb
@@ -643,7 +643,7 @@ def test_cardholder_name_passing_with_card
@gateway.purchase(100, credit_card('41111111111111111111'), :customer => {:first_name => 'Longbob', :last_name => 'Longsen'})
end
- def test_three_d_secure_pass_thru_handling
+ def test_three_d_secure_pass_thru_handling_version_1
Braintree::TransactionGateway.
any_instance.
expects(:sale).
@@ -657,6 +657,39 @@ def test_three_d_secure_pass_thru_handling
@gateway.purchase(100, credit_card('41111111111111111111'), three_d_secure: {cavv: 'cavv', eci: 'eci', xid: 'xid'})
end
+ def test_three_d_secure_pass_thru_handling_version_2
+ Braintree::TransactionGateway.
+ any_instance.
+ expects(:sale).
+ with(has_entries(three_d_secure_pass_thru: has_entries(
+ three_d_secure_version: '2.0',
+ cavv: 'cavv',
+ eci_flag: 'eci',
+ ds_transaction_id: 'trans_id',
+ cavv_algorithm: 'algorithm',
+ directory_response: 'directory',
+ authentication_response: 'auth'
+ ))).
+ returns(braintree_result)
+
+ @gateway.purchase(100, credit_card('41111111111111111111'), three_d_secure: {version: '2.0', cavv: 'cavv', eci: 'eci', ds_transaction_id: 'trans_id', cavv_algorithm: 'algorithm', directory_response_status: 'directory', authentication_response_status: 'auth'})
+ end
+
+ def test_three_d_secure_pass_thru_some_fields
+ Braintree::TransactionGateway.
+ any_instance.
+ expects(:sale).
+ with(has_entries(three_d_secure_pass_thru: has_entries(
+ three_d_secure_version: '2.0',
+ cavv: 'cavv',
+ eci_flag: 'eci',
+ ds_transaction_id: 'trans_id'
+ ))).
+ returns(braintree_result)
+
+ @gateway.purchase(100, credit_card('41111111111111111111'), three_d_secure: {version: '2.0', cavv: 'cavv', eci: 'eci', ds_transaction_id: 'trans_id'})
+ end
+
def test_passes_recurring_flag
@gateway = BraintreeBlueGateway.new(
:merchant_id => 'test',
From d10768f30187118b40ad20e6bdde7e41c5669f04 Mon Sep 17 00:00:00 2001
From: leila-alderman
Date: Mon, 26 Aug 2019 16:10:46 -0400
Subject: [PATCH 0429/2234] Global Collect: Add Cabal card
Adds the Cabal card to the Global Collect gateway (also known as the
Ingenico gateway).
The Ingenico gateway docs do not include a test card number for Cabal,
and sending card numbers that follow the Luhn algorithm and fall within
the Cabal card range results in error messages of "Rejected".
Therefore, no additional remote or unit tests were added to the Global
Collect gateway to test the implementation of the Cabal card type.
CE-94 / CE-97
Unit:
20 tests, 88 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
Remote:
17 tests, 40 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/global_collect.rb | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 6df67f62f32..7cf4e6f6c1d 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -16,6 +16,7 @@
* BlueSnap: add standardized 3DS 2 auth fields [bayprogrammer] #3318
* Barclaycard Smartpay: Add app based 3DS requests for auth and purchase [britth] #3327
* Stripe Payment Intents, Checkout V2: Add support for `MOTO` flagging [britth] #3323
+* Global Collect: Add Cabal card [leila-alderman] #3310
== Version 1.97.0 (Aug 15, 2019)
* CyberSource: Add issuer `additionalData` gateway-specific field [jasonxp] #3296
diff --git a/lib/active_merchant/billing/gateways/global_collect.rb b/lib/active_merchant/billing/gateways/global_collect.rb
index 9395d0985ff..879ff3acc6f 100644
--- a/lib/active_merchant/billing/gateways/global_collect.rb
+++ b/lib/active_merchant/billing/gateways/global_collect.rb
@@ -10,7 +10,7 @@ class GlobalCollectGateway < Gateway
self.supported_countries = ['AD', 'AE', 'AG', 'AI', 'AL', 'AM', 'AO', 'AR', 'AS', 'AT', 'AU', 'AW', 'AX', 'AZ', 'BA', 'BB', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BL', 'BM', 'BN', 'BO', 'BQ', 'BR', 'BS', 'BT', 'BW', 'BY', 'BZ', 'CA', 'CC', 'CD', 'CF', 'CH', 'CI', 'CK', 'CL', 'CM', 'CN', 'CO', 'CR', 'CU', 'CV', 'CW', 'CX', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM', 'DO', 'DZ', 'EC', 'EE', 'EG', 'ER', 'ES', 'ET', 'FI', 'FJ', 'FK', 'FM', 'FO', 'FR', 'GA', 'GB', 'GD', 'GE', 'GF', 'GH', 'GI', 'GL', 'GM', 'GN', 'GP', 'GQ', 'GR', 'GS', 'GT', 'GU', 'GW', 'GY', 'HK', 'HN', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IM', 'IN', 'IS', 'IT', 'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI', 'KM', 'KN', 'KR', 'KW', 'KY', 'KZ', 'LA', 'LB', 'LC', 'LI', 'LK', 'LR', 'LS', 'LT', 'LU', 'LV', 'MA', 'MC', 'MD', 'ME', 'MF', 'MG', 'MH', 'MK', 'MM', 'MN', 'MO', 'MP', 'MQ', 'MR', 'MS', 'MT', 'MU', 'MV', 'MW', 'MX', 'MY', 'MZ', 'NA', 'NC', 'NE', 'NG', 'NI', 'NL', 'NO', 'NP', 'NR', 'NU', 'NZ', 'OM', 'PA', 'PE', 'PF', 'PG', 'PH', 'PL', 'PN', 'PS', 'PT', 'PW', 'QA', 'RE', 'RO', 'RS', 'RU', 'RW', 'SA', 'SB', 'SC', 'SE', 'SG', 'SH', 'SI', 'SJ', 'SK', 'SL', 'SM', 'SN', 'SR', 'ST', 'SV', 'SZ', 'TC', 'TD', 'TG', 'TH', 'TJ', 'TL', 'TM', 'TN', 'TO', 'TR', 'TT', 'TV', 'TW', 'TZ', 'UA', 'UG', 'US', 'UY', 'UZ', 'VC', 'VE', 'VG', 'VI', 'VN', 'WF', 'WS', 'ZA', 'ZM', 'ZW']
self.default_currency = 'USD'
self.money_format = :cents
- self.supported_cardtypes = [:visa, :master, :american_express, :discover, :naranja]
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :naranja, :cabal]
def initialize(options={})
requires!(options, :merchant_id, :api_key_id, :secret_api_key)
From 75bc0e902e32582064846146a3385e6e5d610c71 Mon Sep 17 00:00:00 2001
From: leila-alderman
Date: Thu, 29 Aug 2019 09:50:22 -0400
Subject: [PATCH 0430/2234] WorldPay: Add Cabal card
Adds the ability to use the newly added Cabal card to the WorldPay
gateway.
Although the WorldPay gateway documentation includes a test card number
for Cabal, the current gateway integration is not set up to accept Cabal
cards and results in error messages of `"Payment Method CABAL-SSL is
unknown; The Payment Method is not available."`. Therefore, no
additional remote or unit tests were added to the WorldPay gateway to
test the implementation of the Cabal card type.
CE-94 / CE-98
Unit:
66 tests, 392 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
Remote:
50 tests, 215 assertions, 5 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
90% passed
Two of the failing tests are for 3DS parameter pass-through, which are
known to fail with the current test credentials. (See
https://github.com/activemerchant/active_merchant/commit/1243289c2e700e666a634a86611cd6fa8da0ae05#diff-5b1b45d9c385decf3c649a4e3e8ebbc5)
The other three failing tests are all related to `credit`:
- `test_successful_credit_using_token`
- `test_successful_mastercard_credit_on_cft_gateway`
- `test_successful_visa_credit_on_cft_gateway`
These tests all result in error messages of `"Security violation"`, so
it's possible that the current credentials are not allowed to run
`credit` transactions.
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/worldpay.rb | 3 ++-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 7cf4e6f6c1d..4c73c7c229a 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -17,6 +17,7 @@
* Barclaycard Smartpay: Add app based 3DS requests for auth and purchase [britth] #3327
* Stripe Payment Intents, Checkout V2: Add support for `MOTO` flagging [britth] #3323
* Global Collect: Add Cabal card [leila-alderman] #3310
+* WorldPay: Add Cabal card [leila-alderman] #3316
== Version 1.97.0 (Aug 15, 2019)
* CyberSource: Add issuer `additionalData` gateway-specific field [jasonxp] #3296
diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb
index e020e2d0b64..bb2ec55a3b5 100644
--- a/lib/active_merchant/billing/gateways/worldpay.rb
+++ b/lib/active_merchant/billing/gateways/worldpay.rb
@@ -7,7 +7,7 @@ class WorldpayGateway < Gateway
self.default_currency = 'GBP'
self.money_format = :cents
self.supported_countries = %w(HK GB AU AD AR BE BR CA CH CN CO CR CY CZ DE DK ES FI FR GI GR HU IE IN IT JP LI LU MC MT MY MX NL NO NZ PA PE PL PT SE SG SI SM TR UM VA)
- self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :maestro, :elo, :naranja]
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :maestro, :elo, :naranja, :cabal]
self.currencies_without_fractions = %w(HUF IDR ISK JPY KRW)
self.currencies_with_three_decimal_places = %w(BHD KWD OMR RSD TND)
self.homepage_url = 'http://www.worldpay.com/'
@@ -23,6 +23,7 @@ class WorldpayGateway < Gateway
'diners_club' => 'DINERS-SSL',
'elo' => 'ELO-SSL',
'naranja' => 'NARANJA-SSL',
+ 'cabal' => 'CABAL-SSL',
'unknown' => 'CARD-SSL'
}
From 487399bdd34237cef18075bf24a167c10544eb77 Mon Sep 17 00:00:00 2001
From: leila-alderman
Date: Tue, 3 Sep 2019 09:48:14 -0400
Subject: [PATCH 0431/2234] Decidir: Add Cabal card
Adds the Cabal card type to the Decidir gateway.
With our current test gateway implementation, it does not seem possible
to test Cabal cards. When attempting to run a remote test with a Cabal
test card number, the error message states that the request contains an
invalid BIN (first 6 digits of the card number). Therefore, the addition
of Cabal cards has not been tested on the Decidir gateway.
CE-94 / CE-100
Unit:
22 tests, 112 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
Remote:
17 tests, 60 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/decidir.rb | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 4c73c7c229a..3436046a5d3 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -18,6 +18,7 @@
* Stripe Payment Intents, Checkout V2: Add support for `MOTO` flagging [britth] #3323
* Global Collect: Add Cabal card [leila-alderman] #3310
* WorldPay: Add Cabal card [leila-alderman] #3316
+* Decidir: Add Cabal card [leila-alderman] #3322
== Version 1.97.0 (Aug 15, 2019)
* CyberSource: Add issuer `additionalData` gateway-specific field [jasonxp] #3296
diff --git a/lib/active_merchant/billing/gateways/decidir.rb b/lib/active_merchant/billing/gateways/decidir.rb
index 56233db4e43..550d6bdb49e 100644
--- a/lib/active_merchant/billing/gateways/decidir.rb
+++ b/lib/active_merchant/billing/gateways/decidir.rb
@@ -7,7 +7,7 @@ class DecidirGateway < Gateway
self.supported_countries = ['AR']
self.money_format = :cents
self.default_currency = 'ARS'
- self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :naranja]
+ self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :naranja, :cabal]
self.homepage_url = 'http://www.decidir.com'
self.display_name = 'Decidir'
From 5e46ebd38b5577dc4feaf575c9659eeb1eddf327 Mon Sep 17 00:00:00 2001
From: leila-alderman
Date: Tue, 3 Sep 2019 11:41:41 -0400
Subject: [PATCH 0432/2234] PayU Latam: Add Cabal card
Adds the Cabal card to the PayU Latam gateway, including adding new
remote and unit tests.
CE-94 / CE-101
Unit:
31 tests, 117 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
Remote:
33 tests, 80 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/payu_latam.rb | 5 +-
.../remote/gateways/remote_payu_latam_test.rb | 22 +++++
test/unit/gateways/payu_latam_test.rb | 82 +++++++++++++++++++
4 files changed, 108 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 3436046a5d3..e74c2047189 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -19,6 +19,7 @@
* Global Collect: Add Cabal card [leila-alderman] #3310
* WorldPay: Add Cabal card [leila-alderman] #3316
* Decidir: Add Cabal card [leila-alderman] #3322
+* PayU Latam: Add Cabal card [leila-alderman] #3324
== Version 1.97.0 (Aug 15, 2019)
* CyberSource: Add issuer `additionalData` gateway-specific field [jasonxp] #3296
diff --git a/lib/active_merchant/billing/gateways/payu_latam.rb b/lib/active_merchant/billing/gateways/payu_latam.rb
index 56c7e64f0d4..aef7ea42e89 100644
--- a/lib/active_merchant/billing/gateways/payu_latam.rb
+++ b/lib/active_merchant/billing/gateways/payu_latam.rb
@@ -12,14 +12,15 @@ class PayuLatamGateway < Gateway
self.supported_countries = ['AR', 'BR', 'CL', 'CO', 'MX', 'PA', 'PE']
self.default_currency = 'USD'
self.money_format = :dollars
- self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :naranja]
+ self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :naranja, :cabal]
BRAND_MAP = {
'visa' => 'VISA',
'master' => 'MASTERCARD',
'american_express' => 'AMEX',
'diners_club' => 'DINERS',
- 'naranja' => 'NARANJA'
+ 'naranja' => 'NARANJA',
+ 'cabal' => 'CABAL'
}
MINIMUMS = {
diff --git a/test/remote/gateways/remote_payu_latam_test.rb b/test/remote/gateways/remote_payu_latam_test.rb
index e9f02d78ddc..e78fd67fffa 100644
--- a/test/remote/gateways/remote_payu_latam_test.rb
+++ b/test/remote/gateways/remote_payu_latam_test.rb
@@ -9,6 +9,8 @@ def setup
@declined_card = credit_card('4097440000000004', verification_value: '444', first_name: 'REJECTED', last_name: '')
@pending_card = credit_card('4097440000000004', verification_value: '444', first_name: 'PENDING', last_name: '')
@naranja_credit_card = credit_card('5895620000000002', :verification_value => '123', :first_name => 'APPROVED', :last_name => '', :brand => 'naranja')
+ @cabal_credit_card = credit_card('5896570000000004', :verification_value => '123', :first_name => 'APPROVED', :last_name => '', :brand => 'cabal')
+ @invalid_cabal_card = credit_card('6271700000000000', :verification_value => '123', :first_name => 'APPROVED', :last_name => '', :brand => 'cabal')
@options = {
dni_number: '5415668464654',
@@ -58,6 +60,13 @@ def test_successful_purchase_with_naranja_card
assert response.test?
end
+ def test_successful_purchase_with_cabal_card
+ response = @gateway.purchase(@amount, @cabal_credit_card, @options)
+ assert_success response
+ assert_equal 'APPROVED', response.message
+ assert response.test?
+ end
+
def test_successful_purchase_with_specified_language
response = @gateway.purchase(@amount, @credit_card, @options.merge(language: 'es'))
assert_success response
@@ -221,6 +230,12 @@ def test_failed_purchase
assert_equal 'DECLINED', response.params['transactionResponse']['state']
end
+ def test_failed_purchase_with_cabal_card
+ response = @gateway.purchase(@amount, @invalid_cabal_card, @options)
+ assert_failure response
+ assert_equal 'DECLINED', response.params['transactionResponse']['state']
+ end
+
def test_failed_purchase_with_no_options
response = @gateway.purchase(@amount, @declined_card, {})
assert_failure response
@@ -248,6 +263,13 @@ def test_successful_authorize_with_naranja_card
assert_match %r(^\d+\|(\w|-)+$), response.authorization
end
+ def test_successful_authorize_with_cabal_card
+ response = @gateway.authorize(@amount, @cabal_credit_card, @options)
+ assert_success response
+ assert_equal 'APPROVED', response.message
+ assert_match %r(^\d+\|(\w|-)+$), response.authorization
+ end
+
def test_successful_authorize_with_specified_language
response = @gateway.authorize(@amount, @credit_card, @options.merge(language: 'es'))
assert_success response
diff --git a/test/unit/gateways/payu_latam_test.rb b/test/unit/gateways/payu_latam_test.rb
index d2c0dbf28c5..d4ea5d0664e 100644
--- a/test/unit/gateways/payu_latam_test.rb
+++ b/test/unit/gateways/payu_latam_test.rb
@@ -12,6 +12,7 @@ def setup
@pending_card = credit_card('4097440000000004', verification_value: '222', first_name: 'PENDING', last_name: '')
@no_cvv_visa_card = credit_card('4097440000000004', verification_value: ' ')
@no_cvv_amex_card = credit_card('4097440000000004', verification_value: ' ', brand: 'american_express')
+ @cabal_credit_card = credit_card('5896570000000004', :verification_value => '123', :first_name => 'APPROVED', :last_name => '', :brand => 'cabal')
@options = {
dni_number: '5415668464654',
@@ -57,6 +58,15 @@ def test_successful_purchase_with_specified_language
end.respond_with(successful_purchase_response)
end
+ def test_successful_purchase_with_cabal_card
+ @gateway.expects(:ssl_post).returns(successful_purchase_with_cabal_response)
+
+ response = @gateway.purchase(@amount, @cabal_credit_card, @options)
+ assert_success response
+ assert_equal 'APPROVED', response.message
+ assert response.test?
+ end
+
def test_failed_purchase
@gateway.expects(:ssl_post).returns(failed_purchase_response)
@@ -83,6 +93,15 @@ def test_successful_authorize_with_specified_language
end.respond_with(successful_purchase_response)
end
+ def test_successful_authorize_with_cabal_card
+ @gateway.expects(:ssl_post).returns(successful_authorize_with_cabal_response)
+
+ response = @gateway.authorize(@amount, @cabal_credit_card, @options)
+ assert_success response
+ assert_equal 'APPROVED', response.message
+ assert_match %r(^\d+\|(\w|-)+$), response.authorization
+ end
+
def test_failed_authorize
@gateway.expects(:ssl_post).returns(pending_authorize_response)
@@ -461,6 +480,37 @@ def successful_purchase_response
RESPONSE
end
+ def successful_purchase_with_cabal_response
+ <<-RESPONSE
+ {
+ "code":"SUCCESS",
+ "error":null,
+ "transactionResponse": {
+ "orderId":846449068,
+ "transactionId":"34fa1616-f16c-4474-98dc-6163cb05f6d1",
+ "state":"APPROVED",
+ "paymentNetworkResponseCode":null,
+ "paymentNetworkResponseErrorMessage":null,
+ "trazabilityCode":"00000000",
+ "authorizationCode":"00000000",
+ "pendingReason":null,
+ "responseCode":"APPROVED",
+ "errorCode":null,
+ "responseMessage":null,
+ "transactionDate":null,
+ "transactionTime":null,
+ "operationDate":1567524354749,
+ "referenceQuestionnaire":null,
+ "extraParameters": {
+ "PAYMENT_WAY_ID":"28",
+ "BANK_REFERENCED_CODE":"DEBIT"
+ },
+ "additionalInfo":null
+ }
+ }
+ RESPONSE
+ end
+
def failed_purchase_response
<<-RESPONSE
{
@@ -514,6 +564,38 @@ def successful_authorize_response
RESPONSE
end
+ def successful_authorize_with_cabal_response
+ <<-RESPONSE
+ {
+ "code":"SUCCESS",
+ "error":null,
+ "transactionResponse": {
+ "orderId":846449155,
+ "transactionId":"c15e6015-87c2-4db9-9100-894bf5564330",
+ "state":"APPROVED",
+ "paymentNetworkResponseCode":null,
+ "paymentNetworkResponseErrorMessage":null,
+ "trazabilityCode":"00000000",
+ "authorizationCode":"00000000",
+ "pendingReason":null,
+ "responseCode":"APPROVED",
+ "errorCode":null,
+ "responseMessage":null,
+ "transactionDate":null,
+ "transactionTime":null,
+ "operationDate":1567524806987,
+ "referenceQuestionnaire":null,
+ "extraParameters": {
+ "PAYMENT_WAY_ID":"28",
+ "BANK_REFERENCED_CODE":"DEBIT"
+ },
+ "additionalInfo":null
+ }
+ }
+
+ RESPONSE
+ end
+
def pending_authorize_response
<<-RESPONSE
{
From 32f5a2c83a30b9d05dd9e27de16edc80a49dcf07 Mon Sep 17 00:00:00 2001
From: leila-alderman
Date: Tue, 3 Sep 2019 12:23:48 -0400
Subject: [PATCH 0433/2234] dLocal: Add Cabal card
Adds the Cabal card type to the dLocal gateway, including adding remote
tests to confirm that Cabal cards work on this gateway. The remote tests
include a failed purchase test to ensure that dLocal is validating the
test card.
CE-94 / CE-102
Unit:
17 tests, 67 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
Remote:
26 tests, 72 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/d_local.rb | 2 +-
test/remote/gateways/remote_d_local_test.rb | 30 +++++++++++++++++++
3 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index e74c2047189..e611549980a 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -20,6 +20,7 @@
* WorldPay: Add Cabal card [leila-alderman] #3316
* Decidir: Add Cabal card [leila-alderman] #3322
* PayU Latam: Add Cabal card [leila-alderman] #3324
+* dLocal: Add Cabal card [leila-alderman] #3325
== Version 1.97.0 (Aug 15, 2019)
* CyberSource: Add issuer `additionalData` gateway-specific field [jasonxp] #3296
diff --git a/lib/active_merchant/billing/gateways/d_local.rb b/lib/active_merchant/billing/gateways/d_local.rb
index 8f639449404..19739582f00 100644
--- a/lib/active_merchant/billing/gateways/d_local.rb
+++ b/lib/active_merchant/billing/gateways/d_local.rb
@@ -6,7 +6,7 @@ class DLocalGateway < Gateway
self.supported_countries = ['AR', 'BR', 'CL', 'CO', 'MX', 'PE', 'UY', 'TR']
self.default_currency = 'USD'
- self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners_club, :maestro, :naranja]
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners_club, :maestro, :naranja, :cabal]
self.homepage_url = 'https://dlocal.com/'
self.display_name = 'dLocal'
diff --git a/test/remote/gateways/remote_d_local_test.rb b/test/remote/gateways/remote_d_local_test.rb
index 865257401fa..2dc9708d940 100644
--- a/test/remote/gateways/remote_d_local_test.rb
+++ b/test/remote/gateways/remote_d_local_test.rb
@@ -7,6 +7,8 @@ def setup
@amount = 200
@credit_card = credit_card('4111111111111111')
@credit_card_naranja = credit_card('5895627823453005')
+ @cabal_credit_card = credit_card('5896 5700 0000 0004')
+ @invalid_cabal_card = credit_card('6035 2277 0000 0000')
# No test card numbers, all txns are approved by default,
# but errors can be invoked directly with the `description` field
@options = {
@@ -48,6 +50,12 @@ def test_successful_purchase_naranja
assert_match 'The payment was paid', response.message
end
+ def test_successful_purchase_cabal
+ response = @gateway.purchase(@amount, @cabal_credit_card, @options)
+ assert_success response
+ assert_match 'The payment was paid', response.message
+ end
+
def test_successful_purchase_with_more_options
options = @options.merge(
order_id: '1',
@@ -95,6 +103,12 @@ def test_failed_purchase
assert_match 'The payment was rejected', response.message
end
+ def test_failed_purchase_with_cabal
+ response = @gateway.purchase(@amount, @invalid_cabal_card, @options)
+ assert_failure response
+ assert_match 'Payment not found', response.message
+ end
+
def test_failed_document_format
response = @gateway.purchase(@amount, @credit_card, @options.merge(document: 'bad_document'))
assert_failure response
@@ -111,6 +125,16 @@ def test_successful_authorize_and_capture
assert_match 'The payment was paid', capture.message
end
+ def test_successful_authorize_and_capture_with_cabal
+ auth = @gateway.authorize(@amount, @cabal_credit_card, @options)
+ assert_success auth
+ assert_match 'The payment was authorized', auth.message
+
+ assert capture = @gateway.capture(@amount, auth.authorization, @options)
+ assert_success capture
+ assert_match 'The payment was paid', capture.message
+ end
+
def test_failed_authorize
response = @gateway.authorize(@amount, @credit_card, @options.merge(description: '309'))
assert_failure response
@@ -187,6 +211,12 @@ def test_successful_verify
assert_match %r{The payment was authorized}, response.message
end
+ def test_successful_verify_with_cabal
+ response = @gateway.verify(@cabal_credit_card, @options)
+ assert_success response
+ assert_match %r{The payment was authorized}, response.message
+ end
+
def test_failed_verify
response = @gateway.verify(@credit_card, @options.merge(description: '315'))
assert_failure response
From c1c3fa499727edfc3f94ef97d9030078f487a9a4 Mon Sep 17 00:00:00 2001
From: leila-alderman
Date: Tue, 3 Sep 2019 12:54:32 -0400
Subject: [PATCH 0434/2234] BlueSnap: Add Cabal card
Adds the Cabal card type to the BlueSnap gateway.
I have been able to successfully add a remote test for a failed purchase
transaction made with an invalid Cabal card; however, when I try to run
a remote test for a successful purchase with a Cabal card, I receive the
error message "Transaction failed because there are no available
processors." (error code 14016). According to the [BlueSnap documentation](https://developers.bluesnap.com/v8976-JSON/docs/card-transaction-errors),
resolving this error requires contacting BlueSnap Support.
BlueSnap provides a [Cabal test card number](https://developers.bluesnap.com/docs/test-credit-cards)
in their docs, so it seems that Cabal needs to enabled on our test
gateway in order to test Cabal on this gateway.
CE-94 / CE-103
Unit:
27 tests, 110 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
Remote:
36 tests, 112 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/blue_snap.rb | 2 +-
test/remote/gateways/remote_blue_snap_test.rb | 9 +++++++++
3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index e611549980a..e6d6a224e39 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -21,6 +21,7 @@
* Decidir: Add Cabal card [leila-alderman] #3322
* PayU Latam: Add Cabal card [leila-alderman] #3324
* dLocal: Add Cabal card [leila-alderman] #3325
+* BlueSnap: Add Cabal card [leila-alderman] #3326
== Version 1.97.0 (Aug 15, 2019)
* CyberSource: Add issuer `additionalData` gateway-specific field [jasonxp] #3296
diff --git a/lib/active_merchant/billing/gateways/blue_snap.rb b/lib/active_merchant/billing/gateways/blue_snap.rb
index b710e55b891..b344749b2d4 100644
--- a/lib/active_merchant/billing/gateways/blue_snap.rb
+++ b/lib/active_merchant/billing/gateways/blue_snap.rb
@@ -8,7 +8,7 @@ class BlueSnapGateway < Gateway
self.supported_countries = %w(US CA GB AT BE BG HR CY CZ DK EE FI FR DE GR HU IE IT LV LT LU MT NL PL PT RO SK SI ES SE AR BO BR BZ CL CO CR DO EC GF GP GT HN HT MF MQ MX NI PA PE PR PY SV UY VE)
self.default_currency = 'USD'
- self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners_club, :maestro, :naranja]
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners_club, :maestro, :naranja, :cabal]
self.homepage_url = 'https://home.bluesnap.com/'
self.display_name = 'BlueSnap'
diff --git a/test/remote/gateways/remote_blue_snap_test.rb b/test/remote/gateways/remote_blue_snap_test.rb
index bdbf9fba078..da9bf2c2ce1 100644
--- a/test/remote/gateways/remote_blue_snap_test.rb
+++ b/test/remote/gateways/remote_blue_snap_test.rb
@@ -6,10 +6,12 @@ def setup
@amount = 100
@credit_card = credit_card('4263982640269299')
+ @cabal_credit_card = credit_card('6271701225979642')
@declined_card = credit_card('4917484589897107', month: 1, year: 2023)
@invalid_card = credit_card('4917484589897106', month: 1, year: 2023)
@three_ds_visa_card = credit_card('4000000000001091', month: 1)
@three_ds_master_card = credit_card('5200000000001096', month: 1)
+ @invalid_cabal_card = credit_card('5896 5700 0000 0000', month: 1, year: 2023)
@options = { billing_address: address }
@options_3ds2 = @options.merge(
@@ -157,6 +159,13 @@ def test_failed_purchase
assert_equal '14002', response.error_code
end
+ def test_failed_purchase_with_invalid_cabal_card
+ response = @gateway.purchase(@amount, @invalid_cabal_card, @options)
+ assert_failure response
+ assert_match(/'Card Number' should be a valid Credit Card/, response.message)
+ assert_equal '10001', response.error_code
+ end
+
def test_cvv_result
response = @gateway.purchase(@amount, @credit_card, @options)
assert_success response
From b7375014c292e351e97529d38473a9f945f0e3cc Mon Sep 17 00:00:00 2001
From: molbrown
Date: Wed, 4 Sep 2019 16:33:16 -0400
Subject: [PATCH 0435/2234] Add entry to CHANGELOG for #3328
---
CHANGELOG | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG b/CHANGELOG
index e6d6a224e39..23ccdc0122e 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -16,6 +16,7 @@
* BlueSnap: add standardized 3DS 2 auth fields [bayprogrammer] #3318
* Barclaycard Smartpay: Add app based 3DS requests for auth and purchase [britth] #3327
* Stripe Payment Intents, Checkout V2: Add support for `MOTO` flagging [britth] #3323
+* Braintree Blue: Adding 3DS2 passthru support [molbrown] #3328
* Global Collect: Add Cabal card [leila-alderman] #3310
* WorldPay: Add Cabal card [leila-alderman] #3316
* Decidir: Add Cabal card [leila-alderman] #3322
From 341b53eb0b3a129808389c5b4f7714b6a80d06cd Mon Sep 17 00:00:00 2001
From: Rik ter Beek
Date: Wed, 4 Sep 2019 22:59:06 +0200
Subject: [PATCH 0436/2234] added 3ds authenticated data if provided (#3294)
* [WIP] added 3ds authenticated data if provided
* trans_status_ares could be null in frictionless flow then use transStatus from the ARes
* add empty lines
* Using new variables provided in three_d_secure response
---
lib/active_merchant/billing/gateways/adyen.rb | 39 +++++++++++++
test/remote/gateways/remote_adyen_test.rb | 58 ++++++++++++++++++-
test/unit/gateways/adyen_test.rb | 58 +++++++++++++++++++
3 files changed, 154 insertions(+), 1 deletion(-)
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index 75253e6fd6f..56826eeda98 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -56,6 +56,7 @@ def authorize(money, payment, options={})
add_address(post, options)
add_installments(post, options) if options[:installments]
add_3ds(post, options)
+ add_3ds_authenticated_data(post, options)
commit('authorise', post, options)
end
@@ -342,6 +343,44 @@ def add_3ds(post, options)
end
end
+ def add_3ds_authenticated_data(post, options)
+ if options[:three_d_secure] && options[:three_d_secure][:eci] && options[:three_d_secure][:xid]
+ add_3ds1_authenticated_data(post, options)
+ elsif options[:three_d_secure]
+ add_3ds2_authenticated_data(post, options)
+ end
+ end
+
+ def add_3ds1_authenticated_data(post, options)
+ three_d_secure_options = options[:three_d_secure]
+ post[:mpiData] = {
+ cavv: three_d_secure_options[:cavv],
+ cavvAlgorithm: three_d_secure_options[:cavv_algorithm],
+ eci: three_d_secure_options[:eci],
+ xid: three_d_secure_options[:xid],
+ directoryResponse: three_d_secure_options[:directory_response_status],
+ authenticationResponse: three_d_secure_options[:authentication_response_status]
+ }
+ end
+
+ def add_3ds2_authenticated_data(post, options)
+ three_d_secure_options = options[:three_d_secure]
+ # If the transaction was authenticated in a frictionless flow, send the transStatus from the ARes.
+ if(three_d_secure_options[:authentication_response_status].nil?)
+ authentication_response = three_d_secure_options[:directory_response_status]
+ else
+ authentication_response = three_d_secure_options[:authentication_response_status]
+ end
+ post[:mpiData] = {
+ threeDSVersion: three_d_secure_options[:version],
+ eci: three_d_secure_options[:eci],
+ cavv: three_d_secure_options[:cavv],
+ dsTransID: three_d_secure_options[:ds_transaction_id],
+ directoryResponse: three_d_secure_options[:directory_response_status],
+ authenticationResponse: authentication_response
+ }
+ end
+
def parse(body)
return {} if body.blank?
JSON.parse(body)
diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb
index 5cfc7ecb22f..584d9a1e96a 100644
--- a/test/remote/gateways/remote_adyen_test.rb
+++ b/test/remote/gateways/remote_adyen_test.rb
@@ -206,6 +206,62 @@ def test_successful_authorize_with_3ds_dynamic_rule_broken
assert_equal response.params['resultCode'], 'Authorised'
end
+ def test_successful_purchase_with_auth_data_via_threeds1_standalone
+ eci = '05'
+ cavv = '3q2+78r+ur7erb7vyv66vv\/\/\/\/8='
+ cavv_algorithm = '1'
+ xid = 'ODUzNTYzOTcwODU5NzY3Qw=='
+ directory_response_status = 'Y'
+ authentication_response_status = 'Y'
+ options = @options.merge(
+ three_d_secure: {
+ eci: eci,
+ cavv: cavv,
+ cavv_algorithm: cavv_algorithm,
+ xid: xid,
+ directory_response_status: directory_response_status,
+ authentication_response_status: authentication_response_status
+ }
+ )
+
+ auth = @gateway.authorize(@amount, @credit_card, options)
+ assert_success auth
+ assert_equal 'Authorised', auth.message
+ assert_equal 'true', auth.params['additionalData']['liabilityShift']
+
+ response = @gateway.purchase(@amount, @credit_card, options)
+ assert_success response
+ assert_equal '[capture-received]', response.message
+ end
+
+ def test_successful_purchase_with_auth_data_via_threeds2_standalone
+ version = '2.1.0'
+ eci = '02'
+ cavv = 'jJ81HADVRtXfCBATEp01CJUAAAA='
+ ds_transaction_id = '97267598-FAE6-48F2-8083-C23433990FBC'
+ directory_response_status = 'C'
+ authentication_response_status = 'Y'
+
+ options = @options.merge(
+ three_d_secure: {
+ version: version,
+ eci: eci,
+ cavv: cavv,
+ ds_transaction_id: ds_transaction_id,
+ directory_response_status: directory_response_status,
+ authentication_response_status: authentication_response_status
+ }
+ )
+
+ auth = @gateway.authorize(@amount, @credit_card, options)
+ assert_success auth
+ assert_equal 'Authorised', auth.message
+ assert_equal 'true', auth.params['additionalData']['liabilityShift']
+
+ response = @gateway.purchase(@amount, @credit_card, options)
+ assert_success response
+ end
+
def test_successful_authorize_with_no_address
options = {
reference: '345123',
@@ -453,7 +509,7 @@ def test_failed_synchronous_adjust_using_adjust_data
assert_success authorize
options = @options.merge(adjust_authorisation_data: authorize.params['additionalData']['adjustAuthorisationData'],
- requested_test_acquirer_response_code: '2')
+ requested_test_acquirer_response_code: '2')
assert adjust = @gateway.adjust(200, authorize.authorization, options)
assert_failure adjust
assert_equal 'Refused', adjust.message
diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb
index d38e33fafc0..976cedc73b5 100644
--- a/test/unit/gateways/adyen_test.rb
+++ b/test/unit/gateways/adyen_test.rb
@@ -130,6 +130,64 @@ def test_successful_authorize_with_3ds
refute response.params['paRequest'].blank?
end
+ def test_adds_3ds1_standalone_fields
+ eci = '05'
+ cavv = '3q2+78r+ur7erb7vyv66vv\/\/\/\/8='
+ cavv_algorithm = '1'
+ xid = 'ODUzNTYzOTcwODU5NzY3Qw=='
+ directory_response_status = 'C'
+ authentication_response_status = 'Y'
+ options_with_3ds1_standalone = @options.merge(
+ three_d_secure: {
+ eci: eci,
+ cavv: cavv,
+ cavv_algorithm: cavv_algorithm,
+ xid: xid,
+ directory_response_status: directory_response_status,
+ authentication_response_status: authentication_response_status
+ }
+ )
+ stub_comms do
+ @gateway.authorize(@amount, @credit_card, options_with_3ds1_standalone)
+ end.check_request do |endpoint, data, headers|
+ assert_equal eci, JSON.parse(data)['mpiData']['eci']
+ assert_equal cavv, JSON.parse(data)['mpiData']['cavv']
+ assert_equal cavv_algorithm, JSON.parse(data)['mpiData']['cavvAlgorithm']
+ assert_equal xid, JSON.parse(data)['mpiData']['xid']
+ assert_equal directory_response_status, JSON.parse(data)['mpiData']['directoryResponse']
+ assert_equal authentication_response_status, JSON.parse(data)['mpiData']['authenticationResponse']
+ end.respond_with(successful_authorize_response)
+ end
+
+ def test_adds_3ds2_standalone_fields
+ version = '2.1.0'
+ eci = '02'
+ cavv = 'jJ81HADVRtXfCBATEp01CJUAAAA='
+ ds_transaction_id = '97267598-FAE6-48F2-8083-C23433990FBC'
+ directory_response_status = 'C'
+ authentication_response_status = 'Y'
+ options_with_3ds2_standalone = @options.merge(
+ three_d_secure: {
+ version: version,
+ eci: eci,
+ cavv: cavv,
+ ds_transaction_id: ds_transaction_id,
+ directory_response_status: directory_response_status,
+ authentication_response_status: authentication_response_status
+ }
+ )
+ stub_comms do
+ @gateway.authorize(@amount, @credit_card, options_with_3ds2_standalone)
+ end.check_request do |endpoint, data, headers|
+ assert_equal version, JSON.parse(data)['mpiData']['threeDSVersion']
+ assert_equal eci, JSON.parse(data)['mpiData']['eci']
+ assert_equal cavv, JSON.parse(data)['mpiData']['cavv']
+ assert_equal ds_transaction_id, JSON.parse(data)['mpiData']['dsTransID']
+ assert_equal directory_response_status, JSON.parse(data)['mpiData']['directoryResponse']
+ assert_equal authentication_response_status, JSON.parse(data)['mpiData']['authenticationResponse']
+ end.respond_with(successful_authorize_response)
+ end
+
def test_failed_authorize
@gateway.expects(:ssl_post).returns(failed_authorize_response)
From 988f103688675f7f890e9b01800da00464f5262b Mon Sep 17 00:00:00 2001
From: britth
Date: Wed, 4 Sep 2019 13:39:39 -0400
Subject: [PATCH 0437/2234] Worldpay: Exemption flagging
This PR adds the necessary fields to mark transactions as MOTO
by setting dynamicInteractionType to MOTO when the payment is
marked as a manual entry (requires configuration on the account
level to be able to use).
Remote:
51 tests, 217 assertions, 5 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
90.1961% passed
(5 failing tests preexist current branch changes)
Unit:
66 tests, 392 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/worldpay.rb | 5 +++++
test/remote/gateways/remote_worldpay_test.rb | 6 ++++++
3 files changed, 12 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index 23ccdc0122e..cb7908b1345 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -23,6 +23,7 @@
* PayU Latam: Add Cabal card [leila-alderman] #3324
* dLocal: Add Cabal card [leila-alderman] #3325
* BlueSnap: Add Cabal card [leila-alderman] #3326
+* Worldpay: Add support for MOTO flagging [britth] #3329
== Version 1.97.0 (Aug 15, 2019)
* CyberSource: Add issuer `additionalData` gateway-specific field [jasonxp] #3296
diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb
index bb2ec55a3b5..f5e74db9114 100644
--- a/lib/active_merchant/billing/gateways/worldpay.rb
+++ b/lib/active_merchant/billing/gateways/worldpay.rb
@@ -207,6 +207,7 @@ def build_authorization_request(money, payment_method, options)
if options[:instalments]
add_instalments_data(xml, options)
end
+ add_moto_flag(xml, options) if options.dig(:metadata, :manual_entry)
end
end
end
@@ -423,6 +424,10 @@ def add_instalments_data(xml, options)
end
end
+ def add_moto_flag(xml, options)
+ xml.tag! 'dynamicInteractionType', 'type' => 'MOTO'
+ end
+
def address_with_defaults(address)
address ||= {}
address.delete_if { |_, v| v.blank? }
diff --git a/test/remote/gateways/remote_worldpay_test.rb b/test/remote/gateways/remote_worldpay_test.rb
index c93542ce7bd..2d09cf5e4ab 100644
--- a/test/remote/gateways/remote_worldpay_test.rb
+++ b/test/remote/gateways/remote_worldpay_test.rb
@@ -144,6 +144,12 @@ def test_successful_authorize_with_3ds
refute first_message.params['session_id'].blank?
end
+ # Requires additional account configuration to proceed successfully
+ def test_marking_3ds_purchase_as_moto
+ assert response = @gateway.purchase(@amount, @credit_card, @options.merge(metadata: { manual_entry: true }))
+ assert_equal 'AllowDynamicInteractionType property is disabled for this merchant', response.message
+ end
+
def test_successful_auth_and_capture_with_normalized_stored_credential
stored_credential_params = {
initial_transaction: true,
From 8564b107b503a333a8b2621ea944760a1f92b9a8 Mon Sep 17 00:00:00 2001
From: Allan Wamming Lie
Date: Mon, 9 Sep 2019 16:36:57 +0200
Subject: [PATCH 0438/2234] Bambora Online ePay: 3DS support (#3321)
---
lib/active_merchant/billing/gateways/epay.rb | 15 +++-
test/remote/gateways/remote_epay_test.rb | 86 +++++++++++++++-----
test/unit/gateways/epay_test.rb | 25 ++++++
3 files changed, 102 insertions(+), 24 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/epay.rb b/lib/active_merchant/billing/gateways/epay.rb
index 4f33ae1afe8..6b34708e816 100644
--- a/lib/active_merchant/billing/gateways/epay.rb
+++ b/lib/active_merchant/billing/gateways/epay.rb
@@ -63,6 +63,7 @@ def authorize(money, credit_card_or_reference, options = {})
add_invoice(post, options)
add_creditcard_or_reference(post, credit_card_or_reference)
add_instant_capture(post, false)
+ add_3ds_auth(post, options)
commit(:authorize, post)
end
@@ -74,6 +75,7 @@ def purchase(money, credit_card_or_reference, options = {})
add_creditcard_or_reference(post, credit_card_or_reference)
add_invoice(post, options)
add_instant_capture(post, true)
+ add_3ds_auth(post, options)
commit(:authorize, post)
end
@@ -158,6 +160,16 @@ def add_instant_capture(post, option)
post[:instantcapture] = option ? 1 : 0
end
+ def add_3ds_auth(post, options)
+ if options[:three_d_secure]
+ post[:eci] = options.dig(:three_d_secure, :eci)
+ post[:xid] = options.dig(:three_d_secure, :xid)
+ post[:cavv] = options.dig(:three_d_secure, :cavv)
+ post[:threeds_version] = options.dig(:three_d_secure, :version)
+ post[:ds_transaction_id] = options.dig(:three_d_secure, :ds_transaction_id)
+ end
+ end
+
def commit(action, params)
response = send("do_#{action}", params)
@@ -193,7 +205,6 @@ def do_authorize(params)
headers['Referer'] = (options[:password] || 'activemerchant.org')
response = raw_ssl_request(:post, live_url + 'auth/default.aspx', authorize_post_data(params), headers)
-
# Authorize gives the response back by redirecting with the values in
# the URL query
if location = response['Location']
@@ -268,7 +279,7 @@ def xml_builder(params, soap_call)
def authorize_post_data(params = {})
params[:language] = '2'
- params[:cms] = 'activemerchant'
+ params[:cms] = 'activemerchant_3ds'
params[:accepturl] = live_url + 'auth/default.aspx?accept=1'
params[:declineurl] = live_url + 'auth/default.aspx?decline=1'
params[:merchantnumber] = @options[:login]
diff --git a/test/remote/gateways/remote_epay_test.rb b/test/remote/gateways/remote_epay_test.rb
index 3cde00ce108..9c900098697 100644
--- a/test/remote/gateways/remote_epay_test.rb
+++ b/test/remote/gateways/remote_epay_test.rb
@@ -5,23 +5,22 @@ def setup
Base.mode = :test
@gateway = EpayGateway.new(fixtures(:epay))
-
@credit_card = credit_card('3333333333333000')
@credit_card_declined = credit_card('3333333333333102')
-
@amount = 100
- @options = {order_id: '1'}
+ @options_xid = {order_id: '1', three_d_secure: { eci: '7', xid: '123', cavv: '456', version: '2', ds_transaction_id: nil }}
+ @options_ds_transaction_id = {order_id: '1', three_d_secure: { eci: '7', xid: nil, cavv: '456', version: '2', ds_transaction_id: '798' }}
end
- def test_successful_purchase
- response = @gateway.purchase(@amount, @credit_card, @options)
+ def test_successful_purchase_xid
+ response = @gateway.purchase(@amount, @credit_card, @options_xid)
assert_success response
assert !response.authorization.blank?
assert response.test?
end
- def test_successful_authorize_and_capture
- response = @gateway.authorize(@amount, @credit_card, @options)
+ def test_successful_authorize_and_capture_xid
+ response = @gateway.authorize(@amount, @credit_card, @options_xid)
assert_success response
assert !response.authorization.blank?
@@ -29,44 +28,87 @@ def test_successful_authorize_and_capture
assert_success capture_response
end
- def test_failed_authorization
- response = @gateway.authorize(@amount, @credit_card_declined, @options)
- assert_failure response
- end
-
- def test_failed_purchase
- response = @gateway.purchase(@amount, @credit_card_declined, @options)
+ def test_failed_authorization_xid
+ response = @gateway.authorize(@amount, @credit_card_declined, @options_xid)
assert_failure response
end
- def test_failed_capture
- response = @gateway.capture(@amount, 0)
+ def test_failed_purchase_xid
+ response = @gateway.purchase(@amount, @credit_card_declined, @options_xid)
assert_failure response
end
- def test_successful_refund
- response = @gateway.purchase(@amount, @credit_card, @options)
+ def test_successful_refund_xid
+ response = @gateway.purchase(@amount, @credit_card, @options_xid)
assert_success response
refund_response = @gateway.refund(@amount, response.authorization)
assert_success refund_response
end
- def test_failed_refund
- response = @gateway.refund(@amount, 0)
+ def test_successful_void_xid
+ response = @gateway.authorize(@amount, @credit_card, @options_xid)
+ assert_success response
+
+ void_response = @gateway.void(response.authorization)
+ assert_success void_response
+ end
+
+ def test_successful_purchase_ds_transaction_id
+ response = @gateway.purchase(@amount, @credit_card, @options_ds_transaction_id)
+ assert_success response
+ assert !response.authorization.blank?
+ assert response.test?
+ end
+
+ def test_successful_authorize_and_capture_ds_transaction_id
+ response = @gateway.authorize(@amount, @credit_card, @options_ds_transaction_id)
+ assert_success response
+ assert !response.authorization.blank?
+
+ capture_response = @gateway.capture(@amount, response.authorization)
+ assert_success capture_response
+ end
+
+ def test_failed_authorization_ds_transaction_id
+ response = @gateway.authorize(@amount, @credit_card_declined, @options_ds_transaction_id)
+ assert_failure response
+ end
+
+ def test_failed_purchase_ds_transaction_id
+ response = @gateway.purchase(@amount, @credit_card_declined, @options_ds_transaction_id)
assert_failure response
end
- def test_successful_void
- response = @gateway.authorize(@amount, @credit_card, @options)
+ def test_successful_refund_ds_transaction_id
+ response = @gateway.purchase(@amount, @credit_card, @options_ds_transaction_id)
+ assert_success response
+
+ refund_response = @gateway.refund(@amount, response.authorization)
+ assert_success refund_response
+ end
+
+ def test_successful_void_ds_transaction_id
+ response = @gateway.authorize(@amount, @credit_card, @options_ds_transaction_id)
assert_success response
void_response = @gateway.void(response.authorization)
assert_success void_response
end
+ def test_failed_capture
+ response = @gateway.capture(@amount, 0)
+ assert_failure response
+ end
+
+ def test_failed_refund
+ response = @gateway.refund(@amount, 0)
+ assert_failure response
+ end
+
def test_failed_void
response = @gateway.void(0)
assert_failure response
end
+
end
diff --git a/test/unit/gateways/epay_test.rb b/test/unit/gateways/epay_test.rb
index 59becd05499..c232cc16661 100644
--- a/test/unit/gateways/epay_test.rb
+++ b/test/unit/gateways/epay_test.rb
@@ -10,6 +10,7 @@ def setup
)
@credit_card = credit_card
+ @options = {three_d_secure: { eci: '7', xid: '123', cavv: '456', version: '2', ds_transaction_id: '798' }}
end
def test_successful_purchase
@@ -29,6 +30,22 @@ def test_failed_purchase
response.message
end
+ def test_successful_3ds_purchase
+ @gateway.expects(:raw_ssl_request).returns(valid_authorize_3ds_response)
+
+ assert response = @gateway.authorize(100, @credit_card, @options)
+ assert_success response
+ assert_equal '123', response.authorization
+ end
+
+ def test_failed_3ds_purchase
+ @gateway.expects(:raw_ssl_request).returns(invalid_authorize_3ds_response)
+
+ assert response = @gateway.authorize(100, @credit_card, @options)
+ assert_success response
+ assert_equal '123', response.authorization
+ end
+
def test_invalid_characters_in_response
@gateway.expects(:raw_ssl_request).returns(invalid_authorize_response_with_invalid_characters)
@@ -132,6 +149,14 @@ def invalid_authorize_response_with_invalid_characters
{ 'Location' => 'https://ssl.ditonlinebetalingssystem.dk/auth/default.aspx?decline=1&error=209&errortext=The payment was declined of unknown reasons. For more information contact the bank. E.g. try with another credit card.
Denied - Call your bank for information' }
end
+ def valid_authorize_3ds_response
+ { 'Location' => 'https://ssl.ditonlinebetalingssystem.dk/auth/default.aspx?accept=1&tid=123&&amount=100&cur=208&date=20101117&time=2357&cardnopostfix=3000&fraud=1&cardid=18&transfee=0&eci=7&xci=123&cavv=456&threeds_version=2&ds_transaction_id=798' }
+ end
+
+ def invalid_authorize_3ds_response
+ { 'Location' => 'https://ssl.ditonlinebetalingssystem.dk/auth/default.aspx?accept=1&tid=123&&amount=100&cur=208&date=20101117&time=2357&cardnopostfix=3000&fraud=1&cardid=18&transfee=0&eci=5&xci=1234&cavv=3456&threeds_version=1&ds_transaction_id=6798' }
+ end
+
def valid_capture_response
'true0-1'
end
From 9e40fbac831e29282074e7393dc108dd0ac4e1a6 Mon Sep 17 00:00:00 2001
From: Filipe Costa
Date: Mon, 9 Sep 2019 10:58:16 -0400
Subject: [PATCH 0439/2234] [Checkout.com] Using options[:moto] for Moto
transactions (#3330)
---
lib/active_merchant/billing/gateways/checkout_v2.rb | 2 +-
test/remote/gateways/remote_checkout_v2_test.rb | 7 +++++++
test/unit/gateways/checkout_v2_test.rb | 13 +++++++++++++
3 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/lib/active_merchant/billing/gateways/checkout_v2.rb b/lib/active_merchant/billing/gateways/checkout_v2.rb
index 0f916158a22..ea9a4c88393 100644
--- a/lib/active_merchant/billing/gateways/checkout_v2.rb
+++ b/lib/active_merchant/billing/gateways/checkout_v2.rb
@@ -128,7 +128,7 @@ def add_customer_data(post, options)
def add_transaction_data(post, options = {})
post[:payment_type] = 'Regular' if options[:transaction_indicator] == 1
post[:payment_type] = 'Recurring' if options[:transaction_indicator] == 2
- post[:payment_type] = 'MOTO' if options[:transaction_indicator] == 3
+ post[:payment_type] = 'MOTO' if options[:transaction_indicator] == 3 || options.dig(:metadata, :manual_entry)
post[:previous_payment_id] = options[:previous_charge_id] if options[:previous_charge_id]
end
diff --git a/test/remote/gateways/remote_checkout_v2_test.rb b/test/remote/gateways/remote_checkout_v2_test.rb
index bec80aba153..fa02c0c3371 100644
--- a/test/remote/gateways/remote_checkout_v2_test.rb
+++ b/test/remote/gateways/remote_checkout_v2_test.rb
@@ -70,6 +70,13 @@ def test_successful_purchase_with_moto_flag
assert_equal 'Succeeded', response.message
end
+ def test_successful_purchase_with_manual_entry_flag
+ response = @gateway.authorize(@amount, @credit_card, @options.merge(metadata: { manual_entry: true}))
+
+ assert_success response
+ assert_equal 'Succeeded', response.message
+ end
+
def test_successful_purchase_includes_avs_result
response = @gateway.purchase(@amount, @credit_card, @options)
assert_success response
diff --git a/test/unit/gateways/checkout_v2_test.rb b/test/unit/gateways/checkout_v2_test.rb
index 0855d53da5b..141534eed8f 100644
--- a/test/unit/gateways/checkout_v2_test.rb
+++ b/test/unit/gateways/checkout_v2_test.rb
@@ -117,6 +117,19 @@ def test_successful_authorize_and_capture_with_additional_options
assert_success capture
end
+ def test_moto_transaction_is_properly_set
+ response = stub_comms do
+ options = {
+ metadata: { manual_entry: true}
+ }
+ @gateway.authorize(@amount, @credit_card, options)
+ end.check_request do |endpoint, data, headers|
+ assert_match(%r{"payment_type":"MOTO"}, data)
+ end.respond_with(successful_authorize_response)
+
+ assert_success response
+ end
+
def test_3ds_passed
response = stub_comms do
options = {
From b3af89f09c18d93d5837848b9907b94963cd6116 Mon Sep 17 00:00:00 2001
From: Filipe Costa
Date: Mon, 9 Sep 2019 11:11:51 -0400
Subject: [PATCH 0440/2234] Release v1.98.0
---
CHANGELOG | 8 ++++++--
lib/active_merchant/version.rb | 2 +-
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index cb7908b1345..1e17fa99fa6 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,13 +1,16 @@
= ActiveMerchant CHANGELOG
== HEAD
+== Version 1.98.0 (Sep 9, 2019)
* Stripe Payment Intents: Add new gateway [britth] #3290
* Stripe: Send cardholder name and address when creating sources for 3DS 1.0 [jknipp] #3300
* Checkout_v2: Support for native 3DS2.0 [nfarve] #3303
+* Adds new Maestro BINs [tanyajajodia] #3305
* eWAY Rapid: If no address is available, default to the name associated with the payment method when setting the Customer fields [jasonxp] #3306
* eWAY Rapid: Fix a bug in which the email was not set in Customer fields if no address was provided [jasonxp] #3306
* eWAY Rapid: Support both `phone` and `phone_number` fields under the `shipping_address` option [jasonxp] #3306
* PayU Latam: Add support for the `merchant_buyer_id` field in the `options` and `buyer` hashes [jasonxp] #3308
+* Update Braintree Gem [curiousepic] #3311
* Fat Zebra: Send metadata for purchase and authorize [montdidier] #3101
* TrustCommerce: Add support for custom fields [jasonxp] #3313
* Stripe Payment Intents: Support option fields `transfer_destination` and `transfer_amount` and remove `transfer_data` hash [britth] #3317
@@ -23,7 +26,10 @@
* PayU Latam: Add Cabal card [leila-alderman] #3324
* dLocal: Add Cabal card [leila-alderman] #3325
* BlueSnap: Add Cabal card [leila-alderman] #3326
+* Adyen: added 3DS support through external [rikterbeek] #3294
* Worldpay: Add support for MOTO flagging [britth] #3329
+* ePay: 3DS support [AllaWLie] #3321
+* Checkout.com: added options[:metadata][:manual_entry] support for MOTO transactions [filipebarcos] #3330
== Version 1.97.0 (Aug 15, 2019)
* CyberSource: Add issuer `additionalData` gateway-specific field [jasonxp] #3296
@@ -38,7 +44,6 @@
* Realex: Re-implement credit as general credit [leila-alderman] #3280
* Braintree Blue: Support for stored credentials [hdeters] #3286
* CardConnect: Move domain from gateway specific to gateway field [hdeters] #3283
-* Adds new Maestro BINs [tanyajajodia] #3305
== Version 1.96.0 (Jul 26, 2019)
* Bluesnap: Omit state codes for unsupported countries [therufs] #3229
@@ -202,7 +207,6 @@
* Payeezy: Add `stored_credentials` [nfarve] #3083
* Fix CVC validation for 0 length CVC [filipebarcos] #3082
* NMI: Supports vendor_id and processor_id fields [molbrown] #3085
-* Update Braintree Gem [curiousepic] #3311
== Version 1.88.0 (November 30, 2018)
* Added ActiveSupport/Rails master support [Edouard-chin] #3065
diff --git a/lib/active_merchant/version.rb b/lib/active_merchant/version.rb
index f01a6db39d8..dfc97b78ba4 100644
--- a/lib/active_merchant/version.rb
+++ b/lib/active_merchant/version.rb
@@ -1,3 +1,3 @@
module ActiveMerchant
- VERSION = '1.97.0'
+ VERSION = '1.98.0'
end
From fca5cadd8bbeab132c938dc28564937fa47244a2 Mon Sep 17 00:00:00 2001
From: britth
Date: Mon, 9 Sep 2019 15:44:41 -0400
Subject: [PATCH 0441/2234] Adyen: Set 3DS exemptions via API
There are a few different ways to request exemptions via Adyen.
Users can let Adyen handle compliance by default, they can
configure specific rules using dynamic 3dsecure, or they can set
exemption flags via the API. This PR updates the Adyen gateway to
allow users to set specific exemptions using the sca_exemption
field, used in conjunction with the execute_threed field. Users
can also now set execute_threed to false if they want to bypass
3DS on a transaction.
Remote:
66 tests, 213 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
96.9697% passed
(2 failures unrelated, related to standalone 3ds feature)
Unit:
47 tests, 228 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 2 +
lib/active_merchant/billing/gateways/adyen.rb | 5 ++
test/remote/gateways/remote_adyen_test.rb | 24 ++++++++-
test/unit/gateways/adyen_test.rb | 54 +++++++++++++++++++
4 files changed, 84 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 1e17fa99fa6..2819fb1ba7b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,8 @@
= ActiveMerchant CHANGELOG
== HEAD
+* Adyen: Add functionality to set 3DS exemptions via API [britth] #3331
+
== Version 1.98.0 (Sep 9, 2019)
* Stripe Payment Intents: Add new gateway [britth] #3290
* Stripe: Send cardholder name and address when creating sources for 3DS 1.0 [jknipp] #3300
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index 56826eeda98..3dcbee6efa0 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -336,6 +336,11 @@ def add_3ds(post, options)
add_browser_info(three_ds_2_options[:browser_info], post)
post[:threeDS2RequestData] = { deviceChannel: device_channel, notificationURL: three_ds_2_options[:notification_url] }
end
+
+ if options.has_key?(:execute_threed)
+ post[:additionalData][:executeThreeD] = options[:execute_threed]
+ post[:additionalData][:scaExemption] = options[:sca_exemption] if options[:sca_exemption]
+ end
else
return unless options[:execute_threed] || options[:threed_dynamic]
post[:browserInfo] = { userAgent: options[:user_agent], acceptHeader: options[:accept_header] }
diff --git a/test/remote/gateways/remote_adyen_test.rb b/test/remote/gateways/remote_adyen_test.rb
index 584d9a1e96a..3e964d29f3e 100644
--- a/test/remote/gateways/remote_adyen_test.rb
+++ b/test/remote/gateways/remote_adyen_test.rb
@@ -33,7 +33,7 @@ def setup
:brand => 'elo'
)
- @three_ds_enrolled_card = credit_card('4917610000000000', brand: :visa)
+ @three_ds_enrolled_card = credit_card('4917610000000000', month: 10, year: 2020, verification_value: '737', brand: :visa)
@declined_card = credit_card('4000300011112220')
@@ -165,6 +165,28 @@ def test_successful_authorize_with_3ds2_browser_client_data
refute response.params['additionalData']['threeds2.threeDSMethodURL'].blank?
end
+ def test_successful_purchase_with_3ds2_exemption_requested_and_execute_threed_false
+ assert response = @gateway.authorize(@amount, @three_ds_enrolled_card, @normalized_3ds_2_options.merge(execute_threed: false, sca_exemption: 'lowValue'))
+ assert response.test?
+ refute response.authorization.blank?
+
+ assert_equal response.params['resultCode'], 'Authorised'
+ end
+
+ # According to Adyen documentation, if execute_threed is set to true and an exemption provided
+ # the gateway will apply and request for the specified exemption in the authentication request,
+ # after the device fingerprint is submitted to the issuer.
+ def test_successful_purchase_with_3ds2_exemption_requested_and_execute_threed_true
+ assert response = @gateway.authorize(@amount, @three_ds_enrolled_card, @normalized_3ds_2_options.merge(execute_threed: true, sca_exemption: 'lowValue'))
+ assert response.test?
+ refute response.authorization.blank?
+
+ assert_equal response.params['resultCode'], 'IdentifyShopper'
+ refute response.params['additionalData']['threeds2.threeDS2Token'].blank?
+ refute response.params['additionalData']['threeds2.threeDSServerTransID'].blank?
+ refute response.params['additionalData']['threeds2.threeDSMethodURL'].blank?
+ end
+
def test_successful_authorize_with_3ds2_app_based_request
three_ds_app_based_options = {
reference: '345123',
diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb
index 976cedc73b5..f9651effcb6 100644
--- a/test/unit/gateways/adyen_test.rb
+++ b/test/unit/gateways/adyen_test.rb
@@ -277,6 +277,60 @@ def test_custom_routing_sent
end.respond_with(successful_authorize_response)
end
+ def test_execute_threed_false_sent_3ds2
+ stub_comms do
+ @gateway.authorize(@amount, '123', @normalized_3ds_2_options.merge({execute_threed: false}))
+ end.check_request do |endpoint, data, headers|
+ refute JSON.parse(data)['additionalData']['scaExemption']
+ assert_false JSON.parse(data)['additionalData']['executeThreeD']
+ end.respond_with(successful_authorize_response)
+ end
+
+ def test_sca_exemption_not_sent_if_execute_threed_missing_3ds2
+ stub_comms do
+ @gateway.authorize(@amount, '123', @normalized_3ds_2_options.merge({scaExemption: 'lowValue'}))
+ end.check_request do |endpoint, data, headers|
+ refute JSON.parse(data)['additionalData']['scaExemption']
+ refute JSON.parse(data)['additionalData']['executeThreeD']
+ end.respond_with(successful_authorize_response)
+ end
+
+ def test_sca_exemption_and_execute_threed_false_sent_3ds2
+ stub_comms do
+ @gateway.authorize(@amount, '123', @normalized_3ds_2_options.merge({sca_exemption: 'lowValue', execute_threed: false}))
+ end.check_request do |endpoint, data, headers|
+ assert_equal 'lowValue', JSON.parse(data)['additionalData']['scaExemption']
+ assert_false JSON.parse(data)['additionalData']['executeThreeD']
+ end.respond_with(successful_authorize_response)
+ end
+
+ def test_sca_exemption_and_execute_threed_true_sent_3ds2
+ stub_comms do
+ @gateway.authorize(@amount, '123', @normalized_3ds_2_options.merge({sca_exemption: 'lowValue', execute_threed: true}))
+ end.check_request do |endpoint, data, headers|
+ assert_equal 'lowValue', JSON.parse(data)['additionalData']['scaExemption']
+ assert JSON.parse(data)['additionalData']['executeThreeD']
+ end.respond_with(successful_authorize_response)
+ end
+
+ def test_sca_exemption_not_sent_when_execute_threed_true_3ds1
+ stub_comms do
+ @gateway.authorize(@amount, '123', @options.merge({sca_exemption: 'lowValue', execute_threed: true}))
+ end.check_request do |endpoint, data, headers|
+ refute JSON.parse(data)['additionalData']['scaExemption']
+ assert JSON.parse(data)['additionalData']['executeThreeD']
+ end.respond_with(successful_authorize_response)
+ end
+
+ def test_sca_exemption_not_sent_when_execute_threed_false_3ds1
+ stub_comms do
+ @gateway.authorize(@amount, '123', @options.merge({sca_exemption: 'lowValue', execute_threed: false}))
+ end.check_request do |endpoint, data, headers|
+ refute JSON.parse(data)['additionalData']['scaExemption']
+ refute JSON.parse(data)['additionalData']['executeThreeD']
+ end.respond_with(successful_authorize_response)
+ end
+
def test_update_shopper_statement_and_industry_usage_sent
stub_comms do
@gateway.adjust(@amount, '123', @options.merge({update_shopper_statement: 'statement note', industry_usage: 'DelayedCharge'}))
From df372a96ddc00b6588dd5b707c3b95d7fea1c872 Mon Sep 17 00:00:00 2001
From: leila-alderman
Date: Mon, 9 Sep 2019 16:27:30 -0400
Subject: [PATCH 0442/2234] Adyen: Send "NA" instead of "N/A"
When an address field is not provided, the default will now be "NA"
instead of the previous "N/A". According to Adyen, this should improve
acceptance rates for transactions that do not include an address
provided by the customer.
CE-115
Unit:
47 tests, 228 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
Remote:
66 tests, 213 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
96.9697% passed
The two tests that are failing:
- test_successful_purchase_with_auth_data_via_threeds1_standalone
- test_successful_purchase_with_auth_data_via_threeds2_standalone
These failures seem to be unrelated to the changes here.
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/adyen.rb | 8 ++++----
test/unit/gateways/adyen_test.rb | 6 +++---
3 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 2819fb1ba7b..a42b6370ab4 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,7 @@
== HEAD
* Adyen: Add functionality to set 3DS exemptions via API [britth] #3331
+* Adyen: Send "NA" instead of "N/A" [leila-alderman] #3339
== Version 1.98.0 (Sep 9, 2019)
* Stripe Payment Intents: Add new gateway [britth] #3290
diff --git a/lib/active_merchant/billing/gateways/adyen.rb b/lib/active_merchant/billing/gateways/adyen.rb
index 3dcbee6efa0..acc8a1c2680 100644
--- a/lib/active_merchant/billing/gateways/adyen.rb
+++ b/lib/active_merchant/billing/gateways/adyen.rb
@@ -229,17 +229,17 @@ def add_address(post, options)
return unless post[:card]&.kind_of?(Hash)
if (address = options[:billing_address] || options[:address]) && address[:country]
post[:billingAddress] = {}
- post[:billingAddress][:street] = address[:address1] || 'N/A'
- post[:billingAddress][:houseNumberOrName] = address[:address2] || 'N/A'
+ post[:billingAddress][:street] = address[:address1] || 'NA'
+ post[:billingAddress][:houseNumberOrName] = address[:address2] || 'NA'
post[:billingAddress][:postalCode] = address[:zip] if address[:zip]
- post[:billingAddress][:city] = address[:city] || 'N/A'
+ post[:billingAddress][:city] = address[:city] || 'NA'
post[:billingAddress][:stateOrProvince] = get_state(address)
post[:billingAddress][:country] = address[:country] if address[:country]
end
end
def get_state(address)
- address[:state] && !address[:state].blank? ? address[:state] : 'N/A'
+ address[:state] && !address[:state].blank? ? address[:state] : 'NA'
end
def add_invoice(post, money, options)
diff --git a/test/unit/gateways/adyen_test.rb b/test/unit/gateways/adyen_test.rb
index f9651effcb6..38bbefdd5e3 100644
--- a/test/unit/gateways/adyen_test.rb
+++ b/test/unit/gateways/adyen_test.rb
@@ -534,9 +534,9 @@ def test_add_address
@options[:billing_address].delete(:address2)
@options[:billing_address].delete(:state)
@gateway.send(:add_address, post, @options)
- assert_equal 'N/A', post[:billingAddress][:street]
- assert_equal 'N/A', post[:billingAddress][:houseNumberOrName]
- assert_equal 'N/A', post[:billingAddress][:stateOrProvince]
+ assert_equal 'NA', post[:billingAddress][:street]
+ assert_equal 'NA', post[:billingAddress][:houseNumberOrName]
+ assert_equal 'NA', post[:billingAddress][:stateOrProvince]
assert_equal @options[:billing_address][:zip], post[:billingAddress][:postalCode]
assert_equal @options[:billing_address][:city], post[:billingAddress][:city]
assert_equal @options[:billing_address][:country], post[:billingAddress][:country]
From 90048bea58e85571220387f44afa98bb8ed34fa8 Mon Sep 17 00:00:00 2001
From: britth
Date: Wed, 11 Sep 2019 09:49:04 -0400
Subject: [PATCH 0443/2234] Stripe Payment Intents: Successfully set
application fee on capture
You do not need to pass the transfer destination in a capture request,
and in fact the request will fail if you try to post that data.
However, before this PR, we were requiring that a destination account
be present before setting the associated fee/transfer amount. This PR
updates the logic to set only the application fee or transfer amount
on capture requests when present.
Remote:
29 tests, 124 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
6 tests, 42 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../gateways/stripe_payment_intents.rb | 6 ++++-
.../remote_stripe_payment_intents_test.rb | 22 +++++++++++++++++++
3 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index a42b6370ab4..daa252d140d 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -3,6 +3,7 @@
== HEAD
* Adyen: Add functionality to set 3DS exemptions via API [britth] #3331
* Adyen: Send "NA" instead of "N/A" [leila-alderman] #3339
+* Stripe Payment Intents: Set application fee or transfer amount on capture [britth] #3340
== Version 1.98.0 (Sep 9, 2019)
* Stripe Payment Intents: Add new gateway [britth] #3290
diff --git a/lib/active_merchant/billing/gateways/stripe_payment_intents.rb b/lib/active_merchant/billing/gateways/stripe_payment_intents.rb
index 6469e671113..6afd036e7aa 100644
--- a/lib/active_merchant/billing/gateways/stripe_payment_intents.rb
+++ b/lib/active_merchant/billing/gateways/stripe_payment_intents.rb
@@ -92,7 +92,11 @@ def purchase(money, payment_method, options = {})
def capture(money, intent_id, options = {})
post = {}
post[:amount_to_capture] = money
- add_connected_account(post, options)
+ if options[:transfer_amount]
+ post[:transfer_data] = {}
+ post[:transfer_data][:amount] = options[:transfer_amount]
+ end
+ post[:application_fee_amount] = options[:application_fee] if options[:application_fee]
commit(:post, "payment_intents/#{intent_id}/capture", post, options)
end
diff --git a/test/remote/gateways/remote_stripe_payment_intents_test.rb b/test/remote/gateways/remote_stripe_payment_intents_test.rb
index a8928f5cf3e..d88c68af801 100644
--- a/test/remote/gateways/remote_stripe_payment_intents_test.rb
+++ b/test/remote/gateways/remote_stripe_payment_intents_test.rb
@@ -273,6 +273,28 @@ def test_create_a_payment_intent_and_manually_capture
assert_equal 'Payment complete.', capture_response.params.dig('charges', 'data')[0].dig('outcome', 'seller_message')
end
+ def test_auth_and_capture_with_destination_account_and_fee
+ options = {
+ currency: 'GBP',
+ customer: @customer,
+ confirmation_method: 'manual',
+ capture_method: 'manual',
+ transfer_destination: @destination_account,
+ confirm: true
+ }
+ assert create_response = @gateway.create_intent(@amount, @visa_payment_method, options)
+ intent_id = create_response.params['id']
+ assert_equal 'requires_capture', create_response.params['status']
+ assert_equal @destination_account, create_response.params['transfer_data']['destination']
+ assert_nil create_response.params['application_fee_amount']
+
+ assert capture_response = @gateway.capture(@amount, intent_id, { application_fee: 100 })
+ assert_equal 'succeeded', capture_response.params['status']
+ assert_equal @destination_account, capture_response.params['transfer_data']['destination']
+ assert_equal 100, capture_response.params['application_fee_amount']
+ assert_equal 'Payment complete.', capture_response.params.dig('charges', 'data')[0].dig('outcome', 'seller_message')
+ end
+
def test_create_a_payment_intent_and_automatically_capture
options = {
currency: 'GBP',
From 79f8dbf2382233c6843de1592ae4803c129ca350 Mon Sep 17 00:00:00 2001
From: David Perry
Date: Wed, 11 Sep 2019 15:29:00 -0400
Subject: [PATCH 0444/2234] TNS: Support Europe endpoint
Closes #3346
Remote (1 failure for expired AP region test account)
13 tests, 44 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
92.3077% passed
Unit:
17 tests, 78 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/mastercard.rb | 18 ++++++++++++++++--
lib/active_merchant/billing/gateways/tns.rb | 5 ++++-
test/unit/gateways/tns_test.rb | 16 ++++++++++++++++
4 files changed, 37 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index daa252d140d..44e0c7b6799 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -4,6 +4,7 @@
* Adyen: Add functionality to set 3DS exemptions via API [britth] #3331
* Adyen: Send "NA" instead of "N/A" [leila-alderman] #3339
* Stripe Payment Intents: Set application fee or transfer amount on capture [britth] #3340
+* TNS: Support Europe endpoint [curiousepic] #3346
== Version 1.98.0 (Sep 9, 2019)
* Stripe Payment Intents: Add new gateway [britth] #3290
diff --git a/lib/active_merchant/billing/gateways/mastercard.rb b/lib/active_merchant/billing/gateways/mastercard.rb
index 609039cb9e3..0a1517d526f 100644
--- a/lib/active_merchant/billing/gateways/mastercard.rb
+++ b/lib/active_merchant/billing/gateways/mastercard.rb
@@ -206,9 +206,23 @@ def build_url(orderid, transactionid)
def base_url
if test?
- @options[:region] == 'asia_pacific' ? test_ap_url : test_na_url
+ case @options[:region]
+ when 'asia_pacific'
+ test_ap_url
+ when 'europe'
+ test_eu_url
+ when 'north_america', nil
+ test_na_url
+ end
else
- @options[:region] == 'asia_pacific' ? live_ap_url : live_na_url
+ case @options[:region]
+ when 'asia_pacific'
+ live_ap_url
+ when 'europe'
+ live_eu_url
+ when 'north_america', nil
+ live_na_url
+ end
end
end
diff --git a/lib/active_merchant/billing/gateways/tns.rb b/lib/active_merchant/billing/gateways/tns.rb
index 25ed79306a9..33bf3196976 100644
--- a/lib/active_merchant/billing/gateways/tns.rb
+++ b/lib/active_merchant/billing/gateways/tns.rb
@@ -3,7 +3,7 @@ module Billing
class TnsGateway < Gateway
include MastercardGateway
- class_attribute :live_na_url, :live_ap_url, :test_na_url, :test_ap_url
+ class_attribute :live_na_url, :live_ap_url, :live_eu_url, :test_na_url, :test_ap_url, :test_eu_url
self.live_na_url = 'https://secure.na.tnspayments.com/api/rest/version/36/'
self.test_na_url = 'https://secure.na.tnspayments.com/api/rest/version/36/'
@@ -11,6 +11,9 @@ class TnsGateway < Gateway
self.live_ap_url = 'https://secure.ap.tnspayments.com/api/rest/version/36/'
self.test_ap_url = 'https://secure.ap.tnspayments.com/api/rest/version/36/'
+ self.live_eu_url = 'https://secure.eu.tnspayments.com/api/rest/version/36/'
+ self.test_eu_url = 'https://secure.eu.tnspayments.com/api/rest/version/36/'
+
self.display_name = 'TNS'
self.homepage_url = 'http://www.tnsi.com/'
self.supported_countries = %w(AR AU BR FR DE HK MX NZ SG GB US)
diff --git a/test/unit/gateways/tns_test.rb b/test/unit/gateways/tns_test.rb
index f97a0e6e242..926b921bca3 100644
--- a/test/unit/gateways/tns_test.rb
+++ b/test/unit/gateways/tns_test.rb
@@ -189,6 +189,22 @@ def test_asia_pacific_region_url
assert_success response
end
+ def test_europe_region_url
+ @gateway = TnsGateway.new(
+ userid: 'userid',
+ password: 'password',
+ region: 'europe'
+ )
+
+ response = stub_comms(@gateway, :ssl_request) do
+ @gateway.purchase(@amount, @credit_card, @options)
+ end.check_request do |method, endpoint, data, headers|
+ assert_match(/secure.eu.tnspayments.com/, endpoint)
+ end.respond_with(successful_capture_response)
+
+ assert_success response
+ end
+
def test_scrub
assert @gateway.supports_scrubbing?
assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed
From 74506fc41d2ddb0c56aacd9ea95ff5f3ceea25e2 Mon Sep 17 00:00:00 2001
From: britth
Date: Thu, 12 Sep 2019 10:29:01 -0400
Subject: [PATCH 0445/2234] Redsys: 3DS Support
This PR preps Redsys for 3DS integration. It adds the test and production
URLs for the 3DS service, updates the commit method to interact with the
appropriate endpoint for 3DS transactions, and updates the parse method
to appropriately parse responses.
Unit:
34 tests, 104 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
20 tests, 63 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/redsys.rb | 134 ++++++++++++++----
.../gateways/remote_redsys_sha256_test.rb | 20 +++
test/unit/gateways/redsys_sha256_test.rb | 22 +++
4 files changed, 147 insertions(+), 30 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 44e0c7b6799..a6a6e33fe83 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -5,6 +5,7 @@
* Adyen: Send "NA" instead of "N/A" [leila-alderman] #3339
* Stripe Payment Intents: Set application fee or transfer amount on capture [britth] #3340
* TNS: Support Europe endpoint [curiousepic] #3346
+* Redsys: Add 3DS support to gateway [britth] #3336
== Version 1.98.0 (Sep 9, 2019)
* Stripe Payment Intents: Add new gateway [britth] #3290
diff --git a/lib/active_merchant/billing/gateways/redsys.rb b/lib/active_merchant/billing/gateways/redsys.rb
index 792b935d557..35a27be6b18 100644
--- a/lib/active_merchant/billing/gateways/redsys.rb
+++ b/lib/active_merchant/billing/gateways/redsys.rb
@@ -193,28 +193,30 @@ def purchase(money, payment, options = {})
requires!(options, :order_id)
data = {}
- add_action(data, :purchase)
+ add_action(data, :purchase, options)
add_amount(data, money, options)
add_order(data, options[:order_id])
add_payment(data, payment)
+ add_threeds(data, options) if options[:execute_threed]
data[:description] = options[:description]
data[:store_in_vault] = options[:store]
- commit data
+ commit data, options
end
def authorize(money, payment, options = {})
requires!(options, :order_id)
data = {}
- add_action(data, :authorize)
+ add_action(data, :authorize, options)
add_amount(data, money, options)
add_order(data, options[:order_id])
add_payment(data, payment)
+ add_threeds(data, options) if options[:execute_threed]
data[:description] = options[:description]
data[:store_in_vault] = options[:store]
- commit data
+ commit data, options
end
def capture(money, authorization, options = {})
@@ -225,7 +227,7 @@ def capture(money, authorization, options = {})
add_order(data, order_id)
data[:description] = options[:description]
- commit data
+ commit data, options
end
def void(authorization, options = {})
@@ -236,7 +238,7 @@ def void(authorization, options = {})
add_order(data, order_id)
data[:description] = options[:description]
- commit data
+ commit data, options
end
def refund(money, authorization, options = {})
@@ -247,7 +249,7 @@ def refund(money, authorization, options = {})
add_order(data, order_id)
data[:description] = options[:description]
- commit data
+ commit data, options
end
def verify(creditcard, options = {})
@@ -278,8 +280,8 @@ def scrub(transcript)
private
- def add_action(data, action)
- data[:action] = transaction_code(action)
+ def add_action(data, action, options = {})
+ data[:action] = options[:execute_threed].present? ? '0' : transaction_code(action)
end
def add_amount(data, money, options)
@@ -295,6 +297,10 @@ def url
test? ? test_url : live_url
end
+ def threeds_url
+ test? ? 'https://sis-t.redsys.es:25443/sis/services/SerClsWSEntradaV2': 'https://sis.redsys.es/sis/services/SerClsWSEntradaV2'
+ end
+
def add_payment(data, card)
if card.is_a?(String)
data[:credit_card_token] = card
@@ -311,21 +317,57 @@ def add_payment(data, card)
end
end
- def commit(data)
- parse(ssl_post(url, "entrada=#{CGI.escape(xml_request_from(data))}", headers))
+ def add_threeds(data, options)
+ if options[:execute_threed] == true
+ data[:threeds] = {threeDSInfo: 'CardData'}
+ end
end
- def headers
- {
- 'Content-Type' => 'application/x-www-form-urlencoded'
- }
+ def determine_3ds_action(threeds_hash)
+ return 'iniciaPeticion' if threeds_hash[:threeDSInfo] == 'CardData'
+ return 'trataPeticion' if threeds_hash[:threeDSInfo] == 'AuthenticationData' ||
+ threeds_hash[:threeDSInfo] == 'ChallengeResponse'
+ end
+
+ def commit(data, options = {})
+ if data[:threeds]
+ action = determine_3ds_action(data[:threeds])
+ request = <<-EOS
+
+
+
+
+
+
+
+
+
+
+ EOS
+ parse(ssl_post(threeds_url, request, headers(action)), action)
+ else
+ parse(ssl_post(url, "entrada=#{CGI.escape(xml_request_from(data, options))}", headers), action)
+ end
end
- def xml_request_from(data)
+ def headers(action=nil)
+ if action
+ {
+ 'Content-Type' => 'text/xml',
+ 'SOAPAction' => action
+ }
+ else
+ {
+ 'Content-Type' => 'application/x-www-form-urlencoded'
+ }
+ end
+ end
+
+ def xml_request_from(data, options = {})
if sha256_authentication?
- build_sha256_xml_request(data)
+ build_sha256_xml_request(data, options)
else
- build_sha1_xml_request(data)
+ build_sha1_xml_request(data, options)
end
end
@@ -351,30 +393,30 @@ def build_signature(data)
Digest::SHA1.hexdigest(str)
end
- def build_sha256_xml_request(data)
+ def build_sha256_xml_request(data, options = {})
xml = Builder::XmlMarkup.new
xml.instruct!
xml.REQUEST do
- build_merchant_data(xml, data)
+ build_merchant_data(xml, data, options)
xml.DS_SIGNATUREVERSION 'HMAC_SHA256_V1'
- xml.DS_SIGNATURE sign_request(merchant_data_xml(data), data[:order_id])
+ xml.DS_SIGNATURE sign_request(merchant_data_xml(data, options), data[:order_id])
end
xml.target!
end
- def build_sha1_xml_request(data)
+ def build_sha1_xml_request(data, options = {})
xml = Builder::XmlMarkup.new :indent => 2
- build_merchant_data(xml, data)
+ build_merchant_data(xml, data, options)
xml.target!
end
- def merchant_data_xml(data)
+ def merchant_data_xml(data, options = {})
xml = Builder::XmlMarkup.new
- build_merchant_data(xml, data)
+ build_merchant_data(xml, data, options)
xml.target!
end
- def build_merchant_data(xml, data)
+ def build_merchant_data(xml, data, options = {})
xml.DATOSENTRADA do
# Basic elements
xml.DS_Version 0.1
@@ -383,7 +425,7 @@ def build_merchant_data(xml, data)
xml.DS_MERCHANT_ORDER data[:order_id]
xml.DS_MERCHANT_TRANSACTIONTYPE data[:action]
xml.DS_MERCHANT_PRODUCTDESCRIPTION data[:description]
- xml.DS_MERCHANT_TERMINAL @options[:terminal]
+ xml.DS_MERCHANT_TERMINAL options[:terminal] || @options[:terminal]
xml.DS_MERCHANT_MERCHANTCODE @options[:login]
xml.DS_MERCHANT_MERCHANTSIGNATURE build_signature(data) unless sha256_authentication?
@@ -398,22 +440,36 @@ def build_merchant_data(xml, data)
xml.DS_MERCHANT_IDENTIFIER data[:credit_card_token]
xml.DS_MERCHANT_DIRECTPAYMENT 'true'
end
+
+ if data[:threeds]
+ xml.DS_MERCHANT_EMV3DS data[:threeds].to_json
+ end
end
end
- def parse(data)
+ def parse(data, action)
params = {}
success = false
message = ''
options = @options.merge(:test => test?)
xml = Nokogiri::XML(data)
code = xml.xpath('//RETORNOXML/CODIGO').text
- if code == '0'
+
+ if ['iniciaPeticion', 'trataPeticion'].include?(action)
+ vxml = Nokogiri::XML(data).remove_namespaces!.xpath("//Envelope/Body/#{action}Response/#{action}Return").inner_text
+ xml = Nokogiri::XML(vxml)
+ node = (action == 'iniciaPeticion' ? 'INFOTARJETA' : 'OPERACION')
+ op = xml.xpath("//RETORNOXML/#{node}")
+ op.children.each do |element|
+ params[element.name.downcase.to_sym] = element.text
+ end
+ message = response_text_3ds(xml, params)
+ success = params.size > 0 && is_success_response?(params[:ds_response])
+ elsif code == '0'
op = xml.xpath('//RETORNOXML/OPERACION')
op.children.each do |element|
params[element.name.downcase.to_sym] = element.text
end
-
if validate_signature(params)
message = response_text(params[:ds_response])
options[:authorization] = build_authorization(params)
@@ -474,6 +530,20 @@ def response_text(code)
RESPONSE_TEXTS[code] || 'Unkown code, please check in manual'
end
+ def response_text_3ds(xml, params)
+ code = xml.xpath('//RETORNOXML/CODIGO').text
+ message = ''
+ if code != '0'
+ message = "#{code} ERROR"
+ elsif params[:ds_emv3ds]
+ three_ds_data = JSON.parse(params[:ds_emv3ds])
+ message = three_ds_data['threeDSInfo']
+ elsif params[:ds_response]
+ message = response_text(params[:ds_response])
+ end
+ message
+ end
+
def is_success_response?(code)
(code.to_i < 100) || [400, 481, 500, 900].include?(code.to_i)
end
@@ -523,6 +593,10 @@ def xml_signed_fields(data)
xml_signed_fields += data[:ds_cardnumber]
end
+ if data[:ds_emv3ds]
+ xml_signed_fields += data[:ds_emv3ds]
+ end
+
xml_signed_fields + data[:ds_transactiontype] + data[:ds_securepayment]
end
diff --git a/test/remote/gateways/remote_redsys_sha256_test.rb b/test/remote/gateways/remote_redsys_sha256_test.rb
index 43718a5f67a..fec07cde065 100644
--- a/test/remote/gateways/remote_redsys_sha256_test.rb
+++ b/test/remote/gateways/remote_redsys_sha256_test.rb
@@ -5,6 +5,7 @@ def setup
@gateway = RedsysGateway.new(fixtures(:redsys_sha256))
@credit_card = credit_card('4548812049400004')
@declined_card = credit_card
+ @threeds2_credit_card = credit_card('4918019199883839')
@options = {
order_id: generate_order_id,
}
@@ -16,6 +17,25 @@ def test_successful_purchase
assert_equal 'Transaction Approved', response.message
end
+ def test_successful_authorize_3ds
+ options = @options.merge(execute_threed: true, terminal: 12)
+ response = @gateway.authorize(100, @credit_card, options)
+ assert_success response
+ assert response.params['ds_emv3ds']
+ assert_equal 'NO_3DS_v2', JSON.parse(response.params['ds_emv3ds'])['protocolVersion']
+ assert_equal 'CardConfiguration', response.message
+ end
+
+ def test_successful_purchase_3ds
+ options = @options.merge(execute_threed: true, terminal: 12)
+ response = @gateway.purchase(100, @threeds2_credit_card, options)
+ assert_success response
+ assert three_ds_data = JSON.parse(response.params['ds_emv3ds'])
+ assert_equal '2.1.0', three_ds_data['protocolVersion']
+ assert_equal 'https://sis-d.redsys.es/sis-simulador-web/threeDsMethod.jsp', three_ds_data['threeDSMethodURL']
+ assert_equal 'CardConfiguration', response.message
+ end
+
def test_purchase_with_invalid_order_id
response = @gateway.purchase(100, @credit_card, order_id: "a%4#{generate_order_id}")
assert_success response
diff --git a/test/unit/gateways/redsys_sha256_test.rb b/test/unit/gateways/redsys_sha256_test.rb
index f1fbac3c70f..94f17e1797c 100644
--- a/test/unit/gateways/redsys_sha256_test.rb
+++ b/test/unit/gateways/redsys_sha256_test.rb
@@ -114,6 +114,24 @@ def test_authorize_without_order_id
end
end
+ def test_successful_authorize_with_3ds
+ @gateway.expects(:ssl_post).returns(successful_authorize_with_3ds_response)
+ response = @gateway.authorize(100, credit_card, { execute_threed: true, order_id: '156201452719' })
+ assert response.test?
+ assert response.params['ds_emv3ds']
+ assert_equal response.message, 'CardConfiguration'
+ end
+
+ def test_3ds_data_passed
+ stub_comms(@gateway, :ssl_request) do
+ @gateway.authorize(100, credit_card, { execute_threed: true, order_id: '156201452719', terminal: 12 })
+ end.check_request do |method, endpoint, data, headers|
+ assert_match(/iniciaPeticion/, data)
+ assert_match(/12<\/DS_MERCHANT_TERMINAL>/, data)
+ assert_match(/\"threeDSInfo\":\"CardData\"/, data)
+ end.respond_with(successful_authorize_with_3ds_response)
+ end
+
def test_bad_order_id_format
stub_comms(@gateway, :ssl_request) do
@gateway.authorize(100, credit_card, order_id: 'Una#cce-ptable44Format')
@@ -289,6 +307,10 @@ def successful_authorize_response
"00.110097814474336727329qv8K/6k3P1zyk5F+ZYmMel0uuOzC58kXCgp5rcnhI=09195271310000399957101724\n"
end
+ def successful_authorize_with_3ds_response
+ '<RETORNOXML><CODIGO>0</CODIGO><INFOTARJETA><Ds_Order>156270437866</Ds_Order><Ds_MerchantCode>091952713</Ds_MerchantCode><Ds_Terminal>1</Ds_Terminal><Ds_TransactionType>0</Ds_TransactionType><Ds_EMV3DS>{"protocolVersion":"NO_3DS_v2","threeDSInfo":"CardConfiguration"}</Ds_EMV3DS><Ds_Signature>LIWUaQh+lwsE0DBNpv2EOYALCY6ZxHDQ6gLvOcWiSB4=</Ds_Signature></INFOTARJETA></RETORNOXML>'
+ end
+
def failed_authorize_response
"SIS0093\n 0.1\n 978\n 100\n 141278225678\n 1\n 1\n 91952713\n 1c34699589507802f800b929ea314dc143b0b8a5\n Longbob Longsen\n 4242424242424242\n 1509\n 123\n\n"
end
From c0c2bc8a485850392d7c1704afeacc5d75f939c0 Mon Sep 17 00:00:00 2001
From: Jared Knipp
Date: Thu, 12 Sep 2019 12:49:17 -0500
Subject: [PATCH 0446/2234] Worldpay: Allow multiple refunds per authorization
Remove the restriction to perform refunds only if a payment is in a
certain set of states.
ECS-344
Unit:
66 tests, 392 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
Two unrelated test failures.
53 tests, 232 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
96.2264% passed
closes #3349
---
CHANGELOG | 1 +
.../billing/gateways/worldpay.rb | 2 +-
test/remote/gateways/remote_worldpay_test.rb | 30 +++++++++++++++----
3 files changed, 26 insertions(+), 7 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index a6a6e33fe83..0760194c0c1 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -6,6 +6,7 @@
* Stripe Payment Intents: Set application fee or transfer amount on capture [britth] #3340
* TNS: Support Europe endpoint [curiousepic] #3346
* Redsys: Add 3DS support to gateway [britth] #3336
+* Worldpay: Allow multiple refunds per authorization [jknipp] #3349
== Version 1.98.0 (Sep 9, 2019)
* Stripe Payment Intents: Add new gateway [britth] #3290
diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb
index f5e74db9114..35857ea32f6 100644
--- a/lib/active_merchant/billing/gateways/worldpay.rb
+++ b/lib/active_merchant/billing/gateways/worldpay.rb
@@ -88,7 +88,7 @@ def void(authorization, options = {})
def refund(money, authorization, options = {})
authorization = order_id_from_authorization(authorization.to_s)
response = MultiResponse.run do |r|
- r.process { inquire_request(authorization, options, 'CAPTURED', 'SETTLED', 'SETTLED_BY_MERCHANT') }
+ r.process { inquire_request(authorization, options, 'CAPTURED', 'SETTLED', 'SETTLED_BY_MERCHANT') } unless options[:authorization_validated]
r.process { refund_request(money, authorization, options) }
end
diff --git a/test/remote/gateways/remote_worldpay_test.rb b/test/remote/gateways/remote_worldpay_test.rb
index 2d09cf5e4ab..497a143145e 100644
--- a/test/remote/gateways/remote_worldpay_test.rb
+++ b/test/remote/gateways/remote_worldpay_test.rb
@@ -492,12 +492,30 @@ def test_failed_verify_with_unknown_card
# puts 'auth: ' + response.authorization
# end
#
- # def test_refund
- # refund = @gateway.refund(@amount, '39270fd70be13aab55f84e28be45cad3')
- # assert_success refund
- # assert_equal 'SUCCESS', refund.message
- # end
- #
+ def test_refund
+ response = @gateway.purchase(@amount, @credit_card, @options)
+ assert_success response
+ assert_equal 'SUCCESS', response.message
+ assert response.authorization
+
+ refund = @gateway.refund(@amount, response.authorization, authorization_validated: true)
+ assert_success refund
+ assert_equal 'SUCCESS', refund.message
+ end
+
+ def test_multiple_refunds
+ purchase = @gateway.purchase(@amount, @credit_card, @options)
+ assert_success purchase
+ assert_equal 'SUCCESS', purchase.message
+
+ partial_amount = @amount - 1
+ assert_success refund1 = @gateway.refund(partial_amount, purchase.authorization, authorization_validated: true)
+ assert_equal 'SUCCESS', refund1.message
+
+ assert_success refund2 = @gateway.refund(@amount - partial_amount, purchase.authorization, authorization_validated: true)
+ assert_equal 'SUCCESS', refund2.message
+ end
+
# def test_void_fails_unless_status_is_authorised
# response = @gateway.void('replace_with_authorization') # existing transaction in CAPTURED state
# assert_failure response
From e0ee76a5d18f9563b9fc37da3b9386eb26122b67 Mon Sep 17 00:00:00 2001
From: Hannah Deters
Date: Wed, 11 Sep 2019 13:36:53 -0400
Subject: [PATCH 0447/2234] MercadoPago: Add tests for Naranja card
Adds remote and unit tests for the Naranja card type
The `test_partial_capture` and
`test_successful_purchase_with_processing_mode_gateway` remote tests are
currently failing and were failing prior to these changes.
Remote:
30 tests, 91 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
93.3333% passed
Unit:
28 tests, 147 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
---
CHANGELOG | 1 +
.../gateways/remote_mercado_pago_test.rb | 41 +++++++++++++
test/unit/gateways/mercado_pago_test.rb | 58 +++++++++++++++++++
3 files changed, 100 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index 0760194c0c1..76d3f825d32 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -7,6 +7,7 @@
* TNS: Support Europe endpoint [curiousepic] #3346
* Redsys: Add 3DS support to gateway [britth] #3336
* Worldpay: Allow multiple refunds per authorization [jknipp] #3349
+* MercadoPago: Add remote and unit tests for Naranja card [hdeters] #3345
== Version 1.98.0 (Sep 9, 2019)
* Stripe Payment Intents: Add new gateway [britth] #3290
diff --git a/test/remote/gateways/remote_mercado_pago_test.rb b/test/remote/gateways/remote_mercado_pago_test.rb
index f6a9e0fc0bb..0bf8cad1c8f 100644
--- a/test/remote/gateways/remote_mercado_pago_test.rb
+++ b/test/remote/gateways/remote_mercado_pago_test.rb
@@ -21,6 +21,13 @@ def setup
:last_name => 'Smith',
:verification_value => '737'
)
+ @naranja_credit_card = credit_card('5895627823453005',
+ :month => 10,
+ :year => 2020,
+ :first_name => 'John',
+ :last_name => 'Smith',
+ :verification_value => '123'
+ )
@declined_card = credit_card('4000300011112220')
@options = {
billing_address: address,
@@ -55,6 +62,12 @@ def test_successful_purchase_with_cabal
assert_equal 'accredited', response.message
end
+ def test_successful_purchase_with_naranja
+ response = @argentina_gateway.purchase(@amount, @naranja_credit_card, @options)
+ assert_success response
+ assert_equal 'accredited', response.message
+ end
+
def test_successful_purchase_with_binary_false
@options.update(binary_mode: false)
response = @gateway.authorize(@amount, @credit_card, @options)
@@ -114,6 +127,16 @@ def test_successful_authorize_and_capture_with_cabal
assert_equal 'accredited', capture.message
end
+ def test_successful_authorize_and_capture_with_naranja
+ auth = @argentina_gateway.authorize(@amount, @naranja_credit_card, @options)
+ assert_success auth
+ assert_equal 'pending_capture', auth.message
+
+ assert capture = @argentina_gateway.capture(@amount, auth.authorization)
+ assert_success capture
+ assert_equal 'accredited', capture.message
+ end
+
def test_failed_authorize
response = @gateway.authorize(@amount, @declined_card, @options)
assert_failure response
@@ -162,6 +185,15 @@ def test_successful_refund_with_cabal
assert_equal nil, refund.message
end
+ def test_successful_refund_with_naranja
+ purchase = @argentina_gateway.purchase(@amount, @naranja_credit_card, @options)
+ assert_success purchase
+
+ assert refund = @argentina_gateway.refund(@amount, purchase.authorization)
+ assert_success refund
+ assert_equal nil, refund.message
+ end
+
def test_partial_refund
purchase = @gateway.purchase(@amount, @credit_card, @options)
assert_success purchase
@@ -203,6 +235,15 @@ def test_successful_void_with_cabal
assert_equal 'by_collector', void.message
end
+ def test_successful_void_with_naranja
+ auth = @argentina_gateway.authorize(@amount, @naranja_credit_card, @options)
+ assert_success auth
+
+ assert void = @argentina_gateway.void(auth.authorization)
+ assert_success void
+ assert_equal 'by_collector', void.message
+ end
+
def test_failed_void
response = @gateway.void('')
assert_failure response
diff --git a/test/unit/gateways/mercado_pago_test.rb b/test/unit/gateways/mercado_pago_test.rb
index a0a9a0c3429..02dbc7f7324 100644
--- a/test/unit/gateways/mercado_pago_test.rb
+++ b/test/unit/gateways/mercado_pago_test.rb
@@ -20,6 +20,13 @@ def setup
:last_name => 'Smith',
:verification_value => '737'
)
+ @naranja_credit_card = credit_card('5895627823453005',
+ :month => 10,
+ :year => 2020,
+ :first_name => 'John',
+ :last_name => 'Smith',
+ :verification_value => '123'
+ )
@amount = 100
@options = {
@@ -62,6 +69,17 @@ def test_successful_purchase_with_cabal
assert response.test?
end
+ def test_successful_purchase_with_naranja
+ @gateway.expects(:ssl_post).at_most(2).returns(successful_purchase_with_naranja_response)
+
+ response = @gateway.purchase(@amount, @naranja_credit_card, @options)
+ assert_success response
+
+ assert_equal '20728968|1.0', response.authorization
+ assert_equal 'accredited', response.message
+ assert response.test?
+ end
+
def test_failed_purchase
@gateway.expects(:ssl_post).at_most(2).returns(failed_purchase_response)
@@ -104,6 +122,17 @@ def test_successful_authorize_with_cabal
assert response.test?
end
+ def test_successful_authorize_with_naranja
+ @gateway.expects(:ssl_post).at_most(2).returns(successful_authorize_with_naranja_response)
+
+ response = @gateway.authorize(@amount, @naranja_credit_card, @options)
+ assert_success response
+
+ assert_equal '20729288|1.0', response.authorization
+ assert_equal 'pending_capture', response.message
+ assert response.test?
+ end
+
def test_failed_authorize
@gateway.expects(:ssl_post).at_most(2).returns(failed_authorize_response)
@@ -146,6 +175,17 @@ def test_successful_capture_with_cabal
assert response.test?
end
+ def test_successful_capture_with_naranja
+ @gateway.expects(:ssl_request).returns(successful_capture_with_naranja_response)
+
+ response = @gateway.capture(@amount, 'authorization|amount')
+ assert_success response
+
+ assert_equal '20729288|1.0', response.authorization
+ assert_equal 'accredited', response.message
+ assert response.test?
+ end
+
def test_failed_capture
@gateway.expects(:ssl_request).returns(failed_capture_response)
@@ -425,6 +465,12 @@ def successful_purchase_with_cabal_response
)
end
+ def successful_purchase_with_naranja_response
+ %(
+ {"id":20728968,"date_created":"2019-08-06T15:38:12.000-04:00","date_approved":"2019-08-06T15:38:12.000-04:00","date_last_updated":"2019-08-06T15:38:12.000-04:00","date_of_expiration":null,"money_release_date":"2019-08-20T15:38:12.000-04:00","operation_type":"regular_payment","issuer_id":"688","payment_method_id":"naranja","payment_type_id":"credit_card","status":"approved","status_detail":"accredited","currency_id":"ARS","description":"Store Purchase","live_mode":false,"sponsor_id":null,"authorization_code":null,"money_release_schema":null,"taxes_amount":0,"counter_currency":null,"shipping_amount":0,"pos_id":null,"store_id":null,"collector_id":388534608,"payer":{"first_name":"Test","last_name":"Test","email":"test_user_80507629@testuser.com","identification":{"number":"32659430","type":"DNI"},"phone":{"area_code":"01","number":"1111-1111","extension":""},"type":"registered","entity_type":null,"id":"388571255"},"metadata":{},"additional_info":{"payer":{"address":{"zip_code":"K1C2N6","street_name":"456 My Street Apt 1"}},"shipments":{"receiver_address":{"zip_code":"K1C2N6","street_name":"456 My Street Apt 1"}}},"order":{},"external_reference":"ab86ce493d1cc1e447877720843812e9","transaction_amount":5,"transaction_amount_refunded":0,"coupon_amount":0,"differential_pricing_id":null,"deduction_schema":null,"transaction_details":{"payment_method_reference_id":null,"net_received_amount":4.79,"total_paid_amount":5,"overpaid_amount":0,"external_resource_url":null,"installment_amount":5,"financial_institution":null,"payable_deferral_period":null,"acquirer_reference":null},"fee_details":[{"type":"mercadopago_fee","amount":0.21,"fee_payer":"collector"}],"captured":true,"binary_mode":true,"call_for_authorize_id":null,"statement_descriptor":"SPREEDLYMLA","installments":1,"card":{"id":null,"first_six_digits":"603522","last_four_digits":"7021","expiration_month":10,"expiration_year":2020,"date_created":"2019-08-06T15:38:12.000-04:00","date_last_updated":"2019-08-06T15:38:12.000-04:00","cardholder":{"name":"John Smith","identification":{"number":null,"type":null}}},"notification_url":null,"refunds":[],"processing_mode":"aggregator","merchant_account_id":null,"acquirer":null,"merchant_number":null,"acquirer_reconciliation":[]}
+ )
+ end
+
def failed_purchase_response
%(
{"id":4142297,"date_created":"2017-07-06T10:13:32.000-04:00","date_approved":null,"date_last_updated":"2017-07-06T10:13:32.000-04:00","date_of_expiration":null,"money_release_date":null,"operation_type":"regular_payment","issuer_id":"166","payment_method_id":"visa","payment_type_id":"credit_card","status":"rejected","status_detail":"cc_rejected_other_reason","currency_id":"MXN","description":"Store Purchase","live_mode":false,"sponsor_id":null,"authorization_code":null,"related_exchange_rate":null,"collector_id":261735089,"payer":{"type":"guest","id":null,"email":"user@example.com","identification":{"type":null,"number":null},"phone":{"area_code":null,"number":null,"extension":""},"first_name":"First User","last_name":"User","entity_type":null},"metadata":{},"additional_info":{"payer":{"address":{"zip_code":"K1C2N6","street_name":"My Street","street_number":"456"}}},"order":{"type":"mercadopago","id":"830943860538524456"},"external_reference":null,"transaction_amount":5,"transaction_amount_refunded":0,"coupon_amount":0,"differential_pricing_id":null,"deduction_schema":null,"transaction_details":{"net_received_amount":0,"total_paid_amount":5,"overpaid_amount":0,"external_resource_url":null,"installment_amount":5,"financial_institution":null,"payment_method_reference_id":null,"payable_deferral_period":null,"acquirer_reference":null},"fee_details":[],"captured":true,"binary_mode":false,"call_for_authorize_id":null,"statement_descriptor":"WWW.MERCADOPAGO.COM","installments":1,"card":{"id":null,"first_six_digits":"400030","last_four_digits":"2220","expiration_month":9,"expiration_year":2018,"date_created":"2017-07-06T10:13:32.000-04:00","date_last_updated":"2017-07-06T10:13:32.000-04:00","cardholder":{"name":"Longbob Longsen","identification":{"number":null,"type":null}}},"notification_url":null,"refunds":[],"processing_mode":null,"merchant_account_id":null,"acquirer":null,"merchant_number":null}
@@ -449,6 +495,12 @@ def successful_authorize_with_cabal_response
)
end
+ def successful_authorize_with_naranja_response
+ %(
+ {"id":20729288,"date_created":"2019-08-06T15:57:47.000-04:00","date_approved":null,"date_last_updated":"2019-08-06T15:57:49.000-04:00","date_of_expiration":null,"money_release_date":null,"operation_type":"regular_payment","issuer_id":"688","payment_method_id":"naranja","payment_type_id":"credit_card","status":"authorized","status_detail":"pending_capture","currency_id":"ARS","description":"Store Purchase","live_mode":false,"sponsor_id":null,"authorization_code":null,"money_release_schema":null,"taxes_amount":0,"counter_currency":null,"shipping_amount":0,"pos_id":null,"store_id":null,"collector_id":388534608,"payer":{"first_name":"Test","last_name":"Test","email":"test_user_80507629@testuser.com","identification":{"number":"32659430","type":"DNI"},"phone":{"area_code":"01","number":"1111-1111","extension":""},"type":"registered","entity_type":null,"id":"388571255"},"metadata":{},"additional_info":{"payer":{"address":{"zip_code":"K1C2N6","street_name":"456 My Street Apt 1"}},"shipments":{"receiver_address":{"zip_code":"K1C2N6","street_name":"456 My Street Apt 1"}}},"order":{},"external_reference":"f70cb796271176441a5077012ff2af2a","transaction_amount":5,"transaction_amount_refunded":0,"coupon_amount":0,"differential_pricing_id":null,"deduction_schema":null,"transaction_details":{"payment_method_reference_id":null,"net_received_amount":0,"total_paid_amount":5,"overpaid_amount":0,"external_resource_url":null,"installment_amount":5,"financial_institution":null,"payable_deferral_period":null,"acquirer_reference":null},"fee_details":[],"captured":false,"binary_mode":true,"call_for_authorize_id":null,"statement_descriptor":"SPREEDLYMLA","installments":1,"card":{"id":null,"first_six_digits":"603522","last_four_digits":"7021","expiration_month":10,"expiration_year":2020,"date_created":"2019-08-06T15:57:47.000-04:00","date_last_updated":"2019-08-06T15:57:47.000-04:00","cardholder":{"name":"John Smith","identification":{"number":null,"type":null}}},"notification_url":null,"refunds":[],"processing_mode":"aggregator","merchant_account_id":null,"acquirer":null,"merchant_number":null,"acquirer_reconciliation":[]}
+ )
+ end
+
def failed_authorize_response
%(
{"id":4261953,"date_created":"2017-07-13T14:25:33.000-04:00","date_approved":null,"date_last_updated":"2017-07-13T14:25:33.000-04:00","date_of_expiration":null,"money_release_date":null,"operation_type":"regular_payment","issuer_id":"25","payment_method_id":"visa","payment_type_id":"credit_card","status":"rejected","status_detail":"cc_rejected_other_reason","currency_id":"BRL","description":"Store Purchase","live_mode":false,"sponsor_id":null,"authorization_code":null,"related_exchange_rate":null,"collector_id":263489584,"payer":{"type":"guest","id":null,"email":"user+br@example.com","identification":{"type":null,"number":null},"phone":{"area_code":null,"number":null,"extension":null},"first_name":null,"last_name":null,"entity_type":null},"metadata":{},"additional_info":{"payer":{"address":{"zip_code":"K1C2N6","street_name":"My Street","street_number":"456"}}},"order":{"type":"mercadopago","id":"7528376941458928221"},"external_reference":null,"transaction_amount":5,"transaction_amount_refunded":0,"coupon_amount":0,"differential_pricing_id":null,"deduction_schema":null,"transaction_details":{"net_received_amount":0,"total_paid_amount":5,"overpaid_amount":0,"external_resource_url":null,"installment_amount":5,"financial_institution":null,"payment_method_reference_id":null,"payable_deferral_period":null,"acquirer_reference":null},"fee_details":[],"captured":false,"binary_mode":false,"call_for_authorize_id":null,"statement_descriptor":"WWW.MERCADOPAGO.COM","installments":1,"card":{"id":null,"first_six_digits":"400030","last_four_digits":"2220","expiration_month":9,"expiration_year":2018,"date_created":"2017-07-13T14:25:33.000-04:00","date_last_updated":"2017-07-13T14:25:33.000-04:00","cardholder":{"name":"Longbob Longsen","identification":{"number":null,"type":null}}},"notification_url":null,"refunds":[],"processing_mode":"aggregator","merchant_account_id":null,"acquirer":null,"merchant_number":null}
@@ -473,6 +525,12 @@ def successful_capture_with_cabal_response
)
end
+ def successful_capture_with_naranja_response
+ %(
+ {"id":20729288,"date_created":"2019-08-06T15:57:47.000-04:00","date_approved":"2019-08-06T15:57:49.000-04:00","date_last_updated":"2019-08-06T15:57:49.000-04:00","date_of_expiration":null,"money_release_date":"2019-08-20T15:57:49.000-04:00","operation_type":"regular_payment","issuer_id":"688","payment_method_id":"naranja","payment_type_id":"credit_card","status":"approved","status_detail":"accredited","currency_id":"ARS","description":"Store Purchase","live_mode":false,"sponsor_id":null,"authorization_code":null,"money_release_schema":null,"taxes_amount":0,"counter_currency":null,"shipping_amount":0,"pos_id":null,"store_id":null,"collector_id":388534608,"payer":{"first_name":"Test","last_name":"Test","email":"test_user_80507629@testuser.com","identification":{"number":"32659430","type":"DNI"},"phone":{"area_code":"01","number":"1111-1111","extension":""},"type":"registered","entity_type":null,"id":"388571255"},"metadata":{},"additional_info":{"payer":{"address":{"zip_code":"K1C2N6","street_name":"456 My Street Apt 1"}},"shipments":{"receiver_address":{"zip_code":"K1C2N6","street_name":"456 My Street Apt 1"}}},"order":{},"external_reference":"f70cb796271176441a5077012ff2af2a","transaction_amount":5,"transaction_amount_refunded":0,"coupon_amount":0,"differential_pricing_id":null,"deduction_schema":null,"transaction_details":{"payment_method_reference_id":null,"net_received_amount":4.79,"total_paid_amount":5,"overpaid_amount":0,"external_resource_url":null,"installment_amount":5,"financial_institution":null,"payable_deferral_period":null,"acquirer_reference":null},"fee_details":[{"type":"mercadopago_fee","amount":0.21,"fee_payer":"collector"}],"captured":true,"binary_mode":true,"call_for_authorize_id":null,"statement_descriptor":"SPREEDLYMLA","installments":1,"card":{"id":null,"first_six_digits":"603522","last_four_digits":"7021","expiration_month":10,"expiration_year":2020,"date_created":"2019-08-06T15:57:47.000-04:00","date_last_updated":"2019-08-06T15:57:47.000-04:00","cardholder":{"name":"John Smith","identification":{"number":null,"type":null}}},"notification_url":null,"refunds":[],"processing_mode":"aggregator","merchant_account_id":null,"acquirer":null,"merchant_number":null,"acquirer_reconciliation":[]}
+ )
+ end
+
def failed_capture_response
%(
{"message":"Method not allowed","error":"method_not_allowed","status":405,"cause":[{"code":"Method not allowed","description":"Method not allowed","data":null}]}
From ac7100fe30d82a461de977a9bbea4fccc5f88477 Mon Sep 17 00:00:00 2001
From: David Perry
Date: Fri, 13 Sep 2019 11:54:30 -0400
Subject: [PATCH 0448/2234] CyberSource: Pass commerce indicator if present
Closes #3350
Remote (5 unrelated failures also on master):
59 tests, 259 assertions, 5 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
91.5254% passed
Unit:
61 tests, 288 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/cyber_source.rb | 11 +++--------
test/remote/gateways/remote_cyber_source_test.rb | 3 ++-
test/unit/gateways/cyber_source_test.rb | 8 ++++++++
4 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 76d3f825d32..3082da22494 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -8,6 +8,7 @@
* Redsys: Add 3DS support to gateway [britth] #3336
* Worldpay: Allow multiple refunds per authorization [jknipp] #3349
* MercadoPago: Add remote and unit tests for Naranja card [hdeters] #3345
+* CyberSource: Pass commerce indicator if present [curiousepic] #3350
== Version 1.98.0 (Sep 9, 2019)
* Stripe Payment Intents: Add new gateway [britth] #3290
diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb
index ba4cb8438f9..d1c65ec2641 100644
--- a/lib/active_merchant/billing/gateways/cyber_source.rb
+++ b/lib/active_merchant/billing/gateways/cyber_source.rb
@@ -530,19 +530,14 @@ def add_auth_service(xml, payment_method, options)
add_auth_network_tokenization(xml, payment_method, options)
else
xml.tag! 'ccAuthService', {'run' => 'true'} do
- check_for_stored_cred_commerce_indicator(xml, options)
+ indicator = options[:commerce_indicator] || stored_credential_commerce_indicator(options)
+ xml.tag!('commerceIndicator', indicator) if indicator
end
end
end
- def check_for_stored_cred_commerce_indicator(xml, options)
+ def stored_credential_commerce_indicator(options)
return unless options[:stored_credential]
- if commerce_indicator(options)
- xml.tag!('commerceIndicator', commerce_indicator(options))
- end
- end
-
- def commerce_indicator(options)
return if options[:stored_credential][:initial_transaction]
case options[:stored_credential][:reason_type]
when 'installment' then 'install'
diff --git a/test/remote/gateways/remote_cyber_source_test.rb b/test/remote/gateways/remote_cyber_source_test.rb
index c295737a0a6..8b0683ad631 100644
--- a/test/remote/gateways/remote_cyber_source_test.rb
+++ b/test/remote/gateways/remote_cyber_source_test.rb
@@ -55,7 +55,8 @@ def setup
],
:currency => 'USD',
:ignore_avs => 'true',
- :ignore_cvv => 'true'
+ :ignore_cvv => 'true',
+ :commerce_indicator => 'internet'
}
@subscription_options = {
diff --git a/test/unit/gateways/cyber_source_test.rb b/test/unit/gateways/cyber_source_test.rb
index c71a31aed9b..dabe29eb90e 100644
--- a/test/unit/gateways/cyber_source_test.rb
+++ b/test/unit/gateways/cyber_source_test.rb
@@ -118,6 +118,14 @@ def test_authorize_includes_mdd_fields
end.respond_with(successful_authorization_response)
end
+ def test_authorize_includes_commerce_indicator
+ stub_comms do
+ @gateway.authorize(100, @credit_card, commerce_indicator: 'internet')
+ end.check_request do |endpoint, data, headers|
+ assert_match(/internet<\/commerceIndicator>/m, data)
+ end.respond_with(successful_authorization_response)
+ end
+
def test_successful_check_purchase
@gateway.expects(:ssl_post).returns(successful_purchase_response)
From 04af0f449fa220172bb5b2b75b553c6704f50752 Mon Sep 17 00:00:00 2001
From: Niaja
Date: Mon, 8 Jul 2019 13:35:33 -0400
Subject: [PATCH 0449/2234] Worldpay: Add 3DS2 Support
Adds 3DS support to worldpay gateway. Two remote tests failing that are
unlreated.
Loaded suite test/remote/gateways/remote_worldpay_test
.................................................
51 tests, 221 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
96.0784% passed
Loaded suite test/unit/gateways/worldpay_test
Started
...................................................................
67 tests, 397 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/worldpay.rb | 13 ++++++++++++-
test/remote/gateways/remote_worldpay_test.rb | 8 ++++++++
test/unit/gateways/worldpay_test.rb | 10 ++++++++++
4 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 3082da22494..b09602200ba 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -9,6 +9,7 @@
* Worldpay: Allow multiple refunds per authorization [jknipp] #3349
* MercadoPago: Add remote and unit tests for Naranja card [hdeters] #3345
* CyberSource: Pass commerce indicator if present [curiousepic] #3350
+* Worldpay: Add 3DS2 Support [nfarve] #3344
== Version 1.98.0 (Sep 9, 2019)
* Stripe Payment Intents: Add new gateway [britth] #3290
diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb
index 35857ea32f6..050fd5f1aa2 100644
--- a/lib/active_merchant/billing/gateways/worldpay.rb
+++ b/lib/active_merchant/billing/gateways/worldpay.rb
@@ -208,6 +208,8 @@ def build_authorization_request(money, payment_method, options)
add_instalments_data(xml, options)
end
add_moto_flag(xml, options) if options.dig(:metadata, :manual_entry)
+ add_additional_3ds_data(xml, options) if options[:execute_threed] && options[:three_ds_version] && options[:three_ds_version] =~ /^2/
+ add_3ds_exemption(xml, options) if options[:exemption_type]
end
end
end
@@ -257,6 +259,14 @@ def build_store_request(credit_card, options)
end
end
+ def add_additional_3ds_data(xml, options)
+ xml.tag! 'additional3DSData', 'dfReferenceId' => options[:session_id]
+ end
+
+ def add_3ds_exemption(xml, options)
+ xml.tag! 'exemption', 'type' => options[:exemption_type], 'placement' => options[:exemption_placement] || 'AUTHORISATION'
+ end
+
def add_amount(xml, money, options)
currency = options[:currency] || currency(money)
@@ -329,7 +339,7 @@ def add_card(xml, payment_method, options)
xml.tag! 'date', 'month' => format(payment_method.month, :two_digits), 'year' => format(payment_method.year, :four_digits)
end
- xml.tag! 'cardHolderName', options[:execute_threed] ? '3D' : payment_method.name
+ xml.tag! 'cardHolderName', options[:execute_threed] && (options[:three_ds_version] =~ /[^2]/).nil? ? '3D' : payment_method.name
xml.tag! 'cvc', payment_method.verification_value
add_address(xml, (options[:billing_address] || options[:address]))
@@ -481,6 +491,7 @@ def commit(action, request, *success_criteria, options)
if options[:execute_threed]
raw[:cookie] = @cookie
raw[:session_id] = options[:session_id]
+ raw[:is3DSOrder] = true
end
success = success_from(action, raw, success_criteria)
message = message_from(success, raw, success_criteria)
diff --git a/test/remote/gateways/remote_worldpay_test.rb b/test/remote/gateways/remote_worldpay_test.rb
index 497a143145e..6bd0f20b149 100644
--- a/test/remote/gateways/remote_worldpay_test.rb
+++ b/test/remote/gateways/remote_worldpay_test.rb
@@ -19,6 +19,7 @@ def setup
@sodexo_voucher = credit_card('6060704495764400', brand: 'sodexo')
@declined_card = credit_card('4111111111111111', :first_name => nil, :last_name => 'REFUSED')
@threeDS_card = credit_card('4111111111111111', :first_name => nil, :last_name => '3D')
+ @threeDS2_card = credit_card('4111111111111111', :first_name => nil, :last_name => '3DS_V2_FRICTIONLESS_IDENTIFIED')
@threeDS_card_external_MPI = credit_card('4444333322221111', :first_name => 'AA', :last_name => 'BD')
@options = {
@@ -52,6 +53,13 @@ def test_successful_authorize_avs_and_cvv
assert_match %r{CVV matches}, response.cvv_result['message']
end
+ def test_successful_3ds2_authorize
+ options = @options.merge({execute_threed: true, three_ds_version: '2.0'})
+ assert response = @gateway.authorize(@amount, @threeDS2_card, options)
+ assert_success response
+ assert_equal 'SUCCESS', response.message
+ end
+
def test_successful_purchase_with_hcg_additional_data
@options[:hcg_additional_data] = {
key1: 'value1',
diff --git a/test/unit/gateways/worldpay_test.rb b/test/unit/gateways/worldpay_test.rb
index 531ef493450..d74f646efc3 100644
--- a/test/unit/gateways/worldpay_test.rb
+++ b/test/unit/gateways/worldpay_test.rb
@@ -48,6 +48,16 @@ def test_successful_authorize_by_reference
assert_equal 'R50704213207145707', response.authorization
end
+ def test_exemption_in_request
+ response = stub_comms do
+ @gateway.authorize(@amount, @credit_card, @options.merge({exemption_type: 'LV', exemption_placement: 'AUTHENTICATION'}))
+ end.check_request do |endpoint, data, headers|
+ assert_match(/exemption/, data)
+ assert_match(/AUTHENTICATION/, data)
+ end.respond_with(successful_authorize_response)
+ assert_success response
+ end
+
def test_successful_reference_transaction_authorize_with_merchant_code
response = stub_comms do
@gateway.authorize(@amount, @options[:order_id].to_s, @options.merge({ merchant_code: 'testlogin2'}))
From 20b865be8e73bb797d1de14fdb0dfb7414e28799 Mon Sep 17 00:00:00 2001
From: Niaja
Date: Mon, 8 Jul 2019 13:35:33 -0400
Subject: [PATCH 0450/2234] Worldpay: Add 3DS2 Support
Adds 3DS support to worldpay gateway. Two remote tests failing that are
unlreated.
Loaded suite test/remote/gateways/remote_worldpay_test
.................................................
51 tests, 221 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
96.0784% passed
Loaded suite test/unit/gateways/worldpay_test
Started
...................................................................
67 tests, 397 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
lib/active_merchant/billing/gateways/worldpay.rb | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb
index 050fd5f1aa2..44d3607ad5d 100644
--- a/lib/active_merchant/billing/gateways/worldpay.rb
+++ b/lib/active_merchant/billing/gateways/worldpay.rb
@@ -339,7 +339,8 @@ def add_card(xml, payment_method, options)
xml.tag! 'date', 'month' => format(payment_method.month, :two_digits), 'year' => format(payment_method.year, :four_digits)
end
- xml.tag! 'cardHolderName', options[:execute_threed] && (options[:three_ds_version] =~ /[^2]/).nil? ? '3D' : payment_method.name
+ three_ds_version = options[:three_ds_version] || options[:three_d_secure][:version]
+ xml.tag! 'cardHolderName', options[:execute_threed] && (three_ds_version =~ /[^2]/).nil? ? '3D' : payment_method.name
xml.tag! 'cvc', payment_method.verification_value
add_address(xml, (options[:billing_address] || options[:address]))
From 76e034db75c9744ce182231bf7342ba155042487 Mon Sep 17 00:00:00 2001
From: Niaja
Date: Mon, 16 Sep 2019 16:01:49 -0400
Subject: [PATCH 0451/2234] Revert "Worldpay: Add 3DS2 Support"
This reverts commit 20b865be8e73bb797d1de14fdb0dfb7414e28799.
---
lib/active_merchant/billing/gateways/worldpay.rb | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb
index 44d3607ad5d..050fd5f1aa2 100644
--- a/lib/active_merchant/billing/gateways/worldpay.rb
+++ b/lib/active_merchant/billing/gateways/worldpay.rb
@@ -339,8 +339,7 @@ def add_card(xml, payment_method, options)
xml.tag! 'date', 'month' => format(payment_method.month, :two_digits), 'year' => format(payment_method.year, :four_digits)
end
- three_ds_version = options[:three_ds_version] || options[:three_d_secure][:version]
- xml.tag! 'cardHolderName', options[:execute_threed] && (three_ds_version =~ /[^2]/).nil? ? '3D' : payment_method.name
+ xml.tag! 'cardHolderName', options[:execute_threed] && (options[:three_ds_version] =~ /[^2]/).nil? ? '3D' : payment_method.name
xml.tag! 'cvc', payment_method.verification_value
add_address(xml, (options[:billing_address] || options[:address]))
From c9a851ce60038bff75a7b9c015bdea72ccf8f4a5 Mon Sep 17 00:00:00 2001
From: Niaja
Date: Fri, 6 Sep 2019 15:33:07 -0400
Subject: [PATCH 0452/2234] Credorax: Add 3DS 2.0
Adds 3DS 2.0 fields to credorax and a new field that is required for
passing 3DS authenticated fields.
Loaded suite test/remote/gateways/remote_credorax_test
..........................
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
26 tests, 73 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Loaded suite test/unit/gateways/credorax_test
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
23 tests, 124 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---
CHANGELOG | 1 +
.../billing/gateways/credorax.rb | 29 +++++++++-
test/remote/gateways/remote_credorax_test.rb | 35 ++++++++++-
test/unit/gateways/credorax_test.rb | 58 +++++++++++++++++++
4 files changed, 121 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index b09602200ba..8988b783944 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -10,6 +10,7 @@
* MercadoPago: Add remote and unit tests for Naranja card [hdeters] #3345
* CyberSource: Pass commerce indicator if present [curiousepic] #3350
* Worldpay: Add 3DS2 Support [nfarve] #3344
+* Credorax: Add 3DS 2.0 [nfarve] #3342
== Version 1.98.0 (Sep 9, 2019)
* Stripe Payment Intents: Add new gateway [britth] #3290
diff --git a/lib/active_merchant/billing/gateways/credorax.rb b/lib/active_merchant/billing/gateways/credorax.rb
index 6f28d82f259..94bae1251a3 100644
--- a/lib/active_merchant/billing/gateways/credorax.rb
+++ b/lib/active_merchant/billing/gateways/credorax.rb
@@ -270,6 +270,30 @@ def add_email(post, options)
def add_3d_secure(post, options)
if options[:eci] && options[:xid]
add_3d_secure_1_data(post, options)
+ elsif options[:execute_threed] && options[:three_ds_2]
+ three_ds_2_options = options[:three_ds_2]
+ browser_info = three_ds_2_options[:browser_info]
+ post[:'3ds_initiate'] = options[:three_ds_initiate] || '01'
+ post[:'3ds_purchasedate'] = Time.now.utc.strftime('%Y%m%d%I%M%S')
+ post[:'3ds_channel'] = '02'
+ post[:'3ds_redirect_url'] = three_ds_2_options[:notification_url]
+ post[:'3ds_challengewindowsize'] = options[:three_ds_challenge_window_size] || '03'
+ post[:d5] = browser_info[:user_agent]
+ post[:'3ds_browsertz'] = browser_info[:timezone]
+ post[:'3ds_browserscreenwidth'] = browser_info[:width]
+ post[:'3ds_browserscreenheight'] = browser_info[:height]
+ post[:'3ds_browsercolordepth'] = browser_info[:depth]
+ post[:d6] = browser_info[:language]
+ post[:'3ds_browserjavaenabled'] = browser_info[:java]
+ post[:'3ds_browseracceptheader'] = browser_info[:accept_header]
+ if (shipping_address = options[:shipping_address])
+ post[:'3ds_shipaddrstate'] = shipping_address[:state]
+ post[:'3ds_shipaddrpostcode'] = shipping_address[:zip]
+ post[:'3ds_shipaddrline2'] = shipping_address[:address2]
+ post[:'3ds_shipaddrline1'] = shipping_address[:address1]
+ post[:'3ds_shipaddrcountry'] = shipping_address[:country]
+ post[:'3ds_shipaddrcity'] = shipping_address[:city]
+ end
elsif options[:three_d_secure]
add_normalized_3d_secure_2_data(post, options)
end
@@ -277,6 +301,7 @@ def add_3d_secure(post, options)
def add_3d_secure_1_data(post, options)
post[:i8] = build_i8(options[:eci], options[:cavv], options[:xid])
+ post[:r1] = 'CREDORAX'
end
def add_normalized_3d_secure_2_data(post, options)
@@ -288,6 +313,7 @@ def add_normalized_3d_secure_2_data(post, options)
)
post[:'3ds_version'] = three_d_secure_options[:version]
post[:'3ds_dstrxid'] = three_d_secure_options[:ds_transaction_id]
+ post[:r1] = 'CREDORAX'
end
def build_i8(eci, cavv=nil, xid=nil)
@@ -317,7 +343,8 @@ def add_transaction_type(post, options)
credit: '6',
purchase_void: '7',
refund_void: '8',
- capture_void: '9'
+ capture_void: '9',
+ threeds_completion: '92'
}
def commit(action, params, reference_action = nil)
diff --git a/test/remote/gateways/remote_credorax_test.rb b/test/remote/gateways/remote_credorax_test.rb
index f826f157987..7997fc593b8 100644
--- a/test/remote/gateways/remote_credorax_test.rb
+++ b/test/remote/gateways/remote_credorax_test.rb
@@ -8,12 +8,39 @@ def setup
@credit_card = credit_card('4176661000001015', verification_value: '281', month: '12', year: '2022')
@fully_auth_card = credit_card('5223450000000007', brand: 'mastercard', verification_value: '090', month: '12', year: '2025')
@declined_card = credit_card('4176661000001111', verification_value: '681', month: '12', year: '2022')
+ @three_ds_card = credit_card('5185520050000010', verification_value: '737', month: '12', year: '2022')
@options = {
order_id: '1',
currency: 'EUR',
billing_address: address,
description: 'Store Purchase'
}
+ @normalized_3ds_2_options = {
+ reference: '345123',
+ shopper_email: 'john.smith@test.com',
+ shopper_ip: '77.110.174.153',
+ shopper_reference: 'John Smith',
+ billing_address: address(),
+ shipping_address: address(),
+ order_id: '123',
+ execute_threed: true,
+ three_ds_challenge_window_size: '01',
+ stored_credential: {reason_type: 'unscheduled'},
+ three_ds_2: {
+ channel: 'browser',
+ notification_url: 'www.example.com',
+ browser_info: {
+ accept_header: 'unknown',
+ depth: 24,
+ java: false,
+ language: 'US',
+ height: 1000,
+ width: 500,
+ timezone: '-120',
+ user_agent: 'unknown'
+ }
+ }
+ }
end
def test_invalid_login
@@ -49,6 +76,12 @@ def test_successful_purchase_with_auth_data_via_3ds1_fields
assert_equal 'Succeeded', response.message
end
+ def test_successful_purchase_with_3ds2_fields
+ options = @options.merge(@normalized_3ds_2_options)
+ response = @gateway.purchase(@amount, @three_ds_card, options)
+ assert_equal 'Transaction pending cardholder authentication.', response.message
+ end
+
def test_successful_purchase_with_auth_data_via_normalized_3ds2_options
version = '2.0'
eci = '02'
@@ -91,7 +124,7 @@ def test_failed_purchase_invalid_auth_data_via_3ds1_fields
def test_failed_purchase_invalid_auth_data_via_normalized_3ds2_options
version = '2.0'
eci = '02'
- cavv = 'BOGUS'
+ cavv = 'BOGUS;:'
ds_transaction_id = '97267598-FAE6-48F2-8083-C23433990FBC'
options = @options.merge(
three_d_secure: {
diff --git a/test/unit/gateways/credorax_test.rb b/test/unit/gateways/credorax_test.rb
index f353c0297fb..06955aa118c 100644
--- a/test/unit/gateways/credorax_test.rb
+++ b/test/unit/gateways/credorax_test.rb
@@ -12,6 +12,33 @@ def setup
billing_address: address,
description: 'Store Purchase'
}
+
+ @normalized_3ds_2_options = {
+ reference: '345123',
+ shopper_email: 'john.smith@test.com',
+ shopper_ip: '77.110.174.153',
+ shopper_reference: 'John Smith',
+ billing_address: address(),
+ shipping_address: address(),
+ order_id: '123',
+ execute_threed: true,
+ three_ds_challenge_window_size: '01',
+ stored_credential: {reason_type: 'unscheduled'},
+ three_ds_2: {
+ channel: 'browser',
+ notification_url: 'www.example.com',
+ browser_info: {
+ accept_header: 'unknown',
+ depth: 100,
+ java: false,
+ language: 'US',
+ height: 1000,
+ width: 500,
+ timezone: '-120',
+ user_agent: 'unknown'
+ }
+ }
+ }
end
def test_successful_purchase
@@ -174,6 +201,37 @@ def test_transcript_scrubbing
assert_equal scrubbed_transcript, @gateway.scrub(transcript)
end
+ def test_adds_3d2_secure_fields
+ options_with_3ds = @normalized_3ds_2_options
+
+ response = stub_comms do
+ @gateway.purchase(@amount, @credit_card, options_with_3ds)
+ end.check_request do |endpoint, data, headers|
+ assert_match(/3ds_channel=02/, data)
+ assert_match(/3ds_redirect_url=www.example.com/, data)
+ assert_match(/3ds_challengewindowsize=01/, data)
+ assert_match(/d5=unknown/, data)
+ assert_match(/3ds_browsertz=-120/, data)
+ assert_match(/3ds_browserscreenwidth=500/, data)
+ assert_match(/3ds_browserscreenheight=1000/, data)
+ assert_match(/3ds_browsercolordepth=100/, data)
+ assert_match(/d6=US/, data)
+ assert_match(/3ds_browserjavaenabled=false/, data)
+ assert_match(/3ds_browseracceptheader=unknown/, data)
+ assert_match(/3ds_shipaddrstate=ON/, data)
+ assert_match(/3ds_shipaddrpostcode=K1C2N6/, data)
+ assert_match(/3ds_shipaddrline2=Apt\+1/, data)
+ assert_match(/3ds_shipaddrline1=456\+My\+Street/, data)
+ assert_match(/3ds_shipaddrcountry=CA/, data)
+ assert_match(/3ds_shipaddrcity=Ottawa/, data)
+ end.respond_with(successful_purchase_response)
+
+ assert_success response
+
+ assert_equal '8a82944a5351570601535955efeb513c;006596;02617cf5f02ccaed239b6521748298c5;purchase', response.authorization
+ assert response.test?
+ end
+
def test_adds_3d_secure_fields
options_with_3ds = @options.merge({eci: 'sample-eci', cavv: 'sample-cavv', xid: 'sample-xid'})
From a9280e361014b7b29c5fac026ae5698cd624adc0 Mon Sep 17 00:00:00 2001
From: David Perry
Date: Wed, 11 Sep 2019 10:01:40 -0400
Subject: [PATCH 0453/2234] TNS: Update verison and support pay mode
This is an account-level flag that allows single-step purchases.
Test cards were updated to use expiry date to invoke response codes
according to https://na-gateway.mastercard.com/api/documentation/integrationGuidelines/supportedFeatures/testAndGoLive.html?locale=en_US
Closes #3355
Remote (1 unrelated failure due to regional test account):
14 tests, 48 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
92.8571% passed
Unit:
17 tests, 78 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/mastercard.rb | 17 ++++++++++++++---
lib/active_merchant/billing/gateways/tns.rb | 14 ++++++++------
test/fixtures.yml | 5 +++++
test/remote/gateways/remote_tns_test.rb | 18 +++++++++++++++---
5 files changed, 43 insertions(+), 12 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 8988b783944..f796f0d9253 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -11,6 +11,7 @@
* CyberSource: Pass commerce indicator if present [curiousepic] #3350
* Worldpay: Add 3DS2 Support [nfarve] #3344
* Credorax: Add 3DS 2.0 [nfarve] #3342
+* TNS: Update verison and support pay mode [curiousepic] #3355
== Version 1.98.0 (Sep 9, 2019)
* Stripe Payment Intents: Add new gateway [britth] #3290
diff --git a/lib/active_merchant/billing/gateways/mastercard.rb b/lib/active_merchant/billing/gateways/mastercard.rb
index 0a1517d526f..e2f31193ea9 100644
--- a/lib/active_merchant/billing/gateways/mastercard.rb
+++ b/lib/active_merchant/billing/gateways/mastercard.rb
@@ -7,9 +7,20 @@ def initialize(options={})
end
def purchase(amount, payment_method, options={})
- MultiResponse.run do |r|
- r.process { authorize(amount, payment_method, options) }
- r.process { capture(amount, r.authorization, options) }
+ if options[:pay_mode]
+ post = new_post
+ add_invoice(post, amount, options)
+ add_reference(post, *new_authorization)
+ add_payment_method(post, payment_method)
+ add_customer_data(post, payment_method, options)
+ add_3dsecure_id(post, options)
+
+ commit('pay', post)
+ else
+ MultiResponse.run do |r|
+ r.process { authorize(amount, payment_method, options) }
+ r.process { capture(amount, r.authorization, options) }
+ end
end
end
diff --git a/lib/active_merchant/billing/gateways/tns.rb b/lib/active_merchant/billing/gateways/tns.rb
index 33bf3196976..ac58f510120 100644
--- a/lib/active_merchant/billing/gateways/tns.rb
+++ b/lib/active_merchant/billing/gateways/tns.rb
@@ -5,14 +5,16 @@ class TnsGateway < Gateway
class_attribute :live_na_url, :live_ap_url, :live_eu_url, :test_na_url, :test_ap_url, :test_eu_url
- self.live_na_url = 'https://secure.na.tnspayments.com/api/rest/version/36/'
- self.test_na_url = 'https://secure.na.tnspayments.com/api/rest/version/36/'
+ VERSION = '52'
- self.live_ap_url = 'https://secure.ap.tnspayments.com/api/rest/version/36/'
- self.test_ap_url = 'https://secure.ap.tnspayments.com/api/rest/version/36/'
+ self.live_na_url = "https://secure.na.tnspayments.com/api/rest/version/#{VERSION}/"
+ self.test_na_url = "https://secure.na.tnspayments.com/api/rest/version/#{VERSION}/"
- self.live_eu_url = 'https://secure.eu.tnspayments.com/api/rest/version/36/'
- self.test_eu_url = 'https://secure.eu.tnspayments.com/api/rest/version/36/'
+ self.live_ap_url = "https://secure.ap.tnspayments.com/api/rest/version/#{VERSION}/"
+ self.test_ap_url = "https://secure.ap.tnspayments.com/api/rest/version/#{VERSION}/"
+
+ self.live_eu_url = "https://secure.eu.tnspayments.com/api/rest/version/#{VERSION}/"
+ self.test_eu_url = "https://secure.eu.tnspayments.com/api/rest/version/#{VERSION}/"
self.display_name = 'TNS'
self.homepage_url = 'http://www.tnsi.com/'
diff --git a/test/fixtures.yml b/test/fixtures.yml
index 7f8439a76eb..2b9a8e14318 100644
--- a/test/fixtures.yml
+++ b/test/fixtures.yml
@@ -1184,10 +1184,15 @@ tns:
userid: TESTSPREEDLY01
password: 3f34fe50334fbe6cbe04c283411a5860
+# This account seem to have expired
tns_ap:
userid: TESTUNISOLMAA01
password: b7f8119fda3bd27c17656badb52c95bb
+tns_pay_mode:
+ userid: USERID
+ password: password
+
trans_first:
login: 45567
password: TNYYKYMFZ59HSN7Q
diff --git a/test/remote/gateways/remote_tns_test.rb b/test/remote/gateways/remote_tns_test.rb
index cc1aa80efa1..2a55bbd1853 100644
--- a/test/remote/gateways/remote_tns_test.rb
+++ b/test/remote/gateways/remote_tns_test.rb
@@ -7,9 +7,9 @@ def setup
@gateway = TnsGateway.new(fixtures(:tns))
@amount = 100
- @credit_card = credit_card('5123456789012346')
- @ap_credit_card = credit_card('5424180279791732', month: 05, year: 2017, verification_value: 222)
- @declined_card = credit_card('4000300011112220')
+ @credit_card = credit_card('5123456789012346', month: 05, year: 2021)
+ @ap_credit_card = credit_card('5424180279791732', month: 05, year: 2021)
+ @declined_card = credit_card('5123456789012346', month: 01, year: 2028)
@options = {
order_id: generate_unique_id,
@@ -45,6 +45,18 @@ def test_successful_purchase_with_more_options
assert_equal 'Succeeded', response.message
end
+ # This requires a test account flagged for pay/purchase mode.
+ # The primary test account (TESTSPREEDLY01) is not flagged for this mode.
+ # This was initially tested with a private account.
+ def test_successful_purchase_in_pay_mode
+ gateway = TnsGateway.new(fixtures(:tns_pay_mode).merge(region: 'europe'))
+
+ assert response = gateway.purchase(@amount, @credit_card, @options.merge(currency: 'GBP', pay_mode: true))
+ assert_success response
+ assert_equal 'Succeeded', response.message
+ assert_equal 'CAPTURED', response.params['order']['status']
+ end
+
def test_successful_purchase_with_region
@gateway = TnsGateway.new(fixtures(:tns_ap).merge(region: 'asia_pacific'))
From 4df499ac0c5452c5164d46549d63ce2b3e785717 Mon Sep 17 00:00:00 2001
From: Ruthan
Date: Tue, 17 Sep 2019 16:39:42 -0400
Subject: [PATCH 0454/2234] Stripe: add countries to supported list
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/stripe.rb | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index f796f0d9253..8cfb103dfdf 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -12,6 +12,7 @@
* Worldpay: Add 3DS2 Support [nfarve] #3344
* Credorax: Add 3DS 2.0 [nfarve] #3342
* TNS: Update verison and support pay mode [curiousepic] #3355
+* Stripe: Add supported countries [therufs] #3358
== Version 1.98.0 (Sep 9, 2019)
* Stripe Payment Intents: Add new gateway [britth] #3290
diff --git a/lib/active_merchant/billing/gateways/stripe.rb b/lib/active_merchant/billing/gateways/stripe.rb
index ffa022c58d7..faa11772e66 100644
--- a/lib/active_merchant/billing/gateways/stripe.rb
+++ b/lib/active_merchant/billing/gateways/stripe.rb
@@ -25,7 +25,7 @@ class StripeGateway < Gateway
DEFAULT_API_VERSION = '2015-04-07'
- self.supported_countries = %w(AT AU BE BR CA CH DE DK ES FI FR GB HK IE IT JP LU MX NL NO NZ PT SE SG US)
+ self.supported_countries = %w(AT AU BE BR CA CH DE DK EE ES FI FR GB GR HK IE IT JP LT LU LV MX NL NO NZ PL PT SE SG SI SK US)
self.default_currency = 'USD'
self.money_format = :cents
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners_club, :maestro]
From 515836147c96997f778db8ed4cf11c6f5be5ddfb Mon Sep 17 00:00:00 2001
From: Ruthan
Date: Tue, 17 Sep 2019 16:50:12 -0400
Subject: [PATCH 0455/2234] Stripe Payment Intents: add supported countries
---
CHANGELOG | 1 +
lib/active_merchant/billing/gateways/stripe_payment_intents.rb | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 8cfb103dfdf..364e3a855ef 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -13,6 +13,7 @@
* Credorax: Add 3DS 2.0 [nfarve] #3342
* TNS: Update verison and support pay mode [curiousepic] #3355
* Stripe: Add supported countries [therufs] #3358
+* Stripe Payment Intents: Add supported countries [therufs] #3359
== Version 1.98.0 (Sep 9, 2019)
* Stripe Payment Intents: Add new gateway [britth] #3290
diff --git a/lib/active_merchant/billing/gateways/stripe_payment_intents.rb b/lib/active_merchant/billing/gateways/stripe_payment_intents.rb
index 6afd036e7aa..6262abc53b8 100644
--- a/lib/active_merchant/billing/gateways/stripe_payment_intents.rb
+++ b/lib/active_merchant/billing/gateways/stripe_payment_intents.rb
@@ -6,7 +6,7 @@ module Billing #:nodoc:
# For the legacy API, see the Stripe gateway
class StripePaymentIntentsGateway < StripeGateway
- self.supported_countries = %w(AT AU BE BR CA CH DE DK ES FI FR GB HK IE IT JP LU MX NL NO NZ PT SE SG US)
+ self.supported_countries = %w(AT AU BE BR CA CH DE DK EE ES FI FR GB GR HK IE IT JP LT LU LV MX NL NO NZ PL PT SE SG SI SK US)
ALLOWED_METHOD_STATES = %w[automatic manual].freeze
ALLOWED_CANCELLATION_REASONS = %w[duplicate fraudulent requested_by_customer abandoned].freeze
From b1e0807f4306ffe2d2c7a4bec9bb2914ff79994e Mon Sep 17 00:00:00 2001
From: Jason Nappier
Date: Fri, 13 Sep 2019 17:52:00 -0400
Subject: [PATCH 0456/2234] Mundipagg: Append error messages to the message
response field
For purchase, authorize, and store, extract any error messages from the
gateway response and append them to the "message" response feld. Mundipagg
can return errors at either the top level of the response object, or under
the last_transaction gateway_response key.
CE-114
Unit:
4268 tests, 70604 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications
100% passed
Remote:
37 tests, 93 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/mundipagg.rb | 37 +++-
test/remote/gateways/remote_mundipagg_test.rb | 30 +++
test/unit/gateways/mundipagg_test.rb | 193 ++++++++++++++++++
4 files changed, 256 insertions(+), 5 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 364e3a855ef..0727ffe0a39 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -14,6 +14,7 @@
* TNS: Update verison and support pay mode [curiousepic] #3355
* Stripe: Add supported countries [therufs] #3358
* Stripe Payment Intents: Add supported countries [therufs] #3359
+* Mundipagg: Append error messages to the message response field [jasonxp] #3353
== Version 1.98.0 (Sep 9, 2019)
* Stripe Payment Intents: Add new gateway [britth] #3290
diff --git a/lib/active_merchant/billing/gateways/mundipagg.rb b/lib/active_merchant/billing/gateways/mundipagg.rb
index e66a6b94680..447a708c0fb 100644
--- a/lib/active_merchant/billing/gateways/mundipagg.rb
+++ b/lib/active_merchant/billing/gateways/mundipagg.rb
@@ -249,7 +249,8 @@ def commit(action, parameters, auth = nil)
error_code: error_code_from(response)
)
rescue ResponseError => e
- message = get_error_message(e)
+ message = get_error_messages(e)
+
return Response.new(
false,
"#{STANDARD_ERROR_MESSAGE_MAPPING[e.response.code]} #{message}",
@@ -263,15 +264,41 @@ def success_from(response)
%w[pending paid processing canceled active].include? response['status']
end
- def get_error_message(error)
- JSON.parse(error.response.body)['message']
- end
-
def message_from(response)
+ return gateway_response_errors(response) if gateway_response_errors?(response)
return response['message'] if response['message']
return response['last_transaction']['acquirer_message'] if response['last_transaction']
end
+ def get_error_messages(error)
+ parsed_response_body = parse(error.response.body)
+ message = parsed_response_body['message']
+
+ parsed_response_body['errors']&.each do |type, descriptions|
+ message += ' | '
+ message += descriptions.join(', ')
+ end
+
+ message
+ end
+
+ def gateway_response_errors?(response)
+ response.try(:[], 'last_transaction').try(:[], 'gateway_response').try(:[], 'errors').present?
+ end
+
+ def gateway_response_errors(response)
+ error_string = ''
+
+ response['last_transaction']['gateway_response']['errors']&.each do |error|
+ error.each do |key, value|
+ error_string += ' | ' unless error_string.blank?
+ error_string += value
+ end
+ end
+
+ error_string
+ end
+
def authorization_from(response, action)
return "#{response['customer']['id']}|#{response['id']}" if action == 'store'
response['id']
diff --git a/test/remote/gateways/remote_mundipagg_test.rb b/test/remote/gateways/remote_mundipagg_test.rb
index e1c16f2cc67..9a3f6f61bfc 100644
--- a/test/remote/gateways/remote_mundipagg_test.rb
+++ b/test/remote/gateways/remote_mundipagg_test.rb
@@ -21,6 +21,9 @@ def setup
billing_address: address({neighborhood: 'Sesame Street'}),
description: 'Store Purchase'
}
+
+ @excess_length_neighborhood = address({neighborhood: 'Super Long Neighborhood Name' * 5})
+ @neighborhood_length_error = 'Invalid parameters; The request is invalid. | The field neighborhood must be a string with a maximum length of 64.'
end
def test_successful_purchase
@@ -68,6 +71,15 @@ def test_failed_purchase
test_failed_purchase_with(@declined_card)
end
+ def test_failed_purchase_with_top_level_errors
+ @options[:billing_address] = @excess_length_neighborhood
+
+ response = @gateway.purchase(105200, @credit_card, @options)
+
+ assert_failure response
+ assert_equal @neighborhood_length_error, response.message
+ end
+
def test_failed_purchase_with_alelo_card
test_failed_purchase_with(@declined_alelo_voucher)
end
@@ -88,6 +100,15 @@ def test_failed_authorize_with_alelo_card
test_failed_authorize_with(@declined_alelo_voucher)
end
+ def test_failed_authorize_with_top_level_errors
+ @options[:billing_address] = @excess_length_neighborhood
+
+ response = @gateway.authorize(@amount, @credit_card, @options)
+
+ assert_failure response
+ assert_equal @neighborhood_length_error, response.message
+ end
+
def test_partial_capture
test_partial_capture_with(@credit_card)
end
@@ -190,6 +211,15 @@ def test_successful_store_and_purchase_with_alelo_card
test_successful_store_and_purchase_with(@alelo_voucher)
end
+ def test_failed_store_with_top_level_errors
+ @options[:billing_address] = @excess_length_neighborhood
+
+ response = @gateway.store(@credit_card, @options)
+
+ assert_failure response
+ assert_equal @neighborhood_length_error, response.message
+ end
+
def test_invalid_login
gateway = MundipaggGateway.new(api_key: '')
diff --git a/test/unit/gateways/mundipagg_test.rb b/test/unit/gateways/mundipagg_test.rb
index b6806224f3a..fd0af377ec6 100644
--- a/test/unit/gateways/mundipagg_test.rb
+++ b/test/unit/gateways/mundipagg_test.rb
@@ -38,6 +38,8 @@ def setup
billing_address: address,
description: 'Store Purchase'
}
+
+ @gateway_response_error = 'Esta loja n??o possui um meio de pagamento configurado para a bandeira VR'
end
def test_successful_purchase
@@ -81,6 +83,23 @@ def test_failed_purchase
assert_equal Gateway::STANDARD_ERROR_CODE[:processing_error], response.error_code
end
+ def test_failed_purchase_with_top_level_errors
+ @gateway.expects(:ssl_post).raises(mock_response_error)
+
+ response = @gateway.purchase(@amount, @credit_card, @options)
+
+ assert_invalid_parameter_errors(response)
+ end
+
+ def test_failed_purchase_with_gateway_response_errors
+ @gateway.expects(:ssl_post).returns(failed_response_with_gateway_response_errors)
+
+ response = @gateway.purchase(@amount, @credit_card, @options)
+
+ assert_success response
+ assert_equal @gateway_response_error, response.message
+ end
+
def test_successful_authorize
@gateway.expects(:ssl_post).returns(successful_authorize_response)
@@ -113,6 +132,23 @@ def test_failed_authorize
assert_equal Gateway::STANDARD_ERROR_CODE[:processing_error], response.error_code
end
+ def test_failed_authorize_with_top_level_errors
+ @gateway.expects(:ssl_post).raises(mock_response_error)
+
+ response = @gateway.authorize(@amount, @credit_card, @options)
+
+ assert_invalid_parameter_errors(response)
+ end
+
+ def test_failed_authorize_with_gateway_response_errors
+ @gateway.expects(:ssl_post).returns(failed_response_with_gateway_response_errors)
+
+ response = @gateway.authorize(@amount, @credit_card, @options)
+
+ assert_success response
+ assert_equal @gateway_response_error, response.message
+ end
+
def test_successful_capture
@gateway.expects(:ssl_post).returns(successful_capture_response)
@@ -196,6 +232,23 @@ def test_sucessful_store
assert response.test?
end
+ def test_failed_store_with_top_level_errors
+ @gateway.expects(:ssl_post).times(2).raises(mock_response_error)
+
+ response = @gateway.store(@credit_card, @options)
+
+ assert_invalid_parameter_errors(response)
+ end
+
+ def test_failed_store_with_gateway_response_errors
+ @gateway.expects(:ssl_post).times(2).returns(failed_response_with_gateway_response_errors)
+
+ response = @gateway.store(@credit_card, @options)
+
+ assert_success response
+ assert_equal @gateway_response_error, response.message
+ end
+
def test_gateway_id_fallback
gateway = MundipaggGateway.new(api_key: 'my_api_key', gateway_id: 'abc123')
options = {
@@ -227,6 +280,22 @@ def test_successful_purchase_with(card)
assert response.test?
end
+ def mock_response_error
+ mock_response = Net::HTTPUnprocessableEntity.new('1.1', '422', 'Unprocessable Entity')
+ mock_response.stubs(:body).returns(failed_response_with_top_level_errors)
+
+ ActiveMerchant::ResponseError.new(mock_response)
+ end
+
+ def assert_invalid_parameter_errors(response)
+ assert_failure response
+
+ assert_equal(
+ 'Invalid parameters; The request is invalid. | The field neighborhood must be a string with a maximum length of 64. | The field line_1 must be a string with a maximum length of 256.',
+ response.message
+ )
+ end
+
def pre_scrubbed
%q(
opening connection to api.mundipagg.com:443...
@@ -418,6 +487,130 @@ def failed_purchase_response
)
end
+ def failed_response_with_top_level_errors
+ %(
+ {
+ "message": "The request is invalid.",
+ "errors": {
+ "charge.payment.credit_card.card.billing_address.neighborhood": [
+ "The field neighborhood must be a string with a maximum length of 64."
+ ],
+ "charge.payment.credit_card.card.billing_address.line_1": [
+ "The field line_1 must be a string with a maximum length of 256."
+ ]
+ },
+ "request": {
+ "currency": "USD",
+ "amount": 100,
+ "customer": {
+ "name": "Longbob Longsen",
+ "phones": {},
+ "metadata": {}
+ },
+ "payment": {
+ "gateway_affiliation_id": "d76dffc8-c3e5-4d80-b9ee-dc8fb6c56c83",
+ "payment_method": "credit_card",
+ "credit_card": {
+ "installments": 1,
+ "capture": true,
+ "card": {
+ "last_four_digits": "2224",
+ "brand": "Visa",
+ "holder_name": "Longbob Longsen",
+ "exp_month": 9,
+ "exp_year": 2020,
+ "billing_address": {
+ "street": "My Street",
+ "number": "456",
+ "zip_code": "K1C2N6",
+ "neighborhood": "Sesame StreetSesame StreetSesame StreetSesame StreetSesame StreetSesame StreetSesame StreetSesame StreetSesame StreetSesame StreetSesame StreetSesame StreetSesame StreetSesame StreetSesame StreetSesame StreetSesame StreetSesame StreetSesame StreetSesame StreetSesame Street",
+ "city": "Ottawa",
+ "state": "ON",
+ "country": "CA",
+ "line_1": "456, My Street, Sesame StreetSesame StreetSesame StreetSesame StreetSesame StreetSesame StreetSesame StreetSesame StreetSesame StreetSesame StreetSesame StreetSesame StreetSesame StreetSesame StreetSesame StreetSesame StreetSesame StreetSesame StreetSesame StreetSesame StreetSesame Street"
+ },
+ "options": {}
+ }
+ },
+ "metadata": {
+ "mundipagg_payment_method_code": "1"
+ }
+ }
+ }
+ }
+ )
+ end
+
+ def failed_response_with_gateway_response_errors
+ %(
+ {
+ "id": "ch_90Vjq8TrwfP74XJO",
+ "code": "ME0KIN4A0O",
+ "gateway_id": "162bead8-23a0-4708-b687-078a69a1aa7c",
+ "amount": 100,
+ "paid_amount": 100,
+ "status": "paid",
+ "currency": "USD",
+ "payment_method": "credit_card",
+ "paid_at": "2018-02-01T18:41:05Z",
+ "created_at": "2018-02-01T18:41:04Z",
+ "updated_at": "2018-02-01T18:41:04Z",
+ "customer": {
+ "id": "cus_VxJX2NmTqyUnXgL9",
+ "name": "Longbob Longsen",
+ "email": "",
+ "delinquent": false,
+ "created_at": "2018-02-01T18:41:04Z",
+ "updated_at": "2018-02-01T18:41:04Z",
+ "phones": {}
+ },
+ "last_transaction": {
+ "id": "tran_JNzjzadcVZHlG8K2",
+ "transaction_type": "credit_card",
+ "gateway_id": "c579c8fa-53d7-41a8-b4cc-a03c712ebbb7",
+ "amount": 100,
+ "status": "captured",
+ "success": true,
+ "installments": 1,
+ "operation_type": "auth_and_capture",
+ "card": {
+ "id": "card_pD02Q6WtOTB7a3kE",
+ "first_six_digits": "400010",
+ "last_four_digits": "2224",
+ "brand": "Visa",
+ "holder_name": "Longbob Longsen",
+ "exp_month": 9,
+ "exp_year": 2019,
+ "status": "active",
+ "created_at": "2018-02-01T18:41:04Z",
+ "updated_at": "2018-02-01T18:41:04Z",
+ "billing_address": {
+ "street": "My Street",
+ "number": "456",
+ "zip_code": "K1C2N6",
+ "neighborhood": "Sesame Street",
+ "city": "Ottawa",
+ "state": "ON",
+ "country": "CA",
+ "line_1": "456, My Street, Sesame Street"
+ },
+ "type": "credit"
+ },
+ "created_at": "2018-02-01T18:41:04Z",
+ "updated_at": "2018-02-01T18:41:04Z",
+ "gateway_response": {
+ "code": "400",
+ "errors": [
+ {
+ "message": "Esta loja n??o possui um meio de pagamento configurado para a bandeira VR"
+ }
+ ]
+ }
+ }
+ }
+ )
+ end
+
def successful_authorize_response
%(
{
From 4b8ddb1a8d3408f60faa9ed897f72c7015865284 Mon Sep 17 00:00:00 2001
From: britth
Date: Fri, 20 Sep 2019 10:03:49 -0400
Subject: [PATCH 0457/2234] Redsys: Add exemptions
Sets sca_exemption when available for 3ds transactions. Also sets
moto flag when requested.
Remote:
22 tests, 68 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Unit:
36 tests, 111 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---
CHANGELOG | 1 +
.../billing/gateways/redsys.rb | 9 +++++++++
.../gateways/remote_redsys_sha256_test.rb | 15 +++++++++++++++
test/unit/gateways/redsys_sha256_test.rb | 19 ++++++++++++++++++-
4 files changed, 43 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 0727ffe0a39..41c3e356173 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -15,6 +15,7 @@
* Stripe: Add supported countries [therufs] #3358
* Stripe Payment Intents: Add supported countries [therufs] #3359
* Mundipagg: Append error messages to the message response field [jasonxp] #3353
+* Redsys: Add ability to pass sca_exemption and moto fields to request exemptions [britth] #3354
== Version 1.98.0 (Sep 9, 2019)
* Stripe Payment Intents: Add new gateway [britth] #3290
diff --git a/lib/active_merchant/billing/gateways/redsys.rb b/lib/active_merchant/billing/gateways/redsys.rb
index 35a27be6b18..c396091998a 100644
--- a/lib/active_merchant/billing/gateways/redsys.rb
+++ b/lib/active_merchant/billing/gateways/redsys.rb
@@ -200,6 +200,7 @@ def purchase(money, payment, options = {})
add_threeds(data, options) if options[:execute_threed]
data[:description] = options[:description]
data[:store_in_vault] = options[:store]
+ data[:sca_exemption] = options[:sca_exemption]
commit data, options
end
@@ -215,6 +216,7 @@ def authorize(money, payment, options = {})
add_threeds(data, options) if options[:execute_threed]
data[:description] = options[:description]
data[:store_in_vault] = options[:store]
+ data[:sca_exemption] = options[:sca_exemption]
commit data, options
end
@@ -428,6 +430,7 @@ def build_merchant_data(xml, data, options = {})
xml.DS_MERCHANT_TERMINAL options[:terminal] || @options[:terminal]
xml.DS_MERCHANT_MERCHANTCODE @options[:login]
xml.DS_MERCHANT_MERCHANTSIGNATURE build_signature(data) unless sha256_authentication?
+ xml.DS_MERCHANT_EXCEP_SCA data[:sca_exemption] if data[:sca_exemption]
# Only when card is present
if data[:card]
@@ -441,6 +444,12 @@ def build_merchant_data(xml, data, options = {})
xml.DS_MERCHANT_DIRECTPAYMENT 'true'
end
+ # Set moto flag only if explicitly requested via moto field
+ # Requires account configuration to be able to use
+ if options.dig(:moto) && options.dig(:metadata, :manual_entry)
+ xml.DS_MERCHANT_DIRECTPAYMENT 'moto'
+ end
+
if data[:threeds]
xml.DS_MERCHANT_EMV3DS data[:threeds].to_json
end
diff --git a/test/remote/gateways/remote_redsys_sha256_test.rb b/test/remote/gateways/remote_redsys_sha256_test.rb
index fec07cde065..19ae8623f5e 100644
--- a/test/remote/gateways/remote_redsys_sha256_test.rb
+++ b/test/remote/gateways/remote_redsys_sha256_test.rb
@@ -36,6 +36,21 @@ def test_successful_purchase_3ds
assert_equal 'CardConfiguration', response.message
end
+ # Requires account configuration to allow setting moto flag
+ def test_purchase_with_moto_flag
+ response = @gateway.purchase(100, @credit_card, @options.merge(moto: true, metadata: { manual_entry: true }))
+ assert_equal 'SIS0488 ERROR', response.message
+ end
+
+ def test_successful_3ds_authorize_with_exemption
+ options = @options.merge(execute_threed: true, terminal: 12)
+ response = @gateway.authorize(100, @credit_card, options.merge(sca_exemption: 'LWV'))
+ assert_success response
+ assert response.params['ds_emv3ds']
+ assert_equal 'NO_3DS_v2', JSON.parse(response.params['ds_emv3ds'])['protocolVersion']
+ assert_equal 'CardConfiguration', response.message
+ end
+
def test_purchase_with_invalid_order_id
response = @gateway.purchase(100, @credit_card, order_id: "a%4#{generate_order_id}")
assert_success response
diff --git a/test/unit/gateways/redsys_sha256_test.rb b/test/unit/gateways/redsys_sha256_test.rb
index 94f17e1797c..d19f286708a 100644
--- a/test/unit/gateways/redsys_sha256_test.rb
+++ b/test/unit/gateways/redsys_sha256_test.rb
@@ -124,11 +124,28 @@ def test_successful_authorize_with_3ds
def test_3ds_data_passed
stub_comms(@gateway, :ssl_request) do
- @gateway.authorize(100, credit_card, { execute_threed: true, order_id: '156201452719', terminal: 12 })
+ @gateway.authorize(100, credit_card, { execute_threed: true, order_id: '156201452719', terminal: 12, sca_exemption: 'LWV' })
end.check_request do |method, endpoint, data, headers|
assert_match(/iniciaPeticion/, data)
assert_match(/12<\/DS_MERCHANT_TERMINAL>/, data)
assert_match(/\"threeDSInfo\":\"CardData\"/, data)
+ assert_match(/