/, body)
end.respond_with(successful_authorize_response)
@@ -129,8 +129,8 @@ def test_purchase_using_reference_sets_proper_elements
def test_setting_mode_sets_proper_element
stub_comms do
- @gateway.purchase(@amount, 'MY_AUTHORIZE_VALUE', {mode: 'CRAZY_TEST_MODE'})
- end.check_request do |endpoint, body, headers|
+ @gateway.purchase(@amount, 'MY_AUTHORIZE_VALUE', { mode: 'CRAZY_TEST_MODE' })
+ end.check_request do |_endpoint, body, _headers|
assert_xpath_text(body, '//Transaction/@mode', 'CRAZY_TEST_MODE')
end.respond_with(successful_authorize_response)
end
@@ -138,7 +138,7 @@ def test_setting_mode_sets_proper_element
def test_defaults_to_integrator_test
stub_comms do
@gateway.purchase(@amount, 'MY_AUTHORIZE_VALUE', {})
- end.check_request do |endpoint, body, headers|
+ end.check_request do |_endpoint, body, _headers|
assert_xpath_text(body, '//Transaction/@mode', 'INTEGRATOR_TEST')
end.respond_with(successful_authorize_response)
end
diff --git a/test/unit/gateways/balanced_test.rb b/test/unit/gateways/balanced_test.rb
index 4222e7b8e89..86d16dfc067 100644
--- a/test/unit/gateways/balanced_test.rb
+++ b/test/unit/gateways/balanced_test.rb
@@ -33,7 +33,7 @@ def test_successful_purchase
def test_successful_purchase_with_outside_token
response = stub_comms(@gateway, :ssl_request) do
@gateway.purchase(@amount, '/cards/CCVOX2d7Ar6Ze5TOxHsebeH', @options)
- end.check_request do |method, endpoint, data, headers|
+ end.check_request do |_method, endpoint, _data, _headers|
assert_equal('https://api.balancedpayments.com/cards/CCVOX2d7Ar6Ze5TOxHsebeH/debits', endpoint)
end.respond_with(debits_response)
@@ -211,7 +211,7 @@ def test_store
new_email_address = '%d@example.org' % Time.now
assert response = @gateway.store(@credit_card, {
- email: new_email_address
+ email: new_email_address
})
assert_instance_of String, response.authorization
end
@@ -221,7 +221,7 @@ def test_successful_purchase_with_legacy_outside_token
response = stub_comms(@gateway, :ssl_request) do
@gateway.purchase(@amount, legacy_outside_token, @options)
- end.check_request do |method, endpoint, data, headers|
+ end.check_request do |_method, endpoint, _data, _headers|
assert_equal('https://api.balancedpayments.com/cards/CC7m1Mtqk6rVJo5tcD1qitAC/debits', endpoint)
end.respond_with(debits_response)
@@ -237,7 +237,7 @@ def test_capturing_legacy_authorizations
[v1_authorization, v11_authorization].each do |authorization|
stub_comms(@gateway, :ssl_request) do
@gateway.capture(@amount, authorization)
- end.check_request do |method, endpoint, data, headers|
+ end.check_request do |_method, endpoint, _data, _headers|
assert_equal('https://api.balancedpayments.com/card_holds/HL7dYMhpVBcqAYqxLF5mZtQ5/debits', endpoint)
end.respond_with(authorized_debits_response)
end
@@ -250,7 +250,7 @@ def test_voiding_legacy_authorizations
[v1_authorization, v11_authorization].each do |authorization|
stub_comms(@gateway, :ssl_request) do
@gateway.void(authorization)
- end.check_request do |method, endpoint, data, headers|
+ end.check_request do |method, endpoint, data, _headers|
assert_equal :put, method
assert_equal('https://api.balancedpayments.com/card_holds/HL7dYMhpVBcqAYqxLF5mZtQ5', endpoint)
assert_match %r{\bis_void=true\b}, data
@@ -265,7 +265,7 @@ def test_refunding_legacy_purchases
[v1_authorization, v11_authorization].each do |authorization|
stub_comms(@gateway, :ssl_request) do
@gateway.refund(nil, authorization)
- end.check_request do |method, endpoint, data, headers|
+ end.check_request do |_method, endpoint, _data, _headers|
assert_equal('https://api.balancedpayments.com/debits/WD2x6vLS7RzHYEcdymqRyNAO/refunds', endpoint)
end.respond_with(refunds_response)
end
@@ -275,8 +275,9 @@ def test_passing_address
a = address
response = stub_comms(@gateway, :ssl_request) do
@gateway.purchase(@amount, @credit_card, address: a)
- end.check_request do |method, endpoint, data, headers|
+ end.check_request do |_method, endpoint, data, _headers|
next if endpoint =~ /debits/
+
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)
@@ -292,8 +293,9 @@ def test_passing_address
def test_passing_address_without_zip
response = stub_comms(@gateway, :ssl_request) do
@gateway.purchase(@amount, @credit_card, address: address(zip: nil))
- end.check_request do |method, endpoint, data, headers|
+ end.check_request do |_method, endpoint, data, _headers|
next if endpoint =~ /debits/
+
assert_no_match(%r{address}, data)
end.respond_with(cards_response, debits_response)
@@ -303,8 +305,9 @@ def test_passing_address_without_zip
def test_passing_address_with_blank_zip
response = stub_comms(@gateway, :ssl_request) do
@gateway.purchase(@amount, @credit_card, address: address(zip: ' '))
- end.check_request do |method, endpoint, data, headers|
+ end.check_request do |_method, endpoint, data, _headers|
next if endpoint =~ /debits/
+
assert_no_match(%r{address}, data)
end.respond_with(cards_response, debits_response)
@@ -331,539 +334,539 @@ def invalid_login_response
end
def marketplace_response
- <<-RESPONSE
-{
- "meta": {
- "last": "/marketplaces?limit=10&offset=0",
- "next": null,
- "href": "/marketplaces?limit=10&offset=0",
- "limit": 10,
- "offset": 0,
- "previous": null,
- "total": 1,
- "first": "/marketplaces?limit=10&offset=0"
- },
- "marketplaces": [
- {
- "in_escrow": 47202,
- "domain_url": "example.com",
- "name": "Test Marketplace",
- "links": {
- "owner_customer": "AC73SN17anKkjk6Y1sVe2uaq"
- },
- "href": "/marketplaces/TEST-MP73SaFdpQePv9dOaG5wXOGO",
- "created_at": "2012-07-19T17:33:51.974238Z",
- "support_email_address": "support@example.com",
- "updated_at": "2012-07-19T17:33:52.848042Z",
- "support_phone_number": "+16505551234",
- "production": false,
- "meta": {},
- "unsettled_fees": 0,
- "id": "TEST-MP73SaFdpQePv9dOaG5wXOGO"
- }
- ],
- "links": {
- "marketplaces.debits": "/debits",
- "marketplaces.reversals": "/reversals",
- "marketplaces.customers": "/customers",
- "marketplaces.credits": "/credits",
- "marketplaces.cards": "/cards",
- "marketplaces.card_holds": "/card_holds",
- "marketplaces.refunds": "/refunds",
- "marketplaces.owner_customer": "/customers/{marketplaces.owner_customer}",
- "marketplaces.transactions": "/transactions",
- "marketplaces.bank_accounts": "/bank_accounts",
- "marketplaces.callbacks": "/callbacks",
- "marketplaces.events": "/events"
- }
-}
+ <<~RESPONSE
+ {
+ "meta": {
+ "last": "/marketplaces?limit=10&offset=0",
+ "next": null,
+ "href": "/marketplaces?limit=10&offset=0",
+ "limit": 10,
+ "offset": 0,
+ "previous": null,
+ "total": 1,
+ "first": "/marketplaces?limit=10&offset=0"
+ },
+ "marketplaces": [
+ {
+ "in_escrow": 47202,
+ "domain_url": "example.com",
+ "name": "Test Marketplace",
+ "links": {
+ "owner_customer": "AC73SN17anKkjk6Y1sVe2uaq"
+ },
+ "href": "/marketplaces/TEST-MP73SaFdpQePv9dOaG5wXOGO",
+ "created_at": "2012-07-19T17:33:51.974238Z",
+ "support_email_address": "support@example.com",
+ "updated_at": "2012-07-19T17:33:52.848042Z",
+ "support_phone_number": "+16505551234",
+ "production": false,
+ "meta": {},
+ "unsettled_fees": 0,
+ "id": "TEST-MP73SaFdpQePv9dOaG5wXOGO"
+ }
+ ],
+ "links": {
+ "marketplaces.debits": "/debits",
+ "marketplaces.reversals": "/reversals",
+ "marketplaces.customers": "/customers",
+ "marketplaces.credits": "/credits",
+ "marketplaces.cards": "/cards",
+ "marketplaces.card_holds": "/card_holds",
+ "marketplaces.refunds": "/refunds",
+ "marketplaces.owner_customer": "/customers/{marketplaces.owner_customer}",
+ "marketplaces.transactions": "/transactions",
+ "marketplaces.bank_accounts": "/bank_accounts",
+ "marketplaces.callbacks": "/callbacks",
+ "marketplaces.events": "/events"
+ }
+ }
RESPONSE
end
def cards_response
- <<-RESPONSE
-{
- "cards": [
- {
- "cvv_match": null,
- "links": {
- "customer": null
- },
- "name": "Longbob Longsen",
- "expiration_year": 2015,
- "avs_street_match": null,
- "is_verified": true,
- "created_at": "2014-02-06T23:19:27.146436Z",
- "cvv_result": null,
- "brand": "Visa",
- "number": "xxxxxxxxxxxx1111",
- "updated_at": "2014-02-06T23:19:27.146441Z",
- "id": "CCXfdppSxXOGzaMUHp9EQyI",
- "expiration_month": 9,
- "cvv": null,
- "meta": {},
- "href": "/cards/CCXfdppSxXOGzaMUHp9EQyI",
- "address": {
- "city": null,
- "line2": null,
- "line1": null,
- "state": null,
- "postal_code": null,
- "country_code": null
- },
- "fingerprint": "e0928a7fe2233bf6697413f663b3d94114358e6ac027fcd58ceba0bb37f05039",
- "avs_postal_match": null,
- "avs_result": null
- }
- ],
- "links": {
- "cards.card_holds": "/cards/{cards.id}/card_holds",
- "cards.customer": "/customers/{cards.customer}",
- "cards.debits": "/cards/{cards.id}/debits"
- }
-}
+ <<~RESPONSE
+ {
+ "cards": [
+ {
+ "cvv_match": null,
+ "links": {
+ "customer": null
+ },
+ "name": "Longbob Longsen",
+ "expiration_year": 2015,
+ "avs_street_match": null,
+ "is_verified": true,
+ "created_at": "2014-02-06T23:19:27.146436Z",
+ "cvv_result": null,
+ "brand": "Visa",
+ "number": "xxxxxxxxxxxx1111",
+ "updated_at": "2014-02-06T23:19:27.146441Z",
+ "id": "CCXfdppSxXOGzaMUHp9EQyI",
+ "expiration_month": 9,
+ "cvv": null,
+ "meta": {},
+ "href": "/cards/CCXfdppSxXOGzaMUHp9EQyI",
+ "address": {
+ "city": null,
+ "line2": null,
+ "line1": null,
+ "state": null,
+ "postal_code": null,
+ "country_code": null
+ },
+ "fingerprint": "e0928a7fe2233bf6697413f663b3d94114358e6ac027fcd58ceba0bb37f05039",
+ "avs_postal_match": null,
+ "avs_result": null
+ }
+ ],
+ "links": {
+ "cards.card_holds": "/cards/{cards.id}/card_holds",
+ "cards.customer": "/customers/{cards.customer}",
+ "cards.debits": "/cards/{cards.id}/debits"
+ }
+ }
RESPONSE
end
def debits_response
- <<-RESPONSE
-{
- "debits": [
- {
- "status": "succeeded",
- "description": "Shopify Purchase",
- "links": {
- "customer": null,
- "source": "CCXfdppSxXOGzaMUHp9EQyI",
- "order": null,
- "dispute": null
- },
- "updated_at": "2014-02-06T23:19:29.690815Z",
- "created_at": "2014-02-06T23:19:28.709143Z",
- "transaction_number": "W250-112-1883",
- "failure_reason": null,
- "currency": "USD",
- "amount": 100,
- "failure_reason_code": null,
- "meta": {},
- "href": "/debits/WDYZhc3mWCkxvOwIokeUz6M",
- "appears_on_statement_as": "BAL*example.com",
- "id": "WDYZhc3mWCkxvOwIokeUz6M"
- }
- ],
- "links": {
- "debits.customer": "/customers/{debits.customer}",
- "debits.dispute": "/disputes/{debits.dispute}",
- "debits.source": "/resources/{debits.source}",
- "debits.order": "/orders/{debits.order}",
- "debits.refunds": "/debits/{debits.id}/refunds",
- "debits.events": "/debits/{debits.id}/events"
- }
-}
+ <<~RESPONSE
+ {
+ "debits": [
+ {
+ "status": "succeeded",
+ "description": "Shopify Purchase",
+ "links": {
+ "customer": null,
+ "source": "CCXfdppSxXOGzaMUHp9EQyI",
+ "order": null,
+ "dispute": null
+ },
+ "updated_at": "2014-02-06T23:19:29.690815Z",
+ "created_at": "2014-02-06T23:19:28.709143Z",
+ "transaction_number": "W250-112-1883",
+ "failure_reason": null,
+ "currency": "USD",
+ "amount": 100,
+ "failure_reason_code": null,
+ "meta": {},
+ "href": "/debits/WDYZhc3mWCkxvOwIokeUz6M",
+ "appears_on_statement_as": "BAL*example.com",
+ "id": "WDYZhc3mWCkxvOwIokeUz6M"
+ }
+ ],
+ "links": {
+ "debits.customer": "/customers/{debits.customer}",
+ "debits.dispute": "/disputes/{debits.dispute}",
+ "debits.source": "/resources/{debits.source}",
+ "debits.order": "/orders/{debits.order}",
+ "debits.refunds": "/debits/{debits.id}/refunds",
+ "debits.events": "/debits/{debits.id}/events"
+ }
+ }
RESPONSE
end
def authorized_debits_response
- <<-RESPONSE
-{
- "debits": [
- {
- "status": "succeeded",
- "description": "Shopify Purchase",
- "links": {
- "customer": null,
- "source": "CC2uKKcUhaSFRrl2mnGPSbDO",
- "order": null,
- "dispute": null
- },
- "updated_at": "2014-02-06T23:19:29.690815Z",
- "created_at": "2014-02-06T23:19:28.709143Z",
- "transaction_number": "W250-112-1883",
- "failure_reason": null,
- "currency": "USD",
- "amount": 100,
- "failure_reason_code": null,
- "meta": {},
- "href": "/debits/WDYZhc3mWCkxvOwIokeUz6M",
- "appears_on_statement_as": "BAL*example.com",
- "id": "WDYZhc3mWCkxvOwIokeUz6M"
- }
- ],
- "links": {
- "debits.customer": "/customers/{debits.customer}",
- "debits.dispute": "/disputes/{debits.dispute}",
- "debits.source": "/resources/{debits.source}",
- "debits.order": "/orders/{debits.order}",
- "debits.refunds": "/debits/{debits.id}/refunds",
- "debits.events": "/debits/{debits.id}/events"
- }
-}
+ <<~RESPONSE
+ {
+ "debits": [
+ {
+ "status": "succeeded",
+ "description": "Shopify Purchase",
+ "links": {
+ "customer": null,
+ "source": "CC2uKKcUhaSFRrl2mnGPSbDO",
+ "order": null,
+ "dispute": null
+ },
+ "updated_at": "2014-02-06T23:19:29.690815Z",
+ "created_at": "2014-02-06T23:19:28.709143Z",
+ "transaction_number": "W250-112-1883",
+ "failure_reason": null,
+ "currency": "USD",
+ "amount": 100,
+ "failure_reason_code": null,
+ "meta": {},
+ "href": "/debits/WDYZhc3mWCkxvOwIokeUz6M",
+ "appears_on_statement_as": "BAL*example.com",
+ "id": "WDYZhc3mWCkxvOwIokeUz6M"
+ }
+ ],
+ "links": {
+ "debits.customer": "/customers/{debits.customer}",
+ "debits.dispute": "/disputes/{debits.dispute}",
+ "debits.source": "/resources/{debits.source}",
+ "debits.order": "/orders/{debits.order}",
+ "debits.refunds": "/debits/{debits.id}/refunds",
+ "debits.events": "/debits/{debits.id}/events"
+ }
+ }
RESPONSE
end
def authorized_partial_debits_response
- <<-RESPONSE
-{
- "debits": [
- {
- "status": "succeeded",
- "description": "Shopify Purchase",
- "links": {
- "customer": null,
- "source": "CC2uKKcUhaSFRrl2mnGPSbDO",
- "order": null,
- "dispute": null
- },
- "updated_at": "2014-02-06T23:19:29.690815Z",
- "created_at": "2014-02-06T23:19:28.709143Z",
- "transaction_number": "W250-112-1883",
- "failure_reason": null,
- "currency": "USD",
- "amount": 50,
- "failure_reason_code": null,
- "meta": {},
- "href": "/debits/WDYZhc3mWCkxvOwIokeUz6M",
- "appears_on_statement_as": "BAL*example.com",
- "id": "WDYZhc3mWCkxvOwIokeUz6M"
- }
- ],
- "links": {
- "debits.customer": "/customers/{debits.customer}",
- "debits.dispute": "/disputes/{debits.dispute}",
- "debits.source": "/resources/{debits.source}",
- "debits.order": "/orders/{debits.order}",
- "debits.refunds": "/debits/{debits.id}/refunds",
- "debits.events": "/debits/{debits.id}/events"
- }
-}
+ <<~RESPONSE
+ {
+ "debits": [
+ {
+ "status": "succeeded",
+ "description": "Shopify Purchase",
+ "links": {
+ "customer": null,
+ "source": "CC2uKKcUhaSFRrl2mnGPSbDO",
+ "order": null,
+ "dispute": null
+ },
+ "updated_at": "2014-02-06T23:19:29.690815Z",
+ "created_at": "2014-02-06T23:19:28.709143Z",
+ "transaction_number": "W250-112-1883",
+ "failure_reason": null,
+ "currency": "USD",
+ "amount": 50,
+ "failure_reason_code": null,
+ "meta": {},
+ "href": "/debits/WDYZhc3mWCkxvOwIokeUz6M",
+ "appears_on_statement_as": "BAL*example.com",
+ "id": "WDYZhc3mWCkxvOwIokeUz6M"
+ }
+ ],
+ "links": {
+ "debits.customer": "/customers/{debits.customer}",
+ "debits.dispute": "/disputes/{debits.dispute}",
+ "debits.source": "/resources/{debits.source}",
+ "debits.order": "/orders/{debits.order}",
+ "debits.refunds": "/debits/{debits.id}/refunds",
+ "debits.events": "/debits/{debits.id}/events"
+ }
+ }
RESPONSE
end
def declined_response
- <<-RESPONSE
-{
- "errors": [
- {
- "status": "Payment Required",
- "category_code": "card-declined",
- "additional": "Customer call bank",
- "status_code": 402,
- "category_type": "banking",
- "extras": {},
- "request_id": "OHMc8d80eb4903011e390c002a1fe53e539",
- "description": "R530: Customer call bank. Your request id is OHMc8d80eb4903011e390c002a1fe53e539."
- }
- ]
-}
+ <<~RESPONSE
+ {
+ "errors": [
+ {
+ "status": "Payment Required",
+ "category_code": "card-declined",
+ "additional": "Customer call bank",
+ "status_code": 402,
+ "category_type": "banking",
+ "extras": {},
+ "request_id": "OHMc8d80eb4903011e390c002a1fe53e539",
+ "description": "R530: Customer call bank. Your request id is OHMc8d80eb4903011e390c002a1fe53e539."
+ }
+ ]
+ }
RESPONSE
end
def bad_email_response
- <<-'RESPONSE'
-{
- "errors": [
- {
- "status": "Bad Request",
- "category_code": "request",
- "additional": null,
- "status_code": 400,
- "category_type": "request",
- "extras": {
- "email": "\"invalid_email\" must be a valid email address as specified by RFC-2822"
- },
- "request_id": "OHM9107a4bc903111e390c002a1fe53e539",
- "description": "Invalid field [email] - \"invalid_email\" must be a valid email address as specified by RFC-2822 Your request id is OHM9107a4bc903111e390c002a1fe53e539."
- }
- ]
-}
+ <<~'RESPONSE'
+ {
+ "errors": [
+ {
+ "status": "Bad Request",
+ "category_code": "request",
+ "additional": null,
+ "status_code": 400,
+ "category_type": "request",
+ "extras": {
+ "email": "\"invalid_email\" must be a valid email address as specified by RFC-2822"
+ },
+ "request_id": "OHM9107a4bc903111e390c002a1fe53e539",
+ "description": "Invalid field [email] - \"invalid_email\" must be a valid email address as specified by RFC-2822 Your request id is OHM9107a4bc903111e390c002a1fe53e539."
+ }
+ ]
+ }
RESPONSE
end
def account_frozen_response
- <<-RESPONSE
-{
- "errors": [
- {
- "status": "Payment Required",
- "category_code": "card-declined",
- "additional": "Account Frozen",
- "status_code": 402,
- "category_type": "banking",
- "extras": {},
- "request_id": "OHMec50b6be903c11e387cb026ba7cac9da",
- "description": "R758: Account Frozen. Your request id is OHMec50b6be903c11e387cb026ba7cac9da."
- }
- ],
- "links": {
- "debits.customer": "/customers/{debits.customer}",
- "debits.dispute": "/disputes/{debits.dispute}",
- "debits.source": "/resources/{debits.source}",
- "debits.order": "/orders/{debits.order}",
- "debits.refunds": "/debits/{debits.id}/refunds",
- "debits.events": "/debits/{debits.id}/events"
- },
- "debits": [
- {
- "status": "failed",
- "description": "Shopify Purchase",
- "links": {
- "customer": null,
- "source": "CC7a41DYIaSSyGoau6rZ8VcG",
- "order": null,
- "dispute": null
- },
- "updated_at": "2014-02-07T21:15:10.107464Z",
- "created_at": "2014-02-07T21:15:09.206335Z",
- "transaction_number": "W202-883-1157",
- "failure_reason": "R758: Account Frozen.",
- "currency": "USD",
- "amount": 100,
- "failure_reason_code": "card-declined",
- "meta": {},
- "href": "/debits/WD7cjQ5gizGWMDWbxDndgm7w",
- "appears_on_statement_as": "BAL*example.com",
- "id": "WD7cjQ5gizGWMDWbxDndgm7w"
- }
- ]
-}
+ <<~RESPONSE
+ {
+ "errors": [
+ {
+ "status": "Payment Required",
+ "category_code": "card-declined",
+ "additional": "Account Frozen",
+ "status_code": 402,
+ "category_type": "banking",
+ "extras": {},
+ "request_id": "OHMec50b6be903c11e387cb026ba7cac9da",
+ "description": "R758: Account Frozen. Your request id is OHMec50b6be903c11e387cb026ba7cac9da."
+ }
+ ],
+ "links": {
+ "debits.customer": "/customers/{debits.customer}",
+ "debits.dispute": "/disputes/{debits.dispute}",
+ "debits.source": "/resources/{debits.source}",
+ "debits.order": "/orders/{debits.order}",
+ "debits.refunds": "/debits/{debits.id}/refunds",
+ "debits.events": "/debits/{debits.id}/events"
+ },
+ "debits": [
+ {
+ "status": "failed",
+ "description": "Shopify Purchase",
+ "links": {
+ "customer": null,
+ "source": "CC7a41DYIaSSyGoau6rZ8VcG",
+ "order": null,
+ "dispute": null
+ },
+ "updated_at": "2014-02-07T21:15:10.107464Z",
+ "created_at": "2014-02-07T21:15:09.206335Z",
+ "transaction_number": "W202-883-1157",
+ "failure_reason": "R758: Account Frozen.",
+ "currency": "USD",
+ "amount": 100,
+ "failure_reason_code": "card-declined",
+ "meta": {},
+ "href": "/debits/WD7cjQ5gizGWMDWbxDndgm7w",
+ "appears_on_statement_as": "BAL*example.com",
+ "id": "WD7cjQ5gizGWMDWbxDndgm7w"
+ }
+ ]
+ }
RESPONSE
end
def appears_on_response
- <<-RESPONSE
-{
- "debits": [
- {
- "status": "succeeded",
- "description": "Shopify Purchase",
- "links": {
- "customer": null,
- "source": "CC4SKo0WY3lhfWc6CgMyPo34",
- "order": null,
- "dispute": null
- },
- "updated_at": "2014-02-07T21:20:13.950392Z",
- "created_at": "2014-02-07T21:20:12.737821Z",
- "transaction_number": "W337-477-3752",
- "failure_reason": null,
- "currency": "USD",
- "amount": 100,
- "failure_reason_code": null,
- "meta": {},
- "href": "/debits/WD4UDDm6iqtYMEd21UBaa50H",
- "appears_on_statement_as": "BAL*Homer Electric",
- "id": "WD4UDDm6iqtYMEd21UBaa50H"
- }
- ],
- "links": {
- "debits.customer": "/customers/{debits.customer}",
- "debits.dispute": "/disputes/{debits.dispute}",
- "debits.source": "/resources/{debits.source}",
- "debits.order": "/orders/{debits.order}",
- "debits.refunds": "/debits/{debits.id}/refunds",
- "debits.events": "/debits/{debits.id}/events"
- }
-}
+ <<~RESPONSE
+ {
+ "debits": [
+ {
+ "status": "succeeded",
+ "description": "Shopify Purchase",
+ "links": {
+ "customer": null,
+ "source": "CC4SKo0WY3lhfWc6CgMyPo34",
+ "order": null,
+ "dispute": null
+ },
+ "updated_at": "2014-02-07T21:20:13.950392Z",
+ "created_at": "2014-02-07T21:20:12.737821Z",
+ "transaction_number": "W337-477-3752",
+ "failure_reason": null,
+ "currency": "USD",
+ "amount": 100,
+ "failure_reason_code": null,
+ "meta": {},
+ "href": "/debits/WD4UDDm6iqtYMEd21UBaa50H",
+ "appears_on_statement_as": "BAL*Homer Electric",
+ "id": "WD4UDDm6iqtYMEd21UBaa50H"
+ }
+ ],
+ "links": {
+ "debits.customer": "/customers/{debits.customer}",
+ "debits.dispute": "/disputes/{debits.dispute}",
+ "debits.source": "/resources/{debits.source}",
+ "debits.order": "/orders/{debits.order}",
+ "debits.refunds": "/debits/{debits.id}/refunds",
+ "debits.events": "/debits/{debits.id}/events"
+ }
+ }
RESPONSE
end
def holds_response
- <<-RESPONSE
-{
- "card_holds": [
- {
- "status": "succeeded",
- "description": "Shopify Purchase",
- "links": {
- "card": "CC2uKKcUhaSFRrl2mnGPSbDO",
- "debit": null
- },
- "updated_at": "2014-02-07T21:46:39.678439Z",
- "created_at": "2014-02-07T21:46:39.303526Z",
- "transaction_number": "HL343-028-3032",
- "expires_at": "2014-02-14T21:46:39.532363Z",
- "failure_reason": null,
- "currency": "USD",
- "amount": 100,
- "meta": {},
- "href": "/card_holds/HL2wPXf6ByqkLMiWGab7QRsq",
- "failure_reason_code": null,
- "voided_at": null,
- "id": "HL2wPXf6ByqkLMiWGab7QRsq"
- }
- ],
- "links": {
- "card_holds.events": "/card_holds/{card_holds.id}/events",
- "card_holds.card": "/resources/{card_holds.card}",
- "card_holds.debits": "/card_holds/{card_holds.id}/debits",
- "card_holds.debit": "/debits/{card_holds.debit}"
- }
-}
+ <<~RESPONSE
+ {
+ "card_holds": [
+ {
+ "status": "succeeded",
+ "description": "Shopify Purchase",
+ "links": {
+ "card": "CC2uKKcUhaSFRrl2mnGPSbDO",
+ "debit": null
+ },
+ "updated_at": "2014-02-07T21:46:39.678439Z",
+ "created_at": "2014-02-07T21:46:39.303526Z",
+ "transaction_number": "HL343-028-3032",
+ "expires_at": "2014-02-14T21:46:39.532363Z",
+ "failure_reason": null,
+ "currency": "USD",
+ "amount": 100,
+ "meta": {},
+ "href": "/card_holds/HL2wPXf6ByqkLMiWGab7QRsq",
+ "failure_reason_code": null,
+ "voided_at": null,
+ "id": "HL2wPXf6ByqkLMiWGab7QRsq"
+ }
+ ],
+ "links": {
+ "card_holds.events": "/card_holds/{card_holds.id}/events",
+ "card_holds.card": "/resources/{card_holds.card}",
+ "card_holds.debits": "/card_holds/{card_holds.id}/debits",
+ "card_holds.debit": "/debits/{card_holds.debit}"
+ }
+ }
RESPONSE
end
def method_not_allowed_response
- <<-RESPONSE
-{
- "errors": [
- {
- "status": "Method Not Allowed",
- "category_code": "method-not-allowed",
- "description": "Your request id is OHMfaf5570a904211e3bcab026ba7f8ec28.",
- "status_code": 405,
- "category_type": "request",
- "request_id": "OHMfaf5570a904211e3bcab026ba7f8ec28"
- }
- ]
-}
+ <<~RESPONSE
+ {
+ "errors": [
+ {
+ "status": "Method Not Allowed",
+ "category_code": "method-not-allowed",
+ "description": "Your request id is OHMfaf5570a904211e3bcab026ba7f8ec28.",
+ "status_code": 405,
+ "category_type": "request",
+ "request_id": "OHMfaf5570a904211e3bcab026ba7f8ec28"
+ }
+ ]
+ }
RESPONSE
end
def unauthorized_response
- <<-RESPONSE
-{
- "errors": [
- {
- "status": "Unauthorized",
- "category_code": "authentication-required",
- "description": "The server could not verify that you are authorized to access the URL requested. You either supplied the wrong credentials (e.g. a bad password), or your browser doesn't understand how to supply the credentials required.
In case you are allowed to request the document, please check your user-id and password and try again.
Your request id is OHM56702560904311e3988c026ba7cd33d0.",
- "status_code": 401,
- "category_type": "permission",
- "request_id": "OHM56702560904311e3988c026ba7cd33d0"
- }
- ]
-}
+ <<~RESPONSE
+ {
+ "errors": [
+ {
+ "status": "Unauthorized",
+ "category_code": "authentication-required",
+ "description": "The server could not verify that you are authorized to access the URL requested. You either supplied the wrong credentials (e.g. a bad password), or your browser doesn't understand how to supply the credentials required.
In case you are allowed to request the document, please check your user-id and password and try again.
Your request id is OHM56702560904311e3988c026ba7cd33d0.",
+ "status_code": 401,
+ "category_type": "permission",
+ "request_id": "OHM56702560904311e3988c026ba7cd33d0"
+ }
+ ]
+ }
RESPONSE
end
def voided_hold_response
- <<-RESPONSE
-{
- "card_holds": [
- {
- "status": "succeeded",
- "description": "Shopify Purchase",
- "links": {
- "card": "CC52ACcRnrG5eupOERKK4OAq",
- "debit": null
- },
- "updated_at": "2014-02-07T22:10:28.923304Z",
- "created_at": "2014-02-07T22:10:27.904233Z",
- "transaction_number": "HL728-165-8425",
- "expires_at": "2014-02-14T22:10:28.045745Z",
- "failure_reason": null,
- "currency": "USD",
- "amount": 100,
- "meta": {},
- "href": "/card_holds/HL54qindwhlErSujLo5IcP5J",
- "failure_reason_code": null,
- "voided_at": "2014-02-07T22:10:28.923308Z",
- "id": "HL54qindwhlErSujLo5IcP5J"
- }
- ],
- "links": {
- "card_holds.events": "/card_holds/{card_holds.id}/events",
- "card_holds.card": "/resources/{card_holds.card}",
- "card_holds.debits": "/card_holds/{card_holds.id}/debits",
- "card_holds.debit": "/debits/{card_holds.debit}"
- }
-}
+ <<~RESPONSE
+ {
+ "card_holds": [
+ {
+ "status": "succeeded",
+ "description": "Shopify Purchase",
+ "links": {
+ "card": "CC52ACcRnrG5eupOERKK4OAq",
+ "debit": null
+ },
+ "updated_at": "2014-02-07T22:10:28.923304Z",
+ "created_at": "2014-02-07T22:10:27.904233Z",
+ "transaction_number": "HL728-165-8425",
+ "expires_at": "2014-02-14T22:10:28.045745Z",
+ "failure_reason": null,
+ "currency": "USD",
+ "amount": 100,
+ "meta": {},
+ "href": "/card_holds/HL54qindwhlErSujLo5IcP5J",
+ "failure_reason_code": null,
+ "voided_at": "2014-02-07T22:10:28.923308Z",
+ "id": "HL54qindwhlErSujLo5IcP5J"
+ }
+ ],
+ "links": {
+ "card_holds.events": "/card_holds/{card_holds.id}/events",
+ "card_holds.card": "/resources/{card_holds.card}",
+ "card_holds.debits": "/card_holds/{card_holds.id}/debits",
+ "card_holds.debit": "/debits/{card_holds.debit}"
+ }
+ }
RESPONSE
end
def refunds_response
- <<-RESPONSE
-{
- "links": {
- "refunds.dispute": "/disputes/{refunds.dispute}",
- "refunds.events": "/refunds/{refunds.id}/events",
- "refunds.debit": "/debits/{refunds.debit}",
- "refunds.order": "/orders/{refunds.order}"
- },
- "refunds": [
- {
- "status": "succeeded",
- "description": "Shopify Purchase",
- "links": {
- "debit": "WDAtJcbjh3EJLW0tp7CUxAk",
- "order": null,
- "dispute": null
- },
- "href": "/refunds/RFJ4N00zLaQFrfBkC8cbN68",
- "created_at": "2014-02-07T22:35:06.424855Z",
- "transaction_number": "RF424-240-3258",
- "updated_at": "2014-02-07T22:35:07.655276Z",
- "currency": "USD",
- "amount": 100,
- "meta": {},
- "id": "RFJ4N00zLaQFrfBkC8cbN68"
- }
- ]
-}
+ <<~RESPONSE
+ {
+ "links": {
+ "refunds.dispute": "/disputes/{refunds.dispute}",
+ "refunds.events": "/refunds/{refunds.id}/events",
+ "refunds.debit": "/debits/{refunds.debit}",
+ "refunds.order": "/orders/{refunds.order}"
+ },
+ "refunds": [
+ {
+ "status": "succeeded",
+ "description": "Shopify Purchase",
+ "links": {
+ "debit": "WDAtJcbjh3EJLW0tp7CUxAk",
+ "order": null,
+ "dispute": null
+ },
+ "href": "/refunds/RFJ4N00zLaQFrfBkC8cbN68",
+ "created_at": "2014-02-07T22:35:06.424855Z",
+ "transaction_number": "RF424-240-3258",
+ "updated_at": "2014-02-07T22:35:07.655276Z",
+ "currency": "USD",
+ "amount": 100,
+ "meta": {},
+ "id": "RFJ4N00zLaQFrfBkC8cbN68"
+ }
+ ]
+ }
RESPONSE
end
def partial_refunds_response
- <<-RESPONSE
-{
- "links": {
- "refunds.dispute": "/disputes/{refunds.dispute}",
- "refunds.events": "/refunds/{refunds.id}/events",
- "refunds.debit": "/debits/{refunds.debit}",
- "refunds.order": "/orders/{refunds.order}"
- },
- "refunds": [
- {
- "status": "succeeded",
- "description": "Shopify Purchase",
- "links": {
- "debit": "WDAtJcbjh3EJLW0tp7CUxAk",
- "order": null,
- "dispute": null
- },
- "href": "/refunds/RFJ4N00zLaQFrfBkC8cbN68",
- "created_at": "2014-02-07T22:35:06.424855Z",
- "transaction_number": "RF424-240-3258",
- "updated_at": "2014-02-07T22:35:07.655276Z",
- "currency": "USD",
- "amount": 50,
- "meta": {},
- "id": "RFJ4N00zLaQFrfBkC8cbN68"
- }
- ]
-}
+ <<~RESPONSE
+ {
+ "links": {
+ "refunds.dispute": "/disputes/{refunds.dispute}",
+ "refunds.events": "/refunds/{refunds.id}/events",
+ "refunds.debit": "/debits/{refunds.debit}",
+ "refunds.order": "/orders/{refunds.order}"
+ },
+ "refunds": [
+ {
+ "status": "succeeded",
+ "description": "Shopify Purchase",
+ "links": {
+ "debit": "WDAtJcbjh3EJLW0tp7CUxAk",
+ "order": null,
+ "dispute": null
+ },
+ "href": "/refunds/RFJ4N00zLaQFrfBkC8cbN68",
+ "created_at": "2014-02-07T22:35:06.424855Z",
+ "transaction_number": "RF424-240-3258",
+ "updated_at": "2014-02-07T22:35:07.655276Z",
+ "currency": "USD",
+ "amount": 50,
+ "meta": {},
+ "id": "RFJ4N00zLaQFrfBkC8cbN68"
+ }
+ ]
+ }
RESPONSE
end
def refunds_pending_response
- <<-RESPONSE
-{
- "links": {
- "refunds.dispute": "/disputes/{refunds.dispute}",
- "refunds.events": "/refunds/{refunds.id}/events",
- "refunds.debit": "/debits/{refunds.debit}",
- "refunds.order": "/orders/{refunds.order}"
- },
- "refunds": [
- {
- "status": "pending",
- "description": null,
- "links": {
- "debit": "WD7AT5AGKI0jccoElAEEqiuL",
- "order": null,
- "dispute": null
- },
- "href": "/refunds/RF46a5p6ZVMK4qVIeCJ8u2LE",
- "created_at": "2014-05-22T20:20:32.956467Z",
- "transaction_number": "RF485-302-2551",
- "updated_at": "2014-05-22T20:20:35.991553Z",
- "currency": "USD",
- "amount": 100,
- "meta": {},
- "id": "RF46a5p6ZVMK4qVIeCJ8u2LE"
- }
- ]
-}
+ <<~RESPONSE
+ {
+ "links": {
+ "refunds.dispute": "/disputes/{refunds.dispute}",
+ "refunds.events": "/refunds/{refunds.id}/events",
+ "refunds.debit": "/debits/{refunds.debit}",
+ "refunds.order": "/orders/{refunds.order}"
+ },
+ "refunds": [
+ {
+ "status": "pending",
+ "description": null,
+ "links": {
+ "debit": "WD7AT5AGKI0jccoElAEEqiuL",
+ "order": null,
+ "dispute": null
+ },
+ "href": "/refunds/RF46a5p6ZVMK4qVIeCJ8u2LE",
+ "created_at": "2014-05-22T20:20:32.956467Z",
+ "transaction_number": "RF485-302-2551",
+ "updated_at": "2014-05-22T20:20:35.991553Z",
+ "currency": "USD",
+ "amount": 100,
+ "meta": {},
+ "id": "RF46a5p6ZVMK4qVIeCJ8u2LE"
+ }
+ ]
+ }
RESPONSE
end
end
diff --git a/test/unit/gateways/bambora_apac_test.rb b/test/unit/gateways/bambora_apac_test.rb
index 3b4e62c2977..c31335dfdc4 100644
--- a/test/unit/gateways/bambora_apac_test.rb
+++ b/test/unit/gateways/bambora_apac_test.rb
@@ -16,7 +16,7 @@ def setup
def test_successful_purchase
response = stub_comms do
@gateway.purchase(@amount, @credit_card, order_id: 1)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(%r{username<}, data)
assert_match(%r{password<}, data)
@@ -48,7 +48,7 @@ def test_failed_purchase
def test_successful_authorize
response = stub_comms do
@gateway.authorize(@amount, @credit_card, order_id: 1)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(%r{1<}, data)
assert_match(%r{2<}, data)
@@ -61,7 +61,7 @@ def test_successful_authorize
def test_successful_capture
response = stub_comms do
@gateway.capture(@amount, 'receipt')
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(%r{receipt<}, data)
assert_match(%r{100<}, data)
@@ -73,7 +73,7 @@ def test_successful_capture
def test_successful_refund
response = stub_comms do
@gateway.refund(@amount, 'receipt')
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(%r{receipt<}, data)
assert_match(%r{100<}, data)
@@ -84,9 +84,10 @@ def test_successful_refund
def test_successful_void
response = stub_comms do
- @gateway.void(@amount, 'receipt')
- end.check_request do |endpoint, data, headers|
+ @gateway.void('receipt', amount: 200)
+ end.check_request do |_endpoint, data, _headers|
assert_match(%r{200<}, data)
end.respond_with(successful_void_response)
assert_success response
@@ -100,133 +101,133 @@ def test_scrub
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'
+ 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'
+ 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
+ <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
+ <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
+ <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
+ <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
+ <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
def successful_void_response
- <<-XML
-<Response>
- <ResponseCode>0</ResponseCode>
- <DeclinedCode></DeclinedCode>
- <DeclinedMessage></DeclinedMessage>
- </Response>
-
+ <<~XML
+ <Response>
+ <ResponseCode>0</ResponseCode>
+ <DeclinedCode></DeclinedCode>
+ <DeclinedMessage></DeclinedMessage>
+ </Response>
+
XML
end
end
diff --git a/test/unit/gateways/banwire_test.rb b/test/unit/gateways/banwire_test.rb
index faa341c1f97..b28c2411e75 100644
--- a/test/unit/gateways/banwire_test.rb
+++ b/test/unit/gateways/banwire_test.rb
@@ -5,32 +5,33 @@ class BanwireTest < Test::Unit::TestCase
def setup
@gateway = BanwireGateway.new(
- :login => 'desarrollo',
- :currency => 'MXN')
+ login: 'desarrollo',
+ currency: 'MXN'
+ )
@credit_card = credit_card('5204164299999999',
- :month => 11,
- :year => 2012,
- :verification_value => '999')
+ month: 11,
+ year: 2012,
+ verification_value: '999')
@amount = 100
@options = {
- :order_id => '1',
- :email => 'test@email.com',
- :billing_address => address,
- :description => 'Store purchase'
+ order_id: '1',
+ email: 'test@email.com',
+ billing_address: address,
+ description: 'Store purchase'
}
@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',
- :billing_address => address(:address1 => 'Horacio', :zip => 11560),
- :description => 'Store purchase amex'
+ order_id: '2',
+ email: 'test@email.com',
+ billing_address: address(address1: 'Horacio', zip: 11560),
+ description: 'Store purchase amex'
}
end
@@ -65,7 +66,7 @@ def test_invalid_json
def test_successful_amex_purchase
response = stub_comms do
@gateway.purchase(@amount, @amex_credit_card, @amex_options)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/post_code=11560/, data)
end.respond_with(successful_purchase_amex_response)
diff --git a/test/unit/gateways/barclaycard_smartpay_test.rb b/test/unit/gateways/barclaycard_smartpay_test.rb
index 87ad0da5c0b..9b84e216b0c 100644
--- a/test/unit/gateways/barclaycard_smartpay_test.rb
+++ b/test/unit/gateways/barclaycard_smartpay_test.rb
@@ -46,37 +46,38 @@ def setup
}
@options_with_shipping_house_number_and_shipping_street = {
- order_id: '1',
- street: 'Top Level Drive',
- house_number: '1000',
- billing_address: address,
- shipping_house_number: '999',
- shipping_street: 'Downtown Loop',
- shipping_address: {
- name: 'PU JOI SO',
- address1: '新北市店溪路3579號139樓',
- company: 'Widgets Inc',
- city: '新北市',
- zip: '231509',
- country: 'TW',
- phone: '(555)555-5555',
- fax: '(555)555-6666'
- },
- description: 'Store Purchase'
+ order_id: '1',
+ street: 'Top Level Drive',
+ house_number: '1000',
+ billing_address: address,
+ shipping_house_number: '999',
+ shipping_street: 'Downtown Loop',
+ shipping_address: {
+ name: 'PU JOI SO',
+ address1: '新北市店溪路3579號139樓',
+ company: 'Widgets Inc',
+ city: '新北市',
+ zip: '231509',
+ country: 'TW',
+ phone: '(555)555-5555',
+ fax: '(555)555-6666'
+ },
+ description: 'Store Purchase'
}
@options_with_credit_fields = {
order_id: '1',
- billing_address: {
- name: 'Jim Smith',
- address1: '100 Street',
- company: 'Widgets Inc',
- city: 'Ottawa',
- state: 'ON',
- zip: 'K1C2N6',
- country: 'CA',
- phone: '(555)555-5555',
- fax: '(555)555-6666'},
+ billing_address: {
+ name: 'Jim Smith',
+ address1: '100 Street',
+ company: 'Widgets Inc',
+ city: 'Ottawa',
+ state: 'ON',
+ zip: 'K1C2N6',
+ country: 'CA',
+ phone: '(555)555-5555',
+ fax: '(555)555-6666'
+ },
email: 'long@bob.com',
customer: 'Longbob Longsen',
description: 'Store Purchase',
@@ -92,14 +93,14 @@ def setup
@avs_address = @options.clone
@avs_address.update(billing_address: {
- name: 'Jim Smith',
- street: 'Test AVS result',
- houseNumberOrName: '2',
- city: 'Cupertino',
- state: 'CA',
- zip: '95014',
- country: 'US'
- })
+ name: 'Jim Smith',
+ street: 'Test AVS result',
+ houseNumberOrName: '2',
+ city: 'Cupertino',
+ state: 'CA',
+ zip: '95014',
+ country: 'US'
+ })
@normalized_3ds_2_options = {
reference: '345123',
@@ -108,7 +109,7 @@ def setup
shopper_reference: 'John Smith',
billing_address: address(),
order_id: '123',
- stored_credential: {reason_type: 'unscheduled'},
+ stored_credential: { reason_type: 'unscheduled' },
three_ds_2: {
channel: 'browser',
browser_info: {
@@ -139,7 +140,7 @@ def test_successful_purchase
def test_successful_authorize_with_alternate_address
response = stub_comms do
@gateway.authorize(@amount, @credit_card, @options_with_alternate_address)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/billingAddress.houseNumberOrName=%E6%96%B0%E5%8C%97%E5%B8%82%E5%BA%97%E6%BA%AA%E8%B7%AF3579%E8%99%9F139%E6%A8%93/, data)
assert_match(/billingAddress.street=Not\+Provided/, data)
end.respond_with(successful_authorize_response)
@@ -154,7 +155,7 @@ def test_successful_authorize_with_house_number_and_street
@gateway.authorize(@amount,
@credit_card,
@options_with_house_number_and_street)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/billingAddress.street=Top\+Level\+Drive/, data)
assert_match(/billingAddress.houseNumberOrName=1000/, data)
end.respond_with(successful_authorize_response)
@@ -169,7 +170,7 @@ def test_successful_authorize_with_shipping_house_number_and_street
@gateway.authorize(@amount,
@credit_card,
@options_with_shipping_house_number_and_shipping_street)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/billingAddress.street=Top\+Level\+Drive/, data)
assert_match(/billingAddress.houseNumberOrName=1000/, data)
assert_match(/deliveryAddress.street=Downtown\+Loop/, data)
@@ -196,7 +197,7 @@ def test_successful_authorize_with_extra_options
shopper_statement: shopper_statement
)
)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/shopperInteraction=#{shopper_interaction}/, data)
assert_match(/shopperStatement=#{Regexp.quote(CGI.escape(shopper_statement))}/, data)
assert_match(/deviceFingerprint=#{device_fingerprint}/, data)
@@ -256,7 +257,7 @@ def test_successful_capture
end
def test_failed_capture
- @gateway.stubs(:ssl_post).raises(ActiveMerchant::ResponseError.new(stub(:code => '422', :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
@@ -267,7 +268,7 @@ def test_failed_capture
def test_legacy_capture_psp_reference_passed_for_refund
response = stub_comms do
@gateway.refund(@amount, '8814002632606717', @options)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/originalReference=8814002632606717/, data)
end.respond_with(successful_refund_response)
@@ -278,7 +279,7 @@ def test_legacy_capture_psp_reference_passed_for_refund
def test_successful_refund
response = stub_comms do
@gateway.refund(@amount, '7914002629995504#8814002632606717', @options)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/originalReference=7914002629995504&/, data)
assert_no_match(/8814002632606717/, data)
end.respond_with(successful_refund_response)
@@ -288,7 +289,7 @@ def test_successful_refund
end
def test_failed_refund
- @gateway.stubs(:ssl_post).raises(ActiveMerchant::ResponseError.new(stub(:code => '422', :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
@@ -313,7 +314,7 @@ def test_failed_credit
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|
+ end.check_request do |endpoint, data, _headers|
assert_match(%r{/refundWithData}, endpoint)
assert_match(/dateOfBirth=1990-10-11&/, data)
assert_match(/entityType=NaturalPerson&/, data)
@@ -327,9 +328,9 @@ def test_credit_contains_all_fields
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
+ @gateway.credit(@amount, @credit_card, @options_with_credit_fields.merge({ third_party_payout: true }))
+ end.check_request do |endpoint, data, _headers|
+ if /storeDetailAndSubmitThirdParty/.match?(endpoint)
assert_match(%r{/storeDetailAndSubmitThirdParty}, endpoint)
assert_match(/dateOfBirth=1990-10-11&/, data)
assert_match(/entityType=NaturalPerson&/, data)
@@ -371,9 +372,9 @@ def test_unsuccessful_verify
def test_authorize_nonfractional_currency
response = stub_comms do
@gateway.authorize(@amount, @credit_card, @options.merge(currency: 'JPY'))
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/amount.value=1/, data)
- assert_match(/amount.currency=JPY/, data)
+ assert_match(/amount.currency=JPY/, data)
end.respond_with(successful_authorize_response)
assert_success response
@@ -382,9 +383,9 @@ def test_authorize_nonfractional_currency
def test_authorize_three_decimal_currency
response = stub_comms do
@gateway.authorize(@amount, @credit_card, @options.merge(currency: 'OMR'))
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/amount.value=100/, data)
- assert_match(/amount.currency=OMR/, data)
+ assert_match(/amount.currency=OMR/, data)
end.respond_with(successful_authorize_response)
assert_success response
@@ -398,13 +399,67 @@ def test_successful_store
end
def test_failed_store
- @gateway.stubs(:ssl_post).raises(ActiveMerchant::ResponseError.new(stub(:code => '422', :body => failed_store_response)))
+ @gateway.stubs(:ssl_post).raises(ActiveMerchant::ResponseError.new(stub(code: '422', body: failed_store_response)))
response = @gateway.store(@credit_card, @options)
assert_failure response
assert response.test?
end
+ def test_execute_threed_false_sent_3ds2
+ stub_comms do
+ @gateway.authorize(@amount, @credit_card, @normalized_3ds_2_options.merge({ execute_threed: false }))
+ end.check_request do |_endpoint, data, _headers|
+ refute_match(/additionalData.scaExemption/, data)
+ assert_match(/additionalData.executeThreeD=false/, data)
+ end.respond_with(successful_authorize_response)
+ end
+
+ def test_sca_exemption_not_sent_if_execute_threed_missing_3ds2
+ stub_comms do
+ @gateway.authorize(@amount, @credit_card, @normalized_3ds_2_options.merge({ scaExemption: 'lowValue' }))
+ end.check_request do |_endpoint, data, _headers|
+ refute_match(/additionalData.scaExemption/, data)
+ refute_match(/additionalData.executeThreeD=false/, data)
+ end.respond_with(successful_authorize_response)
+ end
+
+ def test_sca_exemption_and_execute_threed_false_sent_3ds2
+ stub_comms do
+ @gateway.authorize(@amount, @credit_card, @normalized_3ds_2_options.merge({ sca_exemption: 'lowValue', execute_threed: false }))
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(/additionalData.scaExemption=lowValue/, data)
+ assert_match(/additionalData.executeThreeD=false/, data)
+ end.respond_with(successful_authorize_response)
+ end
+
+ def test_sca_exemption_and_execute_threed_true_sent_3ds2
+ stub_comms do
+ @gateway.authorize(@amount, @credit_card, @normalized_3ds_2_options.merge({ sca_exemption: 'lowValue', execute_threed: true }))
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(/additionalData.scaExemption=lowValue/, data)
+ assert_match(/additionalData.executeThreeD=true/, data)
+ end.respond_with(successful_authorize_response)
+ end
+
+ def test_sca_exemption_not_sent_when_execute_threed_true_3ds1
+ stub_comms do
+ @gateway.authorize(@amount, @credit_card, @options.merge({ sca_exemption: 'lowValue', execute_threed: true }))
+ end.check_request do |_endpoint, data, _headers|
+ refute_match(/additionalData.scaExemption/, data)
+ assert_match(/additionalData.executeThreeD=true/, data)
+ end.respond_with(successful_authorize_response)
+ end
+
+ def test_sca_exemption_not_sent_when_execute_threed_false_3ds1
+ stub_comms do
+ @gateway.authorize(@amount, @credit_card, @options.merge({ sca_exemption: 'lowValue', execute_threed: false }))
+ end.check_request do |_endpoint, data, _headers|
+ refute_match(/additionalData.scaExemption/, data)
+ refute_match(/additionalData.executeThreeD/, data)
+ end.respond_with(successful_authorize_response)
+ end
+
def test_avs_result
@gateway.expects(:ssl_post).returns(failed_avs_response)
@@ -597,5 +652,4 @@ def scrubbed_transcript
Conn close
)
end
-
end
diff --git a/test/unit/gateways/barclays_epdq_extra_plus_test.rb b/test/unit/gateways/barclays_epdq_extra_plus_test.rb
index 330bdf13d4d..194173a69c9 100644
--- a/test/unit/gateways/barclays_epdq_extra_plus_test.rb
+++ b/test/unit/gateways/barclays_epdq_extra_plus_test.rb
@@ -2,21 +2,21 @@
class BarclaysEpdqExtraPlusTest < Test::Unit::TestCase
def setup
- @credentials = { :login => 'pspid',
- :user => 'username',
- :password => 'password',
- :signature => 'mynicesig',
- :signature_encryptor => 'sha512' }
+ @credentials = { login: 'pspid',
+ user: 'username',
+ password: 'password',
+ signature: 'mynicesig',
+ signature_encryptor: 'sha512' }
@gateway = BarclaysEpdqExtraPlusGateway.new(@credentials)
@credit_card = credit_card
- @mastercard = credit_card('5399999999999999', :brand => 'mastercard')
+ @mastercard = credit_card('5399999999999999', brand: 'mastercard')
@amount = 100
@identification = '3014726'
@billing_id = 'myalias'
@options = {
- :order_id => '1',
- :billing_address => address,
- :description => 'Store Purchase'
+ order_id: '1',
+ billing_address: address,
+ description: 'Store Purchase'
}
@parameters = {
'orderID' => '1',
@@ -54,7 +54,7 @@ def test_successful_purchase_with_action_param
@gateway.expects(:add_pair).at_least(1)
@gateway.expects(:add_pair).with(anything, 'ECI', '7')
@gateway.expects(:ssl_post).returns(successful_purchase_response)
- assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:action => 'SAS'))
+ assert response = @gateway.purchase(@amount, @credit_card, @options.merge(action: 'SAS'))
assert_success response
assert_equal '3014726;SAS', response.authorization
assert response.params['HTML_ANSWER'].nil?
@@ -74,7 +74,7 @@ def test_successful_purchase_with_custom_eci
@gateway.expects(:add_pair).at_least(1)
@gateway.expects(:add_pair).with(anything, 'ECI', '4')
@gateway.expects(:ssl_post).returns(successful_purchase_response)
- assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:eci => 4))
+ assert response = @gateway.purchase(@amount, @credit_card, @options.merge(eci: 4))
assert_success response
assert_equal '3014726;SAL', response.authorization
assert response.test?
@@ -82,7 +82,7 @@ def test_successful_purchase_with_custom_eci
def test_successful_purchase_with_3dsecure
@gateway.expects(:ssl_post).returns(successful_3dsecure_purchase_response)
- assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:d3d => true))
+ assert response = @gateway.purchase(@amount, @credit_card, @options.merge(d3d: true))
assert_success response
assert_equal '3014726;SAL', response.authorization
assert response.params['HTML_ANSWER']
@@ -115,7 +115,7 @@ def test_successful_authorize_with_custom_eci
@gateway.expects(:add_pair).at_least(1)
@gateway.expects(:add_pair).with(anything, 'ECI', '4')
@gateway.expects(:ssl_post).returns(successful_purchase_response)
- assert response = @gateway.authorize(@amount, @credit_card, @options.merge(:eci => 4))
+ assert response = @gateway.authorize(@amount, @credit_card, @options.merge(eci: 4))
assert_success response
assert_equal '3014726;RES', response.authorization
assert response.test?
@@ -123,7 +123,7 @@ def test_successful_authorize_with_custom_eci
def test_successful_authorize_with_3dsecure
@gateway.expects(:ssl_post).returns(successful_3dsecure_purchase_response)
- assert response = @gateway.authorize(@amount, @credit_card, @options.merge(:d3d => true))
+ assert response = @gateway.authorize(@amount, @credit_card, @options.merge(d3d: true))
assert_success response
assert_equal '3014726;RES', response.authorization
assert response.params['HTML_ANSWER']
@@ -141,7 +141,7 @@ def test_successful_capture
def test_successful_capture_with_action_option
@gateway.expects(:ssl_post).returns(successful_capture_response)
- assert response = @gateway.capture(@amount, '3048326', :action => 'SAS')
+ assert response = @gateway.capture(@amount, '3048326', action: 'SAS')
assert_success response
assert_equal '3048326;SAS', response.authorization
assert response.test?
@@ -185,7 +185,7 @@ def test_successful_store
@gateway.expects(:add_pair).at_least(1)
@gateway.expects(:add_pair).with(anything, 'ECI', '7')
@gateway.expects(:ssl_post).times(2).returns(successful_purchase_response)
- assert response = @gateway.store(@credit_card, :billing_id => @billing_id)
+ assert response = @gateway.store(@credit_card, billing_id: @billing_id)
assert_success response
assert_equal '3014726;RES', response.authorization
assert_equal '2', response.billing_id
@@ -197,7 +197,7 @@ def test_deprecated_store_option
@gateway.expects(:add_pair).with(anything, 'ECI', '7')
@gateway.expects(:ssl_post).times(2).returns(successful_purchase_response)
assert_deprecation_warning(BarclaysEpdqExtraPlusGateway::OGONE_STORE_OPTION_DEPRECATION_MESSAGE) do
- assert response = @gateway.store(@credit_card, :store => @billing_id)
+ assert response = @gateway.store(@credit_card, store: @billing_id)
assert_success response
assert_equal '3014726;RES', response.authorization
assert response.test?
@@ -225,7 +225,7 @@ def test_supported_countries
end
def test_supported_card_types
- assert_equal [:visa, :master, :american_express, :diners_club, :discover, :jcb, :maestro], BarclaysEpdqExtraPlusGateway.supported_cardtypes
+ assert_equal %i[visa master american_express diners_club discover jcb maestro], BarclaysEpdqExtraPlusGateway.supported_cardtypes
end
def test_default_currency
@@ -239,7 +239,7 @@ def test_default_currency
end
def test_custom_currency_at_gateway_level
- gateway = BarclaysEpdqExtraPlusGateway.new(@credentials.merge(:currency => 'USD'))
+ gateway = BarclaysEpdqExtraPlusGateway.new(@credentials.merge(currency: 'USD'))
gateway.expects(:add_pair).at_least(1)
gateway.expects(:add_pair).with(anything, 'currency', 'USD')
gateway.expects(:ssl_post).returns(successful_purchase_response)
@@ -247,11 +247,11 @@ def test_custom_currency_at_gateway_level
end
def test_local_custom_currency_overwrite_gateway_level
- gateway = BarclaysEpdqExtraPlusGateway.new(@credentials.merge(:currency => 'USD'))
+ gateway = BarclaysEpdqExtraPlusGateway.new(@credentials.merge(currency: 'USD'))
gateway.expects(:add_pair).at_least(1)
gateway.expects(:add_pair).with(anything, 'currency', 'EUR')
gateway.expects(:ssl_post).returns(successful_purchase_response)
- gateway.purchase(@amount, @credit_card, @options.merge(:currency => 'EUR'))
+ gateway.purchase(@amount, @credit_card, @options.merge(currency: 'EUR'))
end
def test_avs_result
@@ -310,13 +310,13 @@ def test_format_error_message_with_no_separator
end
def test_without_signature
- gateway = BarclaysEpdqExtraPlusGateway.new(@credentials.merge(:signature => nil, :signature_encryptor => nil))
+ gateway = BarclaysEpdqExtraPlusGateway.new(@credentials.merge(signature: nil, signature_encryptor: nil))
gateway.expects(:ssl_post).returns(successful_purchase_response)
assert_deprecation_warning(BarclaysEpdqExtraPlusGateway::OGONE_NO_SIGNATURE_DEPRECATION_MESSAGE) do
gateway.purchase(@amount, @credit_card, @options)
end
- gateway = BarclaysEpdqExtraPlusGateway.new(@credentials.merge(:signature => nil, :signature_encryptor => 'none'))
+ gateway = BarclaysEpdqExtraPlusGateway.new(@credentials.merge(signature: nil, signature_encryptor: 'none'))
gateway.expects(:ssl_post).returns(successful_purchase_response)
assert_no_deprecation_warning do
gateway.purchase(@amount, @credit_card, @options)
@@ -324,27 +324,27 @@ def test_without_signature
end
def test_signature_for_accounts_created_before_10_may_20101
- gateway = BarclaysEpdqExtraPlusGateway.new(@credentials.merge(:signature_encryptor => nil))
+ gateway = BarclaysEpdqExtraPlusGateway.new(@credentials.merge(signature_encryptor: nil))
assert signature = gateway.send(:add_signature, @parameters)
assert_equal Digest::SHA1.hexdigest('1100EUR4111111111111111MrPSPIDRES2mynicesig').upcase, signature
end
def test_signature_for_accounts_with_signature_encryptor_to_sha1
- gateway = BarclaysEpdqExtraPlusGateway.new(@credentials.merge(:signature_encryptor => 'sha1'))
+ gateway = BarclaysEpdqExtraPlusGateway.new(@credentials.merge(signature_encryptor: 'sha1'))
assert signature = gateway.send(:add_signature, @parameters)
assert_equal Digest::SHA1.hexdigest(string_to_digest).upcase, signature
end
def test_signature_for_accounts_with_signature_encryptor_to_sha256
- gateway = BarclaysEpdqExtraPlusGateway.new(@credentials.merge(:signature_encryptor => 'sha256'))
+ gateway = BarclaysEpdqExtraPlusGateway.new(@credentials.merge(signature_encryptor: 'sha256'))
assert signature = gateway.send(:add_signature, @parameters)
assert_equal Digest::SHA256.hexdigest(string_to_digest).upcase, signature
end
def test_signature_for_accounts_with_signature_encryptor_to_sha512
- gateway = BarclaysEpdqExtraPlusGateway.new(@credentials.merge(:signature_encryptor => 'sha512'))
+ gateway = BarclaysEpdqExtraPlusGateway.new(@credentials.merge(signature_encryptor: 'sha512'))
assert signature = gateway.send(:add_signature, @parameters)
assert_equal Digest::SHA512.hexdigest(string_to_digest).upcase, signature
end
@@ -359,13 +359,13 @@ def test_3dsecure_win_3ds_option
post = {}
gateway = BarclaysEpdqExtraPlusGateway.new(@credentials)
- gateway.send(:add_d3d, post, { :win_3ds => :pop_up })
+ gateway.send(:add_d3d, post, { win_3ds: :pop_up })
assert 'POPUP', post['WIN3DS']
- gateway.send(:add_d3d, post, { :win_3ds => :pop_ix })
+ gateway.send(:add_d3d, post, { win_3ds: :pop_ix })
assert 'POPIX', post['WIN3DS']
- gateway.send(:add_d3d, post, { :win_3ds => :invalid })
+ gateway.send(:add_d3d, post, { win_3ds: :invalid })
assert 'MAINW', post['WIN3DS']
end
@@ -374,14 +374,14 @@ def test_3dsecure_additional_options
gateway = BarclaysEpdqExtraPlusGateway.new(@credentials)
gateway.send(:add_d3d, post, {
- :http_accept => 'text/html',
- :http_user_agent => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)',
- :accept_url => 'https://accept_url',
- :decline_url => 'https://decline_url',
- :exception_url => 'https://exception_url',
- :paramsplus => 'params_plus',
- :complus => 'com_plus',
- :language => 'fr_FR'
+ http_accept: 'text/html',
+ http_user_agent: 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)',
+ accept_url: 'https://accept_url',
+ decline_url: 'https://decline_url',
+ exception_url: 'https://exception_url',
+ paramsplus: 'params_plus',
+ complus: 'com_plus',
+ language: 'fr_FR'
})
assert 'HTTP_ACCEPT', 'text/html'
assert 'HTTP_USER_AGENT', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)'
@@ -427,7 +427,7 @@ def d3d_string_to_digest
end
def successful_authorize_response
- <<-END
+ <<-XML
- END
+ XML
end
def successful_purchase_response
- <<-END
+ <<-XML
- END
+ XML
end
def successful_3dsecure_purchase_response
- <<-END
+ <<-XML
- END
+ XML
end
def failed_purchase_response
- <<-END
+ <<-XML
- END
+ XML
end
def successful_capture_response
- <<-END
+ <<-XML
- END
+ XML
end
def successful_void_response
- <<-END
+ <<-XML
- END
+ XML
end
def successful_referenced_credit_response
- <<-END
+ <<-XML
- END
+ XML
end
def successful_unreferenced_credit_response
- <<-END
+ <<-XML
- END
+ XML
end
def test_failed_authorization_due_to_unknown_order_number
- <<-END
+ <<-XML
- END
+ XML
end
def transcript
diff --git a/test/unit/gateways/be2bill_test.rb b/test/unit/gateways/be2bill_test.rb
index d83f42e42b5..e4ca81f6381 100644
--- a/test/unit/gateways/be2bill_test.rb
+++ b/test/unit/gateways/be2bill_test.rb
@@ -3,17 +3,17 @@
class Be2billTest < Test::Unit::TestCase
def setup
@gateway = Be2billGateway.new(
- :login => 'login',
- :password => 'password'
- )
+ login: 'login',
+ password: 'password'
+ )
@credit_card = credit_card
@amount = 100
@options = {
- :order_id => '1',
- :billing_address => address,
- :description => 'Store Purchase'
+ order_id: '1',
+ billing_address: address,
+ description: 'Store Purchase'
}
end
@@ -41,11 +41,11 @@ def test_unsuccessful_request
# Place raw successful response from gateway here
def successful_purchase_response
- {'OPERATIONTYPE'=>'payment', 'TRANSACTIONID'=>'A189063', 'EXECCODE'=>'0000', 'MESSAGE'=>'The transaction has been accepted.', 'ALIAS'=>'A189063', 'DESCRIPTOR'=>'RENTABILITEST'}.to_json
+ { 'OPERATIONTYPE' => 'payment', 'TRANSACTIONID' => 'A189063', 'EXECCODE' => '0000', 'MESSAGE' => 'The transaction has been accepted.', 'ALIAS' => 'A189063', 'DESCRIPTOR' => 'RENTABILITEST' }.to_json
end
# Place raw failed response from gateway here
def failed_purchase_response
- {'OPERATIONTYPE'=>'payment', 'TRANSACTIONID'=>'A189063', 'EXECCODE'=>'1001', 'MESSAGE'=>"The parameter \"CARDCODE\" is missing.\n", 'DESCRIPTOR'=>'RENTABILITEST'}.to_json
+ { 'OPERATIONTYPE' => 'payment', 'TRANSACTIONID' => 'A189063', 'EXECCODE' => '1001', 'MESSAGE' => "The parameter \"CARDCODE\" is missing.\n", 'DESCRIPTOR' => 'RENTABILITEST' }.to_json
end
end
diff --git a/test/unit/gateways/beanstream_interac_test.rb b/test/unit/gateways/beanstream_interac_test.rb
index a0a7bac3862..71f7d3f9dda 100644
--- a/test/unit/gateways/beanstream_interac_test.rb
+++ b/test/unit/gateways/beanstream_interac_test.rb
@@ -3,16 +3,16 @@
class BeanstreamInteracTest < Test::Unit::TestCase
def setup
@gateway = BeanstreamInteracGateway.new(
- :login => 'login',
- :password => 'password'
- )
+ login: 'login',
+ password: 'password'
+ )
@amount = 100
@options = {
- :order_id => '1',
- :billing_address => address,
- :description => 'Store Purchase'
+ order_id: '1',
+ billing_address: address,
+ description: 'Store Purchase'
}
end
diff --git a/test/unit/gateways/beanstream_test.rb b/test/unit/gateways/beanstream_test.rb
index c07adf22c0e..886a4479e1c 100644
--- a/test/unit/gateways/beanstream_test.rb
+++ b/test/unit/gateways/beanstream_test.rb
@@ -7,11 +7,11 @@ def setup
Base.mode = :test
@gateway = BeanstreamGateway.new(
- :login => 'merchant id',
- :user => 'username',
- :password => 'password',
- :api_key => 'api_key'
- )
+ login: 'merchant id',
+ user: 'username',
+ password: 'password',
+ api_key: 'api_key'
+ )
@credit_card = credit_card
@@ -25,42 +25,43 @@ def setup
transaction_id: 'transaction ID'
)
- @check = check(
- :institution_number => '001',
- :transit_number => '26729'
- )
+ @check = check(
+ institution_number: '001',
+ transit_number: '26729'
+ )
@amount = 1000
@options = {
- :order_id => '1234',
- :billing_address => {
- :name => 'xiaobo zzz',
- :phone => '555-555-5555',
- :address1 => '1234 Levesque St.',
- :address2 => 'Apt B',
- :city => 'Montreal',
- :state => 'QC',
- :country => 'CA',
- :zip => 'H2C1X8'
+ order_id: '1234',
+ billing_address: {
+ name: 'xiaobo zzz',
+ phone: '555-555-5555',
+ address1: '1234 Levesque St.',
+ address2: 'Apt B',
+ city: 'Montreal',
+ state: 'QC',
+ country: 'CA',
+ zip: 'H2C1X8'
},
- :email => 'xiaobozzz@example.com',
- :subtotal => 800,
- :shipping => 100,
- :tax1 => 100,
- :tax2 => 100,
- :custom => 'reference one'
+ email: 'xiaobozzz@example.com',
+ subtotal: 800,
+ shipping: 100,
+ tax1: 100,
+ tax2: 100,
+ custom: 'reference one'
}
@recurring_options = @options.merge(
- :interval => { :unit => :months, :length => 1 },
- :occurrences => 5)
+ interval: { unit: :months, length: 1 },
+ occurrences: 5
+ )
end
def test_successful_purchase
response = stub_comms(@gateway, :ssl_request) do
@gateway.purchase(@amount, @decrypted_credit_card, @options)
- end.check_request do |method, endpoint, data, headers|
+ end.check_request do |_method, _endpoint, data, _headers|
refute_match(/recurringPayment=true/, data)
end.respond_with(successful_purchase_response)
@@ -71,7 +72,7 @@ def test_successful_purchase
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|
+ end.check_request do |_method, _endpoint, data, _headers|
assert_match(/recurringPayment=1/, data)
end.respond_with(successful_purchase_response)
@@ -81,7 +82,7 @@ def test_successful_purchase_with_recurring
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|
+ end.check_request do |_method, _endpoint, data, _headers|
assert_match(/recurringPayment=1/, data)
end.respond_with(successful_purchase_response)
@@ -210,7 +211,7 @@ def test_successful_update_recurring
@gateway.expects(:ssl_post).returns(successful_update_recurring_response)
response = assert_deprecation_warning(Gateway::RECURRING_DEPRECATION_MESSAGE) do
- @gateway.update_recurring(@amount, @credit_card, @recurring_options.merge(:account_id => response.params['rbAccountId']))
+ @gateway.update_recurring(@amount, @credit_card, @recurring_options.merge(account_id: response.params['rbAccountId']))
end
assert_success response
assert_equal 'Request successful', response.message
@@ -228,14 +229,14 @@ def test_successful_cancel_recurring
@gateway.expects(:ssl_post).returns(successful_cancel_recurring_response)
response = assert_deprecation_warning(Gateway::RECURRING_DEPRECATION_MESSAGE) do
- @gateway.cancel_recurring(:account_id => response.params['rbAccountId'])
+ @gateway.cancel_recurring(account_id: response.params['rbAccountId'])
end
assert_success response
assert_equal 'Request successful', response.message
end
def test_ip_is_being_sent
- @gateway.expects(:ssl_post).with do |url, data|
+ @gateway.expects(:ssl_post).with do |_url, data|
data =~ /customerIp=123\.123\.123\.123/
end.returns(successful_purchase_response)
@@ -246,7 +247,7 @@ def test_ip_is_being_sent
def test_includes_network_tokenization_fields
response = stub_comms(@gateway, :ssl_request) do
@gateway.purchase(@amount, @decrypted_credit_card, @options)
- end.check_request do |method, endpoint, data, headers|
+ end.check_request do |_method, _endpoint, data, _headers|
assert_match(/3DSecureXID/, data)
assert_match(/3DSecureECI/, data)
assert_match(/3DSecureCAVV/, data)
@@ -261,7 +262,7 @@ def test_defaults_state_and_zip_with_country
@options[:shipping_address] = address
response = stub_comms(@gateway, :ssl_request) do
@gateway.purchase(@amount, @decrypted_credit_card, @options)
- end.check_request do |method, endpoint, data, headers|
+ end.check_request do |_method, _endpoint, data, _headers|
assert_match(/ordProvince=--/, data)
assert_match(/ordPostalCode=000000/, data)
assert_match(/shipProvince=--/, data)
@@ -272,12 +273,12 @@ def test_defaults_state_and_zip_with_country
end
def test_no_state_and_zip_default_with_missing_country
- address = { }
+ address = {}
@options[:billing_address] = address
@options[:shipping_address] = address
response = stub_comms(@gateway, :ssl_request) do
@gateway.purchase(@amount, @decrypted_credit_card, @options)
- end.check_request do |method, endpoint, data, headers|
+ end.check_request do |_method, _endpoint, data, _headers|
assert_no_match(/ordProvince=--/, data)
assert_no_match(/ordPostalCode=000000/, data)
assert_no_match(/shipProvince=--/, data)
@@ -293,7 +294,7 @@ def test_sends_email_without_addresses
@options[:shipping_email] = 'ship@mail.com'
response = stub_comms(@gateway, :ssl_request) do
@gateway.purchase(@amount, @decrypted_credit_card, @options)
- end.check_request do |method, endpoint, data, headers|
+ end.check_request do |_method, _endpoint, data, _headers|
assert_match(/ordEmailAddress=xiaobozzz%40example.com/, data)
assert_match(/shipEmailAddress=ship%40mail.com/, data)
end.respond_with(successful_purchase_response)
@@ -340,11 +341,11 @@ def unsuccessful_void_response
end
def brazilian_address_params_without_zip_and_state
- { :shipProvince => '--', :shipPostalCode => '000000', :ordProvince => '--', :ordPostalCode => '000000', :ordCountry => 'BR', :trnCardOwner => 'Longbob Longsen', :shipCity => 'Rio de Janeiro', :ordAddress1 => '1234 Levesque St.', :ordShippingPrice => '1.00', :deliveryEstimate => nil, :shipName => 'xiaobo zzz', :trnCardNumber => '4242424242424242', :trnAmount => '10.00', :trnType => 'P', :ordAddress2 => 'Apt B', :ordTax1Price => '1.00', :shipEmailAddress => 'xiaobozzz@example.com', :trnExpMonth => '09', :ordCity => 'Rio de Janeiro', :shipPhoneNumber => '555-555-5555', :ordName => 'xiaobo zzz', :trnExpYear => next_year, :trnOrderNumber => '1234', :shipCountry => 'BR', :ordTax2Price => '1.00', :shipAddress1 => '1234 Levesque St.', :ordEmailAddress => 'xiaobozzz@example.com', :trnCardCvd => '123', :trnComments => nil, :shippingMethod => nil, :ref1 => 'reference one', :shipAddress2 => 'Apt B', :ordPhoneNumber => '555-555-5555', :ordItemPrice => '8.00' }
+ { shipProvince: '--', shipPostalCode: '000000', ordProvince: '--', ordPostalCode: '000000', ordCountry: 'BR', trnCardOwner: 'Longbob Longsen', shipCity: 'Rio de Janeiro', ordAddress1: '1234 Levesque St.', ordShippingPrice: '1.00', deliveryEstimate: nil, shipName: 'xiaobo zzz', trnCardNumber: '4242424242424242', trnAmount: '10.00', trnType: 'P', ordAddress2: 'Apt B', ordTax1Price: '1.00', shipEmailAddress: 'xiaobozzz@example.com', trnExpMonth: '09', ordCity: 'Rio de Janeiro', shipPhoneNumber: '555-555-5555', ordName: 'xiaobo zzz', trnExpYear: next_year, trnOrderNumber: '1234', shipCountry: 'BR', ordTax2Price: '1.00', shipAddress1: '1234 Levesque St.', ordEmailAddress: 'xiaobozzz@example.com', trnCardCvd: '123', trnComments: nil, shippingMethod: nil, ref1: 'reference one', shipAddress2: 'Apt B', ordPhoneNumber: '555-555-5555', ordItemPrice: '8.00' }
end
def german_address_params_without_state
- { :shipProvince => '--', :shipPostalCode => '12345', :ordProvince => '--', :ordPostalCode => '12345', :ordCountry => 'DE', :trnCardOwner => 'Longbob Longsen', :shipCity => 'Berlin', :ordAddress1 => '1234 Levesque St.', :ordShippingPrice => '1.00', :deliveryEstimate => nil, :shipName => 'xiaobo zzz', :trnCardNumber => '4242424242424242', :trnAmount => '10.00', :trnType => 'P', :ordAddress2 => 'Apt B', :ordTax1Price => '1.00', :shipEmailAddress => 'xiaobozzz@example.com', :trnExpMonth => '09', :ordCity => 'Berlin', :shipPhoneNumber => '555-555-5555', :ordName => 'xiaobo zzz', :trnExpYear => next_year, :trnOrderNumber => '1234', :shipCountry => 'DE', :ordTax2Price => '1.00', :shipAddress1 => '1234 Levesque St.', :ordEmailAddress => 'xiaobozzz@example.com', :trnCardCvd => '123', :trnComments => nil, :shippingMethod => nil, :ref1 => 'reference one', :shipAddress2 => 'Apt B', :ordPhoneNumber => '555-555-5555', :ordItemPrice => '8.00' }
+ { shipProvince: '--', shipPostalCode: '12345', ordProvince: '--', ordPostalCode: '12345', ordCountry: 'DE', trnCardOwner: 'Longbob Longsen', shipCity: 'Berlin', ordAddress1: '1234 Levesque St.', ordShippingPrice: '1.00', deliveryEstimate: nil, shipName: 'xiaobo zzz', trnCardNumber: '4242424242424242', trnAmount: '10.00', trnType: 'P', ordAddress2: 'Apt B', ordTax1Price: '1.00', shipEmailAddress: 'xiaobozzz@example.com', trnExpMonth: '09', ordCity: 'Berlin', shipPhoneNumber: '555-555-5555', ordName: 'xiaobo zzz', trnExpYear: next_year, trnOrderNumber: '1234', shipCountry: 'DE', ordTax2Price: '1.00', shipAddress1: '1234 Levesque St.', ordEmailAddress: 'xiaobozzz@example.com', trnCardCvd: '123', trnComments: nil, shippingMethod: nil, ref1: 'reference one', shipAddress2: 'Apt B', ordPhoneNumber: '555-555-5555', ordItemPrice: '8.00' }
end
def next_year
@@ -370,5 +371,4 @@ def transcript
def scrubbed_transcript
'ref1=reference+one&trnCardOwner=Longbob+Longsen&trnCardNumber=[FILTERED]&trnExpMonth=09&trnExpYear=16&trnCardCvd=[FILTERED]&ordName=xiaobo+zzz&ordEmailAddress=xiaobozzz%40example.com&username=awesomesauce&password=[FILTERED]'
end
-
end
diff --git a/test/unit/gateways/blue_pay_test.rb b/test/unit/gateways/blue_pay_test.rb
index 4f883818dd7..9e952cd6a56 100644
--- a/test/unit/gateways/blue_pay_test.rb
+++ b/test/unit/gateways/blue_pay_test.rb
@@ -1,11 +1,11 @@
require 'test_helper'
RSP = {
- :approved_auth => 'AUTH_CODE=XCADZ&PAYMENT_ACCOUNT_MASK=xxxxxxxxxxxx4242&CARD_TYPE=VISA&TRANS_TYPE=AUTH&REBID=&STATUS=1&AVS=_&TRANS_ID=100134203758&CVV2=_&MESSAGE=Approved%20Auth',
- :approved_capture => 'AUTH_CODE=CHTHX&PAYMENT_ACCOUNT_MASK=xxxxxxxxxxxx4242&CARD_TYPE=VISA&TRANS_TYPE=CAPTURE&REBID=&STATUS=1&AVS=_&TRANS_ID=100134203760&CVV2=_&MESSAGE=Approved%20Capture',
- :approved_void => 'AUTH_CODE=KTMHB&PAYMENT_ACCOUNT_MASK=xxxxxxxxxxxx4242&CARD_TYPE=VISA&TRANS_TYPE=VOID&REBID=&STATUS=1&AVS=_&TRANS_ID=100134203763&CVV2=_&MESSAGE=Approved%20Void',
- :declined => 'TRANS_ID=100000000150&STATUS=0&AVS=0&CVV2=7&MESSAGE=Declined&REBID=',
- :approved_purchase => 'AUTH_CODE=GYRUY&PAYMENT_ACCOUNT_MASK=xxxxxxxxxxxx4242&CARD_TYPE=VISA&TRANS_TYPE=SALE&REBID=&STATUS=1&AVS=_&TRANS_ID=100134203767&CVV2=_&MESSAGE=Approved%20Sale'
+ approved_auth: 'AUTH_CODE=XCADZ&PAYMENT_ACCOUNT_MASK=xxxxxxxxxxxx4242&CARD_TYPE=VISA&TRANS_TYPE=AUTH&REBID=&STATUS=1&AVS=_&TRANS_ID=100134203758&CVV2=_&MESSAGE=Approved%20Auth',
+ approved_capture: 'AUTH_CODE=CHTHX&PAYMENT_ACCOUNT_MASK=xxxxxxxxxxxx4242&CARD_TYPE=VISA&TRANS_TYPE=CAPTURE&REBID=&STATUS=1&AVS=_&TRANS_ID=100134203760&CVV2=_&MESSAGE=Approved%20Capture',
+ approved_void: 'AUTH_CODE=KTMHB&PAYMENT_ACCOUNT_MASK=xxxxxxxxxxxx4242&CARD_TYPE=VISA&TRANS_TYPE=VOID&REBID=&STATUS=1&AVS=_&TRANS_ID=100134203763&CVV2=_&MESSAGE=Approved%20Void',
+ declined: 'TRANS_ID=100000000150&STATUS=0&AVS=0&CVV2=7&MESSAGE=Declined&REBID=',
+ approved_purchase: 'AUTH_CODE=GYRUY&PAYMENT_ACCOUNT_MASK=xxxxxxxxxxxx4242&CARD_TYPE=VISA&TRANS_TYPE=SALE&REBID=&STATUS=1&AVS=_&TRANS_ID=100134203767&CVV2=_&MESSAGE=Approved%20Sale'
}
class BluePayTest < Test::Unit::TestCase
@@ -13,21 +13,21 @@ class BluePayTest < Test::Unit::TestCase
def setup
@gateway = BluePayGateway.new(
- :login => 'X',
- :password => 'Y'
+ login: 'X',
+ password: 'Y'
)
@amount = 100
@credit_card = credit_card
@check = check
@rebill_id = '100096219669'
@rebill_status = 'active'
- @options = {ip: '192.168.0.1'}
+ @options = { ip: '192.168.0.1' }
end
def test_successful_authorization
response = stub_comms do
@gateway.authorize(@amount, @credit_card, @options)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/CUSTOMER_IP=192.168.0.1/, data)
end.respond_with(RSP[:approved_auth])
@@ -40,7 +40,7 @@ def test_successful_authorization
def test_successful_purchase
response = stub_comms do
@gateway.purchase(@amount, @credit_card, @options)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/CUSTOMER_IP=192.168.0.1/, data)
end.respond_with(RSP[:approved_purchase])
@@ -53,7 +53,7 @@ def test_successful_purchase
def test_failed_authorization
response = stub_comms do
@gateway.authorize(@amount, @credit_card, @options)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/CUSTOMER_IP=192.168.0.1/, data)
end.respond_with(RSP[:declined])
@@ -66,8 +66,8 @@ 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 => ''})
- assert_equal ['ADDR1', 'ADDR2', 'CITY', 'COMPANY_NAME', 'COUNTRY', 'PHONE', 'STATE', 'ZIP'], result.stringify_keys.keys.sort
+ @gateway.send(:add_address, result, billing_address: { address1: '123 Test St.', address2: '5F', city: 'Testville', company: 'Test Company', country: 'DE', state: '' })
+ assert_equal %w[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]
assert_equal 'DE', result[:COUNTRY]
@@ -76,9 +76,9 @@ 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 %w[ADDR1 ADDR2 CITY COMPANY_NAME COUNTRY PHONE STATE ZIP], result.stringify_keys.keys.sort
assert_equal 'AK', result[:STATE]
assert_equal '123 Test St.', result[:ADDR1]
assert_equal 'US', result[:COUNTRY]
@@ -88,7 +88,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]
@@ -96,19 +96,19 @@ def test_name_comes_from_payment_method
def test_add_invoice
result = {}
- @gateway.send(:add_invoice, result, :order_id => '#1001')
+ @gateway.send(:add_invoice, result, order_id: '#1001')
assert_equal '#1001', result[:invoice_num]
end
def test_add_description
result = {}
- @gateway.send(:add_invoice, result, :description => 'My Purchase is great')
+ @gateway.send(:add_invoice, result, description: 'My Purchase is great')
assert_equal 'My Purchase is great', result[:description]
end
def test_purchase_meets_minimum_requirements
params = {
- :amount => '1.01',
+ amount: '1.01'
}
@gateway.send(:add_creditcard, params, @credit_card)
@@ -121,8 +121,8 @@ def test_purchase_meets_minimum_requirements
def test_successful_refund
response = stub_comms do
- @gateway.refund(@amount, '100134230412', @options.merge({:card_number => @credit_card.number}))
- end.check_request do |endpoint, data, headers|
+ @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)
@@ -133,8 +133,8 @@ def test_successful_refund
def test_refund_passing_extra_info
response = stub_comms do
- @gateway.refund(50, '123456789', @options.merge({:card_number => @credit_card.number, :first_name => 'Bob', :last_name => 'Smith', :zip => '12345', :doc_type => 'WEB'}))
- end.check_request do |endpoint, data, headers|
+ @gateway.refund(50, '123456789', @options.merge({ card_number: @credit_card.number, first_name: 'Bob', last_name: 'Smith', zip: '12345', doc_type: 'WEB' }))
+ end.check_request do |_endpoint, data, _headers|
assert_match(/NAME1=Bob/, data)
assert_match(/NAME2=Smith/, data)
assert_match(/ZIP=12345/, data)
@@ -147,8 +147,8 @@ def test_refund_passing_extra_info
def test_failed_refund
response = stub_comms do
- @gateway.refund(@amount, '123456789', @options.merge({:card_number => @credit_card.number}))
- end.check_request do |endpoint, data, headers|
+ @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)
@@ -161,8 +161,8 @@ 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
response = stub_comms do
- @gateway.credit(@amount, '123456789', @options.merge({:card_number => @credit_card.number}))
- end.check_request do |endpoint, data, headers|
+ @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)
@@ -174,8 +174,8 @@ def test_deprecated_credit
def test_successful_credit_with_check
response = stub_comms do
- @gateway.credit(50, @check, @options.merge({:doc_type => 'PPD'}))
- end.check_request do |endpoint, data, headers|
+ @gateway.credit(50, @check, @options.merge({ doc_type: 'PPD' }))
+ end.check_request do |_endpoint, data, _headers|
assert_match(/DOC_TYPE=PPD/, data)
end.respond_with(successful_credit_response)
@@ -183,11 +183,11 @@ def test_successful_credit_with_check
end
def test_supported_countries
- assert_equal ['US', 'CA'], BluePayGateway.supported_countries
+ assert_equal %w[US CA], BluePayGateway.supported_countries
end
def test_supported_card_types
- assert_equal [:visa, :master, :american_express, :discover, :diners_club, :jcb], BluePayGateway.supported_cardtypes
+ assert_equal %i[visa master american_express discover diners_club jcb], BluePayGateway.supported_cardtypes
end
def test_parser_extracts_exactly_the_keys_in_gateway_response
@@ -230,12 +230,11 @@ def test_successful_recurring
response = assert_deprecation_warning(Gateway::RECURRING_DEPRECATION_MESSAGE) do
@gateway.recurring(@amount, @credit_card,
- :billing_address => address.merge(:first_name => 'Jim', :last_name => 'Smith'),
- :rebill_start_date => '1 MONTH',
- :rebill_expression => '14 DAYS',
- :rebill_cycles => '24',
- :rebill_amount => @amount * 4
- )
+ billing_address: address.merge(first_name: 'Jim', last_name: 'Smith'),
+ rebill_start_date: '1 MONTH',
+ rebill_expression: '14 DAYS',
+ rebill_cycles: '24',
+ rebill_amount: @amount * 4)
end
assert_instance_of Response, response
@@ -248,7 +247,7 @@ def test_successful_update_recurring
@gateway.expects(:ssl_post).returns(successful_update_recurring_response)
response = assert_deprecation_warning(Gateway::RECURRING_DEPRECATION_MESSAGE) do
- @gateway.update_recurring(:rebill_id => @rebill_id, :rebill_amount => @amount * 2)
+ @gateway.update_recurring(rebill_id: @rebill_id, rebill_amount: @amount * 2)
end
assert_instance_of Response, response
diff --git a/test/unit/gateways/blue_snap_test.rb b/test/unit/gateways/blue_snap_test.rb
index 541cc05a65d..1ea552b79f4 100644
--- a/test/unit/gateways/blue_snap_test.rb
+++ b/test/unit/gateways/blue_snap_test.rb
@@ -2,6 +2,16 @@
require 'test_helper'
+class BlueSnapCurrencyDocMock
+ attr_accessor :received_amount
+
+ def currency(currency); end
+
+ def amount(amount)
+ @received_amount = amount
+ end
+end
+
class BlueSnapTest < Test::Unit::TestCase
include CommStub
@@ -10,6 +20,15 @@ def setup
@credit_card = credit_card
@check = check
@amount = 100
+
+ # BlueSnap may require support contact to activate fraud checking on sandbox accounts.
+ # Specific merchant-configurable thresholds were set and are reflected in the
+ # recorded responses:
+ # Order Total Amount Decline Threshold = 3728
+ # Payment Country Decline List = Brazil
+ @fraudulent_amount = 3729
+ @fraudulent_card = credit_card('4007702835532454')
+
@options = { order_id: '1', personal_identification_number: 'CNPJ' }
@options_3ds2 = @options.merge(
three_d_secure: {
@@ -30,6 +49,11 @@ def setup
},
authorized_by_shopper: true
}
+ @option_fraud_info = @options.merge(
+ transaction_fraud_info: {
+ fraud_session_id: 'fbcc094208f54c0e974d56875c73af7a'
+ }
+ )
end
def test_successful_purchase
@@ -40,6 +64,162 @@ def test_successful_purchase
assert_equal '1012082839', response.authorization
end
+ def test_successful_purchase_with_shipping_contact_info
+ more_options = @options.merge({
+ shipping_address: {
+ address1: '123 Main St',
+ adress2: 'Apt B',
+ city: 'Springfield',
+ state: 'NC',
+ country: 'US',
+ zip: '27701'
+ }
+ })
+ response = stub_comms(@gateway, :raw_ssl_request) do
+ @gateway.purchase(@amount, @credit_card, more_options)
+ end.check_request do |_method, _url, data|
+ assert_match(/shipping-contact-info/, data)
+ assert_match(/123 Main St/, data)
+ assert_match(/Springfield/, data)
+ assert_match(/NC/, data)
+ assert_match(/US/, data)
+ assert_match(/27701/, data)
+ end.respond_with(successful_purchase_response_with_metadata)
+
+ assert_success response
+ assert_equal '1012082839', response.authorization
+ end
+
+ def test_successful_purchase_with_card_holder_info
+ more_options = @options.merge({
+ billing_address: {
+ address1: '123 Street',
+ address2: 'Apt 1',
+ city: 'Happy City',
+ state: 'CA',
+ zip: '94901'
+ },
+ phone_number: '555 888 0000'
+ })
+ response = stub_comms(@gateway, :raw_ssl_request) do
+ @gateway.purchase(@amount, @credit_card, more_options)
+ end.check_request do |_method, _url, data|
+ assert_match(/card-holder-info/, data)
+ assert_match(/123 Street/, data)
+ assert_match(/Apt 1/, data)
+ assert_match(/555 888 0000/, data)
+ end.respond_with(successful_purchase_response_with_metadata)
+
+ assert_success response
+ assert_equal '1012082839', response.authorization
+ end
+
+ def test_successful_purchase_with_metadata
+ # description option should become meta-data field
+
+ more_options = @options.merge({
+ order_id: '1',
+ ip: '127.0.0.1',
+ email: 'joe@example.com',
+ transaction_meta_data: [
+ {
+ meta_key: 'stateTaxAmount',
+ meta_value: '20.00',
+ meta_description: 'State Tax Amount'
+ },
+ {
+ meta_key: 'cityTaxAmount',
+ meta_value: 10.00,
+ meta_description: 'City Tax Amount'
+ },
+ {
+ meta_key: 'websiteInfo',
+ meta_value: 'www.info.com',
+ meta_description: 'Website'
+ }
+ ],
+ description: 'Legacy Product Desc',
+ soft_descriptor: 'OnCardStatement',
+ personal_identification_number: 'CNPJ'
+ })
+
+ response = stub_comms(@gateway, :raw_ssl_request) do
+ @gateway.purchase(@amount, @credit_card, more_options)
+ end.check_request do |_method, _url, data|
+ assert_match(/transaction-meta-data/, data)
+ assert_match(/Legacy Product Desc<\/meta-value>/, data)
+ assert_match(/description<\/meta-key>/, data)
+ assert_match(/cityTaxAmount<\/meta-key>/, data)
+ assert_match(/stateTaxAmount<\/meta-key>/, data)
+ assert_match(/websiteInfo<\/meta-key>/, data)
+ end.respond_with(successful_purchase_response_with_metadata)
+
+ assert_success response
+ assert_equal '1012082839', response.authorization
+
+ assert_equal 4, response.params['transaction-meta-data'].length
+
+ response.params['transaction-meta-data'].each { |m|
+ assert_true m['meta-key'].length > 0
+ assert_true m['meta-value'].length > 0
+ assert_true m['meta-description'].length > 0
+
+ case m['meta-key']
+ when 'description'
+ assert_equal 'Product ABC', m['meta-value']
+ assert_equal 'Product Description', m['meta-description']
+ when 'cityTaxAmount'
+ assert_equal '10.00', m['meta-value']
+ assert_equal 'City Tax Amount', m['meta-description']
+ when 'stateTaxAmount'
+ assert_equal '20.00', m['meta-value']
+ assert_equal 'State Tax Amount', m['meta-description']
+ end
+ }
+ end
+
+ def test_successful_purchase_with_metadata_empty
+ more_options = @options.merge({
+ order_id: '1',
+ ip: '127.0.0.1',
+ email: 'joe@example.com',
+ transaction_meta_data: [],
+ soft_descriptor: 'OnCardStatement',
+ personal_identification_number: 'CNPJ'
+ })
+
+ response = stub_comms(@gateway, :raw_ssl_request) do
+ @gateway.purchase(@amount, @credit_card, more_options)
+ end.check_request do |_method, _url, data|
+ assert_not_match(/transaction-meta-data/, data)
+ assert_not_match(/meta-key/, data)
+ end.respond_with(successful_purchase_response)
+
+ assert_success response
+ assert_nil response.params['transaction-meta-data']
+ end
+
+ def test_successful_purchase_with_metadata_nil
+ more_options = @options.merge({
+ order_id: '1',
+ ip: '127.0.0.1',
+ email: 'joe@example.com',
+ transaction_meta_data: nil,
+ soft_descriptor: 'OnCardStatement',
+ personal_identification_number: 'CNPJ'
+ })
+
+ response = stub_comms(@gateway, :raw_ssl_request) do
+ @gateway.purchase(@amount, @credit_card, more_options)
+ end.check_request do |_method, _url, data|
+ assert_not_match(/transaction-meta-data/, data)
+ assert_not_match(/meta-key/, data)
+ end.respond_with(successful_purchase_response)
+
+ assert_success response
+ assert_nil response.params['transaction-meta-data']
+ end
+
def test_successful_purchase_with_unused_state_code
unrecognized_state_code_options = {
billing_address: {
@@ -58,6 +238,19 @@ def test_successful_purchase_with_unused_state_code
assert_not_includes(response.params, 'state')
end
+ def test_successful_purchase_with_fraud_info
+ fraud_info = @option_fraud_info.merge({ ip: '123.12.134.1' })
+ response = stub_comms(@gateway, :raw_ssl_request) do
+ @gateway.purchase(@amount, @credit_card, fraud_info)
+ end.check_request do |_method, _url, data|
+ assert_match(/fbcc094208f54c0e974d56875c73af7a<\/fraud-session-id>/, data)
+ assert_match(/123.12.134.1<\/shopper-ip-address>/, data)
+ end.respond_with(successful_purchase_response)
+
+ assert_success response
+ assert_equal '1012082839', response.authorization
+ end
+
def test_successful_echeck_purchase
@gateway.expects(:raw_ssl_request).returns(successful_echeck_purchase_response)
@@ -69,7 +262,7 @@ def test_successful_echeck_purchase
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|
+ 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)
@@ -87,7 +280,7 @@ def test_successful_purchase_with_3ds_auth
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|
+ end.check_request do |_method, _url, data|
assert_not_match(//, data)
assert_not_match(//, data)
assert_not_match(//, data)
@@ -116,7 +309,7 @@ def test_failed_echeck_purchase
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|
+ end.check_request do |_type, _endpoint, data, _headers|
assert_match 'false ', data
assert_match 'CNPJ ', data
end.respond_with(successful_authorize_response)
@@ -127,7 +320,7 @@ def test_successful_authorize
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|
+ 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)
@@ -153,7 +346,7 @@ 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|
+ 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)
@@ -165,7 +358,7 @@ def test_successful_capture
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|
+ end.check_request do |_method, _url, data|
assert_match(/1.00<\/amount>/, data)
assert_match(/USD<\/currency>/, data)
end.respond_with(successful_capture_response)
@@ -265,7 +458,7 @@ def test_failed_echeck_store
def test_currency_added_correctly
stub_comms(@gateway, :raw_ssl_request) do
@gateway.purchase(@amount, @credit_card, @options.merge(currency: 'CAD'))
- end.check_request do |method, url, data|
+ end.check_request do |_method, _url, data|
assert_match(/CAD<\/currency>/, data)
end.respond_with(successful_purchase_response)
end
@@ -291,12 +484,30 @@ def test_failed_forbidden_response
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|
+ 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_fraud_response_handling
+ @gateway.expects(:raw_ssl_request).returns(fraudulent_purchase_response)
+
+ response = @gateway.purchase(@fraudulent_amount, @credit_card, @options)
+ assert_failure response
+ assert_match(/fraud-reference-id/, response.message)
+ assert_match(/fraud-event/, response.message)
+ end
+
+ def test_fraud_response_handling_multiple_triggers
+ @gateway.expects(:raw_ssl_request).returns(fraudulent_purchase_response_multiple_triggers)
+
+ response = @gateway.purchase(@fraudulent_amount, @fraudulent_card, @options)
+ assert_failure response
+ assert_match(/orderTotalDecline/, response.message)
+ assert_match(/blacklistPaymentCountryDecline/, response.message)
+ end
+
def test_scrub
assert @gateway.supports_scrubbing?
assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed
@@ -307,8 +518,33 @@ def test_echeck_scrub
assert_equal @gateway.scrub(pre_scrubbed_echeck), post_scrubbed_echeck
end
+ def test_localizes_currencies
+ amount = 1234
+
+ # Check a 2 decimal place currency
+ assert_equal '12.34', check_amount_registered(amount, 'USD')
+
+ # Check all 0 decimal currencies
+ ActiveMerchant::Billing::BlueSnapGateway.currencies_without_fractions.each do |currency|
+ assert_equal '12', check_amount_registered(amount, currency)
+ end
+
+ # Check all 3 decimal currencies
+ ActiveMerchant::Billing::BlueSnapGateway.currencies_with_three_decimal_places.each do |currency|
+ assert_equal '1.234', check_amount_registered(amount, currency)
+ end
+ end
+
private
+ def check_amount_registered(amount, currency)
+ doc = BlueSnapCurrencyDocMock.new
+ options = @options.merge(currency: currency)
+ @gateway.send(:add_amount, doc, amount, options)
+
+ doc.received_amount
+ end
+
def pre_scrubbed
%q{
opening connection to sandbox.bluesnap.com:443...
@@ -400,6 +636,63 @@ def successful_purchase_response
XML
end
+ def successful_purchase_response_with_metadata
+ MockResponse.succeeded <<-XML
+
+
+ AUTH_CAPTURE
+ 1012082839
+ ECOMMERCE
+ BLS*Spreedly
+ 1.00
+ USD
+
+ Longbob
+ Longsen
+ CA
+ ON
+ Ottawa
+ K1C2N6
+ CNPJ
+
+
+ 9299
+ VISA
+ CREDIT
+
+
+
+ stateTaxAmount
+ 20.00
+ State Tax Amount
+
+
+ cityTaxAmount
+ 10.00
+ City Tax Amount
+
+
+ shippingAmount
+ 150.00
+ Shipping Amount
+
+
+ websiteInfo
+ www.info.com
+ Website
+
+
+
+ success
+ ND
+ U
+ U
+ U
+
+
+ XML
+ end
+
def successful_purchase_with_3ds_auth_response
MockResponse.succeeded <<-XML
@@ -938,6 +1231,55 @@ def forbidden_response
MockResponse.new(403, 'You are not authorized to perform this request due to inappropriate role permissions. ')
end
+ def fraudulent_purchase_response
+ body = <<-XML
+
+
+
+ FRAUD_DETECTED
+ 15011
+ The request cannot be fulfilled for the current shopper. Please contact BlueSnap support for further details.
+
+ 6270209
+
+ orderTotalDecline
+ D
+ 3729 > 3728
+
+
+
+
+ XML
+ MockResponse.new(400, body)
+ end
+
+ def fraudulent_purchase_response_multiple_triggers
+ body = <<-XML
+
+
+
+ FRAUD_DETECTED
+ 15011
+ The request cannot be fulfilled for the current shopper. Please contact BlueSnap support for further details.
+
+ 6270189
+
+ blacklistPaymentCountryDecline
+ D
+ BR is in list: [BR]
+
+
+ orderTotalDecline
+ D
+ 3729 > 3728
+
+
+
+
+ XML
+ MockResponse.new(400, body)
+ end
+
def credentials_are_legit_response
MockResponse.new(400, 'Server Error ')
end
diff --git a/test/unit/gateways/bogus_test.rb b/test/unit/gateways/bogus_test.rb
index e6978d828e1..4564a4d3096 100644
--- a/test/unit/gateways/bogus_test.rb
+++ b/test/unit/gateways/bogus_test.rb
@@ -8,13 +8,13 @@ class BogusTest < Test::Unit::TestCase
def setup
@gateway = BogusGateway.new(
- :login => 'bogus',
- :password => 'bogus'
+ login: 'bogus',
+ password: 'bogus'
)
@creditcard = credit_card(CC_SUCCESS_PLACEHOLDER)
- @response = ActiveMerchant::Billing::Response.new(true, 'Transaction successful', :transid => BogusGateway::AUTHORIZATION)
+ @response = ActiveMerchant::Billing::Response.new(true, 'Transaction successful', transid: BogusGateway::AUTHORIZATION)
end
def test_authorize
@@ -47,7 +47,7 @@ def test_purchase
def test_capture
assert @gateway.capture(1000, '1337').success?
assert @gateway.capture(1000, @response.params['transid']).success?
- response = @gateway.capture(1000, CC_FAILURE_PLACEHOLDER)
+ response = @gateway.capture(1000, CC_FAILURE_PLACEHOLDER)
refute response.success?
assert_equal Gateway::STANDARD_ERROR_CODE[:processing_error], response.error_code
assert_raises(ActiveMerchant::Billing::Error) do
@@ -57,7 +57,7 @@ def test_capture
def test_credit
assert @gateway.credit(1000, credit_card(CC_SUCCESS_PLACEHOLDER)).success?
- response = @gateway.credit(1000, credit_card(CC_FAILURE_PLACEHOLDER))
+ response = @gateway.credit(1000, credit_card(CC_FAILURE_PLACEHOLDER))
refute response.success?
assert_equal Gateway::STANDARD_ERROR_CODE[:processing_error], response.error_code
e = assert_raises(ActiveMerchant::Billing::Error) do
@@ -78,7 +78,7 @@ def test_refund
end
def test_credit_uses_refund
- options = {:foo => :bar}
+ options = { foo: :bar }
@gateway.expects(:refund).with(1000, '1337', options)
assert_deprecation_warning(Gateway::CREDIT_DEPRECATION_MESSAGE) do
@gateway.credit(1000, '1337', options)
@@ -125,71 +125,71 @@ def test_supported_card_types
end
def test_authorize_with_check
- assert @gateway.authorize(1000, check(:account_number => CHECK_SUCCESS_PLACEHOLDER, :number => nil)).success?
- assert !@gateway.authorize(1000, check(:account_number => CHECK_FAILURE_PLACEHOLDER, :number => nil)).success?
+ assert @gateway.authorize(1000, check(account_number: CHECK_SUCCESS_PLACEHOLDER, number: nil)).success?
+ assert !@gateway.authorize(1000, check(account_number: CHECK_FAILURE_PLACEHOLDER, number: nil)).success?
e = assert_raises(ActiveMerchant::Billing::Error) do
- @gateway.authorize(1000, check(:account_number => '123', :number => nil))
+ @gateway.authorize(1000, check(account_number: '123', number: nil))
end
assert_equal('Bogus Gateway: Use bank account number ending in 1 for success, 2 for exception and anything else for error', e.message)
end
def test_purchase_with_check
# use account number if number isn't given
- assert @gateway.purchase(1000, check(:account_number => CHECK_SUCCESS_PLACEHOLDER, :number => nil)).success?
- assert !@gateway.purchase(1000, check(:account_number => CHECK_FAILURE_PLACEHOLDER, :number => nil)).success?
+ assert @gateway.purchase(1000, check(account_number: CHECK_SUCCESS_PLACEHOLDER, number: nil)).success?
+ assert !@gateway.purchase(1000, check(account_number: CHECK_FAILURE_PLACEHOLDER, number: nil)).success?
# give priority to number over account_number if given
- assert !@gateway.purchase(1000, check(:account_number => CHECK_SUCCESS_PLACEHOLDER, :number => CHECK_FAILURE_PLACEHOLDER)).success?
- assert @gateway.purchase(1000, check(:account_number => CHECK_FAILURE_PLACEHOLDER, :number => CHECK_SUCCESS_PLACEHOLDER)).success?
+ assert !@gateway.purchase(1000, check(account_number: CHECK_SUCCESS_PLACEHOLDER, number: CHECK_FAILURE_PLACEHOLDER)).success?
+ assert @gateway.purchase(1000, check(account_number: CHECK_FAILURE_PLACEHOLDER, number: CHECK_SUCCESS_PLACEHOLDER)).success?
e = assert_raises(ActiveMerchant::Billing::Error) do
- @gateway.purchase(1000, check(:account_number => '123', :number => nil))
+ @gateway.purchase(1000, check(account_number: '123', number: nil))
end
assert_equal('Bogus Gateway: Use bank account number ending in 1 for success, 2 for exception and anything else for error', e.message)
end
def test_store_with_check
- assert @gateway.store(check(:account_number => CHECK_SUCCESS_PLACEHOLDER, :number => nil)).success?
- assert !@gateway.store(check(:account_number => CHECK_FAILURE_PLACEHOLDER, :number => nil)).success?
+ assert @gateway.store(check(account_number: CHECK_SUCCESS_PLACEHOLDER, number: nil)).success?
+ assert !@gateway.store(check(account_number: CHECK_FAILURE_PLACEHOLDER, number: nil)).success?
e = assert_raises(ActiveMerchant::Billing::Error) do
- @gateway.store(check(:account_number => '123', :number => nil))
+ @gateway.store(check(account_number: '123', number: nil))
end
assert_equal('Bogus Gateway: Use bank account number ending in 1 for success, 2 for exception and anything else for error', e.message)
end
def test_credit_with_check
- assert @gateway.credit(1000, check(:account_number => CHECK_SUCCESS_PLACEHOLDER, :number => nil)).success?
- assert !@gateway.credit(1000, check(:account_number => CHECK_FAILURE_PLACEHOLDER, :number => nil)).success?
+ assert @gateway.credit(1000, check(account_number: CHECK_SUCCESS_PLACEHOLDER, number: nil)).success?
+ assert !@gateway.credit(1000, check(account_number: CHECK_FAILURE_PLACEHOLDER, number: nil)).success?
e = assert_raises(ActiveMerchant::Billing::Error) do
- @gateway.credit(1000, check(:account_number => '123', :number => nil))
+ @gateway.credit(1000, check(account_number: '123', number: nil))
end
assert_equal('Bogus Gateway: Use bank account number ending in 1 for success, 2 for exception and anything else for error', e.message)
end
def test_store_then_purchase_with_check
- reference = @gateway.store(check(:account_number => CHECK_SUCCESS_PLACEHOLDER, :number => nil))
+ reference = @gateway.store(check(account_number: CHECK_SUCCESS_PLACEHOLDER, number: nil))
assert @gateway.purchase(1000, reference.authorization).success?
end
def test_authorize_emv
- approve_response = @gateway.authorize(1000, credit_card('123', {icc_data: 'DEADBEEF'}))
+ approve_response = @gateway.authorize(1000, credit_card('123', { icc_data: 'DEADBEEF' }))
assert approve_response.success?
assert_equal '8A023030', approve_response.emv_authorization
- decline_response = @gateway.authorize(1005, credit_card('123', {icc_data: 'DEADBEEF'}))
+ decline_response = @gateway.authorize(1005, credit_card('123', { icc_data: 'DEADBEEF' }))
refute decline_response.success?
assert_equal Gateway::STANDARD_ERROR_CODE[:processing_error], decline_response.error_code
assert_equal '8A023035', decline_response.emv_authorization
e = assert_raises(ActiveMerchant::Billing::Error) do
- @gateway.authorize(1001, credit_card('123', {icc_data: 'DEADBEEF'}))
+ @gateway.authorize(1001, credit_card('123', { icc_data: 'DEADBEEF' }))
end
assert_equal('Bogus Gateway: Use amount ending in 00 for success, 05 for failure and anything else for exception', e.message)
end
def test_purchase_emv
- assert @gateway.purchase(1000, credit_card('123', {icc_data: 'DEADBEEF'})).success?
- response = @gateway.purchase(1005, credit_card('123', {icc_data: 'DEADBEEF'}))
+ 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
e = assert_raises(ActiveMerchant::Billing::Error) do
- @gateway.purchase(1001, credit_card('123', {icc_data: 'DEADBEEF'}))
+ @gateway.purchase(1001, credit_card('123', { icc_data: 'DEADBEEF' }))
end
assert_equal('Bogus Gateway: Use amount ending in 00 for success, 05 for failure and anything else for exception', e.message)
end
diff --git a/test/unit/gateways/borgun_test.rb b/test/unit/gateways/borgun_test.rb
index bd38587664a..506b78c88cf 100644
--- a/test/unit/gateways/borgun_test.rb
+++ b/test/unit/gateways/borgun_test.rb
@@ -49,13 +49,30 @@ def test_authorize_and_capture
capture = stub_comms do
@gateway.capture(@amount, response.authorization)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/140601083732/, data)
end.respond_with(successful_capture_response)
assert_success capture
end
+ def test_authorize_airline_data
+ # itinerary data abbreviated for brevity
+ passenger_itinerary_data = {
+ 'MessageNumber' => '1111111',
+ 'TrDate' => '20120222',
+ 'TrTime' => '151515',
+ 'PassengerName' => 'Jane Doe'
+ }
+ response = stub_comms do
+ @gateway.authorize(@amount, @credit_card, { passenger_itinerary_data: passenger_itinerary_data })
+ end.check_request do |_endpoint, data, _headers|
+ assert_match('PassengerItineraryData', data)
+ end.respond_with(successful_authorize_response)
+
+ assert_success response
+ end
+
def test_refund
response = stub_comms do
@gateway.purchase(@amount, @credit_card)
@@ -66,7 +83,7 @@ def test_refund
refund = stub_comms do
@gateway.refund(@amount, response.authorization)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/140216103700/, data)
end.respond_with(successful_refund_response)
@@ -83,7 +100,7 @@ def test_void
refund = stub_comms do
@gateway.void(response.authorization)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/140216103700/, data)
end.respond_with(successful_void_response)
@@ -93,7 +110,7 @@ def test_void
def test_passing_cvv
stub_comms do
@gateway.purchase(@amount, @credit_card)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/#{@credit_card.verification_value}/, data)
end.respond_with(successful_purchase_response)
end
@@ -101,7 +118,7 @@ def test_passing_cvv
def test_passing_terminal_id
stub_comms do
@gateway.purchase(@amount, @credit_card, { terminal_id: '3' })
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/TerminalID>3/, data)
end.respond_with(successful_purchase_response)
end
diff --git a/test/unit/gateways/bpoint_test.rb b/test/unit/gateways/bpoint_test.rb
index 3ee09b8c0e1..1c156a6212e 100644
--- a/test/unit/gateways/bpoint_test.rb
+++ b/test/unit/gateways/bpoint_test.rb
@@ -88,13 +88,23 @@ def test_failed_refund
def test_successful_void
@gateway.expects(:ssl_post).returns(successful_void_response)
- response = @gateway.void(@amount, '')
+ response = @gateway.void('', amount: 300)
assert_success response
end
+ def test_void_passes_correct_transaction_reference
+ stub_comms do
+ # transaction number from successful authorize response
+ @gateway.void('219388558', amount: 300)
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(%r(219388558 )m, data)
+ assert_match(%r(300 )m, data)
+ end.respond_with(successful_void_response)
+ end
+
def test_failed_void
@gateway.expects(:ssl_post).returns(failed_void_response)
- response = @gateway.void(@amount, '')
+ response = @gateway.void('')
assert_failure response
end
@@ -125,7 +135,7 @@ def test_scrub
def test_passing_biller_code
stub_comms do
@gateway.authorize(@amount, @credit_card, { biller_code: '1234' })
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(%r(1234 )m, data)
end.respond_with(successful_authorize_response)
end
@@ -133,7 +143,7 @@ def test_passing_biller_code
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|
+ 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)
@@ -234,7 +244,7 @@ def successful_authorize_response
)
end
- alias_method :successful_verify_response, :successful_authorize_response
+ alias successful_verify_response successful_authorize_response
def failed_authorize_response
%(
@@ -261,7 +271,7 @@ def failed_authorize_response
)
end
- alias_method :failed_verify_response, :failed_authorize_response
+ alias failed_verify_response failed_authorize_response
def successful_capture_response
%(
diff --git a/test/unit/gateways/braintree_blue_test.rb b/test/unit/gateways/braintree_blue_test.rb
index 727fbd054d8..a154ab83b8d 100644
--- a/test/unit/gateways/braintree_blue_test.rb
+++ b/test/unit/gateways/braintree_blue_test.rb
@@ -5,10 +5,10 @@ def setup
@old_verbose, $VERBOSE = $VERBOSE, false
@gateway = BraintreeBlueGateway.new(
- :merchant_id => 'test',
- :public_key => 'test',
- :private_key => 'test',
- :test => true
+ merchant_id: 'test',
+ public_key: 'test',
+ private_key: 'test',
+ test: true
)
@internal_gateway = @gateway.instance_variable_get(:@braintree_gateway)
@@ -21,22 +21,22 @@ def teardown
def test_refund_legacy_method_signature
Braintree::TransactionGateway.any_instance.expects(:refund).
with('transaction_id', nil).
- returns(braintree_result(:id => 'refund_transaction_id'))
- response = @gateway.refund('transaction_id', :test => true)
+ returns(braintree_result(id: 'refund_transaction_id'))
+ response = @gateway.refund('transaction_id', test: true)
assert_equal 'refund_transaction_id', response.authorization
end
def test_refund_method_signature
Braintree::TransactionGateway.any_instance.expects(:refund).
with('transaction_id', '10.00').
- returns(braintree_result(:id => 'refund_transaction_id'))
- response = @gateway.refund(1000, 'transaction_id', :test => true)
+ returns(braintree_result(id: 'refund_transaction_id'))
+ response = @gateway.refund(1000, 'transaction_id', test: true)
assert_equal 'refund_transaction_id', response.authorization
end
def test_transaction_uses_customer_id_by_default
Braintree::TransactionGateway.any_instance.expects(:sale).
- with(has_entries(:customer_id => 'present')).
+ with(has_entries(customer_id: 'present')).
returns(braintree_result)
assert response = @gateway.purchase(10, 'present', {})
@@ -46,7 +46,7 @@ def test_transaction_uses_customer_id_by_default
def test_transaction_uses_payment_method_token_when_option
Braintree::TransactionGateway.any_instance.expects(:sale).
- with(has_entries(:payment_method_token => 'present')).
+ with(has_entries(payment_method_token: 'present')).
returns(braintree_result)
assert response = @gateway.purchase(10, 'present', { payment_method_token: true })
@@ -56,7 +56,7 @@ def test_transaction_uses_payment_method_token_when_option
def test_transaction_uses_payment_method_nonce_when_option
Braintree::TransactionGateway.any_instance.expects(:sale).
- with(has_entries(:payment_method_nonce => 'present')).
+ with(all_of(has_entries(payment_method_nonce: 'present'), has_key(:customer))).
returns(braintree_result)
assert response = @gateway.purchase(10, 'present', { payment_method_nonce: true })
@@ -86,7 +86,7 @@ def test_purchase_transaction
def test_capture_transaction
Braintree::TransactionGateway.any_instance.expects(:submit_for_settlement).
- returns(braintree_result(:id => 'capture_transaction_id'))
+ returns(braintree_result(id: 'capture_transaction_id'))
response = @gateway.capture(100, 'transaction_id')
@@ -96,7 +96,7 @@ def test_capture_transaction
def test_refund_transaction
Braintree::TransactionGateway.any_instance.expects(:refund).
- returns(braintree_result(:id => 'refund_transaction_id'))
+ returns(braintree_result(id: 'refund_transaction_id'))
response = @gateway.refund(1000, 'transaction_id')
assert_equal 'refund_transaction_id', response.authorization
@@ -106,7 +106,7 @@ def test_refund_transaction
def test_void_transaction
Braintree::TransactionGateway.any_instance.expects(:void).
with('transaction_id').
- returns(braintree_result(:id => 'void_transaction_id'))
+ returns(braintree_result(id: 'void_transaction_id'))
response = @gateway.void('transaction_id')
assert_equal 'void_transaction_id', response.authorization
@@ -133,14 +133,14 @@ def test_user_agent_includes_activemerchant_version
def test_merchant_account_id_present_when_provided_on_gateway_initialization
@gateway = BraintreeBlueGateway.new(
- :merchant_id => 'test',
- :merchant_account_id => 'present',
- :public_key => 'test',
- :private_key => 'test'
+ merchant_id: 'test',
+ merchant_account_id: 'present',
+ public_key: 'test',
+ private_key: 'test'
)
Braintree::TransactionGateway.any_instance.expects(:sale).
- with(has_entries(:merchant_account_id => 'present')).
+ with(has_entries(merchant_account_id: 'present')).
returns(braintree_result)
@gateway.authorize(100, credit_card('41111111111111111111'))
@@ -148,33 +148,33 @@ def test_merchant_account_id_present_when_provided_on_gateway_initialization
def test_merchant_account_id_on_transaction_takes_precedence
@gateway = BraintreeBlueGateway.new(
- :merchant_id => 'test',
- :merchant_account_id => 'present',
- :public_key => 'test',
- :private_key => 'test'
+ merchant_id: 'test',
+ merchant_account_id: 'present',
+ public_key: 'test',
+ private_key: 'test'
)
Braintree::TransactionGateway.any_instance.expects(:sale).
- with(has_entries(:merchant_account_id => 'account_on_transaction')).
+ with(has_entries(merchant_account_id: 'account_on_transaction')).
returns(braintree_result)
- @gateway.authorize(100, credit_card('41111111111111111111'), :merchant_account_id => 'account_on_transaction')
+ @gateway.authorize(100, credit_card('41111111111111111111'), merchant_account_id: 'account_on_transaction')
end
def test_merchant_account_id_present_when_provided
Braintree::TransactionGateway.any_instance.expects(:sale).
- with(has_entries(:merchant_account_id => 'present')).
+ with(has_entries(merchant_account_id: 'present')).
returns(braintree_result)
- @gateway.authorize(100, credit_card('41111111111111111111'), :merchant_account_id => 'present')
+ @gateway.authorize(100, credit_card('41111111111111111111'), merchant_account_id: 'present')
end
def test_service_fee_amount_can_be_specified
Braintree::TransactionGateway.any_instance.expects(:sale).
- with(has_entries(:service_fee_amount => '2.31')).
+ with(has_entries(service_fee_amount: '2.31')).
returns(braintree_result)
- @gateway.authorize(100, credit_card('41111111111111111111'), :service_fee_amount => '2.31')
+ @gateway.authorize(100, credit_card('41111111111111111111'), service_fee_amount: '2.31')
end
def test_hold_in_escrow_can_be_specified
@@ -182,7 +182,7 @@ def test_hold_in_escrow_can_be_specified
(params[:options][:hold_in_escrow] == true)
end.returns(braintree_result)
- @gateway.authorize(100, credit_card('41111111111111111111'), :hold_in_escrow => true)
+ @gateway.authorize(100, credit_card('41111111111111111111'), hold_in_escrow: true)
end
def test_merchant_account_id_absent_if_not_provided
@@ -195,61 +195,61 @@ def test_merchant_account_id_absent_if_not_provided
def test_verification_merchant_account_id_exists_when_verify_card_and_merchant_account_id
gateway = BraintreeBlueGateway.new(
- :merchant_id => 'merchant_id',
- :merchant_account_id => 'merchant_account_id',
- :public_key => 'public_key',
- :private_key => 'private_key'
+ merchant_id: 'merchant_id',
+ merchant_account_id: 'merchant_account_id',
+ public_key: 'public_key',
+ private_key: 'private_key'
)
customer = stub(
- :credit_cards => [stub_everything],
- :email => 'email',
- :phone => '321-654-0987',
- :first_name => 'John',
- :last_name => 'Smith'
+ credit_cards: [stub_everything],
+ email: 'email',
+ phone: '321-654-0987',
+ first_name: 'John',
+ last_name: 'Smith'
)
customer.stubs(:id).returns('123')
- result = Braintree::SuccessfulResult.new(:customer => customer)
+ result = Braintree::SuccessfulResult.new(customer: customer)
Braintree::CustomerGateway.any_instance.expects(:create).with do |params|
params[:credit_card][:options][:verification_merchant_account_id] == 'merchant_account_id'
end.returns(result)
- gateway.store(credit_card('41111111111111111111'), :verify_card => true)
+ gateway.store(credit_card('41111111111111111111'), verify_card: true)
end
def test_merchant_account_id_can_be_set_by_options
gateway = BraintreeBlueGateway.new(
- :merchant_id => 'merchant_id',
- :merchant_account_id => 'merchant_account_id',
- :public_key => 'public_key',
- :private_key => 'private_key'
+ merchant_id: 'merchant_id',
+ merchant_account_id: 'merchant_account_id',
+ public_key: 'public_key',
+ private_key: 'private_key'
)
customer = stub(
- :credit_cards => [stub_everything],
- :email => 'email',
- :phone => '321-654-0987',
- :first_name => 'John',
- :last_name => 'Smith'
+ credit_cards: [stub_everything],
+ email: 'email',
+ phone: '321-654-0987',
+ first_name: 'John',
+ last_name: 'Smith'
)
customer.stubs(:id).returns('123')
- result = Braintree::SuccessfulResult.new(:customer => customer)
+ result = Braintree::SuccessfulResult.new(customer: customer)
Braintree::CustomerGateway.any_instance.expects(:create).with do |params|
params[:credit_card][:options][:verification_merchant_account_id] == 'value_from_options'
end.returns(result)
- gateway.store(credit_card('41111111111111111111'), :verify_card => true, :verification_merchant_account_id => 'value_from_options')
+ gateway.store(credit_card('41111111111111111111'), verify_card: true, verification_merchant_account_id: 'value_from_options')
end
def test_store_with_verify_card_true
customer = stub(
- :credit_cards => [stub_everything],
- :email => 'email',
- :phone => '321-654-0987',
- :first_name => 'John',
- :last_name => 'Smith'
+ credit_cards: [stub_everything],
+ email: 'email',
+ phone: '321-654-0987',
+ first_name: 'John',
+ last_name: 'Smith'
)
customer.stubs(:id).returns('123')
- result = Braintree::SuccessfulResult.new(:customer => customer)
+ result = Braintree::SuccessfulResult.new(customer: customer)
Braintree::CustomerGateway.any_instance.expects(:create).with do |params|
params[:credit_card][:options].has_key?(:verify_card)
assert_equal true, params[:credit_card][:options][:verify_card]
@@ -257,171 +257,171 @@ def test_store_with_verify_card_true
params
end.returns(result)
- response = @gateway.store(credit_card('41111111111111111111'), :verify_card => true)
+ response = @gateway.store(credit_card('41111111111111111111'), verify_card: true)
assert_equal '123', response.params['customer_vault_id']
assert_equal response.params['customer_vault_id'], response.authorization
end
def test_passes_email
customer = stub(
- :credit_cards => [stub_everything],
- :email => 'bob@example.com',
- :phone => '321-654-0987',
- :first_name => 'John',
- :last_name => 'Smith',
+ credit_cards: [stub_everything],
+ email: 'bob@example.com',
+ phone: '321-654-0987',
+ first_name: 'John',
+ last_name: 'Smith',
id: '123'
)
- result = Braintree::SuccessfulResult.new(:customer => customer)
+ result = Braintree::SuccessfulResult.new(customer: customer)
Braintree::CustomerGateway.any_instance.expects(:create).with do |params|
assert_equal 'bob@example.com', params[:email]
params
end.returns(result)
- response = @gateway.store(credit_card('41111111111111111111'), :email => 'bob@example.com')
+ response = @gateway.store(credit_card('41111111111111111111'), email: 'bob@example.com')
assert_success response
end
def test_scrubs_invalid_email
customer = stub(
- :credit_cards => [stub_everything],
- :email => nil,
- :phone => '321-654-0987',
- :first_name => 'John',
- :last_name => 'Smith',
- :id => '123'
+ credit_cards: [stub_everything],
+ email: nil,
+ phone: '321-654-0987',
+ first_name: 'John',
+ last_name: 'Smith',
+ id: '123'
)
- result = Braintree::SuccessfulResult.new(:customer => customer)
+ result = Braintree::SuccessfulResult.new(customer: customer)
Braintree::CustomerGateway.any_instance.expects(:create).with do |params|
assert_equal nil, params[:email]
params
end.returns(result)
- response = @gateway.store(credit_card('41111111111111111111'), :email => 'bogus')
+ response = @gateway.store(credit_card('41111111111111111111'), email: 'bogus')
assert_success response
end
def test_store_with_verify_card_false
customer = stub(
- :credit_cards => [stub_everything],
- :email => 'email',
- :phone => '321-654-0987',
- :first_name => 'John',
- :last_name => 'Smith'
+ credit_cards: [stub_everything],
+ email: 'email',
+ phone: '321-654-0987',
+ first_name: 'John',
+ last_name: 'Smith'
)
customer.stubs(:id).returns('123')
- result = Braintree::SuccessfulResult.new(:customer => customer)
+ result = Braintree::SuccessfulResult.new(customer: customer)
Braintree::CustomerGateway.any_instance.expects(:create).with do |params|
params[:credit_card][:options].has_key?(:verify_card)
assert_equal false, params[:credit_card][:options][:verify_card]
params
end.returns(result)
- response = @gateway.store(credit_card('41111111111111111111'), :verify_card => false)
+ response = @gateway.store(credit_card('41111111111111111111'), verify_card: false)
assert_equal '123', response.params['customer_vault_id']
assert_equal response.params['customer_vault_id'], response.authorization
end
def test_store_with_billing_address_options
customer_attributes = {
- :credit_cards => [stub_everything],
- :email => 'email',
- :phone => '321-654-0987',
- :first_name => 'John',
- :last_name => 'Smith'
+ credit_cards: [stub_everything],
+ email: 'email',
+ phone: '321-654-0987',
+ first_name: 'John',
+ last_name: 'Smith'
}
billing_address = {
- :address1 => '1 E Main St',
- :address2 => 'Suite 403',
- :city => 'Chicago',
- :state => 'Illinois',
- :zip => '60622',
- :country_name => 'US'
+ address1: '1 E Main St',
+ address2: 'Suite 403',
+ city: 'Chicago',
+ state: 'Illinois',
+ zip: '60622',
+ country_name: 'US'
}
customer = stub(customer_attributes)
customer.stubs(:id).returns('123')
- result = Braintree::SuccessfulResult.new(:customer => customer)
+ result = Braintree::SuccessfulResult.new(customer: customer)
Braintree::CustomerGateway.any_instance.expects(:create).with do |params|
assert_not_nil params[:credit_card][:billing_address]
- [:street_address, :extended_address, :locality, :region, :postal_code, :country_name].each do |billing_attribute|
+ %i[street_address extended_address locality region postal_code country_name].each do |billing_attribute|
params[:credit_card][:billing_address].has_key?(billing_attribute) if params[:billing_address]
end
params
end.returns(result)
- @gateway.store(credit_card('41111111111111111111'), :billing_address => billing_address)
+ @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'
+ credit_cards: [stub_everything],
+ email: 'email',
+ first_name: 'John',
+ last_name: 'Smith',
+ phone: '123-456-7890'
}
billing_address = {
- :phone => '123-456-7890'
+ phone: '123-456-7890'
}
customer = stub(customer_attributes)
customer.stubs(:id).returns('123')
- result = Braintree::SuccessfulResult.new(:customer => customer)
+ 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)
+ @gateway.store(credit_card('41111111111111111111'), billing_address: billing_address)
end
def test_store_with_nil_billing_address_options
customer_attributes = {
- :credit_cards => [stub_everything],
- :email => 'email',
- :first_name => 'John',
- :last_name => 'Smith',
- :phone => '123-456-7890'
+ credit_cards: [stub_everything],
+ email: 'email',
+ first_name: 'John',
+ last_name: 'Smith',
+ phone: '123-456-7890'
}
billing_address = {
- :name => 'John Smith',
- :phone => '123-456-7890',
- :company => nil,
- :address1 => nil,
- :address2 => '',
- :city => nil,
- :state => nil,
- :zip => nil,
- :country_name => nil
+ name: 'John Smith',
+ phone: '123-456-7890',
+ company: nil,
+ address1: nil,
+ address2: '',
+ city: nil,
+ state: nil,
+ zip: nil,
+ country_name: nil
}
customer = stub(customer_attributes)
customer.stubs(:id).returns('123')
- result = Braintree::SuccessfulResult.new(:customer => customer)
+ 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)
+ @gateway.store(credit_card('41111111111111111111'), billing_address: billing_address)
end
def test_store_with_credit_card_token
customer = stub(
- :email => 'email',
- :phone => '321-654-0987',
- :first_name => 'John',
- :last_name => 'Smith'
+ email: 'email',
+ phone: '321-654-0987',
+ first_name: 'John',
+ last_name: 'Smith'
)
customer.stubs(:id).returns('123')
braintree_credit_card = stub_everything(token: 'cctoken')
customer.stubs(:credit_cards).returns([braintree_credit_card])
- result = Braintree::SuccessfulResult.new(:customer => customer)
+ result = Braintree::SuccessfulResult.new(customer: customer)
Braintree::CustomerGateway.any_instance.expects(:create).with do |params|
assert_equal 'cctoken', params[:credit_card][:token]
params
end.returns(result)
- response = @gateway.store(credit_card('41111111111111111111'), :credit_card_token => 'cctoken')
+ response = @gateway.store(credit_card('41111111111111111111'), credit_card_token: 'cctoken')
assert_success response
assert_equal 'cctoken', response.params['braintree_customer']['credit_cards'][0]['token']
assert_equal 'cctoken', response.params['credit_card_token']
@@ -429,15 +429,15 @@ def test_store_with_credit_card_token
def test_store_with_customer_id
customer = stub(
- :email => 'email',
- :phone => '321-654-0987',
- :first_name => 'John',
- :last_name => 'Smith',
- :credit_cards => [stub_everything]
+ email: 'email',
+ phone: '321-654-0987',
+ first_name: 'John',
+ last_name: 'Smith',
+ credit_cards: [stub_everything]
)
customer.stubs(:id).returns('customerid')
- result = Braintree::SuccessfulResult.new(:customer => customer)
+ result = Braintree::SuccessfulResult.new(customer: customer)
Braintree::CustomerGateway.any_instance.expects(:find).
with('customerid').
raises(Braintree::NotFoundError)
@@ -446,7 +446,7 @@ def test_store_with_customer_id
params
end.returns(result)
- response = @gateway.store(credit_card('41111111111111111111'), :customer => 'customerid')
+ response = @gateway.store(credit_card('41111111111111111111'), customer: 'customerid')
assert_success response
assert_equal 'customerid', response.params['braintree_customer']['id']
end
@@ -479,17 +479,17 @@ def test_store_with_existing_customer_id_and_nil_billing_address_options
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
+ 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
}
}
@@ -510,88 +510,88 @@ def test_store_with_existing_customer_id_and_nil_billing_address_options
end
def test_update_with_cvv
- stored_credit_card = mock(:token => 'token', :default? => true)
- customer = mock(:credit_cards => [stored_credit_card], :id => '123')
+ stored_credit_card = mock(token: 'token', default?: true)
+ customer = mock(credit_cards: [stored_credit_card], id: '123')
Braintree::CustomerGateway.any_instance.stubs(:find).with('vault_id').returns(customer)
BraintreeBlueGateway.any_instance.stubs(:customer_hash)
- result = Braintree::SuccessfulResult.new(:customer => customer)
+ result = Braintree::SuccessfulResult.new(customer: customer)
Braintree::CustomerGateway.any_instance.expects(:update).with do |vault, params|
assert_equal '567', params[:credit_card][:cvv]
assert_equal 'Longbob Longsen', params[:credit_card][:cardholder_name]
[vault, params]
end.returns(result)
- @gateway.update('vault_id', credit_card('41111111111111111111', :verification_value => '567'))
+ @gateway.update('vault_id', credit_card('41111111111111111111', verification_value: '567'))
end
def test_update_with_verify_card_true
- stored_credit_card = stub(:token => 'token', :default? => true)
- customer = stub(:credit_cards => [stored_credit_card], :id => '123')
+ stored_credit_card = stub(token: 'token', default?: true)
+ customer = stub(credit_cards: [stored_credit_card], id: '123')
Braintree::CustomerGateway.any_instance.stubs(:find).with('vault_id').returns(customer)
BraintreeBlueGateway.any_instance.stubs(:customer_hash)
- result = Braintree::SuccessfulResult.new(:customer => customer)
+ result = Braintree::SuccessfulResult.new(customer: customer)
Braintree::CustomerGateway.any_instance.expects(:update).with do |vault, params|
assert_equal true, params[:credit_card][:options][:verify_card]
[vault, params]
end.returns(result)
- @gateway.update('vault_id', credit_card('41111111111111111111'), :verify_card => true)
+ @gateway.update('vault_id', credit_card('41111111111111111111'), verify_card: true)
end
def test_merge_credit_card_options_ignores_bad_option
- params = {:first_name => 'John', :credit_card => {:cvv => '123'}}
- options = {:verify_card => true, :bogus => 'ignore me'}
+ params = { first_name: 'John', credit_card: { cvv: '123' } }
+ options = { verify_card: true, bogus: 'ignore me' }
merged_params = @gateway.send(:merge_credit_card_options, params, options)
- expected_params = {:first_name => 'John', :credit_card => {:cvv => '123', :options => {:verify_card => true}}}
+ expected_params = { first_name: 'John', credit_card: { cvv: '123', options: { verify_card: true } } }
assert_equal expected_params, merged_params
end
def test_merge_credit_card_options_handles_nil_credit_card
- params = {:first_name => 'John'}
- options = {:verify_card => true, :bogus => 'ignore me'}
+ params = { first_name: 'John' }
+ options = { verify_card: true, bogus: 'ignore me' }
merged_params = @gateway.send(:merge_credit_card_options, params, options)
- expected_params = {:first_name => 'John', :credit_card => {:options => {:verify_card => true}}}
+ expected_params = { first_name: 'John', credit_card: { options: { verify_card: true } } }
assert_equal expected_params, merged_params
end
def test_merge_credit_card_options_handles_billing_address
billing_address = {
- :address1 => '1 E Main St',
- :city => 'Chicago',
- :state => 'Illinois',
- :zip => '60622',
- :country => 'US'
+ address1: '1 E Main St',
+ city: 'Chicago',
+ state: 'Illinois',
+ zip: '60622',
+ country: 'US'
}
- params = {:first_name => 'John'}
- options = {:billing_address => billing_address}
+ params = { first_name: 'John' }
+ options = { billing_address: billing_address }
expected_params = {
- :first_name => 'John',
- :credit_card => {
- :billing_address => {
- :street_address => '1 E Main St',
- :extended_address => nil,
- :company => nil,
- :locality => 'Chicago',
- :region => 'Illinois',
- :postal_code => '60622',
- :country_code_alpha2 => 'US',
- :country_code_alpha3 => 'USA'
+ first_name: 'John',
+ credit_card: {
+ billing_address: {
+ street_address: '1 E Main St',
+ extended_address: nil,
+ company: nil,
+ locality: 'Chicago',
+ region: 'Illinois',
+ postal_code: '60622',
+ country_code_alpha2: 'US',
+ country_code_alpha3: 'USA'
},
- :options => {}
+ options: {}
}
}
assert_equal expected_params, @gateway.send(:merge_credit_card_options, params, options)
end
def test_merge_credit_card_options_only_includes_billing_address_when_present
- params = {:first_name => 'John'}
+ params = { first_name: 'John' }
options = {}
expected_params = {
- :first_name => 'John',
- :credit_card => {
- :options => {}
+ first_name: 'John',
+ credit_card: {
+ options: {}
}
}
assert_equal expected_params, @gateway.send(:merge_credit_card_options, params, options)
@@ -601,46 +601,46 @@ def test_address_country_handling
Braintree::TransactionGateway.any_instance.expects(:sale).with do |params|
(params[:billing][:country_code_alpha2] == 'US')
end.returns(braintree_result)
- @gateway.purchase(100, credit_card('41111111111111111111'), :billing_address => {:country => 'US'})
+ @gateway.purchase(100, credit_card('41111111111111111111'), billing_address: { country: 'US' })
Braintree::TransactionGateway.any_instance.expects(:sale).with do |params|
(params[:billing][:country_code_alpha2] == 'US')
end.returns(braintree_result)
- @gateway.purchase(100, credit_card('41111111111111111111'), :billing_address => {:country_code_alpha2 => 'US'})
+ @gateway.purchase(100, credit_card('41111111111111111111'), billing_address: { country_code_alpha2: 'US' })
Braintree::TransactionGateway.any_instance.expects(:sale).with do |params|
(params[:billing][:country_name] == 'United States of America')
end.returns(braintree_result)
- @gateway.purchase(100, credit_card('41111111111111111111'), :billing_address => {:country_name => 'United States of America'})
+ @gateway.purchase(100, credit_card('41111111111111111111'), billing_address: { country_name: 'United States of America' })
Braintree::TransactionGateway.any_instance.expects(:sale).with do |params|
(params[:billing][:country_code_alpha3] == 'USA')
end.returns(braintree_result)
- @gateway.purchase(100, credit_card('41111111111111111111'), :billing_address => {:country_code_alpha3 => 'USA'})
+ @gateway.purchase(100, credit_card('41111111111111111111'), billing_address: { country_code_alpha3: 'USA' })
Braintree::TransactionGateway.any_instance.expects(:sale).with do |params|
(params[:billing][:country_code_numeric] == 840)
end.returns(braintree_result)
- @gateway.purchase(100, credit_card('41111111111111111111'), :billing_address => {:country_code_numeric => 840})
+ @gateway.purchase(100, credit_card('41111111111111111111'), billing_address: { country_code_numeric: 840 })
end
def test_address_zip_handling
Braintree::TransactionGateway.any_instance.expects(:sale).with do |params|
(params[:billing][:postal_code] == '12345')
end.returns(braintree_result)
- @gateway.purchase(100, credit_card('41111111111111111111'), :billing_address => {:zip => '12345'})
+ @gateway.purchase(100, credit_card('41111111111111111111'), billing_address: { zip: '12345' })
Braintree::TransactionGateway.any_instance.expects(:sale).with do |params|
(params[:billing][:postal_code] == nil)
end.returns(braintree_result)
- @gateway.purchase(100, credit_card('41111111111111111111'), :billing_address => {:zip => '1234567890'})
+ @gateway.purchase(100, credit_card('41111111111111111111'), billing_address: { zip: '1234567890' })
end
def test_cardholder_name_passing_with_card
Braintree::TransactionGateway.any_instance.expects(:sale).with do |params|
(params[:credit_card][:cardholder_name] == 'Longbob Longsen')
end.returns(braintree_result)
- @gateway.purchase(100, credit_card('41111111111111111111'), :customer => {:first_name => 'Longbob', :last_name => 'Longsen'})
+ @gateway.purchase(100, credit_card('41111111111111111111'), customer: { first_name: 'Longbob', last_name: 'Longsen' })
end
def test_three_d_secure_pass_thru_handling_version_1
@@ -650,11 +650,11 @@ def test_three_d_secure_pass_thru_handling_version_1
with(has_entries(three_d_secure_pass_thru: {
cavv: 'cavv',
eci_flag: 'eci',
- xid: 'xid',
+ xid: 'xid'
})).
returns(braintree_result)
- @gateway.purchase(100, credit_card('41111111111111111111'), three_d_secure: {cavv: 'cavv', eci: 'eci', xid: 'xid'})
+ @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
@@ -672,7 +672,7 @@ def test_three_d_secure_pass_thru_handling_version_2
))).
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'})
+ @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
@@ -687,25 +687,45 @@ def test_three_d_secure_pass_thru_some_fields
))).
returns(braintree_result)
- @gateway.purchase(100, credit_card('41111111111111111111'), three_d_secure: {version: '2.0', cavv: 'cavv', eci: 'eci', ds_transaction_id: 'trans_id'})
+ @gateway.purchase(100, credit_card('41111111111111111111'), three_d_secure: { version: '2.0', cavv: 'cavv', eci: 'eci', ds_transaction_id: 'trans_id' })
+ end
+
+ def test_purchase_string_based_payment_method_nonce_removes_customer
+ Braintree::TransactionGateway.
+ any_instance.
+ expects(:sale).
+ with(Not(has_key(:customer))).
+ returns(braintree_result)
+
+ @gateway.purchase(100, credit_card('41111111111111111111'), payment_method_nonce: '1234')
+ end
+
+ def test_authorize_string_based_payment_method_nonce_removes_customer
+ Braintree::TransactionGateway.
+ any_instance.
+ expects(:sale).
+ with(Not(has_key(:customer))).
+ returns(braintree_result)
+
+ @gateway.authorize(100, credit_card('41111111111111111111'), payment_method_nonce: '1234')
end
def test_passes_recurring_flag
@gateway = BraintreeBlueGateway.new(
- :merchant_id => 'test',
- :merchant_account_id => 'present',
- :public_key => 'test',
- :private_key => 'test'
+ merchant_id: 'test',
+ merchant_account_id: 'present',
+ public_key: 'test',
+ private_key: 'test'
)
Braintree::TransactionGateway.any_instance.expects(:sale).
- with(has_entries(:recurring => true)).
+ with(has_entries(transaction_source: 'recurring')).
returns(braintree_result)
- @gateway.purchase(100, credit_card('41111111111111111111'), :recurring => true)
+ @gateway.purchase(100, credit_card('41111111111111111111'), recurring: true)
Braintree::TransactionGateway.any_instance.expects(:sale).
- with(Not(has_entries(:recurring => true))).
+ with(Not(has_entries(recurring: true))).
returns(braintree_result)
@gateway.purchase(100, credit_card('41111111111111111111'))
@@ -713,30 +733,37 @@ def test_passes_recurring_flag
def test_passes_transaction_source
Braintree::TransactionGateway.any_instance.expects(:sale).with do |params|
- (params[:transaction_source] == 'recurring')
- (params[:recurring] == nil)
+ (params[:transaction_source] == 'recurring') && (params[:recurring] == nil)
end.returns(braintree_result)
- @gateway.purchase(100, credit_card('41111111111111111111'), :transaction_source => 'recurring', :recurring => true)
+ @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'))
+ 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)
+ 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'))
+ end.returns(braintree_result(cvv_response_code: 'B'))
- response = @gateway.purchase(100, credit_card('41111111111111111111'), :skip_cvv => true)
+ response = @gateway.purchase(100, credit_card('41111111111111111111'), skip_cvv: true)
assert_equal 'B', response.cvv_result['code']
end
+ def test_successful_purchase_with_account_type
+ Braintree::TransactionGateway.any_instance.expects(:sale).with do |params|
+ params[:options][:credit_card][:account_type] == 'credit'
+ end.returns(braintree_result)
+
+ @gateway.purchase(100, credit_card('41111111111111111111'), account_type: 'credit')
+ 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
@@ -755,9 +782,9 @@ def test_default_logger_sets_warn_level_without_overwriting_global
# Re-instantiate a gateway to show it doesn't touch the global
gateway = BraintreeBlueGateway.new(
- :merchant_id => 'test',
- :public_key => 'test',
- :private_key => 'test'
+ merchant_id: 'test',
+ public_key: 'test',
+ private_key: 'test'
)
internal_gateway = gateway.instance_variable_get(:@braintree_gateway)
@@ -774,9 +801,9 @@ def test_that_setting_a_wiredump_device_on_the_gateway_sets_the_braintree_logger
assert_not_equal logger, Braintree::Configuration.logger
gateway = BraintreeBlueGateway.new(
- :merchant_id => 'test',
- :public_key => 'test',
- :private_key => 'test'
+ merchant_id: 'test',
+ public_key: 'test',
+ private_key: 'test'
)
internal_gateway = gateway.instance_variable_get(:@braintree_gateway)
@@ -790,7 +817,7 @@ def test_solution_id_is_added_to_create_transaction_parameters
ActiveMerchant::Billing::BraintreeBlueGateway.application_id = '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')
+ 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'
ensure
ActiveMerchant::Billing::BraintreeBlueGateway.application_id = nil
@@ -799,8 +826,8 @@ def test_solution_id_is_added_to_create_transaction_parameters
def test_successful_purchase_with_descriptor
Braintree::TransactionGateway.any_instance.expects(:sale).with do |params|
(params[:descriptor][:name] == 'wow*productname') &&
- (params[:descriptor][:phone] == '4443331112') &&
- (params[:descriptor][:url] == 'wow.com')
+ (params[:descriptor][:phone] == '4443331112') &&
+ (params[:descriptor][:url] == 'wow.com')
end.returns(braintree_result)
@gateway.purchase(100, credit_card('41111111111111111111'), descriptor_name: 'wow*productname', descriptor_phone: '4443331112', descriptor_url: 'wow.com')
end
@@ -808,7 +835,7 @@ def test_successful_purchase_with_descriptor
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'}}))
+ 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')
@@ -820,102 +847,137 @@ def test_successful_purchase_with_device_data
assert_equal 'kount', transaction['risk_data']['fraud_service_provider']
end
+ def test_successful_purchase_with_travel_data
+ Braintree::TransactionGateway.any_instance.expects(:sale).with do |params|
+ (params[:industry][:industry_type] == Braintree::Transaction::IndustryType::TravelAndCruise) &&
+ (params[:industry][:data][:travel_package] == 'flight') &&
+ (params[:industry][:data][:departure_date] == '2050-07-22') &&
+ (params[:industry][:data][:lodging_check_in_date] == '2050-07-22') &&
+ (params[:industry][:data][:lodging_check_out_date] == '2050-07-25') &&
+ (params[:industry][:data][:lodging_name] == 'Best Hotel Ever')
+ end.returns(braintree_result)
+
+ @gateway.purchase(100, credit_card('41111111111111111111'),
+ travel_data: {
+ travel_package: 'flight',
+ departure_date: '2050-07-22',
+ lodging_check_in_date: '2050-07-22',
+ lodging_check_out_date: '2050-07-25',
+ lodging_name: 'Best Hotel Ever'
+ })
+ end
+
+ def test_successful_purchase_with_lodging_data
+ Braintree::TransactionGateway.any_instance.expects(:sale).with do |params|
+ (params[:industry][:industry_type] == Braintree::Transaction::IndustryType::Lodging) &&
+ (params[:industry][:data][:folio_number] == 'ABC123') &&
+ (params[:industry][:data][:check_in_date] == '2050-12-22') &&
+ (params[:industry][:data][:check_out_date] == '2050-12-25') &&
+ (params[:industry][:data][:room_rate] == '80.00')
+ end.returns(braintree_result)
+
+ @gateway.purchase(100, credit_card('41111111111111111111'),
+ lodging_data: {
+ folio_number: 'ABC123',
+ check_in_date: '2050-12-22',
+ check_out_date: '2050-12-25',
+ room_rate: '80.00'
+ })
+ end
+
def test_apple_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,
- :apple_pay_card => {
- :number => '4111111111111111',
- :expiration_month => '09',
- :expiration_year => (Time.now.year + 1).to_s,
- :cardholder_name => 'Longbob Longsen',
- :cryptogram => '111111111100cryptogram',
- :eci_indicator => '05'
+ 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,
+ apple_pay_card: {
+ number: '4111111111111111',
+ expiration_month: '09',
+ expiration_year: (Time.now.year + 1).to_s,
+ cardholder_name: 'Longbob Longsen',
+ cryptogram: '111111111100cryptogram',
+ eci_indicator: '05'
}
).
- returns(braintree_result(:id => 'transaction_id'))
+ returns(braintree_result(id: 'transaction_id'))
credit_card = network_tokenization_credit_card('4111111111111111',
- :brand => 'visa',
- :transaction_id => '123',
- :eci => '05',
- :payment_cryptogram => '111111111100cryptogram'
- )
+ brand: 'visa',
+ transaction_id: '123',
+ eci: '05',
+ payment_cryptogram: '111111111100cryptogram')
- response = @gateway.authorize(100, credit_card, :test => true, :order_id => '1')
+ response = @gateway.authorize(100, credit_card, test: true, order_id: '1')
assert_equal 'transaction_id', response.authorization
end
def test_android_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'
+ 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'))
+ returns(braintree_result(id: 'transaction_id'))
credit_card = network_tokenization_credit_card('4111111111111111',
- :brand => 'visa',
- :eci => '05',
- :payment_cryptogram => '111111111100cryptogram',
- :source => :android_pay,
- :transaction_id => '1234567890'
- )
+ brand: 'visa',
+ eci: '05',
+ payment_cryptogram: '111111111100cryptogram',
+ source: :android_pay,
+ transaction_id: '1234567890')
- response = @gateway.authorize(100, credit_card, :test => true, :order_id => '1')
+ response = @gateway.authorize(100, credit_card, test: true, order_id: '1')
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'
+ 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'))
+ 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'
- )
+ brand: 'visa',
+ eci: '05',
+ payment_cryptogram: '111111111100cryptogram',
+ source: :google_pay,
+ transaction_id: '1234567890')
- response = @gateway.authorize(100, credit_card, :test => true, :order_id => '1')
+ response = @gateway.authorize(100, credit_card, test: true, order_id: '1')
assert_equal 'transaction_id', response.authorization
end
@@ -924,7 +986,7 @@ def test_supports_network_tokenization
end
def test_unsuccessful_transaction_returns_id_when_available
- Braintree::TransactionGateway.any_instance.expects(:sale).returns(braintree_error_result(transaction: {id: 'transaction_id'}))
+ Braintree::TransactionGateway.any_instance.expects(:sale).returns(braintree_error_result(transaction: { id: 'transaction_id' }))
assert response = @gateway.purchase(100, credit_card('41111111111111111111'))
refute response.success?
assert response.authorization.present?
@@ -965,177 +1027,213 @@ def test_refund_unsettled_payment_forces_void_on_full_refund
assert response.success?
end
+ def test_refund_unsettled_payment_other_error_does_not_void
+ Braintree::TransactionGateway.any_instance.
+ expects(:refund).
+ returns(braintree_error_result(message: 'Some error message'))
+
+ Braintree::TransactionGateway.any_instance.
+ expects(:void).
+ never
+
+ response = @gateway.refund(1.00, 'transaction_id', force_full_refund_if_unsettled: true)
+ refute 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 => ''
- })
+ 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)})
+ @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 => ''
- })
+ 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')})
+ @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'
- })
+ 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)})
+ @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'
- })
+ 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')})
+ @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 => ''
- })
+ 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)})
+ @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 => ''
- })
+ 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')})
+ @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'
- })
+ 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)})
+ @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'
- })
+ 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')})
+ @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 => ''
- })
+ 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)})
+ @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 => ''
- })
+ 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')})
+ @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'
- })
+ 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)})
+ @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'
- })
+ 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')})
+ @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 = {})
- Braintree::SuccessfulResult.new(:transaction => Braintree::Transaction._new(nil, {:id => 'transaction_id'}.merge(options)))
+ Braintree::SuccessfulResult.new(transaction: Braintree::Transaction._new(nil, { id: 'transaction_id' }.merge(options)))
end
def braintree_error_result(options = {})
- Braintree::ErrorResult.new(@internal_gateway, {errors: {}}.merge(options))
+ Braintree::ErrorResult.new(@internal_gateway, { errors: {} }.merge(options))
end
def with_braintree_configuration_restoration(&block)
@@ -1153,18 +1251,18 @@ def with_braintree_configuration_restoration(&block)
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',
+ 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: (Time.now.year + 1).to_s,
+ cardholder_name: 'Longbob Longsen'
}
}
end
diff --git a/test/unit/gateways/braintree_orange_test.rb b/test/unit/gateways/braintree_orange_test.rb
index ee4149137bb..49a15e4abe6 100644
--- a/test/unit/gateways/braintree_orange_test.rb
+++ b/test/unit/gateways/braintree_orange_test.rb
@@ -5,14 +5,14 @@ class BraintreeOrangeTest < Test::Unit::TestCase
def setup
@gateway = BraintreeOrangeGateway.new(
- :login => 'LOGIN',
- :password => 'PASSWORD'
+ login: 'LOGIN',
+ password: 'PASSWORD'
)
@credit_card = credit_card
@amount = 100
- @options = { :billing_address => address }
+ @options = { billing_address: address }
end
def test_successful_purchase
@@ -27,7 +27,7 @@ def test_successful_purchase
def test_fractional_amounts
response = stub_comms do
@gateway.purchase(100, @credit_card, @options.merge(currency: 'JPY'))
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
refute_match(/amount=1.00/, data)
end.respond_with(successful_purchase_response)
@@ -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,8 +86,8 @@ def test_unsuccessful_verify
def test_add_address
result = {}
- @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
+ @gateway.send(:add_address, result, { address1: '164 Waverley Street', country: 'US', state: 'CO' })
+ assert_equal %w[address1 city company country phone state zip], result.stringify_keys.keys.sort
assert_equal 'CO', result['state']
assert_equal '164 Waverley Street', result['address1']
assert_equal 'US', result['country']
@@ -96,8 +96,8 @@ def test_add_address
def test_add_shipping_address
result = {}
- @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
+ @gateway.send(:add_address, result, { address1: '164 Waverley Street', country: 'US', state: 'CO' }, 'shipping')
+ assert_equal %w[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']
assert_equal 'US', result['shipping_country']
@@ -106,8 +106,8 @@ def test_add_shipping_address
def test_adding_store_adds_vault_id_flag
result = {}
- @gateway.send(:add_creditcard, result, @credit_card, :store => true)
- assert_equal ['ccexp', 'ccnumber', 'customer_vault', 'cvv', 'firstname', 'lastname'], result.stringify_keys.keys.sort
+ @gateway.send(:add_creditcard, result, @credit_card, store: true)
+ assert_equal %w[ccexp ccnumber customer_vault cvv firstname lastname], result.stringify_keys.keys.sort
assert_equal 'add_customer', result[:customer_vault]
end
@@ -115,17 +115,17 @@ def test_blank_store_doesnt_add_vault_flag
result = {}
@gateway.send(:add_creditcard, result, @credit_card, {})
- assert_equal ['ccexp', 'ccnumber', 'cvv', 'firstname', 'lastname'], result.stringify_keys.keys.sort
+ assert_equal %w[ccexp ccnumber cvv firstname lastname], result.stringify_keys.keys.sort
assert_nil result[:customer_vault]
end
def test_accept_check
post = {}
- check = Check.new(:name => 'Fred Bloggs',
- :routing_number => '111000025',
- :account_number => '123456789012',
- :account_holder_type => 'personal',
- :account_type => 'checking')
+ check = Check.new(name: 'Fred Bloggs',
+ routing_number: '111000025',
+ account_number: '123456789012',
+ account_holder_type: 'personal',
+ account_type: 'checking')
@gateway.send(:add_check, post, check, {})
assert_equal %w[account_holder_type account_type checkaba checkaccount checkname payment], post.stringify_keys.keys.sort
end
@@ -155,7 +155,7 @@ def test_add_eci
@gateway.purchase(@amount, @credit_card, {})
@gateway.expects(:commit).with { |_, _, parameters| parameters[:billing_method] == 'recurring' }
- @gateway.purchase(@amount, @credit_card, {:eci => 'recurring'})
+ @gateway.purchase(@amount, @credit_card, { eci: 'recurring' })
end
def test_transcript_scrubbing
diff --git a/test/unit/gateways/braintree_test.rb b/test/unit/gateways/braintree_test.rb
index 7cff9f6512f..28fb1d0bc87 100644
--- a/test/unit/gateways/braintree_test.rb
+++ b/test/unit/gateways/braintree_test.rb
@@ -1,20 +1,19 @@
require 'test_helper'
class BraintreeTest < Test::Unit::TestCase
-
def test_new_with_login_password_creates_braintree_orange
gateway = BraintreeGateway.new(
- :login => 'LOGIN',
- :password => 'PASSWORD'
+ login: 'LOGIN',
+ password: 'PASSWORD'
)
assert_instance_of BraintreeOrangeGateway, gateway
end
def test_new_with_merchant_id_creates_braintree_blue
gateway = BraintreeGateway.new(
- :merchant_id => 'MERCHANT_ID',
- :public_key => 'PUBLIC_KEY',
- :private_key => 'PRIVATE_KEY'
+ merchant_id: 'MERCHANT_ID',
+ public_key: 'PUBLIC_KEY',
+ private_key: 'PRIVATE_KEY'
)
assert_instance_of BraintreeBlueGateway, gateway
end
@@ -28,7 +27,7 @@ def test_should_have_homepage_url
end
def test_should_have_supported_credit_card_types
- assert_equal [:visa, :master, :american_express, :discover, :jcb, :diners_club, :maestro], BraintreeGateway.supported_cardtypes
+ assert_equal %i[visa master american_express discover jcb diners_club maestro], BraintreeGateway.supported_cardtypes
end
def test_should_have_default_currency
diff --git a/test/unit/gateways/bridge_pay_test.rb b/test/unit/gateways/bridge_pay_test.rb
index ce60e3e05f9..dde12fc7ee8 100644
--- a/test/unit/gateways/bridge_pay_test.rb
+++ b/test/unit/gateways/bridge_pay_test.rb
@@ -63,7 +63,7 @@ def test_authorize_and_capture
capture = stub_comms do
@gateway.capture(@amount, response.authorization)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/OK2657/, data)
end.respond_with(successful_capture_response)
@@ -80,7 +80,7 @@ def test_refund
refund = stub_comms do
@gateway.refund(@amount, response.authorization)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/OK9757/, data)
end.respond_with(successful_refund_response)
@@ -97,7 +97,7 @@ def test_void
refund = stub_comms do
@gateway.void(response.authorization)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/OK9757/, data)
end.respond_with(successful_refund_response)
@@ -123,15 +123,15 @@ def test_store_and_purchase_with_token
def test_passing_cvv
stub_comms do
@gateway.purchase(@amount, @credit_card)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/#{@credit_card.verification_value}/, data)
end.respond_with(successful_purchase_response)
end
def test_passing_billing_address
stub_comms do
- @gateway.purchase(@amount, @credit_card, :billing_address => address)
- end.check_request do |endpoint, data, headers|
+ @gateway.purchase(@amount, @credit_card, billing_address: address)
+ end.check_request do |_endpoint, data, _headers|
assert_match(/Street=456\+My\+Street/, data)
assert_match(/Zip=K1C2N6/, data)
end.respond_with(successful_purchase_response)
diff --git a/test/unit/gateways/cams_test.rb b/test/unit/gateways/cams_test.rb
index 23102e41c39..fcd0a53cc54 100644
--- a/test/unit/gateways/cams_test.rb
+++ b/test/unit/gateways/cams_test.rb
@@ -7,8 +7,8 @@ def setup
password: 'password9'
)
- @credit_card = credit_card('4111111111111111', :month => 5, :year => 10)
- @bad_credit_card = credit_card('4242424245555555', :month => 5, :year => 10)
+ @credit_card = credit_card('4111111111111111', month: 5, year: 10)
+ @bad_credit_card = credit_card('4242424245555555', month: 5, year: 10)
@amount = 100
@options = {
@@ -116,46 +116,46 @@ def test_scrub
private
def pre_scrubbed
- <<-PRE_SCRUBBED
-opening connection to secure.centralams.com:443...
-opened
-starting SSL for secure.centralams.com:443...
-SSL established
-<- "POST /gw/api/transact.php 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: secure.centralams.com\r\nContent-Length: 249\r\n\r\n"
-<- "amount=1.03¤cy=USD&ccnumber=4111111111111111&ccexp=0916&firstname=Longbob&lastname=Longsen&address1=1234 My Street&address2=Apt 1&city=Ottawa&state=ON&zip=K1C2N6&country=US&phone=(555)555-5555&type=&password=password9&username=testintegrationc"
--> "HTTP/1.1 200 OK\r\n"
--> "Date: Tue, 21 Apr 2015 23:27:05 GMT\r\n"
--> "Server: Apache\r\n"
--> "Content-Length: 132\r\n"
--> "Connection: close\r\n"
--> "Content-Type: text/html; charset=UTF-8\r\n"
--> "\r\n"
-reading 132 bytes...
--> "response=1&responsetext=SUCCESS&authcode=123456&transactionid=2654605773&avsresponse=N&cvvresponse=&orderid=&type=&response_code=100"
-read 132 bytes
-Conn close
+ <<~PRE_SCRUBBED
+ opening connection to secure.centralams.com:443...
+ opened
+ starting SSL for secure.centralams.com:443...
+ SSL established
+ <- "POST /gw/api/transact.php 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: secure.centralams.com\r\nContent-Length: 249\r\n\r\n"
+ <- "amount=1.03¤cy=USD&ccnumber=4111111111111111&ccexp=0916&firstname=Longbob&lastname=Longsen&address1=1234 My Street&address2=Apt 1&city=Ottawa&state=ON&zip=K1C2N6&country=US&phone=(555)555-5555&type=&password=password9&username=testintegrationc"
+ -> "HTTP/1.1 200 OK\r\n"
+ -> "Date: Tue, 21 Apr 2015 23:27:05 GMT\r\n"
+ -> "Server: Apache\r\n"
+ -> "Content-Length: 132\r\n"
+ -> "Connection: close\r\n"
+ -> "Content-Type: text/html; charset=UTF-8\r\n"
+ -> "\r\n"
+ reading 132 bytes...
+ -> "response=1&responsetext=SUCCESS&authcode=123456&transactionid=2654605773&avsresponse=N&cvvresponse=&orderid=&type=&response_code=100"
+ read 132 bytes
+ Conn close
PRE_SCRUBBED
end
def post_scrubbed
- <<-POST_SCRUBBED
-opening connection to secure.centralams.com:443...
-opened
-starting SSL for secure.centralams.com:443...
-SSL established
-<- "POST /gw/api/transact.php 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: secure.centralams.com\r\nContent-Length: 249\r\n\r\n"
-<- "amount=1.03¤cy=USD&ccnumber=[FILTERED]&ccexp=0916&firstname=Longbob&lastname=Longsen&address1=1234 My Street&address2=Apt 1&city=Ottawa&state=ON&zip=K1C2N6&country=US&phone=(555)555-5555&type=&password=[FILTERED]&username=testintegrationc"
--> "HTTP/1.1 200 OK\r\n"
--> "Date: Tue, 21 Apr 2015 23:27:05 GMT\r\n"
--> "Server: Apache\r\n"
--> "Content-Length: 132\r\n"
--> "Connection: close\r\n"
--> "Content-Type: text/html; charset=UTF-8\r\n"
--> "\r\n"
-reading 132 bytes...
--> "response=1&responsetext=SUCCESS&authcode=123456&transactionid=2654605773&avsresponse=N&cvvresponse=&orderid=&type=&response_code=100"
-read 132 bytes
-Conn close
+ <<~POST_SCRUBBED
+ opening connection to secure.centralams.com:443...
+ opened
+ starting SSL for secure.centralams.com:443...
+ SSL established
+ <- "POST /gw/api/transact.php 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: secure.centralams.com\r\nContent-Length: 249\r\n\r\n"
+ <- "amount=1.03¤cy=USD&ccnumber=[FILTERED]&ccexp=0916&firstname=Longbob&lastname=Longsen&address1=1234 My Street&address2=Apt 1&city=Ottawa&state=ON&zip=K1C2N6&country=US&phone=(555)555-5555&type=&password=[FILTERED]&username=testintegrationc"
+ -> "HTTP/1.1 200 OK\r\n"
+ -> "Date: Tue, 21 Apr 2015 23:27:05 GMT\r\n"
+ -> "Server: Apache\r\n"
+ -> "Content-Length: 132\r\n"
+ -> "Connection: close\r\n"
+ -> "Content-Type: text/html; charset=UTF-8\r\n"
+ -> "\r\n"
+ reading 132 bytes...
+ -> "response=1&responsetext=SUCCESS&authcode=123456&transactionid=2654605773&avsresponse=N&cvvresponse=&orderid=&type=&response_code=100"
+ read 132 bytes
+ Conn close
POST_SCRUBBED
end
diff --git a/test/unit/gateways/card_connect_test.rb b/test/unit/gateways/card_connect_test.rb
index c4736f57616..44e51252403 100644
--- a/test/unit/gateways/card_connect_test.rb
+++ b/test/unit/gateways/card_connect_test.rb
@@ -16,9 +16,19 @@ def setup
}
end
- def test_incorrect_domain
+ def test_allow_domains_without_ports
+ assert CardConnectGateway.new(username: 'username', password: 'password', merchant_id: 'merchand_id', domain: 'https://vendor.cardconnect.com/test')
+ end
+
+ def test_reject_domains_without_card_connect
+ assert_raise(ArgumentError) {
+ CardConnectGateway.new(username: 'username', password: 'password', merchant_id: 'merchand_id', domain: 'https://www.google.com')
+ }
+ end
+
+ def test_reject_domains_without_https
assert_raise(ArgumentError) {
- CardConnectGateway.new(username: 'username', password: 'password', merchant_id: 'merchand_id', domain: 'www.google.com')
+ CardConnectGateway.new(username: 'username', password: 'password', merchant_id: 'merchand_id', domain: 'ttps://cardconnect.com')
}
end
@@ -185,7 +195,7 @@ def test_failed_store
def test_successful_unstore
stub_comms(@gateway, :ssl_request) do
@gateway.unstore('1|16700875781344019340')
- end.check_request do |verb, url, data, headers|
+ end.check_request do |verb, url, _data, _headers|
assert_equal :delete, verb
assert_match %r{16700875781344019340/1}, url
end.respond_with(successful_unstore_response)
diff --git a/test/unit/gateways/card_save_test.rb b/test/unit/gateways/card_save_test.rb
index bb19495a1f1..6689ca22eef 100644
--- a/test/unit/gateways/card_save_test.rb
+++ b/test/unit/gateways/card_save_test.rb
@@ -3,10 +3,10 @@
class CardSaveTest < Test::Unit::TestCase
def setup
Base.mode = :test
- @gateway = CardSaveGateway.new(:login => 'login', :password => 'password')
+ @gateway = CardSaveGateway.new(login: 'login', password: 'password')
@credit_card = credit_card
@amount = 100
- @options = {:order_id =>'1', :billing_address => address, :description =>'Store Purchase'}
+ @options = { order_id: '1', billing_address: address, description: 'Store Purchase' }
end
def test_successful_purchase
@@ -273,5 +273,4 @@ def failed_refund
)
end
-
end
diff --git a/test/unit/gateways/card_stream_test.rb b/test/unit/gateways/card_stream_test.rb
index 917397db76b..97232894cbb 100644
--- a/test/unit/gateways/card_stream_test.rb
+++ b/test/unit/gateways/card_stream_test.rb
@@ -5,45 +5,49 @@ class CardStreamTest < Test::Unit::TestCase
def setup
@gateway = CardStreamGateway.new(
- :login => 'login',
- :shared_secret => 'secret'
+ login: 'login',
+ shared_secret: 'secret'
)
@visacreditcard = credit_card('4929421234600821',
- :month => '12',
- :year => '2014',
- :verification_value => '356',
- :brand => :visa
- )
+ month: '12',
+ year: '2014',
+ verification_value: '356',
+ brand: :visa)
@visacredit_options = {
- :billing_address => {
- :address1 => 'Flat 6, Primrose Rise',
- :address2 => '347 Lavender Road',
- :city => '',
- :state => 'Northampton',
- :zip => 'NN17 8YG '
+ billing_address: {
+ address1: 'Flat 6, Primrose Rise',
+ address2: '347 Lavender Road',
+ city: '',
+ state: 'Northampton',
+ zip: 'NN17 8YG '
},
- :order_id => generate_unique_id,
- :description => 'AM test purchase'
+ order_id: generate_unique_id,
+ description: 'AM test purchase'
}
@visacredit_descriptor_options = {
- :billing_address => {
- :address1 => 'Flat 6, Primrose Rise',
- :address2 => '347 Lavender Road',
- :city => '',
- :state => 'Northampton',
- :zip => 'NN17 8YG '
+ billing_address: {
+ address1: 'Flat 6, Primrose Rise',
+ address2: '347 Lavender Road',
+ city: '',
+ state: 'Northampton',
+ zip: 'NN17 8YG '
},
- :merchant_name => 'merchant',
- :dynamic_descriptor => 'product'
+ merchant_name: 'merchant',
+ dynamic_descriptor: 'product'
}
+ @amex = credit_card('374245455400001',
+ month: '12',
+ year: 2014,
+ verification_value: '4887',
+ brand: :american_express)
+
@declined_card = credit_card('4000300011112220',
- :month => '9',
- :year => '2014'
- )
+ month: '9',
+ year: '2014')
end
def test_successful_visacreditcard_authorization
@@ -130,7 +134,7 @@ def test_successful_visacreditcard_purchase
def test_successful_visacreditcard_purchase_with_descriptors
stub_comms do
@gateway.purchase(284, @visacreditcard, @visacredit_descriptor_options)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/statementNarrative1=merchant/, data)
assert_match(/statementNarrative2=product/, data)
end.respond_with(successful_purchase_response_with_descriptors)
@@ -139,7 +143,7 @@ def test_successful_visacreditcard_purchase_with_descriptors
def test_successful_visacreditcard_purchase_with_default_ip
stub_comms do
@gateway.purchase(284, @visacreditcard, @visacredit_options)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/remoteAddress=1\.1\.1\.1/, data)
end.respond_with(successful_purchase_response_with_descriptors)
end
@@ -147,7 +151,7 @@ def test_successful_visacreditcard_purchase_with_default_ip
def test_successful_visacreditcard_purchase_with_default_country
stub_comms do
@gateway.purchase(284, @visacreditcard, @visacredit_options.delete(:billing_address))
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/customerCountryCode=GB/, data)
end.respond_with(successful_purchase_response)
end
@@ -179,6 +183,14 @@ def test_declined_mastercard_purchase
assert response.test?
end
+ def test_successful_amex_purchase_with_localized_invoice_amount
+ stub_comms do
+ @gateway.purchase(28400, @amex, @visacredit_descriptor_options.merge(currency: 'JPY', order_id: '1234567890'))
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(/item1GrossValue=284&/, data)
+ end.respond_with(successful_purchase_response)
+ end
+
def test_successful_verify
response = stub_comms do
@gateway.verify(@visacreditcard, @visacredit_options)
@@ -199,7 +211,7 @@ def test_purchase_options
# Default
purchase = stub_comms do
@gateway.purchase(142, @visacreditcard, @visacredit_options)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/type=1/, data)
end.respond_with(successful_purchase_response)
@@ -207,7 +219,7 @@ def test_purchase_options
purchase = stub_comms do
@gateway.purchase(142, @visacreditcard, @visacredit_options.merge(type: 2))
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/type=2/, data)
end.respond_with(successful_purchase_response)
@@ -215,7 +227,7 @@ def test_purchase_options
purchase = stub_comms do
@gateway.purchase(142, @visacreditcard, @visacredit_options.merge(currency: 'PEN'))
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/currencyCode=604/, data)
end.respond_with(successful_purchase_response)
@@ -224,7 +236,7 @@ def test_purchase_options
def test_successful_purchase_without_street_address
@gateway.expects(:ssl_post).returns(successful_purchase_response)
- assert response = @gateway.purchase(142, @visacreditcard, billing_address: {state: 'Northampton'})
+ assert response = @gateway.purchase(142, @visacreditcard, billing_address: { state: 'Northampton' })
assert_equal 'APPROVED', response.message
end
@@ -238,17 +250,25 @@ def test_hmac_signature_added_to_post
post_params = "action=SALE&amount=10000&captureDelay=0&cardCVV=356&cardExpiryMonth=12&cardExpiryYear=14&cardNumber=4929421234600821&countryCode=GB¤cyCode=826&customerAddress=Flat+6%2C+Primrose+Rise+347+Lavender+Road&customerCountryCode=GB&customerName=Longbob+Longsen&customerPostCode=NN17+8YG+&merchantID=login&orderRef=AM+test+purchase&remoteAddress=1.1.1.1&threeDSRequired=N&transactionUnique=#{@visacredit_options[:order_id]}&type=1"
expected_signature = Digest::SHA512.hexdigest("#{post_params}#{@gateway.options[:shared_secret]}")
- @gateway.expects(:ssl_post).with do |url, data|
+ @gateway.expects(:ssl_post).with do |_url, data|
data.include?("signature=#{expected_signature}")
end.returns(successful_authorization_response)
@gateway.purchase(10000, @visacreditcard, @visacredit_options)
end
+ def test_nonfractional_currency_handling
+ stub_comms do
+ @gateway.authorize(200, @visacreditcard, @visacredit_options.merge(currency: 'JPY'))
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(/amount=2¤cyCode=392/, data)
+ end.respond_with(successful_authorization_response)
+ end
+
def test_3ds_response
purchase = stub_comms do
@gateway.purchase(142, @visacreditcard, @visacredit_options.merge(threeds_required: true))
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/threeDSRequired=Y/, data)
end.respond_with(successful_purchase_response_with_3dsecure)
@@ -261,14 +281,14 @@ def test_3ds_response
def test_deprecated_3ds_required
assert_deprecation_warning(CardStreamGateway::THREEDSECURE_REQUIRED_DEPRECATION_MESSAGE) do
@gateway = CardStreamGateway.new(
- :login => 'login',
- :shared_secret => 'secret',
- :threeDSRequired => true
+ login: 'login',
+ shared_secret: 'secret',
+ threeDSRequired: true
)
end
stub_comms do
@gateway.purchase(142, @visacreditcard, @visacredit_options)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/threeDSRequired=Y/, data)
end.respond_with(successful_purchase_response)
end
@@ -276,7 +296,7 @@ def test_deprecated_3ds_required
def test_default_3dsecure_required
stub_comms do
@gateway.purchase(142, @visacreditcard, @visacredit_options)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/threeDSRequired=N/, data)
end.respond_with(successful_purchase_response)
end
@@ -340,16 +360,16 @@ def failed_reference_purchase_response
end
def transcript
- <<-eos
+ <<-REQUEST
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=4929421234600821&cardExpiryMonth=12&cardExpiryYear=14&cardCVV=356&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
+ REQUEST
end
def scrubbed_transcript
- <<-eos
+ <<-REQUEST
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
+ REQUEST
end
end
diff --git a/test/unit/gateways/cardknox_test.rb b/test/unit/gateways/cardknox_test.rb
index bc10d5e0e70..11e05970f77 100644
--- a/test/unit/gateways/cardknox_test.rb
+++ b/test/unit/gateways/cardknox_test.rb
@@ -16,7 +16,7 @@ def setup
def test_successful_purchase_passing_extra_info
response = stub_comms do
@gateway.purchase(@amount, @credit_card, @options.merge(order_id: '1337', description: 'socool'))
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/xOrderID=1337/, data)
assert_match(/xDescription=socool/, data)
end.respond_with(successful_purchase_response)
@@ -66,7 +66,7 @@ def test_manual_entry_is_properly_indicated_on_purchase
@credit_card.manual_entry = true
response = stub_comms do
@gateway.purchase(@amount, @credit_card, @options)
- end.check_request do |endpoint, data, headers|
+ 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)
@@ -75,7 +75,7 @@ def test_manual_entry_is_properly_indicated_on_purchase
end
def test_ip_is_being_sent # failed
- @gateway.expects(:ssl_post).with do |url, data|
+ @gateway.expects(:ssl_post).with do |_url, data|
data =~ /xIP=123.123.123.123/
end.returns(successful_purchase_response)
@@ -131,7 +131,7 @@ def test_successful_capture
def test_failed_capture
@gateway.expects(:ssl_post).returns(failed_capture_response)
- assert capture = @gateway.capture(@amount-1, '')
+ assert capture = @gateway.capture(@amount - 1, '')
assert_failure capture
assert_equal 'Original transaction not specified', capture.message
end
diff --git a/test/unit/gateways/cardprocess_test.rb b/test/unit/gateways/cardprocess_test.rb
index 5377cd16c73..97e8061f2ff 100644
--- a/test/unit/gateways/cardprocess_test.rb
+++ b/test/unit/gateways/cardprocess_test.rb
@@ -167,7 +167,7 @@ def test_error_code_parsing
'800.800.202' => :invalid_zip
}
codes.each_pair do |code, key|
- response = {'result' => {'code' => code}}
+ response = { 'result' => { 'code' => code } }
assert_equal Gateway::STANDARD_ERROR_CODE[key], @gateway.send(:error_code_from, response), "expecting #{code} => #{key}"
end
end
diff --git a/test/unit/gateways/cashnet_test.rb b/test/unit/gateways/cashnet_test.rb
index 7ac004c8b0b..d9f3c0c2d29 100644
--- a/test/unit/gateways/cashnet_test.rb
+++ b/test/unit/gateways/cashnet_test.rb
@@ -55,7 +55,7 @@ def test_supported_countries
end
def test_supported_card_types
- assert_equal [:visa, :master, :american_express, :discover, :diners_club, :jcb], CashnetGateway.supported_cardtypes
+ assert_equal %i[visa master american_express discover diners_club jcb], CashnetGateway.supported_cardtypes
end
def test_add_invoice
@@ -76,9 +76,9 @@ 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 %w[addr_g city_g state_g zip_g], result.stringify_keys.keys.sort
assert_equal '123 Test St.,5F', result[:addr_g]
assert_equal 'Testville', result[:city_g]
assert_equal 'AK', result[:state_g]
@@ -93,7 +93,7 @@ def test_add_customer_data
def test_action_meets_minimum_requirements
params = {
- amount: '1.01',
+ amount: '1.01'
}
@gateway.send(:add_creditcard, params, @credit_card)
@@ -108,7 +108,7 @@ def test_action_meets_minimum_requirements
def test_successful_purchase_with_fname_and_lname
stub_comms(@gateway, :ssl_request) do
@gateway.purchase(@amount, @credit_card, {})
- end.check_request do |method, endpoint, data, headers|
+ end.check_request do |_method, _endpoint, data, _headers|
assert_match(/fname=Longbob/, data)
assert_match(/lname=Longsen/, data)
end.respond_with(successful_purchase_response)
@@ -127,7 +127,7 @@ def test_passes_custcode_from_credentials
gateway = CashnetGateway.new(merchant: 'X', operator: 'X', password: 'test123', merchant_gateway_name: 'X', custcode: 'TheCustCode')
stub_comms(gateway, :ssl_request) do
gateway.purchase(@amount, @credit_card, {})
- end.check_request do |method, endpoint, data, headers|
+ end.check_request do |_method, _endpoint, data, _headers|
assert_match(/custcode=TheCustCode/, data)
end.respond_with(successful_purchase_response)
end
@@ -136,7 +136,7 @@ def test_allows_custcode_override
gateway = CashnetGateway.new(merchant: 'X', operator: 'X', password: 'test123', merchant_gateway_name: 'X', custcode: 'TheCustCode')
stub_comms(gateway, :ssl_request) do
gateway.purchase(@amount, @credit_card, custcode: 'OveriddenCustCode')
- end.check_request do |method, endpoint, data, headers|
+ end.check_request do |_method, _endpoint, data, _headers|
assert_match(/custcode=OveriddenCustCode/, data)
end.respond_with(successful_purchase_response)
end
@@ -177,128 +177,128 @@ def invalid_response
end
def pre_scrubbed
- <<-TRANSCRIPT
-opening connection to train.cashnet.com:443...
-opened
-starting SSL for train.cashnet.com:443...
-SSL established
-<- "POST /givecorpsgateway 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: train.cashnet.com\r\nContent-Length: 364\r\n\r\n"
-<- "command=SALE&merchant=GiveCorpGW&operator=givecorp&password=14givecorps&station=WEB&custcode=ActiveMerchant%2F1.76.0&cardno=5454545454545454&cid=123&expdate=1215&card_name_g=Longbob+Longsen&fname=Longbob&lname=Longsen&order_number=c440ec8493f215d21c8a993ceae30129&itemcode=FEE&addr_g=456+My+Street%2CApt+1&city_g=Ottawa&state_g=ON&zip_g=K1C2N6&email_g=&amount=1.00"
--> "HTTP/1.1 302 Found\r\n"
--> "Date: Wed, 03 Jan 2018 17:03:35 GMT\r\n"
--> "Content-Type: text/html; charset=utf-8\r\n"
--> "Transfer-Encoding: chunked\r\n"
--> "Connection: close\r\n"
--> "Set-Cookie: AWSALB=5ISjTg8Mez7jS1kEnzY4j5NkQ5bdlwDDNmfzTyEMBmILpb0Tn3k58pUQTGHBj3NUpciP0uqQs7FaAb42YZvt35ndLERGJA0dPQ03iCfrqbneQ+Wm5BhDzMGo5GUT; Expires=Wed, 10 Jan 2018 17:03:35 GMT; Path=/\r\n"
--> "Set-Cookie: AWSALB=bVhwwfJ2D6cI5zB3eapqNStEzF5yX1pXhaJGUBUCa+DZhEgn/TZGxznxIOYB9qKqzkPF4lq/zxWg/tuMBTiY4JGLRjayyhizvHnj2smrnNvr2DLQN7ZjLSh51BzM; Expires=Wed, 10 Jan 2018 17:03:35 GMT; Path=/\r\n"
--> "Cache-Control: private\r\n"
--> "Location: https://train.cashnet.com/cashneti/Gateway/htmlgw.aspx?client=EMARKETVENDOR_DEMO&command=SALE&merchant=GiveCorpGW&operator=givecorp&password=14givecorps&station=WEB&custcode=ActiveMerchant%2f1.76.0&cardno=5454545454545454&cid=123&expdate=1215&card_name_g=Longbob+Longsen&fname=Longbob&lname=Longsen&order_number=c440ec8493f215d21c8a993ceae30129&itemcode=FEE&addr_g=456+My+Street%2cApt+1&city_g=Ottawa&state_g=ON&zip_g=K1C2N6&email_g=&amount=1.00\r\n"
--> "Set-Cookie: ASP.NET_SessionId=; path=/; HttpOnly\r\n"
--> "P3P: CP=\"NOI DSP COR NID NOR\"\r\n"
--> "Set-Cookie: BNI_persistence=0000000000000000000000004d79da0a00005000; Path=/\r\n"
--> "Strict-Transport-Security: max-age=31536000\r\n"
--> "\r\n"
--> "282\r\n"
-reading 642 bytes...
--> "Object moved \r\nObject moved to here . \r\n\r\n"
-read 642 bytes
-reading 2 bytes...
--> "\r\n"
-read 2 bytes
--> "0\r\n"
--> "\r\n"
-Conn close
-opening connection to train.cashnet.com:443...
-opened
-starting SSL for train.cashnet.com:443...
-SSL established
-<- "GET /cashneti/Gateway/htmlgw.aspx?client=EMARKETVENDOR_DEMO&command=SALE&merchant=GiveCorpGW&operator=givecorp&password=14givecorps&station=WEB&custcode=ActiveMerchant%2f1.76.0&cardno=5454545454545454&cid=123&expdate=1215&card_name_g=Longbob+Longsen&fname=Longbob&lname=Longsen&order_number=c440ec8493f215d21c8a993ceae30129&itemcode=FEE&addr_g=456+My+Street%2cApt+1&city_g=Ottawa&state_g=ON&zip_g=K1C2N6&email_g=&amount=1.00 HTTP/1.1\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: train.cashnet.com\r\n\r\n"
--> "HTTP/1.1 200 OK\r\n"
--> "Date: Wed, 03 Jan 2018 17:03:35 GMT\r\n"
--> "Content-Type: text/html; charset=utf-8\r\n"
--> "Transfer-Encoding: chunked\r\n"
--> "Connection: close\r\n"
--> "Set-Cookie: AWSALB=lFPwFYRnXJHRNmE6NCRAIfHtQadwx4bYJoT5xeAL5AuAXPcm1vYWx5F/s5FBr3GcungifktpWlwIgAmWS29K7YRXTCjk4xmcAnhXS86fpVUVQt4ECwPH2xdv8tf2; Expires=Wed, 10 Jan 2018 17:03:35 GMT; Path=/\r\n"
--> "Set-Cookie: AWSALB=mEfysFNBclo1/9+tTuI/XtHrmVkD89Fh6tAJ3Gl0u2EuLCYTW5VwEq+fVqYG1fEkN02dbhKSkIdM22QvyT6cRccDaUBsYAnOKjg2JlVShJlf+li5tfbrsUDk14jG; Expires=Wed, 10 Jan 2018 17:03:35 GMT; Path=/\r\n"
--> "Cache-Control: private\r\n"
--> "Set-Cookie: ASP.NET_SessionId=3ocslggtk4cdz54unbdnm25o; path=/; HttpOnly\r\n"
--> "P3P: CP=\"NOI DSP COR NID NOR\"\r\n"
--> "Set-Cookie: BNI_persistence=0000000000000000000000004d79da0a00005000; Path=/\r\n"
--> "Strict-Transport-Security: max-age=31536000\r\n"
--> "\r\n"
--> "3a\r\n"
-reading 58 bytes...
--> "result=0&tx=77972&busdate=7/25/2017 "
-read 58 bytes
-reading 2 bytes...
--> "\r\n"
-read 2 bytes
--> "0\r\n"
--> "\r\n"
-Conn close
+ <<~TRANSCRIPT
+ opening connection to train.cashnet.com:443...
+ opened
+ starting SSL for train.cashnet.com:443...
+ SSL established
+ <- "POST /givecorpsgateway 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: train.cashnet.com\r\nContent-Length: 364\r\n\r\n"
+ <- "command=SALE&merchant=GiveCorpGW&operator=givecorp&password=14givecorps&station=WEB&custcode=ActiveMerchant%2F1.76.0&cardno=5454545454545454&cid=123&expdate=1215&card_name_g=Longbob+Longsen&fname=Longbob&lname=Longsen&order_number=c440ec8493f215d21c8a993ceae30129&itemcode=FEE&addr_g=456+My+Street%2CApt+1&city_g=Ottawa&state_g=ON&zip_g=K1C2N6&email_g=&amount=1.00"
+ -> "HTTP/1.1 302 Found\r\n"
+ -> "Date: Wed, 03 Jan 2018 17:03:35 GMT\r\n"
+ -> "Content-Type: text/html; charset=utf-8\r\n"
+ -> "Transfer-Encoding: chunked\r\n"
+ -> "Connection: close\r\n"
+ -> "Set-Cookie: AWSALB=5ISjTg8Mez7jS1kEnzY4j5NkQ5bdlwDDNmfzTyEMBmILpb0Tn3k58pUQTGHBj3NUpciP0uqQs7FaAb42YZvt35ndLERGJA0dPQ03iCfrqbneQ+Wm5BhDzMGo5GUT; Expires=Wed, 10 Jan 2018 17:03:35 GMT; Path=/\r\n"
+ -> "Set-Cookie: AWSALB=bVhwwfJ2D6cI5zB3eapqNStEzF5yX1pXhaJGUBUCa+DZhEgn/TZGxznxIOYB9qKqzkPF4lq/zxWg/tuMBTiY4JGLRjayyhizvHnj2smrnNvr2DLQN7ZjLSh51BzM; Expires=Wed, 10 Jan 2018 17:03:35 GMT; Path=/\r\n"
+ -> "Cache-Control: private\r\n"
+ -> "Location: https://train.cashnet.com/cashneti/Gateway/htmlgw.aspx?client=EMARKETVENDOR_DEMO&command=SALE&merchant=GiveCorpGW&operator=givecorp&password=14givecorps&station=WEB&custcode=ActiveMerchant%2f1.76.0&cardno=5454545454545454&cid=123&expdate=1215&card_name_g=Longbob+Longsen&fname=Longbob&lname=Longsen&order_number=c440ec8493f215d21c8a993ceae30129&itemcode=FEE&addr_g=456+My+Street%2cApt+1&city_g=Ottawa&state_g=ON&zip_g=K1C2N6&email_g=&amount=1.00\r\n"
+ -> "Set-Cookie: ASP.NET_SessionId=; path=/; HttpOnly\r\n"
+ -> "P3P: CP=\"NOI DSP COR NID NOR\"\r\n"
+ -> "Set-Cookie: BNI_persistence=0000000000000000000000004d79da0a00005000; Path=/\r\n"
+ -> "Strict-Transport-Security: max-age=31536000\r\n"
+ -> "\r\n"
+ -> "282\r\n"
+ reading 642 bytes...
+ -> "Object moved \r\nObject moved to here . \r\n\r\n"
+ read 642 bytes
+ reading 2 bytes...
+ -> "\r\n"
+ read 2 bytes
+ -> "0\r\n"
+ -> "\r\n"
+ Conn close
+ opening connection to train.cashnet.com:443...
+ opened
+ starting SSL for train.cashnet.com:443...
+ SSL established
+ <- "GET /cashneti/Gateway/htmlgw.aspx?client=EMARKETVENDOR_DEMO&command=SALE&merchant=GiveCorpGW&operator=givecorp&password=14givecorps&station=WEB&custcode=ActiveMerchant%2f1.76.0&cardno=5454545454545454&cid=123&expdate=1215&card_name_g=Longbob+Longsen&fname=Longbob&lname=Longsen&order_number=c440ec8493f215d21c8a993ceae30129&itemcode=FEE&addr_g=456+My+Street%2cApt+1&city_g=Ottawa&state_g=ON&zip_g=K1C2N6&email_g=&amount=1.00 HTTP/1.1\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: train.cashnet.com\r\n\r\n"
+ -> "HTTP/1.1 200 OK\r\n"
+ -> "Date: Wed, 03 Jan 2018 17:03:35 GMT\r\n"
+ -> "Content-Type: text/html; charset=utf-8\r\n"
+ -> "Transfer-Encoding: chunked\r\n"
+ -> "Connection: close\r\n"
+ -> "Set-Cookie: AWSALB=lFPwFYRnXJHRNmE6NCRAIfHtQadwx4bYJoT5xeAL5AuAXPcm1vYWx5F/s5FBr3GcungifktpWlwIgAmWS29K7YRXTCjk4xmcAnhXS86fpVUVQt4ECwPH2xdv8tf2; Expires=Wed, 10 Jan 2018 17:03:35 GMT; Path=/\r\n"
+ -> "Set-Cookie: AWSALB=mEfysFNBclo1/9+tTuI/XtHrmVkD89Fh6tAJ3Gl0u2EuLCYTW5VwEq+fVqYG1fEkN02dbhKSkIdM22QvyT6cRccDaUBsYAnOKjg2JlVShJlf+li5tfbrsUDk14jG; Expires=Wed, 10 Jan 2018 17:03:35 GMT; Path=/\r\n"
+ -> "Cache-Control: private\r\n"
+ -> "Set-Cookie: ASP.NET_SessionId=3ocslggtk4cdz54unbdnm25o; path=/; HttpOnly\r\n"
+ -> "P3P: CP=\"NOI DSP COR NID NOR\"\r\n"
+ -> "Set-Cookie: BNI_persistence=0000000000000000000000004d79da0a00005000; Path=/\r\n"
+ -> "Strict-Transport-Security: max-age=31536000\r\n"
+ -> "\r\n"
+ -> "3a\r\n"
+ reading 58 bytes...
+ -> "result=0&tx=77972&busdate=7/25/2017 "
+ read 58 bytes
+ reading 2 bytes...
+ -> "\r\n"
+ read 2 bytes
+ -> "0\r\n"
+ -> "\r\n"
+ Conn close
TRANSCRIPT
end
def post_scrubbed
- <<-SCRUBBED
-opening connection to train.cashnet.com:443...
-opened
-starting SSL for train.cashnet.com:443...
-SSL established
-<- "POST /givecorpsgateway 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: train.cashnet.com\r\nContent-Length: 364\r\n\r\n"
-<- "command=SALE&merchant=GiveCorpGW&operator=givecorp&password=[FILTERED]&station=WEB&custcode=ActiveMerchant%2F1.76.0&cardno=[FILTERED]&cid=[FILTERED]&expdate=1215&card_name_g=Longbob+Longsen&fname=Longbob&lname=Longsen&order_number=c440ec8493f215d21c8a993ceae30129&itemcode=FEE&addr_g=456+My+Street%2CApt+1&city_g=Ottawa&state_g=ON&zip_g=K1C2N6&email_g=&amount=1.00"
--> "HTTP/1.1 302 Found\r\n"
--> "Date: Wed, 03 Jan 2018 17:03:35 GMT\r\n"
--> "Content-Type: text/html; charset=utf-8\r\n"
--> "Transfer-Encoding: chunked\r\n"
--> "Connection: close\r\n"
--> "Set-Cookie: AWSALB=5ISjTg8Mez7jS1kEnzY4j5NkQ5bdlwDDNmfzTyEMBmILpb0Tn3k58pUQTGHBj3NUpciP0uqQs7FaAb42YZvt35ndLERGJA0dPQ03iCfrqbneQ+Wm5BhDzMGo5GUT; Expires=Wed, 10 Jan 2018 17:03:35 GMT; Path=/\r\n"
--> "Set-Cookie: AWSALB=bVhwwfJ2D6cI5zB3eapqNStEzF5yX1pXhaJGUBUCa+DZhEgn/TZGxznxIOYB9qKqzkPF4lq/zxWg/tuMBTiY4JGLRjayyhizvHnj2smrnNvr2DLQN7ZjLSh51BzM; Expires=Wed, 10 Jan 2018 17:03:35 GMT; Path=/\r\n"
--> "Cache-Control: private\r\n"
--> "Location: https://train.cashnet.com/cashneti/Gateway/htmlgw.aspx?client=EMARKETVENDOR_DEMO&command=SALE&merchant=GiveCorpGW&operator=givecorp&password=[FILTERED]&station=WEB&custcode=ActiveMerchant%2f1.76.0&cardno=[FILTERED]&cid=[FILTERED]&expdate=1215&card_name_g=Longbob+Longsen&fname=Longbob&lname=Longsen&order_number=c440ec8493f215d21c8a993ceae30129&itemcode=FEE&addr_g=456+My+Street%2cApt+1&city_g=Ottawa&state_g=ON&zip_g=K1C2N6&email_g=&amount=1.00\r\n"
--> "Set-Cookie: ASP.NET_SessionId=; path=/; HttpOnly\r\n"
--> "P3P: CP=\"NOI DSP COR NID NOR\"\r\n"
--> "Set-Cookie: BNI_persistence=0000000000000000000000004d79da0a00005000; Path=/\r\n"
--> "Strict-Transport-Security: max-age=31536000\r\n"
--> "\r\n"
--> "282\r\n"
-reading 642 bytes...
--> "Object moved \r\nObject moved to here . \r\n\r\n"
-read 642 bytes
-reading 2 bytes...
--> "\r\n"
-read 2 bytes
--> "0\r\n"
--> "\r\n"
-Conn close
-opening connection to train.cashnet.com:443...
-opened
-starting SSL for train.cashnet.com:443...
-SSL established
-<- "GET /cashneti/Gateway/htmlgw.aspx?client=EMARKETVENDOR_DEMO&command=SALE&merchant=GiveCorpGW&operator=givecorp&password=[FILTERED]&station=WEB&custcode=ActiveMerchant%2f1.76.0&cardno=[FILTERED]&cid=[FILTERED]&expdate=1215&card_name_g=Longbob+Longsen&fname=Longbob&lname=Longsen&order_number=c440ec8493f215d21c8a993ceae30129&itemcode=FEE&addr_g=456+My+Street%2cApt+1&city_g=Ottawa&state_g=ON&zip_g=K1C2N6&email_g=&amount=1.00 HTTP/1.1\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: train.cashnet.com\r\n\r\n"
--> "HTTP/1.1 200 OK\r\n"
--> "Date: Wed, 03 Jan 2018 17:03:35 GMT\r\n"
--> "Content-Type: text/html; charset=utf-8\r\n"
--> "Transfer-Encoding: chunked\r\n"
--> "Connection: close\r\n"
--> "Set-Cookie: AWSALB=lFPwFYRnXJHRNmE6NCRAIfHtQadwx4bYJoT5xeAL5AuAXPcm1vYWx5F/s5FBr3GcungifktpWlwIgAmWS29K7YRXTCjk4xmcAnhXS86fpVUVQt4ECwPH2xdv8tf2; Expires=Wed, 10 Jan 2018 17:03:35 GMT; Path=/\r\n"
--> "Set-Cookie: AWSALB=mEfysFNBclo1/9+tTuI/XtHrmVkD89Fh6tAJ3Gl0u2EuLCYTW5VwEq+fVqYG1fEkN02dbhKSkIdM22QvyT6cRccDaUBsYAnOKjg2JlVShJlf+li5tfbrsUDk14jG; Expires=Wed, 10 Jan 2018 17:03:35 GMT; Path=/\r\n"
--> "Cache-Control: private\r\n"
--> "Set-Cookie: ASP.NET_SessionId=3ocslggtk4cdz54unbdnm25o; path=/; HttpOnly\r\n"
--> "P3P: CP=\"NOI DSP COR NID NOR\"\r\n"
--> "Set-Cookie: BNI_persistence=0000000000000000000000004d79da0a00005000; Path=/\r\n"
--> "Strict-Transport-Security: max-age=31536000\r\n"
--> "\r\n"
--> "3a\r\n"
-reading 58 bytes...
--> "result=0&tx=77972&busdate=7/25/2017 "
-read 58 bytes
-reading 2 bytes...
--> "\r\n"
-read 2 bytes
--> "0\r\n"
--> "\r\n"
-Conn close
+ <<~SCRUBBED
+ opening connection to train.cashnet.com:443...
+ opened
+ starting SSL for train.cashnet.com:443...
+ SSL established
+ <- "POST /givecorpsgateway 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: train.cashnet.com\r\nContent-Length: 364\r\n\r\n"
+ <- "command=SALE&merchant=GiveCorpGW&operator=givecorp&password=[FILTERED]&station=WEB&custcode=ActiveMerchant%2F1.76.0&cardno=[FILTERED]&cid=[FILTERED]&expdate=1215&card_name_g=Longbob+Longsen&fname=Longbob&lname=Longsen&order_number=c440ec8493f215d21c8a993ceae30129&itemcode=FEE&addr_g=456+My+Street%2CApt+1&city_g=Ottawa&state_g=ON&zip_g=K1C2N6&email_g=&amount=1.00"
+ -> "HTTP/1.1 302 Found\r\n"
+ -> "Date: Wed, 03 Jan 2018 17:03:35 GMT\r\n"
+ -> "Content-Type: text/html; charset=utf-8\r\n"
+ -> "Transfer-Encoding: chunked\r\n"
+ -> "Connection: close\r\n"
+ -> "Set-Cookie: AWSALB=5ISjTg8Mez7jS1kEnzY4j5NkQ5bdlwDDNmfzTyEMBmILpb0Tn3k58pUQTGHBj3NUpciP0uqQs7FaAb42YZvt35ndLERGJA0dPQ03iCfrqbneQ+Wm5BhDzMGo5GUT; Expires=Wed, 10 Jan 2018 17:03:35 GMT; Path=/\r\n"
+ -> "Set-Cookie: AWSALB=bVhwwfJ2D6cI5zB3eapqNStEzF5yX1pXhaJGUBUCa+DZhEgn/TZGxznxIOYB9qKqzkPF4lq/zxWg/tuMBTiY4JGLRjayyhizvHnj2smrnNvr2DLQN7ZjLSh51BzM; Expires=Wed, 10 Jan 2018 17:03:35 GMT; Path=/\r\n"
+ -> "Cache-Control: private\r\n"
+ -> "Location: https://train.cashnet.com/cashneti/Gateway/htmlgw.aspx?client=EMARKETVENDOR_DEMO&command=SALE&merchant=GiveCorpGW&operator=givecorp&password=[FILTERED]&station=WEB&custcode=ActiveMerchant%2f1.76.0&cardno=[FILTERED]&cid=[FILTERED]&expdate=1215&card_name_g=Longbob+Longsen&fname=Longbob&lname=Longsen&order_number=c440ec8493f215d21c8a993ceae30129&itemcode=FEE&addr_g=456+My+Street%2cApt+1&city_g=Ottawa&state_g=ON&zip_g=K1C2N6&email_g=&amount=1.00\r\n"
+ -> "Set-Cookie: ASP.NET_SessionId=; path=/; HttpOnly\r\n"
+ -> "P3P: CP=\"NOI DSP COR NID NOR\"\r\n"
+ -> "Set-Cookie: BNI_persistence=0000000000000000000000004d79da0a00005000; Path=/\r\n"
+ -> "Strict-Transport-Security: max-age=31536000\r\n"
+ -> "\r\n"
+ -> "282\r\n"
+ reading 642 bytes...
+ -> "Object moved \r\nObject moved to here . \r\n\r\n"
+ read 642 bytes
+ reading 2 bytes...
+ -> "\r\n"
+ read 2 bytes
+ -> "0\r\n"
+ -> "\r\n"
+ Conn close
+ opening connection to train.cashnet.com:443...
+ opened
+ starting SSL for train.cashnet.com:443...
+ SSL established
+ <- "GET /cashneti/Gateway/htmlgw.aspx?client=EMARKETVENDOR_DEMO&command=SALE&merchant=GiveCorpGW&operator=givecorp&password=[FILTERED]&station=WEB&custcode=ActiveMerchant%2f1.76.0&cardno=[FILTERED]&cid=[FILTERED]&expdate=1215&card_name_g=Longbob+Longsen&fname=Longbob&lname=Longsen&order_number=c440ec8493f215d21c8a993ceae30129&itemcode=FEE&addr_g=456+My+Street%2cApt+1&city_g=Ottawa&state_g=ON&zip_g=K1C2N6&email_g=&amount=1.00 HTTP/1.1\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: train.cashnet.com\r\n\r\n"
+ -> "HTTP/1.1 200 OK\r\n"
+ -> "Date: Wed, 03 Jan 2018 17:03:35 GMT\r\n"
+ -> "Content-Type: text/html; charset=utf-8\r\n"
+ -> "Transfer-Encoding: chunked\r\n"
+ -> "Connection: close\r\n"
+ -> "Set-Cookie: AWSALB=lFPwFYRnXJHRNmE6NCRAIfHtQadwx4bYJoT5xeAL5AuAXPcm1vYWx5F/s5FBr3GcungifktpWlwIgAmWS29K7YRXTCjk4xmcAnhXS86fpVUVQt4ECwPH2xdv8tf2; Expires=Wed, 10 Jan 2018 17:03:35 GMT; Path=/\r\n"
+ -> "Set-Cookie: AWSALB=mEfysFNBclo1/9+tTuI/XtHrmVkD89Fh6tAJ3Gl0u2EuLCYTW5VwEq+fVqYG1fEkN02dbhKSkIdM22QvyT6cRccDaUBsYAnOKjg2JlVShJlf+li5tfbrsUDk14jG; Expires=Wed, 10 Jan 2018 17:03:35 GMT; Path=/\r\n"
+ -> "Cache-Control: private\r\n"
+ -> "Set-Cookie: ASP.NET_SessionId=3ocslggtk4cdz54unbdnm25o; path=/; HttpOnly\r\n"
+ -> "P3P: CP=\"NOI DSP COR NID NOR\"\r\n"
+ -> "Set-Cookie: BNI_persistence=0000000000000000000000004d79da0a00005000; Path=/\r\n"
+ -> "Strict-Transport-Security: max-age=31536000\r\n"
+ -> "\r\n"
+ -> "3a\r\n"
+ reading 58 bytes...
+ -> "result=0&tx=77972&busdate=7/25/2017 "
+ read 58 bytes
+ reading 2 bytes...
+ -> "\r\n"
+ read 2 bytes
+ -> "0\r\n"
+ -> "\r\n"
+ Conn close
SCRUBBED
end
end
diff --git a/test/unit/gateways/cecabank_test.rb b/test/unit/gateways/cecabank_test.rb
index 87ad7e20ab5..2641b1b6800 100644
--- a/test/unit/gateways/cecabank_test.rb
+++ b/test/unit/gateways/cecabank_test.rb
@@ -5,18 +5,18 @@ class CecabankTest < Test::Unit::TestCase
def setup
@gateway = CecabankGateway.new(
- :merchant_id => '12345678',
- :acquirer_bin => '12345678',
- :terminal_id => '00000003',
- :key => 'enc_key'
+ merchant_id: '12345678',
+ acquirer_bin: '12345678',
+ terminal_id: '00000003',
+ key: 'enc_key'
)
@credit_card = credit_card
@amount = 100
@options = {
- :order_id => '1',
- :description => 'Store Purchase'
+ order_id: '1',
+ description: 'Store Purchase'
}
end
@@ -43,7 +43,7 @@ def test_invalid_xml_response_handling
def test_expiration_date_sent_correctly
stub_comms do
@gateway.purchase(@amount, credit_card('4242424242424242', month: 1, year: 2014), @options)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/Caducidad=201401&/, data, 'Expected expiration date format is yyyymm')
end.respond_with(successful_purchase_response)
end
@@ -81,60 +81,60 @@ def test_transcript_scrubbing
private
def successful_purchase_response
- <<-RESPONSE
-
-
-
- 171.00 Euros
-
- 101000
- 12345678901234567890
- ##PAN##
-
-
+ <<~RESPONSE
+
+
+
+ 171.00 Euros
+
+ 101000
+ 12345678901234567890
+ ##PAN##
+
+
RESPONSE
end
def failed_purchase_response
- <<-RESPONSE
-
-
-
- 27
-
-
-
+ <<~RESPONSE
+
+
+
+ 27
+
+
+
RESPONSE
end
def invalid_xml_purchase_response
- <<-RESPONSE
-
-
-Invalid unparsable xml in the response
+ <<~RESPONSE
+
+
+ Invalid unparsable xml in the response
RESPONSE
end
def successful_refund_response
- <<-RESPONSE
-
-
-
- 1.00 Euros
-
-
+ <<~RESPONSE
+
+
+
+ 1.00 Euros
+
+
RESPONSE
end
def failed_refund_response
- <<-RESPONSE
-
-
-
- 15
- ]]>
-
-
+ <<~RESPONSE
+
+
+
+ 15
+ ]]>
+
+
RESPONSE
end
diff --git a/test/unit/gateways/cenpos_test.rb b/test/unit/gateways/cenpos_test.rb
index 950701578bd..0fd8f452a1b 100644
--- a/test/unit/gateways/cenpos_test.rb
+++ b/test/unit/gateways/cenpos_test.rb
@@ -5,9 +5,9 @@ class CenposTest < Test::Unit::TestCase
def setup
@gateway = CenposGateway.new(
- :merchant_id => 'merchant_id',
- :password => 'password',
- :user_id => 'user_id'
+ merchant_id: 'merchant_id',
+ password: 'password',
+ user_id: 'user_id'
)
@credit_card = credit_card
@@ -115,7 +115,7 @@ def test_successful_authorize_and_capture
capture = stub_comms do
@gateway.capture(@amount, response.authorization)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/1760035844/, data)
end.respond_with(successful_capture_response)
@@ -151,7 +151,7 @@ def test_successful_void
void = stub_comms do
@gateway.void(response.authorization)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/1760035844/, data)
end.respond_with(successful_void_response)
@@ -161,7 +161,7 @@ def test_successful_void
def test_failed_void
response = stub_comms do
@gateway.void('1758584451|4242|1.00')
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/1758584451/, data)
end.respond_with(failed_void_response)
@@ -178,7 +178,7 @@ def test_successful_refund
refund = stub_comms do
@gateway.refund(@amount, response.authorization)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/1609995363/, data)
end.respond_with(successful_refund_response)
diff --git a/test/unit/gateways/checkout_test.rb b/test/unit/gateways/checkout_test.rb
index ab70056694e..d58e55ee55e 100644
--- a/test/unit/gateways/checkout_test.rb
+++ b/test/unit/gateways/checkout_test.rb
@@ -5,8 +5,8 @@ class CheckoutTest < Test::Unit::TestCase
def setup
@gateway = ActiveMerchant::Billing::CheckoutGateway.new(
- :merchant_id => 'SBMTEST', # Merchant Code
- :password => 'Password1!' # Processing Password
+ merchant_id: 'SBMTEST', # Merchant Code
+ password: 'Password1!' # Processing Password
)
@options = {
order_id: generate_unique_id
@@ -72,21 +72,20 @@ def test_unsuccessful_purchase
def test_passes_correct_currency
stub_comms do
- @gateway.purchase(100, credit_card, @options.merge(
- currency: 'EUR'
- ))
- end.check_request do |endpoint, data, headers|
+ @gateway.purchase(100, credit_card, @options.merge(currency: 'EUR'))
+ end.check_request do |_endpoint, data, _headers|
assert_match(/EUR<\/bill_currencycode>/, data)
end.respond_with(successful_purchase_response)
end
def test_passes_descriptors
+ options = @options.merge(
+ descriptor_name: 'ZahName',
+ descriptor_city: 'Oakland'
+ )
stub_comms do
- @gateway.purchase(100, credit_card, @options.merge(
- descriptor_name: 'ZahName',
- descriptor_city: 'Oakland'
- ))
- end.check_request do |endpoint, data, headers|
+ @gateway.purchase(100, credit_card, options)
+ end.check_request do |_endpoint, data, _headers|
assert_match(/ZahName<\/descriptor_name>/, data)
assert_match(/Oakland<\/descriptor_city>/, data)
end.respond_with(successful_purchase_response)
@@ -96,7 +95,7 @@ def test_successful_void
@options['orderid'] = '9c38d0506da258e216fa072197faaf37'
void = stub_comms(@gateway, :ssl_request) do
@gateway.void('36919371|9c38d0506da258e216fa072197faaf37|1|CAD|100', @options)
- end.check_request do |method, endpoint, data, headers|
+ end.check_request do |_method, _endpoint, data, _headers|
# Should only be one pair of track id tags.
assert_equal 2, data.scan(/trackid/).count
end.respond_with(successful_void_response)
diff --git a/test/unit/gateways/checkout_v2_test.rb b/test/unit/gateways/checkout_v2_test.rb
index 141534eed8f..c76a2ddd433 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 'pay_fj3xswqe3emuxckocjx6td73ni', response.authorization
+ assert_equal 'pay_bgv5tmah6fmuzcmcrcro6exe6m', response.authorization
assert response.test?
end
@@ -41,6 +41,17 @@ def test_successful_purchase_includes_cvv_result
assert_equal 'Y', response.cvv_result['code']
end
+ def test_successful_purchase_using_network_token
+ network_token = network_tokenization_credit_card({ source: :network_token })
+ response = stub_comms do
+ @gateway.purchase(@amount, network_token)
+ end.respond_with(successful_purchase_with_network_token_response)
+
+ assert_success response
+ assert_equal '2FCFE326D92D4C27EDD699560F484', response.params['source']['payment_account_reference']
+ assert response.test?
+ end
+
def test_successful_authorize_includes_avs_result
response = stub_comms do
@gateway.authorize(@amount, @credit_card)
@@ -62,8 +73,8 @@ def test_successful_authorize_includes_cvv_result
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|
+ @gateway.purchase(@amount, @credit_card, { descriptor_city: 'london', descriptor_name: 'sherlock' })
+ end.check_request do |_endpoint, data, _headers|
assert_match(/"billing_descriptor\":{\"name\":\"sherlock\",\"city\":\"london\"}/, data)
end.respond_with(successful_purchase_response)
@@ -101,7 +112,7 @@ def test_successful_authorize_and_capture_with_additional_options
previous_charge_id: 'pay_123'
}
@gateway.authorize(@amount, @credit_card, options)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(%r{"stored":"true"}, data)
assert_match(%r{"payment_type":"Recurring"}, data)
assert_match(%r{"previous_payment_id":"pay_123"}, data)
@@ -120,10 +131,10 @@ def test_successful_authorize_and_capture_with_additional_options
def test_moto_transaction_is_properly_set
response = stub_comms do
options = {
- metadata: { manual_entry: true}
+ metadata: { manual_entry: true }
}
@gateway.authorize(@amount, @credit_card, options)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(%r{"payment_type":"MOTO"}, data)
end.respond_with(successful_authorize_response)
@@ -137,7 +148,7 @@ def test_3ds_passed
callback_url: 'https://www.example.com'
}
@gateway.authorize(@amount, @credit_card, options)
- end.check_request do |endpoint, data, headers|
+ 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)
@@ -165,6 +176,7 @@ def test_successful_authorize_and_capture_with_3ds
response = stub_comms do
options = {
execute_threed: true,
+ attempt_n3d: true,
three_d_secure: {
version: '1.0.2',
eci: '05',
@@ -256,7 +268,7 @@ def test_successful_refund
end.respond_with(successful_purchase_response)
assert_success response
- assert_equal 'pay_fj3xswqe3emuxckocjx6td73ni', response.authorization
+ assert_equal 'pay_bgv5tmah6fmuzcmcrcro6exe6m', response.authorization
refund = stub_comms do
@gateway.refund(@amount, response.authorization)
@@ -276,7 +288,7 @@ def test_failed_refund
def test_successful_verify
response = stub_comms do
@gateway.verify(@credit_card)
- end.respond_with(successful_authorize_response, failed_void_response)
+ end.respond_with(successful_verify_response)
assert_success response
assert_equal 'Succeeded', response.message
end
@@ -284,9 +296,9 @@ def test_successful_verify
def test_failed_verify
response = stub_comms do
@gateway.verify(@credit_card)
- end.respond_with(failed_authorize_response, successful_void_response)
+ end.respond_with(failed_verify_response)
assert_failure response
- assert_equal 'Invalid Card Number', response.message
+ assert_equal 'request_invalid: card_number_invalid', response.message
end
def test_transcript_scrubbing
@@ -299,7 +311,7 @@ def test_invalid_json
end.respond_with(invalid_json_response)
assert_failure response
- assert_match %r{Unable to read error message}, response.message
+ assert_match %r{Invalid JSON response received from Checkout.com Unified Payments Gateway. Please contact Checkout.com if you continue to receive this message.}, response.message
end
def test_error_code_returned
@@ -311,8 +323,17 @@ def test_error_code_returned
assert_match(/request_invalid: card_expired/, response.error_code)
end
+ def test_4xx_error_message
+ @gateway.expects(:ssl_post).raises(error_4xx_response)
+
+ assert response = @gateway.purchase(@amount, @credit_card)
+
+ assert_failure response
+ assert_match(/401: Unauthorized/, response.message)
+ end
+
def test_supported_countries
- assert_equal ['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'], @gateway.supported_countries
+ assert_equal %w[AD AE AR AT AU BE BG BH BR CH CL CN CO CY CZ DE DK EE EG ES FI FR GB GR HK HR HU IE IS IT JO JP KW LI LT LU LV MC MT MX MY NL NO NZ OM PE PL PT QA RO SA SE SG SI SK SM TR US], @gateway.supported_countries
end
private
@@ -333,26 +354,16 @@ def post_scrubbed
def successful_purchase_response
%(
- {
- "id":"pay_fj3xswqe3emuxckocjx6td73ni",
- "amount":200,
- "currency":"USD",
- "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"
- }
- }
+ {"id":"pay_bgv5tmah6fmuzcmcrcro6exe6m","action_id":"act_bgv5tmah6fmuzcmcrcro6exe6m","amount":200,"currency":"USD","approved":true,"status":"Authorized","auth_code":"127172","eci":"05","scheme_id":"096091887499308","response_code":"10000","response_summary":"Approved","risk":{"flagged":false},"source":{"id":"src_fzp3cwkf4ygebbmvrxdhyrwmbm","type":"card","billing_address":{"address_line1":"456 My Street","address_line2":"Apt 1","city":"Ottawa","state":"ON","zip":"K1C2N6","country":"CA"},"expiry_month":6,"expiry_year":2025,"name":"Longbob Longsen","scheme":"Visa","last4":"4242","fingerprint":"9F3BAD2E48C6C8579F2F5DC0710B7C11A8ACD5072C3363A72579A6FB227D64BE","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","payouts":true,"fast_funds":"d"},"customer":{"id":"cus_tz76qzbwr44ezdfyzdvrvlwogy","email":"longbob.longsen@example.com","name":"Longbob Longsen"},"processed_on":"2020-09-11T13:58:32Z","reference":"1","processing":{"acquirer_transaction_id":"9819327011","retrieval_reference_number":"861613285622"},"_links":{"self":{"href":"https://api.sandbox.checkout.com/payments/pay_bgv5tmah6fmuzcmcrcro6exe6m"},"actions":{"href":"https://api.sandbox.checkout.com/payments/pay_bgv5tmah6fmuzcmcrcro6exe6m/actions"},"capture":{"href":"https://api.sandbox.checkout.com/payments/pay_bgv5tmah6fmuzcmcrcro6exe6m/captures"},"void":{"href":"https://api.sandbox.checkout.com/payments/pay_bgv5tmah6fmuzcmcrcro6exe6m/voids"}}}
)
end
+ def successful_purchase_with_network_token_response
+ purchase_response = JSON.parse(successful_purchase_response)
+ purchase_response['source']['payment_account_reference'] = '2FCFE326D92D4C27EDD699560F484'
+ purchase_response.to_json
+ end
+
def failed_purchase_response
%(
{
@@ -511,6 +522,13 @@ def error_code_response
)
end
+ def error_4xx_response
+ mock_response = Net::HTTPUnauthorized.new('1.1', '401', 'Unauthorized')
+ mock_response.stubs(:body).returns('')
+
+ ActiveMerchant::ResponseError.new(mock_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"}}}
@@ -522,4 +540,12 @@ 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
+
+ def successful_verify_response
+ %({"id":"pay_ij6bctwxpzdulm53xyksio7gm4","action_id":"act_ij6bctwxpzdulm53xyksio7gm4","amount":0,"currency":"USD","approved":true,"status":"Card Verified","auth_code":"881790","eci":"05","scheme_id":"305756859646779","response_code":"10000","response_summary":"Approved","risk":{"flagged":false},"source":{"id":"src_nica37p5k7aufhs3rsv2te7xye","type":"card","billing_address":{"address_line1":"456 My Street","address_line2":"Apt 1","city":"Ottawa","state":"ON","zip":"K1C2N6","country":"CA"},"expiry_month":6,"expiry_year":2025,"name":"Longbob Longsen","scheme":"Visa","last4":"4242","fingerprint":"9F3BAD2E48C6C8579F2F5DC0710B7C11A8ACD5072C3363A72579A6FB227D64BE","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","payouts":true,"fast_funds":"d"},"customer":{"id":"cus_r2yb7f2upmsuhm6nbruoqn657y","email":"longbob.longsen@example.com","name":"Longbob Longsen"},"processed_on":"2020-09-18T18:17:45Z","reference":"1","processing":{"acquirer_transaction_id":"4932795322","retrieval_reference_number":"954188232380"},"_links":{"self":{"href":"https://api.sandbox.checkout.com/payments/pay_ij6bctwxpzdulm53xyksio7gm4"},"actions":{"href":"https://api.sandbox.checkout.com/payments/pay_ij6bctwxpzdulm53xyksio7gm4/actions"}}})
+ end
+
+ def failed_verify_response
+ %({"request_id":"911829c3-519a-47e8-bbc1-17337789fda0","error_type":"request_invalid","error_codes":["card_number_invalid"]})
+ end
end
diff --git a/test/unit/gateways/citrus_pay_test.rb b/test/unit/gateways/citrus_pay_test.rb
index 40b126e3782..7c96c1c1308 100644
--- a/test/unit/gateways/citrus_pay_test.rb
+++ b/test/unit/gateways/citrus_pay_test.rb
@@ -48,7 +48,7 @@ def test_authorize_and_capture
capture = stub_comms(@gateway, :ssl_request) do
@gateway.capture(@amount, response.authorization)
- end.check_request do |method, endpoint, data, headers|
+ end.check_request do |_method, _endpoint, data, _headers|
assert_match(/f3d100a7-18d9-4609-aabc-8a710ad0e210/, data)
end.respond_with(successful_capture_response)
@@ -65,7 +65,7 @@ def test_refund
refund = stub_comms(@gateway, :ssl_request) do
@gateway.refund(@amount, response.authorization)
- end.check_request do |method, endpoint, data, headers|
+ end.check_request do |_method, _endpoint, data, _headers|
assert_match(/ce61e06e-8c92-4a0f-a491-6eb473d883dd/, data)
end.respond_with(successful_refund_response)
@@ -82,7 +82,7 @@ def test_void
void = stub_comms(@gateway, :ssl_request) do
@gateway.void(response.authorization)
- end.check_request do |method, endpoint, data, headers|
+ end.check_request do |_method, _endpoint, data, _headers|
assert_match(/ce61e06e-8c92-4a0f-a491-6eb473d883dd/, data)
end.respond_with(successful_void_response)
@@ -91,16 +91,16 @@ def test_void
def test_passing_alpha3_country_code
stub_comms(@gateway, :ssl_request) do
- @gateway.authorize(@amount, @credit_card, :billing_address => {country: 'US'})
- end.check_request do |method, endpoint, data, headers|
+ @gateway.authorize(@amount, @credit_card, billing_address: { country: 'US' })
+ end.check_request do |_method, _endpoint, data, _headers|
assert_match(/USA/, data)
end.respond_with(successful_authorize_response)
end
def test_non_existent_country
stub_comms(@gateway, :ssl_request) do
- @gateway.authorize(@amount, @credit_card, :billing_address => {country: 'Blah'})
- end.check_request do |method, endpoint, data, headers|
+ @gateway.authorize(@amount, @credit_card, billing_address: { country: 'Blah' })
+ end.check_request do |_method, _endpoint, data, _headers|
assert_match(/"country":null/, data)
end.respond_with(successful_authorize_response)
end
@@ -108,15 +108,15 @@ def test_non_existent_country
def test_passing_cvv
stub_comms(@gateway, :ssl_request) do
@gateway.authorize(@amount, @credit_card)
- end.check_request do |method, endpoint, data, headers|
+ end.check_request do |_method, _endpoint, data, _headers|
assert_match(/#{@credit_card.verification_value}/, data)
end.respond_with(successful_authorize_response)
end
def test_passing_billing_address
stub_comms(@gateway, :ssl_request) do
- @gateway.authorize(@amount, @credit_card, :billing_address => address)
- end.check_request do |method, endpoint, data, headers|
+ @gateway.authorize(@amount, @credit_card, billing_address: address)
+ end.check_request do |_method, _endpoint, data, _headers|
parsed = JSON.parse(data)
assert_equal('456 My Street', parsed['billing']['address']['street'])
assert_equal('K1C2N6', parsed['billing']['address']['postcodeZip'])
@@ -125,8 +125,8 @@ def test_passing_billing_address
def test_passing_shipping_name
stub_comms(@gateway, :ssl_request) do
- @gateway.authorize(@amount, @credit_card, :shipping_address => address)
- end.check_request do |method, endpoint, data, headers|
+ @gateway.authorize(@amount, @credit_card, shipping_address: address)
+ end.check_request do |_method, _endpoint, data, _headers|
parsed = JSON.parse(data)
assert_equal('Jim', parsed['shipping']['firstName'])
assert_equal('Smith', parsed['shipping']['lastName'])
@@ -166,7 +166,7 @@ def test_north_america_region_url
response = stub_comms(@gateway, :ssl_request) do
@gateway.purchase(@amount, @credit_card, @options)
- end.check_request do |method, endpoint, data, headers|
+ end.check_request do |_method, endpoint, _data, _headers|
assert_match(/secure.na.tnspayments.com/, endpoint)
end.respond_with(successful_capture_response)
@@ -182,7 +182,7 @@ def test_asia_pacific_region_url
response = stub_comms(@gateway, :ssl_request) do
@gateway.purchase(@amount, @credit_card, @options)
- end.check_request do |method, endpoint, data, headers|
+ end.check_request do |_method, endpoint, _data, _headers|
assert_match(/secure.ap.tnspayments.com/, endpoint)
end.respond_with(successful_capture_response)
diff --git a/test/unit/gateways/clearhaus_test.rb b/test/unit/gateways/clearhaus_test.rb
index b877de05e4f..b5d74ff46ec 100644
--- a/test/unit/gateways/clearhaus_test.rb
+++ b/test/unit/gateways/clearhaus_test.rb
@@ -55,7 +55,7 @@ def test_successful_authorize_with_threed
response = @gateway.authorize(@amount, @credit_card, @options.merge(pares: '123'))
assert_success response
assert response.test?
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
expr = { card: { pares: '123' } }.to_query
assert_match expr, data
end.respond_with(successful_authorize_response)
@@ -66,9 +66,9 @@ def test_additional_params
response = @gateway.authorize(@amount, @credit_card, @options.merge(order_id: '123', text_on_statement: 'test'))
assert_success response
assert response.test?
- end.check_request do |endpoint, data, headers|
- order_expr = { reference: '123'}.to_query
- tos_expr = { text_on_statement: 'test'}.to_query
+ end.check_request do |_endpoint, data, _headers|
+ order_expr = { reference: '123' }.to_query
+ tos_expr = { text_on_statement: 'test' }.to_query
assert_match order_expr, data
assert_match tos_expr, data
@@ -82,7 +82,7 @@ def test_successful_authorize_with_card
assert_equal '84412a34-fa29-4369-a098-0165a80e8fda', response.authorization
assert response.test?
- end.check_request do |endpoint, data, headers|
+ end.check_request do |endpoint, _data, _headers|
assert_match %r{/cards/4110/authorizations}, endpoint
end.respond_with(successful_authorize_response)
end
@@ -222,7 +222,7 @@ def test_signing_request
assert_equal '84412a34-fa29-4369-a098-0165a80e8fda', response.authorization
assert response.test?
- end.check_request do |method, endpoint, data, headers|
+ 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{25f8283c3cc43911d7$}, headers['Signature']
@@ -241,7 +241,7 @@ def test_cleans_whitespace_from_private_key
assert_equal '84412a34-fa29-4369-a098-0165a80e8fda', response.authorization
assert response.test?
- end.check_request do |method, endpoint, data, headers|
+ 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{25f8283c3cc43911d7$}, headers['Signature']
@@ -249,7 +249,7 @@ def test_cleans_whitespace_from_private_key
end
def test_unsuccessful_signing_request_with_invalid_key
- gateway = ClearhausGateway.new(api_key: 'test_key', signing_key: @test_signing_key, private_key: 'foo')
+ gateway = ClearhausGateway.new(api_key: 'test_key', signing_key: @test_signing_key, private_key: 'foo')
# stub actual network access, but this shouldn't be reached
gateway.stubs(:ssl_post).returns(nil)
@@ -266,6 +266,14 @@ def test_scrub
assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed
end
+ def test_nonfractional_currency_handling
+ stub_comms do
+ @gateway.authorize(200, @credit_card, @options.merge(currency: 'JPY'))
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(/amount=2&card/, data)
+ end.respond_with(successful_authorize_response)
+ end
+
private
def pre_scrubbed
@@ -366,11 +374,11 @@ def successful_authorize_response
{
'id' => '84412a34-fa29-4369-a098-0165a80e8fda',
'status' => {
- 'code' => 20000
+ 'code' => 20000
},
'processed_at' => '2014-07-09T09:53:41+00:00',
'_links' => {
- 'captures' => { 'href' => '/authorizations/84412a34-fa29-4369-a098-0165a80e8fda/captures' }
+ 'captures' => { 'href' => '/authorizations/84412a34-fa29-4369-a098-0165a80e8fda/captures' }
}
}.to_json
end
@@ -381,20 +389,20 @@ def failed_authorize_response
def successful_capture_response
{
- 'id' => 'd8e92a70-3030-4d4d-8ad2-684b230c1bed',
- 'status' => {
- 'code' => 20000
+ 'id' => 'd8e92a70-3030-4d4d-8ad2-684b230c1bed',
+ 'status' => {
+ 'code' => 20000
+ },
+ 'processed_at' => '2014-07-09T11:47:28+00:00',
+ 'amount' => 1000,
+ '_links' => {
+ 'authorization' => {
+ 'href' => '/authorizations/84412a34-fa29-4369-a098-0165a80e8fda'
},
- 'processed_at' => '2014-07-09T11:47:28+00:00',
- 'amount' => 1000,
- '_links' => {
- 'authorization' => {
- 'href' => '/authorizations/84412a34-fa29-4369-a098-0165a80e8fda'
- },
- 'refunds' => {
- 'href' => '/authorizations/84412a34-fa29-4369-a098-0165a80e8fda/refunds'
- }
+ 'refunds' => {
+ 'href' => '/authorizations/84412a34-fa29-4369-a098-0165a80e8fda/refunds'
}
+ }
}.to_json
end
@@ -406,12 +414,12 @@ def successful_refund_response
{
'id' => 'f04c0872-47ce-4683-8d8c-e154221bba14',
'status' => {
- 'code' => 20000
+ 'code' => 20000
},
'processed_at' => '2014-07-09T11:57:58+00:00',
'amount' => 500,
'_links' => {
- 'authorization' => { 'href' => '/authorizations/84412a34-fa29-4369-a098-0165a80e8fda' }
+ 'authorization' => { 'href' => '/authorizations/84412a34-fa29-4369-a098-0165a80e8fda' }
}
}.to_json
end
@@ -437,8 +445,8 @@ def successful_void_response
'captures' => {
'href' => '/authorizations/77d08c40-cfa9-42e3-993d-795f772b70a4/captures'
},
- 'voids' => { 'href' => '/authorizations/77d08c40-cfa9-42e3-993d-795f772b70a4/voids'},
- 'refunds' => { 'href' => '/authorizations/77d08c40-cfa9-42e3-993d-795f772b70a4/refunds'}
+ 'voids' => { 'href' => '/authorizations/77d08c40-cfa9-42e3-993d-795f772b70a4/voids' },
+ 'refunds' => { 'href' => '/authorizations/77d08c40-cfa9-42e3-993d-795f772b70a4/refunds' }
}
}
end
@@ -451,14 +459,14 @@ def successful_store_response
{
'id' => '58dabba0-e9ea-4133-8c38-bfa1028c1ed2',
'status' => {
- 'code'=> 20000
+ 'code' => 20000
},
'processed_at' => '2014-07-09T12:14:31+00:00',
'last4' => '0004',
'scheme' => 'mastercard',
'_links' => {
- 'authorizations' => { 'href' => '/cards/58dabba0-e9ea-4133-8c38-bfa1028c1ed2/authorizations' },
- 'credits'=> { 'href' => '/cards/58dabba0-e9ea-4133-8c38-bfa1028c1ed2/credits' }
+ 'authorizations' => { 'href' => '/cards/58dabba0-e9ea-4133-8c38-bfa1028c1ed2/authorizations' },
+ 'credits' => { 'href' => '/cards/58dabba0-e9ea-4133-8c38-bfa1028c1ed2/credits' }
}
}.to_json
end
@@ -468,7 +476,6 @@ def failed_store_response
end
def failed_ch_response
- { 'status' => { 'code' => 40000, 'message' => 'General input error' }}.to_json
+ { 'status' => { 'code' => 40000, 'message' => 'General input error' } }.to_json
end
-
end
diff --git a/test/unit/gateways/conekta_test.rb b/test/unit/gateways/conekta_test.rb
index 215a50b1ba3..710e7f063a3 100644
--- a/test/unit/gateways/conekta_test.rb
+++ b/test/unit/gateways/conekta_test.rb
@@ -4,41 +4,41 @@ class ConektaTest < Test::Unit::TestCase
include CommStub
def setup
- @gateway = ConektaGateway.new(:key => 'key_eYvWV7gSDkNYXsmr')
+ @gateway = ConektaGateway.new(key: 'key_eYvWV7gSDkNYXsmr')
@amount = 300
@credit_card = ActiveMerchant::Billing::CreditCard.new(
- :number => '4242424242424242',
- :verification_value => '183',
- :month => '01',
- :year => '2018',
- :first_name => 'Mario F.',
- :last_name => 'Moreno Reyes'
+ number: '4242424242424242',
+ verification_value: '183',
+ month: '01',
+ year: '2018',
+ first_name: 'Mario F.',
+ last_name: 'Moreno Reyes'
)
@declined_card = ActiveMerchant::Billing::CreditCard.new(
- :number => '4000000000000002',
- :verification_value => '183',
- :month => '01',
- :year => '2018',
- :first_name => 'Mario F.',
- :last_name => 'Moreno Reyes'
+ number: '4000000000000002',
+ verification_value: '183',
+ month: '01',
+ year: '2018',
+ first_name: 'Mario F.',
+ last_name: 'Moreno Reyes'
)
@options = {
- :device_fingerprint => '41l9l92hjco6cuekf0c7dq68v4',
- :description => 'Blue clip',
- :success_url => 'https://www.example.com/success',
- :failure_url => 'https://www.example.com/failure',
- :address1 => 'Rio Missisipi #123',
- :address2 => 'Paris',
- :city => 'Guerrero',
- :country => 'Mexico',
- :zip => '5555',
- :customer => 'Mario Reyes',
- :phone => '12345678',
- :carrier => 'Estafeta'
+ device_fingerprint: '41l9l92hjco6cuekf0c7dq68v4',
+ description: 'Blue clip',
+ success_url: 'https://www.example.com/success',
+ failure_url: 'https://www.example.com/failure',
+ address1: 'Rio Missisipi #123',
+ address2: 'Paris',
+ city: 'Guerrero',
+ country: 'Mexico',
+ zip: '5555',
+ customer: 'Mario Reyes',
+ phone: '12345678',
+ carrier: 'Estafeta'
}
end
@@ -69,8 +69,8 @@ def test_unsuccessful_purchase
def test_successful_purchase_with_installments
response = stub_comms(@gateway, :ssl_request) do
- @gateway.purchase(@amount, @credit_card, @options.merge({monthly_installments: '3'}))
- end.check_request do |method, endpoint, data, headers|
+ @gateway.purchase(@amount, @credit_card, @options.merge({ monthly_installments: '3' }))
+ end.check_request do |_method, _endpoint, data, _headers|
assert_match %r{monthly_installments=3}, data
end.respond_with(successful_purchase_response)
@@ -139,7 +139,7 @@ def test_unsuccessful_capture
end
def test_invalid_key
- gateway = ConektaGateway.new(:key => 'invalid_token')
+ gateway = ConektaGateway.new(key: 'invalid_token')
gateway.expects(:ssl_request).returns(failed_login_response)
assert response = gateway.purchase(@amount, @credit_card, @options)
assert_failure response
@@ -154,8 +154,8 @@ def test_adds_application_and_meta_headers
}
response = stub_comms(@gateway, :ssl_request) do
- @gateway.purchase(@amount, 'tok_xxxxxxxxxxxxxxxx', @options.merge(application: application, meta: {its_so_meta: 'even this acronym'}))
- end.check_request do |method, endpoint, data, headers|
+ @gateway.purchase(@amount, 'tok_xxxxxxxxxxxxxxxx', @options.merge(application: application, meta: { its_so_meta: 'even this acronym' }))
+ end.check_request do |_method, _endpoint, _data, headers|
assert_match(/\"application\"/, headers['X-Conekta-Client-User-Agent'])
assert_match(/\"name\":\"app\"/, headers['X-Conekta-Client-User-Agent'])
assert_match(/\"version\":\"1.0\"/, headers['X-Conekta-Client-User-Agent'])
diff --git a/test/unit/gateways/creditcall_test.rb b/test/unit/gateways/creditcall_test.rb
index 146606ff742..9103162f6cf 100644
--- a/test/unit/gateways/creditcall_test.rb
+++ b/test/unit/gateways/creditcall_test.rb
@@ -112,7 +112,7 @@ def test_failed_verify
def test_verification_value_sent
stub_comms do
@gateway.authorize(@amount, @credit_card, @options)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(%r(123 )m, data)
end.respond_with(successful_authorize_response)
end
@@ -121,7 +121,7 @@ def test_verification_value_not_sent
@credit_card.verification_value = ' '
stub_comms do
@gateway.authorize(@amount, @credit_card, @options)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_no_match(/CSC/, data)
end.respond_with(successful_authorize_response)
end
@@ -129,25 +129,25 @@ def test_verification_value_not_sent
def test_options_add_avs_additional_verification_fields
stub_comms do
@gateway.authorize(@amount, @credit_card, @options)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_no_match(/AdditionalVerification/, data)
end.respond_with(successful_authorize_response)
stub_comms do
@gateway.authorize(@amount, @credit_card, @options.merge(verify_zip: 'false', verify_address: 'false'))
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_no_match(/AdditionalVerification/, data)
end.respond_with(successful_authorize_response)
stub_comms do
@gateway.authorize(@amount, @credit_card, @options.merge(verify_zip: 'true', verify_address: 'true'))
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/\n K1C2N6<\/Zip>\n /, data)
end.respond_with(successful_authorize_response)
stub_comms do
@gateway.authorize(@amount, @credit_card, @options.merge(verify_zip: 'true', verify_address: 'false'))
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/ \n K1C2N6<\/Zip>\n <\/AdditionalVerification>\n/, data)
end.respond_with(successful_authorize_response)
end
diff --git a/test/unit/gateways/credorax_test.rb b/test/unit/gateways/credorax_test.rb
index a3403d44604..71a9a3368e4 100644
--- a/test/unit/gateways/credorax_test.rb
+++ b/test/unit/gateways/credorax_test.rb
@@ -22,8 +22,10 @@ def setup
shipping_address: address(),
order_id: '123',
execute_threed: true,
+ three_ds_initiate: '03',
+ f23: '1',
three_ds_challenge_window_size: '01',
- stored_credential: {reason_type: 'unscheduled'},
+ stored_credential: { reason_type: 'unscheduled' },
three_ds_2: {
channel: 'browser',
notification_url: 'www.example.com',
@@ -44,13 +46,14 @@ def setup
def test_successful_purchase
response = stub_comms do
@gateway.purchase(@amount, @credit_card)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_no_match(/i8=sample-eci%3Asample-cavv%3Asample-xid/, data)
end.respond_with(successful_purchase_response)
assert_success response
assert_equal '8a82944a5351570601535955efeb513c;006596;02617cf5f02ccaed239b6521748298c5;purchase', response.authorization
+ assert_equal 'Succeeded', response.message
assert response.test?
end
@@ -74,11 +77,12 @@ def test_successful_authorize_and_capture
capture = stub_comms do
@gateway.capture(@amount, response.authorization)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/8a829449535154bc0153595952a2517a/, data)
end.respond_with(successful_capture_response)
assert_success capture
+ assert_equal 'Succeeded', response.message
end
def test_failed_authorize
@@ -97,6 +101,7 @@ def test_failed_capture
end.respond_with(failed_capture_response)
assert_failure response
+ assert_equal '2. At least one of input parameters is malformed.: Parameter [g4] cannot be empty.', response.message
end
def test_successful_void
@@ -109,21 +114,23 @@ def test_successful_void
void = stub_comms do
@gateway.void(response.authorization)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/8a829449535154bc0153595952a2517a/, data)
end.respond_with(successful_void_response)
assert_success void
+ assert_equal 'Succeeded', void.message
end
def test_failed_void
response = stub_comms do
@gateway.void('5d53a33d960c46d00f5dc061947d998c')
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/5d53a33d960c46d00f5dc061947d998c/, data)
end.respond_with(failed_void_response)
assert_failure response
+ assert_equal '2. At least one of input parameters is malformed.: Parameter [g4] cannot be empty.', response.message
end
def test_successful_refund
@@ -136,11 +143,12 @@ def test_successful_refund
refund = stub_comms do
@gateway.refund(@amount, response.authorization)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/8a82944a5351570601535955efeb513c/, data)
end.respond_with(successful_refund_response)
assert_success refund
+ assert_equal 'Succeeded', refund.message
end
def test_failed_refund
@@ -149,6 +157,43 @@ def test_failed_refund
end.respond_with(failed_refund_response)
assert_failure response
+ assert_equal '2. At least one of input parameters is malformed.: Parameter [g4] cannot be empty.', response.message
+ end
+
+ def test_successful_referral_cft
+ response = stub_comms do
+ @gateway.purchase(@amount, @credit_card)
+ end.respond_with(successful_purchase_response)
+
+ assert_success response
+ assert_equal '8a82944a5351570601535955efeb513c;006596;02617cf5f02ccaed239b6521748298c5;purchase', response.authorization
+
+ referral_cft = stub_comms do
+ @gateway.refund(@amount, response.authorization, { referral_cft: true, first_name: 'John', last_name: 'Smith' })
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(/8a82944a5351570601535955efeb513c/, data)
+ # Confirm that `j5` (first name) and `j13` (surname) parameters are present
+ # These fields are required for CFT payouts as of Sept 1, 2020
+ assert_match(/j5=John/, data)
+ assert_match(/j13=Smith/, data)
+ # Confirm that the transaction type is `referral_cft`
+ assert_match(/O=34/, data)
+ end.respond_with(successful_referral_cft_response)
+
+ assert_success referral_cft
+ assert_equal 'Succeeded', referral_cft.message
+ end
+
+ def test_failed_referral_cft
+ response = stub_comms do
+ @gateway.refund(nil, '', referral_cft: true)
+ end.check_request do |_endpoint, data, _headers|
+ # Confirm that the transaction type is `referral_cft`
+ assert_match(/O=34/, data)
+ end.respond_with(failed_referral_cft_response)
+
+ assert_failure response
+ assert_equal 'Referred to transaction has not been found.', response.message
end
def test_successful_credit
@@ -159,6 +204,7 @@ def test_successful_credit
assert_success response
assert_equal '8a82944a53515706015359604c135301;;868f8b942fae639d28e27e8933d575d4;credit', response.authorization
+ assert_equal 'Succeeded', response.message
assert response.test?
end
@@ -206,9 +252,11 @@ def test_adds_3d2_secure_fields
response = stub_comms do
@gateway.purchase(@amount, @credit_card, options_with_3ds)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/3ds_channel=02/, data)
assert_match(/3ds_transtype=01/, data)
+ assert_match(/3ds_initiate=03/, data)
+ assert_match(/f23=1/, data)
assert_match(/3ds_redirect_url=www.example.com/, data)
assert_match(/3ds_challengewindowsize=01/, data)
assert_match(/d5=unknown/, data)
@@ -225,6 +273,38 @@ def test_adds_3d2_secure_fields
assert_match(/3ds_shipaddrline1=456\+My\+Street/, data)
assert_match(/3ds_shipaddrcountry=CA/, data)
assert_match(/3ds_shipaddrcity=Ottawa/, data)
+ refute_match(/3ds_version/, 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_correct_3ds_browsercolordepth_when_color_depth_is_30
+ @normalized_3ds_2_options[:three_ds_2][:browser_info][:depth] = 30
+
+ response = stub_comms do
+ @gateway.purchase(@amount, @credit_card, @normalized_3ds_2_options)
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(/3ds_browsercolordepth=32/, 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_3d2_secure_fields_with_3ds_transtype_specified
+ options_with_3ds = @normalized_3ds_2_options.merge(three_ds_transtype: '03')
+
+ 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_transtype=03/, data)
end.respond_with(successful_purchase_response)
assert_success response
@@ -234,12 +314,13 @@ def test_adds_3d2_secure_fields
end
def test_purchase_adds_3d_secure_fields
- options_with_3ds = @options.merge({eci: 'sample-eci', cavv: 'sample-cavv', xid: 'sample-xid'})
+ options_with_3ds = @options.merge({ eci: 'sample-eci', cavv: 'sample-cavv', xid: 'sample-xid', three_ds_version: '1.0.2' })
response = stub_comms do
@gateway.purchase(@amount, @credit_card, options_with_3ds)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/i8=sample-eci%3Asample-cavv%3Asample-xid/, data)
+ assert_match(/3ds_version=1.0&/, data)
end.respond_with(successful_purchase_response)
assert_success response
@@ -248,13 +329,34 @@ def test_purchase_adds_3d_secure_fields
assert response.test?
end
+ def test_purchase_adds_3d_secure_fields_via_normalized_hash
+ version = '1.0.2'
+ eci = 'sample-eci'
+ cavv = 'sample-cavv'
+ xid = 'sample-xid'
+ options_with_normalized_3ds = @options.merge(
+ three_d_secure: {
+ version: version,
+ eci: eci,
+ cavv: cavv,
+ xid: xid
+ }
+ )
+
+ 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}%3A#{xid}/, data)
+ assert_match(/3ds_version=1.0&/, data)
+ end.respond_with(successful_purchase_response)
+ end
+
def test_3ds_channel_field_set_by_stored_credential_initiator
options_with_3ds = @normalized_3ds_2_options.merge(stored_credential_options(:merchant, :unscheduled, id: 'abc123'))
response = stub_comms do
@gateway.purchase(@amount, @credit_card, options_with_3ds)
- end.check_request do |endpoint, data, headers|
- p data
+ end.check_request do |_endpoint, data, _headers|
assert_match(/3ds_channel=03/, data)
end.respond_with(successful_purchase_response)
@@ -265,12 +367,13 @@ def test_3ds_channel_field_set_by_stored_credential_initiator
end
def test_authorize_adds_3d_secure_fields
- options_with_3ds = @options.merge({eci: 'sample-eci', cavv: 'sample-cavv', xid: 'sample-xid'})
+ options_with_3ds = @options.merge({ eci: 'sample-eci', cavv: 'sample-cavv', xid: 'sample-xid' })
response = stub_comms do
@gateway.authorize(@amount, @credit_card, options_with_3ds)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/i8=sample-eci%3Asample-cavv%3Asample-xid/, data)
+ assert_match(/3ds_version=1.0/, data)
end.respond_with(successful_purchase_response)
assert_success response
@@ -280,11 +383,11 @@ def test_authorize_adds_3d_secure_fields
end
def test_defaults_3d_secure_cavv_field_to_none_if_not_present
- options_with_3ds = @options.merge({eci: 'sample-eci', xid: 'sample-xid'})
+ options_with_3ds = @options.merge({ eci: 'sample-eci', xid: 'sample-xid' })
response = stub_comms do
@gateway.purchase(@amount, @credit_card, options_with_3ds)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/i8=sample-eci%3Anone%3Asample-xid/, data)
end.respond_with(successful_purchase_response)
@@ -295,7 +398,7 @@ def test_defaults_3d_secure_cavv_field_to_none_if_not_present
end
def test_adds_3ds2_fields_via_normalized_hash
- version = '2.0'
+ version = '2'
eci = '05'
cavv = '637574652070757070792026206b697474656e73'
ds_transaction_id = '97267598-FAE6-48F2-8083-C23433990FBC'
@@ -310,15 +413,15 @@ def test_adds_3ds2_fields_via_normalized_hash
stub_comms do
@gateway.purchase(@amount, @credit_card, options_with_normalized_3ds)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/i8=#{eci}%3A#{cavv}%3Anone/, data)
- assert_match(/3ds_version=#{version}/, data)
+ assert_match(/3ds_version=2.0/, 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'
+ version = '2.2.0'
eci = '05'
ds_transaction_id = '97267598-FAE6-48F2-8083-C23433990FBC'
options_with_normalized_3ds = @options.merge(
@@ -331,45 +434,55 @@ def test_adds_default_cavv_when_omitted_from_normalized_hash
stub_comms do
@gateway.purchase(@amount, @credit_card, options_with_normalized_3ds)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/i8=#{eci}%3Anone%3Anone/, data)
- assert_match(/3ds_version=#{version}/, data)
+ assert_match(/3ds_version=2.0/, data)
assert_match(/3ds_dstrxid=#{ds_transaction_id}/, data)
end.respond_with(successful_purchase_response)
end
def test_purchase_adds_a9_field
- options_with_3ds = @options.merge({transaction_type: '8'})
+ options_with_3ds = @options.merge({ transaction_type: '8' })
stub_comms do
@gateway.purchase(@amount, @credit_card, options_with_3ds)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/a9=8/, data)
end.respond_with(successful_purchase_response)
end
def test_authorize_adds_a9_field
- options_with_3ds = @options.merge({transaction_type: '8'})
+ options_with_3ds = @options.merge({ transaction_type: '8' })
stub_comms do
@gateway.authorize(@amount, @credit_card, options_with_3ds)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/a9=8/, data)
end.respond_with(successful_authorize_response)
end
def test_credit_adds_a9_field
- options_with_3ds = @options.merge({transaction_type: '8'})
+ options_with_3ds = @options.merge({ transaction_type: '8' })
stub_comms do
@gateway.credit(@amount, @credit_card, options_with_3ds)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/a9=8/, data)
end.respond_with(successful_credit_response)
end
+ def test_authorize_adds_authorization_details
+ options_with_auth_details = @options.merge({ authorization_type: '2', multiple_capture_count: '5' })
+ stub_comms do
+ @gateway.authorize(@amount, @credit_card, options_with_auth_details)
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(/a10=2/, data)
+ assert_match(/a11=5/, data)
+ end.respond_with(successful_authorize_response)
+ end
+
def test_purchase_adds_submerchant_id
@options[:submerchant_id] = '12345'
stub_comms do
@gateway.purchase(@amount, @credit_card, @options)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/h3=12345/, data)
end.respond_with(successful_purchase_response)
end
@@ -378,7 +491,7 @@ def test_adds_moto_a2_field
@options[:metadata] = { manual_entry: true }
stub_comms do
@gateway.purchase(@amount, @credit_card, @options)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/a2=3/, data)
end.respond_with(successful_purchase_response)
end
@@ -387,7 +500,7 @@ def test_authorize_adds_submerchant_id
@options[:submerchant_id] = '12345'
stub_comms do
@gateway.authorize(@amount, @credit_card, @options)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/h3=12345/, data)
end.respond_with(successful_authorize_response)
end
@@ -400,7 +513,7 @@ def test_capture_adds_submerchant_id
@options[:submerchant_id] = '12345'
stub_comms do
@gateway.capture(@amount, response.authorization, @options)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/h3=12345/, data)
end.respond_with(successful_capture_response)
end
@@ -413,7 +526,7 @@ def test_void_adds_submerchant_id
@options[:submerchant_id] = '12345'
stub_comms do
@gateway.void(response.authorization, @options)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/h3=12345/, data)
end.respond_with(successful_void_response)
end
@@ -426,7 +539,7 @@ def test_refund_adds_submerchant_id
@options[:submerchant_id] = '12345'
stub_comms do
@gateway.refund(@amount, response.authorization, @options)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/h3=12345/, data)
end.respond_with(successful_refund_response)
end
@@ -435,7 +548,7 @@ def test_credit_adds_submerchant_id
@options[:submerchant_id] = '12345'
stub_comms do
@gateway.credit(@amount, @credit_card, @options)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/h3=12345/, data)
end.respond_with(successful_credit_response)
end
@@ -444,7 +557,7 @@ def test_supports_billing_descriptor
@options[:billing_descriptor] = 'abcdefghijkl'
stub_comms do
@gateway.purchase(@amount, @credit_card, @options)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/i2=abcdefghijkl/, data)
end.respond_with(successful_purchase_response)
end
@@ -453,7 +566,7 @@ def test_purchase_adds_billing_descriptor
@options[:billing_descriptor] = 'abcdefghijkl'
stub_comms do
@gateway.purchase(@amount, @credit_card, @options)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/i2=abcdefghijkl/, data)
end.respond_with(successful_purchase_response)
end
@@ -462,7 +575,7 @@ def test_authorize_adds_billing_descriptor
@options[:billing_descriptor] = 'abcdefghijkl'
stub_comms do
@gateway.authorize(@amount, @credit_card, @options)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/i2=abcdefghijkl/, data)
end.respond_with(successful_authorize_response)
end
@@ -475,7 +588,7 @@ def test_capture_adds_billing_descriptor
@options[:billing_descriptor] = 'abcdefghijkl'
stub_comms do
@gateway.capture(@amount, response.authorization, @options)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/i2=abcdefghijkl/, data)
end.respond_with(successful_capture_response)
end
@@ -488,7 +601,7 @@ def test_refund_adds_billing_descriptor
@options[:billing_descriptor] = 'abcdefghijkl'
stub_comms do
@gateway.refund(@amount, response.authorization, @options)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/i2=abcdefghijkl/, data)
end.respond_with(successful_refund_response)
end
@@ -497,7 +610,7 @@ def test_credit_adds_billing_descriptor
@options[:billing_descriptor] = 'abcdefghijkl'
stub_comms do
@gateway.credit(@amount, @credit_card, @options)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/i2=abcdefghijkl/, data)
end.respond_with(successful_credit_response)
end
@@ -507,7 +620,7 @@ def test_purchase_adds_processor_fields
@options[:processor_merchant_id] = '123'
stub_comms do
@gateway.purchase(@amount, @credit_card, @options)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/r1=TEST/, data)
assert_match(/r2=123/, data)
end.respond_with(successful_purchase_response)
@@ -518,7 +631,7 @@ def test_authorize_adds_processor_fields
@options[:processor_merchant_id] = '123'
stub_comms do
@gateway.authorize(@amount, @credit_card, @options)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/r1=TEST/, data)
assert_match(/r2=123/, data)
end.respond_with(successful_authorize_response)
@@ -533,7 +646,7 @@ def test_capture_adds_processor_fields
@options[:processor_merchant_id] = '123'
stub_comms do
@gateway.capture(@amount, response.authorization, @options)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/r1=TEST/, data)
assert_match(/r2=123/, data)
end.respond_with(successful_capture_response)
@@ -548,7 +661,7 @@ def test_void_adds_processor_fields
@options[:processor_merchant_id] = '123'
stub_comms do
@gateway.void(response.authorization, @options)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/r1=TEST/, data)
assert_match(/r2=123/, data)
end.respond_with(successful_void_response)
@@ -563,7 +676,7 @@ def test_refund_adds_processor_fields
@options[:processor_merchant_id] = '123'
stub_comms do
@gateway.refund(@amount, response.authorization, @options)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/r1=TEST/, data)
assert_match(/r2=123/, data)
end.respond_with(successful_refund_response)
@@ -574,17 +687,57 @@ def test_credit_adds_processor_fields
@options[:processor_merchant_id] = '123'
stub_comms do
@gateway.credit(@amount, @credit_card, @options)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/r1=TEST/, data)
assert_match(/r2=123/, data)
end.respond_with(successful_credit_response)
end
+ def test_purchase_omits_phone_when_nil
+ # purchase passes the phone number when provided
+ @options[:billing_address][:phone] = '555-444-3333'
+ stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options)
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(/c2=555-444-3333/, data)
+ end.respond_with(successful_purchase_response)
+
+ # purchase doesn't pass the phone number when nil
+ @options[:billing_address][:phone] = nil
+ stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options)
+ end.check_request do |_endpoint, data, _headers|
+ assert_not_match(/c2=/, data)
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_purchase_omits_3ds_homephonecountry_when_phone_is_nil
+ # purchase passes 3ds_homephonecountry when it and phone number are provided
+ @options[:billing_address][:phone] = '555-444-3333'
+ @options[:three_ds_2] = { optional: { '3ds_homephonecountry': 'US' } }
+ stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options)
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(/c2=555-444-3333/, data)
+ assert_match(/3ds_homephonecountry=US/, data)
+ end.respond_with(successful_purchase_response)
+
+ # purchase doesn't pass 3ds_homephonecountry when phone number is nil
+ @options[:billing_address][:phone] = nil
+ @options[:three_ds_2] = { optional: { '3ds_homephonecountry': 'US' } }
+ stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options)
+ end.check_request do |_endpoint, data, _headers|
+ assert_not_match(/c2=/, data)
+ assert_not_match(/3ds_homephonecountry=/, data)
+ end.respond_with(successful_purchase_response)
+ 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|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/a9=9/, data)
end.respond_with(successful_authorize_response)
@@ -595,7 +748,7 @@ 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|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/a9=9/, data)
end.respond_with(successful_authorize_response)
@@ -606,7 +759,7 @@ 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|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/a9=1/, data)
end.respond_with(successful_authorize_response)
@@ -617,7 +770,7 @@ 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|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/a9=2/, data)
end.respond_with(successful_authorize_response)
@@ -628,7 +781,7 @@ 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|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/a9=9/, data)
end.respond_with(successful_authorize_response)
@@ -639,7 +792,7 @@ 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|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/a9=9/, data)
end.respond_with(successful_authorize_response)
@@ -650,7 +803,7 @@ 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|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/a9=8/, data)
end.respond_with(successful_authorize_response)
@@ -661,7 +814,7 @@ 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|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/a9=8/, data)
end.respond_with(successful_authorize_response)
@@ -672,7 +825,7 @@ 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|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/a9=9/, data)
end.respond_with(successful_authorize_response)
@@ -683,7 +836,7 @@ 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|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/a9=9/, data)
end.respond_with(successful_authorize_response)
@@ -694,7 +847,7 @@ 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|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/a9=8/, data)
end.respond_with(successful_authorize_response)
@@ -705,7 +858,7 @@ 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|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/a9=8/, data)
end.respond_with(successful_authorize_response)
@@ -716,7 +869,7 @@ def test_purchase_with_stored_credential
options = stored_credential_options(:merchant, :recurring, id: 'abc123')
response = stub_comms do
@gateway.purchase(@amount, @credit_card, options)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/a9=2/, data)
end.respond_with(successful_authorize_response)
@@ -727,13 +880,48 @@ def test_add_transaction_type_overrides_stored_credential_option
options = stored_credential_options(:merchant, :unscheduled, id: 'abc123').merge(transaction_type: '6')
response = stub_comms do
@gateway.authorize(@amount, @credit_card, options)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/a9=6/, data)
end.respond_with(successful_authorize_response)
assert_success response
end
+ def test_nonfractional_currency_handling
+ stub_comms do
+ @gateway.authorize(200, @credit_card, @options.merge(currency: 'JPY'))
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(/a4=2&a1=/, data)
+ end.respond_with(successful_authorize_response)
+ end
+
+ def test_3ds_2_optional_fields_adds_fields_to_the_root_of_the_post
+ post = {}
+ options = { three_ds_2: { optional: { '3ds_optional_field_1': :a, '3ds_optional_field_2': :b } } }
+
+ @gateway.add_3ds_2_optional_fields(post, options)
+
+ assert_equal post, { '3ds_optional_field_1': :a, '3ds_optional_field_2': :b }
+ end
+
+ def test_3ds_2_optional_fields_does_not_overwrite_fields
+ post = { '3ds_optional_field_1': :existing_value }
+ options = { three_ds_2: { optional: { '3ds_optional_field_1': :a, '3ds_optional_field_2': :b } } }
+
+ @gateway.add_3ds_2_optional_fields(post, options)
+
+ assert_equal post, { '3ds_optional_field_1': :existing_value, '3ds_optional_field_2': :b }
+ end
+
+ def test_3ds_2_optional_fields_does_not_empty_fields
+ post = {}
+ options = { three_ds_2: { optional: { '3ds_optional_field_1': '', '3ds_optional_field_2': 'null', '3ds_optional_field_3': nil } } }
+
+ @gateway.add_3ds_2_optional_fields(post, options)
+
+ assert_equal post, {}
+ end
+
private
def stored_credential_options(*args, id: nil)
@@ -786,6 +974,14 @@ def failed_refund_response
'M=SPREE978&O=5&T=03%2F09%2F2016+03%3A16%3A06&V=413&a1=c2b481deffe0e27bdef1439655260092&a2=2&a4=-&a5=EUR&b1=-&z1=1A-1&z2=-9&z3=2.+At+least+one+of+input+parameters+is+malformed.%3A+Parameter+%5Bg4%5D+cannot+be+empty.&K=c2f6112b40c61859d03684ac8e422766'
end
+ def successful_referral_cft_response
+ 'M=SPREE978&O=34&T=11%2F15%2F2019+15%3A56%3A08&V=413&a1=e852c517da0ffb0cde45671b39165449&a2=2&a4=100&a9=9&b2=2&g2=XZZ72c3228fc3b58525STV56T7YMFAJB&z1=XZZ72e64209459e8C2BAMTBS65MCNGIF&z13=931924132623&z2=0&z3=Transaction+has+been+executed+successfully.&z33=CREDORAX&z34=59990010&z39=XZZ72e64209459e8C2BAMTBS65MCNGIF&z4=HOSTOK&z6=00&K=76f8a35c3357a7613d63438bd86c06d9'
+ end
+
+ def failed_referral_cft_response
+ 'T=11%2F15%2F2019+17%3A17%3A45&a1=896ffaf13766fff647d863e8ab0a707c&z1=XZZ7246087744e7993DRONGBWN4RNFWJ&z2=-9&z3=Referred+to+transaction+has+not+been+found.'
+ end
+
def successful_credit_response
'M=SPREE978&O=6&T=03%2F09%2F2016+03%3A16%3A35&V=413&a1=868f8b942fae639d28e27e8933d575d4&a2=2&a4=100&z1=8a82944a53515706015359604c135301&z13=606944188289&z15=100&z2=0&z3=Transaction+has+been+executed+successfully.&z5=0&z6=00&K=51ba24f6ef3aa161f86e53c34c9616ac'
end
diff --git a/test/unit/gateways/cyber_source_test.rb b/test/unit/gateways/cyber_source_test.rb
index e0fb131d6ba..6de6047b715 100644
--- a/test/unit/gateways/cyber_source_test.rb
+++ b/test/unit/gateways/cyber_source_test.rb
@@ -8,49 +8,49 @@ def setup
Base.mode = :test
@gateway = CyberSourceGateway.new(
- :login => 'l',
- :password => 'p'
+ login: 'l',
+ password: 'p'
)
@amount = 100
@customer_ip = '127.0.0.1'
- @credit_card = credit_card('4111111111111111', :brand => 'visa')
- @master_credit_card = credit_card('4111111111111111', :brand => 'master')
- @elo_credit_card = credit_card('5067310000000010', :brand => 'elo')
- @declined_card = credit_card('801111111111111', :brand => 'visa')
+ @credit_card = credit_card('4111111111111111', brand: 'visa')
+ @master_credit_card = credit_card('4111111111111111', brand: 'master')
+ @elo_credit_card = credit_card('5067310000000010', brand: 'elo')
+ @declined_card = credit_card('801111111111111', brand: 'visa')
@check = check()
@options = {
- :ip => @customer_ip,
- :order_id => '1000',
- :line_items => [
+ 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,
+ code: 'default',
+ description: 'Giant Walrus',
+ sku: 'WA323232323232323'
},
{
- :declared_value => @amount,
- :quantity => 2,
- :description => 'Marble Snowcone',
- :sku => 'FAKE1232132113123'
+ declared_value: @amount,
+ quantity: 2,
+ description: 'Marble Snowcone',
+ sku: 'FAKE1232132113123'
}
],
- :currency => 'USD'
+ currency: 'USD'
}
@subscription_options = {
- :order_id => generate_unique_id,
- :credit_card => @credit_card,
- :setup_fee => 100,
- :subscription => {
- :frequency => 'weekly',
- :start_date => Date.today.next_week,
- :occurrences => 4,
- :automatic_renew => true,
- :amount => 100
+ order_id: generate_unique_id,
+ credit_card: @credit_card,
+ setup_fee: 100,
+ subscription: {
+ frequency: 'weekly',
+ start_date: Date.today.next_week,
+ occurrences: 4,
+ automatic_renew: true,
+ amount: 100
}
}
@@ -90,7 +90,7 @@ def test_purchase_includes_customer_ip
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|
+ 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
@@ -98,15 +98,95 @@ def test_purchase_includes_issuer_additional_data
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')
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/field2>CustomValue2.*field3>CustomValue3181537<\/reconciliationID>/, data)
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_merchant_description
+ stub_comms do
+ @gateway.authorize(100, @credit_card, merchant_descriptor_name: 'Test Name', merchant_descriptor_address1: '123 Main Dr', merchant_descriptor_locality: 'Durham')
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(%r(.*Test Name .* )m, data)
+ assert_match(%r(.*123 Main Dr .* )m, data)
+ assert_match(%r(.*Durham .* )m, data)
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_allows_nil_values_in_billing_address
+ billing_address = {
+ address1: '123 Fourth St',
+ city: 'Fiveton',
+ state: '',
+ country: 'CA'
+ }
+
+ stub_comms do
+ @gateway.authorize(100, @credit_card, billing_address: billing_address)
+ end.check_request do |_endpoint, data, _headers|
+ assert_nil billing_address[:zip]
+ assert_nil billing_address[:phone]
+ assert_match(%r(.*123 Fourth St .* )m, data)
+ assert_match(%r(.*Fiveton .* )m, data)
+ assert_match(%r(.*NC .* )m, data)
+ assert_match(%r(.*00000 .* )m, data)
+ assert_match(%r(.*CA .* )m, data)
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_uses_names_from_billing_address_if_present
+ name = 'Wesley Crusher'
+
+ stub_comms do
+ @gateway.authorize(100, @credit_card, billing_address: { name: name })
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(%r(.*Wesley .* )m, data)
+ assert_match(%r(.*Crusher .* )m, data)
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_uses_names_from_shipping_address_if_present
+ name = 'Wesley Crusher'
+
+ stub_comms do
+ @gateway.authorize(100, @credit_card, shipping_address: { name: name })
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(%r(.*Wesley .* )m, data)
+ assert_match(%r(.*Crusher .* )m, data)
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_uses_names_from_the_payment_method
+ stub_comms do
+ @gateway.authorize(100, @credit_card)
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(%r(.*#{@credit_card.first_name} .* )m, data)
+ assert_match(%r(.*#{@credit_card.last_name} .* )m, data)
+ assert_match(%r(.*#{@credit_card.first_name} .* )m, data)
+ assert_match(%r(.*#{@credit_card.last_name} .* )m, data)
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_purchase_includes_merchant_descriptor
+ stub_comms do
+ @gateway.purchase(100, @credit_card, merchant_descriptor: 'Spreedly')
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(/Spreedly<\/merchantDescriptor>/, data)
+ 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|
+ 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
@@ -114,19 +194,35 @@ def test_authorize_includes_issuer_additional_data
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')
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/field2>CustomValue2.*field3>CustomValue3181537<\/reconciliationID>/, data)
+ 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|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/internet<\/commerceIndicator>/m, data)
end.respond_with(successful_authorization_response)
end
+ def test_authorize_includes_installment_total_count
+ stub_comms do
+ @gateway.authorize(100, @credit_card, order_id: '1', installment_total_count: 5)
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(/\s+5<\/totalCount>\s+<\/installment>/, data)
+ end.respond_with(successful_authorization_response)
+ end
+
def test_successful_check_purchase
@gateway.expects(:ssl_post).returns(successful_purchase_response)
@@ -140,7 +236,7 @@ def test_successful_check_purchase
def test_successful_pinless_debit_card_purchase
@gateway.expects(:ssl_post).returns(successful_purchase_response)
- assert response = @gateway.purchase(@amount, @credit_card, @options.merge(:pinless_debit_card => true))
+ assert response = @gateway.purchase(@amount, @credit_card, @options.merge(pinless_debit_card: true))
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
@@ -148,20 +244,19 @@ def test_successful_pinless_debit_card_purchase
end
def test_successful_credit_cart_purchase_single_request_ignore_avs
- @gateway.expects(:ssl_post).with do |host, request_body|
+ @gateway.expects(:ssl_post).with do |_host, request_body|
assert_match %r'true ', request_body
assert_not_match %r'', request_body
true
end.returns(successful_purchase_response)
- assert response = @gateway.purchase(@amount, @credit_card, @options.merge(
- ignore_avs: true
- ))
+ options = @options.merge(ignore_avs: true)
+ assert response = @gateway.purchase(@amount, @credit_card, options)
assert_success response
end
def test_successful_credit_cart_purchase_single_request_without_ignore_avs
- @gateway.expects(:ssl_post).with do |host, request_body|
+ @gateway.expects(:ssl_post).with do |_host, request_body|
assert_not_match %r'', request_body
assert_not_match %r'', request_body
true
@@ -170,35 +265,34 @@ def test_successful_credit_cart_purchase_single_request_without_ignore_avs
# globally ignored AVS for gateway instance:
@gateway.options[:ignore_avs] = true
- assert response = @gateway.purchase(@amount, @credit_card, @options.merge(
- ignore_avs: false
- ))
+ options = @options.merge(ignore_avs: false)
+ assert response = @gateway.purchase(@amount, @credit_card, options)
assert_success response
end
def test_successful_credit_cart_purchase_single_request_ignore_ccv
- @gateway.expects(:ssl_post).with do |host, request_body|
+ @gateway.expects(:ssl_post).with do |_host, request_body|
assert_not_match %r'', request_body
assert_match %r'true ', request_body
true
end.returns(successful_purchase_response)
assert response = @gateway.purchase(@amount, @credit_card, @options.merge(
- ignore_cvv: true
- ))
+ ignore_cvv: true
+ ))
assert_success response
end
def test_successful_credit_cart_purchase_single_request_without_ignore_ccv
- @gateway.expects(:ssl_post).with do |host, request_body|
+ @gateway.expects(:ssl_post).with do |_host, request_body|
assert_not_match %r'', request_body
assert_not_match %r'', request_body
true
end.returns(successful_purchase_response)
assert response = @gateway.purchase(@amount, @credit_card, @options.merge(
- ignore_cvv: false
- ))
+ ignore_cvv: false
+ ))
assert_success response
end
@@ -263,6 +357,22 @@ def test_successful_credit_card_capture_request
assert response_capture.test?
end
+ def test_capture_includes_local_tax_amount
+ stub_comms do
+ @gateway.capture(100, '1842651133440156177166', local_tax_amount: '0.17')
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(/\s+0.17<\/localTaxAmount>\s+<\/otherTax>/, data)
+ end.respond_with(successful_capture_response)
+ end
+
+ def test_capture_includes_national_tax_amount
+ stub_comms do
+ @gateway.capture(100, '1842651133440156177166', national_tax_amount: '0.05')
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(/\s+0.05<\/nationalTaxAmount>\s+<\/otherTax>/, data)
+ end.respond_with(successful_capture_response)
+ 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)
@@ -273,6 +383,14 @@ def test_successful_credit_card_capture_with_elo_request
assert response_capture.test?
end
+ def test_capture_includes_mdd_fields
+ stub_comms do
+ @gateway.capture(100, '1846925324700976124593', order_id: '1', mdd_field_2: 'CustomValue2', mdd_field_3: 'CustomValue3')
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(/field2>CustomValue2.*field3>CustomValue3 generate_unique_id)
+ assert response = @gateway.unstore(response.authorization, order_id: generate_unique_id)
assert response.success?
assert response.test?
end
@@ -334,7 +452,7 @@ def test_successful_credit_card_retrieve_request
assert response = @gateway.store(@credit_card, @subscription_options)
assert response.success?
assert response.test?
- assert response = @gateway.retrieve(response.authorization, :order_id => generate_unique_id)
+ assert response = @gateway.retrieve(response.authorization, order_id: generate_unique_id)
assert response.success?
assert response.test?
end
@@ -373,6 +491,14 @@ def test_successful_credit_to_card_request
assert_success(@gateway.credit(@amount, @credit_card, @options))
end
+ def test_authorization_under_review_request
+ @gateway.stubs(:ssl_post).returns(authorization_review_response)
+
+ assert_failure(response = @gateway.authorize(@amount, @credit_card, @options))
+ assert response.fraud_review?
+ assert_equal(response.authorization, "#{@options[:order_id]};#{response.params['requestID']};#{response.params['requestToken']};authorize;100;USD;")
+ end
+
def test_successful_credit_to_subscription_request
@gateway.stubs(:ssl_post).returns(successful_create_subscription_response, successful_subscription_credit_response)
@@ -382,22 +508,78 @@ def test_successful_credit_to_subscription_request
assert_success(@gateway.credit(@amount, response.authorization, @options))
end
+ def test_credit_includes_merchant_descriptor
+ stub_comms do
+ @gateway.credit(@amount, @credit_card, merchant_descriptor: 'Spreedly')
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(/Spreedly<\/merchantDescriptor>/, data)
+ end.respond_with(successful_card_credit_response)
+ end
+
+ def test_credit_includes_issuer_additional_data
+ stub_comms do
+ @gateway.credit(@amount, @credit_card, 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_card_credit_response)
+ end
+
+ def test_credit_includes_mdd_fields
+ stub_comms do
+ @gateway.credit(@amount, @credit_card, mdd_field_2: 'CustomValue2', mdd_field_3: 'CustomValue3')
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(/field2>CustomValue2.*field3>CustomValue3\s+#{@issuer_additional_data}<\/additionalData>\s+<\/issuer>/m, data)
+ end.respond_with(successful_void_response)
+ end
+
+ def test_void_includes_mdd_fields
+ authorization = '1000;1842651133440156177166;AP4JY+Or4xRonEAOERAyMzQzOTEzMEM0MFZaNUZCBgDH3fgJ8AEGAMfd+AnwAwzRpAAA7RT/;authorize;100;USD;'
+
+ stub_comms do
+ @gateway.void(authorization, mdd_field_2: 'CustomValue2', mdd_field_3: 'CustomValue3')
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(/field2>CustomValue2.*field3>CustomValue31.00<\/amount>), data
end.respond_with(successful_update_subscription_response)
end
@@ -448,11 +630,10 @@ def test_unsuccessful_verify
def test_successful_auth_with_network_tokenization_for_visa
credit_card = network_tokenization_credit_card('4111111111111111',
- :brand => 'visa',
- :transaction_id => '123',
- :eci => '05',
- :payment_cryptogram => '111111111100cryptogram'
- )
+ brand: 'visa',
+ transaction_id: '123',
+ eci: '05',
+ payment_cryptogram: '111111111100cryptogram')
response = stub_comms do
@gateway.authorize(@amount, credit_card, @options)
@@ -466,116 +647,196 @@ def test_successful_auth_with_network_tokenization_for_visa
def test_successful_purchase_with_network_tokenization_for_visa
credit_card = network_tokenization_credit_card('4111111111111111',
- :brand => 'visa',
- :transaction_id => '123',
- :eci => '05',
- :payment_cryptogram => '111111111100cryptogram'
- )
+ brand: 'visa',
+ transaction_id: '123',
+ eci: '05',
+ payment_cryptogram: '111111111100cryptogram')
response = stub_comms do
@gateway.purchase(@amount, credit_card, @options)
end.check_request do |_endpoint, body, _headers|
assert_xml_valid_to_xsd(body)
- assert_match %r'.+? 'm, body
+ assert_match %r'.+?'m, body
end.respond_with(successful_purchase_response)
assert_success response
end
def test_successful_auth_with_network_tokenization_for_mastercard
- @gateway.expects(:ssl_post).with do |host, request_body|
+ @gateway.expects(:ssl_post).with do |_host, request_body|
assert_xml_valid_to_xsd(request_body)
assert_match %r'\n 111111111100cryptogram \n 2 \n \n\n spa \n \n\n 1 \n ', request_body
true
end.returns(successful_purchase_response)
credit_card = network_tokenization_credit_card('5555555555554444',
- :brand => 'master',
- :transaction_id => '123',
- :eci => '05',
- :payment_cryptogram => '111111111100cryptogram'
- )
+ brand: 'master',
+ transaction_id: '123',
+ eci: '05',
+ payment_cryptogram: '111111111100cryptogram')
assert response = @gateway.authorize(@amount, credit_card, @options)
assert_success response
end
def test_successful_auth_with_network_tokenization_for_amex
- @gateway.expects(:ssl_post).with do |host, request_body|
+ @gateway.expects(:ssl_post).with do |_host, request_body|
assert_xml_valid_to_xsd(request_body)
assert_match %r'\n MTExMTExMTExMTAwY3J5cHRvZ3I=\n \n aesk \n YW0=\n \n \n\n 1 \n ', request_body
true
end.returns(successful_purchase_response)
credit_card = network_tokenization_credit_card('378282246310005',
- :brand => 'american_express',
- :transaction_id => '123',
- :eci => '05',
- :payment_cryptogram => Base64.encode64('111111111100cryptogram')
- )
+ brand: 'american_express',
+ transaction_id: '123',
+ eci: '05',
+ payment_cryptogram: Base64.encode64('111111111100cryptogram'))
assert response = @gateway.authorize(@amount, credit_card, @options)
assert_success response
end
- def test_successful_auth_first_unscheduled_stored_cred
- @gateway.stubs(:ssl_post).returns(successful_authorization_response)
+ def test_cof_first
@options[:stored_credential] = {
- :initiator => 'cardholder',
- :reason_type => 'unscheduled',
- :initial_transaction => true,
- :network_transaction_id => ''
+ initiator: 'cardholder',
+ reason_type: '',
+ initial_transaction: true,
+ network_transaction_id: ''
}
- assert response = @gateway.authorize(@amount, @credit_card, @options)
- assert_equal Response, response.class
+ @options[:commerce_indicator] = 'internet'
+ response = stub_comms do
+ @gateway.authorize(@amount, @credit_card, @options)
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(/\true/, data)
+ assert_not_match(/\true/, data)
+ assert_not_match(/\/, data)
+ assert_not_match(/\/, data)
+ assert_match(/\internet/, data)
+ end.respond_with(successful_authorization_response)
assert response.success?
- assert response.test?
end
- def test_successful_auth_subsequent_unscheduled_stored_cred
- @gateway.stubs(:ssl_post).returns(successful_authorization_response)
+ def test_cof_cit_auth
@options[:stored_credential] = {
- :initiator => 'merchant',
- :reason_type => 'unscheduled',
- :initial_transaction => false,
- :network_transaction_id => '016150703802094'
+ initiator: 'cardholder',
+ reason_type: 'unscheduled',
+ initial_transaction: false,
+ network_transaction_id: ''
}
- assert response = @gateway.authorize(@amount, @credit_card, @options)
- assert_equal Response, response.class
+ response = stub_comms do
+ @gateway.authorize(@amount, @credit_card, @options)
+ end.check_request do |_endpoint, data, _headers|
+ assert_not_match(/\/, data)
+ assert_match(/\/, data)
+ assert_not_match(/\/, data)
+ assert_not_match(/\/, data)
+ end.respond_with(successful_authorization_response)
assert response.success?
- assert response.test?
end
- def test_successful_auth_first_recurring_stored_cred
- @gateway.stubs(:ssl_post).returns(successful_authorization_response)
+ def test_cof_unscheduled_mit_auth
@options[:stored_credential] = {
- :initiator => 'cardholder',
- :reason_type => 'recurring',
- :initial_transaction => true,
- :network_transaction_id => ''
+ 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
+ response = stub_comms do
+ @gateway.authorize(@amount, @credit_card, @options)
+ end.check_request do |_endpoint, data, _headers|
+ assert_not_match(/\/, data)
+ assert_match(/\true/, data)
+ assert_match(/\true/, data)
+ assert_match(/\016150703802094/, data)
+ end.respond_with(successful_authorization_response)
assert response.success?
- assert response.test?
end
- def test_successful_auth_subsequent_recurring_stored_cred
- @gateway.stubs(:ssl_post).returns(successful_authorization_response)
+ def test_cof_installment_mit_auth
@options[:stored_credential] = {
- :initiator => 'merchant',
- :reason_type => 'recurring',
- :initial_transaction => false,
- :network_transaction_id => '016150703802094'
+ initiator: 'merchant',
+ reason_type: 'installment',
+ initial_transaction: false,
+ network_transaction_id: '016150703802094'
}
- assert response = @gateway.authorize(@amount, @credit_card, @options)
- assert_equal Response, response.class
+ response = stub_comms do
+ @gateway.authorize(@amount, @credit_card, @options)
+ end.check_request do |_endpoint, data, _headers|
+ assert_not_match(/\/, data)
+ assert_not_match(/\/, data)
+ assert_match(/\true/, data)
+ assert_match(/\016150703802094/, data)
+ assert_match(/\install/, data)
+ end.respond_with(successful_authorization_response)
+ assert response.success?
+ end
+
+ def test_cof_recurring_mit_auth
+ @options[:stored_credential] = {
+ initiator: 'merchant',
+ reason_type: 'recurring',
+ initial_transaction: false,
+ network_transaction_id: '016150703802094'
+ }
+ response = stub_comms do
+ @gateway.authorize(@amount, @credit_card, @options)
+ end.check_request do |_endpoint, data, _headers|
+ assert_not_match(/\/, data)
+ assert_not_match(/\/, data)
+ assert_match(/\true/, data)
+ assert_match(/\016150703802094/, data)
+ assert_match(/\recurring/, data)
+ end.respond_with(successful_authorization_response)
+ assert response.success?
+ end
+
+ def test_cof_recurring_mit_purchase
+ @options[:stored_credential] = {
+ initiator: 'merchant',
+ reason_type: 'recurring',
+ initial_transaction: false,
+ network_transaction_id: '016150703802094'
+ }
+ response = stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options)
+ end.check_request do |_endpoint, data, _headers|
+ assert_not_match(/\/, data)
+ assert_not_match(/\/, data)
+ assert_match(/\true/, data)
+ assert_match(/\016150703802094/, data)
+ assert_match(/\recurring/, data)
+ end.respond_with(successful_purchase_response)
+ assert response.success?
+ end
+
+ def test_cof_first_with_overrides
+ @options[:stored_credential] = {
+ initiator: 'cardholder',
+ reason_type: '',
+ initial_transaction: true,
+ network_transaction_id: ''
+ }
+ @options[:stored_credential_overrides] = {
+ subsequent_auth: 'true',
+ subsequent_auth_first: 'false',
+ subsequent_auth_stored_credential: 'true',
+ subsequent_auth_transaction_id: '54321'
+ }
+ @options[:commerce_indicator] = 'internet'
+ response = stub_comms do
+ @gateway.authorize(@amount, @credit_card, @options)
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(/\false/, data)
+ assert_match(/\true/, data)
+ assert_match(/\true/, data)
+ assert_match(/\54321/, data)
+ assert_match(/\internet/, data)
+ end.respond_with(successful_authorization_response)
assert response.success?
- assert response.test?
end
def test_nonfractional_currency_handling
- @gateway.expects(:ssl_post).with do |host, request_body|
+ @gateway.expects(:ssl_post).with do |_host, request_body|
assert_match %r(1 ), request_body
assert_match %r(JPY ), request_body
true
@@ -597,7 +858,7 @@ def test_malformed_xml_handling
def test_3ds_enroll_response
purchase = stub_comms do
@gateway.purchase(@amount, @credit_card, @options.merge(payer_auth_enroll_service: true))
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/\/, data)
end.respond_with(threedeesecure_purchase_response)
@@ -610,7 +871,7 @@ def test_3ds_enroll_response
def test_3ds_validate_response
validation = stub_comms do
@gateway.purchase(@amount, @credit_card, @options.merge(payer_auth_validate_service: true, pares: 'ABC123'))
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/\/, data)
assert_match(/\ABC123\<\/signedPARes\>/, data)
end.respond_with(successful_threedeesecure_validate_response)
@@ -618,13 +879,25 @@ def test_3ds_validate_response
assert_success validation
end
+ def test_adds_3ds_brand_based_commerce_indicator
+ %w(visa maestro master american_express jcb discover diners_club).each do |brand|
+ @credit_card.brand = brand
+
+ stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options.merge(three_d_secure: { cavv: 'anything but empty' }))
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(/commerceIndicator\>#{CyberSourceGateway::ECI_BRAND_MAPPING[brand.to_sym]}, data)
+ end.respond_with(successful_purchase_response)
+ end
+ end
+
def test_adds_3ds2_fields_via_normalized_hash
version = '2.0'
eci = '05'
cavv = '637574652070757070792026206b697474656e73'
cavv_algorithm = 2
ds_transaction_id = '97267598-FAE6-48F2-8083-C23433990FBC'
- commerce_indicator = 'vbv'
+ commerce_indicator = 'commerce_indicator'
authentication_response_status = 'Y'
enrolled = 'Y'
options_with_normalized_3ds = @options.merge(
@@ -642,7 +915,7 @@ def test_adds_3ds2_fields_via_normalized_hash
stub_comms do
@gateway.purchase(@amount, @credit_card, options_with_normalized_3ds)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/#{eci}/, data)
assert_match(/#{cavv}/, data)
assert_match(/#{version}/, data)
@@ -654,13 +927,76 @@ def test_adds_3ds2_fields_via_normalized_hash
end.respond_with(successful_purchase_response)
end
+ def test_does_not_add_3ds2_fields_via_normalized_hash_when_cavv_and_commerce_indicator_absent
+ options = options_with_normalized_3ds(cavv: nil, commerce_indicator: nil)
+ stub_comms do
+ @gateway.purchase(@amount, @credit_card, options)
+ end.check_request do |_, data, _|
+ assert_not_match(/#{options[:three_d_secure][:eci]}, data)
+ assert_not_match(/#{options[:three_d_secure][:cavv]}, data)
+ assert_not_match(/#{options[:three_d_secure][:version]}, data)
+ assert_not_match(/#{options[:three_d_secure][:ds_transaction_id]}, data)
+ assert_not_match(/#{options[:three_d_secure][:authentication_response_status]}, data)
+ assert_not_match(/#{options[:three_d_secure][:cavv_algorithm]}, data)
+ assert_not_match(/#{options[:three_d_secure][:enrolled]}, data)
+ assert_not_match(/#{options[:commerce_indicator]}, data)
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_adds_3ds2_fields_via_normalized_hash_when_cavv_and_commerce_indicator_absent_and_commerce_indicator_not_inferred
+ @credit_card.brand = supported_cc_brand_without_inferred_commerce_indicator
+ assert_not_nil @credit_card.brand
+
+ options = options_with_normalized_3ds(cavv: nil, commerce_indicator: nil)
+ stub_comms do
+ @gateway.purchase(@amount, @credit_card, options)
+ end.check_request do |_, data, _|
+ assert_match(/#{options[:three_d_secure][:eci]}, data)
+ assert_match(/#{options[:three_d_secure][:version]}, data)
+ assert_match(/#{options[:three_d_secure][:ds_transaction_id]}, data)
+ assert_match(/#{options[:three_d_secure][:authentication_response_status]}, data)
+ assert_match(/#{options[:three_d_secure][:cavv_algorithm]}, data)
+ assert_match(/#{options[:three_d_secure][:enrolled]}, data)
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_adds_3ds2_fields_via_normalized_hash_when_cavv_absent_and_commerce_indicator_present
+ options = options_with_normalized_3ds(cavv: nil)
+ stub_comms do
+ @gateway.purchase(@amount, @credit_card, options)
+ end.check_request do |_, data, _|
+ assert_match(/#{options[:three_d_secure][:eci]}, data)
+ assert_match(/#{options[:three_d_secure][:version]}, data)
+ assert_match(/#{options[:three_d_secure][:ds_transaction_id]}, data)
+ assert_match(/#{options[:three_d_secure][:authentication_response_status]}, data)
+ assert_match(/#{options[:three_d_secure][:cavv_algorithm]}, data)
+ assert_match(/#{options[:three_d_secure][:enrolled]}, data)
+ assert_match(/#{options[:commerce_indicator]}, data)
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_adds_3ds2_fields_via_normalized_hash_when_cavv_present_and_commerce_indicator_absent
+ options = options_with_normalized_3ds(commerce_indicator: nil)
+ stub_comms do
+ @gateway.purchase(@amount, @credit_card, options)
+ end.check_request do |_, data, _|
+ assert_match(/#{options[:three_d_secure][:eci]}, data)
+ assert_match(/#{options[:three_d_secure][:cavv]}, data)
+ assert_match(/#{options[:three_d_secure][:version]}, data)
+ assert_match(/#{options[:three_d_secure][:ds_transaction_id]}, data)
+ assert_match(/#{options[:three_d_secure][:authentication_response_status]}, data)
+ assert_match(/#{options[:three_d_secure][:cavv_algorithm]}, data)
+ assert_match(/#{options[:three_d_secure][:enrolled]}, data)
+ end.respond_with(successful_purchase_response)
+ end
+
def test_adds_mastercard_3ds2_fields_via_normalized_hash
version = '2.0'
eci = '05'
cavv = '637574652070757070792026206b697474656e73'
cavv_algorithm = 1
ds_transaction_id = '97267598-FAE6-48F2-8083-C23433990FBC'
- commerce_indicator = 'spa'
+ commerce_indicator = 'commerce_indicator'
collection_indicator = 2
options_with_normalized_3ds = @options.merge(
three_d_secure: {
@@ -676,7 +1012,7 @@ def test_adds_mastercard_3ds2_fields_via_normalized_hash
stub_comms do
@gateway.purchase(@amount, @master_credit_card, options_with_normalized_3ds)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/#{eci}/, data)
assert_match(/#{cavv}/, data)
assert_match(/#{version}/, data)
@@ -687,6 +1023,100 @@ def test_adds_mastercard_3ds2_fields_via_normalized_hash
end.respond_with(successful_purchase_response)
end
+ def test_adds_mastercard_3ds2_default_collection_indicator
+ options_with_normalized_3ds = @options.merge(
+ three_d_secure: {
+ version: '2.0',
+ eci: '05',
+ cavv: '637574652070757070792026206b697474656e73',
+ ds_transaction_id: '97267598-FAE6-48F2-8083-C23433990FBC',
+ cavv_algorithm: 'vbv'
+ }
+ )
+
+ stub_comms do
+ @gateway.purchase(@amount, @master_credit_card, options_with_normalized_3ds)
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(/2/, data)
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_send_xid_for_3ds_1_regardless_of_cc_brand
+ options_with_normalized_3ds = @options.merge(
+ three_d_secure: {
+ eci: '05',
+ cavv: '637574652070757070792026206b697474656e73',
+ xid: 'this-is-an-xid',
+ ds_transaction_id: '97267598-FAE6-48F2-8083-C23433990FBC',
+ cavv_algorithm: 'vbv'
+ }
+ )
+
+ stub_comms do
+ @gateway.purchase(@amount, @elo_credit_card, options_with_normalized_3ds)
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(/this-is-an-xid/, data)
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_dont_send_cavv_as_xid_in_3ds2_for_mastercard
+ options_with_normalized_3ds = @options.merge(
+ three_d_secure: {
+ version: '2.0',
+ eci: '05',
+ cavv: '637574652070757070792026206b697474656e73',
+ xid: 'this-is-an-xid',
+ ds_transaction_id: '97267598-FAE6-48F2-8083-C23433990FBC',
+ cavv_algorithm: 'vbv'
+ }
+ )
+
+ stub_comms do
+ @gateway.purchase(@amount, @master_credit_card, options_with_normalized_3ds)
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(/this-is-an-xid/, data)
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_adds_cavv_as_xid_for_3ds2
+ cavv = '637574652070757070792026206b697474656e73'
+
+ options_with_normalized_3ds = @options.merge(
+ three_d_secure: {
+ version: '2.0',
+ eci: '05',
+ cavv: cavv,
+ ds_transaction_id: '97267598-FAE6-48F2-8083-C23433990FBC',
+ cavv_algorithm: 'vbv'
+ }
+ )
+
+ stub_comms do
+ @gateway.purchase(@amount, @credit_card, options_with_normalized_3ds)
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(/#{cavv}/, data)
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_does_not_add_cavv_as_xid_if_xid_is_present
+ options_with_normalized_3ds = @options.merge(
+ three_d_secure: {
+ version: '2.0',
+ eci: '05',
+ cavv: '637574652070757070792026206b697474656e73',
+ xid: 'this-is-an-xid',
+ ds_transaction_id: '97267598-FAE6-48F2-8083-C23433990FBC',
+ cavv_algorithm: 'vbv'
+ }
+ )
+
+ stub_comms do
+ @gateway.purchase(@amount, @credit_card, options_with_normalized_3ds)
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(/this-is-an-xid/, data)
+ end.respond_with(successful_purchase_response)
+ end
+
def test_scrub
assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed
end
@@ -709,8 +1139,125 @@ def test_does_not_throw_on_invalid_xml
assert_failure response
end
+ def test_address_email_has_a_default_when_email_option_is_empty
+ stub_comms do
+ @gateway.authorize(100, @credit_card, email: '')
+ end.check_request do |_endpoint, data, _headers|
+ assert_match('null@cybersource.com ', data)
+ end.respond_with(successful_capture_response)
+ end
+
+ def test_country_code_sent_as_default_when_submitted_as_empty_string
+ stub_comms do
+ @gateway.authorize(100, @credit_card, billing_address: { country: '' })
+ end.check_request do |_endpoint, data, _headers|
+ assert_match('US ', data)
+ end.respond_with(successful_capture_response)
+ end
+
+ def test_default_address_does_not_override_when_hash_keys_are_strings
+ stub_comms do
+ @gateway.authorize(100, @credit_card, billing_address: {
+ 'address1' => '221B Baker Street',
+ 'city' => 'London',
+ 'zip' => 'NW16XE',
+ 'country' => 'GB'
+ })
+ end.check_request do |_endpoint, data, _headers|
+ assert_match('221B Baker Street ', data)
+ assert_match('London ', data)
+ assert_match('NW16XE ', data)
+ assert_match('GB ', data)
+ end.respond_with(successful_capture_response)
+ end
+
+ def test_adds_application_id_as_partner_solution_id
+ partner_id = 'partner_id'
+ CyberSourceGateway.application_id = partner_id
+
+ stub_comms do
+ @gateway.authorize(100, @credit_card, @options)
+ end.check_request do |_endpoint, data, _headers|
+ assert_match("#{partner_id} ", data)
+ end.respond_with(successful_capture_response)
+ ensure
+ CyberSourceGateway.application_id = nil
+ end
+
+ def test_partner_solution_id_position_follows_schema
+ partner_id = 'partner_id'
+ CyberSourceGateway.application_id = partner_id
+
+ @options[:stored_credential] = {
+ initiator: 'cardholder',
+ reason_type: '',
+ initial_transaction: true,
+ network_transaction_id: ''
+ }
+ @options[:commerce_indicator] = 'internet'
+
+ stub_comms do
+ @gateway.authorize(100, @credit_card, @options)
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(" \n#{partner_id} \ntrue \n \n ", data)
+ end.respond_with(successful_capture_response)
+ ensure
+ CyberSourceGateway.application_id = nil
+ end
+
+ def test_missing_field
+ @gateway.expects(:ssl_post).returns(missing_field_response)
+
+ response = @gateway.purchase(@amount, credit_card, @options)
+
+ assert_failure response
+ assert_equal 'c:billTo/c:country', response.params['missingField']
+ end
+
+ def test_invalid_field
+ @gateway.expects(:ssl_post).returns(invalid_field_response)
+
+ response = @gateway.purchase(@amount, credit_card, @options)
+
+ assert_failure response
+ assert_equal 'c:billTo/c:postalCode', response.params['invalidField']
+ end
+
private
+ def options_with_normalized_3ds(
+ cavv: '637574652070757070792026206b697474656e73',
+ commerce_indicator: 'commerce_indicator'
+ )
+ xid = 'Y2FyZGluYWxjb21tZXJjZWF1dGg='
+ authentication_response_status = 'Y'
+ cavv_algorithm = 2
+ collection_indicator = 2
+ ds_transaction_id = '97267598-FAE6-48F2-8083-C23433990FBC'
+ eci = '05'
+ enrolled = 'Y'
+ version = '2.0'
+ @options.merge(
+ three_d_secure: {
+ version: version,
+ eci: eci,
+ xid: xid,
+ cavv: cavv,
+ ds_transaction_id: ds_transaction_id,
+ cavv_algorithm: cavv_algorithm,
+ enrolled: enrolled,
+ authentication_response_status: authentication_response_status
+ },
+ commerce_indicator: commerce_indicator,
+ collection_indicator: collection_indicator
+ ).compact
+ end
+
+ def supported_cc_brand_without_inferred_commerce_indicator
+ (ActiveMerchant::Billing::CyberSourceGateway.supported_cardtypes -
+ ActiveMerchant::Billing::CyberSourceGateway::ECI_BRAND_MAPPING.keys).first
+ end
+
def pre_scrubbed
<<-PRE_SCRUBBED
opening connection to ics2wstest.ic3.com:443...
@@ -760,26 +1307,26 @@ def post_scrubbed
end
def successful_purchase_response
- <<-XML
-
-
-2008-01-15T21:42:03.343Z b0a6cf9aa07f1a8495f89c364bbd6a9a 2004333231260008401927 ACCEPT 100 Afvvj7Ke2Fmsbq0wHFE2sM6R4GAptYZ0jwPSA+R9PhkyhFTb0KRjoE4+ynthZrG6tMBwjAtT USD 100 1.00 123456 Y Y M M 2008-01-15T21:42:03Z 00 U
+ <<~XML
+
+
+ 2008-01-15T21:42:03.343Z b0a6cf9aa07f1a8495f89c364bbd6a9a 2004333231260008401927 ACCEPT 100 Afvvj7Ke2Fmsbq0wHFE2sM6R4GAptYZ0jwPSA+R9PhkyhFTb0KRjoE4+ynthZrG6tMBwjAtT USD 100 1.00 123456 Y Y M M 2008-01-15T21:42:03Z 00 U
XML
end
def successful_authorization_response
- <<-XML
-
-
-2007-07-12T18:31:53.838Z TEST11111111111 1842651133440156177166 ACCEPT 100 AP4JY+Or4xRonEAOERAyMzQzOTEzMEM0MFZaNUZCBgDH3fgJ8AEGAMfd+AnwAwzRpAAA7RT/ USD 100 1.00 004542 A I7 2007-07-12T18:31:53Z 100 23439130C40VZ2FB
+ <<~XML
+
+
+ 2007-07-12T18:31:53.838Z TEST11111111111 1842651133440156177166 ACCEPT 100 AP4JY+Or4xRonEAOERAyMzQzOTEzMEM0MFZaNUZCBgDH3fgJ8AEGAMfd+AnwAwzRpAAA7RT/ USD 100 1.00 004542 A I7 2007-07-12T18:31:53Z 100 23439130C40VZ2FB
XML
end
def unsuccessful_authorization_response
- <<-XML
-
-
-2008-01-15T21:50:41.580Z a1efca956703a2a5037178a8a28f7357 2004338415330008402434 REJECT 231 Afvvj7KfIgU12gooCFE2/DanQIApt+G1OgTSA+R9PTnyhFTb0KRjgFY+ynyIFNdoKKAghwgx 231
+ <<~XML
+
+
+ 2008-01-15T21:50:41.580Z a1efca956703a2a5037178a8a28f7357 2004338415330008402434 REJECT 231 Afvvj7KfIgU12gooCFE2/DanQIApt+G1OgTSA+R9PTnyhFTb0KRjgFY+ynyIFNdoKKAghwgx 231
XML
end
@@ -842,10 +1389,10 @@ def unsuccessful_authorization_response_with_reply
end
def successful_tax_response
- <<-XML
-
-
-2007-07-11T18:27:56.314Z TEST11111111111 1841784762620176127166 ACCEPT 100 AMYJY9fl62i+vx2OEQYAx9zv/9UBZAAA5h5D 100 1.00 0 Madison 0 0 0 WI 0 53717 0
+ <<~XML
+
+
+ 2007-07-11T18:27:56.314Z TEST11111111111 1841784762620176127166 ACCEPT 100 AMYJY9fl62i+vx2OEQYAx9zv/9UBZAAA5h5D 100 1.00 0 Madison 0 0 0 WI 0 53717 0
XML
end
@@ -874,30 +1421,30 @@ def successful_delete_subscription_response
end
def successful_capture_response
- <<-XML
- 2007-07-17T17:15:32.642Z test1111111111111111 1846925324700976124593 ACCEPT 100 AP4JZB883WKS/34BEZAzMTE1OTI5MVQzWE0wQjEzBTUt3wbOAQUy3D7oDgMMmvQAnQgl GBP 100 2007-07-17T17:15:32Z 1.00 31159291T3XM2B13
+ <<~XML
+ 2007-07-17T17:15:32.642Z test1111111111111111 1846925324700976124593 ACCEPT 100 AP4JZB883WKS/34BEZAzMTE1OTI5MVQzWE0wQjEzBTUt3wbOAQUy3D7oDgMMmvQAnQgl GBP 100 2007-07-17T17:15:32Z 1.00 31159291T3XM2B13
XML
end
def successful_refund_response
- <<-XML
-
-
-2008-01-21T16:00:38.927Z TEST11111111111 2009312387810008401927 ACCEPT 100 Af/vj7OzPmut/eogHFCrBiwYsWTJy1r127CpCn0KdOgyTZnzKwVYCmzPmVgr9ID5H1WGTSTKuj0i30IE4+zsz2d/QNzwBwAACCPA USD 100 2008-01-21T16:00:38Z 1.00 010112295WW70TBOPSSP2
+ <<~XML
+
+
+ 2008-01-21T16:00:38.927Z TEST11111111111 2009312387810008401927 ACCEPT 100 Af/vj7OzPmut/eogHFCrBiwYsWTJy1r127CpCn0KdOgyTZnzKwVYCmzPmVgr9ID5H1WGTSTKuj0i30IE4+zsz2d/QNzwBwAACCPA USD 100 2008-01-21T16:00:38Z 1.00 010112295WW70TBOPSSP2
XML
end
def successful_card_credit_response
- <<-XML
-\n\n2019-05-16T20:25:05.234Z 329b25a4540e05c731a4fb16112e4c72 5580383051126990804008 ACCEPT 100 Ahj/7wSTLoNfMt0KyZQoGxDdm1ctGjlmo0/RdCA4BUafouhAdpAfJHYQyaSZbpAdvSeAnJl0GvmW6FZMoUAA/SE0 USD 100 2019-05-16T20:25:05Z 1.00 73594493 000123456789012 01234567
+ <<~XML
+ \n\n2019-05-16T20:25:05.234Z 329b25a4540e05c731a4fb16112e4c72 5580383051126990804008 ACCEPT 100 Ahj/7wSTLoNfMt0KyZQoGxDdm1ctGjlmo0/RdCA4BUafouhAdpAfJHYQyaSZbpAdvSeAnJl0GvmW6FZMoUAA/SE0 USD 100 2019-05-16T20:25:05Z 1.00 73594493 000123456789012 01234567
XML
end
def successful_subscription_credit_response
- <<-XML
-
-
-2008-01-21T16:00:38.927Z TEST11111111111 2009312387810008401927 ACCEPT 100 Af/vj7OzPmut/eogHFCrBiwYsWTJy1r127CpCn0KdOgyTZnzKwVYCmzPmVgr9ID5H1WGTSTKuj0i30IE4+zsz2d/QNzwBwAACCPA USD 100 2012-09-28T16:59:25Z 1.00 010112295WW70TBOPSSP2
+ <<~XML
+
+
+ 2008-01-21T16:00:38.927Z TEST11111111111 2009312387810008401927 ACCEPT 100 Af/vj7OzPmut/eogHFCrBiwYsWTJy1r127CpCn0KdOgyTZnzKwVYCmzPmVgr9ID5H1WGTSTKuj0i30IE4+zsz2d/QNzwBwAACCPA USD 100 2012-09-28T16:59:25Z 1.00 010112295WW70TBOPSSP2
XML
end
@@ -910,58 +1457,83 @@ def successful_retrieve_subscription_response
end
def successful_validate_pinless_debit_card
- <<-XML
-
-
-2013-05-13T13:52:57.159Z 6427013 3684531771310176056442 ACCEPT 100 AhijbwSRj3pM2QqPs2j0Ip+xoJXIsAMPYZNJMq6PSbs5ATAA6z42 100 2013-05-13T13:52:57Z Y
+ <<~XML
+
+
+ 2013-05-13T13:52:57.159Z 6427013 3684531771310176056442 ACCEPT 100 AhijbwSRj3pM2QqPs2j0Ip+xoJXIsAMPYZNJMq6PSbs5ATAA6z42 100 2013-05-13T13:52:57Z Y
XML
end
def successful_auth_reversal_response
- <<-XML
-
-
-2016-07-25T21:10:31.506Z 296805293329eea14917a8d04c63a0c4 4694810311256262804010 ACCEPT 100 Ahj//wSR/QMpn9U9RwRUIkG7Nm4cMm7KVRrS4tppCS5TonESgFLhgHRTp0gPkYP4ZNJMt0gO3pPFAnI/oGUyy27D1uIA+xVK USD 100 1.00 100 2016-07-25T21:10:31Z
+ <<~XML
+
+
+ 2016-07-25T21:10:31.506Z 296805293329eea14917a8d04c63a0c4 4694810311256262804010 ACCEPT 100 Ahj//wSR/QMpn9U9RwRUIkG7Nm4cMm7KVRrS4tppCS5TonESgFLhgHRTp0gPkYP4ZNJMt0gO3pPFAnI/oGUyy27D1uIA+xVK USD 100 1.00 100 2016-07-25T21:10:31Z
XML
end
def successful_void_response
- <<-XML
-
-
-2016-07-25T20:50:50.583Z bb3b1bb530192c9dd20f121686c91c40 4694798504476543904007 ACCEPT 100 Ahj//wSR/QLVu2z/GtIOIkG7Nm4bNW7KPRrRY0mvYS4YB0I7QFLgkgkAA0gAwfwyaSZbpAdvSeeBOR/QLVqII/qE+QAA3yVt USD 100 2016-07-25T20:50:50Z 1.00 usd
+ <<~XML
+
+
+ 2016-07-25T20:50:50.583Z bb3b1bb530192c9dd20f121686c91c40 4694798504476543904007 ACCEPT 100 Ahj//wSR/QLVu2z/GtIOIkG7Nm4bNW7KPRrRY0mvYS4YB0I7QFLgkgkAA0gAwfwyaSZbpAdvSeeBOR/QLVqII/qE+QAA3yVt USD 100 2016-07-25T20:50:50Z 1.00 usd
XML
end
def successful_nonfractional_authorization_response
- <<-XML
-
-
-2007-07-12T18:31:53.838Z TEST11111111111 1842651133440156177166 ACCEPT 100 AP4JY+Or4xRonEAOERAyMzQzOTEzMEM0MFZaNUZCBgDH3fgJ8AEGAMfd+AnwAwzRpAAA7RT/ JPY 100 1 004542 A I7 2007-07-12T18:31:53Z 100 23439130C40VZ2FB
+ <<~XML
+
+
+ 2007-07-12T18:31:53.838Z TEST11111111111 1842651133440156177166 ACCEPT 100 AP4JY+Or4xRonEAOERAyMzQzOTEzMEM0MFZaNUZCBgDH3fgJ8AEGAMfd+AnwAwzRpAAA7RT/ JPY 100 1 004542 A I7 2007-07-12T18:31:53Z 100 23439130C40VZ2FB
+ XML
+ end
+
+ def authorization_review_response
+ <<~XML
+
+
+ 2007-07-12T18:31:53.838Z TEST11111111111 1842651133440156177166 REVIEW 480 AP4JY+Or4xRonEAOERAyMzQzOTEzMEM0MFZaNUZCBgDH3fgJ8AEGAMfd+AnwAwzRpAAA7RT/ USD 100 1.00 004542 A I7 2007-07-12T18:31:53Z 100 23439130C40VZ2FB
XML
end
def malformed_xml_response
- <<-XML
-
-
-2008-01-15T21:42:03.343Z b0a6cf9aa07f1a8495f89c364bbd6a9a 2004333231260008401927 ACCEPT 100 Afvvj7Ke2Fmsbq0wHFE2sM6R4GAptYZ0jwPSA+R9PhkyhFTb0KRjoE4+ynthZrG6tMBwjAtT USD 100 1.00 123456 Y Y M M 2008-01-15T21:42:03Z 00 U
+ <<~XML
+
+
+ 2008-01-15T21:42:03.343Z b0a6cf9aa07f1a8495f89c364bbd6a9a 2004333231260008401927 ACCEPT 100 Afvvj7Ke2Fmsbq0wHFE2sM6R4GAptYZ0jwPSA+R9PhkyhFTb0KRjoE4+ynthZrG6tMBwjAtT USD 100 1.00 123456 Y Y M M 2008-01-15T21:42:03Z 00 U
XML
end
def threedeesecure_purchase_response
- <<-XML
-
-
-2017-10-17T20:39:27.392Z 1a5ba4804da54b384c6e8a2d8057ea99 5082727663166909004012 REJECT 475 AhjzbwSTE4kEGDR65zjsGwFLjtwzsJ0gXLJx6Xb0ky3SA7ek8AYA/A17 475 https://0eafstag.cardinalcommerce.com/EAFService/jsp/v1/redirect eNpVUe9PwjAQ/d6/ghA/r2tBYMvRBEUFFEKQEP1Yu1Om7gfdJoy/3nZsgk2a3Lveu757B+utRhw/oyo0CphjlskPbIXBsC25TvuPD/lkc3xn2d2R6y+3LWA5WuFOwA/qLExiwRzX4UAbSEwLrbYyzgVItbuZLkS353HWA1pDAhHq6Vgw3ule9/pAT5BALCMUqnwznZJCKwRaZQiopIhzXYpB1wXaAAKF/hbbPE8zn9L9fu9cUB2VREBtAQF6FrQsbJSZOQ9hIF7Xs1KNg6dVZzXdxGk0f1nc4+eslMfREKitIBDIHAV3WZ+Z2+Ku3/F8bjRXeQIysmrEFeOOa0yoIYHUfjQ6Icbt02XGTFRojbFqRmoQATykSYymxlD+YjPDWfntxBqrcusg8wbmWGcrXNFD4w3z2IkfVkZRy6H13mi9YhP9W/0vhyyqPw== 1198888 YTJycDdLR3RIVnpmMXNFejJyazA= <AuthProof><Time>2017 Oct 17 20:39:27</Time><DSUrl>https://csrtestcustomer34.cardinalcommerce.com/merchantacsfrontend/vereq.jsp?acqid=CYBS</DSUrl><VEReqProof><Message id="a2rp7KGtHVzf1sEz2rk0"><VEReq><version>1.0.2</version><pan>XXXXXXXXXXXX0002</pan><Merchant><acqBIN>469216</acqBIN><merID>1234567</merID></Merchant><Browser><deviceCategory>0</deviceCategory></Browser></VEReq></Message></VEReqProof><VEResProof><Message id="a2rp7KGtHVzf1sEz2rk0"><VERes><version>1.0.2</version><CH><enrolled>Y</enrolled><acctID>1198888</acctID></CH><url>https://testcustomer34.cardinalcommerce.com/merchantacsfrontend/pareq.jsp?vaa=b&gold=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA</url><protocol>ThreeDSecure</protocol></VERes></Message></VEResProof></AuthProof> Y ENROLLED
+ <<~XML
+
+
+ 2017-10-17T20:39:27.392Z 1a5ba4804da54b384c6e8a2d8057ea99 5082727663166909004012 REJECT 475 AhjzbwSTE4kEGDR65zjsGwFLjtwzsJ0gXLJx6Xb0ky3SA7ek8AYA/A17 475 https://0eafstag.cardinalcommerce.com/EAFService/jsp/v1/redirect eNpVUe9PwjAQ/d6/ghA/r2tBYMvRBEUFFEKQEP1Yu1Om7gfdJoy/3nZsgk2a3Lveu757B+utRhw/oyo0CphjlskPbIXBsC25TvuPD/lkc3xn2d2R6y+3LWA5WuFOwA/qLExiwRzX4UAbSEwLrbYyzgVItbuZLkS353HWA1pDAhHq6Vgw3ule9/pAT5BALCMUqnwznZJCKwRaZQiopIhzXYpB1wXaAAKF/hbbPE8zn9L9fu9cUB2VREBtAQF6FrQsbJSZOQ9hIF7Xs1KNg6dVZzXdxGk0f1nc4+eslMfREKitIBDIHAV3WZ+Z2+Ku3/F8bjRXeQIysmrEFeOOa0yoIYHUfjQ6Icbt02XGTFRojbFqRmoQATykSYymxlD+YjPDWfntxBqrcusg8wbmWGcrXNFD4w3z2IkfVkZRy6H13mi9YhP9W/0vhyyqPw== 1198888 YTJycDdLR3RIVnpmMXNFejJyazA= <AuthProof><Time>2017 Oct 17 20:39:27</Time><DSUrl>https://csrtestcustomer34.cardinalcommerce.com/merchantacsfrontend/vereq.jsp?acqid=CYBS</DSUrl><VEReqProof><Message id="a2rp7KGtHVzf1sEz2rk0"><VEReq><version>1.0.2</version><pan>XXXXXXXXXXXX0002</pan><Merchant><acqBIN>469216</acqBIN><merID>1234567</merID></Merchant><Browser><deviceCategory>0</deviceCategory></Browser></VEReq></Message></VEReqProof><VEResProof><Message id="a2rp7KGtHVzf1sEz2rk0"><VERes><version>1.0.2</version><CH><enrolled>Y</enrolled><acctID>1198888</acctID></CH><url>https://testcustomer34.cardinalcommerce.com/merchantacsfrontend/pareq.jsp?vaa=b&gold=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA</url><protocol>ThreeDSecure</protocol></VERes></Message></VEResProof></AuthProof> Y ENROLLED
XML
end
def successful_threedeesecure_validate_response
- <<-XML
-
-
-2018-05-01T14:28:36.773Z 23751b5aeb076ea5940c5b656284bf6a 5251849164756591904009 ACCEPT 100 Ahj//wSTHLQMXdtQnQUJGxDds0bNnDRoo0+VcdXMBUafKuOrnpAuWT9zDJpJlukB29J4YBpMctAxd21CdBQkwQ3g USD 100 12.02 831000 Y Y 2018-05-01T14:28:36Z 00 ZLIU5GM27GBP 0110322000000E10000200000000000000120205011428360272225A4C495535474D32374742503833313030303030000159004400103232415050524F56414C0022313457303136313530373033383032303934473036340006564943524120 100 2018-05-01T14:28:36Z 12.02 76466844 100 0 Success AAABAWFlmQAAAABjRWWZEEFgFz+= 2 vbv 05 05 S2R4eGtHbEZqbnozeGhBRHJ6QzA= Y
+ <<~XML
+
+
+ 2018-05-01T14:28:36.773Z 23751b5aeb076ea5940c5b656284bf6a 5251849164756591904009 ACCEPT 100 Ahj//wSTHLQMXdtQnQUJGxDds0bNnDRoo0+VcdXMBUafKuOrnpAuWT9zDJpJlukB29J4YBpMctAxd21CdBQkwQ3g USD 100 12.02 831000 Y Y 2018-05-01T14:28:36Z 00 ZLIU5GM27GBP 0110322000000E10000200000000000000120205011428360272225A4C495535474D32374742503833313030303030000159004400103232415050524F56414C0022313457303136313530373033383032303934473036340006564943524120 100 2018-05-01T14:28:36Z 12.02 76466844 100 0 Success AAABAWFlmQAAAABjRWWZEEFgFz+= 2 vbv 05 05 S2R4eGtHbEZqbnozeGhBRHJ6QzA= Y
+ XML
+ end
+
+ def missing_field_response
+ <<~XML
+
+
+ 2019-09-05T01:02:20.132Z 9y2A7XGxMSOUqppiEXkiN8T38Jj 5676453399086696204061 REJECT 101 c:billTo/c:country Ahjz7wSTM7ido1SNM4cdGwFRfPELvH+kE/QkEg+jLpJlXR6RuUgJMmZ3E7RqkaZw46AAniPV 101
+ XML
+ end
+
+ def invalid_field_response
+ <<~XML
+
+
+ 2019-09-05T14:10:46.665Z 5676926465076767004068 REJECT 102 c:billTo/c:postalCode AhjzbwSTM78uTleCsJWkEAJRqivRidukDssiQgRm0ky3SA7oegDUiwLm
+
XML
end
diff --git a/test/unit/gateways/d_local_test.rb b/test/unit/gateways/d_local_test.rb
index bb4d1df6aac..3946ea0003e 100644
--- a/test/unit/gateways/d_local_test.rb
+++ b/test/unit/gateways/d_local_test.rb
@@ -32,6 +32,18 @@ def test_failed_purchase
assert_equal '300', response.error_code
end
+ def test_purchase_with_installments
+ installments = '6'
+ installments_id = 'INS54434'
+
+ stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options.merge(installments: installments, installments_id: installments_id))
+ end.check_request do |_endpoint, data, _headers|
+ assert_equal installments, JSON.parse(data)['card']['installments']
+ assert_equal installments_id, JSON.parse(data)['card']['installments_id']
+ end.respond_with(successful_purchase_response)
+ end
+
def test_successful_authorize
@gateway.expects(:ssl_post).returns(successful_authorize_response)
@@ -50,14 +62,53 @@ def test_successful_authorize_without_address
assert_equal 'D-15104-be03e883-3e6b-497d-840e-54c8b6209bc3', response.authorization
end
+ def test_passing_billing_address
+ stub_comms(@gateway, :ssl_request) do
+ @gateway.authorize(@amount, @credit_card, @options)
+ end.check_request do |_method, _endpoint, data, _headers|
+ assert_match(/"state\":\"ON\"/, data)
+ assert_match(/"city\":\"Ottawa\"/, data)
+ assert_match(/"zip_code\":\"K1C2N6\"/, data)
+ assert_match(/"street\":\"My Street\"/, data)
+ assert_match(/"number\":\"456\"/, data)
+ end.respond_with(successful_authorize_response)
+ end
+
+ def test_passing_incomplete_billing_address
+ stub_comms(@gateway, :ssl_request) do
+ @gateway.authorize(@amount, @credit_card, @options.merge(billing_address: address(address1: 'Just a Street')))
+ end.check_request do |_method, _endpoint, data, _headers|
+ assert_match(/"state\":\"ON\"/, data)
+ assert_match(/"city\":\"Ottawa\"/, data)
+ assert_match(/"zip_code\":\"K1C2N6\"/, data)
+ assert_match(/"street\":\"Just a Street\"/, data)
+ end.respond_with(successful_authorize_response)
+ end
+
+ def test_passing_nil_address_1
+ stub_comms(@gateway, :ssl_request) do
+ @gateway.authorize(@amount, @credit_card, @options.merge(billing_address: address(address1: nil)))
+ end.check_request do |_method, _endpoint, data, _headers|
+ refute_match(/"street\"/, data)
+ end.respond_with(successful_authorize_response)
+ 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|
+ end.check_request do |_method, _endpoint, data, _headers|
assert_match(/"country\":\"CA\"/, data)
end.respond_with(successful_authorize_response)
end
+ def test_invalid_country
+ stub_comms(@gateway, :ssl_request) do
+ @gateway.authorize(@amount, @credit_card, @options.merge(billing_address: address(country: 'INVALID')))
+ end.check_request do |_method, _endpoint, data, _headers|
+ assert_match(/\"country\":null/, data)
+ end.respond_with(successful_authorize_response)
+ end
+
def test_failed_authorize
@gateway.expects(:ssl_post).returns(failed_authorize_response)
@@ -202,6 +253,10 @@ 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 successful_purchase_with_installments_response
+ '{"id":"D-4-e2227981-8ec8-48fd-8e9a-19fedb08d73a","amount":1000,"currency":"BRL","payment_method_id":"CARD","payment_method_type":"CARD","payment_method_flow":"DIRECT","country":"BR","card":{"holder_name":"Thiago Gabriel","expiration_month":10,"expiration_year":2040,"brand":"VI","last4":"1111"},"created_date":"2019-02-06T21:04:43.000+0000","approved_date":"2019-02-06T21:04:44.000+0000","status":"PAID","status_detail":"The payment was paid.","status_code":"200","order_id":"657434343","notification_url":"http://merchant.com/notifications"}'
+ 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
diff --git a/test/unit/gateways/data_cash_test.rb b/test/unit/gateways/data_cash_test.rb
index 9d8f8e8d46f..313f5ea71ea 100644
--- a/test/unit/gateways/data_cash_test.rb
+++ b/test/unit/gateways/data_cash_test.rb
@@ -3,8 +3,8 @@
class DataCashTest < Test::Unit::TestCase
def setup
@gateway = DataCashGateway.new(
- :login => 'LOGIN',
- :password => 'PASSWORD'
+ login: 'LOGIN',
+ password: 'PASSWORD'
)
@credit_card = credit_card('4242424242424242')
@@ -12,19 +12,19 @@ def setup
@amount = 100
@address = {
- :name => 'Mark McBride',
- :address1 => 'Flat 12/3',
- :address2 => '45 Main Road',
- :city => 'London',
- :state => 'None',
- :country => 'GBR',
- :zip => 'A987AA',
- :phone => '(555)555-5555'
+ name: 'Mark McBride',
+ address1: 'Flat 12/3',
+ address2: '45 Main Road',
+ city: 'London',
+ state: 'None',
+ country: 'GBR',
+ zip: 'A987AA',
+ phone: '(555)555-5555'
}
@options = {
- :order_id => generate_unique_id,
- :billing_address => @address
+ order_id: generate_unique_id,
+ billing_address: @address
}
end
@@ -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 ], DataCashGateway.supported_cardtypes
+ assert_equal %i[visa master american_express discover diners_club jcb maestro], DataCashGateway.supported_cardtypes
end
def test_purchase_with_missing_order_id_option
@@ -96,7 +96,7 @@ def test_authorize_with_missing_order_id_option
def test_purchase_does_not_raise_exception_with_missing_billing_address
@gateway.expects(:ssl_post).returns(successful_purchase_response)
- assert @gateway.authorize(100, @credit_card, {:order_id => generate_unique_id }).is_a?(ActiveMerchant::Billing::Response)
+ assert @gateway.authorize(100, @credit_card, { order_id: generate_unique_id }).is_a?(ActiveMerchant::Billing::Response)
end
def test_continuous_authority_purchase_with_missing_continuous_authority_reference
@@ -124,69 +124,69 @@ def test_capture_method_is_ecomm
private
def failed_purchase_response
- <<-XML
-
-
- NOT AUTHORISED
- Mastercard
- Japan
-
- 4500203037300784
- 85613a50952067796b1c6ab61c2cac
- TEST
- DECLINED
- 7
- 1363364315
-
+ <<~XML
+
+
+ NOT AUTHORISED
+ Mastercard
+ Japan
+
+ 4500203037300784
+ 85613a50952067796b1c6ab61c2cac
+ TEST
+ DECLINED
+ 7
+ 1363364315
+
XML
end
def successful_purchase_response
- <<-XML
-
-
-
-
- notprovided
-
- matched
- ACCEPTED
-
- notprovided
-
- 123456789
- Visa
- United Kingdom
-
- 4400200050664928
- 2d24cc91284c1ed5c65d8821f1e752c7
- TEST
- ACCEPTED
- 1
- 1196414665
-
+ <<~XML
+
+
+
+
+ notprovided
+
+ matched
+ ACCEPTED
+
+ notprovided
+
+ 123456789
+ Visa
+ United Kingdom
+
+ 4400200050664928
+ 2d24cc91284c1ed5c65d8821f1e752c7
+ TEST
+ ACCEPTED
+ 1
+ 1196414665
+
XML
end
def successful_purchase_using_continuous_authority_response
- <<-XML
-
-
- 123456789
- VISA Debit
- United Kingdom
- Barclays Bank PLC
-
-
- Using account ref 4500203037301241. CONT_AUTH transaction complete
-
- 4400200050664928
- 3fc2b05ab38b70f0eb3a6b6d35c0de
- TEST
- ACCEPTED
- 1
- 1363364966
-
+ <<~XML
+
+
+ 123456789
+ VISA Debit
+ United Kingdom
+ Barclays Bank PLC
+
+
+ Using account ref 4500203037301241. CONT_AUTH transaction complete
+
+ 4400200050664928
+ 3fc2b05ab38b70f0eb3a6b6d35c0de
+ TEST
+ ACCEPTED
+ 1
+ 1363364966
+
XML
end
@@ -196,62 +196,62 @@ def test_transcript_scrubbing
end
def pre_scrub
- <<-RAW
-opening connection to testserver.datacash.com:443...
-opened
-starting SSL for testserver.datacash.com:443...
-SSL established
-<- "POST /Transaction 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: testserver.datacash.com\r\nContent-Length: 1067\r\n\r\n"
-<- "\n\n \n 99626800 \n 9YM3DjUa6 \n \n \n \n auth \n \n 4539792100000003 \n 03/20 \n \n 444 \n \n \n \n \n \n \n \n \n \n d36e05ce3604313963854fca858d11 \n 1.98 \n ecomm \n \n \n \n"
--> "HTTP/1.1 200 OK\r\n"
--> "Date: Wed, 03 Jan 2018 21:24:38 GMT\r\n"
--> "Server: Apache\r\n"
--> "Connection: close\r\n"
--> "Transfer-Encoding: chunked\r\n"
--> "Content-Type: text/plain; charset=iso-8859-1\r\n"
--> "\r\n"
--> "559\r\n"
-reading 1369 bytes...
--> ""
--> "\n\n \n \n \n notchecked \n \n matched \n ACCEPTED \n \n notchecked \n \n 698899 \n VISA Debit \n United Kingdom \n Barclays Bank PLC \n 00 \n Approved or completed successfully \n D4B1B0558173CAE56E87293F9E9E899C8002F7B6 \n \n RBS \n 4700204504678897 \n d36e05ce3604313963854fca858d11 \n 99626800 \n TEST \n ACCEPTED \n 1 \n 1515014679 \n \n\n"
-read 1369 bytes
-reading 2 bytes...
--> ""
--> "\r\n"
-read 2 bytes
--> "0\r\n"
--> "\r\n"
-Conn close
+ <<~RAW
+ opening connection to testserver.datacash.com:443...
+ opened
+ starting SSL for testserver.datacash.com:443...
+ SSL established
+ <- "POST /Transaction 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: testserver.datacash.com\r\nContent-Length: 1067\r\n\r\n"
+ <- "\n\n \n 99626800 \n 9YM3DjUa6 \n \n \n \n auth \n \n 4539792100000003 \n 03/20 \n \n 444 \n \n \n \n \n \n \n \n \n \n d36e05ce3604313963854fca858d11 \n 1.98 \n ecomm \n \n \n \n"
+ -> "HTTP/1.1 200 OK\r\n"
+ -> "Date: Wed, 03 Jan 2018 21:24:38 GMT\r\n"
+ -> "Server: Apache\r\n"
+ -> "Connection: close\r\n"
+ -> "Transfer-Encoding: chunked\r\n"
+ -> "Content-Type: text/plain; charset=iso-8859-1\r\n"
+ -> "\r\n"
+ -> "559\r\n"
+ reading 1369 bytes...
+ -> ""
+ -> "\n\n \n \n \n notchecked \n \n matched \n ACCEPTED \n \n notchecked \n \n 698899 \n VISA Debit \n United Kingdom \n Barclays Bank PLC \n 00 \n Approved or completed successfully \n D4B1B0558173CAE56E87293F9E9E899C8002F7B6 \n \n RBS \n 4700204504678897 \n d36e05ce3604313963854fca858d11 \n 99626800 \n TEST \n ACCEPTED \n 1 \n 1515014679 \n \n\n"
+ read 1369 bytes
+ reading 2 bytes...
+ -> ""
+ -> "\r\n"
+ read 2 bytes
+ -> "0\r\n"
+ -> "\r\n"
+ Conn close
RAW
end
def post_scrub
- <<-SCRUBBED
-opening connection to testserver.datacash.com:443...
-opened
-starting SSL for testserver.datacash.com:443...
-SSL established
-<- "POST /Transaction 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: testserver.datacash.com\r\nContent-Length: 1067\r\n\r\n"
-<- "\n\n \n 99626800 \n [FILTERED] \n \n \n \n auth \n \n [FILTERED] \n 03/20 \n \n [FILTERED] \n \n \n \n \n \n \n \n \n \n d36e05ce3604313963854fca858d11 \n 1.98 \n ecomm \n \n \n \n"
--> "HTTP/1.1 200 OK\r\n"
--> "Date: Wed, 03 Jan 2018 21:24:38 GMT\r\n"
--> "Server: Apache\r\n"
--> "Connection: close\r\n"
--> "Transfer-Encoding: chunked\r\n"
--> "Content-Type: text/plain; charset=iso-8859-1\r\n"
--> "\r\n"
--> "559\r\n"
-reading 1369 bytes...
--> ""
--> "\n\n \n \n \n notchecked \n \n matched \n ACCEPTED \n \n notchecked \n \n 698899 \n VISA Debit \n United Kingdom \n Barclays Bank PLC \n 00 \n Approved or completed successfully \n D4B1B0558173CAE56E87293F9E9E899C8002F7B6 \n \n RBS \n 4700204504678897 \n d36e05ce3604313963854fca858d11 \n 99626800 \n TEST \n ACCEPTED \n 1 \n 1515014679 \n \n\n"
-read 1369 bytes
-reading 2 bytes...
--> ""
--> "\r\n"
-read 2 bytes
--> "0\r\n"
--> "\r\n"
-Conn close
+ <<~SCRUBBED
+ opening connection to testserver.datacash.com:443...
+ opened
+ starting SSL for testserver.datacash.com:443...
+ SSL established
+ <- "POST /Transaction 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: testserver.datacash.com\r\nContent-Length: 1067\r\n\r\n"
+ <- "\n\n \n 99626800 \n [FILTERED] \n \n \n \n auth \n \n [FILTERED] \n 03/20 \n \n [FILTERED] \n \n \n \n \n \n \n \n \n \n d36e05ce3604313963854fca858d11 \n 1.98 \n ecomm \n \n \n \n"
+ -> "HTTP/1.1 200 OK\r\n"
+ -> "Date: Wed, 03 Jan 2018 21:24:38 GMT\r\n"
+ -> "Server: Apache\r\n"
+ -> "Connection: close\r\n"
+ -> "Transfer-Encoding: chunked\r\n"
+ -> "Content-Type: text/plain; charset=iso-8859-1\r\n"
+ -> "\r\n"
+ -> "559\r\n"
+ reading 1369 bytes...
+ -> ""
+ -> "\n\n \n \n \n notchecked \n \n matched \n ACCEPTED \n \n notchecked \n \n 698899 \n VISA Debit \n United Kingdom \n Barclays Bank PLC \n 00 \n Approved or completed successfully \n D4B1B0558173CAE56E87293F9E9E899C8002F7B6 \n \n RBS \n 4700204504678897 \n d36e05ce3604313963854fca858d11 \n 99626800 \n TEST \n ACCEPTED \n 1 \n 1515014679 \n \n\n"
+ read 1369 bytes
+ reading 2 bytes...
+ -> ""
+ -> "\r\n"
+ read 2 bytes
+ -> "0\r\n"
+ -> "\r\n"
+ Conn close
SCRUBBED
end
end
diff --git a/test/unit/gateways/decidir_test.rb b/test/unit/gateways/decidir_test.rb
index de23333bfc4..3e822f28bcb 100644
--- a/test/unit/gateways/decidir_test.rb
+++ b/test/unit/gateways/decidir_test.rb
@@ -35,16 +35,85 @@ def test_successful_purchase_with_options
card_holder_birthday: '01011980',
card_holder_identification_type: 'dni',
card_holder_identification_number: '123456',
- installments: 12
+ establishment_name: 'Heavenly Buffaloes',
+ device_unique_identifier: '111',
+ fraud_detection: {
+ send_to_cs: false,
+ channel: 'Web',
+ dispatch_method: 'Store Pick Up',
+ csmdds: [
+ {
+ code: 17,
+ description: 'Campo MDD17'
+ }
+ ],
+ device_unique_id: '111'
+ },
+ installments: 12,
+ site_id: '99999999'
}
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.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"/
+ assert data =~ /"establishment_name":"Heavenly Buffaloes"/
+ assert data =~ /"site_id":"99999999"/
+ assert data =~ /"device_unique_identifier":"111"/
+ assert data =~ /"fraud_detection":{"send_to_cs":false,"channel":"Web","dispatch_method":"Store Pick Up","csmdds":\[{"code":17,"description":"Campo MDD17"}\],"device_unique_id":"111"}/
+ end.respond_with(successful_purchase_response)
+
+ assert_equal 7719132, response.authorization
+ assert_equal 'approved', response.message
+ assert response.test?
+ end
+
+ def test_successful_purchase_with_aggregate_data
+ options = {
+ aggregate_data: {
+ indicator: 1,
+ identification_number: '308103480',
+ bill_to_pay: 'test1',
+ bill_to_refund: 'test2',
+ merchant_name: 'Heavenly Buffaloes',
+ street: 'Sesame',
+ number: '123',
+ postal_code: '22001',
+ category: 'yum',
+ channel: '005',
+ geographic_code: 'C1234',
+ city: 'Ciudad de Buenos Aires',
+ merchant_id: 'dec_agg',
+ province: 'Buenos Aires',
+ country: 'Argentina',
+ merchant_email: 'merchant@mail.com',
+ merchant_phone: '2678433111'
+ }
+ }
+
+ 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 =~ /"aggregate_data":{"indicator":1/
+ assert data =~ /"identification_number":"308103480"/
+ assert data =~ /"bill_to_pay":"test1"/
+ assert data =~ /"bill_to_refund":"test2"/
+ assert data =~ /"merchant_name":"Heavenly Buffaloes"/
+ assert data =~ /"street":"Sesame"/
+ assert data =~ /"number":"123"/
+ assert data =~ /"postal_code":"22001"/
+ assert data =~ /"category":"yum"/
+ assert data =~ /"channel":"005"/
+ assert data =~ /"geographic_code":"C1234"/
+ assert data =~ /"city":"Ciudad de Buenos Aires"/
+ assert data =~ /"merchant_id":"dec_agg"/
+ assert data =~ /"province":"Buenos Aires"/
+ assert data =~ /"country":"Argentina"/
+ assert data =~ /"merchant_email":"merchant@mail.com"/
+ assert data =~ /"merchant_phone":"2678433111"/
end.respond_with(successful_purchase_response)
assert_equal 7719132, response.authorization
@@ -57,7 +126,7 @@ def test_failed_purchase
response = @gateway_for_purchase.purchase(@amount, @credit_card, @options)
assert_failure response
- assert_equal 'TARJETA INVALIDA', response.message
+ assert_equal 'TARJETA INVALIDA | invalid_number', response.message
assert_match Gateway::STANDARD_ERROR_CODE[:invalid_number], response.error_code
end
@@ -76,6 +145,22 @@ def test_failed_purchase_with_preauth_mode
end
end
+ def test_failed_purchase_error_response
+ @gateway_for_purchase.expects(:ssl_request).returns(unique_error_response)
+
+ response = @gateway_for_purchase.purchase(@amount, @credit_card, @options)
+ assert_failure response
+ assert_match 'invalid_request_error | invalid_param | payment_type', response.error_code
+ end
+
+ def test_failed_purchase_error_response_with_error_code
+ @gateway_for_purchase.expects(:ssl_request).returns(error_response_with_error_code)
+
+ response = @gateway_for_purchase.purchase(@amount, @credit_card, @options)
+ assert_failure response
+ assert_match '14, invalid_number', response.error_code
+ end
+
def test_successful_authorize
@gateway_for_auth.expects(:ssl_request).returns(successful_authorize_response)
@@ -94,7 +179,7 @@ def test_failed_authorize
assert_failure response
assert_equal 7719358, response.authorization
- assert_equal 'TARJETA INVALIDA', response.message
+ assert_equal 'TARJETA INVALIDA | invalid_number', response.message
assert response.test?
end
@@ -158,7 +243,7 @@ def test_successful_refund
def test_partial_refund
@gateway_for_purchase.expects(:ssl_request).returns(partial_refund_response)
- response = @gateway_for_purchase.refund(@amount-1, 81932, @options)
+ response = @gateway_for_purchase.refund(@amount - 1, 81932, @options)
assert_success response
assert_equal 81932, response.authorization
@@ -225,7 +310,7 @@ def test_failed_verify
response = @gateway_for_auth.verify(@credit_card, @options)
assert_failure response
- assert_equal 'TARJETA INVALIDA', response.message
+ assert_equal 'TARJETA INVALIDA | invalid_number', response.message
assert response.test?
end
@@ -246,6 +331,24 @@ def test_payment_method_id_with_visa
assert_equal 1, post[:payment_method_id]
end
+ def test_payment_method_id_with_mastercard
+ post = {}
+ @gateway_for_purchase.send(:add_auth_purchase_params, post, @amount, credit_card('5299910010000015'), @options)
+ assert_equal 104, post[:payment_method_id]
+ end
+
+ def test_payment_method_id_with_amex
+ post = {}
+ @gateway_for_purchase.send(:add_auth_purchase_params, post, @amount, credit_card('373953192351004'), @options)
+ assert_equal 65, post[:payment_method_id]
+ end
+
+ def test_payment_method_id_with_diners
+ post = {}
+ @gateway_for_purchase.send(:add_auth_purchase_params, post, @amount, credit_card('36463664750005'), @options)
+ assert_equal 8, post[:payment_method_id]
+ end
+
def test_payment_method_id_with_cabal
post = {}
credit_card = credit_card('5896570000000008')
@@ -260,6 +363,53 @@ def test_payment_method_id_with_naranja
assert_equal 24, post[:payment_method_id]
end
+ def test_payment_method_id_with_visa_debit
+ visa_debit_card = credit_card('4517721004856075')
+ debit_options = @options.merge(debit: true)
+
+ stub_comms(@gateway_for_purchase, :ssl_request) do
+ @gateway_for_purchase.purchase(@amount, visa_debit_card, debit_options)
+ end.check_request do |_method, _endpoint, data, _headers|
+ assert_match(/"payment_method_id":31/, data)
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_payment_method_id_with_mastercard_debit
+ # currently lacking a valid MasterCard debit card number, so using the MasterCard credit card number
+ mastercard = credit_card('5299910010000015')
+ debit_options = @options.merge(debit: true)
+
+ stub_comms(@gateway_for_purchase, :ssl_request) do
+ @gateway_for_purchase.purchase(@amount, mastercard, debit_options)
+ end.check_request do |_method, _endpoint, data, _headers|
+ assert_match(/"payment_method_id":105/, data)
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_payment_method_id_with_maestro_debit
+ # currently lacking a valid Maestro debit card number, so using a generated test card number
+ maestro_card = credit_card('6759649826438453')
+ debit_options = @options.merge(debit: true)
+
+ stub_comms(@gateway_for_purchase, :ssl_request) do
+ @gateway_for_purchase.purchase(@amount, maestro_card, debit_options)
+ end.check_request do |_method, _endpoint, data, _headers|
+ assert_match(/"payment_method_id":106/, data)
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_payment_method_id_with_cabal_debit
+ # currently lacking a valid Cabal debit card number, so using the Cabal credit card number
+ cabal_card = credit_card('5896570000000008')
+ debit_options = @options.merge(debit: true)
+
+ stub_comms(@gateway_for_purchase, :ssl_request) do
+ @gateway_for_purchase.purchase(@amount, cabal_card, debit_options)
+ end.check_request do |_method, _endpoint, data, _headers|
+ assert_match(/"payment_method_id":108/, data)
+ end.respond_with(successful_purchase_response)
+ end
+
private
def pre_scrubbed
@@ -281,7 +431,7 @@ def pre_scrubbed
-> "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\"}"
+ -> "{\"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\":{\"status\":null},\"aggregate_data\":null,\"establishment_name\":\"Heavenly Buffaloes\",\"spv\":null,\"confirmed\":null,\"pan\":\"345425f15b2c7c4584e0044357b6394d7e\",\"customer_token\":null,\"card_data\":\"/tokens/7721017\"}"
read 659 bytes
Conn close
)
@@ -306,7 +456,7 @@ def post_scrubbed
-> "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\"}"
+ -> "{\"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\":{\"status\":null},\"aggregate_data\":null,\"establishment_name\":\"Heavenly Buffaloes\",\"spv\":null,\"confirmed\":null,\"pan\":\"345425f15b2c7c4584e0044357b6394d7e\",\"customer_token\":null,\"card_data\":\"/tokens/7721017\"}"
read 659 bytes
Conn close
)
@@ -314,7 +464,7 @@ def post_scrubbed
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"}
+ {"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,"establishment_name":"Heavenly Buffaloes","first_installment_expiration_date":null,"payment_type":"single","sub_payments":[],"site_id":"99999999","fraud_detection":{"status":null},"aggregate_data":null,"establishment_name":null,"spv":null,"confirmed":null,"pan":"345425f15b2c7c4584e0044357b6394d7e","customer_token":null,"card_data":"/tokens/7719132"}
)
end
@@ -388,4 +538,16 @@ def failed_void_response
{"error_type":"not_found_error","entity_name":"","id":""}
)
end
+
+ def unique_error_response
+ %{
+ {\"error\":{\"error_type\":\"invalid_request_error\",\"validation_errors\":[{\"code\":\"invalid_param\",\"param\":\"payment_type\"}]}}
+ }
+ end
+
+ def error_response_with_error_code
+ %{
+ {\"error\":{\"type\":\"invalid_number\",\"reason\":{\"id\":14,\"description\":\"TARJETA INVALIDA\",\"additional_description\":\"\"}}}
+ }
+ end
end
diff --git a/test/unit/gateways/dibs_test.rb b/test/unit/gateways/dibs_test.rb
index af127ba0be8..0f639e4df34 100644
--- a/test/unit/gateways/dibs_test.rb
+++ b/test/unit/gateways/dibs_test.rb
@@ -62,7 +62,7 @@ def test_successful_authorize_and_capture
capture = stub_comms do
@gateway.capture(@amount, response.authorization)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/1066662996/, data)
end.respond_with(successful_capture_response)
@@ -97,7 +97,7 @@ def test_successful_void
void = stub_comms do
@gateway.void(response.authorization)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/1066662996/, data)
end.respond_with(successful_void_response)
@@ -107,7 +107,7 @@ def test_successful_void
def test_failed_void
response = stub_comms do
@gateway.void('5d53a33d960c46d00f5dc061947d998c')
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/5d53a33d960c46d00f5dc061947d998c/, data)
end.respond_with(failed_void_response)
@@ -124,7 +124,7 @@ def test_successful_refund
refund = stub_comms do
@gateway.refund(@amount, response.authorization)
- end.check_request do |endpoint, data, headers|
+ end.check_request do |_endpoint, data, _headers|
assert_match(/1066662996/, data)
end.respond_with(successful_refund_response)
diff --git a/test/unit/gateways/digitzs_test.rb b/test/unit/gateways/digitzs_test.rb
index 99b57ddc432..ef5b67a844b 100644
--- a/test/unit/gateways/digitzs_test.rb
+++ b/test/unit/gateways/digitzs_test.rb
@@ -38,8 +38,8 @@ def test_successful_purchase
def test_successful_card_split_purchase
response = stub_comms do
@gateway.purchase(@amount, @credit_card, @options_with_split)
- end.check_request do |endpoint, data, headers|
- if data =~ /"cardSplit"/
+ end.check_request do |_endpoint, data, _headers|
+ if /"cardSplit"/.match?(data)
assert_match(%r(split), data)
assert_match(%r("merchantId":"spreedly-susanswidg-32270590-2095203-148657924"), data)
end
@@ -52,8 +52,8 @@ def test_successful_card_split_purchase
def test_successful_token_split_purchase
response = stub_comms do
@gateway.purchase(@amount, @credit_card, @options_with_split)
- end.check_request do |endpoint, data, headers|
- if data =~ /"tokenSplit"/
+ end.check_request do |_endpoint, data, _headers|
+ if /"tokenSplit"/.match?(data)
assert_match(%r(split), data)
assert_match(%r("merchantId":"spreedly-susanswidg-32270590-2095203-148657924"), data)
end
@@ -103,7 +103,7 @@ def test_successful_store_creates_new_customer
@gateway.expects(:ssl_get).returns(customer_id_exists_response)
@gateway.expects(:ssl_post).times(3).returns(successful_app_token_response, successful_create_customer_response, successful_token_response)
- assert response = @gateway.store(@credit_card, @options.merge({customer_id: 'pre_existing_customer_id'}))
+ assert response = @gateway.store(@credit_card, @options.merge({ customer_id: 'pre_existing_customer_id' }))
assert_success response
assert_equal 'spreedly-susanswidg-32268973-2091076-148408385-2894006614343495-148710226|c0302d83-a694-4bec-9086-d1886b9eefd9-148710226', response.authorization
end
diff --git a/test/unit/gateways/ebanx_test.rb b/test/unit/gateways/ebanx_test.rb
index c5e93bc8e13..0b0bb76b24a 100644
--- a/test/unit/gateways/ebanx_test.rb
+++ b/test/unit/gateways/ebanx_test.rb
@@ -54,11 +54,20 @@ def test_successful_capture
response = @gateway.capture(@amount, 'authorization', @options)
assert_success response
-
- assert_equal 'Sandbox - Test credit card, transaction captured', response.message
+ assert_equal '5dee94502bd59660b801c441ad5a703f2c4123f5fc892ccb', response.authorization
+ assert_equal 'Accepted', response.message
assert response.test?
end
+ def test_failed_partial_capture
+ @gateway.expects(:ssl_request).returns(failed_partial_capture_response)
+
+ response = @gateway.capture(@amount, 'authorization', @options.merge(include_capture_amount: true))
+ assert_failure response
+ assert_equal 'BP-CAP-11', response.error_code
+ assert_equal 'Partial capture not available', response.message
+ end
+
def test_failed_capture
@gateway.expects(:ssl_request).returns(failed_capture_response)
@@ -157,7 +166,7 @@ def test_scrub
def pre_scrubbed
%q(
- request_body={\"integration_key\":\"1231000\",\"operation\":\"request\",\"payment\":{\"amount_total\":\"1.00\",\"currency_code\":\"USD\",\"merchant_payment_code\":\"2bed75b060e936834e354d944aeaa892\",\"name\":\"Longbob Longsen\",\"email\":\"unspecified@example.com\",\"document\":\"853.513.468-93\",\"payment_type_code\":\"visa\",\"creditcard\":{\"card_number\":\"4111111111111111\",\"card_name\":\"Longbob Longsen\",\"card_due_date\":\"9/2018\",\"card_cvv\":\"123\"},\"address\":\"Rua E\",\"street_number\":\"1040\",\"city\":\"Maracana\u{fa}\",\"state\":\"CE\",\"zipcode\":\"61919-230\",\"country\":\"BR\",\"phone_number\":\"(555)555-5555\"}}
+ request_body={\"integration_key\":\"Ac1EwnH0ud2UIndICS37l0\",\"operation\":\"request\",\"payment\":{\"amount_total\":\"1.00\",\"currency_code\":\"USD\",\"merchant_payment_code\":\"2bed75b060e936834e354d944aeaa892\",\"name\":\"Longbob Longsen\",\"email\":\"unspecified@example.com\",\"document\":\"853.513.468-93\",\"payment_type_code\":\"visa\",\"creditcard\":{\"card_number\":\"4111111111111111\",\"card_name\":\"Longbob Longsen\",\"card_due_date\":\"9/2018\",\"card_cvv\":\"123\"},\"address\":\"Rua E\",\"street_number\":\"1040\",\"city\":\"Maracana\u{fa}\",\"state\":\"CE\",\"zipcode\":\"61919-230\",\"country\":\"BR\",\"phone_number\":\"(555)555-5555\"}}
)
end
@@ -193,7 +202,13 @@ def failed_authorize_response
def successful_capture_response
%(
- {"payment":{"hash":"592dd65824427e4f5f50564c118f399869637bfb30d54f5b","pin":"081043654","merchant_payment_code":"8424e3000d64d056fbd58639957dc1c4","order_number":null,"status":"CO","status_date":"2017-05-30 17:30:16","open_date":"2017-05-30 17:30:15","confirm_date":"2017-05-30 17:30:16","transfer_date":null,"amount_br":"3.31","amount_ext":"1.00","amount_iof":"0.01","currency_rate":"3.3000","currency_ext":"USD","due_date":"2017-06-02","instalments":"1","payment_type_code":"visa","transaction_status":{"acquirer":"EBANX","code":"OK","description":"Sandbox - Test credit card, transaction captured"},"pre_approved":true,"capture_available":false,"customer":{"document":"85351346893","email":"unspecified@example.com","name":"LONGBOB LONGSEN","birth_date":null}},"status":"SUCCESS"}
+ {"payment":{"hash":"5dee94502bd59660b801c441ad5a703f2c4123f5fc892ccb","pin":"675968133","country":"br","merchant_payment_code":"b98b2892b80771b9dadf2ebc482cb65d","order_number":null,"status":"CO","status_date":"2019-12-09 18:37:05","open_date":"2019-12-09 18:37:04","confirm_date":"2019-12-09 18:37:05","transfer_date":null,"amount_br":"4.19","amount_ext":"1.00","amount_iof":"0.02","currency_rate":"4.1700","currency_ext":"USD","due_date":"2019-12-12","instalments":"1","payment_type_code":"visa","details":{"billing_descriptor":"DEMONSTRATION"},"transaction_status":{"acquirer":"EBANX","code":"OK","description":"Accepted"},"pre_approved":true,"capture_available":false,"customer":{"document":"85351346893","email":"unspecified@example.com","name":"LONGBOB LONGSEN","birth_date":null}},"status":"SUCCESS"}
+ )
+ end
+
+ def failed_partial_capture_response
+ %(
+ {"status":"ERROR", "status_code":"BP-CAP-11", "status_message":"Partial capture not available"}
)
end
diff --git a/test/unit/gateways/efsnet_test.rb b/test/unit/gateways/efsnet_test.rb
index e437e2aa422..15c79aecf1f 100644
--- a/test/unit/gateways/efsnet_test.rb
+++ b/test/unit/gateways/efsnet_test.rb
@@ -1,16 +1,15 @@
require 'test_helper'
class EfsnetTest < Test::Unit::TestCase
-
def setup
@gateway = EfsnetGateway.new(
- :login => 'LOGIN',
- :password => 'PASSWORD'
+ login: 'LOGIN',
+ password: 'PASSWORD'
)
@credit_card = credit_card('4242424242424242')
@amount = 100
- @options = { :order_id => 1, :billing_address => address }
+ @options = { order_id: 1, billing_address: address }
end
def test_successful_purchase
@@ -36,28 +35,28 @@ def test_unsuccessful_purchase
def test_credit
@gateway.expects(:ssl_post).with(anything, regexp_matches(/AccountNumber>#{@credit_card.number}<\/AccountNumber/), anything).returns('')
- @gateway.credit(@amount, @credit_card, :order_id => 5)
+ @gateway.credit(@amount, @credit_card, order_id: 5)
end
def test_deprecated_credit
@gateway.expects(:ssl_post).with(anything, regexp_matches(/transaction_id<\/OriginalTransactionID>/), anything).returns('')
assert_deprecation_warning(Gateway::CREDIT_DEPRECATION_MESSAGE) do
- @gateway.credit(@amount, 'transaction_id', :order_id => 5)
+ @gateway.credit(@amount, 'transaction_id', order_id: 5)
end
end
def test_refund
@gateway.expects(:ssl_post).with(anything, regexp_matches(/transaction_id<\/OriginalTransactionID>/), anything).returns('')
- @gateway.refund(@amount, 'transaction_id', :order_id => 5)
+ @gateway.refund(@amount, 'transaction_id', order_id: 5)
end
def test_authorize_is_valid_xml
params = {
- :order_id => 'order1',
- :transaction_amount => '1.01',
- :account_number => '4242424242424242',
- :expiration_month => '12',
- :expiration_year => '2029',
+ order_id: 'order1',
+ transaction_amount: '1.01',
+ account_number: '4242424242424242',
+ expiration_month: '12',
+ expiration_year: '2029'
}
assert data = @gateway.send(:post_data, :credit_card_authorize, params)
@@ -66,10 +65,10 @@ def test_authorize_is_valid_xml
def test_settle_is_valid_xml
params = {
- :order_id => 'order1',
- :transaction_amount => '1.01',
- :original_transaction_amount => '1.01',
- :original_transaction_id => '1',
+ order_id: 'order1',
+ transaction_amount: '1.01',
+ original_transaction_amount: '1.01',
+ original_transaction_id: '1'
}
assert data = @gateway.send(:post_data, :credit_card_settle, params)
@@ -93,48 +92,48 @@ def test_cvv_result
private
def successful_purchase_response
- <<-XML
-
-
-
- 0
- 00
- APPROVED
- 100018347764
- N
- M
- 123456
- 123456
- 080117
- 163222
- 1
- XXXXXXXXXXXX2224
- 1.00
-
-
+ <<~XML
+
+
+
+ 0
+ 00
+ APPROVED
+ 100018347764
+ N
+ M
+ 123456
+ 123456
+ 080117
+ 163222
+ 1
+ XXXXXXXXXXXX2224
+ 1.00
+
+
XML
end
def unsuccessful_purchase_response
- <<-XML
-
-
-
- 256
- 04
- DECLINED
- 100018347784
- N
-
-
-
- 080117
- 163946
- 1
- XXXXXXXXXXXX2224
- 1.56
-
-
+ <<~XML
+
+
+
+ 256
+ 04
+ DECLINED
+ 100018347784
+ N
+
+
+
+ 080117
+ 163946
+ 1
+ XXXXXXXXXXXX2224
+ 1.56
+
+
XML
end
end
diff --git a/test/unit/gateways/elavon_test.rb b/test/unit/gateways/elavon_test.rb
index 8900990d879..81919fe7959 100644
--- a/test/unit/gateways/elavon_test.rb
+++ b/test/unit/gateways/elavon_test.rb
@@ -5,25 +5,25 @@ class ElavonTest < Test::Unit::TestCase
def setup
@gateway = ElavonGateway.new(
- :login => 'login',
- :user => 'user',
- :password => 'password'
- )
+ login: 'login',
+ user: 'user',
+ password: 'password'
+ )
@multi_currency_gateway = ElavonGateway.new(
- :login => 'login',
- :user => 'user',
- :password => 'password',
- :multi_currency => true
- )
+ login: 'login',
+ user: 'user',
+ password: 'password',
+ multi_currency: true
+ )
@credit_card = credit_card
@amount = 100
@options = {
- :order_id => '1',
- :billing_address => address,
- :description => 'Store Purchase'
+ order_id: '1',
+ billing_address: address,
+ description: 'Store Purchase'
}
end
@@ -32,7 +32,7 @@ def test_successful_purchase
assert response = @gateway.purchase(@amount, @credit_card, @options)
assert_success response
- assert_equal '123456;00000000-0000-0000-0000-00000000000', response.authorization
+ assert_equal '093840;180820AD3-27AEE6EF-8CA7-4811-8D1F-E420C3B5041E', response.authorization
assert response.test?
end
@@ -43,8 +43,8 @@ def test_successful_authorization
assert_instance_of Response, response
assert_success response
- assert_equal '123456;00000000-0000-0000-0000-00000000000', response.authorization
- assert_equal 'APPROVED', response.message
+ assert_equal '259404;150920ED4-3EB7A2DF-A5A7-48E6-97B6-D98A9DC0BD59', response.authorization
+ assert_equal 'APPROVAL', response.message
assert response.test?
end
@@ -58,44 +58,44 @@ def test_failed_authorization
def test_successful_capture
@gateway.expects(:ssl_post).returns(successful_capture_response)
- authorization = '123456;00000000-0000-0000-0000-00000000000'
+ authorization = '070213;110820ED4-23CA2F2B-A88C-40E1-AC46-9219F800A520'
- assert response = @gateway.capture(@amount, authorization, :credit_card => @credit_card)
+ assert response = @gateway.capture(@amount, authorization, credit_card: @credit_card)
assert_instance_of Response, response
assert_success response
- assert_equal '123456;00000000-0000-0000-0000-00000000000', response.authorization
+ assert_equal '070213;110820ED4-23CA2F2B-A88C-40E1-AC46-9219F800A520', response.authorization
assert_equal 'APPROVAL', response.message
assert response.test?
end
def test_successful_capture_with_auth_code
@gateway.expects(:ssl_post).returns(successful_capture_response)
- authorization = '123456;00000000-0000-0000-0000-00000000000'
+ authorization = '070213;110820ED4-23CA2F2B-A88C-40E1-AC46-9219F800A520'
assert response = @gateway.capture(@amount, authorization)
assert_instance_of Response, response
assert_success response
- assert_equal '123456;00000000-0000-0000-0000-00000000000', response.authorization
+ assert_equal '070213;110820ED4-23CA2F2B-A88C-40E1-AC46-9219F800A520', response.authorization
assert_equal 'APPROVAL', response.message
assert response.test?
end
def test_successful_capture_with_additional_options
- authorization = '123456;00000000-0000-0000-0000-00000000000'
+ authorization = '070213;110820ED4-23CA2F2B-A88C-40E1-AC46-9219F800A520'
response = stub_comms do
- @gateway.capture(@amount, authorization, :test_mode => true, :partial_shipment_flag => true)
- end.check_request do |endpoint, data, headers|
- assert_match(/ssl_transaction_type=CCCOMPLETE/, data)
- assert_match(/ssl_test_mode=TRUE/, data)
- assert_match(/ssl_partial_shipment_flag=Y/, data)
+ @gateway.capture(@amount, authorization, test_mode: true, partial_shipment_flag: true)
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(/CCCOMPLETE<\/ssl_transaction_type>/, data)
+ assert_match(/TRUE<\/ssl_test_mode>/, data)
+ assert_match(/Y<\/ssl_partial_shipment_flag>/, data)
end.respond_with(successful_capture_response)
assert_instance_of Response, response
assert_success response
- assert_equal '123456;00000000-0000-0000-0000-00000000000', response.authorization
+ assert_equal '070213;110820ED4-23CA2F2B-A88C-40E1-AC46-9219F800A520', response.authorization
assert_equal 'APPROVAL', response.message
assert response.test?
end
@@ -104,8 +104,7 @@ def test_successful_purchase_with_ip
response = stub_comms do
@gateway.purchase(@amount, @credit_card, @options.merge(ip: '203.0.113.0'))
end.check_request do |_endpoint, data, _headers|
- parsed = CGI.parse(data)
- assert_equal ['203.0.113.0'], parsed['ssl_cardholder_ip']
+ assert_match(/203.0.113.0/, data)
end.respond_with(successful_purchase_response)
assert_success response
@@ -115,8 +114,37 @@ def test_successful_authorization_with_ip
response = stub_comms do
@gateway.authorize(@amount, @credit_card, @options.merge(ip: '203.0.113.0'))
end.check_request do |_endpoint, data, _headers|
- parsed = CGI.parse(data)
- assert_equal ['203.0.113.0'], parsed['ssl_cardholder_ip']
+ assert_match(/203.0.113.0<\/ssl_cardholder_ip>/, data)
+ end.respond_with(successful_authorization_response)
+
+ assert_success response
+ end
+
+ def test_successful_purchase_with_dynamic_dba
+ response = stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options.merge(dba: 'MANYMAG*BAKERS MONTHLY'))
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(/MANYMAG\*BAKERS MONTHLY<\/ssl_dynamic_dba>/, data)
+ end.respond_with(successful_purchase_response)
+
+ assert_success response
+ end
+
+ def test_successful_purchase_with_unscheduled
+ response = stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options.merge(merchant_initiated_unscheduled: 'Y'))
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(/Y<\/ssl_merchant_initiated_unscheduled>/, data)
+ end.respond_with(successful_purchase_response)
+
+ assert_success response
+ end
+
+ def test_successful_authorization_with_dynamic_dba
+ response = stub_comms do
+ @gateway.authorize(@amount, @credit_card, @options.merge(dba: 'MANYMAG*BAKERS MONTHLY'))
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(/MANYMAG\*BAKERS MONTHLY<\/ssl_dynamic_dba>/, data)
end.respond_with(successful_authorization_response)
assert_success response
@@ -124,9 +152,9 @@ def test_successful_authorization_with_ip
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)
+ @multi_currency_gateway.purchase(@amount, @credit_card, @options.merge(currency: 'JPY'))
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(/JPY<\/ssl_transaction_currency>/, data)
end.respond_with(successful_purchase_with_multi_currency_response)
assert_success response
@@ -135,7 +163,7 @@ def test_successful_purchase_with_multi_currency
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|
+ end.check_request do |_endpoint, data, _headers|
assert_no_match(/ssl_transaction_currency=EUR/, data)
end.respond_with(successful_purchase_response)
@@ -146,7 +174,7 @@ def test_failed_capture
@gateway.expects(:ssl_post).returns(failed_authorization_response)
authorization = '123456INVALID;00000000-0000-0000-0000-00000000000'
- assert response = @gateway.capture(@amount, authorization, :credit_card => @credit_card)
+ assert response = @gateway.capture(@amount, authorization, credit_card: @credit_card)
assert_instance_of Response, response
assert_failure response
end
@@ -188,28 +216,20 @@ def test_unsuccessful_refund
assert response = @gateway.refund(123, '456')
assert_failure response
- assert_equal 'The refund amount exceeds the original transaction amount.', response.message
+ assert_equal 'The amount exceeded the original transaction amount. Amount must be equal or lower than the original transaction amount.', response.message
end
def test_successful_verify
response = stub_comms do
@gateway.verify(@credit_card)
- end.respond_with(successful_authorization_response, successful_void_response)
- assert_success response
- end
-
- def test_successful_verify_failed_void
- response = stub_comms do
- @gateway.verify(@credit_card, @options)
- end.respond_with(successful_authorization_response, failed_void_response)
+ end.respond_with(successful_verify_response)
assert_success response
- assert_equal 'APPROVED', response.message
end
def test_unsuccessful_verify
response = stub_comms do
@gateway.verify(@credit_card, @options)
- end.respond_with(failed_authorization_response, successful_void_response)
+ end.respond_with(failed_verify_response)
assert_failure response
assert_equal 'The Credit Card Number supplied in the authorization request appears to be invalid.', response.message
end
@@ -219,25 +239,25 @@ def test_invalid_login
assert response = @gateway.purchase(@amount, @credit_card, @options)
- assert_equal '7000', response.params['result']
- assert_equal 'The VirtualMerchant ID and/or User ID supplied in the authorization request is invalid.', response.message
+ assert_equal '4025', response.params['errorCode']
+ assert_equal 'The credentials supplied in the authorization request are invalid.', response.message
assert_failure response
end
def test_supported_card_types
- assert_equal [:visa, :master, :american_express, :discover], ElavonGateway.supported_cardtypes
+ assert_equal %i[visa master american_express discover], ElavonGateway.supported_cardtypes
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']
+ assert_equal 'M', 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 'P', response.cvv_result['code']
+ assert_equal 'M', response.cvv_result['code']
end
def test_successful_store
@@ -245,7 +265,7 @@ def test_successful_store
assert response = @gateway.store(@credit_card, @options)
assert_success response
- assert_equal '7595301425001111', response.params['token']
+ assert_equal '4421912014039990', response.params['token']
assert response.test?
end
@@ -279,7 +299,7 @@ def test_stripping_non_word_characters_from_zip
@options[:billing_address][:zip] = bad_zip
- @gateway.expects(:commit).with(anything, anything, has_entries(:avs_zip => stripped_zip), anything)
+ @gateway.expects(:commit).with(includes("#{stripped_zip} "))
@gateway.purchase(@amount, @credit_card, @options)
end
@@ -287,18 +307,222 @@ def test_stripping_non_word_characters_from_zip
def test_zip_codes_with_letters_are_left_intact
@options[:billing_address][:zip] = '.K1%Z_5E3-'
- @gateway.expects(:commit).with(anything, anything, has_entries(:avs_zip => 'K1Z5E3'), anything)
+ @gateway.expects(:commit).with(includes('K1Z5E3 '))
@gateway.purchase(@amount, @credit_card, @options)
end
+ def test_strip_ampersands
+ stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options.merge(shipping_address: { address1: 'Bats & Cats' }))
+ end.check_request do |_endpoint, data, _headers|
+ refute_match(/&/, data)
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_split_full_network_transaction_id
+ oar_data = '010012318808182231420000047554200000000000093840023122123188'
+ ps2000_data = 'A8181831435010530042VE'
+ network_transaction_id = "#{oar_data}|#{ps2000_data}"
+ stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options.merge(stored_credential: { network_transaction_id: network_transaction_id }))
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(/#{oar_data}<\/ssl_oar_data>/, data)
+ assert_match(/#{ps2000_data}<\/ssl_ps2000_data>/, data)
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_oar_only_network_transaction_id
+ oar_data = '010012318808182231420000047554200000000000093840023122123188'
+ ps2000_data = nil
+ network_transaction_id = "#{oar_data}|#{ps2000_data}"
+ stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options.merge(stored_credential: { network_transaction_id: network_transaction_id }))
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(/#{oar_data}<\/ssl_oar_data>/, data)
+ refute_match(//, data)
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_ps2000_only_network_transaction_id
+ oar_data = nil
+ ps2000_data = 'A8181831435010530042VE'
+ network_transaction_id = "#{oar_data}|#{ps2000_data}"
+ stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options.merge(stored_credential: { network_transaction_id: network_transaction_id }))
+ end.check_request do |_endpoint, data, _headers|
+ refute_match(//, data)
+ assert_match(/#{ps2000_data}<\/ssl_ps2000_data>/, data)
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_oar_transaction_id_without_pipe
+ oar_data = '010012318808182231420000047554200000000000093840023122123188'
+ stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options.merge(stored_credential: { network_transaction_id: oar_data }))
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(/#{oar_data}<\/ssl_oar_data>/, data)
+ refute_match(//, data)
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_ps2000_transaction_id_without_pipe
+ ps2000_data = 'A8181831435010530042VE'
+ stub_comms do
+ @gateway.purchase(@amount, @credit_card, @options.merge(stored_credential: { network_transaction_id: ps2000_data }))
+ end.check_request do |_endpoint, data, _headers|
+ refute_match(//, data)
+ assert_match(/#{ps2000_data}<\/ssl_ps2000_data>/, data)
+ end.respond_with(successful_purchase_response)
+ end
+
def test_custom_fields_in_request
stub_comms do
- @gateway.purchase(@amount, @credit_card, @options.merge(:customer_number => '123', :custom_fields => {:a_key => 'a value'}))
- end.check_request do |endpoint, data, headers|
- assert_match(/customer_number=123/, data)
- assert_match(/a_key/, data)
- refute_match(/ssl_a_key/, data)
+ @gateway.purchase(@amount, @credit_card, @options.merge(customer_number: '123', custom_fields: { a_key: 'a value' }))
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(/123<\/ssl_customer_number>/, data)
+ assert_match(/a value<\/a_key>/, data)
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_truncate_special_characters
+ first_name = 'Ricky ™ Martínez įncogníto'
+ credit_card = @credit_card
+ credit_card.first_name = first_name
+
+ stub_comms do
+ @gateway.purchase(@amount, credit_card, @options)
+ end.check_request do |_endpoint, data, _headers|
+ check = 'Ricky ™ Martínez '
+ assert_match(/#{check}/, data)
+ end.respond_with(successful_purchase_response)
+ end
+
+ def test_level_3_fields_in_request
+ level_3_data = {
+ customer_code: 'bob',
+ salestax: '3.45',
+ salestax_indicator: 'Y',
+ level3_indicator: 'Y',
+ ship_to_zip: '12345',
+ ship_to_country: 'US',
+ shipping_amount: '1234',
+ ship_from_postal_code: '54321',
+ discount_amount: '5',
+ duty_amount: '2',
+ national_tax_indicator: '0',
+ national_tax_amount: '10',
+ order_date: '280810',
+ other_tax: '3',
+ summary_commodity_code: '123',
+ merchant_vat_number: '222',
+ customer_vat_number: '333',
+ freight_tax_amount: '4',
+ vat_invoice_number: '26',
+ tracking_number: '45',
+ shipping_company: 'UFedzon',
+ other_fees: '2',
+ line_items: [
+ {
+ description: 'thing',
+ product_code: '23',
+ commodity_code: '444',
+ quantity: '15',
+ unit_of_measure: 'kropogs',
+ unit_cost: '4.5',
+ discount_indicator: 'Y',
+ tax_indicator: 'Y',
+ discount_amount: '1',
+ tax_rate: '8.25',
+ tax_amount: '12',
+ tax_type: 'state',
+ extended_total: '500',
+ total: '525',
+ alternative_tax: '111'
+ },
+ {
+ description: 'thing2',
+ product_code: '23',
+ commodity_code: '444',
+ quantity: '15',
+ unit_of_measure: 'kropogs',
+ unit_cost: '4.5',
+ discount_indicator: 'Y',
+ tax_indicator: 'Y',
+ discount_amount: '1',
+ tax_rate: '8.25',
+ tax_amount: '12',
+ tax_type: 'state',
+ extended_total: '500',
+ total: '525',
+ alternative_tax: '111'
+ }
+ ]
+ }
+
+ options = @options.merge(level_3_data: level_3_data)
+ stub_comms do
+ @gateway.purchase(@amount, @credit_card, options)
+ end.check_request do |_endpoint, data, _headers|
+ assert_match(/bob/, data)
+ assert_match(/3.45/, data)
+ assert_match(/Y/, data)
+ assert_match(/Y/, data)
+ assert_match(/12345/, data)
+ assert_match(/US/, data)
+ assert_match(/1234/, data)
+ assert_match(/54321/, data)
+ assert_match(/